@veltdev/sdk-dev 6.0.12 → 6.0.14-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/models/data/config.data.model.d.ts +18 -0
- package/app/models/data/user.data.model.d.ts +13 -0
- package/app/models/element/comment-element.model.d.ts +3 -2
- package/app/utils/constants.d.ts +1 -0
- package/{chunk-4RMON7GG.js → chunk-2HGCWC7B.js} +1 -1
- package/{chunk-PK5KF67H.js → chunk-2KTYC2AG.js} +1 -1
- package/chunk-3AL5S762.js +1 -0
- package/chunk-45X5JRZ6.js +2 -0
- package/chunk-5O7VYDEF.js +1 -0
- package/chunk-6NWFM6PC.js +1 -0
- package/chunk-77FADRSO.js +1 -0
- package/chunk-7TFVNMHJ.js +2 -0
- package/{chunk-AFUKEZ7H.js → chunk-C5JOX4MX.js} +1 -1
- package/{chunk-KTSX5UPA.js → chunk-DFEL6HM7.js} +1 -1
- package/{chunk-MUYDAXFY.js → chunk-DZYXTTOX.js} +1 -1
- package/chunk-FZSZ6AV3.js +1 -0
- package/chunk-GULBDPIM.js +2 -0
- package/{chunk-PA223C5M.js → chunk-HRCWTVRH.js} +2 -2
- package/{chunk-WAENSDSI.js → chunk-I63T4QWP.js} +6 -6
- package/{chunk-UI5F5IQU.js → chunk-IMH5OESK.js} +1 -1
- package/chunk-IQ22I2I3.js +1 -0
- package/{chunk-UW45SPLT.js → chunk-KNQJBBQA.js} +1 -1
- package/chunk-KQPNTB77.js +1 -0
- package/chunk-KWLMOL5X.js +193 -0
- package/chunk-L4QMAEKA.js +1 -0
- package/chunk-MRY4A7N6.js +1 -0
- package/{chunk-7WO33FST.js → chunk-NMPXJFDX.js} +1 -1
- package/chunk-O3FUWWWQ.js +1 -0
- package/{chunk-2TTZAEAX.js → chunk-PWTBCAPJ.js} +1 -1
- package/chunk-TQNLXTQA.js +2 -0
- package/chunk-UI2CRSTN.js +1 -0
- package/{chunk-S5R4NUEK.js → chunk-UVKIGEOH.js} +1 -1
- package/{chunk-452RZXIL.js → chunk-VJLHHQ2Z.js} +1 -1
- package/chunk-VW5ND7U4.js +93 -0
- package/{chunk-E3EMSLLD.js → chunk-WMDZMDJS.js} +1 -1
- package/chunk-YFBAHLK6.js +174 -0
- package/chunk-YO4HNOAN.js +1 -0
- package/chunk-ZHXLO4CC.js +1 -0
- package/package.json +1 -1
- package/velt-activity-log.js +1 -1
- package/velt-area.js +1 -1
- package/velt-arrow.js +1 -1
- package/velt-comment.js +7 -7
- package/velt-crdt.js +1 -1
- package/velt-cursor.js +1 -1
- package/velt-huddle.js +1 -1
- package/velt-live-state-sync.js +1 -1
- package/velt-notification.js +1 -1
- package/velt-portable.js +1 -0
- package/velt-presence.js +1 -1
- package/velt-reaction.js +1 -1
- package/velt-recorder.js +1 -1
- package/velt-rewriter.js +1 -1
- package/velt-selection.js +1 -1
- package/velt-tag.js +1 -1
- package/velt-user-invite.js +1 -1
- package/velt-user-request.js +1 -1
- package/velt-video-player.js +1 -1
- package/velt-views.js +3 -3
- package/velt.js +6 -6
- package/chunk-3KTIE7HV.js +0 -2
- package/chunk-3T4C47NJ.js +0 -1
- package/chunk-3V7E3J4J.js +0 -1
- package/chunk-4WJ3D7LP.js +0 -2
- package/chunk-5XTTHBPR.js +0 -2
- package/chunk-GOWYFEFT.js +0 -1
- package/chunk-I3SH43LO.js +0 -193
- package/chunk-K4B6RFWX.js +0 -1
- package/chunk-KQMIVRAC.js +0 -1
- package/chunk-KR2SHB2N.js +0 -1
- package/chunk-NDVI33K6.js +0 -1
- package/chunk-NLQIZD74.js +0 -1
- package/chunk-NMIHVV2J.js +0 -1
- package/chunk-OERYTVQK.js +0 -2
- package/chunk-OGANPKOK.js +0 -93
- package/chunk-OW3IOAXY.js +0 -1
- package/chunk-QPKP4WS7.js +0 -1
- package/chunk-XY4SLOOP.js +0 -1
- package/chunk-Z3CHFM5M.js +0 -167
package/velt-portable.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$i as T,Vi as W,Yd as o,Zi as O,_i as p,a as b,aj as M,c as _,g as m,l as C,qj as q,sj as L}from"./chunk-YFBAHLK6.js";var B=["hello","subscribe","unsubscribe","publish","presence","onDisconnect","onDisconnectCancel","ping"],H=["welcome","snapshot","delta","result","error","pong"],J=[...B,...H],y=3e4,D=2,k=2e4,I=1e3,N=3e4,x=1;function v(i){if(typeof i!="string")return NaN;let e=Number(i.split(".")[0]);return Number.isInteger(e)?e:NaN}function g(i){try{let e=i.apiKey??"",s=i.instanceId?`${i.feature}/${i.instanceId}`:i.feature;switch(i.scope){case"doc":return`${e}:${i.organizationId??""}:doc:${i.documentId??""}:${s}`;case"user":return i.organizationId?`${e}:${i.organizationId}:user:${i.userIdHash??""}:${s}`:`${e}:user:${i.userIdHash??""}:${s}`;case"org":return`${e}:${i.organizationId??""}:${s}`;default:return`${e}:${s}`}}catch(e){return o.catch("Error in buildPortableWireKey: ",e),`${i?.apiKey??""}:${i?.feature??""}`}}var V={presence:"updatePresence",liveState:"publishLiveState",cursor:"updateCursor",selection:"updateSelection",huddle:"updateHuddle",syncVideoPlayer:"updateSyncVideoPlayer",flockSession:"updateFlock"};function U(i,e){if(i==="crdt"){let s=e?.uptoSeq;return Number.isInteger(s)?"writeCrdtSnapshot":"writeCrdtUpdate"}return V[i]}var P=class{constructor(e){this.session=e}whenReady(){return new Promise(e=>{try{let s=!1,t=null,n=null,r=()=>{s||(s=!0,n!==null&&(clearTimeout(n),n=null),setTimeout(()=>{try{t?.unsubscribe()}catch{}},0),e())};n=setTimeout(r,k),t=this.session.getAuthState$().subscribe(a=>{a?.signedIn&&r()})}catch(s){o.catch("Error in PortableRealtimeAdapter whenReady: ",s),e()}})}subscribe(e,s,t,n){try{let r=this.session.getTransport();if(!r)return{unsubscribe:()=>{}};let a=g(e),l=!1,c=r.subscribeChannel(a,s,d=>{try{if(d.kind==="denied"){o.catch(`Velt [portable backend]: subscribe denied on channel ${a}: ${d.code??"unknown"}${L(d)}`,b({ok:!1,code:d.code},d.reasonCode?{reasonCode:d.reasonCode}:{})),n?.onError&&!l&&(l=!0,n.onError(d.code??"permission-denied"));return}if(d.kind==="delta"){t({type:d.change??"modified",id:d.id??"",data:d.data,seq:d.seq});return}if(d.kind==="snapshot-end"){n?.onSnapshotComplete?.();return}t({type:"added",id:d.id??"",data:d.data})}catch(h){o.catch("Error in PortableRealtimeAdapter subscribe callback: ",h)}},n?.since);return{unsubscribe:()=>c.unsubscribe()}}catch(r){return o.catch("Error in PortableRealtimeAdapter subscribe: ",r),{unsubscribe:()=>{}}}}publish(e,s,t){try{let n=U(e.feature,t);if(!n)return Promise.resolve({ok:!1,code:"unimplemented",message:`no realtime publish operation for feature '${e.feature}'`});let r=this.session.getTransport();return r?r.request("publish",g(e),n,t):Promise.resolve({ok:!1,code:"failed-precondition",message:"portable transport not connected"})}catch(n){return o.catch("Error in PortableRealtimeAdapter publish: ",n),Promise.resolve({ok:!1,code:"failed-precondition"})}}presence(e,s){try{let t=this.session.getTransport();return t?t.request("presence",g(e),"updatePresence",s):Promise.resolve({ok:!1,code:"failed-precondition",message:"portable transport not connected"})}catch(t){return o.catch("Error in PortableRealtimeAdapter presence: ",t),Promise.resolve({ok:!1,code:"failed-precondition"})}}onDisconnect(e,s){return m(this,null,function*(){try{let t=this.session.getTransport();return t?yield t.registerOnDisconnect(g(e),s):()=>{}}catch(t){return o.catch("Error in PortableRealtimeAdapter onDisconnect: ",t),()=>{}}})}getServerTimeOffset(){try{return Promise.resolve(this.session.getTransport()?.getServerTimeOffset()??0)}catch(e){return o.catch("Error in PortableRealtimeAdapter getServerTimeOffset: ",e),Promise.resolve(0)}}onServerTimeOffset(e){try{return this.session.getTransport()?.onServerTimeOffset(e)??(()=>{})}catch(s){return o.catch("Error in PortableRealtimeAdapter onServerTimeOffset: ",s),()=>{}}}};var S=class{constructor(e,s){this.rest=e,this.session=s}read(e){return m(this,null,function*(){let s=yield this.rest.call("read",e);return s.ok?{data:s.data}:{data:void 0,errorCode:s.code}})}runTransaction(e){return e()}op(e,s){if(s&&typeof s=="object"&&"channel"in s){let t=s,{channel:n}=t,r=_(t,["channel"]);return this.rest.call(e,r)}return this.rest.call(e,s)}publishOp(e,s,t){if(!s.channel)return Promise.resolve({ok:!1,code:"failed-precondition",message:`portable publish op '${e}' requires a channel on the OperationRequest`});let n=this.session?.getTransport();return n?n.request("publish",g(s.channel),e,t):Promise.resolve({ok:!1,code:"failed-precondition",message:"portable transport not connected"})}notificationWirePayload(e,s){let t=e.resourceId??(typeof e.data?.notificationId=="string"?e.data.notificationId:void 0),n={};if(t!=null&&String(t).length>0&&(n.notificationId=String(t)),s&&e.data!==void 0){let r=e.data;r&&typeof r=="object"&&r.data!==void 0&&r.notificationId!==void 0?n.data=r.data:n.data=e.data}return n}annotationWirePayload(e,s,t=!1){let n=e.resourceId??(typeof e.data?.annotationId=="string"?e.data.annotationId:void 0),r={};return n!=null&&String(n).length>0&&(r.annotationId=String(n)),s&&e.data!==void 0&&(r.data=e.data),t&&e.notificationData!==void 0&&(r.notificationData=e.notificationData),r}addComment(e){return this.publishOp("addComment",e,this.annotationWirePayload(e,!0,!0))}editComment(e){return this.publishOp("editComment",e,this.annotationWirePayload(e,!0))}deleteComment(e){return this.publishOp("deleteComment",e,this.annotationWirePayload(e,!1))}addReaction(e){return this.publishOp("addReaction",e,this.annotationWirePayload(e,!0))}editReaction(e){return this.publishOp("editReaction",e,this.annotationWirePayload(e,!0))}deleteReaction(e){return this.publishOp("deleteReaction",e,this.annotationWirePayload(e,!1))}recordDocumentView(e){return this.publishOp("recordDocumentView",e,{})}getActivitiesForDocuments(e){return this.rest.call("getActivitiesForDocuments",e.data)}getActivitiesForEntity(e){return this.rest.call("getActivitiesForEntity",e.data)}setCommentResolved(e){return this.op("setCommentResolved",e)}setCommentMetadata(e){return this.op("setCommentMetadata",e)}bumpCommentViews(e){return this.op("bumpCommentViews",e)}markCommentThreadRead(e){return this.publishOp("markCommentThreadRead",e,this.notificationWirePayload(e,!1))}markNotificationRead(e){return this.publishOp("markNotificationRead",e,this.notificationWirePayload(e,!1))}addNotification(e){return this.op("addNotification",e)}deleteNotification(e){return this.publishOp("deleteNotification",e,this.notificationWirePayload(e,!1))}updateNotification(e){return this.publishOp("updateNotification",e,this.notificationWirePayload(e,!0))}updatePresence(e){return this.op("updatePresence",e)}grantAccess(e){return this.op("grantAccess",e)}revokeAccess(e){return this.rest.call("revokeAccess",{data:e.data})}getAccess(e){return this.rest.call("getAccess",{data:e.data})}upsertOrgUserProfile(e){return this.rest.call("addUserInfoToOrganization",e.data)}upsertDocMetadata(e){return this.op("upsertDocMetadata",e)}upsertOrgMetadata(e){return this.op("upsertOrgMetadata",e)}createActivity(e){return this.rest.call("createActivity",e.data)}};var K={fetch:(i,e)=>fetch(i,e)},F={400:"invalid-argument",401:"unauthenticated",403:"permission-denied",404:"not-found",412:"failed-precondition",429:"resource-exhausted"};function j(i){return!!i&&typeof i=="object"&&typeof i.ok=="boolean"}var w=class{constructor(e){this.session=e,this.insecureEndpointReported=new Set}call(e,s){return m(this,null,function*(){try{let t=this.session.getApiEndpoint(),n=this.session.getToken();if(!t||!n)return{ok:!1,code:"failed-precondition",message:"portable session not established"};if(!W(t))return this.insecureEndpointReported.has(t)||(this.insecureEndpointReported.add(t),console.error(`Velt [portable backend]: refusing to send the session token to insecure apiEndpoint '${t}' (https required; http is loopback-only). Portable REST operations are disabled until identify returns a secure endpoint.`)),{ok:!1,code:"failed-precondition",message:"portable apiEndpoint is not a secure URL; request not sent"};let r=yield K.fetch(`${t}/operations/${e}`,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify(s??{})}),a;try{a=yield r.json()}catch{a=void 0}if(j(a)){if(a.ok)return r.ok?a:{ok:!1,code:F[r.status]??"permission-denied",message:`HTTP ${r.status} on operation '${e}' contradicted an ok:true envelope`};let c=a.code;return c&&M.includes(c)?a:{ok:!1,code:"permission-denied",message:`unrecognized denial code '${c}'`}}return r.ok?{ok:!0,data:a}:{ok:!1,code:F[r.status]??"permission-denied",message:`HTTP ${r.status} on operation '${e}'`}}catch(t){return o.catch(`Error in PortableRestClient call '${e}': `,t),{ok:!1,code:"permission-denied",message:"portable operation request failed"}}})}};function z(i){if(!i)return!1;try{let e=new URL(i);return e.protocol==="wss:"?!0:e.protocol==="ws:"&&["localhost","127.0.0.1","[::1]"].includes(e.hostname)}catch{return!1}}var E=class{constructor(e){this.transportFactory=e,this.token=null,this.wsEndpoint=null,this.apiEndpoint=null,this.transport=null,this.authState$=new C(null),this.nullTokenWarned=!1,this.insecureEndpointWarned=!1,this.offOffset=null,this.offTerminal=null}establish(e){try{if(!e)return;if(this.wsEndpoint=e.wsEndpoint??null,this.apiEndpoint=e.apiEndpoint??null,this.token=typeof e.token=="string"&&e.token.length>0?e.token:null,!this.token){this.transport&&this.teardown(),this.nullTokenWarned||(this.nullTokenWarned=!0,console.warn("Velt [portable backend]: identify() returned no session token (token: null). Portable transport will not connect on this page load; portable features are disabled."));return}if(!z(this.wsEndpoint)){this.transport&&this.teardown(),this.insecureEndpointWarned||(this.insecureEndpointWarned=!0,console.warn("Velt [portable backend]: refusing to connect to a non-wss:// gateway endpoint ("+this.wsEndpoint+"). The session token would travel in cleartext; portable features are disabled. (Plain ws:// is permitted for localhost only.)"));return}this.transport||(this.transport=this.transportFactory(this),this.offOffset=this.transport.onServerTimeOffset(()=>{this.authState$.value?.signedIn||this.authState$.next({signedIn:!0})}),this.offTerminal=this.transport.onTerminal(()=>{this.authState$.value!==null&&this.authState$.next(null)})),this.transport.connect()}catch(s){o.catch("Error in PortableSession establish: ",s)}}refreshToken(e){try{if(typeof e!="string"||!e.length)return;this.token=e,this.transport?.refreshAuth()}catch(s){o.catch("Error in PortableSession refreshToken: ",s)}}teardown(){try{this.offOffset?.(),this.offOffset=null,this.offTerminal?.(),this.offTerminal=null,this.transport?.close(),this.transport=null,this.authState$.value!==null&&this.authState$.next(null)}catch(e){o.catch("Error in PortableSession teardown: ",e)}}getToken(){return this.token}getWsEndpoint(){return this.wsEndpoint}getApiEndpoint(){return this.apiEndpoint}getTransport(){return this.transport}getAuthState$(){return this.authState$.asObservable()}};var f=1,R=class{constructor(e){this.deps=e,this.state="idle",this.socket=null,this.channels=new Map,this.pendingRequests=new Map,this.nextRequestId=1,this.serverTimeOffsetMs=0,this.offsetListeners=new Set,this.lastInboundAtMs=0,this.heartbeatTimer=null,this.pongDeadlineTimer=null,this.reconnectTimer=null,this.reconnectAttempts=0,this.authRecoveryAttempts=0,this.terminalListeners=new Set}onTerminal(e){return this.terminalListeners.add(e),()=>{this.terminalListeners.delete(e)}}notifyTerminal(e){this.terminalListeners.forEach(s=>{try{s(e)}catch(t){o.catch("Error in PortableWsTransport terminal listener: ",t)}})}getState(){return this.state}connect(){try{if(this.state==="connecting"||this.state==="open"||this.state==="reauthing"||this.state==="unsupported")return;let e=this.deps.getUrl(),s=this.deps.getToken();if(!e||!s)return;this.state="connecting";let t=this.deps.wsFactory(e);this.socket=t,t.onopen=()=>this.onSocketOpen(t),t.onmessage=n=>this.onFrame(t,n.data),t.onclose=()=>this.onSocketClosed(t),t.onerror=()=>{}}catch(e){o.catch("Error in PortableWsTransport connect: ",e)}}close(){try{this.state="closed",this.notifyTerminal("closed"),this.clearTimers();let e=this.socket;this.socket=null,e&&e.readyState<=f&&e.close(1e3,"client close"),this.failPendingRequests()}catch(e){o.catch("Error in PortableWsTransport close: ",e)}}checkLivenessOnResume(e=y*2){try{if(this.state!=="open"&&this.state!=="reauthing")return;let s=this.lastInboundAtMs?this.now()-this.lastInboundAtMs:Number.POSITIVE_INFINITY;if(s<=e)return;p("liveness.stale-on-resume",`silentFor=${Math.round(s/1e3)}s state=${this.state}`),T("the realtime connection was silent while the tab was in the background","Nothing had been received for longer than two heartbeats when this tab came back, so the connection is treated as dead and re-established. Data shown before this point may have been stale \u2014 the UI keeps what it already had, so this is invisible without this message."),this.handleDeadSocket()}catch(s){o.catch("Error in PortableWsTransport checkLivenessOnResume: ",s)}}refreshAuth(){try{if(this.state==="open"&&this.socket&&this.socket.readyState===f){this.state="reauthing",this.sendHello();return}(this.state==="closed"||this.state==="idle")&&(this.state="idle",this.connect())}catch(e){o.catch("Error in PortableWsTransport refreshAuth: ",e)}}subscribeChannel(e,s,t,n){let r=this.ensureChannel(e,s),a={onEvent:t,active:!0};if(r.subscribers.add(a),r.lastSeq===void 0&&typeof n=="number"&&(r.lastSeq=n),r.hasState){for(let[l,c]of r.lastKnown)try{a.onEvent({kind:"snapshot-item",id:l,data:c})}catch(d){o.catch("Error in PortableWsTransport cached-state replay: ",d)}try{a.onEvent({kind:"snapshot-end"})}catch(l){o.catch("Error in PortableWsTransport cached-state snapshot-end: ",l)}}return this.wireSubscribeIfNeeded(e,r),{unsubscribe:()=>{try{if(!a.active)return;a.active=!1,r.subscribers.delete(a),r.subscribers.size===0&&(this.clearSnapshotWatchdog(r),this.channels.delete(e),r.wired&&this.socket&&this.socket.readyState===f&&this.sendFrame({type:"unsubscribe",channel:e,requestId:`r${this.nextRequestId++}`}))}catch(l){o.catch("Error in PortableWsTransport unsubscribe: ",l)}}}}request(e,s,t,n){try{if(this.state!=="open"&&this.state!=="reauthing")return Promise.resolve({ok:!1,code:"failed-precondition",message:"portable transport not connected"});let r=`r${this.nextRequestId++}`,a=new Promise(d=>{this.pendingRequests.set(r,d)}),l={type:e,channel:s,op:t,requestId:r};e==="presence"?l.state=n:l.payload=n;let c=!1;try{c=this.sendFrame(l)}catch(d){throw this.pendingRequests.delete(r),d}return c?a:(this.pendingRequests.delete(r),Promise.resolve({ok:!1,code:"failed-precondition",message:"portable transport not connected"}))}catch(r){return o.catch("Error in PortableWsTransport request: ",r),Promise.resolve({ok:!1,code:"failed-precondition",message:"portable transport send failed"})}}registerOnDisconnect(e,s){return m(this,null,function*(){if(this.state!=="open"&&this.state!=="reauthing")return()=>{};let t=`r${this.nextRequestId++}`,n=new Promise(c=>{this.pendingRequests.set(t,c)}),r=!1;try{r=this.sendFrame({type:"onDisconnect",channel:e,cleanup:s,requestId:t})}catch(c){return this.pendingRequests.delete(t),o.catch("Error in PortableWsTransport registerOnDisconnect send: ",c),()=>{}}if(!r)return this.pendingRequests.delete(t),()=>{};let a=yield n,l=a.ok?a.id:void 0;return()=>{try{l&&this.socket&&this.socket.readyState===f&&this.sendFrame({type:"onDisconnectCancel",intentId:l,requestId:`r${this.nextRequestId++}`})}catch(c){o.catch("Error in PortableWsTransport onDisconnect cancel: ",c)}}})}getServerTimeOffset(){return this.serverTimeOffsetMs}onServerTimeOffset(e){return this.offsetListeners.add(e),()=>this.offsetListeners.delete(e)}now(){return this.deps.now?this.deps.now():Date.now()}ensureChannel(e,s){let t=this.channels.get(e);return t||(t={mode:s,subscribers:new Set,lastSeq:void 0,denied:!1,wired:!1,snapshotWatchdog:null,lastKnown:new Map,hasState:!1,resumeRequested:!1},this.channels.set(e,t)),t}wireSubscribeIfNeeded(e,s){if(s.wired||s.denied||this.state!=="open"&&this.state!=="reauthing"||!this.socket||this.socket.readyState!==f)return;let t={type:"subscribe",channel:e,mode:s.mode,requestId:`r${this.nextRequestId++}`};s.resumeRequested=!1,s.mode==="persistent"&&s.lastSeq!==void 0&&(t.since=s.lastSeq,s.resumeRequested=!0);try{s.wired=this.sendFrame(t),s.wired&&(p("channel.subscribe",`${e}${t.since!==void 0?" since="+t.since:" (full)"}`),this.armSnapshotWatchdog(e,s))}catch(n){o.catch("Error in PortableWsTransport wireSubscribeIfNeeded: ",n)}}sendHello(){this.sendFrame({type:"hello",protocolVersion:"1.0",token:this.deps.getToken(),capabilities:[]})}sendFrame(e){return!this.socket||this.socket.readyState!==f?!1:(this.socket.send(JSON.stringify(e)),!0)}onSocketOpen(e){e===this.socket&&(p("socket.open"),this.sendHello())}onWelcome(e){let s=v(e.protocolVersion),t=v("1.0");if(s!==t){this.state!=="unsupported"&&console.error(`Velt [portable backend]: gateway speaks WS protocol '${e.protocolVersion}' but this SDK speaks '${"1.0"}' (incompatible MAJOR). Portable features are disabled. Align the deployed gateway and SDK versions (see docs/self-hosting-portable-protocol.md).`),this.state="unsupported",this.notifyTerminal("unsupported"),this.clearTimers();try{this.socket?.close(1e3,"protocol-version")}catch{}this.socket=null;return}let n=this.state==="reauthing";if(p("handshake.welcome",`reauth=${n}`),this.state="open",this.reconnectAttempts=0,typeof e.serverTimeMs=="number"){this.serverTimeOffsetMs=e.serverTimeMs-this.now();for(let r of this.offsetListeners)try{r(this.serverTimeOffsetMs)}catch(a){o.catch("Error in PortableWsTransport offset listener: ",a)}}if(this.startHeartbeat(),!n)for(let[r,a]of this.channels)a.wired=!1,this.wireSubscribeIfNeeded(r,a)}onFrame(e,s){if(e!==this.socket)return;this.lastInboundAtMs=this.now();let t;try{t=JSON.parse(s)}catch{o.log("Velt [portable backend]: dropped unparseable WS frame");return}try{switch(t.type){case"welcome":this.onWelcome(t);return;case"pong":this.clearPongDeadline(),O("pong"),this.authRecoveryAttempts=0;return;case"delta":{let n=this.channels.get(t.channel);if(!n)return;typeof t.seq=="number"&&(n.lastSeq=t.seq),n.hasState=!0,t.change==="removed"?n.lastKnown.delete(t.id):t.id!==void 0&&n.lastKnown.set(t.id,t.data),this.emit(n,{kind:"delta",change:t.change,id:t.id,data:t.data,seq:t.seq});return}case"snapshot":{let n=this.channels.get(t.channel);if(!n)return;this.clearSnapshotWatchdog(n),p("channel.snapshot",`${t.channel} items=${Array.isArray(t.items)?t.items.length:"?"}${t.full?" full":""}${t.truncated?" truncated":""}`),typeof t.seq=="number"&&(n.lastSeq=t.seq);let r=Array.isArray(t.items)?t.items:[],a=t.truncated===!0,l=!a&&(t.full===!0||!n.resumeRequested);if(n.hasState=!0,a){for(let c of r)c?.id!==void 0&&n.lastKnown.set(c.id,c?.data),this.emit(n,{kind:"snapshot-item",id:c?.id,data:c?.data});this.emit(n,{kind:"snapshot-end"})}else if(l){let c=new Set;for(let h of r)h?.id!==void 0&&c.add(h.id);let d=[];for(let h of n.lastKnown.keys())c.has(h)||d.push(h);n.lastKnown.clear();for(let h of d)this.emit(n,{kind:"delta",change:"removed",id:h,data:void 0});for(let h of r)h?.id!==void 0&&n.lastKnown.set(h.id,h?.data),this.emit(n,{kind:"snapshot-item",id:h?.id,data:h?.data});this.emit(n,{kind:"snapshot-end"})}else{for(let c of r)c?.id!==void 0&&(c.data===void 0?(n.lastKnown.delete(c.id),this.emit(n,{kind:"delta",change:"removed",id:c.id,data:void 0})):(n.lastKnown.set(c.id,c.data),this.emit(n,{kind:"snapshot-item",id:c.id,data:c.data})));this.emit(n,{kind:"snapshot-end"})}return}case"result":{let n=this.pendingRequests.get(t.requestId);if(!n){o.log(`Velt [portable backend]: uncorrelated result frame (requestId ${t.requestId}, ok=${!!t.ok}${t.code?`, code=${t.code}`:""}) \u2014 no pending request. Expected for unsubscribe / onDisconnectCancel, which are fire-and-forget.`);return}this.pendingRequests.delete(t.requestId),t.ok?n(b({ok:!0,id:t.id,data:t.data},typeof t.seq=="number"?{seq:t.seq}:{})):n(b({ok:!1,code:t.code??"permission-denied",message:t.message},typeof t.reasonCode=="string"?{reasonCode:t.reasonCode}:{}));return}case"error":{let n=t.channel;if(n&&this.channels.has(n)){let r=this.channels.get(n);r.denied=!0,r.wired=!1,this.emit(r,{kind:"denied",code:t.code,reasonCode:t.reasonCode});return}if(t.requestId&&this.pendingRequests.has(t.requestId)){let r=this.pendingRequests.get(t.requestId);this.pendingRequests.delete(t.requestId),r(b({ok:!1,code:t.code??"permission-denied"},typeof t.reasonCode=="string"?{reasonCode:t.reasonCode}:{}));return}if(t.code==="unauthenticated"){if(this.state==="open"&&this.authRecoveryAttempts<x){this.authRecoveryAttempts++,console.warn("Velt [portable backend]: the gateway dropped an authenticated session (unauthenticated on a live connection). Reconnecting once to re-establish it."),this.clearHeartbeat();let a=this.socket;this.socket=null;try{a&&a.readyState<=f&&a.close(4401,"session-lost")}catch{}this.failPendingRequests(),this.markAllChannelsUnwired(),this.scheduleReconnect();return}console.warn("Velt [portable backend]: the gateway rejected authentication. Portable transport is fail-closed for this session; a fresh identify()/token is required to reconnect."),this.state="closed",this.notifyTerminal("closed"),this.clearTimers();let r=this.socket;this.socket=null;try{r&&r.readyState<=f&&r.close(4401,"unauthenticated")}catch{}this.failPendingRequests();return}return}default:return}}catch(n){o.catch("Error in PortableWsTransport onFrame: ",n)}}emit(e,s){for(let t of e.subscribers)if(t.active)try{t.onEvent(s)}catch(n){o.catch("Error in PortableWsTransport subscriber callback: ",n)}}onSocketClosed(e){p("socket.close",`stale=${e!==this.socket} state=${this.state}`),e===this.socket&&(this.socket=null,this.clearTimers(),this.failPendingRequests(),!(this.state==="closed"||this.state==="unsupported")&&(this.markAllChannelsUnwired(),this.scheduleReconnect()))}markAllChannelsUnwired(){for(let e of this.channels.values())e.wired=!1}failPendingRequests(){for(let[,e]of this.pendingRequests)e({ok:!1,code:"failed-precondition",message:"portable transport disconnected"});this.pendingRequests.clear()}scheduleReconnect(){if(this.reconnectTimer)return;this.state="reconnecting";let e=Math.min(N,I*Math.pow(2,this.reconnectAttempts)),s=Math.max(I,e*(.5+Math.random()*.5));this.reconnectAttempts++,this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.state==="reconnecting"&&(this.state="idle",this.connect())},s)}startHeartbeat(){this.clearHeartbeat(),this.heartbeatTimer=setInterval(()=>{try{if(this.state!=="open"&&this.state!=="reauthing")return;if(!this.socket||this.socket.readyState!==f){p("socket.dead-without-close",`state=${this.state} readyState=${this.socket?this.socket.readyState:"no-socket"}`),T("the realtime socket stopped without reporting it (recovering)","The connection was closed by the browser or the network without delivering a close event \u2014 most often a backgrounded/frozen tab. The SDK is reconnecting; if realtime features stay stuck after this, the reconnect is the thing to look at."),this.handleDeadSocket();return}O("ping"),this.sendFrame({type:"ping"}),this.armPongDeadline()}catch(e){o.catch("Error in PortableWsTransport heartbeat: ",e)}},y)}handleDeadSocket(){try{let e=this.socket;this.socket=null,this.clearHeartbeat(),this.clearPongDeadline();try{e?.close(4e3,"socket dead without close event")}catch{}this.failPendingRequests(),this.markAllChannelsUnwired(),this.state!=="closed"&&this.state!=="unsupported"&&this.scheduleReconnect()}catch(e){o.catch("Error in PortableWsTransport handleDeadSocket: ",e)}}armSnapshotWatchdog(e,s){this.clearSnapshotWatchdog(s),s.snapshotWatchdog=setTimeout(()=>{s.snapshotWatchdog=null,p("channel.snapshot-missing",`${e} after ${k}ms`),T("a realtime channel was subscribed but never delivered its first snapshot","Anything waiting on that first emission \u2014 a sidebar skeleton, an empty comment list \u2014 will stay in its loading state. The trail below shows whether the socket handshook, whether the credential was refreshed, and how long the tab was away.",`snapshot-missing:${e}`)},k)}clearSnapshotWatchdog(e){e?.snapshotWatchdog&&(clearTimeout(e.snapshotWatchdog),e.snapshotWatchdog=null)}armPongDeadline(){this.pongDeadlineTimer||(this.pongDeadlineTimer=setTimeout(()=>{this.pongDeadlineTimer=null;let e=this.socket;this.socket=null,this.clearHeartbeat();try{e?.close(4e3,"pong timeout")}catch{}this.failPendingRequests();for(let s of this.channels.values())s.wired=!1;this.state!=="closed"&&this.state!=="unsupported"&&this.scheduleReconnect()},y*D))}clearPongDeadline(){this.pongDeadlineTimer&&(clearTimeout(this.pongDeadlineTimer),this.pongDeadlineTimer=null)}clearHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.clearPongDeadline()}clearTimers(){this.clearHeartbeat();for(let e of this.channels.values())this.clearSnapshotWatchdog(e);this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}};var u=null,A=null;function Y(){try{u?.teardown()}catch{}}function Ae(){try{u?.getTransport()?.checkLivenessOnResume()}catch(i){o.catch("Error in checkPortableBackendLiveness: ",i)}}function Oe(){Y(),u=null,A=null}function G(i){let e=!u;if(u||(u=new E(s=>new R({wsFactory:t=>new WebSocket(t),getUrl:()=>s.getWsEndpoint(),getToken:()=>s.getToken()}))),i?.token&&u.getToken()&&u.getTransport()?u.refreshToken(i.token):u.establish(i),e){let s=new w(u);A={db:new S(s,u),realtime:new P(u)}}return A&&q(A),u}export{Ae as checkPortableBackendLiveness,G as default,Oe as resetPortableBackendEntryForTest,Y as teardownPortableBackend};
|
package/velt-presence.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as K}from"./chunk-NDVI33K6.js";import"./chunk-E3EMSLLD.js";import{D as Jt,F as A,G as N}from"./chunk-KR2SHB2N.js";import{a as Be}from"./chunk-OW3IOAXY.js";import{b as ve,c as Je,d as re}from"./chunk-3KTIE7HV.js";import{a as Vt}from"./chunk-4RMON7GG.js";import{a as Gt}from"./chunk-GOWYFEFT.js";import{a as It}from"./chunk-3V7E3J4J.js";import{D as _t,F as yt,Fa as f,Ga as We,Ha as $,Ia as ze,s as Ct}from"./chunk-WAENSDSI.js";import{$ as ae,Db as vt,Df as xt,Di as jt,E as Y,Eb as pt,Ed as bt,Ee as p,Ef as Ut,Fa as l,Fb as dt,Fc as ft,Fh as E,G as ot,Ga as he,Gc as D,I as He,Ib as te,Ii as $t,J as ke,Jb as ut,Ji as Bt,Kb as Re,L as Ke,Lc as Le,Le as rt,M as Qe,Md as Et,Nb as se,Nd as Pt,Nh as Nt,Ob as Me,Oh as wt,Pa as m,Pb as ht,Pc as St,Ph as Ft,Q as at,Ra as ct,Ri as Wt,Si as zt,T as W,Ta as lt,Ua as x,Uf as Tt,Va as mt,W as H,Wf as me,X as Ze,Ya as U,_a as g,_b as j,a as C,aa as st,b as w,bc as _,ca as P,cc as b,db as gt,dc as tt,de as nt,dg as Ot,fc as k,ff as it,g as oe,ha as De,ia as Ae,k as Xe,kc as ce,l as ue,lb as c,lc as le,li as Rt,mb as T,mi as ge,nb as O,ni as v,ob as R,oe as X,oi as Mt,pc as ne,pg as kt,ph as Dt,qa as Ne,r as F,sb as d,si as Lt,tb as u,th as At,ua as we,ub as Fe,v as L,vb as qe,vi as je,wa as I,wi as $e,xb as et,zb as s}from"./chunk-Z3CHFM5M.js";var z=(()=>{let r=class r{constructor(e,t,i,a,h,y,M,Ve,Ye,Ue,Te,Oe,de){this.analyticsService=e,this.docService=t,this.domService=i,this.authService=a,this.afAuth=h,this.iamService=y,this.databaseService=M,this.configService=Ve,this.avatarService=Ye,this.loggingService=Ue,this.flockService=Te,this.commonDbService=Oe,this.realtimeAdapter=de,this.db=null,this.presenceUser$=new ue(new it),this.documentPaths=null,this.inactivityTime=300*1e3,this.offlineInactivityTime=600*1e3,this.presenceUsers$=new ue([]),this.presenceUsersSubscription=null,this.includeSelf$=new ue(!0),this.customPresenceUsers$=new ue([]),this.userIdleStateDetectionSubscription=null,this.userOfflineStateDetectionSubscription=null;try{this.loggingService.log("%c[WB] Creating CLASS: PresenceService","color: blue;"),this.databaseService.getDb().pipe(Y(S=>!!S),ke(1)).subscribe(S=>{S&&(this.db=S,this.getUser(),this.getDocumentPaths(),this.getLocation(),this.updateOnUserDbConnectionStateChange().subscribe(()=>{},B=>{this.loggingService.catch("Error in PresenceService constructor updateOnUserDbConnectionStateChange: ",B)}),this.updateOnDatabaseDisconnect().subscribe(()=>{},B=>{this.loggingService.catch("Error in PresenceService constructor updateOnDatabaseDisconnect: ",B)}),this.updateOnDocumentFocusChange(),this.updateOnAllowedFeatureListChange())},S=>{this.loggingService.catch("Error in PresenceService constructor: ",S)}),this.authService.addPreSignOutFuction("presence-signout",this.signOutUser.bind(this)),this.presenceUsers$.pipe(Qe()).subscribe(([S,B])=>{try{B?.length>=0&&this.analyticsService.updateDefaultProperties({presenceUsersCount:B?.length}),sessionStorage.getItem(p.SESSION_STORAGE.VELT_PRESENCE_MULTIPLE_USERS_ONLINE)||B?.length>1&&S.length!==B.length&&(sessionStorage.setItem(p.SESSION_STORAGE.VELT_PRESENCE_MULTIPLE_USERS_ONLINE,"true"),this.presenceActionsService?.onMultipleUsersOnline({users:B}))}catch(gn){this.loggingService.catch("Error in presenceUsers$ pairwise subscription: ",gn)}}),this.authService.getUser$().pipe(Y(S=>!!S),ke(1)).subscribe(S=>{S?(this.detectUserIdleState(),this.detectUserOfflineState()):(this.unsubscribeUserIdleStateDetectionSubscription(),this.unsubscribeUserOfflineStateDetectionSubscription())}),this.presenceUser$.subscribe(S=>{try{S?.onlineStatus&&this.presenceActionsService?.onUserStateChange({user:JSON.parse(JSON.stringify(S)),state:S?.onlineStatus})}catch(B){this.loggingService.catch("Error in presenceUser$ subscription: ",B)}},S=>{this.loggingService.catch("Error in presenceUser$ subscribe: ",S)}),this.customPresenceUsers$.subscribe(()=>{try{let S=this.presenceUsers$.value.filter(B=>!B.localOnly);this.presenceUsers$.next(this.mergeWithCustomUsers(S))}catch(S){this.loggingService.catch("Error in customPresenceUsers$ subscription: ",S)}}),this.domService.onNetworkStatusChange$().subscribe(S=>{try{!S&&this.presenceUser$?.value?.onlineStatus&&this.presenceActionsService?.onUserStateChange({user:w(C({},JSON.parse(JSON.stringify(this.presenceUser$.value))),{onlineStatus:p.PRESENCE_STATUS_OFFLINE}),state:p.PRESENCE_STATUS_OFFLINE})}catch(B){this.loggingService.catch("Error in domService.onNetworkStatusChange$ subscription: ",B)}},S=>{this.loggingService.catch("Error in domService.onNetworkStatusChange$ subscribe: ",S)})}catch(S){this.loggingService.catch("Error in PresenceService constructor: ",S)}}setPresenceActionsService(e){try{this.presenceActionsService=e}catch(t){this.loggingService.catch("Error in setPresenceActionsService: ",t)}}detectUserIdleState(){try{this.unsubscribeUserIdleStateDetectionSubscription();let e=!1;this.userIdleStateDetectionSubscription=this.domService.onWindowPointerMove$().pipe(Ze(2e3),H(()=>{this.presenceUser$.value&&e&&(this.setCurrentPresenceUserStatus(p.PRESENCE_STATUS_ONLINE),e=!1)}),He(this.inactivityTime),H(()=>{this.setCurrentPresenceUserStatus(p.PRESENCE_STATUS_AWAY,{isUserIdle:!0}),e=!0})).subscribe()}catch(e){this.loggingService.catch("Error in detectUserIdleState: ",e)}}detectUserOfflineState(){try{this.unsubscribeUserOfflineStateDetectionSubscription();let e=!1;this.userOfflineStateDetectionSubscription=this.domService.onWindowPointerMove$().pipe(Ze(2e3),He(this.offlineInactivityTime),H(()=>{this.setCurrentPresenceUserStatus(p.PRESENCE_STATUS_OFFLINE,{isUserIdle:!0}),e=!0})).subscribe()}catch(e){this.loggingService.catch("Error in detectUserOfflineState: ",e)}}unsubscribeUserIdleStateDetectionSubscription(){try{this.userIdleStateDetectionSubscription&&(this.userIdleStateDetectionSubscription.unsubscribe(),this.userIdleStateDetectionSubscription=null)}catch(e){this.loggingService.catch("Error in unsubscribeUserIdleStateDetectionSubscription: ",e)}}unsubscribeUserOfflineStateDetectionSubscription(){try{this.userOfflineStateDetectionSubscription&&(this.userOfflineStateDetectionSubscription.unsubscribe(),this.userOfflineStateDetectionSubscription=null)}catch(e){this.loggingService.catch("Error in unsubscribeUserOfflineStateDetectionSubscription: ",e)}}getUser(){this.loggingService.log("%c[WB] Calling FUNCTION: getUser","color: green;"),this.authService.getUser$().pipe(Y(e=>!!e)).subscribe(e=>{e&&this.setPresenceUser(e)},e=>{this.loggingService.catch("Error in getUser: ",e)})}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$().pipe(H(e=>{this.documentPaths=e}),Qe(),H(([e,t])=>{e&&this.updateUserStatusOnDocumentChange(p.PRESENCE_STATUS_OFFLINE,e),t&&this.updateUserStatusOnDocumentChange(p.PRESENCE_STATUS_ONLINE,t)})).subscribe(()=>{},e=>{this.loggingService.catch("Error in getDocumentPaths: ",e)})}getLocation(){this.docService.getLocation$().pipe(H(e=>{this.updateUserOnLocationChange(e)})).subscribe(()=>{},e=>{this.loggingService.catch("Error in getLocation: ",e)})}getPresenceUser(){return this.loggingService.log("%c[WB] Calling FUNCTION: getPresenceUser","color: green;"),this.presenceUser$.asObservable()}getPresenceUserValue(){return this.presenceUser$.value}getOnlineUsersOnCurrentDocument(e){return this.loggingService.log("%c[WB] Calling FUNCTION: getOnlineUsersOnCurrentDocument","color: green;"),this.authService.getAuthState$().pipe(Y(t=>!!t),W(t=>this.isFeatureAllowed({firebaseUser:t,users:[],filteredUsers:[]})),W(t=>t.featureAllowed?this.iamService.isUserAllowed$().pipe(L(i=>(t.featureAllowed=i,t))):F(t)),W(t=>t.featureAllowed?this.authService.isPlanExpired$().pipe(L(i=>(t.featureAllowed=!i,t))):F(t)),W(t=>t.featureAllowed?F(t).pipe(W(i=>this.docService.getDocumentPaths$().pipe(L(a=>(this.documentPaths=a,i.documentPaths=a,i)))),W(i=>this.getDataFromDocumentId(e).pipe(L(a=>(i.users=a||[],C({},i))))),L(i=>(e?e?.statuses?.length?i.filteredUsers=i?.users?.filter(a=>e?.statuses?.includes(a?.onlineStatus)):i.filteredUsers=i?.users?.slice():i.filteredUsers=this.filterOnlineUsers(i.users,i.firebaseUser),i)),W(i=>this.getIncludeSelf$().pipe(L(a=>(a||(i.filteredUsers=i?.filteredUsers?.filter(h=>h?.userSnippylyId!==i.user?.userSnippylyId)),i)))),W(i=>{let a=i?.filteredUsers||[];return this.customPresenceUsers$.pipe(L(()=>this.mergeWithCustomUsers(a)))})):F([])),Ke(At))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Y(t=>!!t),L(t=>w(C({},e),{config:t})),W(t=>this.authService.getUser$().pipe(L(i=>w(C({},t),{user:i})))),W(t=>Tt(t.config,t.user,X.PRESENCE)?F(w(C({},t),{featureAllowed:!0})):(this.loggingService.warn("Presence feature is not allowed."),F(w(C({},t),{featureAllowed:!1})))),Ke((t,i)=>t?.featureAllowed===i?.featureAllowed))}getDataFromDocumentId(e){return this.databaseService.getDb().pipe(Y(t=>!!t),W(t=>{if(this.db=t,this.loggingService.log(this.db),this.configService?.getApiKey()&&this.documentPaths?.presence){let i=new Date(Date.now()-864e5).getTime();return this.commonDbService.dbListener({feature:"allPresence",properties:{documentId:e?.documentId??this.documentPaths?.documentId,organizationId:e?.organizationId??this.documentPaths?.organizationId,skipFirestore:!0,useQuery:!0,rtdbQuery:[Et("timestamp"),Pt(i)]}}).pipe(ot(a=>(this.loggingService.catch("Error in PresenceService getDataFromDocumentId: ",a),F(null))),L(a=>a?.data),L(a=>{let h=[];if(a){let y=Object.values(a).filter(M=>typeof M=="object");for(let M of y)h.push(M)}return h}))}else return F([])}))}filterOnlineUsers(e,t){this.loggingService.log("%c[WB] Calling FUNCTION: filterOnlineUsers","color: green;");try{let a=e.slice().filter(h=>{let y=me(h.timestamp);return h.userSnippylyId&&(h.onlineStatus===p.PRESENCE_STATUS_ONLINE||h.onlineStatus===p.PRESENCE_STATUS_AWAY)&&y<this.offlineInactivityTime});return this.presenceUsers$.next(this.mergeWithCustomUsers(a)),a}catch(i){return this.loggingService.catch("Error in filterOnlineUsers:",i),[]}}enableIncludeSelf(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableIncludeSelf","color: green;"),this.includeSelf$.value===!0)return;this.includeSelf$.next(!0)}catch(e){this.loggingService.catch("Error in PresenceService enableIncludeSelf: ",e)}}disableIncludeSelf(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableIncludeSelf","color: green;"),this.includeSelf$.value===!1)return;this.includeSelf$.next(!1)}catch(e){this.loggingService.catch("Error in PresenceService disableIncludeSelf: ",e)}}getIncludeSelf$(){return this.includeSelf$.asObservable()}getIncludeSelf(){return this.includeSelf$.value}getPresenceUserFromExternalId(e){try{if(this.presenceUsers$.value&&this.presenceUsers$.value.length>0){let t=this.presenceUsers$.value.find(i=>i.userId===e);if(t)return t}return null}catch(t){return this.loggingService.catch("Error in getNameFromSnippylyId:",t),null}}getAnonymousAvatarImage(){return this.loggingService.log("%c[WB] Calling FUNCTION: getAnonymousAvatarImage","color: green;"),this.avatarService.generateUserImage()}updateCurrentPresenceUser(e){return oe(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateCurrentPresenceUser","color: green;");try{if(this.documentPaths?.presence&&e&&e.userId&&this.authService.isFeatureAllowed(X.PRESENCE)){if(!e.isAnonymous){e.pageInfo=new rt,e?.onlineStatus===p.PRESENCE_STATUS_ONLINE&&(e.isTabAway=!1,e.isUserIdle=!1);let t=JSON.parse(JSON.stringify(e));this.authService.getUser()&&this.commonDbService.updateData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(w(C({},t),{timestamp:this.timestamp})))})}this.presenceUser$.next(e)}}catch(t){this.loggingService.catch("Error in updateCurrentPresenceUser:",t)}})}setCurrentPresenceUserStatus(e,t){return oe(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: setCurrentPresenceUserStatus","color: green;");try{this.loggingService.log(e);let i=this.presenceUser$.value;if(i.onlineStatus!==e){this.presenceUsersSubscription&&this.presenceUsersSubscription?.unsubscribe();let a=i.onlineStatus,h=e;this.presenceUsersSubscription=this.getPresenceUsers$().pipe(Y(y=>!!y?.length),ke(1)).subscribe(y=>{y?.length>1&&this.analyticsService.trackEvent(E.Events.Presence.PRESENCE_USER_STATUS_CHANGED,{oldStatus:a,newStatus:h,totalUsers:y?.length,presenceSnippylyUserIds:y?.map(M=>M.userSnippylyId),presenceClientUserIds:y?.map(M=>M.userId)})})}i.onlineStatus=e,t&&(i.isTabAway=t?.isTabAway,i.isUserIdle=t?.isUserIdle),e===p.PRESENCE_STATUS_ONLINE&&(i.isTabAway=!1,i.isUserIdle=!1),e===p.PRESENCE_STATUS_OFFLINE&&this.flockService.isInSession()&&this.flockService.removeCurrentUserFromSession(),this.updateCurrentPresenceUser(i)}catch(i){this.loggingService.catch("Error in setCurrentPresenceUserStatus:",i)}})}updateUserStatusOnDocumentChange(e,t){return oe(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateUserStatusOnDocumentChange","color: green;");try{let i=this.presenceUser$.value;if(i.onlineStatus=e,t?.presence&&i&&i.userId&&!i.isAnonymous&&this.authService.isFeatureAllowed(X.PRESENCE)){let a=JSON.parse(JSON.stringify(i));this.commonDbService.updateData({feature:"presence",properties:{documentId:t?.documentId,organizationId:t?.organizationId,userId:i.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(a))})}}catch(i){this.loggingService.catch("Error in updateUserStatusOnDocumentChange:",i)}})}updateUserOnLocationChange(e){return oe(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateUserOnLocationChange","color: green;");try{let t=this.presenceUser$.value;if(t.location=e?e.location:null,t.locationId=e?e?.locationId:null,this.documentPaths?.presence&&t&&t.userId&&!t.isAnonymous&&this.authService.isFeatureAllowed(X.PRESENCE)){let i=JSON.parse(JSON.stringify(t));this.commonDbService.updateData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:t.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(i))})}}catch(t){this.loggingService.catch("Error in updateUserOnLocationChange:",t)}})}updateOnUserDbConnectionStateChange(){this.loggingService.log("%c[WB] Calling FUNCTION: updateOnUserDbConnectionStateChange","color: green;");let e=this.realtimeAdapter.rtdbRef(this.db,".info/connected"),t=this.realtimeAdapter.rtdbObjectVal$("presence",e).pipe(L(i=>i?p.PRESENCE_STATUS_ONLINE:p.PRESENCE_STATUS_OFFLINE));return this.authService.getAuthState$().pipe(at(1),W(i=>i?t:F(p.PRESENCE_STATUS_OFFLINE)),H(i=>this.setCurrentPresenceUserStatus(i)))}updateOnDocumentFocusChange(){this.loggingService.log("%c[WB] Calling FUNCTION: updateOnDocumentFocusChange","color: green;");try{document&&document.addEventListener("visibilitychange",e=>{this.authService.getUser()&&(document.visibilityState==="hidden"?(this.setCurrentPresenceUserStatus(p.PRESENCE_STATUS_AWAY,{isTabAway:!0}),this.flockService.getFlockMode()&&this.flockService.setTabFocused(!1)):(this.setCurrentPresenceUserStatus(p.PRESENCE_STATUS_ONLINE),this.flockService.getFlockMode()&&this.flockService.setTabFocused(!0)))}),window&&(window.addEventListener("focus",()=>{this.authService.getUser()&&(this.setCurrentPresenceUserStatus(p.PRESENCE_STATUS_ONLINE),this.flockService.getFlockMode()&&this.flockService.setWindowFocused(!0))}),window.addEventListener("blur",()=>{this.authService.getUser()&&(document.visibilityState!=="hidden"&&this.setCurrentPresenceUserStatus(p.PRESENCE_STATUS_AWAY,{isTabAway:!0}),this.flockService.getFlockMode()&&this.flockService.setWindowFocused(!1))}))}catch(e){this.loggingService.catch("Error in updateOnDocumentFocusChange:",e)}}updateOnAllowedFeatureListChange(){try{this.configService.getConfig$().subscribe(e=>{if(e&&e.featureAllowList?.length){let t=this.presenceUser$.value,i=!1;if(e.featureAllowList.includes(X.PRESENCE)?t?.onlineStatus!==p.PRESENCE_STATUS_ONLINE&&(t.onlineStatus=p.PRESENCE_STATUS_ONLINE,i=!0):t?.onlineStatus!==p.PRESENCE_STATUS_OFFLINE&&(t.onlineStatus=p.PRESENCE_STATUS_OFFLINE,i=!0),i&&this.authService.getUser()&&this.documentPaths?.presence&&t&&t.userId&&!t.isAnonymous){let a=JSON.parse(JSON.stringify(t));this.commonDbService.updateData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:t.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(a))})}}})}catch(e){this.loggingService.catch("Error in updateOnAllowedFeatureListChange:",e)}}updateOnDatabaseDisconnect(){return this.loggingService.log("%c[WB] Calling FUNCTION: updateOnDatabaseDisconnect","color: green;"),this.authService.getAuthState$().pipe(Y(e=>!!e),W(e=>this.docService.getDocumentPaths$().pipe(L(t=>e))),H(e=>oe(this,null,function*(){try{if(this.documentPaths?.presence&&e){let t=yield this.authService.getIdTokenResultForUser(e,!0).catch(a=>null);if(!t)return;let{user:i}=t.claims;if(!i?.isAnonymous&&this.documentPaths?.presence){this.flockService.isInSession()&&this.flockService.removeCurrentUserFromSession();let a=`${this.documentPaths.presence}/${e.uid}`;this.commonDbService.setupOnDisconnect(a,{onlineStatus:p.PRESENCE_STATUS_OFFLINE,timestamp:this.timestamp}).catch(h=>{this.loggingService.catch("Error in updateOnDatabaseDisconnect:",h)})}}}catch(t){this.loggingService.catch("Error in updateOnDatabaseDisconnect:",t)}})))}setPresenceUser(e){this.loggingService.log("%c[WB] Calling FUNCTION: setPresenceUser","color: green;");try{let t=this.presenceUser$.value;t.userId=e?.userId,t.name=e?.name,t.email=e?.email,t.photoUrl=e?.photoUrl,t.userSnippylyId=e?.userSnippylyId,t.color=e?.color,t.textColor=e?.textColor,t.initial=e?.initial,t.timestamp=this.timestamp,t.type=e?.type,t.isReadOnly=e?.isReadOnly,t.isAnonymous=e?.isAnonymous;let i=e?.name?.split(" ");if(i&&i.length>0){let a=i[0],h=i.length>1?i[i.length-1]:null,y=h?h[0]:null;a&&(t.name=`${a} ${y?y+".":""}`)}this.updateCurrentPresenceUser(t)}catch(t){this.loggingService.catch("Error in setPresenceUser:",t)}}signOutUser(e){return new Promise((t,i)=>{try{this.documentPaths?.presence&&e?this.commonDbService.getData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.uid,skipFirestore:!0}}).then(a=>{a&&(this.flockService.isInSession()&&this.flockService.removeCurrentUserFromSession(),this.commonDbService.updateData({feature:"presence",errorCallback:h=>{i(h)},callback:()=>{t(null)},properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.uid,skipFirestore:!0},data:JSON.parse(JSON.stringify(w(C({},a?.data??{}),{timestamp:this.timestamp,onlineStatus:p.PRESENCE_STATUS_OFFLINE})))})),t(null)}).catch(a=>{this.loggingService.catch("Error in signOutUser subscription: ",a),i(a)}):t(null)}catch(a){this.loggingService.catch("Error in signOutUser:",a),i(a)}})}setInactivityTime(e){try{this.inactivityTime=e,this.analyticsService.trackEvent(E.Events.Presence.PRESENCE_SET_CUSTOM_INACTIVITY_TIMER,{inactivityTime:this.inactivityTime}),this.detectUserIdleState()}catch(t){this.loggingService.catch("Error in setInactivityTime: ",t)}}getInactivityTime(){return this.inactivityTime}setOfflineInactivityTime(e){try{e>=this.inactivityTime?(this.offlineInactivityTime=e,this.analyticsService.trackEvent(E.Events.Presence.PRESENCE_SET_CUSTOM_OFFLINE_INACTIVITY_TIMER,{offlineInactivityTime:this.offlineInactivityTime}),this.detectUserOfflineState()):this.loggingService.catch("Error in setOfflineInactivityTime: ","offline-inactivity-time value is less than inactivity-time.")}catch(t){this.loggingService.catch("Error in setOfflineInactivityTime: ",t)}}getOfflineInactivityTime(){return this.offlineInactivityTime}getPresenceUsers$(){return this.presenceUsers$.asObservable()}getPresenceUsers(){return this.presenceUsers$.value}get timestamp(){return this.commonDbService.getServerTimestamp()}addCustomUser(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: addCustomUser","color: green;");let t=e?.user,i=e?.localOnly??!1;if(!t?.userId){this.loggingService.catch("Error in addCustomUser: ","userId is required");return}let a=this.buildCustomPresenceUser(t,i);if(!a)return;if(i){let h=this.customPresenceUsers$.value,y=h.findIndex(M=>M.userId===t.userId);if(y>=0){let M=[...h];M[y]=a,this.customPresenceUsers$.next(M)}else this.customPresenceUsers$.next([...h,a])}else this.persistCustomUserToDb(a)}catch(t){this.loggingService.catch("Error in addCustomUser: ",t)}}removeCustomUser(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: removeCustomUser","color: green;");let t=e?.user?.userId,i=e?.localOnly??!1;if(!t){this.loggingService.catch("Error in removeCustomUser: ","userId is required");return}if(i){let a=this.customPresenceUsers$.value,h=a.filter(y=>y.userId!==t);h.length!==a.length&&this.customPresenceUsers$.next(h)}else{let a=this.buildCustomPresenceUser(e.user,!1);a&&this.removeCustomUserFromDb(a)}}catch(t){this.loggingService.catch("Error in removeCustomUser: ",t)}}mergeWithCustomUsers(e){try{let t=this.customPresenceUsers$.value;if(t.length===0)return e;let i=new Set(e.map(h=>h.userId)),a=t.filter(h=>!i.has(h.userId));return[...e,...a]}catch(t){return this.loggingService.catch("Error in mergeWithCustomUsers: ",t),e}}buildCustomPresenceUser(e,t=!1){try{let i=this.configService.getApiKey(),a=new it;return a.userId=e.userId,a.name=e.name||e.userId,a.email=e.email||"",a.photoUrl=e.photoUrl||"",a.onlineStatus=e.onlineStatus||p.PRESENCE_STATUS_ONLINE,a.color=e.color||this.avatarService.generateUserColor(),a.textColor=e.textColor||"",a.type="custom",a.initial=e.initial||(a.name?a.name.charAt(0).toUpperCase():"U"),a.timestamp=Date.now(),a.isReadOnly=e.isReadOnly??!1,a.isAnonymous=e.isAnonymous??!1,a.location=e.location||null,a.locationId=e.locationId??null,a.pageInfo=e.pageInfo||new rt,a.isTabAway=!1,a.isUserIdle=!1,a.userSnippylyId=e.userSnippylyId||(i?kt(i,e.userId):`custom_${e.userId}`),a.localOnly=t,a}catch(i){return this.loggingService.catch("Error in buildCustomPresenceUser: ",i),null}}persistCustomUserToDb(e){try{if(this.documentPaths?.presence&&e?.userId&&this.authService.isFeatureAllowed(X.PRESENCE)){let t=JSON.parse(JSON.stringify(e));delete t.localOnly,this.commonDbService.updateData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(w(C({},t),{timestamp:this.timestamp})))})}}catch(t){this.loggingService.catch("Error in persistCustomUserToDb: ",t)}}removeCustomUserFromDb(e){try{this.documentPaths?.presence&&e?.userId&&this.authService.isFeatureAllowed(X.PRESENCE)&&this.commonDbService.deleteData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.userSnippylyId,skipFirestore:!0}})}catch(t){this.loggingService.catch("Error in removeCustomUserFromDb: ",t)}}};r.\u0275fac=function(t){return new(t||r)(P(ge),P($t),P(je),P($e),P(bt),P(Gt),P(jt),P(Mt),P(Lt),P(v),P(K),P(zt),P(Wt))},r.\u0275prov=ae({token:r,factory:r.\u0275fac,providedIn:"root"});let n=r;return n})();var ie=class{constructor(){this.filteredPresenceUsers=[],this.shadowDom=!0,this.maxUsers=5,this.showTooltip=()=>{},this.closeTooltip=()=>{},this.onPresenceUserClick=()=>{}}};var V=class{constructor(){this.shadowDom=!0,this.calculateUserAwayTime=()=>{}}};var Kt=n=>({componentConfigSignal:n}),un=(n,r)=>({condition:n,data:r}),hn=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-tooltip-avatar-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function fn(n,r){if(n&1&&(d(0),R(1,"snippyly-user-avatar",3),u()),n&2){let o=s(2).ngIf,e=s();l(),Re("away",o.presenceUser.onlineStatus===e.constants.PRESENCE_STATUS_AWAY)("velt-presence-avatar--away",o.presenceUser.onlineStatus===e.constants.PRESENCE_STATUS_AWAY),c("user",o.presenceUser)}}function Sn(n,r){if(n&1&&(d(0),g(1,fn,2,5,"ng-container",2),u()),n&2){let o=s().ngIf,e=s();l(),c("veltDynamicTemplate",k(3,hn,e.template,_(1,Kt,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function Cn(n,r){if(n&1&&(d(0),g(1,Sn,2,9,"ng-container",1),u()),n&2){let o=s();l(),c("veltIf",b(3,un,o.conditionSignal(),_(1,Kt,o.componentConfigSignal)))}}var fe=(()=>{let r=class r extends ${constructor(e,t,i){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.componentId="velt-presence-tooltip-avatar",this.constants=p;try{super.initializeComponentConfigSignal(new V)}catch(a){this.loggingService.catch("Error in PresenceTooltipAvatarComponent constructor: ",a)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in PresenceTooltipAvatarComponent ngOnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceTooltipAvatarComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceTooltipAvatarComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(I),m(f),m(v))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-tooltip-avatar-internal"]],standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"],[1,"velt-presence-avatar","s-presence-avatar",3,"user"]],template:function(t,i){t&1&&g(0,Cn,2,6,"ng-container",0),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,N,A,re],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]{display:flex}[_nghost-%COMP%]:empty{display:none}.velt-presence-avatar[_ngcontent-%COMP%]{position:relative;border-radius:var(--velt-border-radius-full);z-index:2;width:calc((1.5 + 0px) * var(--velt-base-rem-unit));height:calc((1.5 + 0px) * var(--velt-base-rem-unit));display:flex;align-items:center;justify-content:center}.velt-presence-avatar--away[_ngcontent-%COMP%]{filter:grayscale(.7)}snippyly-user-avatar[_ngcontent-%COMP%]{--legacy-velt-user-avatar-size: 1.5rem}"],changeDetection:0});let n=r;return n})();var Zt=n=>({componentConfigSignal:n}),yn=(n,r)=>({condition:n,data:r}),In=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-tooltip-user-active-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function bn(n,r){n&1&&(d(0),T(1,"p"),se(2),ce(3,"translate"),O(),u()),n&2&&(l(2),Me(le(3,1,"User online")))}function En(n,r){if(n&1&&(d(0),g(1,bn,4,3,"ng-container",2),u()),n&2){let o=s(2).ngIf,e=s();l(),c("veltDynamicTemplate",k(3,In,e.template,_(1,Zt,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function Pn(n,r){if(n&1&&(d(0),g(1,En,2,9,"ng-container",0),u()),n&2){let o=s().ngIf,e=s();l(),c("ngIf",(o.presenceUser==null?null:o.presenceUser.onlineStatus)===e.constants.PRESENCE_STATUS_ONLINE)}}function xn(n,r){if(n&1&&(d(0),g(1,Pn,2,1,"ng-container",1),u()),n&2){let o=s();l(),c("veltIf",b(3,yn,o.conditionSignal(),_(1,Zt,o.componentConfigSignal)))}}var Se=(()=>{let r=class r extends ${constructor(e,t,i){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.componentId="velt-presence-tooltip-user-active",this.constants=p;try{super.initializeComponentConfigSignal(new V)}catch(a){this.loggingService.catch("Error in PresenceTooltipUserActiveComponent constructor: ",a)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in PresenceTooltipUserActiveComponent ngOnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceTooltipUserActiveComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceTooltipUserActiveComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(I),m(f),m(v))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-tooltip-user-active-internal"]],standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"]],template:function(t,i){t&1&&g(0,xn,2,6,"ng-container",0),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,N,A,ve],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]:empty{display:none}p[_ngcontent-%COMP%]{margin:0;color:var(--velt-green);font-weight:400;font-size:var(--velt-font-size-xs);line-height:1}"],changeDetection:0});let n=r;return n})();var qt=n=>({componentConfigSignal:n}),Tn=(n,r)=>({condition:n,data:r}),On=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-tooltip-user-inactive-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function kn(n,r){if(n&1&&(d(0),T(1,"p",3),se(2),ce(3,"translate"),O(),u()),n&2){let o=s(3).ngIf;l(2),ht(" ",o.calculateUserAwayTime(o.presenceUser).toString()+" "+le(3,1,"mins ago.")," ")}}function Dn(n,r){if(n&1&&(d(0),g(1,kn,4,3,"ng-container",2),u()),n&2){let o=s(2).ngIf,e=s();l(),c("veltDynamicTemplate",k(3,On,e.template,_(1,qt,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function An(n,r){if(n&1&&(d(0),g(1,Dn,2,9,"ng-container",0),u()),n&2){let o=s().ngIf,e=s();l(),c("ngIf",(o.presenceUser==null?null:o.presenceUser.onlineStatus)===e.constants.PRESENCE_STATUS_AWAY)}}function Nn(n,r){if(n&1&&(d(0),g(1,An,2,1,"ng-container",1),u()),n&2){let o=s();l(),c("veltIf",b(3,Tn,o.conditionSignal(),_(1,qt,o.componentConfigSignal)))}}var Ce=(()=>{let r=class r extends ${constructor(e,t,i){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.componentId="velt-presence-tooltip-user-inactive",this.constants=p;try{super.initializeComponentConfigSignal(new V)}catch(a){this.loggingService.catch("Error in PresenceTooltipUserInactiveComponent constructor: ",a)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in PresenceTooltipUserInactiveComponent ngOnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceTooltipUserInactiveComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceTooltipUserInactiveComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(I),m(f),m(v))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-tooltip-user-inactive-internal"]],standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"],[1,"velt-presence-tooltip-user-inactive-text","inactive-text"]],template:function(t,i){t&1&&g(0,Nn,2,6,"ng-container",0),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,N,A,ve],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]:empty{display:none}p[_ngcontent-%COMP%]{margin:0;color:var(--velt-green);font-weight:400;font-size:var(--velt-font-size-xs);line-height:1}.velt-presence-tooltip-user-inactive-text[_ngcontent-%COMP%]{color:var(--velt-text-4)}"],changeDetection:0});let n=r;return n})();var en=n=>({componentConfigSignal:n}),Fn=(n,r)=>({condition:n,data:r}),Rn=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-tooltip-user-name-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function Mn(n,r){if(n&1&&(d(0),T(1,"h1"),se(2),ce(3,"translate"),O(),u()),n&2){let o=s(3).ngIf;l(2),Me(o.presenceUser!=null&&o.presenceUser.name?o.presenceUser==null?null:o.presenceUser.name:le(3,1,o.presenceUser==null?null:o.presenceUser.email))}}function Ln(n,r){n&1&&R(0,"velt-skeleton-loader-internal",5)}function jn(n,r){if(n&1&&(d(0),g(1,Mn,4,3,"ng-container",4)(2,Ln,1,0,"ng-template",null,0,ne),u()),n&2){let o=te(3),e=s(2).ngIf;l(),c("ngIf",(e.presenceUser==null?null:e.presenceUser.name)||(e.presenceUser==null?null:e.presenceUser.email))("ngIfElse",o)}}function $n(n,r){if(n&1&&(d(0),g(1,jn,4,2,"ng-container",3),u()),n&2){let o=s().ngIf,e=s();l(),c("veltDynamicTemplate",k(3,Rn,e.template,_(1,en,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function Bn(n,r){if(n&1&&(d(0),g(1,$n,2,9,"ng-container",2),u()),n&2){let o=s();l(),c("veltIf",b(3,Fn,o.conditionSignal(),_(1,en,o.componentConfigSignal)))}}var _e=(()=>{let r=class r extends ${constructor(e,t,i){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.componentId="velt-presence-tooltip-user-name";try{super.initializeComponentConfigSignal(new V)}catch(a){this.loggingService.catch("Error in PresenceTooltipUserNameComponent constructor: ",a)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in PresenceTooltipUserNameComponent ngOnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceTooltipUserNameComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceTooltipUserNameComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(I),m(f),m(v))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-tooltip-user-name-internal"]],standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[["loadingTemplateRef",""],[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"],[4,"ngIf","ngIfElse"],["height","16px","width","80px","borderRadius","20px"]],template:function(t,i){t&1&&g(0,Bn,2,6,"ng-container",1),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,N,A,Je,ve],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]:empty{display:none}h1[_ngcontent-%COMP%]{margin:0;color:var(--velt-text-0);font-size:var(--velt-font-size-sm);line-height:calc((1rem + 0px) * var(--velt-base-rem-unit));font-weight:400}"],changeDetection:0});let n=r;return n})();var tn=n=>({componentConfigSignal:n}),zn=(n,r)=>({condition:n,data:r}),Jn=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-tooltip-status-container-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function Gn(n,r){if(n&1&&(d(0),T(1,"div",3),R(2,"velt-presence-tooltip-user-name-internal",4)(3,"velt-presence-tooltip-user-active-internal",4)(4,"velt-presence-tooltip-user-inactive-internal",4),O(),u()),n&2){let o=s(3);l(2),c("componentConfigSignal",o.componentConfigSignal),l(),c("componentConfigSignal",o.componentConfigSignal),l(),c("componentConfigSignal",o.componentConfigSignal)}}function Vn(n,r){if(n&1&&(d(0),g(1,Gn,5,3,"ng-container",2),u()),n&2){let o=s().ngIf,e=s();l(),c("veltDynamicTemplate",k(3,Jn,e.template,_(1,tn,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function Yn(n,r){if(n&1&&(d(0),g(1,Vn,2,9,"ng-container",1),u()),n&2){let o=s();l(),c("veltIf",b(3,zn,o.conditionSignal(),_(1,tn,o.componentConfigSignal)))}}var ye=(()=>{let r=class r extends ${constructor(e,t,i){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.componentId="velt-presence-tooltip-status-container",this.constants=p;try{super.initializeComponentConfigSignal(new V)}catch(a){this.loggingService.catch("Error in PresenceTooltipStatusContainerComponent constructor: ",a)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in PresenceTooltipStatusContainerComponent ngOnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceTooltipStatusContainerComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceTooltipStatusContainerComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(I),m(f),m(v))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-tooltip-status-container-internal"]],standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"],[1,"velt-presence-tooltip-status-container","user-status-container"],[3,"componentConfigSignal"]],template:function(t,i){t&1&&g(0,Yn,2,6,"ng-container",0),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,N,A,Se,Ce,_e],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]:empty{display:none}.velt-presence-tooltip-status-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;z-index:2;gap:var(--velt-spacing-xs)}"],changeDetection:0});let n=r;return n})();var nn=(n,r)=>({componentConfigSignal:n,presenceUser:r}),Qn=(n,r)=>({condition:n,data:r}),Zn=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-tooltip-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function qn(n,r){n&1&&Fe(0)}function er(n,r){if(n&1&&(T(0,"velt-shadow-dom-internal"),g(1,qn,1,0,"ng-container",4),O()),n&2){s();let o=te(3);l(),c("ngTemplateOutlet",o)}}function tr(n,r){if(n&1&&(d(0),T(1,"div",8),R(2,"velt-presence-tooltip-avatar-internal",9)(3,"velt-presence-tooltip-status-container-internal",9),O(),u()),n&2){let o=s(5);l(2),c("componentConfigSignal",o.componentConfigSignal),l(),c("componentConfigSignal",o.componentConfigSignal)}}function nr(n,r){if(n&1&&(T(0,"div",6),g(1,tr,4,2,"ng-container",7),O()),n&2){let o=s(3).ngIf,e=s();l(),c("veltDynamicTemplate",k(4,Zn,e.template,b(1,nn,e.componentConfigSignal,e.presenceUser),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function rr(n,r){if(n&1&&g(0,nr,2,10,"div",5),n&2){let o=s(2).ngIf;c("ngIf",o==null?null:o.presenceUser)}}function ir(n,r){if(n&1&&(d(0),g(1,er,2,1,"velt-shadow-dom-internal",3)(2,rr,1,1,"ng-template",null,0,ne),u()),n&2){let o=te(3),e=s().ngIf,t=s();l(),c("ngIf",e.shadowDom&&!t.template||t.template&&t.isExplicitShadowDom)("ngIfElse",o)}}function or(n,r){if(n&1&&(d(0),g(1,ir,4,2,"ng-container",2),u()),n&2){let o=s();l(),c("veltIf",b(4,Qn,o.conditionSignal(),b(1,nn,o.componentConfigSignal,o.presenceUser)))}}var Ie=(()=>{let r=class r extends ze{set shadowDom(e){this._shadowDom=e}get shadowDom(){return this._shadowDom}constructor(e,t,i,a,h){super(e,t,void 0,void 0,void 0,i,a),this.elementRef=e,this.themeService=t,this.dynamicDataService=i,this.loggingService=a,this.wireframeService=h,this._shadowDom=!0,this.isExplicitShadowDom=!1,this.constants=p,this.subscriptions=[],this.componentId="velt-presence-tooltip",this.componentConfigSignal=Ne({presenceUser:null,shadowDom:!0,calculateUserAwayTime:this.calculateUserAwayTime.bind(this)}),this.loggingService.log("%c[WB] Creating CLASS: PresenceTooltipComponent","color: blue;")}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;");try{let e=this.elementRef.nativeElement,t=e.getAttribute("shadow-dom")??e.getAttribute("shadowdom");this.isExplicitShadowDom=t!==null&&t!=="false",this.setupA11yAttributes(),this.dynamicDataService.applyConditionalClasses(this.elementRef.nativeElement,{componentConfigSignal:this.componentConfigSignal,presenceUser:this.presenceUser}),this.subscriptions.push(this.wireframeService.getWireframe$("velt-presence-tooltip-wireframe").subscribe(a=>{if(a){let h=document.createElement(a.tagName);h.innerHTML=a.innerHTML,this.template=h}}))}catch(e){this.loggingService.catch("Error in PresenceComponent oninit: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceComponent setupA11yAttributes:",e)}}ngOnChanges(e){try{super.ngOnChanges(e),e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(i=>(i=w(C({},i),{[t]:e[t].currentValue}),i))})}catch(t){this.loggingService.catch("Error in PresenceTooltipComponent ngOnChanges: ",t)}}ngOnDestroy(){try{super.ngOnDestroy(),this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.loggingService.catch("Error in PresenceTooltipComponent unsubscribe: ",e)}}calculateUserAwayTime(e){try{if(e.onlineStatus===p.PRESENCE_STATUS_ONLINE)return 0;let t=me(e.timestamp);return Math.floor(t/1e3/60)}catch(t){this.loggingService.catch("Error in PresenceTooltipComponent calculateUserAwayTime: ",t)}return 0}};r.\u0275fac=function(t){return new(t||r)(m(I),m(We),m(f),m(v),m(Be))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-tooltip"]],inputs:{presenceUser:"presenceUser",shadowDom:"shadowDom",variant:"variant"},standalone:!1,features:[U,we],decls:1,vars:1,consts:[["presenceTooltipRef",""],[4,"ngIf"],[4,"veltIf"],[4,"ngIf","ngIfElse"],[4,"ngTemplateOutlet"],["class","velt-presence-tooltip-container",4,"ngIf"],[1,"velt-presence-tooltip-container"],[4,"veltDynamicTemplate"],[1,"velt-presence-tooltip","s-tooltiptext","s-presence-tooltip"],[3,"componentConfigSignal"]],template:function(t,i){t&1&&g(0,or,2,7,"ng-container",1),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,Le,N,A,fe,ye],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]{--velt-green: var(--velt-light-mode-green);--velt-magenta: var(--velt-light-mode-magenta);--velt-amber: var(--velt-light-mode-amber);--velt-purple: var(--velt-light-mode-purple);--velt-cyan: var(--velt-light-mode-cyan);--velt-orange: var(--velt-light-mode-orange);--velt-black: var(--velt-light-mode-black);--velt-white: var(--velt-light-mode-white);--velt-gray: var(--velt-light-mode-gray);--velt-error: var(--velt-light-mode-error);--velt-error-hover: var(--velt-light-mode-error-hover);--velt-error-foreground: var(--velt-light-mode-error-foreground);--velt-error-light: var(--velt-light-mode-error-light);--velt-error-transparent: var(--velt-light-mode-error-transparent);--velt-warning: var(--velt-light-mode-warning);--velt-warning-hover: var(--velt-light-mode-warning-hover);--velt-warning-foreground: var(--velt-light-mode-warning-foreground);--velt-warning-light: var(--velt-light-mode-warning-light);--velt-warning-transparent: var(--velt-light-mode-warning-transparent);--velt-agent-accent: #4495ff;--velt-agent-accent-transparent: rgba(68, 149, 255, .2);--velt-success: var(--velt-light-mode-success);--velt-success-hover: var(--velt-light-mode-success-hover);--velt-success-foreground: var(--velt-light-mode-success-foreground);--velt-success-light: var(--velt-light-mode-success-light);--velt-success-transparent: var(--velt-light-mode-success-transparent);--velt-accent: var(--velt-light-mode-accent);--velt-accent-text: var(--velt-light-mode-accent-text);--velt-accent-hover: var(--velt-light-mode-accent-hover);--velt-accent-foreground: var(--velt-light-mode-accent-foreground);--velt-accent-light: var(--velt-light-mode-accent-light);--velt-accent-transparent: var(--velt-light-mode-accent-transparent);--velt-text-0: var(--velt-light-mode-text-0);--velt-text-1: var(--velt-light-mode-text-1);--velt-text-2: var(--velt-light-mode-text-2);--velt-text-3: var(--velt-light-mode-text-3);--velt-text-4: var(--velt-light-mode-text-4);--velt-text-5: var(--velt-light-mode-text-5);--velt-text-6: var(--velt-light-mode-text-6);--velt-text-7: var(--velt-light-mode-text-7);--velt-text-8: var(--velt-light-mode-text-8);--velt-text-9: var(--velt-light-mode-text-9);--velt-text-10: var(--velt-light-mode-text-10);--velt-text-11: var(--velt-light-mode-text-11);--velt-text-12: var(--velt-light-mode-text-12);--velt-background-0: var(--velt-light-mode-background-0);--velt-background-1: var(--velt-light-mode-background-1);--velt-background-2: var(--velt-light-mode-background-2);--velt-background-3: var(--velt-light-mode-background-3);--velt-background-4: var(--velt-light-mode-background-4);--velt-background-5: var(--velt-light-mode-background-5);--velt-background-6: var(--velt-light-mode-background-6);--velt-background-7: var(--velt-light-mode-background-7);--velt-background-8: var(--velt-light-mode-background-8);--velt-background-9: var(--velt-light-mode-background-9);--velt-background-10: var(--velt-light-mode-background-10);--velt-border-0: var(--velt-light-mode-border-0);--velt-border-1: var(--velt-light-mode-border-1);--velt-border-2: var(--velt-light-mode-border-2);--velt-border-3: var(--velt-light-mode-border-3);--velt-border-4: var(--velt-light-mode-border-4);--velt-border-5: var(--velt-light-mode-border-5);--velt-border-6: var(--velt-light-mode-border-6);--velt-border-7: var(--velt-light-mode-border-7);--velt-border-8: var(--velt-light-mode-border-8);--velt-border-9: var(--velt-light-mode-border-9);--velt-border-10: var(--velt-light-mode-border-10);--velt-background-transparent: var(--velt-light-mode-background-transparent);--velt-border-transparent: var(--velt-light-mode-border-transparent);--velt-animation-transparent: var(--velt-light-mode-animation-transparent);margin:calc((.5rem + 0px) * var(--velt-base-rem-unit))}[_nghost-%COMP%]:empty{display:none}[dark][_nghost-%COMP%]{--velt-green: var(--velt-dark-mode-green);--velt-magenta: var(--velt-dark-mode-magenta);--velt-amber: var(--velt-dark-mode-amber);--velt-purple: var(--velt-dark-mode-purple);--velt-cyan: var(--velt-dark-mode-cyan);--velt-orange: var(--velt-dark-mode-orange);--velt-black: var(--velt-dark-mode-black);--velt-white: var(--velt-dark-mode-white);--velt-gray: var(--velt-dark-mode-gray);--velt-error: var(--velt-dark-mode-error);--velt-error-hover: var(--velt-dark-mode-error-hover);--velt-error-foreground: var(--velt-dark-mode-error-foreground);--velt-error-light: var(--velt-dark-mode-error-light);--velt-error-transparent: var(--velt-dark-mode-error-transparent);--velt-warning: var(--velt-dark-mode-warning);--velt-warning-hover: var(--velt-dark-mode-warning-hover);--velt-warning-foreground: var(--velt-dark-mode-warning-foreground);--velt-warning-light: var(--velt-dark-mode-warning-light);--velt-warning-transparent: var(--velt-dark-mode-warning-transparent);--velt-agent-accent: #4495ff;--velt-agent-accent-transparent: rgba(68, 149, 255, .2);--velt-success: var(--velt-dark-mode-success);--velt-success-hover: var(--velt-dark-mode-success-hover);--velt-success-foreground: var(--velt-dark-mode-success-foreground);--velt-success-light: var(--velt-dark-mode-success-light);--velt-success-transparent: var(--velt-dark-mode-success-transparent);--velt-accent: var(--velt-dark-mode-accent);--velt-accent-text: var(--velt-dark-mode-accent-text);--velt-accent-hover: var(--velt-dark-mode-accent-hover);--velt-accent-foreground: var(--velt-dark-mode-accent-foreground);--velt-accent-light: var(--velt-dark-mode-accent-light);--velt-accent-transparent: var(--velt-dark-mode-accent-transparent);--velt-text-0: var(--velt-dark-mode-text-0);--velt-text-1: var(--velt-dark-mode-text-1);--velt-text-2: var(--velt-dark-mode-text-2);--velt-text-3: var(--velt-dark-mode-text-3);--velt-text-4: var(--velt-dark-mode-text-4);--velt-text-5: var(--velt-dark-mode-text-5);--velt-text-6: var(--velt-dark-mode-text-6);--velt-text-7: var(--velt-dark-mode-text-7);--velt-text-8: var(--velt-dark-mode-text-8);--velt-text-9: var(--velt-dark-mode-text-9);--velt-text-10: var(--velt-dark-mode-text-10);--velt-text-11: var(--velt-dark-mode-text-11);--velt-text-12: var(--velt-dark-mode-text-12);--velt-background-0: var(--velt-dark-mode-background-0);--velt-background-1: var(--velt-dark-mode-background-1);--velt-background-2: var(--velt-dark-mode-background-2);--velt-background-3: var(--velt-dark-mode-background-3);--velt-background-4: var(--velt-dark-mode-background-4);--velt-background-5: var(--velt-dark-mode-background-5);--velt-background-6: var(--velt-dark-mode-background-6);--velt-background-7: var(--velt-dark-mode-background-7);--velt-background-8: var(--velt-dark-mode-background-8);--velt-background-9: var(--velt-dark-mode-background-9);--velt-background-10: var(--velt-dark-mode-background-10);--velt-border-0: var(--velt-dark-mode-border-0);--velt-border-1: var(--velt-dark-mode-border-1);--velt-border-2: var(--velt-dark-mode-border-2);--velt-border-3: var(--velt-dark-mode-border-3);--velt-border-4: var(--velt-dark-mode-border-4);--velt-border-5: var(--velt-dark-mode-border-5);--velt-border-6: var(--velt-dark-mode-border-6);--velt-border-7: var(--velt-dark-mode-border-7);--velt-border-8: var(--velt-dark-mode-border-8);--velt-border-9: var(--velt-dark-mode-border-9);--velt-border-10: var(--velt-dark-mode-border-10);--velt-background-transparent: var(--velt-dark-mode-background-transparent);--velt-border-transparent: var(--velt-dark-mode-border-transparent);--velt-animation-transparent: var(--velt-dark-mode-animation-transparent)}.velt-presence-tooltip[_ngcontent-%COMP%]{display:flex;align-items:center;gap:calc((.5rem + 0px) * var(--velt-base-rem-unit));block-size:auto;width:max-content;background-color:var(--velt-background-0);border:1px solid var(--velt-border-5);color:var(--velt-text-0);text-align:left;padding:var(--velt-spacing-xs) var(--velt-spacing-sm);border-radius:var(--velt-border-radius-xs);font-style:normal;font-weight:400;font-size:var(--velt-font-size-xs);line-height:2em;z-index:1;transition:opacity .5s}.velt-presence-tooltip[_ngcontent-%COMP%]:after{background-color:var(--velt-background-0);border-color:var(--velt-border-5)}"],changeDetection:0});let n=r;return n})();var sr=["tooltipContent"],rn=(n,r,o)=>({componentConfigSignal:n,presenceUser:r,index:o}),cr=(n,r)=>({condition:n,data:r}),lr=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-avatar-list-item-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function mr(n,r){if(n&1){let o=qe();d(0),T(1,"snippyly-user-avatar",6),et("click",function(){De(o);let t=s(3).ngIf,i=s();return Ae(t.onPresenceUserClick(i.presenceUser))}),R(2,"div",7),O(),u()}if(n&2){let o=s(4);l(),Re("away",o.presenceUser.onlineStatus===o.constants.PRESENCE_STATUS_AWAY)("velt-presence-avatar--away",o.presenceUser.onlineStatus===o.constants.PRESENCE_STATUS_AWAY),c("user",o.presenceUser),l(),ut("border-color",o.presenceUser.color)}}function gr(n,r){if(n&1){let o=qe();T(0,"div",4),et("pointerenter",function(t){De(o);let i=s(2).ngIf,a=s();return i.showTooltip(t,a.presenceUser),Ae(t.stopPropagation())})("pointerleave",function(t){return De(o),s(2).ngIf.closeTooltip(),Ae(t.stopPropagation())}),g(1,mr,3,7,"ng-container",5),O()}if(n&2){let o=s(2).ngIf,e=s();l(),c("veltDynamicTemplate",k(5,lr,e.template,tt(1,rn,e.componentConfigSignal,e.presenceUser,e.index),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function vr(n,r){if(n&1&&R(0,"velt-presence-tooltip",8),n&2){let o=r.$implicit,e=s(2).ngIf;c("presenceUser",o)("shadowDom",e.shadowDom)}}function pr(n,r){if(n&1&&(d(0),g(1,gr,2,11,"div",3)(2,vr,1,2,"ng-template",null,0,ne),u()),n&2){let o=s().ngIf,e=s();l(),c("ngIf",e.index<o.maxUsers)}}function dr(n,r){if(n&1&&(d(0),g(1,pr,4,1,"ng-container",2),u()),n&2){let o=s();l(),c("veltIf",b(5,cr,o.conditionSignal(),tt(1,rn,o.componentConfigSignal,o.presenceUser,o.index)))}}var be=(()=>{let r=class r extends ${get itemTemplate(){return this._itemTemplate}set itemTemplate(e){try{this._itemTemplate=e,this.itemTemplate?this.template=this.domService.deepCloneElement(this.itemTemplate):this.template=null}catch{}}constructor(e,t,i,a){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.domService=a,this.componentId="velt-presence-avatar-list-item",this.constants=p;try{super.initializeComponentConfigSignal(new ie)}catch(h){this.loggingService.catch("Error in PresenceAvatarListItemComponent constructor: ",h)}}ngOnInit(){try{this.dynamicDataService.applyConditionalClasses(this.elementRef.nativeElement,{componentConfigSignal:this.componentConfigSignal,presenceUser:this.presenceUser,index:this.index}),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in PresenceAvatarListItemComponent ngOnInit: ",e)}}ngAfterViewInit(){try{setTimeout(()=>{this.componentConfigSignal.set(w(C({},this.componentConfigSignal()),{tooltipContent:this.tooltipContent}))},1e3)}catch(e){this.loggingService.catch("Error in PresenceAvatarListItemComponent ngAfterViewInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceAvatarListItemComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceAvatarListItemComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(I),m(f),m(v),m(je))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-avatar-list-item-internal"]],viewQuery:function(t,i){if(t&1&&vt(sr,5),t&2){let a;pt(a=dt())&&(i.tooltipContent=a.first)}},inputs:{presenceUser:"presenceUser",index:"index",itemTemplate:"itemTemplate"},standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[["tooltipContent",""],[4,"ngIf"],[4,"veltIf"],["class","velt-presence-avatar-list-item velt-tooltip s-presence-avatar-container s-tooltip",3,"pointerenter","pointerleave",4,"ngIf"],[1,"velt-presence-avatar-list-item","velt-tooltip","s-presence-avatar-container","s-tooltip",3,"pointerenter","pointerleave"],[4,"veltDynamicTemplate"],[1,"velt-presence-avatar","s-presence-avatar",3,"click","user"],[1,"velt-presence-avatar-outline","avatar-outline"],[3,"presenceUser","shadowDom"]],template:function(t,i){t&1&&g(0,dr,2,8,"ng-container",1),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,N,A,re,Ie],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]:empty{display:none}.velt-presence-avatar-list-item[_ngcontent-%COMP%]{height:calc((1.5 + 0px) * var(--velt-base-rem-unit));width:calc((1.5 + 0px) * var(--velt-base-rem-unit));display:flex;justify-content:center;align-items:center;cursor:pointer}.velt-presence-avatar-list-item[_ngcontent-%COMP%] .velt-presence-avatar[_ngcontent-%COMP%]{position:relative;border-radius:var(--velt-border-radius-full);z-index:2;width:calc((1.5 + 0px) * var(--velt-base-rem-unit));height:calc((1.5 + 0px) * var(--velt-base-rem-unit));display:flex;align-items:center;justify-content:center}.velt-presence-avatar--away[_ngcontent-%COMP%]{filter:grayscale(.7)}.velt-presence-avatar-outline[_ngcontent-%COMP%]{position:absolute;inset:-1px;border:1px solid transparent;border-radius:var(--velt-border-radius-full)}snippyly-user-avatar[_ngcontent-%COMP%]{--legacy-velt-user-avatar-size: 1.5rem}"],changeDetection:0});let n=r;return n})();var on=n=>({componentConfigSignal:n}),hr=(n,r)=>({condition:n,data:r}),fr=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-avatar-list-wireframe",variant:o,setIfCondition:e,componentElementRef:t,replaceTemplate:!1});function Sr(n,r){if(n&1&&(d(0),R(1,"velt-presence-avatar-list-item-internal",4),u()),n&2){let o=r.$implicit,e=r.index,t=s(4);l(),c("presenceUser",o)("index",e)("componentConfigSignal",t.componentConfigSignal)("itemTemplate",t.itemTemplate)}}function Cr(n,r){if(n&1&&(d(0),g(1,Sr,2,4,"ng-container",3),u()),n&2){let o=s(2).ngIf;l(),c("ngForOf",o.filteredPresenceUsers)("ngForTrackBy",o.trackById)}}function _r(n,r){if(n&1&&(d(0),g(1,Cr,2,2,"ng-container",2),u()),n&2){let o=s().ngIf,e=s();l(),c("veltDynamicTemplate",k(3,fr,e.template,_(1,on,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function yr(n,r){if(n&1&&(d(0),g(1,_r,2,9,"ng-container",1),u()),n&2){let o=s();l(),c("veltIf",b(3,hr,o.conditionSignal(),_(1,on,o.componentConfigSignal)))}}var Ee=(()=>{let r=class r extends ${constructor(e,t,i){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.componentId="velt-presence-avatar-list",this.constants=p;try{super.initializeComponentConfigSignal(new ie)}catch(a){this.loggingService.catch("Error in PresenceAvatarListComponent constructor: ",a)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes();let e=this.template?.querySelector("velt-presence-avatar-list-item-wireframe");Dt(e)||(this.itemTemplate=e)}catch(e){this.loggingService.catch("Error in PresenceAvatarListComponent ngOnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceAvatarListComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceAvatarListComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(I),m(f),m(v))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-avatar-list-internal"]],standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"],[4,"ngFor","ngForOf","ngForTrackBy"],[3,"presenceUser","index","componentConfigSignal","itemTemplate"]],template:function(t,i){t&1&&g(0,yr,2,6,"ng-container",0),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[ft,D,N,A,be],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]{position:relative;display:flex;flex-direction:row;justify-content:center;align-items:center;height:calc((1.5 + 0px) * var(--velt-base-rem-unit));min-width:calc((1.5 + 0px) * var(--velt-base-rem-unit))}[_nghost-%COMP%]:empty{display:none}velt-presence-avatar-list-item-internal[_ngcontent-%COMP%]:not(:first-child){margin-left:calc(var(--velt-spacing-xs) * -1)}"],changeDetection:0});let n=r;return n})();var an=n=>({componentConfigSignal:n}),br=(n,r)=>({condition:n,data:r}),Er=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-avatar-remaining-count-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function Pr(n,r){if(n&1&&(d(0),T(1,"snippyly-user-avatar",3),R(2,"div",4),O(),u()),n&2){let o=s(3).ngIf;l(),c("initial","+"+(o.filteredPresenceUsers.length-o.maxUsers).toString())}}function xr(n,r){if(n&1&&(d(0),g(1,Pr,3,1,"ng-container",2),u()),n&2){let o=s(2).ngIf,e=s();l(),c("veltDynamicTemplate",k(3,Er,e.template,_(1,an,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function Ur(n,r){if(n&1&&(d(0),g(1,xr,2,9,"ng-container",0),u()),n&2){let o=s().ngIf;l(),c("ngIf",o.filteredPresenceUsers.length>o.maxUsers)}}function Tr(n,r){if(n&1&&(d(0),g(1,Ur,2,1,"ng-container",1),u()),n&2){let o=s();l(),c("veltIf",b(3,br,o.conditionSignal(),_(1,an,o.componentConfigSignal)))}}var Pe=(()=>{let r=class r extends ${constructor(e,t,i){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.componentId="velt-presence-avatar-remaining-count";try{super.initializeComponentConfigSignal(new ie)}catch(a){this.loggingService.catch("Error in PresenceAvatarRemainingCountComponent constructor: ",a)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in PresenceAvatarRemainingCountComponent ngOnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceAvatarRemainingCountComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceAvatarRemainingCountComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(I),m(f),m(v))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-avatar-remaining-count-internal"]],standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"],[1,"velt-presence-avatar","velt-presence-avatar-remaining-count","s-presence-avatar","more-users",3,"initial"],[1,"velt-presence-avatar-remaining-count-outline","avatar-outline"]],template:function(t,i){t&1&&g(0,Tr,2,6,"ng-container",0),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,N,A,re],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]:empty{display:none}.velt-presence-avatar[_ngcontent-%COMP%]{position:relative;border-radius:var(--velt-border-radius-full);z-index:2;width:calc((1.5 + 0px) * var(--velt-base-rem-unit));height:calc((1.5 + 0px) * var(--velt-base-rem-unit));display:flex;align-items:center;justify-content:center}.velt-presence-avatar.velt-presence-avatar-remaining-count[_ngcontent-%COMP%]{box-shadow:none;color:var(--velt-text-0);margin-left:calc(var(--velt-spacing-xs) * -1);background-color:var(--legacy-velt-presence-more-users-color)}.velt-presence-avatar.velt-presence-avatar-remaining-count[_ngcontent-%COMP%] .velt-presence-avatar-remaining-count-outline[_ngcontent-%COMP%]{border-color:var(--legacy-velt-presence-more-users-color)}snippyly-user-avatar[_ngcontent-%COMP%]{--legacy-velt-user-avatar-size: 1.5rem}"],changeDetection:0});let n=r;return n})();var sn=n=>({componentConfigSignal:n}),kr=(n,r)=>({condition:n,data:r}),Dr=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function Ar(n,r){n&1&&Fe(0)}function Nr(n,r){if(n&1&&(T(0,"velt-shadow-dom-internal"),g(1,Ar,1,0,"ng-container",4),O()),n&2){s();let o=te(3);l(),c("ngTemplateOutlet",o)}}function wr(n,r){if(n&1&&(d(0),R(1,"velt-presence-avatar-list-internal",8)(2,"velt-presence-avatar-remaining-count-internal",8),u()),n&2){let o=s(5);l(),c("componentConfigSignal",o.componentConfigSignal),l(),c("componentConfigSignal",o.componentConfigSignal)}}function Fr(n,r){if(n&1&&(T(0,"div",6),g(1,wr,3,2,"ng-container",7),O()),n&2){let o=s(3).ngIf,e=s();l(),c("veltDynamicTemplate",k(3,Dr,e.template,_(1,sn,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function Rr(n,r){if(n&1&&g(0,Fr,2,9,"div",5),n&2){let o=s(2).ngIf;c("ngIf",o.filteredPresenceUsers&&o.filteredPresenceUsers.length>0&&!(o.user!=null&&o.user.isAnonymous))}}function Mr(n,r){if(n&1&&(d(0),g(1,Nr,2,1,"velt-shadow-dom-internal",3)(2,Rr,1,1,"ng-template",null,0,ne),u()),n&2){let o=te(3),e=s().ngIf,t=s();l(),c("ngIf",e.shadowDom&&!t.template||t.template&&t.isExplicitShadowDom)("ngIfElse",o)}}function Lr(n,r){if(n&1&&(d(0),g(1,Mr,4,2,"ng-container",2),u()),n&2){let o=s();l(),c("veltIf",b(3,kr,o.conditionSignal(),_(1,sn,o.componentConfigSignal)))}}var pe=(()=>{let r=class r extends ze{get maxUsers(){return this._maxUsers}set maxUsers(e){try{isNaN(e)?this.loggingService.catch("Error in Presence set maxUsers: ","max-user value is not a number."):this._maxUsers=e}catch(t){this.loggingService.catch("Error in Presence set maxUsers: ",t)}}get inactivityTime(){return this._inactivityTime}set inactivityTime(e){try{isNaN(e)?this.loggingService.catch("Error in Presence set inactivityTime: ","inactivity-time value is not a number."):(this._inactivityTime=e,this.presenceService.setInactivityTime(this._inactivityTime))}catch(t){this.loggingService.catch("Error in Presence set inactivityTime: ",t)}}get offlineInactivityTime(){return this._offlineInactivityTime}set offlineInactivityTime(e){try{isNaN(e)?this.loggingService.catch("Error in Presence set offlineInactivityTime: ","offline-inactivity-time value is not a number."):(this._offlineInactivityTime=e,this.presenceService.setOfflineInactivityTime(this._offlineInactivityTime))}catch(t){this.loggingService.catch("Error in Presence set offlineInactivityTime: ",t)}}get flockMode(){return this._flockMode}set flockMode(e){try{let t=typeof e=="string"?JSON.parse(e):e;t?(this._flockMode=t,this.flockService.enableFlockMode(),this.flockService.setNavigateEmitter(this.onNavigate)):(this._flockMode=t,this.flockService.disableFlockMode())}catch(t){this.loggingService.catch("Error in Presence set flockMode: ",t)}}set disableFlockNavigation(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.flockService.setDisableFlockNavigation(t)}catch(t){this.loggingService.catch("Error in Presence set disableFlockNavigation: ",t)}}set defaultFlockNavigation(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.flockService.setDisableFlockNavigation(!t)}catch(t){this.loggingService.catch("Error in Presence set defaultFlockNavigation: ",t)}}get location(){return this._location}set location(e){try{if(e&&typeof e=="string"){let t=JSON.parse(e);this._location=t,this.serverLocationId=Ot(this.location)}}catch(t){this.loggingService.catch("Error in Presence set location: ",t)}}set self(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.presenceService.enableIncludeSelf():this.presenceService.disableIncludeSelf()}catch{}}set _shadowDom(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.isExplicitShadowDom=!!t,this.componentConfigSignal.update(i=>(i=w(C({},i),{shadowDom:t}),i))}catch{}}constructor(e,t,i,a,h,y,M,Ve,Ye,Ue,Te,Oe){super(Ue,Te,void 0,void 0,void 0,Oe,h),this.analyticsService=e,this.authService=t,this.flockService=i,this.presenceService=a,this.loggingService=h,this.wireframeService=y,this.overlay=M,this.overlayPositionBuilder=Ve,this.viewContainerRef=Ye,this.elementRef=Ue,this.themeService=Te,this.dynamicDataService=Oe,this.DEFAULT_MAX_USERS=5,this._maxUsers=this.DEFAULT_MAX_USERS,this._inactivityTime=5,this._offlineInactivityTime=10,this._flockMode=!1,this.onNavigate=new he,this.isExplicitShadowDom=!1,this.onPresenceUserClickEmitter=new he,this.presenceUsers=[],this.subscriptions=[],this.constants=p,this.onUsersChanged=new he,this.onPresenceUserChange=new he,this.componentConfigSignal=Ne({filteredPresenceUsers:[],user:null,shadowDom:!0,maxUsers:5,tooltipContent:null,trackById:this.trackById.bind(this),showTooltip:this.showTooltip.bind(this),closeTooltip:this.closeTooltip.bind(this),onPresenceUserClick:this.onPresenceUserClick.bind(this)}),this.veltElement=!0,this.componentId="velt-presence",this.loggingService.log("%c[WB] Creating CLASS: PresenceComponent","color: blue;"),this.subscriptions.push(this.authService.getUser$().subscribe(de=>{this.componentConfigSignal.update(S=>(S=w(C({},S),{user:de}),S)),this.componentConfigSignal().user&&(this.setPresenceInstalledInAnalytics(),this.presenceSetCustomMaxUsersInAnalytics())},de=>{this.loggingService.catch("Error in PresenceComponent getUser$ subscription: ",de)}))}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;");try{this.getOnlineUsersOnCurrentDocument(),this.setupA11yAttributes(),super.ngOnInit(),this.subscriptions.push(this.wireframeService.getWireframe$("velt-presence-wireframe").subscribe(t=>{if(t){let i=document.createElement(t.tagName);i.innerHTML=t.innerHTML,this.template=i}}))}catch(e){this.loggingService.catch("Error in PresenceComponent oninit: ",e)}}ngOnChanges(e){try{this.loggingService.log("%c[WB] Calling PresenceComponent FUNCTION: ngOnChanges","color: green;"),e&&(super.ngOnChanges(e),Object.keys(e).forEach(t=>{this.componentConfigSignal.update(i=>(i=w(C({},i),{[t]:e[t].currentValue}),i))}))}catch(t){this.loggingService.catch("Error in PresenceComponent ngOnChanges: ",t)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceComponent setupA11yAttributes:",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe(),super.ngOnDestroy(),this.closeTooltip()}catch(e){this.loggingService.catch("Error in PresenceComponent ondestroy: ",e)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.loggingService.catch("Error in PresenceComponent unsubscribe: ",e)}}showTooltip(e,t){try{this.closeTooltip();let i=new I(e.currentTarget),a=this.overlayPositionBuilder.flexibleConnectedTo(i).withPositions([{originX:"center",originY:"bottom",overlayX:"center",overlayY:"top"},{originX:"center",originY:"top",overlayX:"center",overlayY:"bottom"},{originX:"start",originY:"center",overlayX:"end",overlayY:"center"},{originX:"end",originY:"center",overlayX:"start",overlayY:"center"}]);this.overlayRef=this.overlay.create({positionStrategy:a}),this.overlayRef.attach(new Ct(this.componentConfigSignal().tooltipContent,this.viewContainerRef,{$implicit:t}))}catch(i){this.loggingService.catch("Error in PresenceComponent showTooltip: ",i)}}closeTooltip(){try{this.overlayRef&&this.overlayRef.dispose()}catch(e){this.loggingService.catch("Error in PresenceComponent closeTooltip: ",e)}}getOnlineUsersOnCurrentDocument(){this.loggingService.log("%c[WB] Calling FUNCTION: getOnlineUsersOnCurrentDocument","color: green;");try{this.subscriptions.push(this.presenceService.getOnlineUsersOnCurrentDocument().pipe(Y(e=>!!e)).subscribe(e=>{this.loggingService.log(e),e&&(this.presenceUsers=e),this.filterPresenceUsers()},e=>{this.loggingService.catch("Error in PresenceComponent getOnlineUsersOnCurrentDocument subscription: ",e)}))}catch(e){this.loggingService.catch("Error in PresenceComponent getOnlineUsersOnCurrentDocument: ",e)}}filterPresenceUsers(){try{let e=[];this.presenceUsers?this.locationId?e=this.presenceUsers.filter(t=>t?.location?.id===this.locationId):this.location?e=this.presenceUsers.filter(t=>t.locationId===this.serverLocationId):e=this.presenceUsers:e=[],this.componentConfigSignal.update(t=>(t=w(C({},t),{filteredPresenceUsers:e}),t)),this.onUsersChanged.emit(this.componentConfigSignal().filteredPresenceUsers),this.onPresenceUserChange.emit(this.componentConfigSignal().filteredPresenceUsers)}catch(e){this.loggingService.catch("Error in PresenceComponent filterPresenceUsers: ",e)}}calculateUserAwayTime(e){try{if(e.onlineStatus===p.PRESENCE_STATUS_ONLINE)return 0;let t=me(e.timestamp);return Math.floor(t/1e3/60)}catch(t){this.loggingService.catch("Error in PresenceComponent calculateUserAwayTime: ",t)}return 0}setPresenceInstalledInAnalytics(){try{this.analyticsService.setInstalledFeature(X.PRESENCE)}catch(e){this.loggingService.catch("Error in PresenceComponent setPresenceInstalledInAnalytics: ",e)}}presenceSetCustomMaxUsersInAnalytics(){try{this.maxUsers!=this.DEFAULT_MAX_USERS&&this.analyticsService.trackEvent(E.Events.Presence.PRESENCE_SET_CUSTOM_MAX_USERS,{maxUsers:+this.maxUsers})}catch(e){this.loggingService.catch("Error in PresenceComponent presenceSetCustomMaxUsersInAnalytics: ",e)}}onPresenceUserClick(e){try{this.analyticsService.trackEvent(E.Events.Presence.PRESENCE_USER_CLICKED,{totalUsers:this.presenceService?.getPresenceUsers()?.length,presenceSnippylyUserIds:this.presenceService?.getPresenceUsers()?.map(t=>t.userSnippylyId),presenceClientUserIds:this.presenceService?.getPresenceUsers()?.map(t=>t.userId)}),this.onPresenceUserClickEmitter.emit(e),this.componentConfigSignal().user?.userSnippylyId!==e?.userSnippylyId&&this.flockService.getFlockMode()&&this.setFlockLeader(e.userSnippylyId,e.name)}catch(t){this.loggingService.catch("Error in PresenceComponent onPresenceUserClick: ",t)}}setFlockLeader(e,t){try{this.flockService.setFlockLeader(e,t)}catch(i){this.loggingService.catch("Error in PresenceComponent setFlockLeader: ",i)}}trackById(e,t){return t?.userId}};r.\u0275fac=function(t){return new(t||r)(m(ge),m($e),m(K),m(z),m(v),m(Be),m(yt),m(_t),m(ct),m(I),m(We),m(f))},r.\u0275cmp=x({type:r,selectors:[["app-presence"]],hostVars:1,hostBindings:function(t,i){t&2&>("data-velt-element",i.veltElement)},inputs:{maxUsers:"maxUsers",inactivityTime:"inactivityTime",offlineInactivityTime:"offlineInactivityTime",flockMode:"flockMode",disableFlockNavigation:"disableFlockNavigation",defaultFlockNavigation:"defaultFlockNavigation",location:"location",locationId:"locationId",self:"self",_shadowDom:[0,"shadowDom","_shadowDom"],variant:"variant"},outputs:{onNavigate:"onNavigate",onPresenceUserClickEmitter:"onPresenceUserClick",onUsersChanged:"usersChanged",onPresenceUserChange:"onPresenceUserChange"},standalone:!1,features:[U,we],decls:1,vars:1,consts:[["presenceRef",""],[4,"ngIf"],[4,"veltIf"],[4,"ngIf","ngIfElse"],[4,"ngTemplateOutlet"],["class","velt-presence-container s-presence-container",4,"ngIf"],[1,"velt-presence-container","s-presence-container"],[4,"veltDynamicTemplate"],[3,"componentConfigSignal"]],template:function(t,i){t&1&&g(0,Lr,2,6,"ng-container",1),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,Le,N,A,Ee,Pe],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]{--velt-green: var(--velt-light-mode-green);--velt-magenta: var(--velt-light-mode-magenta);--velt-amber: var(--velt-light-mode-amber);--velt-purple: var(--velt-light-mode-purple);--velt-cyan: var(--velt-light-mode-cyan);--velt-orange: var(--velt-light-mode-orange);--velt-black: var(--velt-light-mode-black);--velt-white: var(--velt-light-mode-white);--velt-gray: var(--velt-light-mode-gray);--velt-error: var(--velt-light-mode-error);--velt-error-hover: var(--velt-light-mode-error-hover);--velt-error-foreground: var(--velt-light-mode-error-foreground);--velt-error-light: var(--velt-light-mode-error-light);--velt-error-transparent: var(--velt-light-mode-error-transparent);--velt-warning: var(--velt-light-mode-warning);--velt-warning-hover: var(--velt-light-mode-warning-hover);--velt-warning-foreground: var(--velt-light-mode-warning-foreground);--velt-warning-light: var(--velt-light-mode-warning-light);--velt-warning-transparent: var(--velt-light-mode-warning-transparent);--velt-agent-accent: #4495ff;--velt-agent-accent-transparent: rgba(68, 149, 255, .2);--velt-success: var(--velt-light-mode-success);--velt-success-hover: var(--velt-light-mode-success-hover);--velt-success-foreground: var(--velt-light-mode-success-foreground);--velt-success-light: var(--velt-light-mode-success-light);--velt-success-transparent: var(--velt-light-mode-success-transparent);--velt-accent: var(--velt-light-mode-accent);--velt-accent-text: var(--velt-light-mode-accent-text);--velt-accent-hover: var(--velt-light-mode-accent-hover);--velt-accent-foreground: var(--velt-light-mode-accent-foreground);--velt-accent-light: var(--velt-light-mode-accent-light);--velt-accent-transparent: var(--velt-light-mode-accent-transparent);--velt-text-0: var(--velt-light-mode-text-0);--velt-text-1: var(--velt-light-mode-text-1);--velt-text-2: var(--velt-light-mode-text-2);--velt-text-3: var(--velt-light-mode-text-3);--velt-text-4: var(--velt-light-mode-text-4);--velt-text-5: var(--velt-light-mode-text-5);--velt-text-6: var(--velt-light-mode-text-6);--velt-text-7: var(--velt-light-mode-text-7);--velt-text-8: var(--velt-light-mode-text-8);--velt-text-9: var(--velt-light-mode-text-9);--velt-text-10: var(--velt-light-mode-text-10);--velt-text-11: var(--velt-light-mode-text-11);--velt-text-12: var(--velt-light-mode-text-12);--velt-background-0: var(--velt-light-mode-background-0);--velt-background-1: var(--velt-light-mode-background-1);--velt-background-2: var(--velt-light-mode-background-2);--velt-background-3: var(--velt-light-mode-background-3);--velt-background-4: var(--velt-light-mode-background-4);--velt-background-5: var(--velt-light-mode-background-5);--velt-background-6: var(--velt-light-mode-background-6);--velt-background-7: var(--velt-light-mode-background-7);--velt-background-8: var(--velt-light-mode-background-8);--velt-background-9: var(--velt-light-mode-background-9);--velt-background-10: var(--velt-light-mode-background-10);--velt-border-0: var(--velt-light-mode-border-0);--velt-border-1: var(--velt-light-mode-border-1);--velt-border-2: var(--velt-light-mode-border-2);--velt-border-3: var(--velt-light-mode-border-3);--velt-border-4: var(--velt-light-mode-border-4);--velt-border-5: var(--velt-light-mode-border-5);--velt-border-6: var(--velt-light-mode-border-6);--velt-border-7: var(--velt-light-mode-border-7);--velt-border-8: var(--velt-light-mode-border-8);--velt-border-9: var(--velt-light-mode-border-9);--velt-border-10: var(--velt-light-mode-border-10);--velt-background-transparent: var(--velt-light-mode-background-transparent);--velt-border-transparent: var(--velt-light-mode-border-transparent);--velt-animation-transparent: var(--velt-light-mode-animation-transparent)}[_nghost-%COMP%]:empty{display:none}[dark][_nghost-%COMP%]{--velt-green: var(--velt-dark-mode-green);--velt-magenta: var(--velt-dark-mode-magenta);--velt-amber: var(--velt-dark-mode-amber);--velt-purple: var(--velt-dark-mode-purple);--velt-cyan: var(--velt-dark-mode-cyan);--velt-orange: var(--velt-dark-mode-orange);--velt-black: var(--velt-dark-mode-black);--velt-white: var(--velt-dark-mode-white);--velt-gray: var(--velt-dark-mode-gray);--velt-error: var(--velt-dark-mode-error);--velt-error-hover: var(--velt-dark-mode-error-hover);--velt-error-foreground: var(--velt-dark-mode-error-foreground);--velt-error-light: var(--velt-dark-mode-error-light);--velt-error-transparent: var(--velt-dark-mode-error-transparent);--velt-warning: var(--velt-dark-mode-warning);--velt-warning-hover: var(--velt-dark-mode-warning-hover);--velt-warning-foreground: var(--velt-dark-mode-warning-foreground);--velt-warning-light: var(--velt-dark-mode-warning-light);--velt-warning-transparent: var(--velt-dark-mode-warning-transparent);--velt-agent-accent: #4495ff;--velt-agent-accent-transparent: rgba(68, 149, 255, .2);--velt-success: var(--velt-dark-mode-success);--velt-success-hover: var(--velt-dark-mode-success-hover);--velt-success-foreground: var(--velt-dark-mode-success-foreground);--velt-success-light: var(--velt-dark-mode-success-light);--velt-success-transparent: var(--velt-dark-mode-success-transparent);--velt-accent: var(--velt-dark-mode-accent);--velt-accent-text: var(--velt-dark-mode-accent-text);--velt-accent-hover: var(--velt-dark-mode-accent-hover);--velt-accent-foreground: var(--velt-dark-mode-accent-foreground);--velt-accent-light: var(--velt-dark-mode-accent-light);--velt-accent-transparent: var(--velt-dark-mode-accent-transparent);--velt-text-0: var(--velt-dark-mode-text-0);--velt-text-1: var(--velt-dark-mode-text-1);--velt-text-2: var(--velt-dark-mode-text-2);--velt-text-3: var(--velt-dark-mode-text-3);--velt-text-4: var(--velt-dark-mode-text-4);--velt-text-5: var(--velt-dark-mode-text-5);--velt-text-6: var(--velt-dark-mode-text-6);--velt-text-7: var(--velt-dark-mode-text-7);--velt-text-8: var(--velt-dark-mode-text-8);--velt-text-9: var(--velt-dark-mode-text-9);--velt-text-10: var(--velt-dark-mode-text-10);--velt-text-11: var(--velt-dark-mode-text-11);--velt-text-12: var(--velt-dark-mode-text-12);--velt-background-0: var(--velt-dark-mode-background-0);--velt-background-1: var(--velt-dark-mode-background-1);--velt-background-2: var(--velt-dark-mode-background-2);--velt-background-3: var(--velt-dark-mode-background-3);--velt-background-4: var(--velt-dark-mode-background-4);--velt-background-5: var(--velt-dark-mode-background-5);--velt-background-6: var(--velt-dark-mode-background-6);--velt-background-7: var(--velt-dark-mode-background-7);--velt-background-8: var(--velt-dark-mode-background-8);--velt-background-9: var(--velt-dark-mode-background-9);--velt-background-10: var(--velt-dark-mode-background-10);--velt-border-0: var(--velt-dark-mode-border-0);--velt-border-1: var(--velt-dark-mode-border-1);--velt-border-2: var(--velt-dark-mode-border-2);--velt-border-3: var(--velt-dark-mode-border-3);--velt-border-4: var(--velt-dark-mode-border-4);--velt-border-5: var(--velt-dark-mode-border-5);--velt-border-6: var(--velt-dark-mode-border-6);--velt-border-7: var(--velt-dark-mode-border-7);--velt-border-8: var(--velt-dark-mode-border-8);--velt-border-9: var(--velt-dark-mode-border-9);--velt-border-10: var(--velt-dark-mode-border-10);--velt-background-transparent: var(--velt-dark-mode-background-transparent);--velt-border-transparent: var(--velt-dark-mode-border-transparent);--velt-animation-transparent: var(--velt-dark-mode-animation-transparent)}[_nghost-%COMP%]{position:relative;display:inline-flex;justify-content:center;align-items:center;margin:0;padding:0;-webkit-tap-highlight-color:rgba(255,255,255,0);box-sizing:border-box;width:auto;height:calc((1.5 + 0px) * var(--velt-base-rem-unit));font-size:var(--velt-font-size-xs);line-height:1.5;background:transparent}.velt-presence-container[_ngcontent-%COMP%]{position:relative;display:flex;flex-direction:row;justify-content:center;align-items:center;height:calc((1.5 + 0px) * var(--velt-base-rem-unit));min-width:calc((1.5 + 0px) * var(--velt-base-rem-unit))}"],changeDetection:0});let n=r;return n})();var xe=(()=>{let r=class r{constructor(e,t,i){this.analyticsService=e,this.loggingService=t,this.presenceService=i,this.actionSubjects=new Map,this.subscriptions=[];try{this.presenceService.setPresenceActionsService(this)}catch(a){this.loggingService.catch("Error in PresenceActionsService constructor: ",a)}}onMultipleUsersOnline(e){try{this.loggingService.log("%c[WB] Calling PresenceActionsService FUNCTION: onMultipleUsersOnline","color: green;"),this.triggerAction(nt.MULTIPLE_USERS_ONLINE,e),this.analyticsService.trackEvent(E.Events.Presence.MULTIPLE_USERS_ONLINE,{totalUsers:e?.users?.length,presenceSnippylyUserIds:e?.users?.map(t=>t.userSnippylyId),presenceClientUserIds:e?.users?.map(t=>t.userId)})}catch(t){this.loggingService.catch("Error in PresenceActionsService onMultipleUsersOnline: ",t)}}onUserStateChange(e){try{this.loggingService.log("%c[WB] Calling PresenceActionsService FUNCTION: onUserStateChange","color: green;"),this.triggerAction(nt.USER_STATE_CHANGE,e),this.analyticsService.trackEvent(E.Events.Presence.ON_USER_STATE_CHANGE,{userSnippylyId:e?.user?.userSnippylyId,userId:e?.user?.userId,state:e?.state})}catch(t){this.loggingService.catch("Error in PresenceActionsService onUserStateChange: ",t)}}getData(e){try{return this.loggingService.log("%c[WB] Calling PresenceActionsService FUNCTION: getData","color: green;"),this.presenceService.getOnlineUsersOnCurrentDocument(e).pipe(L(t=>({data:t})))}catch(t){return this.loggingService.catch("Error in PresenceActionsService getData: ",t),F({data:null})}}triggerAction(e,t){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new Xe),this.actionSubjects.get(e)?.next(t)}catch(i){this.loggingService.catch("Error in PresenceActionsService triggerAction: ",i)}}onAction(e){try{return this.actionSubjects.has(e)||this.actionSubjects.set(e,new Xe),this.actionSubjects.get(e)?.asObservable()}catch(t){return this.loggingService.catch("Error in PresenceActionsService onAction: ",t),F(null)}}};r.\u0275fac=function(t){return new(t||r)(P(ge),P(v),P(z))},r.\u0275prov=ae({token:r,factory:r.\u0275fac,providedIn:"root"});let n=r;return n})();var Ge=class extends Vt{constructor(r){super(r),this.getService(v).log("%c[WB] Creating CLASS: PresenceElement","color: blue;"),this.getOnlineUsersOnCurrentDocument=this._getOnlineUsersOnCurrentDocument,this.setInactivityTime=this._setInactivityTime,this.enableFlockMode=this._enableFlockMode,this.disableFlockMode=this._disableFlockMode,this.startFollowingUser=this._startFollowingUser,this.stopFollowingUser=this._stopFollowingUser,this.enableSelf=this._enableSelf,this.disableSelf=this._disableSelf,this.getData=this._getData,this.on=this._on,this.addUser=this._addUser,this.removeUser=this._removeUser}_getOnlineUsersOnCurrentDocument(){this.getService(v).log("%c[WB] Calling FUNCTION: getOnlineUsers","color: green;");try{return this.trackEvent(E.Events.Presence.GET_ONLINE_USERS_ON_CURRENT_DOCUMENT_TRIGGERED),this.getService(z).getOnlineUsersOnCurrentDocument()}catch(r){return this.getService(v).catch("Error in _getOnlineUsersOnCurrentDocument: ",r),F(null)}}_setInactivityTime(r){this.getService(v).log("%c[WB] Calling FUNCTION: _setInactivityTime","color: green;");try{this.trackEvent(E.Events.Presence.SET_INACTIVITY_TIME_TRIGGERED,{payload:{time:r}}),isNaN(r)?this.getService(v).catch("Error in setInactivityTime: ","Provided value is not a number."):this.getService(z).setInactivityTime(r)}catch(o){this.getService(v).catch("Error in setInactivityTime: ",o)}}_disableFlockMode(){try{this.trackEvent(E.Events.Presence.DISABLE_FLOCK_MODE_TRIGGERED),this.getService(K).disableFlockMode()}catch(r){this.getService(v).catch("Error in _disableFlockMode: ",r)}}_enableFlockMode(r){try{this.trackEvent(E.Events.Presence.ENABLE_FLOCK_MODE_TRIGGERED,{payload:{options:r}}),this.getService(K).enableFlockMode(r)}catch(o){this.getService(v).catch("Error in _enableFlockMode: ",o)}}_stopFollowingUser(){try{this.trackEvent(E.Events.Presence.STOP_FOLLOWING_USER_TRIGGERED),this.getService(K).stopFollowingUser()}catch(r){this.getService(v).catch("Error in _stopFollowingUser: ",r)}}_startFollowingUser(r){try{this.trackEvent(E.Events.Presence.START_FOLLOWING_USER_TRIGGERED,{payload:{externalId:r}});let o=this.getService(z).getPresenceUserFromExternalId(r);return o&&o.userSnippylyId&&o.name!==void 0?(this.getService(K).startFollowingUser(o.userSnippylyId,o.name),{success:!0,msg:"Joined flock session."}):{success:!1,msg:"User could not be found."}}catch(o){return this.getService(v).catch("Error in _startFollowingUser: ",o),{success:!1,msg:"Unknown error.",raw:o}}}_enableSelf(){try{this.trackEvent(E.Events.Presence.ENABLE_SELF_TRIGGERED),this.getService(z).enableIncludeSelf()}catch(r){this.getService(v).catch("Error in _enableSelf: ",r)}}_disableSelf(){try{this.trackEvent(E.Events.Presence.DISABLE_SELF_TRIGGERED),this.getService(z).disableIncludeSelf()}catch(r){this.getService(v).catch("Error in _disableSelf: ",r)}}_getData(r){this.getService(v).log("%c[WB] Calling FUNCTION: getData","color: green;");try{return this.trackEvent(E.Events.Presence.GET_PRESENCE_DATA_TRIGGERED,{payload:{query:r}}),r&&typeof r=="object"&&(r=C({},r),r?.documentId&&(r.documentId=xt(r.documentId)),r?.organizationId&&(r.organizationId=Ut(r.organizationId))),this.getService(xe).getData(r)}catch(o){return this.getService(v).catch("Error in _getData: ",o),F({data:null})}}_on(r){this.getService(v).log("%c[WB] Calling FUNCTION: on","color: green;");try{return this.getService(xe).onAction(r)}catch(o){return this.getService(v).catch("Error in _on: ",o),F(null)}}_addUser(r){this.getService(v).log("%c[WB] Calling FUNCTION: addUser","color: green;");try{if(this.trackEvent(E.Events.Presence.ADD_USER_TRIGGERED,{payload:{userId:r?.user?.userId,localOnly:r?.localOnly}}),!r?.user?.userId){this.getService(v).catch("Error in addUser: ","userId is required");return}this.getService(z).addCustomUser(r)}catch(o){this.getService(v).catch("Error in addUser: ",o)}}_removeUser(r){this.getService(v).log("%c[WB] Calling FUNCTION: removeUser","color: green;");try{if(this.trackEvent(E.Events.Presence.REMOVE_USER_TRIGGERED,{payload:{userId:r?.user?.userId,localOnly:r?.localOnly}}),!r?.user?.userId){this.getService(v).catch("Error in removeUser: ","userId is required");return}this.getService(z).removeCustomUser(r)}catch(o){this.getService(v).catch("Error in removeUser: ",o)}}};var cn=(()=>{let r=class r{};r.\u0275fac=function(t){return new(t||r)},r.\u0275mod=mt({type:r}),r.\u0275inj=st({imports:[St,re,Je]});let n=r;return n})();var ln=(()=>{let r=class r{constructor(e,t){this.loggingService=e,this.usersService=t}getUserIdsToResolveFromPresenceUsers(e){try{let t=new Set;for(let i of e)i?.userId&&t.add(i?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in PresenceUtilsService getUserIdsToResolveFromPresenceUsers:",t),[]}}mergePresenceUserWithUser(e){try{if(this.usersService.userDataProviderAvailable()&&e?.userId){let t=this.usersService.getUserById(e?.userId);t&&(e=C(C({},e),t))}return e}catch(t){return this.loggingService.catch("Error in PresenceUtilsService mergePresenceUserWithUser:",t),e}}formatPresenceUserData(e){try{if(this.usersService.userDataProviderAvailable()){let t=["userId","onlineStatus","userSnippylyId","color","textColor","timestamp","type","selections","documentParamsId","documentParams","locationId","location","isReadOnly","isAnonymous","pageInfo"];Object.keys(e).forEach(i=>{t.includes(i)||(e[i]=null)})}return e}catch(t){return this.loggingService.catch("Error in PresenceUtilsService formatPresenceUserData:",t),e}}};r.\u0275fac=function(t){return new(t||r)(P(v),P(Bt))},r.\u0275prov=ae({token:r,factory:r.\u0275fac,providedIn:"root"});let n=r;return n})();var jr={"velt-presence-wireframe":pe,"velt-presence-avatar-list-wireframe":Ee,"velt-presence-avatar-list-item-wireframe":be,"velt-presence-avatar-remaining-count-wireframe":Pe,"velt-presence-tooltip-wireframe":Ie,"velt-presence-tooltip-avatar-wireframe":fe,"velt-presence-tooltip-user-active-wireframe":Se,"velt-presence-tooltip-user-inactive-wireframe":Ce,"velt-presence-tooltip-user-name-wireframe":_e,"velt-presence-tooltip-status-container-wireframe":ye};Object.assign(Jt,jr);function $r(n){n.get(v).log("%c[WB] Loading presence feature chunk","color: blue;");let o=n.get(Rt);o.set(Nt,n.get(z)),o.set(wt,n.get(xe)),o.set(Ft,n.get(ln));let t=lt(cn,n).injector;return mn(t,p.TAGS.VELT_PRESENCE,pe),mn(t,p.TAGS.SNIPPYLY_PRESENCE,pe),new Ge(n)}function mn(n,r,o){if(customElements.get(r))return;let e=It(o,n);customElements.define(r,e)}export{$r as default};
|
|
1
|
+
import{a as K}from"./chunk-77FADRSO.js";import"./chunk-WMDZMDJS.js";import{D as Qt,F as A,G as N}from"./chunk-O3FUWWWQ.js";import{a as Je}from"./chunk-YO4HNOAN.js";import{b as ve,c as Ye,d as re}from"./chunk-GULBDPIM.js";import{a as Zt}from"./chunk-3AL5S762.js";import{a as Tt}from"./chunk-L4QMAEKA.js";import{D as xt,F as Ut,Ga as f,Ha as Ge,Ia as $,Ja as Ve,s as Pt}from"./chunk-I63T4QWP.js";import{a as qt}from"./chunk-2HGCWC7B.js";import{e as Xt,l as Ht,t as Kt}from"./chunk-MRY4A7N6.js";import{$f as Nt,Af as st,Bb as s,Cg as Ft,D as mt,E as Y,Fb as St,G as gt,Gb as Ct,Gd as Ot,Ha as l,Hb as _t,Hc as bt,He as v,Ia as fe,Ic as D,J as Ze,K as Ne,Kb as te,Lb as yt,M as qe,Mb as je,Nc as Be,O as et,Od as kt,Og as Rt,Pb as se,Pd as Dt,Qb as $e,Qh as Mt,Ra as m,Rb as It,Rc as Et,Ri as Wt,S as vt,Se as at,Si as ge,Ta as dt,Ti as p,Uh as Lt,Ui as zt,V as B,Va as ut,Wa as x,Xa as ht,Y as H,Z as tt,Zf as At,_a as U,a as C,ab as g,ac as j,b as F,ba as ae,ca as pt,dc as _,ea as I,ec as E,fb as ft,fc as it,g as oe,ge as ot,hc as k,i as lt,ja as we,ji as P,jj as Jt,k as Qe,ka as Fe,l as he,mc as ce,mj as Gt,nb as c,nc as le,nj as ct,ob as T,pb as O,qb as R,qg as wt,r as w,rc as ne,re as X,ri as jt,rj as Vt,sa as Re,sg as me,si as $t,ti as Bt,tj as Yt,ub as d,v as L,vb as u,wa as Me,wb as Le,wj as We,x as Ae,xb as nt,xj as ze,ya as b,zb as rt}from"./chunk-YFBAHLK6.js";var W=(()=>{let r=class r{constructor(e,t,i,a,h,y,M,He,Ke,Te,Oe,ke,de,ue){this.analyticsService=e,this.docService=t,this.domService=i,this.authService=a,this.afAuth=h,this.iamService=y,this.databaseService=M,this.configService=He,this.avatarService=Ke,this.loggingService=Te,this.flockService=Oe,this.commonDbService=ke,this.realtimeAdapter=de,this.adapterSelectorService=ue,this.db=null,this.presenceUser$=new he(new st),this.documentPaths=null,this.inactivityTime=300*1e3,this.offlineInactivityTime=600*1e3,this.presenceUsers$=new he([]),this.presenceUsersSubscription=null,this.includeSelf$=new he(!0),this.customPresenceUsers$=new he([]),this.userIdleStateDetectionSubscription=null,this.userOfflineStateDetectionSubscription=null,this.presenceRuntimeInitialized=!1;try{this.loggingService.log("%c[WB] Creating CLASS: PresenceService","color: blue;"),this.databaseService.getDb().pipe(Y(S=>!!S),Ne(1)).subscribe(S=>{S&&(this.db=S,this.initializePresenceRuntime())},S=>{this.loggingService.catch("Error in PresenceService constructor: ",S)});let De=ct(()=>{this.adapterSelectorService?.isPortableBackendActive()&&(this.initializePresenceRuntime(),De())});this.adapterSelectorService?.isPortableBackendActive()&&(this.initializePresenceRuntime(),De()),this.authService.addPreSignOutFuction("presence-signout",this.signOutUser.bind(this)),this.presenceUsers$.pipe(et()).subscribe(([S,V])=>{try{V?.length>=0&&this.analyticsService.updateDefaultProperties({presenceUsersCount:V?.length}),sessionStorage.getItem(v.SESSION_STORAGE.VELT_PRESENCE_MULTIPLE_USERS_ONLINE)||V?.length>1&&S.length!==V.length&&(sessionStorage.setItem(v.SESSION_STORAGE.VELT_PRESENCE_MULTIPLE_USERS_ONLINE,"true"),this.presenceActionsService?.onMultipleUsersOnline({users:V}))}catch(Sn){this.loggingService.catch("Error in presenceUsers$ pairwise subscription: ",Sn)}}),this.authService.getUser$().pipe(Y(S=>!!S),Ne(1)).subscribe(S=>{S?(this.detectUserIdleState(),this.detectUserOfflineState()):(this.unsubscribeUserIdleStateDetectionSubscription(),this.unsubscribeUserOfflineStateDetectionSubscription())}),this.presenceUser$.subscribe(S=>{try{S?.onlineStatus&&this.presenceActionsService?.onUserStateChange({user:JSON.parse(JSON.stringify(S)),state:S?.onlineStatus})}catch(V){this.loggingService.catch("Error in presenceUser$ subscription: ",V)}},S=>{this.loggingService.catch("Error in presenceUser$ subscribe: ",S)}),this.customPresenceUsers$.subscribe(()=>{try{let S=this.presenceUsers$.value.filter(V=>!V.localOnly);this.presenceUsers$.next(this.mergeWithCustomUsers(S))}catch(S){this.loggingService.catch("Error in customPresenceUsers$ subscription: ",S)}}),this.domService.onNetworkStatusChange$().subscribe(S=>{try{!S&&this.presenceUser$?.value?.onlineStatus&&this.presenceActionsService?.onUserStateChange({user:F(C({},JSON.parse(JSON.stringify(this.presenceUser$.value))),{onlineStatus:v.PRESENCE_STATUS_OFFLINE}),state:v.PRESENCE_STATUS_OFFLINE})}catch(V){this.loggingService.catch("Error in domService.onNetworkStatusChange$ subscription: ",V)}},S=>{this.loggingService.catch("Error in domService.onNetworkStatusChange$ subscribe: ",S)})}catch(De){this.loggingService.catch("Error in PresenceService constructor: ",De)}}initializePresenceRuntime(){try{if(this.presenceRuntimeInitialized)return;this.presenceRuntimeInitialized=!0,this.getUser(),this.getDocumentPaths(),this.getLocation(),this.updateOnUserDbConnectionStateChange().subscribe(()=>{},e=>{this.loggingService.catch("Error in PresenceService constructor updateOnUserDbConnectionStateChange: ",e)}),this.updateOnDatabaseDisconnect().subscribe(()=>{},e=>{this.loggingService.catch("Error in PresenceService constructor updateOnDatabaseDisconnect: ",e)}),this.updateOnDocumentFocusChange(),this.updateOnAllowedFeatureListChange()}catch(e){this.loggingService.catch("Error in initializePresenceRuntime: ",e)}}setPresenceActionsService(e){try{this.presenceActionsService=e}catch(t){this.loggingService.catch("Error in setPresenceActionsService: ",t)}}detectUserIdleState(){try{this.unsubscribeUserIdleStateDetectionSubscription();let e=!1;this.userIdleStateDetectionSubscription=this.domService.onWindowPointerMove$().pipe(tt(2e3),H(()=>{this.presenceUser$.value&&e&&(this.setCurrentPresenceUserStatus(v.PRESENCE_STATUS_ONLINE),e=!1)}),Ze(this.inactivityTime),H(()=>{this.setCurrentPresenceUserStatus(v.PRESENCE_STATUS_AWAY,{isUserIdle:!0}),e=!0})).subscribe()}catch(e){this.loggingService.catch("Error in detectUserIdleState: ",e)}}detectUserOfflineState(){try{this.unsubscribeUserOfflineStateDetectionSubscription();let e=!1;this.userOfflineStateDetectionSubscription=this.domService.onWindowPointerMove$().pipe(tt(2e3),Ze(this.offlineInactivityTime),H(()=>{this.setCurrentPresenceUserStatus(v.PRESENCE_STATUS_OFFLINE,{isUserIdle:!0}),e=!0})).subscribe()}catch(e){this.loggingService.catch("Error in detectUserOfflineState: ",e)}}unsubscribeUserIdleStateDetectionSubscription(){try{this.userIdleStateDetectionSubscription&&(this.userIdleStateDetectionSubscription.unsubscribe(),this.userIdleStateDetectionSubscription=null)}catch(e){this.loggingService.catch("Error in unsubscribeUserIdleStateDetectionSubscription: ",e)}}unsubscribeUserOfflineStateDetectionSubscription(){try{this.userOfflineStateDetectionSubscription&&(this.userOfflineStateDetectionSubscription.unsubscribe(),this.userOfflineStateDetectionSubscription=null)}catch(e){this.loggingService.catch("Error in unsubscribeUserOfflineStateDetectionSubscription: ",e)}}getUser(){this.loggingService.log("%c[WB] Calling FUNCTION: getUser","color: green;"),this.authService.getUser$().pipe(Y(e=>!!e)).subscribe(e=>{e&&this.setPresenceUser(e)},e=>{this.loggingService.catch("Error in getUser: ",e)})}getDocumentPaths(){this.loggingService.log("%c[WB] Calling FUNCTION: getDocumentPaths","color: green;"),this.docService.getDocumentPaths$().pipe(H(e=>{this.documentPaths=e}),et(),H(([e,t])=>{e&&this.updateUserStatusOnDocumentChange(v.PRESENCE_STATUS_OFFLINE,e),t&&this.updateUserStatusOnDocumentChange(v.PRESENCE_STATUS_ONLINE,t)})).subscribe(()=>{},e=>{this.loggingService.catch("Error in getDocumentPaths: ",e)})}getLocation(){this.docService.getLocation$().pipe(H(e=>{this.updateUserOnLocationChange(e)})).subscribe(()=>{},e=>{this.loggingService.catch("Error in getLocation: ",e)})}getPresenceUser(){return this.loggingService.log("%c[WB] Calling FUNCTION: getPresenceUser","color: green;"),this.presenceUser$.asObservable()}getPresenceUserValue(){return this.presenceUser$.value}getOnlineUsersOnCurrentDocument(e){return this.loggingService.log("%c[WB] Calling FUNCTION: getOnlineUsersOnCurrentDocument","color: green;"),this.authService.getAuthState$().pipe(Y(t=>!!t),B(t=>this.isFeatureAllowed({firebaseUser:t,users:[],filteredUsers:[]})),B(t=>t.featureAllowed?this.iamService.isUserAllowed$().pipe(L(i=>(t.featureAllowed=i,t))):w(t)),B(t=>t.featureAllowed?this.authService.isPlanExpired$().pipe(L(i=>(t.featureAllowed=!i,t))):w(t)),B(t=>t.featureAllowed?w(t).pipe(B(i=>this.docService.getDocumentPaths$().pipe(L(a=>(this.documentPaths=a,i.documentPaths=a,i)))),B(i=>this.getDataFromDocumentId(e).pipe(L(a=>(i.users=a||[],C({},i))))),L(i=>(e?e?.statuses?.length?i.filteredUsers=i?.users?.filter(a=>e?.statuses?.includes(a?.onlineStatus)):i.filteredUsers=i?.users?.slice():i.filteredUsers=this.filterOnlineUsers(i.users,i.firebaseUser),i)),B(i=>this.getIncludeSelf$().pipe(L(a=>(a||(i.filteredUsers=i?.filteredUsers?.filter(h=>h?.userSnippylyId!==i.user?.userSnippylyId)),i)))),B(i=>{let a=i?.filteredUsers||[];return this.customPresenceUsers$.pipe(L(()=>this.mergeWithCustomUsers(a)))})):w([])),qe(Lt))}isFeatureAllowed(e){return this.configService.getConfig$().pipe(Y(t=>!!t),L(t=>F(C({},e),{config:t})),B(t=>this.authService.getUser$().pipe(L(i=>F(C({},t),{user:i})))),B(t=>wt(t.config,t.user,X.PRESENCE)?w(F(C({},t),{featureAllowed:!0})):(this.loggingService.warn("Presence feature is not allowed."),w(F(C({},t),{featureAllowed:!1})))),qe((t,i)=>t?.featureAllowed===i?.featureAllowed))}getDataFromDocumentId(e){return Ae(()=>{if(this.adapterSelectorService?.isPortableBackendActive())return w(null);let t=new lt(i=>ct(()=>{this.adapterSelectorService?.isPortableBackendActive()&&i.next(null)}));return mt(this.databaseService.getDb().pipe(Y(i=>!!i)),t)}).pipe(B(t=>{if(t&&(this.db=t,this.loggingService.log(this.db)),this.configService?.getApiKey()&&this.documentPaths?.presence){let i=new Date(Date.now()-864e5).getTime();return this.commonDbService.dbListener({feature:"allPresence",properties:{documentId:e?.documentId??this.documentPaths?.documentId,organizationId:e?.organizationId??this.documentPaths?.organizationId,skipFirestore:!0,useQuery:!0,rtdbQuery:[kt("timestamp"),Dt(i)]}}).pipe(gt(a=>(this.loggingService.catch("Error in PresenceService getDataFromDocumentId: ",a),w(null))),L(a=>a?.data),L(a=>{let h=[];if(a){let y=Object.values(a).filter(M=>typeof M=="object");for(let M of y)h.push(M)}return h}))}else return w([])}))}filterOnlineUsers(e,t){this.loggingService.log("%c[WB] Calling FUNCTION: filterOnlineUsers","color: green;");try{let a=e.slice().filter(h=>{let y=me(h.timestamp);return h.userSnippylyId&&(h.onlineStatus===v.PRESENCE_STATUS_ONLINE||h.onlineStatus===v.PRESENCE_STATUS_AWAY)&&y<this.offlineInactivityTime});return this.presenceUsers$.next(this.mergeWithCustomUsers(a)),a}catch(i){return this.loggingService.catch("Error in filterOnlineUsers:",i),[]}}enableIncludeSelf(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: enableIncludeSelf","color: green;"),this.includeSelf$.value===!0)return;this.includeSelf$.next(!0)}catch(e){this.loggingService.catch("Error in PresenceService enableIncludeSelf: ",e)}}disableIncludeSelf(){try{if(this.loggingService.log("%c[WB] Calling FUNCTION: disableIncludeSelf","color: green;"),this.includeSelf$.value===!1)return;this.includeSelf$.next(!1)}catch(e){this.loggingService.catch("Error in PresenceService disableIncludeSelf: ",e)}}getIncludeSelf$(){return this.includeSelf$.asObservable()}getIncludeSelf(){return this.includeSelf$.value}getPresenceUserFromExternalId(e){try{if(this.presenceUsers$.value&&this.presenceUsers$.value.length>0){let t=this.presenceUsers$.value.find(i=>i.userId===e);if(t)return t}return null}catch(t){return this.loggingService.catch("Error in getNameFromSnippylyId:",t),null}}getAnonymousAvatarImage(){return this.loggingService.log("%c[WB] Calling FUNCTION: getAnonymousAvatarImage","color: green;"),this.avatarService.generateUserImage()}updateCurrentPresenceUser(e){return oe(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateCurrentPresenceUser","color: green;");try{if(this.documentPaths?.presence&&e&&e.userId&&this.authService.isFeatureAllowed(X.PRESENCE)){if(!e.isAnonymous){e.pageInfo=new at,e?.onlineStatus===v.PRESENCE_STATUS_ONLINE&&(e.isTabAway=!1,e.isUserIdle=!1);let t=JSON.parse(JSON.stringify(e));this.authService.getUser()&&this.commonDbService.updateData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(F(C({},t),{timestamp:this.timestamp})))})}this.presenceUser$.next(e)}}catch(t){this.loggingService.catch("Error in updateCurrentPresenceUser:",t)}})}setCurrentPresenceUserStatus(e,t){return oe(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: setCurrentPresenceUserStatus","color: green;");try{this.loggingService.log(e);let i=this.presenceUser$.value;if(i.onlineStatus!==e){this.presenceUsersSubscription&&this.presenceUsersSubscription?.unsubscribe();let a=i.onlineStatus,h=e;this.presenceUsersSubscription=this.getPresenceUsers$().pipe(Y(y=>!!y?.length),Ne(1)).subscribe(y=>{y?.length>1&&this.analyticsService.trackEvent(P.Events.Presence.PRESENCE_USER_STATUS_CHANGED,{oldStatus:a,newStatus:h,totalUsers:y?.length,presenceSnippylyUserIds:y?.map(M=>M.userSnippylyId),presenceClientUserIds:y?.map(M=>M.userId)})})}i.onlineStatus=e,t&&(i.isTabAway=t?.isTabAway,i.isUserIdle=t?.isUserIdle),e===v.PRESENCE_STATUS_ONLINE&&(i.isTabAway=!1,i.isUserIdle=!1),e===v.PRESENCE_STATUS_OFFLINE&&this.flockService.isInSession()&&this.flockService.removeCurrentUserFromSession(),this.updateCurrentPresenceUser(i)}catch(i){this.loggingService.catch("Error in setCurrentPresenceUserStatus:",i)}})}updateUserStatusOnDocumentChange(e,t){return oe(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateUserStatusOnDocumentChange","color: green;");try{let i=this.presenceUser$.value;if(i.onlineStatus=e,t?.presence&&i&&i.userId&&!i.isAnonymous&&this.authService.isFeatureAllowed(X.PRESENCE)){let a=JSON.parse(JSON.stringify(i));this.commonDbService.updateData({feature:"presence",properties:{documentId:t?.documentId,organizationId:t?.organizationId,userId:i.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(a))})}}catch(i){this.loggingService.catch("Error in updateUserStatusOnDocumentChange:",i)}})}updateUserOnLocationChange(e){return oe(this,null,function*(){this.loggingService.log("%c[WB] Calling FUNCTION: updateUserOnLocationChange","color: green;");try{let t=this.presenceUser$.value;if(t.location=e?e.location:null,t.locationId=e?e?.locationId:null,this.documentPaths?.presence&&t&&t.userId&&!t.isAnonymous&&this.authService.isFeatureAllowed(X.PRESENCE)){let i=JSON.parse(JSON.stringify(t));this.commonDbService.updateData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:t.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(i))})}}catch(t){this.loggingService.catch("Error in updateUserOnLocationChange:",t)}})}updateOnUserDbConnectionStateChange(){this.loggingService.log("%c[WB] Calling FUNCTION: updateOnUserDbConnectionStateChange","color: green;");let e=Ae(()=>this.adapterSelectorService?.isPortableBackendActive()?w(v.PRESENCE_STATUS_ONLINE):this.realtimeAdapter.rtdbObjectVal$("presence",this.realtimeAdapter.rtdbRef(this.db,".info/connected")).pipe(L(t=>t?v.PRESENCE_STATUS_ONLINE:v.PRESENCE_STATUS_OFFLINE)));return Ae(()=>{let t=this.adapterSelectorService?.isPortableBackendActive()?0:1;return this.authService.getAuthState$().pipe(vt(t))}).pipe(B(t=>t?e:w(v.PRESENCE_STATUS_OFFLINE)),H(t=>this.setCurrentPresenceUserStatus(t)))}updateOnDocumentFocusChange(){this.loggingService.log("%c[WB] Calling FUNCTION: updateOnDocumentFocusChange","color: green;");try{document&&document.addEventListener("visibilitychange",e=>{this.authService.getUser()&&(document.visibilityState==="hidden"?(this.setCurrentPresenceUserStatus(v.PRESENCE_STATUS_AWAY,{isTabAway:!0}),this.flockService.getFlockMode()&&this.flockService.setTabFocused(!1)):(this.setCurrentPresenceUserStatus(v.PRESENCE_STATUS_ONLINE),this.flockService.getFlockMode()&&this.flockService.setTabFocused(!0)))}),window&&(window.addEventListener("focus",()=>{this.authService.getUser()&&(this.setCurrentPresenceUserStatus(v.PRESENCE_STATUS_ONLINE),this.flockService.getFlockMode()&&this.flockService.setWindowFocused(!0))}),window.addEventListener("blur",()=>{this.authService.getUser()&&(document.visibilityState!=="hidden"&&this.setCurrentPresenceUserStatus(v.PRESENCE_STATUS_AWAY,{isTabAway:!0}),this.flockService.getFlockMode()&&this.flockService.setWindowFocused(!1))}))}catch(e){this.loggingService.catch("Error in updateOnDocumentFocusChange:",e)}}updateOnAllowedFeatureListChange(){try{this.configService.getConfig$().subscribe(e=>{if(e&&e.featureAllowList?.length){let t=this.presenceUser$.value,i=!1;if(e.featureAllowList.includes(X.PRESENCE)?t?.onlineStatus!==v.PRESENCE_STATUS_ONLINE&&(t.onlineStatus=v.PRESENCE_STATUS_ONLINE,i=!0):t?.onlineStatus!==v.PRESENCE_STATUS_OFFLINE&&(t.onlineStatus=v.PRESENCE_STATUS_OFFLINE,i=!0),i&&this.authService.getUser()&&this.documentPaths?.presence&&t&&t.userId&&!t.isAnonymous){let a=JSON.parse(JSON.stringify(t));this.commonDbService.updateData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:t.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(a))})}}})}catch(e){this.loggingService.catch("Error in updateOnAllowedFeatureListChange:",e)}}updateOnDatabaseDisconnect(){return this.loggingService.log("%c[WB] Calling FUNCTION: updateOnDatabaseDisconnect","color: green;"),this.authService.getAuthState$().pipe(Y(e=>!!e),B(e=>this.docService.getDocumentPaths$().pipe(L(t=>e))),H(e=>oe(this,null,function*(){try{if(this.documentPaths?.presence&&e){let t;if(this.adapterSelectorService?.isPortableBackendActive())t=!!this.authService.getUser()?.isAnonymous;else{let i=yield this.authService.getIdTokenResultForUser(e,!0).catch(h=>null);if(!i)return;let{user:a}=i.claims;t=!!a?.isAnonymous}if(!t&&this.documentPaths?.presence){this.flockService.isInSession()&&this.flockService.removeCurrentUserFromSession();let i=`${this.documentPaths.presence}/${e.uid}`;this.commonDbService.setupOnDisconnect(i,{onlineStatus:v.PRESENCE_STATUS_OFFLINE,timestamp:this.timestamp},"presence").catch(a=>{this.loggingService.catch("Error in updateOnDatabaseDisconnect:",a)})}}}catch(t){this.loggingService.catch("Error in updateOnDatabaseDisconnect:",t)}})))}setPresenceUser(e){this.loggingService.log("%c[WB] Calling FUNCTION: setPresenceUser","color: green;");try{let t=this.presenceUser$.value;t.userId=e?.userId,t.name=e?.name,t.email=e?.email,t.photoUrl=e?.photoUrl,t.userSnippylyId=e?.userSnippylyId,t.color=e?.color,t.textColor=e?.textColor,t.initial=e?.initial,t.timestamp=this.timestamp,t.type=e?.type,t.isReadOnly=e?.isReadOnly,t.isAnonymous=e?.isAnonymous;let i=e?.name?.split(" ");if(i&&i.length>0){let a=i[0],h=i.length>1?i[i.length-1]:null,y=h?h[0]:null;a&&(t.name=`${a} ${y?y+".":""}`)}this.updateCurrentPresenceUser(t)}catch(t){this.loggingService.catch("Error in setPresenceUser:",t)}}signOutUser(e){return new Promise((t,i)=>{try{this.documentPaths?.presence&&e?this.commonDbService.getData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.uid,skipFirestore:!0}}).then(a=>{a&&(this.flockService.isInSession()&&this.flockService.removeCurrentUserFromSession(),this.commonDbService.updateData({feature:"presence",errorCallback:h=>{i(h)},callback:()=>{t(null)},properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.uid,skipFirestore:!0},data:JSON.parse(JSON.stringify(F(C({},a?.data??{}),{timestamp:this.timestamp,onlineStatus:v.PRESENCE_STATUS_OFFLINE})))})),t(null)}).catch(a=>{this.loggingService.catch("Error in signOutUser subscription: ",a),i(a)}):t(null)}catch(a){this.loggingService.catch("Error in signOutUser:",a),i(a)}})}setInactivityTime(e){try{this.inactivityTime=e,this.analyticsService.trackEvent(P.Events.Presence.PRESENCE_SET_CUSTOM_INACTIVITY_TIMER,{inactivityTime:this.inactivityTime}),this.detectUserIdleState()}catch(t){this.loggingService.catch("Error in setInactivityTime: ",t)}}getInactivityTime(){return this.inactivityTime}setOfflineInactivityTime(e){try{e>=this.inactivityTime?(this.offlineInactivityTime=e,this.analyticsService.trackEvent(P.Events.Presence.PRESENCE_SET_CUSTOM_OFFLINE_INACTIVITY_TIMER,{offlineInactivityTime:this.offlineInactivityTime}),this.detectUserOfflineState()):this.loggingService.catch("Error in setOfflineInactivityTime: ","offline-inactivity-time value is less than inactivity-time.")}catch(t){this.loggingService.catch("Error in setOfflineInactivityTime: ",t)}}getOfflineInactivityTime(){return this.offlineInactivityTime}getPresenceUsers$(){return this.presenceUsers$.asObservable()}getPresenceUsers(){return this.presenceUsers$.value}get timestamp(){return this.commonDbService.getServerTimestamp()}addCustomUser(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: addCustomUser","color: green;");let t=e?.user,i=e?.localOnly??!1;if(!t?.userId){this.loggingService.catch("Error in addCustomUser: ","userId is required");return}let a=this.buildCustomPresenceUser(t,i);if(!a)return;if(i){let h=this.customPresenceUsers$.value,y=h.findIndex(M=>M.userId===t.userId);if(y>=0){let M=[...h];M[y]=a,this.customPresenceUsers$.next(M)}else this.customPresenceUsers$.next([...h,a])}else this.persistCustomUserToDb(a)}catch(t){this.loggingService.catch("Error in addCustomUser: ",t)}}removeCustomUser(e){try{this.loggingService.log("%c[WB] Calling FUNCTION: removeCustomUser","color: green;");let t=e?.user?.userId,i=e?.localOnly??!1;if(!t){this.loggingService.catch("Error in removeCustomUser: ","userId is required");return}if(i){let a=this.customPresenceUsers$.value,h=a.filter(y=>y.userId!==t);h.length!==a.length&&this.customPresenceUsers$.next(h)}else{let a=this.buildCustomPresenceUser(e.user,!1);a&&this.removeCustomUserFromDb(a)}}catch(t){this.loggingService.catch("Error in removeCustomUser: ",t)}}mergeWithCustomUsers(e){try{let t=this.customPresenceUsers$.value;if(t.length===0)return e;let i=new Set(e.map(h=>h.userId)),a=t.filter(h=>!i.has(h.userId));return[...e,...a]}catch(t){return this.loggingService.catch("Error in mergeWithCustomUsers: ",t),e}}buildCustomPresenceUser(e,t=!1){try{let i=this.configService.getApiKey(),a=new st;return a.userId=e.userId,a.name=e.name||e.userId,a.email=e.email||"",a.photoUrl=e.photoUrl||"",a.onlineStatus=e.onlineStatus||v.PRESENCE_STATUS_ONLINE,a.color=e.color||this.avatarService.generateUserColor(),a.textColor=e.textColor||"",a.type="custom",a.initial=e.initial||(a.name?a.name.charAt(0).toUpperCase():"U"),a.timestamp=Date.now(),a.isReadOnly=e.isReadOnly??!1,a.isAnonymous=e.isAnonymous??!1,a.location=e.location||null,a.locationId=e.locationId??null,a.pageInfo=e.pageInfo||new at,a.isTabAway=!1,a.isUserIdle=!1,a.userSnippylyId=e.userSnippylyId||(i?Rt(i,e.userId):`custom_${e.userId}`),a.localOnly=t,a}catch(i){return this.loggingService.catch("Error in buildCustomPresenceUser: ",i),null}}persistCustomUserToDb(e){try{if(this.documentPaths?.presence&&e?.userId&&this.authService.isFeatureAllowed(X.PRESENCE)){let t=JSON.parse(JSON.stringify(e));delete t.localOnly,this.commonDbService.updateData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.userSnippylyId,skipFirestore:!0},data:JSON.parse(JSON.stringify(F(C({},t),{timestamp:this.timestamp})))})}}catch(t){this.loggingService.catch("Error in persistCustomUserToDb: ",t)}}removeCustomUserFromDb(e){try{this.documentPaths?.presence&&e?.userId&&this.authService.isFeatureAllowed(X.PRESENCE)&&this.commonDbService.deleteData({feature:"presence",properties:{documentId:this.documentPaths?.documentId,organizationId:this.documentPaths?.organizationId,userId:e.userSnippylyId,skipFirestore:!0}})}catch(t){this.loggingService.catch("Error in removeCustomUserFromDb: ",t)}}};r.\u0275fac=function(t){return new(t||r)(I(ge),I(Xt),I(We),I(ze),I(Ot),I(Zt),I(Jt),I(zt),I(Yt),I(p),I(K),I(Kt),I(Gt),I(Vt))},r.\u0275prov=ae({token:r,factory:r.\u0275fac,providedIn:"root"});let n=r;return n})();var ie=class{constructor(){this.filteredPresenceUsers=[],this.shadowDom=!0,this.maxUsers=5,this.showTooltip=()=>{},this.closeTooltip=()=>{},this.onPresenceUserClick=()=>{}}};var G=class{constructor(){this.shadowDom=!0,this.calculateUserAwayTime=()=>{}}};var rn=n=>({componentConfigSignal:n}),In=(n,r)=>({condition:n,data:r}),bn=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-tooltip-avatar-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function En(n,r){if(n&1&&(d(0),R(1,"snippyly-user-avatar",3),u()),n&2){let o=s(2).ngIf,e=s();l(),je("away",o.presenceUser.onlineStatus===e.constants.PRESENCE_STATUS_AWAY)("velt-presence-avatar--away",o.presenceUser.onlineStatus===e.constants.PRESENCE_STATUS_AWAY),c("user",o.presenceUser)}}function Pn(n,r){if(n&1&&(d(0),g(1,En,2,5,"ng-container",2),u()),n&2){let o=s().ngIf,e=s();l(),c("veltDynamicTemplate",k(3,bn,e.template,_(1,rn,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function xn(n,r){if(n&1&&(d(0),g(1,Pn,2,9,"ng-container",1),u()),n&2){let o=s();l(),c("veltIf",E(3,In,o.conditionSignal(),_(1,rn,o.componentConfigSignal)))}}var Se=(()=>{let r=class r extends ${constructor(e,t,i){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.componentId="velt-presence-tooltip-avatar",this.constants=v;try{super.initializeComponentConfigSignal(new G)}catch(a){this.loggingService.catch("Error in PresenceTooltipAvatarComponent constructor: ",a)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in PresenceTooltipAvatarComponent ngOnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceTooltipAvatarComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceTooltipAvatarComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(b),m(f),m(p))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-tooltip-avatar-internal"]],standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"],[1,"velt-presence-avatar","s-presence-avatar",3,"user"]],template:function(t,i){t&1&&g(0,xn,2,6,"ng-container",0),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,N,A,re],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]{display:flex}[_nghost-%COMP%]:empty{display:none}.velt-presence-avatar[_ngcontent-%COMP%]{position:relative;border-radius:var(--velt-border-radius-full);z-index:2;width:calc((1.5 + 0px) * var(--velt-base-rem-unit));height:calc((1.5 + 0px) * var(--velt-base-rem-unit));display:flex;align-items:center;justify-content:center}.velt-presence-avatar--away[_ngcontent-%COMP%]{filter:grayscale(.7)}snippyly-user-avatar[_ngcontent-%COMP%]{--legacy-velt-user-avatar-size: 1.5rem}"],changeDetection:0});let n=r;return n})();var an=n=>({componentConfigSignal:n}),Tn=(n,r)=>({condition:n,data:r}),On=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-tooltip-user-active-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function kn(n,r){n&1&&(d(0),T(1,"p"),se(2),ce(3,"translate"),O(),u()),n&2&&(l(2),$e(le(3,1,"User online")))}function Dn(n,r){if(n&1&&(d(0),g(1,kn,4,3,"ng-container",2),u()),n&2){let o=s(2).ngIf,e=s();l(),c("veltDynamicTemplate",k(3,On,e.template,_(1,an,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function An(n,r){if(n&1&&(d(0),g(1,Dn,2,9,"ng-container",0),u()),n&2){let o=s().ngIf,e=s();l(),c("ngIf",(o.presenceUser==null?null:o.presenceUser.onlineStatus)===e.constants.PRESENCE_STATUS_ONLINE)}}function Nn(n,r){if(n&1&&(d(0),g(1,An,2,1,"ng-container",1),u()),n&2){let o=s();l(),c("veltIf",E(3,Tn,o.conditionSignal(),_(1,an,o.componentConfigSignal)))}}var Ce=(()=>{let r=class r extends ${constructor(e,t,i){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.componentId="velt-presence-tooltip-user-active",this.constants=v;try{super.initializeComponentConfigSignal(new G)}catch(a){this.loggingService.catch("Error in PresenceTooltipUserActiveComponent constructor: ",a)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in PresenceTooltipUserActiveComponent ngOnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceTooltipUserActiveComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceTooltipUserActiveComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(b),m(f),m(p))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-tooltip-user-active-internal"]],standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"]],template:function(t,i){t&1&&g(0,Nn,2,6,"ng-container",0),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,N,A,ve],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]:empty{display:none}p[_ngcontent-%COMP%]{margin:0;color:var(--velt-green);font-weight:400;font-size:var(--velt-font-size-xs);line-height:1}"],changeDetection:0});let n=r;return n})();var sn=n=>({componentConfigSignal:n}),Fn=(n,r)=>({condition:n,data:r}),Rn=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-tooltip-user-inactive-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function Mn(n,r){if(n&1&&(d(0),T(1,"p",3),se(2),ce(3,"translate"),O(),u()),n&2){let o=s(3).ngIf;l(2),It(" ",o.calculateUserAwayTime(o.presenceUser).toString()+" "+le(3,1,"mins ago.")," ")}}function Ln(n,r){if(n&1&&(d(0),g(1,Mn,4,3,"ng-container",2),u()),n&2){let o=s(2).ngIf,e=s();l(),c("veltDynamicTemplate",k(3,Rn,e.template,_(1,sn,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function jn(n,r){if(n&1&&(d(0),g(1,Ln,2,9,"ng-container",0),u()),n&2){let o=s().ngIf,e=s();l(),c("ngIf",(o.presenceUser==null?null:o.presenceUser.onlineStatus)===e.constants.PRESENCE_STATUS_AWAY)}}function $n(n,r){if(n&1&&(d(0),g(1,jn,2,1,"ng-container",1),u()),n&2){let o=s();l(),c("veltIf",E(3,Fn,o.conditionSignal(),_(1,sn,o.componentConfigSignal)))}}var _e=(()=>{let r=class r extends ${constructor(e,t,i){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.componentId="velt-presence-tooltip-user-inactive",this.constants=v;try{super.initializeComponentConfigSignal(new G)}catch(a){this.loggingService.catch("Error in PresenceTooltipUserInactiveComponent constructor: ",a)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in PresenceTooltipUserInactiveComponent ngOnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceTooltipUserInactiveComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceTooltipUserInactiveComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(b),m(f),m(p))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-tooltip-user-inactive-internal"]],standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"],[1,"velt-presence-tooltip-user-inactive-text","inactive-text"]],template:function(t,i){t&1&&g(0,$n,2,6,"ng-container",0),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,N,A,ve],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]:empty{display:none}p[_ngcontent-%COMP%]{margin:0;color:var(--velt-green);font-weight:400;font-size:var(--velt-font-size-xs);line-height:1}.velt-presence-tooltip-user-inactive-text[_ngcontent-%COMP%]{color:var(--velt-text-4)}"],changeDetection:0});let n=r;return n})();var cn=n=>({componentConfigSignal:n}),Wn=(n,r)=>({condition:n,data:r}),zn=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-tooltip-user-name-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function Jn(n,r){if(n&1&&(d(0),T(1,"h1"),se(2),ce(3,"translate"),O(),u()),n&2){let o=s(3).ngIf;l(2),$e(o.presenceUser!=null&&o.presenceUser.name?o.presenceUser==null?null:o.presenceUser.name:le(3,1,o.presenceUser==null?null:o.presenceUser.email))}}function Gn(n,r){n&1&&R(0,"velt-skeleton-loader-internal",5)}function Vn(n,r){if(n&1&&(d(0),g(1,Jn,4,3,"ng-container",4)(2,Gn,1,0,"ng-template",null,0,ne),u()),n&2){let o=te(3),e=s(2).ngIf;l(),c("ngIf",(e.presenceUser==null?null:e.presenceUser.name)||(e.presenceUser==null?null:e.presenceUser.email))("ngIfElse",o)}}function Yn(n,r){if(n&1&&(d(0),g(1,Vn,4,2,"ng-container",3),u()),n&2){let o=s().ngIf,e=s();l(),c("veltDynamicTemplate",k(3,zn,e.template,_(1,cn,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function Xn(n,r){if(n&1&&(d(0),g(1,Yn,2,9,"ng-container",2),u()),n&2){let o=s();l(),c("veltIf",E(3,Wn,o.conditionSignal(),_(1,cn,o.componentConfigSignal)))}}var ye=(()=>{let r=class r extends ${constructor(e,t,i){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.componentId="velt-presence-tooltip-user-name";try{super.initializeComponentConfigSignal(new G)}catch(a){this.loggingService.catch("Error in PresenceTooltipUserNameComponent constructor: ",a)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in PresenceTooltipUserNameComponent ngOnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceTooltipUserNameComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceTooltipUserNameComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(b),m(f),m(p))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-tooltip-user-name-internal"]],standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[["loadingTemplateRef",""],[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"],[4,"ngIf","ngIfElse"],["height","16px","width","80px","borderRadius","20px"]],template:function(t,i){t&1&&g(0,Xn,2,6,"ng-container",1),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,N,A,Ye,ve],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]:empty{display:none}h1[_ngcontent-%COMP%]{margin:0;color:var(--velt-text-0);font-size:var(--velt-font-size-sm);line-height:calc((1rem + 0px) * var(--velt-base-rem-unit));font-weight:400}"],changeDetection:0});let n=r;return n})();var ln=n=>({componentConfigSignal:n}),Kn=(n,r)=>({condition:n,data:r}),Qn=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-tooltip-status-container-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function Zn(n,r){if(n&1&&(d(0),T(1,"div",3),R(2,"velt-presence-tooltip-user-name-internal",4)(3,"velt-presence-tooltip-user-active-internal",4)(4,"velt-presence-tooltip-user-inactive-internal",4),O(),u()),n&2){let o=s(3);l(2),c("componentConfigSignal",o.componentConfigSignal),l(),c("componentConfigSignal",o.componentConfigSignal),l(),c("componentConfigSignal",o.componentConfigSignal)}}function qn(n,r){if(n&1&&(d(0),g(1,Zn,5,3,"ng-container",2),u()),n&2){let o=s().ngIf,e=s();l(),c("veltDynamicTemplate",k(3,Qn,e.template,_(1,ln,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function er(n,r){if(n&1&&(d(0),g(1,qn,2,9,"ng-container",1),u()),n&2){let o=s();l(),c("veltIf",E(3,Kn,o.conditionSignal(),_(1,ln,o.componentConfigSignal)))}}var Ie=(()=>{let r=class r extends ${constructor(e,t,i){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.componentId="velt-presence-tooltip-status-container",this.constants=v;try{super.initializeComponentConfigSignal(new G)}catch(a){this.loggingService.catch("Error in PresenceTooltipStatusContainerComponent constructor: ",a)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in PresenceTooltipStatusContainerComponent ngOnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceTooltipStatusContainerComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceTooltipStatusContainerComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(b),m(f),m(p))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-tooltip-status-container-internal"]],standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"],[1,"velt-presence-tooltip-status-container","user-status-container"],[3,"componentConfigSignal"]],template:function(t,i){t&1&&g(0,er,2,6,"ng-container",0),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,N,A,Ce,_e,ye],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]:empty{display:none}.velt-presence-tooltip-status-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;z-index:2;gap:var(--velt-spacing-xs)}"],changeDetection:0});let n=r;return n})();var mn=(n,r)=>({componentConfigSignal:n,presenceUser:r}),ir=(n,r)=>({condition:n,data:r}),or=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-tooltip-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function ar(n,r){n&1&&Le(0)}function sr(n,r){if(n&1&&(T(0,"velt-shadow-dom-internal"),g(1,ar,1,0,"ng-container",4),O()),n&2){s();let o=te(3);l(),c("ngTemplateOutlet",o)}}function cr(n,r){if(n&1&&(d(0),T(1,"div",8),R(2,"velt-presence-tooltip-avatar-internal",9)(3,"velt-presence-tooltip-status-container-internal",9),O(),u()),n&2){let o=s(5);l(2),c("componentConfigSignal",o.componentConfigSignal),l(),c("componentConfigSignal",o.componentConfigSignal)}}function lr(n,r){if(n&1&&(T(0,"div",6),g(1,cr,4,2,"ng-container",7),O()),n&2){let o=s(3).ngIf,e=s();l(),c("veltDynamicTemplate",k(4,or,e.template,E(1,mn,e.componentConfigSignal,e.presenceUser),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function mr(n,r){if(n&1&&g(0,lr,2,10,"div",5),n&2){let o=s(2).ngIf;c("ngIf",o==null?null:o.presenceUser)}}function gr(n,r){if(n&1&&(d(0),g(1,sr,2,1,"velt-shadow-dom-internal",3)(2,mr,1,1,"ng-template",null,0,ne),u()),n&2){let o=te(3),e=s().ngIf,t=s();l(),c("ngIf",e.shadowDom&&!t.template||t.template&&t.isExplicitShadowDom)("ngIfElse",o)}}function vr(n,r){if(n&1&&(d(0),g(1,gr,4,2,"ng-container",2),u()),n&2){let o=s();l(),c("veltIf",E(4,ir,o.conditionSignal(),E(1,mn,o.componentConfigSignal,o.presenceUser)))}}var be=(()=>{let r=class r extends Ve{set shadowDom(e){this._shadowDom=e}get shadowDom(){return this._shadowDom}constructor(e,t,i,a,h){super(e,t,void 0,void 0,void 0,i,a),this.elementRef=e,this.themeService=t,this.dynamicDataService=i,this.loggingService=a,this.wireframeService=h,this._shadowDom=!0,this.isExplicitShadowDom=!1,this.constants=v,this.subscriptions=[],this.componentId="velt-presence-tooltip",this.componentConfigSignal=Re({presenceUser:null,shadowDom:!0,calculateUserAwayTime:this.calculateUserAwayTime.bind(this)}),this.loggingService.log("%c[WB] Creating CLASS: PresenceTooltipComponent","color: blue;")}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;");try{let e=this.elementRef.nativeElement,t=e.getAttribute("shadow-dom")??e.getAttribute("shadowdom");this.isExplicitShadowDom=t!==null&&t!=="false",this.setupA11yAttributes(),this.dynamicDataService.applyConditionalClasses(this.elementRef.nativeElement,{componentConfigSignal:this.componentConfigSignal,presenceUser:this.presenceUser}),this.subscriptions.push(this.wireframeService.getWireframe$("velt-presence-tooltip-wireframe").subscribe(a=>{if(a){let h=document.createElement(a.tagName);h.innerHTML=a.innerHTML,this.template=h}}))}catch(e){this.loggingService.catch("Error in PresenceComponent oninit: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceComponent setupA11yAttributes:",e)}}ngOnChanges(e){try{super.ngOnChanges(e),e&&Object.keys(e).forEach(t=>{this.componentConfigSignal.update(i=>(i=F(C({},i),{[t]:e[t].currentValue}),i))})}catch(t){this.loggingService.catch("Error in PresenceTooltipComponent ngOnChanges: ",t)}}ngOnDestroy(){try{super.ngOnDestroy(),this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.loggingService.catch("Error in PresenceTooltipComponent unsubscribe: ",e)}}calculateUserAwayTime(e){try{if(e.onlineStatus===v.PRESENCE_STATUS_ONLINE)return 0;let t=me(e.timestamp);return Math.floor(t/1e3/60)}catch(t){this.loggingService.catch("Error in PresenceTooltipComponent calculateUserAwayTime: ",t)}return 0}};r.\u0275fac=function(t){return new(t||r)(m(b),m(Ge),m(f),m(p),m(Je))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-tooltip"]],inputs:{presenceUser:"presenceUser",shadowDom:"shadowDom",variant:"variant"},standalone:!1,features:[U,Me],decls:1,vars:1,consts:[["presenceTooltipRef",""],[4,"ngIf"],[4,"veltIf"],[4,"ngIf","ngIfElse"],[4,"ngTemplateOutlet"],["class","velt-presence-tooltip-container",4,"ngIf"],[1,"velt-presence-tooltip-container"],[4,"veltDynamicTemplate"],[1,"velt-presence-tooltip","s-tooltiptext","s-presence-tooltip"],[3,"componentConfigSignal"]],template:function(t,i){t&1&&g(0,vr,2,7,"ng-container",1),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,Be,N,A,Se,Ie],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]{--velt-green: var(--velt-light-mode-green);--velt-magenta: var(--velt-light-mode-magenta);--velt-amber: var(--velt-light-mode-amber);--velt-purple: var(--velt-light-mode-purple);--velt-cyan: var(--velt-light-mode-cyan);--velt-orange: var(--velt-light-mode-orange);--velt-black: var(--velt-light-mode-black);--velt-white: var(--velt-light-mode-white);--velt-gray: var(--velt-light-mode-gray);--velt-error: var(--velt-light-mode-error);--velt-error-hover: var(--velt-light-mode-error-hover);--velt-error-foreground: var(--velt-light-mode-error-foreground);--velt-error-light: var(--velt-light-mode-error-light);--velt-error-transparent: var(--velt-light-mode-error-transparent);--velt-warning: var(--velt-light-mode-warning);--velt-warning-hover: var(--velt-light-mode-warning-hover);--velt-warning-foreground: var(--velt-light-mode-warning-foreground);--velt-warning-light: var(--velt-light-mode-warning-light);--velt-warning-transparent: var(--velt-light-mode-warning-transparent);--velt-agent-accent: #4495ff;--velt-agent-accent-transparent: rgba(68, 149, 255, .2);--velt-success: var(--velt-light-mode-success);--velt-success-hover: var(--velt-light-mode-success-hover);--velt-success-foreground: var(--velt-light-mode-success-foreground);--velt-success-light: var(--velt-light-mode-success-light);--velt-success-transparent: var(--velt-light-mode-success-transparent);--velt-accent: var(--velt-light-mode-accent);--velt-accent-text: var(--velt-light-mode-accent-text);--velt-accent-hover: var(--velt-light-mode-accent-hover);--velt-accent-foreground: var(--velt-light-mode-accent-foreground);--velt-accent-light: var(--velt-light-mode-accent-light);--velt-accent-transparent: var(--velt-light-mode-accent-transparent);--velt-text-0: var(--velt-light-mode-text-0);--velt-text-1: var(--velt-light-mode-text-1);--velt-text-2: var(--velt-light-mode-text-2);--velt-text-3: var(--velt-light-mode-text-3);--velt-text-4: var(--velt-light-mode-text-4);--velt-text-5: var(--velt-light-mode-text-5);--velt-text-6: var(--velt-light-mode-text-6);--velt-text-7: var(--velt-light-mode-text-7);--velt-text-8: var(--velt-light-mode-text-8);--velt-text-9: var(--velt-light-mode-text-9);--velt-text-10: var(--velt-light-mode-text-10);--velt-text-11: var(--velt-light-mode-text-11);--velt-text-12: var(--velt-light-mode-text-12);--velt-background-0: var(--velt-light-mode-background-0);--velt-background-1: var(--velt-light-mode-background-1);--velt-background-2: var(--velt-light-mode-background-2);--velt-background-3: var(--velt-light-mode-background-3);--velt-background-4: var(--velt-light-mode-background-4);--velt-background-5: var(--velt-light-mode-background-5);--velt-background-6: var(--velt-light-mode-background-6);--velt-background-7: var(--velt-light-mode-background-7);--velt-background-8: var(--velt-light-mode-background-8);--velt-background-9: var(--velt-light-mode-background-9);--velt-background-10: var(--velt-light-mode-background-10);--velt-border-0: var(--velt-light-mode-border-0);--velt-border-1: var(--velt-light-mode-border-1);--velt-border-2: var(--velt-light-mode-border-2);--velt-border-3: var(--velt-light-mode-border-3);--velt-border-4: var(--velt-light-mode-border-4);--velt-border-5: var(--velt-light-mode-border-5);--velt-border-6: var(--velt-light-mode-border-6);--velt-border-7: var(--velt-light-mode-border-7);--velt-border-8: var(--velt-light-mode-border-8);--velt-border-9: var(--velt-light-mode-border-9);--velt-border-10: var(--velt-light-mode-border-10);--velt-background-transparent: var(--velt-light-mode-background-transparent);--velt-border-transparent: var(--velt-light-mode-border-transparent);--velt-animation-transparent: var(--velt-light-mode-animation-transparent);margin:calc((.5rem + 0px) * var(--velt-base-rem-unit))}[_nghost-%COMP%]:empty{display:none}[dark][_nghost-%COMP%]{--velt-green: var(--velt-dark-mode-green);--velt-magenta: var(--velt-dark-mode-magenta);--velt-amber: var(--velt-dark-mode-amber);--velt-purple: var(--velt-dark-mode-purple);--velt-cyan: var(--velt-dark-mode-cyan);--velt-orange: var(--velt-dark-mode-orange);--velt-black: var(--velt-dark-mode-black);--velt-white: var(--velt-dark-mode-white);--velt-gray: var(--velt-dark-mode-gray);--velt-error: var(--velt-dark-mode-error);--velt-error-hover: var(--velt-dark-mode-error-hover);--velt-error-foreground: var(--velt-dark-mode-error-foreground);--velt-error-light: var(--velt-dark-mode-error-light);--velt-error-transparent: var(--velt-dark-mode-error-transparent);--velt-warning: var(--velt-dark-mode-warning);--velt-warning-hover: var(--velt-dark-mode-warning-hover);--velt-warning-foreground: var(--velt-dark-mode-warning-foreground);--velt-warning-light: var(--velt-dark-mode-warning-light);--velt-warning-transparent: var(--velt-dark-mode-warning-transparent);--velt-agent-accent: #4495ff;--velt-agent-accent-transparent: rgba(68, 149, 255, .2);--velt-success: var(--velt-dark-mode-success);--velt-success-hover: var(--velt-dark-mode-success-hover);--velt-success-foreground: var(--velt-dark-mode-success-foreground);--velt-success-light: var(--velt-dark-mode-success-light);--velt-success-transparent: var(--velt-dark-mode-success-transparent);--velt-accent: var(--velt-dark-mode-accent);--velt-accent-text: var(--velt-dark-mode-accent-text);--velt-accent-hover: var(--velt-dark-mode-accent-hover);--velt-accent-foreground: var(--velt-dark-mode-accent-foreground);--velt-accent-light: var(--velt-dark-mode-accent-light);--velt-accent-transparent: var(--velt-dark-mode-accent-transparent);--velt-text-0: var(--velt-dark-mode-text-0);--velt-text-1: var(--velt-dark-mode-text-1);--velt-text-2: var(--velt-dark-mode-text-2);--velt-text-3: var(--velt-dark-mode-text-3);--velt-text-4: var(--velt-dark-mode-text-4);--velt-text-5: var(--velt-dark-mode-text-5);--velt-text-6: var(--velt-dark-mode-text-6);--velt-text-7: var(--velt-dark-mode-text-7);--velt-text-8: var(--velt-dark-mode-text-8);--velt-text-9: var(--velt-dark-mode-text-9);--velt-text-10: var(--velt-dark-mode-text-10);--velt-text-11: var(--velt-dark-mode-text-11);--velt-text-12: var(--velt-dark-mode-text-12);--velt-background-0: var(--velt-dark-mode-background-0);--velt-background-1: var(--velt-dark-mode-background-1);--velt-background-2: var(--velt-dark-mode-background-2);--velt-background-3: var(--velt-dark-mode-background-3);--velt-background-4: var(--velt-dark-mode-background-4);--velt-background-5: var(--velt-dark-mode-background-5);--velt-background-6: var(--velt-dark-mode-background-6);--velt-background-7: var(--velt-dark-mode-background-7);--velt-background-8: var(--velt-dark-mode-background-8);--velt-background-9: var(--velt-dark-mode-background-9);--velt-background-10: var(--velt-dark-mode-background-10);--velt-border-0: var(--velt-dark-mode-border-0);--velt-border-1: var(--velt-dark-mode-border-1);--velt-border-2: var(--velt-dark-mode-border-2);--velt-border-3: var(--velt-dark-mode-border-3);--velt-border-4: var(--velt-dark-mode-border-4);--velt-border-5: var(--velt-dark-mode-border-5);--velt-border-6: var(--velt-dark-mode-border-6);--velt-border-7: var(--velt-dark-mode-border-7);--velt-border-8: var(--velt-dark-mode-border-8);--velt-border-9: var(--velt-dark-mode-border-9);--velt-border-10: var(--velt-dark-mode-border-10);--velt-background-transparent: var(--velt-dark-mode-background-transparent);--velt-border-transparent: var(--velt-dark-mode-border-transparent);--velt-animation-transparent: var(--velt-dark-mode-animation-transparent)}.velt-presence-tooltip[_ngcontent-%COMP%]{display:flex;align-items:center;gap:calc((.5rem + 0px) * var(--velt-base-rem-unit));block-size:auto;width:max-content;background-color:var(--velt-background-0);border:1px solid var(--velt-border-5);color:var(--velt-text-0);text-align:left;padding:var(--velt-spacing-xs) var(--velt-spacing-sm);border-radius:var(--velt-border-radius-xs);font-style:normal;font-weight:400;font-size:var(--velt-font-size-xs);line-height:2em;z-index:1;transition:opacity .5s}.velt-presence-tooltip[_ngcontent-%COMP%]:after{background-color:var(--velt-background-0);border-color:var(--velt-border-5)}"],changeDetection:0});let n=r;return n})();var dr=["tooltipContent"],gn=(n,r,o)=>({componentConfigSignal:n,presenceUser:r,index:o}),ur=(n,r)=>({condition:n,data:r}),hr=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-avatar-list-item-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function fr(n,r){if(n&1){let o=nt();d(0),T(1,"snippyly-user-avatar",6),rt("click",function(){we(o);let t=s(3).ngIf,i=s();return Fe(t.onPresenceUserClick(i.presenceUser))}),R(2,"div",7),O(),u()}if(n&2){let o=s(4);l(),je("away",o.presenceUser.onlineStatus===o.constants.PRESENCE_STATUS_AWAY)("velt-presence-avatar--away",o.presenceUser.onlineStatus===o.constants.PRESENCE_STATUS_AWAY),c("user",o.presenceUser),l(),yt("border-color",o.presenceUser.color)}}function Sr(n,r){if(n&1){let o=nt();T(0,"div",4),rt("pointerenter",function(t){we(o);let i=s(2).ngIf,a=s();return i.showTooltip(t,a.presenceUser),Fe(t.stopPropagation())})("pointerleave",function(t){return we(o),s(2).ngIf.closeTooltip(),Fe(t.stopPropagation())}),g(1,fr,3,7,"ng-container",5),O()}if(n&2){let o=s(2).ngIf,e=s();l(),c("veltDynamicTemplate",k(5,hr,e.template,it(1,gn,e.componentConfigSignal,e.presenceUser,e.index),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function Cr(n,r){if(n&1&&R(0,"velt-presence-tooltip",8),n&2){let o=r.$implicit,e=s(2).ngIf;c("presenceUser",o)("shadowDom",e.shadowDom)}}function _r(n,r){if(n&1&&(d(0),g(1,Sr,2,11,"div",3)(2,Cr,1,2,"ng-template",null,0,ne),u()),n&2){let o=s().ngIf,e=s();l(),c("ngIf",e.index<o.maxUsers)}}function yr(n,r){if(n&1&&(d(0),g(1,_r,4,1,"ng-container",2),u()),n&2){let o=s();l(),c("veltIf",E(5,ur,o.conditionSignal(),it(1,gn,o.componentConfigSignal,o.presenceUser,o.index)))}}var Ee=(()=>{let r=class r extends ${get itemTemplate(){return this._itemTemplate}set itemTemplate(e){try{this._itemTemplate=e,this.itemTemplate?this.template=this.domService.deepCloneElement(this.itemTemplate):this.template=null}catch{}}constructor(e,t,i,a){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.domService=a,this.componentId="velt-presence-avatar-list-item",this.constants=v;try{super.initializeComponentConfigSignal(new ie)}catch(h){this.loggingService.catch("Error in PresenceAvatarListItemComponent constructor: ",h)}}ngOnInit(){try{this.dynamicDataService.applyConditionalClasses(this.elementRef.nativeElement,{componentConfigSignal:this.componentConfigSignal,presenceUser:this.presenceUser,index:this.index}),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in PresenceAvatarListItemComponent ngOnInit: ",e)}}ngAfterViewInit(){try{setTimeout(()=>{this.componentConfigSignal.set(F(C({},this.componentConfigSignal()),{tooltipContent:this.tooltipContent}))},1e3)}catch(e){this.loggingService.catch("Error in PresenceAvatarListItemComponent ngAfterViewInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceAvatarListItemComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceAvatarListItemComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(b),m(f),m(p),m(We))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-avatar-list-item-internal"]],viewQuery:function(t,i){if(t&1&&St(dr,5),t&2){let a;Ct(a=_t())&&(i.tooltipContent=a.first)}},inputs:{presenceUser:"presenceUser",index:"index",itemTemplate:"itemTemplate"},standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[["tooltipContent",""],[4,"ngIf"],[4,"veltIf"],["class","velt-presence-avatar-list-item velt-tooltip s-presence-avatar-container s-tooltip",3,"pointerenter","pointerleave",4,"ngIf"],[1,"velt-presence-avatar-list-item","velt-tooltip","s-presence-avatar-container","s-tooltip",3,"pointerenter","pointerleave"],[4,"veltDynamicTemplate"],[1,"velt-presence-avatar","s-presence-avatar",3,"click","user"],[1,"velt-presence-avatar-outline","avatar-outline"],[3,"presenceUser","shadowDom"]],template:function(t,i){t&1&&g(0,yr,2,8,"ng-container",1),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,N,A,re,be],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]:empty{display:none}.velt-presence-avatar-list-item[_ngcontent-%COMP%]{height:calc((1.5 + 0px) * var(--velt-base-rem-unit));width:calc((1.5 + 0px) * var(--velt-base-rem-unit));display:flex;justify-content:center;align-items:center;cursor:pointer}.velt-presence-avatar-list-item[_ngcontent-%COMP%] .velt-presence-avatar[_ngcontent-%COMP%]{position:relative;border-radius:var(--velt-border-radius-full);z-index:2;width:calc((1.5 + 0px) * var(--velt-base-rem-unit));height:calc((1.5 + 0px) * var(--velt-base-rem-unit));display:flex;align-items:center;justify-content:center}.velt-presence-avatar--away[_ngcontent-%COMP%]{filter:grayscale(.7)}.velt-presence-avatar-outline[_ngcontent-%COMP%]{position:absolute;inset:-1px;border:1px solid transparent;border-radius:var(--velt-border-radius-full)}snippyly-user-avatar[_ngcontent-%COMP%]{--legacy-velt-user-avatar-size: 1.5rem}"],changeDetection:0});let n=r;return n})();var vn=n=>({componentConfigSignal:n}),br=(n,r)=>({condition:n,data:r}),Er=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-avatar-list-wireframe",variant:o,setIfCondition:e,componentElementRef:t,replaceTemplate:!1});function Pr(n,r){if(n&1&&(d(0),R(1,"velt-presence-avatar-list-item-internal",4),u()),n&2){let o=r.$implicit,e=r.index,t=s(4);l(),c("presenceUser",o)("index",e)("componentConfigSignal",t.componentConfigSignal)("itemTemplate",t.itemTemplate)}}function xr(n,r){if(n&1&&(d(0),g(1,Pr,2,4,"ng-container",3),u()),n&2){let o=s(2).ngIf;l(),c("ngForOf",o.filteredPresenceUsers)("ngForTrackBy",o.trackById)}}function Ur(n,r){if(n&1&&(d(0),g(1,xr,2,2,"ng-container",2),u()),n&2){let o=s().ngIf,e=s();l(),c("veltDynamicTemplate",k(3,Er,e.template,_(1,vn,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function Tr(n,r){if(n&1&&(d(0),g(1,Ur,2,9,"ng-container",1),u()),n&2){let o=s();l(),c("veltIf",E(3,br,o.conditionSignal(),_(1,vn,o.componentConfigSignal)))}}var Pe=(()=>{let r=class r extends ${constructor(e,t,i){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.componentId="velt-presence-avatar-list",this.constants=v;try{super.initializeComponentConfigSignal(new ie)}catch(a){this.loggingService.catch("Error in PresenceAvatarListComponent constructor: ",a)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes();let e=this.template?.querySelector("velt-presence-avatar-list-item-wireframe");Mt(e)||(this.itemTemplate=e)}catch(e){this.loggingService.catch("Error in PresenceAvatarListComponent ngOnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceAvatarListComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceAvatarListComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(b),m(f),m(p))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-avatar-list-internal"]],standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"],[4,"ngFor","ngForOf","ngForTrackBy"],[3,"presenceUser","index","componentConfigSignal","itemTemplate"]],template:function(t,i){t&1&&g(0,Tr,2,6,"ng-container",0),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[bt,D,N,A,Ee],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]{position:relative;display:flex;flex-direction:row;justify-content:center;align-items:center;height:calc((1.5 + 0px) * var(--velt-base-rem-unit));min-width:calc((1.5 + 0px) * var(--velt-base-rem-unit))}[_nghost-%COMP%]:empty{display:none}velt-presence-avatar-list-item-internal[_ngcontent-%COMP%]:not(:first-child){margin-left:calc(var(--velt-spacing-xs) * -1)}"],changeDetection:0});let n=r;return n})();var pn=n=>({componentConfigSignal:n}),kr=(n,r)=>({condition:n,data:r}),Dr=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-avatar-remaining-count-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function Ar(n,r){if(n&1&&(d(0),T(1,"snippyly-user-avatar",3),R(2,"div",4),O(),u()),n&2){let o=s(3).ngIf;l(),c("initial","+"+(o.filteredPresenceUsers.length-o.maxUsers).toString())}}function Nr(n,r){if(n&1&&(d(0),g(1,Ar,3,1,"ng-container",2),u()),n&2){let o=s(2).ngIf,e=s();l(),c("veltDynamicTemplate",k(3,Dr,e.template,_(1,pn,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function wr(n,r){if(n&1&&(d(0),g(1,Nr,2,9,"ng-container",0),u()),n&2){let o=s().ngIf;l(),c("ngIf",o.filteredPresenceUsers.length>o.maxUsers)}}function Fr(n,r){if(n&1&&(d(0),g(1,wr,2,1,"ng-container",1),u()),n&2){let o=s();l(),c("veltIf",E(3,kr,o.conditionSignal(),_(1,pn,o.componentConfigSignal)))}}var xe=(()=>{let r=class r extends ${constructor(e,t,i){super(e,t,i),this.elementRef=e,this.dynamicDataService=t,this.loggingService=i,this.componentId="velt-presence-avatar-remaining-count";try{super.initializeComponentConfigSignal(new ie)}catch(a){this.loggingService.catch("Error in PresenceAvatarRemainingCountComponent constructor: ",a)}}ngOnInit(){try{super.ngOnInit(),this.setupA11yAttributes()}catch(e){this.loggingService.catch("Error in PresenceAvatarRemainingCountComponent ngOnInit: ",e)}}ngOnDestroy(){try{super.ngOnDestroy()}catch(e){this.loggingService.catch("Error in PresenceAvatarRemainingCountComponent ngOnDestroy: ",e)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceAvatarRemainingCountComponent setupA11yAttributes:",e)}}};r.\u0275fac=function(t){return new(t||r)(m(b),m(f),m(p))},r.\u0275cmp=x({type:r,selectors:[["velt-presence-avatar-remaining-count-internal"]],standalone:!1,features:[j([f]),U],decls:1,vars:1,consts:[[4,"ngIf"],[4,"veltIf"],[4,"veltDynamicTemplate"],[1,"velt-presence-avatar","velt-presence-avatar-remaining-count","s-presence-avatar","more-users",3,"initial"],[1,"velt-presence-avatar-remaining-count-outline","avatar-outline"]],template:function(t,i){t&1&&g(0,Fr,2,6,"ng-container",0),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,N,A,re],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]:empty{display:none}.velt-presence-avatar[_ngcontent-%COMP%]{position:relative;border-radius:var(--velt-border-radius-full);z-index:2;width:calc((1.5 + 0px) * var(--velt-base-rem-unit));height:calc((1.5 + 0px) * var(--velt-base-rem-unit));display:flex;align-items:center;justify-content:center}.velt-presence-avatar.velt-presence-avatar-remaining-count[_ngcontent-%COMP%]{box-shadow:none;color:var(--velt-text-0);margin-left:calc(var(--velt-spacing-xs) * -1);background-color:var(--legacy-velt-presence-more-users-color)}.velt-presence-avatar.velt-presence-avatar-remaining-count[_ngcontent-%COMP%] .velt-presence-avatar-remaining-count-outline[_ngcontent-%COMP%]{border-color:var(--legacy-velt-presence-more-users-color)}snippyly-user-avatar[_ngcontent-%COMP%]{--legacy-velt-user-avatar-size: 1.5rem}"],changeDetection:0});let n=r;return n})();var dn=n=>({componentConfigSignal:n}),Mr=(n,r)=>({condition:n,data:r}),Lr=(n,r,o,e,t)=>({template:n,context:r,componentName:"velt-presence-wireframe",variant:o,setIfCondition:e,componentElementRef:t});function jr(n,r){n&1&&Le(0)}function $r(n,r){if(n&1&&(T(0,"velt-shadow-dom-internal"),g(1,jr,1,0,"ng-container",4),O()),n&2){s();let o=te(3);l(),c("ngTemplateOutlet",o)}}function Br(n,r){if(n&1&&(d(0),R(1,"velt-presence-avatar-list-internal",8)(2,"velt-presence-avatar-remaining-count-internal",8),u()),n&2){let o=s(5);l(),c("componentConfigSignal",o.componentConfigSignal),l(),c("componentConfigSignal",o.componentConfigSignal)}}function Wr(n,r){if(n&1&&(T(0,"div",6),g(1,Br,3,2,"ng-container",7),O()),n&2){let o=s(3).ngIf,e=s();l(),c("veltDynamicTemplate",k(3,Lr,e.template,_(1,dn,e.componentConfigSignal),o==null?null:o.variant,e.setIfCondition.bind(e),e.elementRef))}}function zr(n,r){if(n&1&&g(0,Wr,2,9,"div",5),n&2){let o=s(2).ngIf;c("ngIf",o.filteredPresenceUsers&&o.filteredPresenceUsers.length>0&&!(o.user!=null&&o.user.isAnonymous))}}function Jr(n,r){if(n&1&&(d(0),g(1,$r,2,1,"velt-shadow-dom-internal",3)(2,zr,1,1,"ng-template",null,0,ne),u()),n&2){let o=te(3),e=s().ngIf,t=s();l(),c("ngIf",e.shadowDom&&!t.template||t.template&&t.isExplicitShadowDom)("ngIfElse",o)}}function Gr(n,r){if(n&1&&(d(0),g(1,Jr,4,2,"ng-container",2),u()),n&2){let o=s();l(),c("veltIf",E(3,Mr,o.conditionSignal(),_(1,dn,o.componentConfigSignal)))}}var pe=(()=>{let r=class r extends Ve{get maxUsers(){return this._maxUsers}set maxUsers(e){try{isNaN(e)?this.loggingService.catch("Error in Presence set maxUsers: ","max-user value is not a number."):this._maxUsers=e}catch(t){this.loggingService.catch("Error in Presence set maxUsers: ",t)}}get inactivityTime(){return this._inactivityTime}set inactivityTime(e){try{isNaN(e)?this.loggingService.catch("Error in Presence set inactivityTime: ","inactivity-time value is not a number."):(this._inactivityTime=e,this.presenceService.setInactivityTime(this._inactivityTime))}catch(t){this.loggingService.catch("Error in Presence set inactivityTime: ",t)}}get offlineInactivityTime(){return this._offlineInactivityTime}set offlineInactivityTime(e){try{isNaN(e)?this.loggingService.catch("Error in Presence set offlineInactivityTime: ","offline-inactivity-time value is not a number."):(this._offlineInactivityTime=e,this.presenceService.setOfflineInactivityTime(this._offlineInactivityTime))}catch(t){this.loggingService.catch("Error in Presence set offlineInactivityTime: ",t)}}get flockMode(){return this._flockMode}set flockMode(e){try{let t=typeof e=="string"?JSON.parse(e):e;t?(this._flockMode=t,this.flockService.enableFlockMode(),this.flockService.setNavigateEmitter(this.onNavigate)):(this._flockMode=t,this.flockService.disableFlockMode())}catch(t){this.loggingService.catch("Error in Presence set flockMode: ",t)}}set disableFlockNavigation(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.flockService.setDisableFlockNavigation(t)}catch(t){this.loggingService.catch("Error in Presence set disableFlockNavigation: ",t)}}set defaultFlockNavigation(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.flockService.setDisableFlockNavigation(!t)}catch(t){this.loggingService.catch("Error in Presence set defaultFlockNavigation: ",t)}}get location(){return this._location}set location(e){try{if(e&&typeof e=="string"){let t=JSON.parse(e);this._location=t,this.serverLocationId=Ft(this.location)}}catch(t){this.loggingService.catch("Error in Presence set location: ",t)}}set self(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),t?this.presenceService.enableIncludeSelf():this.presenceService.disableIncludeSelf()}catch{}}set _shadowDom(e){try{let t=e;typeof e=="string"&&(t=JSON.parse(e)),this.isExplicitShadowDom=!!t,this.componentConfigSignal.update(i=>(i=F(C({},i),{shadowDom:t}),i))}catch{}}constructor(e,t,i,a,h,y,M,He,Ke,Te,Oe,ke){super(Te,Oe,void 0,void 0,void 0,ke,h),this.analyticsService=e,this.authService=t,this.flockService=i,this.presenceService=a,this.loggingService=h,this.wireframeService=y,this.overlay=M,this.overlayPositionBuilder=He,this.viewContainerRef=Ke,this.elementRef=Te,this.themeService=Oe,this.dynamicDataService=ke,this.DEFAULT_MAX_USERS=5,this._maxUsers=this.DEFAULT_MAX_USERS,this._inactivityTime=5,this._offlineInactivityTime=10,this._flockMode=!1,this.onNavigate=new fe,this.isExplicitShadowDom=!1,this.onPresenceUserClickEmitter=new fe,this.presenceUsers=[],this.subscriptions=[],this.constants=v,this.onUsersChanged=new fe,this.onPresenceUserChange=new fe,this.componentConfigSignal=Re({filteredPresenceUsers:[],user:null,shadowDom:!0,maxUsers:5,tooltipContent:null,trackById:this.trackById.bind(this),showTooltip:this.showTooltip.bind(this),closeTooltip:this.closeTooltip.bind(this),onPresenceUserClick:this.onPresenceUserClick.bind(this)}),this.veltElement=!0,this.componentId="velt-presence",this.loggingService.log("%c[WB] Creating CLASS: PresenceComponent","color: blue;"),this.subscriptions.push(this.authService.getUser$().subscribe(de=>{this.componentConfigSignal.update(ue=>(ue=F(C({},ue),{user:de}),ue)),this.componentConfigSignal().user&&(this.setPresenceInstalledInAnalytics(),this.presenceSetCustomMaxUsersInAnalytics())},de=>{this.loggingService.catch("Error in PresenceComponent getUser$ subscription: ",de)}))}ngOnInit(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnInit","color: green;");try{this.getOnlineUsersOnCurrentDocument(),this.setupA11yAttributes(),super.ngOnInit(),this.subscriptions.push(this.wireframeService.getWireframe$("velt-presence-wireframe").subscribe(t=>{if(t){let i=document.createElement(t.tagName);i.innerHTML=t.innerHTML,this.template=i}}))}catch(e){this.loggingService.catch("Error in PresenceComponent oninit: ",e)}}ngOnChanges(e){try{this.loggingService.log("%c[WB] Calling PresenceComponent FUNCTION: ngOnChanges","color: green;"),e&&(super.ngOnChanges(e),Object.keys(e).forEach(t=>{this.componentConfigSignal.update(i=>(i=F(C({},i),{[t]:e[t].currentValue}),i))}))}catch(t){this.loggingService.catch("Error in PresenceComponent ngOnChanges: ",t)}}setupA11yAttributes(){try{this.elementRef.nativeElement.setAttribute("data-testid",this.componentId+"-container")}catch(e){this.loggingService.catch("Error in PresenceComponent setupA11yAttributes:",e)}}ngOnDestroy(){this.loggingService.log("%c[WB] Calling FUNCTION: ngOnDestroy","color: green;");try{this.unsubscribe(),super.ngOnDestroy(),this.closeTooltip()}catch(e){this.loggingService.catch("Error in PresenceComponent ondestroy: ",e)}}unsubscribe(){this.loggingService.log("%c[WB] Calling FUNCTION: unsubscribe","color: green;");try{this.subscriptions.map(e=>{e.unsubscribe()}),this.subscriptions=[]}catch(e){this.loggingService.catch("Error in PresenceComponent unsubscribe: ",e)}}showTooltip(e,t){try{this.closeTooltip();let i=new b(e.currentTarget),a=this.overlayPositionBuilder.flexibleConnectedTo(i).withPositions([{originX:"center",originY:"bottom",overlayX:"center",overlayY:"top"},{originX:"center",originY:"top",overlayX:"center",overlayY:"bottom"},{originX:"start",originY:"center",overlayX:"end",overlayY:"center"},{originX:"end",originY:"center",overlayX:"start",overlayY:"center"}]);this.overlayRef=this.overlay.create({positionStrategy:a}),this.overlayRef.attach(new Pt(this.componentConfigSignal().tooltipContent,this.viewContainerRef,{$implicit:t}))}catch(i){this.loggingService.catch("Error in PresenceComponent showTooltip: ",i)}}closeTooltip(){try{this.overlayRef&&this.overlayRef.dispose()}catch(e){this.loggingService.catch("Error in PresenceComponent closeTooltip: ",e)}}getOnlineUsersOnCurrentDocument(){this.loggingService.log("%c[WB] Calling FUNCTION: getOnlineUsersOnCurrentDocument","color: green;");try{this.subscriptions.push(this.presenceService.getOnlineUsersOnCurrentDocument().pipe(Y(e=>!!e)).subscribe(e=>{this.loggingService.log(e),e&&(this.presenceUsers=e),this.filterPresenceUsers()},e=>{this.loggingService.catch("Error in PresenceComponent getOnlineUsersOnCurrentDocument subscription: ",e)}))}catch(e){this.loggingService.catch("Error in PresenceComponent getOnlineUsersOnCurrentDocument: ",e)}}filterPresenceUsers(){try{let e=[];this.presenceUsers?this.locationId?e=this.presenceUsers.filter(t=>t?.location?.id===this.locationId):this.location?e=this.presenceUsers.filter(t=>t.locationId===this.serverLocationId):e=this.presenceUsers:e=[],this.componentConfigSignal.update(t=>(t=F(C({},t),{filteredPresenceUsers:e}),t)),this.onUsersChanged.emit(this.componentConfigSignal().filteredPresenceUsers),this.onPresenceUserChange.emit(this.componentConfigSignal().filteredPresenceUsers)}catch(e){this.loggingService.catch("Error in PresenceComponent filterPresenceUsers: ",e)}}calculateUserAwayTime(e){try{if(e.onlineStatus===v.PRESENCE_STATUS_ONLINE)return 0;let t=me(e.timestamp);return Math.floor(t/1e3/60)}catch(t){this.loggingService.catch("Error in PresenceComponent calculateUserAwayTime: ",t)}return 0}setPresenceInstalledInAnalytics(){try{this.analyticsService.setInstalledFeature(X.PRESENCE)}catch(e){this.loggingService.catch("Error in PresenceComponent setPresenceInstalledInAnalytics: ",e)}}presenceSetCustomMaxUsersInAnalytics(){try{this.maxUsers!=this.DEFAULT_MAX_USERS&&this.analyticsService.trackEvent(P.Events.Presence.PRESENCE_SET_CUSTOM_MAX_USERS,{maxUsers:+this.maxUsers})}catch(e){this.loggingService.catch("Error in PresenceComponent presenceSetCustomMaxUsersInAnalytics: ",e)}}onPresenceUserClick(e){try{this.analyticsService.trackEvent(P.Events.Presence.PRESENCE_USER_CLICKED,{totalUsers:this.presenceService?.getPresenceUsers()?.length,presenceSnippylyUserIds:this.presenceService?.getPresenceUsers()?.map(t=>t.userSnippylyId),presenceClientUserIds:this.presenceService?.getPresenceUsers()?.map(t=>t.userId)}),this.onPresenceUserClickEmitter.emit(e),this.componentConfigSignal().user?.userSnippylyId!==e?.userSnippylyId&&this.flockService.getFlockMode()&&this.setFlockLeader(e.userSnippylyId,e.name)}catch(t){this.loggingService.catch("Error in PresenceComponent onPresenceUserClick: ",t)}}setFlockLeader(e,t){try{this.flockService.setFlockLeader(e,t)}catch(i){this.loggingService.catch("Error in PresenceComponent setFlockLeader: ",i)}}trackById(e,t){return t?.userId}};r.\u0275fac=function(t){return new(t||r)(m(ge),m(ze),m(K),m(W),m(p),m(Je),m(Ut),m(xt),m(dt),m(b),m(Ge),m(f))},r.\u0275cmp=x({type:r,selectors:[["app-presence"]],hostVars:1,hostBindings:function(t,i){t&2&&ft("data-velt-element",i.veltElement)},inputs:{maxUsers:"maxUsers",inactivityTime:"inactivityTime",offlineInactivityTime:"offlineInactivityTime",flockMode:"flockMode",disableFlockNavigation:"disableFlockNavigation",defaultFlockNavigation:"defaultFlockNavigation",location:"location",locationId:"locationId",self:"self",_shadowDom:[0,"shadowDom","_shadowDom"],variant:"variant"},outputs:{onNavigate:"onNavigate",onPresenceUserClickEmitter:"onPresenceUserClick",onUsersChanged:"usersChanged",onPresenceUserChange:"onPresenceUserChange"},standalone:!1,features:[U,Me],decls:1,vars:1,consts:[["presenceRef",""],[4,"ngIf"],[4,"veltIf"],[4,"ngIf","ngIfElse"],[4,"ngTemplateOutlet"],["class","velt-presence-container s-presence-container",4,"ngIf"],[1,"velt-presence-container","s-presence-container"],[4,"veltDynamicTemplate"],[3,"componentConfigSignal"]],template:function(t,i){t&1&&g(0,Gr,2,6,"ng-container",1),t&2&&c("ngIf",i.componentConfigSignal())},dependencies:[D,Be,N,A,Pe,xe],styles:["html[_ngcontent-%COMP%]{--velt-base-rem-unit: 1}*[data-snippyly-element=true][_ngcontent-%COMP%], *[data-velt-element=true][_ngcontent-%COMP%]{font-family:var(--velt-default-font-family)}velt-wireframe[_ngcontent-%COMP%]{display:none!important}body.velt-pin-dragging[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{pointer-events:none!important}[_nghost-%COMP%]{--velt-green: var(--velt-light-mode-green);--velt-magenta: var(--velt-light-mode-magenta);--velt-amber: var(--velt-light-mode-amber);--velt-purple: var(--velt-light-mode-purple);--velt-cyan: var(--velt-light-mode-cyan);--velt-orange: var(--velt-light-mode-orange);--velt-black: var(--velt-light-mode-black);--velt-white: var(--velt-light-mode-white);--velt-gray: var(--velt-light-mode-gray);--velt-error: var(--velt-light-mode-error);--velt-error-hover: var(--velt-light-mode-error-hover);--velt-error-foreground: var(--velt-light-mode-error-foreground);--velt-error-light: var(--velt-light-mode-error-light);--velt-error-transparent: var(--velt-light-mode-error-transparent);--velt-warning: var(--velt-light-mode-warning);--velt-warning-hover: var(--velt-light-mode-warning-hover);--velt-warning-foreground: var(--velt-light-mode-warning-foreground);--velt-warning-light: var(--velt-light-mode-warning-light);--velt-warning-transparent: var(--velt-light-mode-warning-transparent);--velt-agent-accent: #4495ff;--velt-agent-accent-transparent: rgba(68, 149, 255, .2);--velt-success: var(--velt-light-mode-success);--velt-success-hover: var(--velt-light-mode-success-hover);--velt-success-foreground: var(--velt-light-mode-success-foreground);--velt-success-light: var(--velt-light-mode-success-light);--velt-success-transparent: var(--velt-light-mode-success-transparent);--velt-accent: var(--velt-light-mode-accent);--velt-accent-text: var(--velt-light-mode-accent-text);--velt-accent-hover: var(--velt-light-mode-accent-hover);--velt-accent-foreground: var(--velt-light-mode-accent-foreground);--velt-accent-light: var(--velt-light-mode-accent-light);--velt-accent-transparent: var(--velt-light-mode-accent-transparent);--velt-text-0: var(--velt-light-mode-text-0);--velt-text-1: var(--velt-light-mode-text-1);--velt-text-2: var(--velt-light-mode-text-2);--velt-text-3: var(--velt-light-mode-text-3);--velt-text-4: var(--velt-light-mode-text-4);--velt-text-5: var(--velt-light-mode-text-5);--velt-text-6: var(--velt-light-mode-text-6);--velt-text-7: var(--velt-light-mode-text-7);--velt-text-8: var(--velt-light-mode-text-8);--velt-text-9: var(--velt-light-mode-text-9);--velt-text-10: var(--velt-light-mode-text-10);--velt-text-11: var(--velt-light-mode-text-11);--velt-text-12: var(--velt-light-mode-text-12);--velt-background-0: var(--velt-light-mode-background-0);--velt-background-1: var(--velt-light-mode-background-1);--velt-background-2: var(--velt-light-mode-background-2);--velt-background-3: var(--velt-light-mode-background-3);--velt-background-4: var(--velt-light-mode-background-4);--velt-background-5: var(--velt-light-mode-background-5);--velt-background-6: var(--velt-light-mode-background-6);--velt-background-7: var(--velt-light-mode-background-7);--velt-background-8: var(--velt-light-mode-background-8);--velt-background-9: var(--velt-light-mode-background-9);--velt-background-10: var(--velt-light-mode-background-10);--velt-border-0: var(--velt-light-mode-border-0);--velt-border-1: var(--velt-light-mode-border-1);--velt-border-2: var(--velt-light-mode-border-2);--velt-border-3: var(--velt-light-mode-border-3);--velt-border-4: var(--velt-light-mode-border-4);--velt-border-5: var(--velt-light-mode-border-5);--velt-border-6: var(--velt-light-mode-border-6);--velt-border-7: var(--velt-light-mode-border-7);--velt-border-8: var(--velt-light-mode-border-8);--velt-border-9: var(--velt-light-mode-border-9);--velt-border-10: var(--velt-light-mode-border-10);--velt-background-transparent: var(--velt-light-mode-background-transparent);--velt-border-transparent: var(--velt-light-mode-border-transparent);--velt-animation-transparent: var(--velt-light-mode-animation-transparent)}[_nghost-%COMP%]:empty{display:none}[dark][_nghost-%COMP%]{--velt-green: var(--velt-dark-mode-green);--velt-magenta: var(--velt-dark-mode-magenta);--velt-amber: var(--velt-dark-mode-amber);--velt-purple: var(--velt-dark-mode-purple);--velt-cyan: var(--velt-dark-mode-cyan);--velt-orange: var(--velt-dark-mode-orange);--velt-black: var(--velt-dark-mode-black);--velt-white: var(--velt-dark-mode-white);--velt-gray: var(--velt-dark-mode-gray);--velt-error: var(--velt-dark-mode-error);--velt-error-hover: var(--velt-dark-mode-error-hover);--velt-error-foreground: var(--velt-dark-mode-error-foreground);--velt-error-light: var(--velt-dark-mode-error-light);--velt-error-transparent: var(--velt-dark-mode-error-transparent);--velt-warning: var(--velt-dark-mode-warning);--velt-warning-hover: var(--velt-dark-mode-warning-hover);--velt-warning-foreground: var(--velt-dark-mode-warning-foreground);--velt-warning-light: var(--velt-dark-mode-warning-light);--velt-warning-transparent: var(--velt-dark-mode-warning-transparent);--velt-agent-accent: #4495ff;--velt-agent-accent-transparent: rgba(68, 149, 255, .2);--velt-success: var(--velt-dark-mode-success);--velt-success-hover: var(--velt-dark-mode-success-hover);--velt-success-foreground: var(--velt-dark-mode-success-foreground);--velt-success-light: var(--velt-dark-mode-success-light);--velt-success-transparent: var(--velt-dark-mode-success-transparent);--velt-accent: var(--velt-dark-mode-accent);--velt-accent-text: var(--velt-dark-mode-accent-text);--velt-accent-hover: var(--velt-dark-mode-accent-hover);--velt-accent-foreground: var(--velt-dark-mode-accent-foreground);--velt-accent-light: var(--velt-dark-mode-accent-light);--velt-accent-transparent: var(--velt-dark-mode-accent-transparent);--velt-text-0: var(--velt-dark-mode-text-0);--velt-text-1: var(--velt-dark-mode-text-1);--velt-text-2: var(--velt-dark-mode-text-2);--velt-text-3: var(--velt-dark-mode-text-3);--velt-text-4: var(--velt-dark-mode-text-4);--velt-text-5: var(--velt-dark-mode-text-5);--velt-text-6: var(--velt-dark-mode-text-6);--velt-text-7: var(--velt-dark-mode-text-7);--velt-text-8: var(--velt-dark-mode-text-8);--velt-text-9: var(--velt-dark-mode-text-9);--velt-text-10: var(--velt-dark-mode-text-10);--velt-text-11: var(--velt-dark-mode-text-11);--velt-text-12: var(--velt-dark-mode-text-12);--velt-background-0: var(--velt-dark-mode-background-0);--velt-background-1: var(--velt-dark-mode-background-1);--velt-background-2: var(--velt-dark-mode-background-2);--velt-background-3: var(--velt-dark-mode-background-3);--velt-background-4: var(--velt-dark-mode-background-4);--velt-background-5: var(--velt-dark-mode-background-5);--velt-background-6: var(--velt-dark-mode-background-6);--velt-background-7: var(--velt-dark-mode-background-7);--velt-background-8: var(--velt-dark-mode-background-8);--velt-background-9: var(--velt-dark-mode-background-9);--velt-background-10: var(--velt-dark-mode-background-10);--velt-border-0: var(--velt-dark-mode-border-0);--velt-border-1: var(--velt-dark-mode-border-1);--velt-border-2: var(--velt-dark-mode-border-2);--velt-border-3: var(--velt-dark-mode-border-3);--velt-border-4: var(--velt-dark-mode-border-4);--velt-border-5: var(--velt-dark-mode-border-5);--velt-border-6: var(--velt-dark-mode-border-6);--velt-border-7: var(--velt-dark-mode-border-7);--velt-border-8: var(--velt-dark-mode-border-8);--velt-border-9: var(--velt-dark-mode-border-9);--velt-border-10: var(--velt-dark-mode-border-10);--velt-background-transparent: var(--velt-dark-mode-background-transparent);--velt-border-transparent: var(--velt-dark-mode-border-transparent);--velt-animation-transparent: var(--velt-dark-mode-animation-transparent)}[_nghost-%COMP%]{position:relative;display:inline-flex;justify-content:center;align-items:center;margin:0;padding:0;-webkit-tap-highlight-color:rgba(255,255,255,0);box-sizing:border-box;width:auto;height:calc((1.5 + 0px) * var(--velt-base-rem-unit));font-size:var(--velt-font-size-xs);line-height:1.5;background:transparent}.velt-presence-container[_ngcontent-%COMP%]{position:relative;display:flex;flex-direction:row;justify-content:center;align-items:center;height:calc((1.5 + 0px) * var(--velt-base-rem-unit));min-width:calc((1.5 + 0px) * var(--velt-base-rem-unit))}"],changeDetection:0});let n=r;return n})();var Ue=(()=>{let r=class r{constructor(e,t,i){this.analyticsService=e,this.loggingService=t,this.presenceService=i,this.actionSubjects=new Map,this.subscriptions=[];try{this.presenceService.setPresenceActionsService(this)}catch(a){this.loggingService.catch("Error in PresenceActionsService constructor: ",a)}}onMultipleUsersOnline(e){try{this.loggingService.log("%c[WB] Calling PresenceActionsService FUNCTION: onMultipleUsersOnline","color: green;"),this.triggerAction(ot.MULTIPLE_USERS_ONLINE,e),this.analyticsService.trackEvent(P.Events.Presence.MULTIPLE_USERS_ONLINE,{totalUsers:e?.users?.length,presenceSnippylyUserIds:e?.users?.map(t=>t.userSnippylyId),presenceClientUserIds:e?.users?.map(t=>t.userId)})}catch(t){this.loggingService.catch("Error in PresenceActionsService onMultipleUsersOnline: ",t)}}onUserStateChange(e){try{this.loggingService.log("%c[WB] Calling PresenceActionsService FUNCTION: onUserStateChange","color: green;"),this.triggerAction(ot.USER_STATE_CHANGE,e),this.analyticsService.trackEvent(P.Events.Presence.ON_USER_STATE_CHANGE,{userSnippylyId:e?.user?.userSnippylyId,userId:e?.user?.userId,state:e?.state})}catch(t){this.loggingService.catch("Error in PresenceActionsService onUserStateChange: ",t)}}getData(e){try{return this.loggingService.log("%c[WB] Calling PresenceActionsService FUNCTION: getData","color: green;"),this.presenceService.getOnlineUsersOnCurrentDocument(e).pipe(L(t=>({data:t})))}catch(t){return this.loggingService.catch("Error in PresenceActionsService getData: ",t),w({data:null})}}triggerAction(e,t){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new Qe),this.actionSubjects.get(e)?.next(t)}catch(i){this.loggingService.catch("Error in PresenceActionsService triggerAction: ",i)}}onAction(e){try{return this.actionSubjects.has(e)||this.actionSubjects.set(e,new Qe),this.actionSubjects.get(e)?.asObservable()}catch(t){return this.loggingService.catch("Error in PresenceActionsService onAction: ",t),w(null)}}};r.\u0275fac=function(t){return new(t||r)(I(ge),I(p),I(W))},r.\u0275prov=ae({token:r,factory:r.\u0275fac,providedIn:"root"});let n=r;return n})();var Xe=class extends qt{constructor(r){super(r),this.getService(p).log("%c[WB] Creating CLASS: PresenceElement","color: blue;"),this.getOnlineUsersOnCurrentDocument=this._getOnlineUsersOnCurrentDocument,this.setInactivityTime=this._setInactivityTime,this.enableFlockMode=this._enableFlockMode,this.disableFlockMode=this._disableFlockMode,this.startFollowingUser=this._startFollowingUser,this.stopFollowingUser=this._stopFollowingUser,this.enableSelf=this._enableSelf,this.disableSelf=this._disableSelf,this.getData=this._getData,this.on=this._on,this.addUser=this._addUser,this.removeUser=this._removeUser}_getOnlineUsersOnCurrentDocument(){this.getService(p).log("%c[WB] Calling FUNCTION: getOnlineUsers","color: green;");try{return this.trackEvent(P.Events.Presence.GET_ONLINE_USERS_ON_CURRENT_DOCUMENT_TRIGGERED),this.getService(W).getOnlineUsersOnCurrentDocument()}catch(r){return this.getService(p).catch("Error in _getOnlineUsersOnCurrentDocument: ",r),w(null)}}_setInactivityTime(r){this.getService(p).log("%c[WB] Calling FUNCTION: _setInactivityTime","color: green;");try{this.trackEvent(P.Events.Presence.SET_INACTIVITY_TIME_TRIGGERED,{payload:{time:r}}),isNaN(r)?this.getService(p).catch("Error in setInactivityTime: ","Provided value is not a number."):this.getService(W).setInactivityTime(r)}catch(o){this.getService(p).catch("Error in setInactivityTime: ",o)}}_disableFlockMode(){try{this.trackEvent(P.Events.Presence.DISABLE_FLOCK_MODE_TRIGGERED),this.getService(K).disableFlockMode()}catch(r){this.getService(p).catch("Error in _disableFlockMode: ",r)}}_enableFlockMode(r){try{this.trackEvent(P.Events.Presence.ENABLE_FLOCK_MODE_TRIGGERED,{payload:{options:r}}),this.getService(K).enableFlockMode(r)}catch(o){this.getService(p).catch("Error in _enableFlockMode: ",o)}}_stopFollowingUser(){try{this.trackEvent(P.Events.Presence.STOP_FOLLOWING_USER_TRIGGERED),this.getService(K).stopFollowingUser()}catch(r){this.getService(p).catch("Error in _stopFollowingUser: ",r)}}_startFollowingUser(r){try{this.trackEvent(P.Events.Presence.START_FOLLOWING_USER_TRIGGERED,{payload:{externalId:r}});let o=this.getService(W).getPresenceUserFromExternalId(r);return o&&o.userSnippylyId&&o.name!==void 0?(this.getService(K).startFollowingUser(o.userSnippylyId,o.name),{success:!0,msg:"Joined flock session."}):{success:!1,msg:"User could not be found."}}catch(o){return this.getService(p).catch("Error in _startFollowingUser: ",o),{success:!1,msg:"Unknown error.",raw:o}}}_enableSelf(){try{this.trackEvent(P.Events.Presence.ENABLE_SELF_TRIGGERED),this.getService(W).enableIncludeSelf()}catch(r){this.getService(p).catch("Error in _enableSelf: ",r)}}_disableSelf(){try{this.trackEvent(P.Events.Presence.DISABLE_SELF_TRIGGERED),this.getService(W).disableIncludeSelf()}catch(r){this.getService(p).catch("Error in _disableSelf: ",r)}}_getData(r){this.getService(p).log("%c[WB] Calling FUNCTION: getData","color: green;");try{return this.trackEvent(P.Events.Presence.GET_PRESENCE_DATA_TRIGGERED,{payload:{query:r}}),r&&typeof r=="object"&&(r=C({},r),r?.documentId&&(r.documentId=At(r.documentId)),r?.organizationId&&(r.organizationId=Nt(r.organizationId))),this.getService(Ue).getData(r)}catch(o){return this.getService(p).catch("Error in _getData: ",o),w({data:null})}}_on(r){this.getService(p).log("%c[WB] Calling FUNCTION: on","color: green;");try{return this.getService(Ue).onAction(r)}catch(o){return this.getService(p).catch("Error in _on: ",o),w(null)}}_addUser(r){this.getService(p).log("%c[WB] Calling FUNCTION: addUser","color: green;");try{if(this.trackEvent(P.Events.Presence.ADD_USER_TRIGGERED,{payload:{userId:r?.user?.userId,localOnly:r?.localOnly}}),!r?.user?.userId){this.getService(p).catch("Error in addUser: ","userId is required");return}this.getService(W).addCustomUser(r)}catch(o){this.getService(p).catch("Error in addUser: ",o)}}_removeUser(r){this.getService(p).log("%c[WB] Calling FUNCTION: removeUser","color: green;");try{if(this.trackEvent(P.Events.Presence.REMOVE_USER_TRIGGERED,{payload:{userId:r?.user?.userId,localOnly:r?.localOnly}}),!r?.user?.userId){this.getService(p).catch("Error in removeUser: ","userId is required");return}this.getService(W).removeCustomUser(r)}catch(o){this.getService(p).catch("Error in removeUser: ",o)}}};var un=(()=>{let r=class r{};r.\u0275fac=function(t){return new(t||r)},r.\u0275mod=ht({type:r}),r.\u0275inj=pt({imports:[Et,re,Ye]});let n=r;return n})();var hn=(()=>{let r=class r{constructor(e,t){this.loggingService=e,this.usersService=t}getUserIdsToResolveFromPresenceUsers(e){try{let t=new Set;for(let i of e)i?.userId&&t.add(i?.userId);return Array.from(t)}catch(t){return this.loggingService.catch("Error in PresenceUtilsService getUserIdsToResolveFromPresenceUsers:",t),[]}}mergePresenceUserWithUser(e){try{if(this.usersService.userDataProviderAvailable()&&e?.userId){let t=this.usersService.getUserById(e?.userId);t&&(e=C(C({},e),t))}return e}catch(t){return this.loggingService.catch("Error in PresenceUtilsService mergePresenceUserWithUser:",t),e}}formatPresenceUserData(e){try{if(this.usersService.userDataProviderAvailable()){let t=["userId","onlineStatus","userSnippylyId","color","textColor","timestamp","type","selections","documentParamsId","documentParams","locationId","location","isReadOnly","isAnonymous","pageInfo"];Object.keys(e).forEach(i=>{t.includes(i)||(e[i]=null)})}return e}catch(t){return this.loggingService.catch("Error in PresenceUtilsService formatPresenceUserData:",t),e}}};r.\u0275fac=function(t){return new(t||r)(I(p),I(Ht))},r.\u0275prov=ae({token:r,factory:r.\u0275fac,providedIn:"root"});let n=r;return n})();var Vr={"velt-presence-wireframe":pe,"velt-presence-avatar-list-wireframe":Pe,"velt-presence-avatar-list-item-wireframe":Ee,"velt-presence-avatar-remaining-count-wireframe":xe,"velt-presence-tooltip-wireframe":be,"velt-presence-tooltip-avatar-wireframe":Se,"velt-presence-tooltip-user-active-wireframe":Ce,"velt-presence-tooltip-user-inactive-wireframe":_e,"velt-presence-tooltip-user-name-wireframe":ye,"velt-presence-tooltip-status-container-wireframe":Ie};Object.assign(Qt,Vr);function Yr(n){n.get(p).log("%c[WB] Loading presence feature chunk","color: blue;");let o=n.get(Wt);o.set(jt,n.get(W)),o.set($t,n.get(Ue)),o.set(Bt,n.get(hn));let t=ut(un,n).injector;return fn(t,v.TAGS.VELT_PRESENCE,pe),fn(t,v.TAGS.SNIPPYLY_PRESENCE,pe),new Xe(n)}function fn(n,r,o){if(customElements.get(r))return;let e=Tt(o,n);customElements.define(r,e)}export{Yr as default};
|