define("discourse/plugins/discourse-presence/discourse/components/composer-presence-display",["exports","@ember/component","@ember/object/computed","@ember/service","discourse-common/utils/decorators","@ember/template-factory"],(function(e,s,r,n,t,i){"use strict"
var l,o,a,c,p,u,d,h,m,b
function y(e,s,r,n,t){var i={}
return Object.keys(n).forEach((function(e){i[e]=n[e]})),i.enumerable=!!i.enumerable,i.configurable=!!i.configurable,("value"in i||i.initializer)&&(i.writable=!0),i=r.slice().reverse().reduce((function(r,n){return n(e,s,r)||r}),i),t&&void 0!==i.initializer&&(i.value=i.initializer?i.initializer.call(t):void 0,i.initializer=void 0),void 0===i.initializer&&(Object.defineProperty(e,s,i),i=null),i}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const f=(0,i.createTemplateFactory)({id:"fKramLOc",block:'[[[41,[30,0,["shouldDisplay"]],[[[1,"  "],[10,0],[14,0,"presence-users"],[12],[1,"\\n    "],[10,0],[14,0,"presence-avatars"],[12],[1,"\\n"],[42,[28,[37,2],[[28,[37,2],[[30,0,["presenceUsers"]]],null]],null],null,[[[1,"        "],[1,[28,[35,3],[[30,1]],[["imageSize"],["small"]]]],[1,"\\n"]],[1]],null],[1,"    "],[13],[1,"\\n    "],[10,1],[14,0,"presence-text"],[12],[1,"\\n      "],[10,1],[14,0,"description"],[12],[41,[30,0,["isReply"]],[[[1,[28,[35,4],["presence.replying"],[["count"],[[30,0,["presenceUsers","length"]]]]]]],[]],[[[1,[28,[35,4],["presence.editing"],[["count"],[[30,0,["presenceUsers","length"]]]]]]],[]]],[13],[1,"\\n      "],[10,1],[14,0,"wave"],[12],[1,"\\n        "],[10,1],[14,0,"dot"],[12],[1,"."],[13],[1,"\\n        "],[10,1],[14,0,"dot"],[12],[1,"."],[13],[1,"\\n        "],[10,1],[14,0,"dot"],[12],[1,"."],[13],[1,"\\n      "],[13],[1,"\\n    "],[13],[1,"\\n  "],[13],[1,"\\n"]],[]],null]],["user"],false,["if","each","-track-array","avatar","i18n"]]',moduleName:"discourse/plugins/discourse-presence/discourse/components/composer-presence-display.hbs",isStrictMode:!1})
e.default=(0,s.setComponentTemplate)(f,s.default.extend((l=(0,t.default)("model.replyingToTopic","model.editingPost","model.whisper","model.composerOpened"),o=(0,t.default)("model.topic.id","isReply","isWhisper"),a=(0,t.default)("model.topic.id","isReply","isWhisper"),c=(0,t.default)("isEdit","model.post.id"),p=(0,t.observes)("replyChannelName","whisperChannelName","editChannelName"),u=(0,t.default)("isReply","replyingUsers.[]","editingUsers.[]"),d=(0,t.on)("didInsertElement"),h=(0,t.observes)("model.reply","state","model.post.id","model.topic.id"),m=(0,t.on)("willDestroyElement"),y(b={tagName:"",presence:(0,n.inject)(),composerPresenceManager:(0,n.inject)(),state(e,s,r,n){if(n)return s?"edit":r?"whisper":e?"reply":void 0},isReply:(0,r.equal)("state","reply"),isEdit:(0,r.equal)("state","edit"),isWhisper:(0,r.equal)("state","whisper"),replyChannelName(e,s,r){if(e&&(s||r))return`/discourse-presence/reply/${e}`},whisperChannelName(e,s,r){if(e&&this.currentUser.whisperer&&(s||r))return`/discourse-presence/whisper/${e}`},editChannelName(e,s){if(e)return`/discourse-presence/edit/${s}`},_setupChannel(e,s){this[e]?.name!==s&&(this[e]?.unsubscribe(),s?(this.set(e,this.presence.getChannel(s)),this[e].subscribe()):this[e]&&this.set(e,null))},_setupChannels(){this._setupChannel("replyChannel",this.replyChannelName),this._setupChannel("whisperChannel",this.whisperChannelName),this._setupChannel("editChannel",this.editChannelName)},_cleanupChannels(){this._setupChannel("replyChannel",null),this._setupChannel("whisperChannel",null),this._setupChannel("editChannel",null)},replyingUsers:(0,r.union)("replyChannel.users","whisperChannel.users"),editingUsers:(0,r.readOnly)("editChannel.users"),presenceUsers(e,s,r){const n=e?s:r
return n?.filter((e=>e.id!==this.currentUser.id))?.slice(0,this.siteSettings.presence_max_users_shown)},shouldDisplay:(0,r.gt)("presenceUsers.length",0),subscribe(){this._setupChannels()},_contentChanged(){if(""===this.model.reply)return
const e="edit"===this.state?this.model?.post:this.model?.topic
this.composerPresenceManager.notifyState(this.state,e?.id)},closeComposer(){this._cleanupChannels(),this.composerPresenceManager.leave()}},"state",[l],Object.getOwnPropertyDescriptor(b,"state"),b),y(b,"replyChannelName",[o],Object.getOwnPropertyDescriptor(b,"replyChannelName"),b),y(b,"whisperChannelName",[a],Object.getOwnPropertyDescriptor(b,"whisperChannelName"),b),y(b,"editChannelName",[c],Object.getOwnPropertyDescriptor(b,"editChannelName"),b),y(b,"_setupChannels",[p],Object.getOwnPropertyDescriptor(b,"_setupChannels"),b),y(b,"presenceUsers",[u],Object.getOwnPropertyDescriptor(b,"presenceUsers"),b),y(b,"subscribe",[d],Object.getOwnPropertyDescriptor(b,"subscribe"),b),y(b,"_contentChanged",[h],Object.getOwnPropertyDescriptor(b,"_contentChanged"),b),y(b,"closeComposer",[m],Object.getOwnPropertyDescriptor(b,"closeComposer"),b),b)))})),define("discourse/plugins/discourse-presence/discourse/components/topic-presence-display",["exports","@ember/component","@ember/object/computed","@ember/service","discourse-common/utils/decorators","@ember/template-factory"],(function(e,s,r,n,t,i){"use strict"
var l,o,a,c,p,u
function d(e,s,r,n,t){var i={}
return Object.keys(n).forEach((function(e){i[e]=n[e]})),i.enumerable=!!i.enumerable,i.configurable=!!i.configurable,("value"in i||i.initializer)&&(i.writable=!0),i=r.slice().reverse().reduce((function(r,n){return n(e,s,r)||r}),i),t&&void 0!==i.initializer&&(i.value=i.initializer?i.initializer.call(t):void 0,i.initializer=void 0),void 0===i.initializer&&(Object.defineProperty(e,s,i),i=null),i}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
const h=(0,i.createTemplateFactory)({id:"4V683/rb",block:'[[[41,[30,0,["shouldDisplay"]],[[[1,"  "],[10,0],[14,0,"presence-users"],[12],[1,"\\n    "],[10,0],[14,0,"presence-avatars"],[12],[1,"\\n"],[42,[28,[37,2],[[28,[37,2],[[30,0,["users"]]],null]],null],null,[[[1,"        "],[8,[39,3],null,[["@user"],[[30,1]]],[["default"],[[[[1,"\\n          "],[1,[28,[35,4],[[30,1]],[["imageSize"],["small"]]]],[1,"\\n        "]],[]]]]],[1,"\\n"]],[1]],null],[1,"    "],[13],[1,"\\n    "],[10,1],[14,0,"presence-text"],[12],[1,"\\n      "],[10,1],[14,0,"description"],[12],[1,"\\n        "],[1,[28,[35,5],["presence.replying_to_topic"],[["count"],[[30,0,["users","length"]]]]]],[1,"\\n      "],[13],[1,"\\n      "],[10,1],[14,0,"wave"],[12],[1,"\\n        "],[10,1],[14,0,"dot"],[12],[1,"."],[13],[1,"\\n        "],[10,1],[14,0,"dot"],[12],[1,"."],[13],[1,"\\n        "],[10,1],[14,0,"dot"],[12],[1,"."],[13],[1,"\\n      "],[13],[1,"\\n    "],[13],[1,"\\n  "],[13],[1,"\\n"]],[]],null]],["user"],false,["if","each","-track-array","user-link","avatar","i18n"]]',moduleName:"discourse/plugins/discourse-presence/discourse/components/topic-presence-display.hbs",isStrictMode:!1})
e.default=(0,s.setComponentTemplate)(h,s.default.extend((l=(0,t.default)("replyChannel.users.[]"),o=(0,t.default)("whisperChannel.users.[]"),a=(0,t.default)("topic.id"),c=(0,t.default)("topic.id"),p=(0,t.on)("willDestroyElement"),u={topic:null,presence:(0,n.inject)(),replyChannel:null,whisperChannel:null,replyUsers(e){return e?.filter((e=>e.id!==this.currentUser.id))},whisperUsers(e){return e?.filter((e=>e.id!==this.currentUser.id))},users:(0,r.union)("replyUsers","whisperUsers"),replyChannelName:e=>`/discourse-presence/reply/${e}`,whisperChannelName:e=>`/discourse-presence/whisper/${e}`,shouldDisplay:(0,r.gt)("users.length",0),didReceiveAttrs(){this._super(...arguments),this.replyChannel?.name!==this.replyChannelName&&(this.replyChannel?.unsubscribe(),this.set("replyChannel",this.presence.getChannel(this.replyChannelName)),this.replyChannel.subscribe()),this.currentUser.staff&&this.whisperChannel?.name!==this.whisperChannelName&&(this.whisperChannel?.unsubscribe(),this.set("whisperChannel",this.presence.getChannel(this.whisperChannelName)),this.whisperChannel.subscribe())},_destroyed(){this.replyChannel?.unsubscribe(),this.whisperChannel?.unsubscribe()}},d(u,"replyUsers",[l],Object.getOwnPropertyDescriptor(u,"replyUsers"),u),d(u,"whisperUsers",[o],Object.getOwnPropertyDescriptor(u,"whisperUsers"),u),d(u,"replyChannelName",[a],Object.getOwnPropertyDescriptor(u,"replyChannelName"),u),d(u,"whisperChannelName",[c],Object.getOwnPropertyDescriptor(u,"whisperChannelName"),u),d(u,"_destroyed",[p],Object.getOwnPropertyDescriptor(u,"_destroyed"),u),u)))})),define("discourse/plugins/discourse-presence/discourse/services/composer-presence-manager",["exports","@ember/runloop","@ember/service","discourse-common/config/environment"],(function(e,s,r,n){"use strict"
var t,i
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(t=class extends r.default{constructor(){var e,s,r,n
super(...arguments),e=this,s="presence",n=this,(r=i)&&Object.defineProperty(e,s,{enumerable:r.enumerable,configurable:r.configurable,writable:r.writable,value:r.initializer?r.initializer.call(n):void 0})}notifyState(e,r){if(this.siteSettings.allow_users_to_hide_profile&&this.currentUser.user_option.hide_profile_and_presence)return
if(void 0===e)return this.leave()
if(!["reply","whisper","edit"].includes(e))throw`Unknown intent ${e}`
const t=`${e}/${r}`
this._state!==t&&(this._enter(e,r),this._state=t),(0,n.isTesting)()||(this._autoLeaveTimer=(0,s.debounce)(this,this.leave,1e4))}leave(){this._presentChannel?.leave(),this._presentChannel=null,this._state=null,this._autoLeaveTimer&&((0,s.cancel)(this._autoLeaveTimer),this._autoLeaveTimer=null)}_enter(e,s){this.leave()
let r=`/discourse-presence/${e}/${s}`
this._presentChannel=this.presence.getChannel(r),this._presentChannel.enter()}willDestroy(){this.leave()}},l=t.prototype,o="presence",a=[r.inject],c={configurable:!0,enumerable:!0,writable:!0,initializer:null},u={},Object.keys(c).forEach((function(e){u[e]=c[e]})),u.enumerable=!!u.enumerable,u.configurable=!!u.configurable,("value"in u||u.initializer)&&(u.writable=!0),u=a.slice().reverse().reduce((function(e,s){return s(l,o,e)||e}),u),p&&void 0!==u.initializer&&(u.value=u.initializer?u.initializer.call(p):void 0,u.initializer=void 0),void 0===u.initializer&&(Object.defineProperty(l,o,u),u=null),i=u,t)
var l,o,a,c,p,u})),define("discourse/plugins/discourse-presence/discourse/templates/connectors/before-composer-controls/presence",["exports","@ember/template-factory"],(function(e,s){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,s.createTemplateFactory)({id:"G/OxL/Vj",block:'[[[8,[39,0],null,[["@model"],[[30,0,["model"]]]],null]],[],false,["composer-presence-display"]]',moduleName:"discourse/plugins/discourse-presence/discourse/templates/connectors/before-composer-controls/presence.hbs",isStrictMode:!1})})),define("discourse/plugins/discourse-presence/discourse/templates/connectors/topic-above-footer-buttons/presence",["exports","@ember/template-factory"],(function(e,s){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,s.createTemplateFactory)({id:"CmudhbhK",block:'[[[8,[39,0],null,[["@topic"],[[30,0,["model"]]]],null]],[],false,["topic-presence-display"]]',moduleName:"discourse/plugins/discourse-presence/discourse/templates/connectors/topic-above-footer-buttons/presence.hbs",isStrictMode:!1})}))

//# sourceMappingURL=discourse-presence-e6e61f80036635f57d4b1319cf027210a0797d7c8af514273f941ad05d4366d0.map
//!

;
