/*! For license information please see converse.min.js.LICENSE.txt */ (()=>{var e,t,n,s,i={9494:(e,t,n)=>{"use strict";const s=n(7672),i=n(4817);e.exports={atob:s,btoa:i}},7672:e=>{"use strict";function t(e){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e);return t<0?void 0:t}e.exports=function(e){if((e=(e=`${e}`).replace(/[ \t\n\f\r]/g,"")).length%4==0&&(e=e.replace(/==?$/,"")),e.length%4==1||/[^+/0-9A-Za-z]/.test(e))return null;let n="",s=0,i=0;for(let r=0;r>16),n+=String.fromCharCode((65280&s)>>8),n+=String.fromCharCode(255&s),s=i=0);return 12===i?(s>>=4,n+=String.fromCharCode(s)):18===i&&(s>>=2,n+=String.fromCharCode((65280&s)>>8),n+=String.fromCharCode(255&s)),n}},4817:e=>{"use strict";function t(e){if(e>=0&&e<64)return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e]}e.exports=function(e){let n;for(e=`${e}`,n=0;n255)return null;let s="";for(n=0;n>2,i[1]=(3&e.charCodeAt(n))<<4,e.length>n+1&&(i[1]|=e.charCodeAt(n+1)>>4,i[2]=(15&e.charCodeAt(n+1))<<2),e.length>n+2&&(i[2]|=e.charCodeAt(n+2)>>6,i[3]=63&e.charCodeAt(n+2));for(let e=0;e{var s;!function(){"use strict";var i={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function r(e){return a(l(e),arguments)}function o(e,t){return r.apply(null,[e].concat(t||[]))}function a(e,t){var n,s,o,a,c,l,u,d,h,f=1,g=e.length,m="";for(s=0;s=0),a.type){case"b":n=parseInt(n,10).toString(2);break;case"c":n=String.fromCharCode(parseInt(n,10));break;case"d":case"i":n=parseInt(n,10);break;case"j":n=JSON.stringify(n,null,a.width?parseInt(a.width):0);break;case"e":n=a.precision?parseFloat(n).toExponential(a.precision):parseFloat(n).toExponential();break;case"f":n=a.precision?parseFloat(n).toFixed(a.precision):parseFloat(n);break;case"g":n=a.precision?String(Number(n.toPrecision(a.precision))):parseFloat(n);break;case"o":n=(parseInt(n,10)>>>0).toString(8);break;case"s":n=String(n),n=a.precision?n.substring(0,a.precision):n;break;case"t":n=String(!!n),n=a.precision?n.substring(0,a.precision):n;break;case"T":n=Object.prototype.toString.call(n).slice(8,-1).toLowerCase(),n=a.precision?n.substring(0,a.precision):n;break;case"u":n=parseInt(n,10)>>>0;break;case"v":n=n.valueOf(),n=a.precision?n.substring(0,a.precision):n;break;case"x":n=(parseInt(n,10)>>>0).toString(16);break;case"X":n=(parseInt(n,10)>>>0).toString(16).toUpperCase()}i.json.test(a.type)?m+=n:(!i.number.test(a.type)||d&&!a.sign?h="":(h=d?"+":"-",n=n.toString().replace(i.sign,"")),l=a.pad_char?"0"===a.pad_char?"0":a.pad_char.charAt(1):" ",u=a.width-(h+n).length,c=a.width&&u>0?l.repeat(u):"",m+=a.align?h+n+c:"0"===l?h+c+n:c+h+n)}return m}var c=Object.create(null);function l(e){if(c[e])return c[e];for(var t,n=e,s=[],r=0;n;){if(null!==(t=i.text.exec(n)))s.push(t[0]);else if(null!==(t=i.modulo.exec(n)))s.push("%");else{if(null===(t=i.placeholder.exec(n)))throw new SyntaxError("[sprintf] unexpected placeholder");if(t[2]){r|=1;var o=[],a=t[2],l=[];if(null===(l=i.key.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(o.push(l[1]);""!==(a=a.substring(l[0].length));)if(null!==(l=i.key_access.exec(a)))o.push(l[1]);else{if(null===(l=i.index_access.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");o.push(l[1])}t[2]=o}else r|=2;if(3===r)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");s.push({placeholder:t[0],param_no:t[1],keys:t[2],sign:t[3],pad_char:t[4],align:t[5],width:t[6],precision:t[7],type:t[8]})}n=n.substring(t[0].length)}return c[e]=s}t.sprintf=r,t.vsprintf=o,"undefined"!=typeof window&&(window.sprintf=r,window.vsprintf=o,void 0===(s=function(){return{sprintf:r,vsprintf:o}}.call(t,n,t,e))||(e.exports=s))}()},1059:function(e,t,n){var s,i;!function(r,o){"use strict";e.exports?e.exports=o():void 0===(i="function"==typeof(s=o)?s.call(t,n,t,e):s)||(e.exports=i)}(0,(function(e){"use strict";var t=e&&e.IPv6;return{best:function(e){var t,n,s=e.toLowerCase().split(":"),i=s.length,r=8;for(""===s[0]&&""===s[1]&&""===s[2]?(s.shift(),s.shift()):""===s[0]&&""===s[1]?s.shift():""===s[i-1]&&""===s[i-2]&&s.pop(),-1!==s[(i=s.length)-1].indexOf(".")&&(r=7),t=0;t1;a++)n.splice(0,1);s[o]=n.join("")}var c=-1,l=0,u=0,d=-1,h=!1;for(o=0;ol&&(c=d,l=u)):"0"===s[o]&&(h=!0,d=o,u=1);u>l&&(c=d,l=u),l>1&&s.splice(c,l,""),i=s.length;var f="";for(""===s[0]&&(f=":"),o=0;o=e.length-1)return!1;var s=e.lastIndexOf(".",t-1);if(s<=0||s>=t-1)return!1;var i=n.list[e.slice(t+1)];return!!i&&i.indexOf(" "+e.slice(s+1,t)+" ")>=0},is:function(e){var t=e.lastIndexOf(".");if(t<=0||t>=e.length-1)return!1;if(e.lastIndexOf(".",t-1)>=0)return!1;var s=n.list[e.slice(t+1)];return!!s&&s.indexOf(" "+e.slice(0,t)+" ")>=0},get:function(e){var t=e.lastIndexOf(".");if(t<=0||t>=e.length-1)return null;var s=e.lastIndexOf(".",t-1);if(s<=0||s>=t-1)return null;var i=n.list[e.slice(t+1)];return i?i.indexOf(" "+e.slice(s+1,t)+" ")<0?null:e.slice(s+1):null},noConflict:function(){return e.SecondLevelDomains===this&&(e.SecondLevelDomains=t),this}};return n}))},2369:function(e,t,n){var s,i,r;!function(o,a){"use strict";e.exports?e.exports=a(n(6635),n(1059),n(4463)):(i=[n(6635),n(1059),n(4463)],void 0===(r="function"==typeof(s=a)?s.apply(t,i):s)||(e.exports=r))}(0,(function(e,t,n,s){"use strict";var i=s&&s.URI;function r(e,t){var n=arguments.length>=1,s=arguments.length>=2;if(!(this instanceof r))return n?s?new r(e,t):new r(e):new r;if(void 0===e){if(n)throw new TypeError("undefined is not a valid argument for URI");e="undefined"!=typeof location?location.href+"":""}if(null===e&&n)throw new TypeError("null is not a valid argument for URI");return this.href(e),void 0!==t?this.absoluteTo(t):this}r.version="1.19.6";var o=r.prototype,a=Object.prototype.hasOwnProperty;function c(e){return e.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function l(e){return void 0===e?"Undefined":String(Object.prototype.toString.call(e)).slice(8,-1)}function u(e){return"Array"===l(e)}function d(e,t){var n,s,i={};if("RegExp"===l(t))i=null;else if(u(t))for(n=0,s=t.length;n]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi,r.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?«»“”„‘’]+$/,parens:/(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g},r.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},r.hostProtocols=["http","https"],r.invalid_hostname_characters=/[^a-zA-Z0-9\.\-:_]/,r.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src",audio:"src",video:"src"},r.getDomAttribute=function(e){if(e&&e.nodeName){var t=e.nodeName.toLowerCase();if("input"!==t||"image"===e.type)return r.domAttributes[t]}},r.encode=p,r.decode=decodeURIComponent,r.iso8859=function(){r.encode=escape,r.decode=unescape},r.unicode=function(){r.encode=p,r.decode=decodeURIComponent},r.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/gi,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/gi,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}},urnpath:{encode:{expression:/%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/gi,map:{"%21":"!","%24":"$","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"=","%40":"@"}},decode:{expression:/[\/\?#:]/g,map:{"/":"%2F","?":"%3F","#":"%23",":":"%3A"}}}},r.encodeQuery=function(e,t){var n=r.encode(e+"");return void 0===t&&(t=r.escapeQuerySpace),t?n.replace(/%20/g,"+"):n},r.decodeQuery=function(e,t){e+="",void 0===t&&(t=r.escapeQuerySpace);try{return r.decode(t?e.replace(/\+/g,"%20"):e)}catch(t){return e}};var v,b={encode:"encode",decode:"decode"},y=function(e,t){return function(n){try{return r[t](n+"").replace(r.characters[e][t].expression,(function(n){return r.characters[e][t].map[n]}))}catch(e){return n}}};for(v in b)r[v+"PathSegment"]=y("pathname",b[v]),r[v+"UrnPathSegment"]=y("urnpath",b[v]);var _=function(e,t,n){return function(s){var i;i=n?function(e){return r[t](r[n](e))}:r[t];for(var o=(s+"").split(e),a=0,c=o.length;a-1&&(t.fragment=e.substring(n+1)||null,e=e.substring(0,n)),(n=e.indexOf("?"))>-1&&(t.query=e.substring(n+1)||null,e=e.substring(0,n)),"//"===e.substring(0,2)?(t.protocol=null,e=e.substring(2),e=r.parseAuthority(e,t)):(n=e.indexOf(":"))>-1&&(t.protocol=e.substring(0,n)||null,t.protocol&&!t.protocol.match(r.protocol_expression)?t.protocol=void 0:"//"===e.substring(n+1,n+3).replace(/\\/g,"/")?(e=e.substring(n+3),e=r.parseAuthority(e,t)):(e=e.substring(n+1),t.urn=!0)),t.path=e,t},r.parseHost=function(e,t){e||(e="");var n,s,i=(e=e.replace(/\\/g,"/")).indexOf("/");if(-1===i&&(i=e.length),"["===e.charAt(0))n=e.indexOf("]"),t.hostname=e.substring(1,n)||null,t.port=e.substring(n+2,i)||null,"/"===t.port&&(t.port=null);else{var o=e.indexOf(":"),a=e.indexOf("/"),c=e.indexOf(":",o+1);-1!==c&&(-1===a||c-1?i:e.length-1);return o>-1&&(-1===i||o-1?f.slice(0,g)+f.slice(g).replace(o,""):f.replace(o,"")).length<=l[0].length||n.ignore&&n.ignore.test(f))){var v=t(f,u,h=u+f.length,e);void 0!==v?(v=String(v),e=e.slice(0,u)+v+e.slice(h),s.lastIndex=u+v.length):s.lastIndex=h}}return s.lastIndex=0,e},r.ensureValidHostname=function(t,n){var s=!!t,i=!1;if(!!n&&(i=h(r.hostProtocols,n)),i&&!s)throw new TypeError("Hostname cannot be empty, if protocol is "+n);if(t&&t.match(r.invalid_hostname_characters)){if(!e)throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-:_] and Punycode.js is not available');if(e.toASCII(t).match(r.invalid_hostname_characters))throw new TypeError('Hostname "'+t+'" contains characters other than [A-Z0-9.-:_]')}},r.ensureValidPort=function(e){if(e){var t=Number(e);if(!(/^[0-9]+$/.test(t)&&t>0&&t<65536))throw new TypeError('Port "'+e+'" is not a valid port')}},r.noConflict=function(e){if(e){var t={URI:this.noConflict()};return s.URITemplate&&"function"==typeof s.URITemplate.noConflict&&(t.URITemplate=s.URITemplate.noConflict()),s.IPv6&&"function"==typeof s.IPv6.noConflict&&(t.IPv6=s.IPv6.noConflict()),s.SecondLevelDomains&&"function"==typeof s.SecondLevelDomains.noConflict&&(t.SecondLevelDomains=s.SecondLevelDomains.noConflict()),t}return s.URI===this&&(s.URI=i),this},o.build=function(e){return!0===e?this._deferred_build=!0:(void 0===e||this._deferred_build)&&(this._string=r.build(this._parts),this._deferred_build=!1),this},o.clone=function(){return new r(this)},o.valueOf=o.toString=function(){return this.build(!1)._string},o.protocol=w("protocol"),o.username=w("username"),o.password=w("password"),o.hostname=w("hostname"),o.port=w("port"),o.query=S("query","?"),o.fragment=S("fragment","#"),o.search=function(e,t){var n=this.query(e,t);return"string"==typeof n&&n.length?"?"+n:n},o.hash=function(e,t){var n=this.fragment(e,t);return"string"==typeof n&&n.length?"#"+n:n},o.pathname=function(e,t){if(void 0===e||!0===e){var n=this._parts.path||(this._parts.hostname?"/":"");return e?(this._parts.urn?r.decodeUrnPath:r.decodePath)(n):n}return this._parts.urn?this._parts.path=e?r.recodeUrnPath(e):"":this._parts.path=e?r.recodePath(e):"/",this.build(!t),this},o.path=o.pathname,o.href=function(e,t){var n;if(void 0===e)return this.toString();this._string="",this._parts=r._parts();var s=e instanceof r,i="object"==typeof e&&(e.hostname||e.path||e.pathname);if(e.nodeName&&(e=e[r.getDomAttribute(e)]||"",i=!1),!s&&i&&void 0!==e.pathname&&(e=e.toString()),"string"==typeof e||e instanceof String)this._parts=r.parse(String(e),this._parts);else{if(!s&&!i)throw new TypeError("invalid input");var o=s?e._parts:e;for(n in o)"query"!==n&&a.call(this._parts,n)&&(this._parts[n]=o[n]);o.query&&this.query(o.query,!1)}return this.build(!t),this},o.is=function(e){var t=!1,s=!1,i=!1,o=!1,a=!1,c=!1,l=!1,u=!this._parts.urn;switch(this._parts.hostname&&(u=!1,s=r.ip4_expression.test(this._parts.hostname),i=r.ip6_expression.test(this._parts.hostname),a=(o=!(t=s||i))&&n&&n.has(this._parts.hostname),c=o&&r.idn_expression.test(this._parts.hostname),l=o&&r.punycode_expression.test(this._parts.hostname)),e.toLowerCase()){case"relative":return u;case"absolute":return!u;case"domain":case"name":return o;case"sld":return a;case"ip":return t;case"ip4":case"ipv4":case"inet4":return s;case"ip6":case"ipv6":case"inet6":return i;case"idn":return c;case"url":return!this._parts.urn;case"urn":return!!this._parts.urn;case"punycode":return l}return null};var x=o.protocol,E=o.port,j=o.hostname;o.protocol=function(e,t){if(e&&!(e=e.replace(/:(\/\/)?$/,"")).match(r.protocol_expression))throw new TypeError('Protocol "'+e+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return x.call(this,e,t)},o.scheme=o.protocol,o.port=function(e,t){return this._parts.urn?void 0===e?"":this:(void 0!==e&&(0===e&&(e=null),e&&(":"===(e+="").charAt(0)&&(e=e.substring(1)),r.ensureValidPort(e))),E.call(this,e,t))},o.hostname=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0!==e){var n={preventInvalidHostname:this._parts.preventInvalidHostname};if("/"!==r.parseHost(e,n))throw new TypeError('Hostname "'+e+'" contains characters other than [A-Z0-9.-]');e=n.hostname,this._parts.preventInvalidHostname&&r.ensureValidHostname(e,this._parts.protocol)}return j.call(this,e,t)},o.origin=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e){var n=this.protocol();return this.authority()?(n?n+"://":"")+this.authority():""}var s=r(e);return this.protocol(s.protocol()).authority(s.authority()).build(!t),this},o.host=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e)return this._parts.hostname?r.buildHost(this._parts):"";if("/"!==r.parseHost(e,this._parts))throw new TypeError('Hostname "'+e+'" contains characters other than [A-Z0-9.-]');return this.build(!t),this},o.authority=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e)return this._parts.hostname?r.buildAuthority(this._parts):"";if("/"!==r.parseAuthority(e,this._parts))throw new TypeError('Hostname "'+e+'" contains characters other than [A-Z0-9.-]');return this.build(!t),this},o.userinfo=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e){var n=r.buildUserinfo(this._parts);return n?n.substring(0,n.length-1):n}return"@"!==e[e.length-1]&&(e+="@"),r.parseUserinfo(e,this._parts),this.build(!t),this},o.resource=function(e,t){var n;return void 0===e?this.path()+this.search()+this.hash():(n=r.parse(e),this._parts.path=n.path,this._parts.query=n.query,this._parts.fragment=n.fragment,this.build(!t),this)},o.subdomain=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e){if(!this._parts.hostname||this.is("IP"))return"";var n=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,n)||""}var s=this._parts.hostname.length-this.domain().length,i=this._parts.hostname.substring(0,s),o=new RegExp("^"+c(i));if(e&&"."!==e.charAt(e.length-1)&&(e+="."),-1!==e.indexOf(":"))throw new TypeError("Domains cannot contain colons");return e&&r.ensureValidHostname(e,this._parts.protocol),this._parts.hostname=this._parts.hostname.replace(o,e),this.build(!t),this},o.domain=function(e,t){if(this._parts.urn)return void 0===e?"":this;if("boolean"==typeof e&&(t=e,e=void 0),void 0===e){if(!this._parts.hostname||this.is("IP"))return"";var n=this._parts.hostname.match(/\./g);if(n&&n.length<2)return this._parts.hostname;var s=this._parts.hostname.length-this.tld(t).length-1;return s=this._parts.hostname.lastIndexOf(".",s-1)+1,this._parts.hostname.substring(s)||""}if(!e)throw new TypeError("cannot set domain empty");if(-1!==e.indexOf(":"))throw new TypeError("Domains cannot contain colons");if(r.ensureValidHostname(e,this._parts.protocol),!this._parts.hostname||this.is("IP"))this._parts.hostname=e;else{var i=new RegExp(c(this.domain())+"$");this._parts.hostname=this._parts.hostname.replace(i,e)}return this.build(!t),this},o.tld=function(e,t){if(this._parts.urn)return void 0===e?"":this;if("boolean"==typeof e&&(t=e,e=void 0),void 0===e){if(!this._parts.hostname||this.is("IP"))return"";var s=this._parts.hostname.lastIndexOf("."),i=this._parts.hostname.substring(s+1);return!0!==t&&n&&n.list[i.toLowerCase()]&&n.get(this._parts.hostname)||i}var r;if(!e)throw new TypeError("cannot set TLD empty");if(e.match(/[^a-zA-Z0-9-]/)){if(!n||!n.is(e))throw new TypeError('TLD "'+e+'" contains characters other than [A-Z0-9]');r=new RegExp(c(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(r,e)}else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");r=new RegExp(c(this.tld())+"$"),this._parts.hostname=this._parts.hostname.replace(r,e)}return this.build(!t),this},o.directory=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e||!0===e){if(!this._parts.path&&!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var n=this._parts.path.length-this.filename().length-1,s=this._parts.path.substring(0,n)||(this._parts.hostname?"/":"");return e?r.decodePath(s):s}var i=this._parts.path.length-this.filename().length,o=this._parts.path.substring(0,i),a=new RegExp("^"+c(o));return this.is("relative")||(e||(e="/"),"/"!==e.charAt(0)&&(e="/"+e)),e&&"/"!==e.charAt(e.length-1)&&(e+="/"),e=r.recodePath(e),this._parts.path=this._parts.path.replace(a,e),this.build(!t),this},o.filename=function(e,t){if(this._parts.urn)return void 0===e?"":this;if("string"!=typeof e){if(!this._parts.path||"/"===this._parts.path)return"";var n=this._parts.path.lastIndexOf("/"),s=this._parts.path.substring(n+1);return e?r.decodePathSegment(s):s}var i=!1;"/"===e.charAt(0)&&(e=e.substring(1)),e.match(/\.?\//)&&(i=!0);var o=new RegExp(c(this.filename())+"$");return e=r.recodePath(e),this._parts.path=this._parts.path.replace(o,e),i?this.normalizePath(t):this.build(!t),this},o.suffix=function(e,t){if(this._parts.urn)return void 0===e?"":this;if(void 0===e||!0===e){if(!this._parts.path||"/"===this._parts.path)return"";var n,s,i=this.filename(),o=i.lastIndexOf(".");return-1===o?"":(n=i.substring(o+1),s=/^[a-z0-9%]+$/i.test(n)?n:"",e?r.decodePathSegment(s):s)}"."===e.charAt(0)&&(e=e.substring(1));var a,l=this.suffix();if(l)a=e?new RegExp(c(l)+"$"):new RegExp(c("."+l)+"$");else{if(!e)return this;this._parts.path+="."+r.recodePath(e)}return a&&(e=r.recodePath(e),this._parts.path=this._parts.path.replace(a,e)),this.build(!t),this},o.segment=function(e,t,n){var s=this._parts.urn?":":"/",i=this.path(),r="/"===i.substring(0,1),o=i.split(s);if(void 0!==e&&"number"!=typeof e&&(n=t,t=e,e=void 0),void 0!==e&&"number"!=typeof e)throw new Error('Bad segment "'+e+'", must be 0-based integer');if(r&&o.shift(),e<0&&(e=Math.max(o.length+e,0)),void 0===t)return void 0===e?o:o[e];if(null===e||void 0===o[e])if(u(t)){o=[];for(var a=0,c=t.length;a= 0x80 (not a basic code point)","invalid-input":"Invalid input"},f=Math.floor,g=String.fromCharCode;function m(e){throw new RangeError(h[e])}function p(e,t){for(var n=e.length,s=[];n--;)s[n]=t(e[n]);return s}function v(e,t){var n=e.split("@"),s="";return n.length>1&&(s=n[0]+"@",e=n[1]),s+p((e=e.replace(d,".")).split("."),t).join(".")}function b(e){for(var t,n,s=[],i=0,r=e.length;i=55296&&t<=56319&&i65535&&(t+=g((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+g(e)})).join("")}function _(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function w(e,t,n){var s=0;for(e=n?f(e/700):e>>1,e+=f(e/t);e>455;s+=c)e=f(e/35);return f(s+36*e/(e+38))}function S(e){var t,n,s,i,r,o,l,u,d,h,g,p=[],v=e.length,b=0,_=128,S=72;for((n=e.lastIndexOf("-"))<0&&(n=0),s=0;s=128&&m("not-basic"),p.push(e.charCodeAt(s));for(i=n>0?n+1:0;i=v&&m("invalid-input"),((u=(g=e.charCodeAt(i++))-48<10?g-22:g-65<26?g-65:g-97<26?g-97:c)>=c||u>f((a-b)/o))&&m("overflow"),b+=u*o,!(u<(d=l<=S?1:l>=S+26?26:l-S));l+=c)o>f(a/(h=c-d))&&m("overflow"),o*=h;S=w(b-r,t=p.length+1,0==r),f(b/t)>a-_&&m("overflow"),_+=f(b/t),b%=t,p.splice(b++,0,_)}return y(p)}function x(e){var t,n,s,i,r,o,l,u,d,h,p,v,y,S,x,E=[];for(v=(e=b(e)).length,t=128,n=0,r=72,o=0;o=t&&pf((a-n)/(y=s+1))&&m("overflow"),n+=(l-t)*y,t=l,o=0;oa&&m("overflow"),p==t){for(u=n,d=c;!(u<(h=d<=r?1:d>=r+26?26:d-r));d+=c)x=u-h,S=c-h,E.push(g(_(h+x%S,0))),u=f(x/S);E.push(g(_(u,0))),r=w(n,y,s==i),n=0,++s}++n,++t}return E.join("")}o={version:"1.3.2",ucs2:{decode:b,encode:y},decode:S,encode:x,toASCII:function(e){return v(e,(function(e){return u.test(e)?"xn--"+x(e):e}))},toUnicode:function(e){return v(e,(function(e){return l.test(e)?S(e.slice(4).toLowerCase()):e}))}},void 0===(s=function(){return o}.call(t,n,t,e))||(e.exports=s)}()},9598:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>oC});const s=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},i=function(e,t){return e===t||e!=e&&t!=t},r=function(e,t){for(var n=e.length;n--;)if(i(e[n][0],t))return n;return-1};var o=Array.prototype.splice;function a(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t-1},a.prototype.set=function(e,t){var n=this.__data__,s=r(n,e);return s<0?(++this.size,n.push([e,t])):n[s][1]=t,this};const c=a,l="object"==typeof global&&global&&global.Object===Object&&global;var u="object"==typeof self&&self&&self.Object===Object&&self;const d=l||u||Function("return this")(),h=d.Symbol;var f=Object.prototype,g=f.hasOwnProperty,m=f.toString,p=h?h.toStringTag:void 0;var v=Object.prototype.toString;var b=h?h.toStringTag:void 0;const y=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":b&&b in Object(e)?function(e){var t=g.call(e,p),n=e[p];try{e[p]=void 0;var s=!0}catch(e){}var i=m.call(e);return s&&(t?e[p]=n:delete e[p]),i}(e):function(e){return v.call(e)}(e)},_=function(e){if(!s(e))return!1;var t=y(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},w=d["__core-js_shared__"];var S,x=(S=/[^.]+$/.exec(w&&w.keys&&w.keys.IE_PROTO||""))?"Symbol(src)_1."+S:"";var E=Function.prototype.toString;const j=function(e){if(null!=e){try{return E.call(e)}catch(e){}try{return e+""}catch(e){}}return""};var A=/^\[object .+?Constructor\]$/,C=Function.prototype,k=Object.prototype,O=C.toString,T=k.hasOwnProperty,N=RegExp("^"+O.call(T).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const I=function(e){return!(!s(e)||(t=e,x&&x in t))&&(_(e)?N:A).test(j(e));var t},M=function(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return I(n)?n:void 0},R=M(d,"Map"),D=M(Object,"create");var z=Object.prototype.hasOwnProperty;var L=Object.prototype.hasOwnProperty;function P(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t-1&&e%1==0&&e<=9007199254740991},ye=function(e){return null!=e&&be(e.length)&&!_(e)},_e=function(e){return de(e)&&ye(e)};var we="object"==typeof exports&&exports&&!exports.nodeType&&exports,Se=we&&"object"==typeof module&&module&&!module.nodeType&&module,xe=Se&&Se.exports===we?d.Buffer:void 0;const Ee=(xe?xe.isBuffer:void 0)||function(){return!1};var je=Function.prototype,Ae=Object.prototype,Ce=je.toString,ke=Ae.hasOwnProperty,Oe=Ce.call(Object);const Te=function(e){if(!de(e)||"[object Object]"!=y(e))return!1;var t=ae(e);if(null===t)return!0;var n=ke.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Ce.call(n)==Oe};var Ne={};Ne["[object Float32Array]"]=Ne["[object Float64Array]"]=Ne["[object Int8Array]"]=Ne["[object Int16Array]"]=Ne["[object Int32Array]"]=Ne["[object Uint8Array]"]=Ne["[object Uint8ClampedArray]"]=Ne["[object Uint16Array]"]=Ne["[object Uint32Array]"]=!0,Ne["[object Arguments]"]=Ne["[object Array]"]=Ne["[object ArrayBuffer]"]=Ne["[object Boolean]"]=Ne["[object DataView]"]=Ne["[object Date]"]=Ne["[object Error]"]=Ne["[object Function]"]=Ne["[object Map]"]=Ne["[object Number]"]=Ne["[object Object]"]=Ne["[object RegExp]"]=Ne["[object Set]"]=Ne["[object String]"]=Ne["[object WeakMap]"]=!1;const Ie=function(e){return function(t){return e(t)}};var Me="object"==typeof exports&&exports&&!exports.nodeType&&exports,Re=Me&&"object"==typeof module&&module&&!module.nodeType&&module,De=Re&&Re.exports===Me&&l.process;const ze=function(){try{return Re&&Re.require&&Re.require("util").types||De&&De.binding&&De.binding("util")}catch(e){}}();var Le=ze&&ze.isTypedArray;const Pe=Le?Ie(Le):function(e){return de(e)&&be(e.length)&&!!Ne[y(e)]},Fe=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]};var Be=Object.prototype.hasOwnProperty;const Ue=function(e,t,n){var s=e[t];Be.call(e,t)&&i(s,n)&&(void 0!==n||t in e)||V(e,t,n)},qe=function(e,t,n,s){var i=!n;n||(n={});for(var r=-1,o=t.length;++r-1&&e%1==0&&e0){if(++at>=800)return arguments[0]}else at=0;return ot.apply(void 0,arguments)});var ot,at,ct;const lt=function(e,t){return rt(tt(e,t,Xe),e+"")},ut=function(e,t,n){if(!s(n))return!1;var r=typeof t;return!!("number"==r?ye(n)&&$e(t,n.length):"string"==r&&t in n)&&i(n[t],e)},dt=function(e){return lt((function(t,n){var s=-1,i=n.length,r=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(r=e.length>3&&"function"==typeof r?(i--,r):void 0,o&&ut(n[0],n[1],o)&&(r=i<3?void 0:r,i=1),t=Object(t);++s{e.resolve=t,e.reject=n}));return Object.assign(t,e),t.then((function(e){return t.isResolved=!0,t.isPending=!1,t.isRejected=!1,e}),(function(e){throw t.isResolved=!1,t.isPending=!1,t.isRejected=!0,e})),t}const jt=Math.max,At=Math.min,Ct=function(e,t,n={}){let i,r,o,a,c,l=[],u=0,d=!1,h=n.promise?Et():null;if("function"!=typeof e)throw new TypeError("Expected a function");function f(t){const s=l,r=i;return l=[],i=void 0,u=t,o=e.apply(r,s),n.promise&&(h.resolve(o),h=Et()),n.promise?h:o}function g(e){return u=e,a=setTimeout(p,t),n.promise?h:o}function m(e){const n=e-c;return void 0===c||n>=t||n<0||d&&e-u>=r}function p(){const e=gt();if(m(e))return v(e);a=setTimeout(p,function(e){const n=t-(e-c);return d?At(n,r-(e-u)):n}(e))}function v(e){return a=void 0,l?f(e):(l=[],i=void 0,n.promise?h:o)}function b(e,t){if(Array.isArray(e)&&Array.isArray(t))return e.concat(t)}function y(e){return l.length?e.length?(null==n?void 0:n.concatArrays)?ft(l,e,b):ht(l,e):l:e.length?e:[]}function _(){const e=gt(),s=m(e);if(l=y(Array.from(arguments)),i=this,c=e,s){if(void 0===a)return g(c);if(d)return clearTimeout(a),a=setTimeout(p,t),f(c)}return void 0===a&&(a=setTimeout(p,t)),n.promise?h:o}return t=xt(t)||0,s(n)&&(d="maxWait"in n,r=d?jt(xt(n.maxWait)||0,t):r),_.cancel=function(){void 0!==a&&clearTimeout(a),u=0,l=[],c=i=a=void 0},_.flush=function(){return void 0===a?o:v(gt())},_};var kt=n(9483),Ot=n(3245);const Tt=oe(Object.keys,Object);var Nt=Object.prototype.hasOwnProperty;const It=function(e){if(!le(e))return Tt(e);var t=[];for(var n in Object(e))Nt.call(e,n)&&"constructor"!=n&&t.push(n);return t},Mt=function(e){return ye(e)?Ve(e):It(e)},Rt=function(e,t){return e&&qe(t,Mt(t),e)},Dt=function(){return[]};var zt=Object.prototype.propertyIsEnumerable,Lt=Object.getOwnPropertySymbols;const Pt=Lt?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,s=null==e?0:e.length,i=0,r=[];++n>4,u[c++]=(15&s)<<4|i>>2,u[c++]=(3&i)<<6|63&r;return l}function qn(e){var t,n=new Uint8Array(e),s="";for(t=0;t>2],s+=En[(3&n[t])<<4|n[t+1]>>4],s+=En[(15&n[t+1])<<2|n[t+2]>>6],s+=En[63&n[t+2]];return n.length%3==2?s=s.substring(0,s.length-1)+"=":n.length%3==1&&(s=s.substring(0,s.length-2)+"=="),s}var Hn={serialize:function(e,t){var n="";if(e&&(n=Bn.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===Bn.call(e.buffer))){var s,i=An;e instanceof ArrayBuffer?(s=e,i+=kn):(s=e.buffer,"[object Int8Array]"===n?i+=Tn:"[object Uint8Array]"===n?i+=Nn:"[object Uint8ClampedArray]"===n?i+=In:"[object Int16Array]"===n?i+=Mn:"[object Uint16Array]"===n?i+=Dn:"[object Int32Array]"===n?i+=Rn:"[object Uint32Array]"===n?i+=zn:"[object Float32Array]"===n?i+=Ln:"[object Float64Array]"===n?i+=Pn:t(new Error("Failed to get type for BinaryArray"))),t(i+qn(s))}else if("[object Blob]"===n){var r=new FileReader;r.onload=function(){var n="~~local_forage_type~"+e.type+"~"+qn(this.result);t("__lfsc__:blob"+n)},r.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}},deserialize:function(e){if(e.substring(0,Cn)!==An)return JSON.parse(e);var t,n=e.substring(Fn),s=e.substring(Cn,Fn);if(s===On&&jn.test(n)){var i=n.match(jn);t=i[1],n=n.substring(i[0].length)}var r=Un(n);switch(s){case kn:return r;case On:return function(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(i){if("TypeError"!==i.name)throw i;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),s=0;s=0;t--){const n=sessionStorage.key(t);0===n.indexOf(e)&&sessionStorage.removeItem(n)}}));return wn(t,e),t},length:function(e){const t=this.keys().then((function(e){return e.length}));return wn(t,e),t},key:function(e,t){const n=this.ready().then((function(){let t;try{t=sessionStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(Gn.keyPrefix.length)),t}));return wn(n,t),n},keys:function(e){const t=this.ready().then((function(){const e=sessionStorage.length,t=[];for(let n=0;n=0;t--){const n=sessionStorage.key(t);0===n.indexOf(e)&&sessionStorage.removeItem(n)}})):Promise.reject(new Error("Invalid arguments")),wn(s,t),s}};var Wn=n(1459);const Jn=Ot._driver;function Qn(){return(65536*(1+Math.random())|0).toString(16).substring(1)}kt.defineDriver(Ot),(0,Wn.extendPrototype)(kt);class Yn{constructor(e,t,n=!1){if("local"===t&&!window.localStorage)throw new Error("Skeletor.storage: Environment does not support localStorage.");if("session"===t&&!window.sessionStorage)throw new Error("Skeletor.storage: Environment does not support sessionStorage.");_n(t)?this.storeInitialized=this.initStore(t,n):(this.store=t,n&&(this.store.debouncedSetItems=Ct((e=>this.store.setItems(e)),50,{promise:!0})),this.storeInitialized=Promise.resolve()),this.name=e}async initStore(e,t){if("session"===e)kt.setDriver(Vn._driver);else if("local"===e)await kt.config({driver:kt.LOCALSTORAGE});else if("in_memory"===e)kt.config({driver:Jn});else if("indexed"!==e)throw new Error("Skeletor.storage: No storage type was specified");this.store=kt,t&&(this.store.debouncedSetItems=Ct((e=>this.store.setItems(e)),50,{promise:!0}))}flush(){var e;return null===(e=this.store.debouncedSetItems)||void 0===e?void 0:e.flush()}async clear(){await this.store.removeItem(this.name).catch((e=>console.error(e)));const e=new RegExp("^".concat(this.name,"-")),t=(await this.store.keys()).filter((t=>e.test(t)));await Promise.all(t.map((e=>this.store.removeItem(e).catch((e=>console.error(e))))))}sync(e){const t=this;async function n(e,n,s){let i,r,o,a;const c=n.collection;var l;["patch","update"].includes(e)&&(l=n.attributes,a=yn(l,5)),await t.storeInitialized;try{const r=n.attributes;switch(e){case"read":i=void 0!==n.id?await t.find(n):await t.findAll();break;case"create":i=await t.create(n,s);break;case"patch":case"update":s.wait&&(n.attributes=a),o=t.update(n,s),s.wait&&(n.attributes=r),i=await o;break;case"delete":i=await t.destroy(n,c)}}catch(e){r=22===e.code&&0===t.getStorageSize()?"Private browsing is unsupported":e.message}if(i){if(s&&s.success){const t="read"===e?i:null;s.success(t,s)}}else r=r||"Record Not Found",s&&s.error&&s.error(r)}return n.__name__="localSync",n}removeCollectionReference(e,t){if(!t)return;const n=t.filter((t=>t.id!==e.id)).map((e=>this.getItemName(e.id)));return this.store.setItem(this.name,n)}addCollectionReference(e,t){if(!t)return;const n=t.map((e=>this.getItemName(e.id))),s=this.getItemName(e.id);return n.includes(s)||n.push(s),this.store.setItem(this.name,n)}getCollectionReferenceData(e){if(!e.collection)return{};const t=e.collection.map((e=>this.getItemName(e.id))),n=this.getItemName(e.id);t.includes(n)||t.push(n);const s={};return s[this.name]=t,s}async save(e){if(this.store.setItems){const t={};return t[this.getItemName(e.id)]=e.toJSON(),Object.assign(t,this.getCollectionReferenceData(e)),this.store.debouncedSetItems?this.store.debouncedSetItems(t):this.store.setItems(t)}{const t=this.getItemName(e.id),n=await this.store.setItem(t,e.toJSON());return await this.addCollectionReference(e,e.collection),n}}create(e,t){return e.id||(e.id=Qn()+Qn()+"-"+Qn()+"-"+Qn()+"-"+Qn()+"-"+Qn()+Qn()+Qn(),e.set(e.idAttribute,e.id,t)),this.save(e)}update(e){return this.save(e)}find(e){return this.store.getItem(this.getItemName(e.id))}async findAll(){const e=await this.store.getItem(this.name);return e&&e.length?Promise.all(e.map((e=>this.store.getItem(e)))):[]}async destroy(e,t){return await this.flush(),await this.store.removeItem(this.getItemName(e.id)),await this.removeCollectionReference(e,t),e}getStorageSize(){return this.store.length}getItemName(e){return this.name+"-"+e}}Yn.sessionStorageInitialized=kt.defineDriver(Vn),Yn.localForage=kt;const Kn=Yn;var Xn=n(4457);const Zn={initialize(){},__:(...e)=>(0,Xn.sprintf)(...e)},es=function(e){return de(e)&&1===e.nodeType&&!Te(e)};var ts,ns,ss,is;const rs={debug:0,info:1,warn:2,error:3,fatal:4},os=Object.assign({debug:(null===(ts=console)||void 0===ts?void 0:ts.log)?console.log.bind(console):function(){},error:(null===(ns=console)||void 0===ns?void 0:ns.log)?console.log.bind(console):function(){},info:(null===(ss=console)||void 0===ss?void 0:ss.log)?console.log.bind(console):function(){},warn:(null===(is=console)||void 0===is?void 0:is.log)?console.log.bind(console):function(){}},console),as={setLogLevel(e){if(!["debug","info","warn","error","fatal"].includes(e))throw new Error("Invalid loglevel: ".concat(e));this.loglevel=e},log(e,t,n=""){if(rs[t]>16)+(t>>16)+(n>>16)<<16|65535&n},ds=function(e){if("string"!=typeof e)throw new Error("str2binl was passed a non-string");const t=[];for(let n=0;n<8*e.length;n+=8)t[n>>5]|=(255&e.charCodeAt(n/8))<>>32-a,n);var o,a},fs=function(e,t,n,s,i,r,o){return hs(t&n|~t&s,e,t,i,r,o)},gs=function(e,t,n,s,i,r,o){return hs(t&s|n&~s,e,t,i,r,o)},ms=function(e,t,n,s,i,r,o){return hs(t^n^s,e,t,i,r,o)},ps=function(e,t,n,s,i,r,o){return hs(n^(t|~s),e,t,i,r,o)},vs=function(e,t){e[t>>5]|=128<>>9<<4)]=t;let n,s,i,r,o=1732584193,a=-271733879,c=-1732584194,l=271733878;for(let t=0;t>2]>>s%4*8+4&15)+t.charAt(e[s>>2]>>s%4*8&15);return n}(vs(ds(e),8*e.length))},hash:function(e){return function(e){let t="";for(let n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>n%32&255);return t}(vs(ds(e),8*e.length))}};class ys{constructor(e,t,n){this.mechname=e,this.isClientFirst=t,this.priority=n}test(){return!0}onStart(e){this._connection=e}onChallenge(e,t){throw new Error("You should implement challenge handling!")}clientChallenge(e){if(!this.isClientFirst)throw new Error("clientChallenge should not be called if isClientFirst is false!");return this.onChallenge(e)}onFailure(){this._connection=null}onSuccess(){this._connection=null}}const _s=function(e){var t,n,s="",i=e.length;for(t=0;t=0&&n<=127?s+=e.charAt(t):n>2047?(s+=String.fromCharCode(224|n>>12&15),s+=String.fromCharCode(128|n>>6&63),s+=String.fromCharCode(128|n>>0&63)):(s+=String.fromCharCode(192|n>>6&31),s+=String.fromCharCode(128|n>>0&63));return s};function ws(e,t){e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;var n,s,i,r,o,a,c,l,u=new Array(80),d=1732584193,h=-271733879,f=-1732584194,g=271733878,m=-1009589776;for(n=0;n16&&(n=ws(n,8*e.length));for(var s=new Array(16),i=new Array(16),r=0;r<16;r++)s[r]=909522486^n[r],i[r]=1549556828^n[r];var o=ws(s.concat(Cs(t)),512+8*t.length);return ws(i.concat(o),672)}function js(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function As(e,t){return e<>>32-t}function Cs(e){for(var t=[],n=0;n<8*e.length;n+=8)t[n>>5]|=(255&e.charCodeAt(n/8))<<24-n%32;return t}function ks(e){for(var t,n,s="",i=0;i<4*e.length;i+=3)for(t=(e[i>>2]>>8*(3-i%4)&255)<<16|(e[i+1>>2]>>8*(3-(i+1)%4)&255)<<8|e[i+2>>2]>>8*(3-(i+2)%4)&255,n=0;n<4;n++)8*i+6*n>32*e.length?s+="=":s+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t>>6*(3-n)&63);return s}function Os(e){for(var t="",n=0;n<32*e.length;n+=8)t+=String.fromCharCode(e[n>>5]>>>24-n%32&255);return t}const Ts={b64_hmac_sha1:function(e,t){return ks(Es(e,t))},b64_sha1:function(e){return ks(ws(Cs(e),8*e.length))},binb2str:Os,core_hmac_sha1:Es,str_hmac_sha1:function(e,t){return Os(Es(e,t))},str_sha1:function(e){return Os(ws(Cs(e),8*e.length))}};var Ns=n(9494);function Is(e,t){return new zs.Builder(e,t)}function Ms(e){return new zs.Builder("message",e)}function Rs(e){return new zs.Builder("iq",e)}function Ds(e){return new zs.Builder("presence",e)}const zs={VERSION:"1.4.2",NS:{HTTPBIND:"http://jabber.org/protocol/httpbind",BOSH:"urn:xmpp:xbosh",CLIENT:"jabber:client",AUTH:"jabber:iq:auth",ROSTER:"jabber:iq:roster",PROFILE:"jabber:iq:profile",DISCO_INFO:"http://jabber.org/protocol/disco#info",DISCO_ITEMS:"http://jabber.org/protocol/disco#items",MUC:"http://jabber.org/protocol/muc",SASL:"urn:ietf:params:xml:ns:xmpp-sasl",STREAM:"http://etherx.jabber.org/streams",FRAMING:"urn:ietf:params:xml:ns:xmpp-framing",BIND:"urn:ietf:params:xml:ns:xmpp-bind",SESSION:"urn:ietf:params:xml:ns:xmpp-session",VERSION:"jabber:iq:version",STANZAS:"urn:ietf:params:xml:ns:xmpp-stanzas",XHTML_IM:"http://jabber.org/protocol/xhtml-im",XHTML:"http://www.w3.org/1999/xhtml"},XHTML:{tags:["a","blockquote","br","cite","em","img","li","ol","p","span","strong","ul","body"],attributes:{a:["href"],blockquote:["style"],br:[],cite:["style"],em:[],img:["src","alt","style","height","width"],li:["style"],ol:["style"],p:["style"],span:["style"],strong:[],ul:["style"],body:[]},css:["background-color","color","font-family","font-size","font-style","font-weight","margin-left","margin-right","text-align","text-decoration"],validTag(e){for(let t=0;t0)for(let n=0;ne.tagName===t,_xmlGenerator:null,xmlGenerator:()=>(zs._xmlGenerator||(zs._xmlGenerator=function(){if("undefined"==typeof document)try{return(new(0,n(647).DOMImplementation)).createDocument("jabber:client","strophe",null)}catch(e){throw new Error('You must install the "xmldom" package to use Strophe in nodejs.')}if(void 0===document.implementation.createDocument||document.implementation.createDocument&&document.documentMode&&document.documentMode<10){const e=function(){const e=["Msxml2.DOMDocument.6.0","Msxml2.DOMDocument.5.0","Msxml2.DOMDocument.4.0","MSXML2.DOMDocument.3.0","MSXML2.DOMDocument","MSXML.DOMDocument","Microsoft.XMLDOM"];for(let t=0;t(e=(e=(e=(e=e.replace(/\&/g,"&")).replace(//g,">")).replace(/'/g,"'")).replace(/"/g,"""),xmlunescape:e=>(e=(e=(e=(e=e.replace(/\&/g,"&")).replace(/</g,"<")).replace(/>/g,">")).replace(/'/g,"'")).replace(/"/g,'"'),xmlTextNode:e=>zs.xmlGenerator().createTextNode(e),xmlHtmlNode(e){let t;return ls?t=(new ls).parseFromString(e,"text/xml"):(t=new ActiveXObject("Microsoft.XMLDOM"),t.async="false",t.loadXML(e)),t},getText(e){if(!e)return null;let t="";0===e.childNodes.length&&e.nodeType===zs.ElementType.TEXT&&(t+=e.nodeValue);for(let n=0;n0&&(r=e.join("; "),t.setAttribute(i,r))}else t.setAttribute(i,r)}for(let n=0;n"string"!=typeof e?e:e.replace(/^\s+|\s+$/g,"").replace(/\\/g,"\\5c").replace(/ /g,"\\20").replace(/\"/g,"\\22").replace(/\&/g,"\\26").replace(/\'/g,"\\27").replace(/\//g,"\\2f").replace(/:/g,"\\3a").replace(//g,"\\3e").replace(/@/g,"\\40"),unescapeNode:e=>"string"!=typeof e?e:e.replace(/\\20/g," ").replace(/\\22/g,'"').replace(/\\26/g,"&").replace(/\\27/g,"'").replace(/\\2f/g,"/").replace(/\\3a/g,":").replace(/\\3c/g,"<").replace(/\\3e/g,">").replace(/\\40/g,"@").replace(/\\5c/g,"\\"),getNodeFromJid:e=>e.indexOf("@")<0?null:e.split("@")[0],getDomainFromJid(e){const t=zs.getBareJidFromJid(e);if(t.indexOf("@")<0)return t;{const e=t.split("@");return e.splice(0,1),e.join("@")}},getResourceFromJid(e){if(!e)return null;const t=e.split("/");return t.length<2?null:(t.splice(0,1),t.join("/"))},getBareJidFromJid:e=>e?e.split("/")[0]:null,_handleError(e){void 0!==e.stack&&zs.fatal(e.stack),e.sourceURL?zs.fatal("error: "+this.handler+" "+e.sourceURL+":"+e.line+" - "+e.name+": "+e.message):e.fileName?zs.fatal("error: "+this.handler+" "+e.fileName+":"+e.lineNumber+" - "+e.name+": "+e.message):zs.fatal("error: "+e.message)},log(e,t){var n;e===this.LogLevel.FATAL&&(null===(n=console)||void 0===n||n.error(t))},debug(e){this.log(this.LogLevel.DEBUG,e)},info(e){this.log(this.LogLevel.INFO,e)},warn(e){this.log(this.LogLevel.WARN,e)},error(e){this.log(this.LogLevel.ERROR,e)},fatal(e){this.log(this.LogLevel.FATAL,e)},serialize(e){if(!e)return null;"function"==typeof e.tree&&(e=e.tree());const t=[...Array(e.attributes.length).keys()].map((t=>e.attributes[t].nodeName));t.sort();let n=t.reduce(((t,n)=>"".concat(t," ").concat(n,'="').concat(zs.xmlescape(e.attributes.getNamedItem(n).value),'"')),"<".concat(e.nodeName));if(e.childNodes.length>0){n+=">";for(let t=0;t"}}n+=""}else n+="/>";return n},_requestId:0,_connectionPlugins:{},addConnectionPlugin(e,t){zs._connectionPlugins[e]=t},Builder:class{constructor(e,t){"presence"!==e&&"message"!==e&&"iq"!==e||(t&&!t.xmlns?t.xmlns=zs.NS.CLIENT:t||(t={xmlns:zs.NS.CLIENT})),this.nodeTree=zs.xmlElement(e,t),this.node=this.nodeTree}tree(){return this.nodeTree}toString(){return zs.serialize(this.nodeTree)}up(){return this.node=this.node.parentNode,this}root(){return this.node=this.nodeTree,this}attrs(e){for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(void 0===e[t]?this.node.removeAttribute(t):this.node.setAttribute(t,e[t]));return this}c(e,t,n){const s=zs.xmlElement(e,t,n);return this.node.appendChild(s),"string"!=typeof n&&"number"!=typeof n&&(this.node=s),this}cnode(e){let t;const n=zs.xmlGenerator();try{t=void 0!==n.importNode}catch(e){t=!1}const s=t?n.importNode(e,!0):zs.copyElement(e);return this.node.appendChild(s),this.node=s,this}t(e){const t=zs.xmlTextNode(e);return this.node.appendChild(t),this}h(e){const t=zs.xmlGenerator().createElement("body");t.innerHTML=e;const n=zs.createHtml(t);for(;n.childNodes.length>0;)this.node.appendChild(n.childNodes[0]);return this}},Handler:function(e,t,n,s,i,r,o){this.handler=e,this.ns=t,this.name=n,this.type=s,this.id=i,this.options=o||{matchBareFromJid:!1,ignoreNamespaceFragment:!1},this.options.matchBare&&(zs.warn('The "matchBare" option is deprecated, use "matchBareFromJid" instead.'),this.options.matchBareFromJid=this.options.matchBare,delete this.options.matchBare),this.options.matchBareFromJid?this.from=r?zs.getBareJidFromJid(r):null:this.from=r,this.user=!0}};zs.Handler.prototype={getNamespace(e){let t=e.getAttribute("xmlns");return t&&this.options.ignoreNamespaceFragment&&(t=t.split("#")[0]),t},namespaceMatch(e){let t=!1;return!this.ns||(zs.forEachChild(e,null,(e=>{this.getNamespace(e)===this.ns&&(t=!0)})),t||this.getNamespace(e)===this.ns)},isMatch(e){let t=e.getAttribute("from");this.options.matchBareFromJid&&(t=zs.getBareJidFromJid(t));const n=e.getAttribute("type");return!(!this.namespaceMatch(e)||this.name&&!zs.isTagEqual(e,this.name)||this.type&&(Array.isArray(this.type)?-1===this.type.indexOf(n):n!==this.type)||this.id&&e.getAttribute("id")!==this.id||this.from&&t!==this.from)},run(e){let t=null;try{t=this.handler(e)}catch(e){throw zs._handleError(e),e}return t},toString(){return"{Handler: "+this.handler+"("+this.name+","+this.id+","+this.ns+")}"}},zs.TimedHandler=class{constructor(e,t){this.period=e,this.handler=t,this.lastCalled=(new Date).getTime(),this.user=!0}run(){return this.lastCalled=(new Date).getTime(),this.handler()}reset(){this.lastCalled=(new Date).getTime()}toString(){return"{TimedHandler: "+this.handler+"("+this.period+")}"}},zs.Connection=class{constructor(e,t){this.service=e,this.options=t||{},this.setProtocol(),this.jid="",this.domain=null,this.features=null,this._sasl_data={},this.do_bind=!1,this.do_session=!1,this.mechanisms={},this.timedHandlers=[],this.handlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this.protocolErrorHandlers={HTTP:{},websocket:{}},this._idleTimeout=null,this._disconnectTimeout=null,this.authenticated=!1,this.connected=!1,this.disconnecting=!1,this.do_authentication=!0,this.paused=!1,this.restored=!1,this._data=[],this._uniqueId=0,this._sasl_success_handler=null,this._sasl_failure_handler=null,this._sasl_challenge_handler=null,this.maxRetries=5,this._idleTimeout=setTimeout((()=>this._onIdle()),100),function(e){e=e||{};for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n="",s="",i="";const r=e[t],o="object"==typeof r,a=escape(unescape(o?r.value:r));o&&(n=r.expires?";expires="+r.expires:"",s=r.domain?";domain="+r.domain:"",i=r.path?";path="+r.path:""),document.cookie=t+"="+a+n+s+i}}(this.options.cookies),this.registerSASLMechanisms(this.options.mechanisms);for(const e in zs._connectionPlugins)if(Object.prototype.hasOwnProperty.call(zs._connectionPlugins,e)){const t=function(){};t.prototype=zs._connectionPlugins[e],this[e]=new t,this[e].init(this)}}setProtocol(){const e=this.options.protocol||"";this.options.worker?this._proto=new zs.WorkerWebsocket(this):0===this.service.indexOf("ws:")||0===this.service.indexOf("wss:")||0===e.indexOf("ws")?this._proto=new zs.Websocket(this):this._proto=new zs.Bosh(this)}reset(){this._proto._reset(),this.do_session=!1,this.do_bind=!1,this.timedHandlers=[],this.handlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this.authenticated=!1,this.connected=!1,this.disconnecting=!1,this.restored=!1,this._data=[],this._requests=[],this._uniqueId=0}pause(){this.paused=!0}resume(){this.paused=!1}getUniqueId(e){const t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return"string"==typeof e||"number"==typeof e?t+":"+e:t+""}addProtocolErrorHandler(e,t,n){this.protocolErrorHandlers[e][t]=n}connect(e,t,n,s,i,r,o){this.jid=e,this.authzid=zs.getBareJidFromJid(this.jid),this.authcid=o||zs.getNodeFromJid(this.jid),this.pass=t,this.connect_callback=n,this.disconnecting=!1,this.connected=!1,this.authenticated=!1,this.restored=!1,this.domain=zs.getDomainFromJid(this.jid),this._changeConnectStatus(zs.Status.CONNECTING,null),this._proto._connect(s,i,r)}attach(e,t,n,s,i,r,o){if(this._proto._attach)return this._proto._attach(e,t,n,s,i,r,o);{const e=new Error('The "attach" method is not available for your connection protocol');throw e.name="StropheSessionError",e}}restore(e,t,n,s,i){if(!this._sessionCachingSupported()){const e=new Error('The "restore" method can only be used with a BOSH connection.');throw e.name="StropheSessionError",e}this._proto._restore(e,t,n,s,i)}_sessionCachingSupported(){if(this._proto instanceof zs.Bosh){if(!JSON)return!1;try{sessionStorage.setItem("_strophe_","_strophe_"),sessionStorage.removeItem("_strophe_")}catch(e){return!1}return!0}return!1}xmlInput(e){}xmlOutput(e){}rawInput(e){}rawOutput(e){}nextValidRid(e){}send(e){if(null!==e){if("function"==typeof e.sort)for(let t=0;t{i&&this.deleteTimedHandler(i),"error"===e.getAttribute("type")?n&&n(e):t&&t(e)}),null,"presence",null,r);s&&(i=this.addTimedHandler(s,(()=>(this.deleteHandler(e),n&&n(null),!1))))}return this.send(e),r}sendIQ(e,t,n,s){let i=null;"function"==typeof e.tree&&(e=e.tree());let r=e.getAttribute("id");if(r||(r=this.getUniqueId("sendIQ"),e.setAttribute("id",r)),"function"==typeof t||"function"==typeof n){const e=this.addHandler((e=>{i&&this.deleteTimedHandler(i);const s=e.getAttribute("type");if("result"===s)t&&t(e);else{if("error"!==s){const e=new Error("Got bad IQ type of ".concat(s));throw e.name="StropheError",e}n&&n(e)}}),null,"iq",["error","result"],r);s&&(i=this.addTimedHandler(s,(()=>(this.deleteHandler(e),n&&n(null),!1))))}return this.send(e),r}_queueData(e){if(null===e||!e.tagName||!e.childNodes){const e=new Error("Cannot queue non-DOMElement.");throw e.name="StropheError",e}this._data.push(e)}_sendRestart(){this._data.push("restart"),this._proto._sendRestart(),this._idleTimeout=setTimeout((()=>this._onIdle()),100)}addTimedHandler(e,t){const n=new zs.TimedHandler(e,t);return this.addTimeds.push(n),n}deleteTimedHandler(e){this.removeTimeds.push(e)}addHandler(e,t,n,s,i,r,o){const a=new zs.Handler(e,t,n,s,i,r,o);return this.addHandlers.push(a),a}deleteHandler(e){this.removeHandlers.push(e);const t=this.addHandlers.indexOf(e);t>=0&&this.addHandlers.splice(t,1)}registerSASLMechanisms(e){this.mechanisms={},(e=e||[zs.SASLAnonymous,zs.SASLExternal,zs.SASLOAuthBearer,zs.SASLXOAuth2,zs.SASLPlain,zs.SASLSHA1]).forEach((e=>this.registerSASLMechanism(e)))}registerSASLMechanism(e){const t=new e;this.mechanisms[t.mechname]=t}disconnect(e){if(this._changeConnectStatus(zs.Status.DISCONNECTING,e),e?zs.warn("Disconnect was called because: "+e):zs.info("Disconnect was called"),this.connected){let e=!1;this.disconnecting=!0,this.authenticated&&(e=Ds({xmlns:zs.NS.CLIENT,type:"unavailable"})),this._disconnectTimeout=this._addSysTimedHandler(3e3,this._onDisconnectTimeout.bind(this)),this._proto._disconnect(e)}else zs.warn("Disconnect was called before Strophe connected to the server"),this._proto._abortAllRequests(),this._doDisconnect()}_changeConnectStatus(e,t,n){for(const n in zs._connectionPlugins)if(Object.prototype.hasOwnProperty.call(zs._connectionPlugins,n)){const s=this[n];if(s.statusChanged)try{s.statusChanged(e,t)}catch(e){zs.error("".concat(n," plugin caused an exception changing status: ").concat(e))}}if(this.connect_callback)try{this.connect_callback(e,t,n)}catch(e){zs._handleError(e),zs.error("User connection callback caused an exception: ".concat(e))}}_doDisconnect(e){"number"==typeof this._idleTimeout&&clearTimeout(this._idleTimeout),null!==this._disconnectTimeout&&(this.deleteTimedHandler(this._disconnectTimeout),this._disconnectTimeout=null),zs.debug("_doDisconnect was called"),this._proto._doDisconnect(),this.authenticated=!1,this.disconnecting=!1,this.restored=!1,this.handlers=[],this.timedHandlers=[],this.removeTimeds=[],this.removeHandlers=[],this.addTimeds=[],this.addHandlers=[],this._changeConnectStatus(zs.Status.DISCONNECTED,e),this.connected=!1}_dataRecv(e,t){const n=this._proto._reqToData(e);if(null===n)return;for(this.xmlInput!==zs.Connection.prototype.xmlInput&&(n.nodeName===this._proto.strip&&n.childNodes.length?this.xmlInput(n.childNodes[0]):this.xmlInput(n)),this.rawInput!==zs.Connection.prototype.rawInput&&(t?this.rawInput(t):this.rawInput(zs.serialize(n)));this.removeHandlers.length>0;){const e=this.removeHandlers.pop(),t=this.handlers.indexOf(e);t>=0&&this.handlers.splice(t,1)}for(;this.addHandlers.length>0;)this.handlers.push(this.addHandlers.pop());if(this.disconnecting&&this._proto._emptyQueue())return void this._doDisconnect();const s=n.getAttribute("type");if(null!==s&&"terminate"===s){if(this.disconnecting)return;let e=n.getAttribute("condition");const t=n.getElementsByTagName("conflict");return null!==e?("remote-stream-error"===e&&t.length>0&&(e="conflict"),this._changeConnectStatus(zs.Status.CONNFAIL,e)):this._changeConnectStatus(zs.Status.CONNFAIL,zs.ErrorCondition.UNKOWN_REASON),void this._doDisconnect(e)}zs.forEachChild(n,null,(e=>{const t=this.handlers;this.handlers=[];for(let n=0;n0:s.getElementsByTagName("stream:features").length>0||s.getElementsByTagName("features").length>0,!i)return void this._proto._no_auth_received(t);const r=Array.from(s.getElementsByTagName("mechanism")).map((e=>this.mechanisms[e.textContent])).filter((e=>e));0!==r.length||0!==s.getElementsByTagName("auth").length?!1!==this.do_authentication&&this.authenticate(r):this._proto._no_auth_received(t)}sortMechanismsByPriority(e){for(let t=0;te[n].priority&&(n=s);if(n!==t){const s=e[t];e[t]=e[n],e[n]=s}}return e}authenticate(e){this._attemptSASLAuth(e)||this._attemptLegacyAuth()}_attemptSASLAuth(e){e=this.sortMechanismsByPriority(e||[]);let t=!1;for(let n=0;n{for(;e.length;)this.deleteHandler(e.pop());return this._onStreamFeaturesAfterSASL(t),!1};return t.push(this._addSysHandler((e=>n(t,e)),null,"stream:features",null,null)),t.push(this._addSysHandler((e=>n(t,e)),zs.NS.STREAM,"features",null,null)),this._sendRestart(),!1}_onStreamFeaturesAfterSASL(e){this.features=e;for(let t=0;t0&&(t=zs.ErrorCondition.CONFLICT),this._changeConnectStatus(zs.Status.AUTHFAIL,t,e),!1}const t=e.getElementsByTagName("bind");if(!(t.length>0))return zs.warn("Resource binding failed."),this._changeConnectStatus(zs.Status.AUTHFAIL,null,e),!1;{const e=t[0].getElementsByTagName("jid");e.length>0&&(this.authenticated=!0,this.jid=zs.getText(e[0]),this.do_session?this._establishSession():this._changeConnectStatus(zs.Status.CONNECTED,null))}}_establishSession(){if(!this.do_session)throw new Error("Strophe.Connection.prototype._establishSession "+"called but apparently ".concat(zs.NS.SESSION," wasn't advertised by the server"));this._addSysHandler(this._onSessionResultIQ.bind(this),null,null,null,"_session_auth_2"),this.send(Rs({type:"set",id:"_session_auth_2"}).c("session",{xmlns:zs.NS.SESSION}).tree())}_onSessionResultIQ(e){if("result"===e.getAttribute("type"))this.authenticated=!0,this._changeConnectStatus(zs.Status.CONNECTED,null);else if("error"===e.getAttribute("type"))return this.authenticated=!1,zs.warn("Session creation failed."),this._changeConnectStatus(zs.Status.AUTHFAIL,null,e),!1;return!1}_sasl_failure_cb(e){return this._sasl_success_handler&&(this.deleteHandler(this._sasl_success_handler),this._sasl_success_handler=null),this._sasl_challenge_handler&&(this.deleteHandler(this._sasl_challenge_handler),this._sasl_challenge_handler=null),this._sasl_mechanism&&this._sasl_mechanism.onFailure(),this._changeConnectStatus(zs.Status.AUTHFAIL,null,e),!1}_auth2_cb(e){return"result"===e.getAttribute("type")?(this.authenticated=!0,this._changeConnectStatus(zs.Status.CONNECTED,null)):"error"===e.getAttribute("type")&&(this._changeConnectStatus(zs.Status.AUTHFAIL,null,e),this.disconnect("authentication failed")),!1}_addSysTimedHandler(e,t){const n=new zs.TimedHandler(e,t);return n.user=!1,this.addTimeds.push(n),n}_addSysHandler(e,t,n,s,i){const r=new zs.Handler(e,t,n,s,i);return r.user=!1,this.addHandlers.push(r),r}_onDisconnectTimeout(){return zs.debug("_onDisconnectTimeout was called"),this._changeConnectStatus(zs.Status.CONNTIMEOUT,null),this._proto._onDisconnectTimeout(),this._doDisconnect(),!1}_onIdle(){for(;this.addTimeds.length>0;)this.timedHandlers.push(this.addTimeds.pop());for(;this.removeTimeds.length>0;){const e=this.removeTimeds.pop(),t=this.timedHandlers.indexOf(e);t>=0&&this.timedHandlers.splice(t,1)}const e=(new Date).getTime(),t=[];for(let n=0;nthis._onIdle()),100))}},zs.SASLMechanism=ys,zs.SASLAnonymous=class extends ys{constructor(e="ANONYMOUS",t=!1,n=20){super(e,t,n)}test(e){return null===e.authcid}},zs.SASLPlain=class extends ys{constructor(e="PLAIN",t=!0,n=50){super(e,t,n)}test(e){return null!==e.authcid}onChallenge(e){const{authcid:t,authzid:n,domain:s,pass:i}=e;if(!s)throw new Error("SASLPlain onChallenge: domain is not defined!");let r=n!=="".concat(t,"@").concat(s)?n:"";return r+="\0",r+=t,r+="\0",r+=i,_s(r)}},zs.SASLSHA1=class extends ys{constructor(e="SCRAM-SHA-1",t=!0,n=60){super(e,t,n)}test(e){return null!==e.authcid}onChallenge(e,t){let n,s,i,r,o,a,c,l,u="c=biws,",d="".concat(e._sasl_data["client-first-message-bare"],",").concat(t,",");const h=e._sasl_data.cnonce,f=/([a-z]+)=([^,]+)(,|$)/;for(;t.match(f);){const e=t.match(f);switch(t=t.replace(e[0],""),e[1]){case"r":n=e[2];break;case"s":s=e[2];break;case"i":i=e[2]}}if(n.substr(0,h.length)!==h)return e._sasl_data={},e._sasl_failure_cb();u+="r="+n,d+=u,s=atob(s),s+="\0\0\0";const g=_s(e.pass);for(r=a=Ts.core_hmac_sha1(g,s),c=1;c0&&(t="conflict"),this._conn._changeConnectStatus(zs.Status.CONNFAIL,t)):this._conn._changeConnectStatus(zs.Status.CONNFAIL,"unknown"),this._conn._doDisconnect(t),zs.Status.CONNFAIL}this.sid||(this.sid=e.getAttribute("sid"));const n=e.getAttribute("requests");n&&(this.window=parseInt(n,10));const s=e.getAttribute("hold");s&&(this.hold=parseInt(s,10));const i=e.getAttribute("wait");i&&(this.wait=parseInt(i,10));const r=e.getAttribute("inactivity");r&&(this.inactivity=parseInt(r,10))}_disconnect(e){this._sendTerminate(e)}_doDisconnect(){this.sid=null,this.rid=Math.floor(4294967295*Math.random()),this._conn._sessionCachingSupported()&&window.sessionStorage.removeItem("strophe-bosh-session"),this._conn.nextValidRid(this.rid)}_emptyQueue(){return 0===this._requests.length}_callProtocolErrorHandlers(t){const n=e._getRequestStatus(t),s=this._conn.protocolErrorHandlers.HTTP[n];s&&s.call(this,n)}_hitError(e){this.errors++,zs.warn("request errored, status: "+e+", number of errors: "+this.errors),this.errors>4&&this._conn._onDisconnectTimeout()}_no_auth_received(e){zs.warn("Server did not yet offer a supported authentication mechanism. Sending a blank poll request."),e=e?e.bind(this._conn):this._conn._connect_cb.bind(this._conn);const t=this._buildBody();this._requests.push(new zs.Request(t.tree(),this._onRequestStateChange.bind(this,e),t.tree().getAttribute("rid"))),this._throttledRequestHandler()}_onDisconnectTimeout(){this._abortAllRequests()}_abortAllRequests(){for(;this._requests.length>0;){const e=this._requests.pop();e.abort=!0,e.xhr.abort(),e.xhr.onreadystatechange=function(){}}}_onIdle(){const e=this._conn._data;if(this._conn.authenticated&&0===this._requests.length&&0===e.length&&!this._conn.disconnecting&&(zs.debug("no requests during idle cycle, sending blank request"),e.push(null)),!this._conn.paused){if(this._requests.length<2&&e.length>0){const t=this._buildBody();for(let n=0;n0){const e=this._requests[0].age();null!==this._requests[0].dead&&this._requests[0].timeDead()>Math.floor(zs.SECONDARY_TIMEOUT*this.wait)&&this._throttledRequestHandler(),e>Math.floor(zs.TIMEOUT*this.wait)&&(zs.warn("Request "+this._requests[0].id+" timed out, over "+Math.floor(zs.TIMEOUT*this.wait)+" seconds since last activity"),this._throttledRequestHandler())}}}static _getRequestStatus(e,t){let n;if(4===e.xhr.readyState)try{n=e.xhr.status}catch(e){zs.error("Caught an error while retrieving a request's status, reqStatus: "+n)}return void 0===n&&(n="number"==typeof t?t:0),n}_onRequestStateChange(t,n){if(zs.debug("request id "+n.id+"."+n.sends+" state changed to "+n.xhr.readyState),n.abort)return void(n.abort=!1);if(4!==n.xhr.readyState)return;const s=e._getRequestStatus(n);if(this.lastResponseHeaders=n.xhr.getAllResponseHeaders(),this._conn.disconnecting&&s>=400)return this._hitError(s),void this._callProtocolErrorHandlers(n);const i=s>0&&s<500,r=n.sends>this._conn.maxRetries;if((i||r)&&(this._removeRequest(n),zs.debug("request id "+n.id+" should now be removed")),200===s){const e=this._requests[0]===n;(this._requests[1]===n||e&&this._requests.length>0&&this._requests[0].age()>Math.floor(zs.SECONDARY_TIMEOUT*this.wait))&&this._restartRequest(0),this._conn.nextValidRid(Number(n.rid)+1),zs.debug("request id "+n.id+"."+n.sends+" got 200"),t(n),this.errors=0}else 0===s||s>=400&&s<600||s>=12e3?(zs.error("request id "+n.id+"."+n.sends+" error "+s+" happened"),this._hitError(s),this._callProtocolErrorHandlers(n),s>=400&&s<500&&(this._conn._changeConnectStatus(zs.Status.DISCONNECTING,null),this._conn._doDisconnect())):zs.error("request id "+n.id+"."+n.sends+" error "+s+" happened");i||r?r&&!this._conn.connected&&this._conn._changeConnectStatus(zs.Status.CONNFAIL,"giving-up"):this._throttledRequestHandler()}_processRequest(t){let n=this._requests[t];const s=e._getRequestStatus(n,-1);if(n.sends>this._conn.maxRetries)return void this._conn._onDisconnectTimeout();const i=n.age(),r=!isNaN(i)&&i>Math.floor(zs.TIMEOUT*this.wait),o=null!==n.dead&&n.timeDead()>Math.floor(zs.SECONDARY_TIMEOUT*this.wait),a=4===n.xhr.readyState&&(s<1||s>=500);if((r||o||a)&&(o&&zs.error("Request ".concat(this._requests[t].id," timed out (secondary), restarting")),n.abort=!0,n.xhr.abort(),n.xhr.onreadystatechange=function(){},this._requests[t]=new zs.Request(n.xmlData,n.origFunc,n.rid,n.sends),n=this._requests[t]),0===n.xhr.readyState){zs.debug("request id "+n.id+"."+n.sends+" posting");try{const e=this._conn.options.contentType||"text/xml; charset=utf-8";n.xhr.open("POST",this._conn.service,!this._conn.options.sync),void 0!==n.xhr.setRequestHeader&&n.xhr.setRequestHeader("Content-Type",e),this._conn.options.withCredentials&&(n.xhr.withCredentials=!0)}catch(e){return zs.error("XHR open failed: "+e.toString()),this._conn.connected||this._conn._changeConnectStatus(zs.Status.CONNFAIL,"bad-service"),void this._conn.disconnect()}const e=()=>{if(n.date=new Date,this._conn.options.customHeaders){const e=this._conn.options.customHeaders;for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.xhr.setRequestHeader(t,e[t])}n.xhr.send(n.data)};if(n.sends>1){const t=1e3*Math.min(Math.floor(zs.TIMEOUT*this.wait),Math.pow(n.sends,3));setTimeout((function(){e()}),t)}else e();n.sends++,this._conn.xmlOutput!==zs.Connection.prototype.xmlOutput&&(n.xmlData.nodeName===this.strip&&n.xmlData.childNodes.length?this._conn.xmlOutput(n.xmlData.childNodes[0]):this._conn.xmlOutput(n.xmlData)),this._conn.rawOutput!==zs.Connection.prototype.rawOutput&&this._conn.rawOutput(n.data)}else zs.debug("_processRequest: "+(0===t?"first":"second")+" request has readyState of "+n.xhr.readyState)}_removeRequest(e){zs.debug("removing request");for(let t=this._requests.length-1;t>=0;t--)e===this._requests[t]&&this._requests.splice(t,1);e.xhr.onreadystatechange=function(){},this._throttledRequestHandler()}_restartRequest(e){const t=this._requests[e];null===t.dead&&(t.dead=new Date),this._processRequest(e)}_reqToData(e){try{return e.getResponse()}catch(e){if("parsererror"!==e.message)throw e;this._conn.disconnect("strophe-parsererror")}}_sendTerminate(e){zs.debug("_sendTerminate was called");const t=this._buildBody().attrs({type:"terminate"});e&&t.cnode(e.tree());const n=new zs.Request(t.tree(),this._onRequestStateChange.bind(this,this._conn._dataRecv.bind(this._conn)),t.tree().getAttribute("rid"));this._requests.push(n),this._throttledRequestHandler()}_send(){clearTimeout(this._conn._idleTimeout),this._throttledRequestHandler(),this._conn._idleTimeout=setTimeout((()=>this._conn._onIdle()),100)}_sendRestart(){this._throttledRequestHandler(),clearTimeout(this._conn._idleTimeout)}_throttledRequestHandler(){this._requests?zs.debug("_throttledRequestHandler called with "+this._requests.length+" requests"):zs.debug("_throttledRequestHandler called with undefined requests"),this._requests&&0!==this._requests.length&&(this._requests.length>0&&this._processRequest(0),this._requests.length>1&&Math.abs(this._requests[0].rid-this._requests[1].rid)this._onOpen(),this.socket.onerror=e=>this._onError(e),this.socket.onclose=e=>this._onClose(e),this.socket.onmessage=e=>this._onInitialMessage(e)}_connect_cb(e){if(this._checkStreamError(e,zs.Status.CONNFAIL))return zs.Status.CONNFAIL}_handleStreamStart(e){let t=!1;const n=e.getAttribute("xmlns");"string"!=typeof n?t="Missing xmlns in ":n!==zs.NS.FRAMING&&(t="Wrong xmlns in : "+n);const s=e.getAttribute("version");return"string"!=typeof s?t="Missing version in ":"1.0"!==s&&(t="Wrong version in : "+s),!t||(this._conn._changeConnectStatus(zs.Status.CONNFAIL,t),this._conn._doDisconnect(),!1)}_onInitialMessage(e){if(0===e.data.indexOf("\s*)*/,"");if(""===t)return;const n=(new ls).parseFromString(t,"text/xml").documentElement;this._conn.xmlInput(n),this._conn.rawInput(e.data),this._handleStreamStart(n)&&this._connect_cb(n)}else if(0===e.data.indexOf("=0&&n.indexOf("wss:")>=0||e.indexOf("ws:")>=0)&&(this._conn._changeConnectStatus(zs.Status.REDIRECT,"Received see-other-uri, resetting connection"),this._conn.reset(),this._conn.service=n,this._connect())}else this._conn._changeConnectStatus(zs.Status.CONNFAIL,"Received closing stream"),this._conn._doDisconnect()}else{this._replaceMessageHandler();const t=this._streamWrap(e.data),n=(new ls).parseFromString(t,"text/xml").documentElement;this._conn._connect_cb(n,null,e.data)}}_replaceMessageHandler(){this.socket.onmessage=e=>this._onMessage(e)}_disconnect(e){if(this.socket&&this.socket.readyState!==cs.CLOSED){e&&this._conn.send(e);const t=Is("close",{xmlns:zs.NS.FRAMING});this._conn.xmlOutput(t.tree());const n=zs.serialize(t);this._conn.rawOutput(n);try{this.socket.send(n)}catch(e){zs.warn("Couldn't send tag.")}}setTimeout((()=>this._conn._doDisconnect),0)}_doDisconnect(){zs.debug("WebSockets _doDisconnect was called"),this._closeSocket()}_streamWrap(e){return""+e+""}_closeSocket(){if(this.socket)try{this.socket.onclose=null,this.socket.onerror=null,this.socket.onmessage=null,this.socket.close()}catch(e){zs.debug(e.message)}this.socket=null}_emptyQueue(){return!0}_onClose(e){this._conn.connected&&!this._conn.disconnecting?(zs.error("Websocket closed unexpectedly"),this._conn._doDisconnect()):e&&1006===e.code&&!this._conn.connected&&this.socket?(zs.error("Websocket closed unexcectedly"),this._conn._changeConnectStatus(zs.Status.CONNFAIL,"The WebSocket connection could not be established or was disconnected."),this._conn._doDisconnect()):zs.debug("Websocket closed")}_no_auth_received(e){zs.error("Server did not offer a supported authentication mechanism"),this._conn._changeConnectStatus(zs.Status.CONNFAIL,zs.ErrorCondition.NO_AUTH_MECH),e&&e.call(this._conn),this._conn._doDisconnect()}_onDisconnectTimeout(){}_abortAllRequests(){}_onError(e){zs.error("Websocket error "+e),this._conn._changeConnectStatus(zs.Status.CONNFAIL,"The WebSocket connection could not be established or was disconnected."),this._disconnect()}_onIdle(){const e=this._conn._data;if(e.length>0&&!this._conn.paused){for(let t=0;t{var t;null===(t=console)||void 0===t||t.error(e),zs.log(zs.LogLevel.ERROR,"Shared Worker Error: ".concat(e))}}get socket(){return{send:e=>this.worker.port.postMessage(["send",e])}}_connect(){this._messageHandler=e=>this._onInitialMessage(e),this.worker.port.start(),this.worker.port.onmessage=e=>this._onWorkerMessage(e),this.worker.port.postMessage(["_connect",this._conn.service,this._conn.jid])}_attach(e){this._messageHandler=e=>this._onMessage(e),this._conn.connect_callback=e,this.worker.port.start(),this.worker.port.onmessage=e=>this._onWorkerMessage(e),this.worker.port.postMessage(["_attach",this._conn.service])}_attachCallback(e,t){e===zs.Status.ATTACHED?(this._conn.jid=t,this._conn.authenticated=!0,this._conn.connected=!0,this._conn.restored=!0,this._conn._changeConnectStatus(zs.Status.ATTACHED)):e===zs.Status.ATTACHFAIL&&(this._conn.authenticated=!1,this._conn.connected=!1,this._conn.restored=!1,this._conn._changeConnectStatus(zs.Status.ATTACHFAIL))}_disconnect(e,t){t&&this._conn.send(t);const n=Is("close",{xmlns:zs.NS.FRAMING});this._conn.xmlOutput(n.tree());const s=zs.serialize(n);this._conn.rawOutput(s),this.worker.port.postMessage(["send",s]),this._conn._doDisconnect()}_onClose(e){this._conn.connected&&!this._conn.disconnecting?(zs.error("Websocket closed unexpectedly"),this._conn._doDisconnect()):e&&1006===e.code&&!this._conn.connected?(zs.error("Websocket closed unexcectedly"),this._conn._changeConnectStatus(zs.Status.CONNFAIL,"The WebSocket connection could not be established or was disconnected."),this._conn._doDisconnect()):zs.debug("Websocket closed")}_closeSocket(){this.worker.port.postMessage(["_closeSocket"])}_replaceMessageHandler(){this._messageHandler=e=>this._onMessage(e)}_onWorkerMessage(e){const{data:t}=e,n=t[0];if("_onMessage"===n)this._messageHandler(t[1]);else if(n in this)try{this[n].apply(this,e.data.slice(1))}catch(e){zs.log(zs.LogLevel.ERROR,e)}else if("log"===n){const e=t[1],n=t[2];zs.log(Ps[e],n)}else zs.log(zs.LogLevel.ERROR,"Found unhandled service worker message: ".concat(t))}},n.g.$build=Ls.$build,n.g.$iq=Ls.$iq,n.g.$msg=Ls.$msg,n.g.$pres=Ls.$pres,n.g.Strophe=Ls.Strophe;const{b64_sha1:Fs}=Ts,Bs={};Bs[zs.Status.ATTACHED]="ATTACHED",Bs[zs.Status.AUTHENTICATING]="AUTHENTICATING",Bs[zs.Status.AUTHFAIL]="AUTHFAIL",Bs[zs.Status.CONNECTED]="CONNECTED",Bs[zs.Status.CONNECTING]="CONNECTING",Bs[zs.Status.CONNFAIL]="CONNFAIL",Bs[zs.Status.DISCONNECTED]="DISCONNECTED",Bs[zs.Status.DISCONNECTING]="DISCONNECTING",Bs[zs.Status.ERROR]="ERROR",Bs[zs.Status.RECONNECTING]="RECONNECTING",Bs[zs.Status.REDIRECT]="REDIRECT";const Us=dt((function(e,t){qe(t,Qe(t),e)})),qs=function(e,t){for(var n=-1,s=null==e?0:e.length;++na))return!1;var l=r.get(e),u=r.get(t);if(l&&u)return l==t&&u==e;var d=-1,h=!0,f=2&n?new $s:void 0;for(r.set(e,t),r.set(t,e);++d0&&(n=t.apply(this,arguments)),e<=1&&(t=void 0),n}}(2,e)};var Ui=0;const qi=function(e){var t=++Ui;return wi(e)+t},Hi={},$i=/\s+/;let Gi;const Vi=function(e,t,n,s,i){let r,o=0;if(n&&"object"==typeof n){void 0!==s&&"context"in i&&void 0===i.context&&(i.context=s);for(r=Mt(n);o{e.resolve=t,e.reject=n}));return Object.assign(t,e),t.then((function(e){return t.isResolved=!0,t.isPending=!1,t.isRejected=!1,e}),(function(e){throw t.isResolved=!1,t.isPending=!1,t.isRejected=!0,e})),t}function or(){throw new Error('A "url" property or function must be specified')}function ar(e,t){const n=t.error;t.error=function(s){n&&n.call(t.context,e,s,t),e.trigger("error",e,s,t)}}Error;const cr={create:"POST",update:"PUT",patch:"PATCH",delete:"DELETE",read:"GET"};function lr(e){const t=sr(e,"browserStorage")||sr(e.collection,"browserStorage");return t?t.sync():ur}function ur(e,t,n={}){const s={type:cr[e],dataType:"json"};n.url||(s.url=sr(t,"url")||or()),null!=n.data||!t||"create"!==e&&"update"!==e&&"patch"!==e||(s.contentType="application/json",s.data=JSON.stringify(n.attrs||t.toJSON(n))),"GET"!==s.type&&(s.processData=!1);const i=n.error;n.error=function(e,t,s){n.textStatus=t,n.errorThrown=s,i&&i.call(n.context,e,t,s)};const r=n.xhr=function(){return fetch.apply(this,arguments)}(Us(s,n));return t.trigger("request",t,r,n),r}const dr=function(){this.handlers=[],this.checkUrl=this.checkUrl.bind(this),"undefined"!=typeof window&&(this.location=window.location,this.history=window.history)};dr.extend=ir;const hr=/^[#\/]|\s+$/g,fr=/^\/+|\/+$/g,gr=/#.*$/;dr.started=!1,Object.assign(dr.prototype,Hi,{interval:50,atRoot:function(){return this.location.pathname.replace(/[^\/]$/,"$&/")===this.root&&!this.getSearch()},matchRoot:function(){return this.decodeFragment(this.location.pathname).slice(0,this.root.length-1)+"/"===this.root},decodeFragment:function(e){return decodeURI(e.replace(/%25/g,"%2525"))},getSearch:function(){const e=this.location.href.replace(/#.*/,"").match(/\?.+/);return e?e[0]:""},getHash:function(e){const t=(e||this).location.href.match(/#(.*)$/);return t?t[1]:""},getPath:function(){const e=this.decodeFragment(this.location.pathname+this.getSearch()).slice(this.root.length-1);return"/"===e.charAt(0)?e.slice(1):e},getFragment:function(e){return null==e&&(e=this._usePushState||!this._wantsHashChange?this.getPath():this.getHash()),e.replace(hr,"")},start:function(e){if(dr.started)throw new Error("history has already been started");if(dr.started=!0,this.options=Us({root:"/"},this.options,e),this.root=this.options.root,this._wantsHashChange=!1!==this.options.hashChange,this._hasHashChange="onhashchange"in window&&(void 0===document.documentMode||document.documentMode>7),this._useHashChange=this._wantsHashChange&&this._hasHashChange,this._wantsPushState=!!this.options.pushState,this._hasPushState=!(!this.history||!this.history.pushState),this._usePushState=this._wantsPushState&&this._hasPushState,this.fragment=this.getFragment(),this.root=("/"+this.root+"/").replace(fr,"/"),this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!this.atRoot()){const e=this.root.slice(0,-1)||"/";return this.location.replace(e+"#"+this.getPath()),!0}this._hasPushState&&this.atRoot()&&this.navigate(this.getHash(),{replace:!0})}if(!this._hasHashChange&&this._wantsHashChange&&!this._usePushState){this.iframe=document.createElement("iframe"),this.iframe.src="javascript:0",this.iframe.style.display="none",this.iframe.tabIndex=-1;const e=document.body,t=e.insertBefore(this.iframe,e.firstChild).contentWindow;t.document.open(),t.document.close(),t.location.hash="#"+this.fragment}if(this._usePushState?addEventListener("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe?addEventListener("hashchange",this.checkUrl,!1):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),!this.options.silent)return this.loadUrl()},stop:function(){this._usePushState?removeEventListener("popstate",this.checkUrl,!1):this._useHashChange&&!this.iframe&&removeEventListener("hashchange",this.checkUrl,!1),this.iframe&&(document.body.removeChild(this.iframe),this.iframe=null),this._checkUrlInterval&&clearInterval(this._checkUrlInterval),dr.started=!1},route:function(e,t){this.handlers.unshift({route:e,callback:t})},checkUrl:function(e){let t=this.getFragment();if(t===this.fragment&&this.iframe&&(t=this.getHash(this.iframe.contentWindow)),t===this.fragment)return!1;this.iframe&&this.navigate(t),this.loadUrl()},loadUrl:function(e){return!!this.matchRoot()&&(e=this.fragment=this.getFragment(e),Di(this.handlers,(function(t){if(t.route.test(e))return t.callback(e),!0})))},navigate:function(e,t){if(!dr.started)return!1;t&&!0!==t||(t={trigger:!!t}),e=this.getFragment(e||"");let n=this.root;""!==e&&"?"!==e.charAt(0)||(n=n.slice(0,-1)||"/");const s=n+e;e=e.replace(gr,"");const i=this.decodeFragment(e);if(this.fragment!==i){if(this.fragment=i,this._usePushState)this.history[t.replace?"replaceState":"pushState"]({},document.title,s);else{if(!this._wantsHashChange)return this.location.assign(s);if(this._updateHash(this.location,e,t.replace),this.iframe&&e!==this.getHash(this.iframe.contentWindow)){const n=this.iframe.contentWindow;t.replace||(n.document.open(),n.document.close()),this._updateHash(n.location,e,t.replace)}}return t.trigger?this.loadUrl(e):void 0}},_updateHash:function(e,t,n){if(n){const n=e.href.replace(/(javascript:|#).*$/,"");e.replace(n+"#"+t)}else e.hash="#"+t}});const mr=dr;var pr=ze&&ze.isRegExp;const vr=pr?Ie(pr):function(e){return de(e)&&"[object RegExp]"==y(e)},br=function(e={}){this.history=e.history||new mr,this.preinitialize.apply(this,arguments),e.routes&&(this.routes=e.routes),this._bindRoutes(),this.initialize.apply(this,arguments)};br.extend=ir;const yr=/\((.*?)\)/g,_r=/(\(\?)?:\w+/g,wr=/\*\w+/g,Sr=/[\-{}\[\]+?.,\\\^$|#\s]/g;Object.assign(br.prototype,Hi,{preinitialize:function(){},initialize:function(){},route:function(e,t,n){return vr(e)||(e=this._routeToRegExp(e)),_(t)&&(n=t,t=""),n||(n=this[t]),this.history.route(e,(s=>{const i=this._extractParameters(e,s);!1!==this.execute(n,i,t)&&(this.trigger.apply(this,["route:"+t].concat(i)),this.trigger("route",t,i),this.history.trigger("route",this,t,i))})),this},execute:function(e,t,n){e&&e.apply(this,t)},navigate:function(e,t){return this.history.navigate(e,t),this},_bindRoutes:function(){if(!this.routes)return;let e;this.routes=sr(this,"routes");const t=Mt(this.routes);for(;null!=(e=t.pop());)this.route(e,this.routes[e])},_routeToRegExp:function(e){return e=e.replace(Sr,"\\$&").replace(yr,"(?:$1)?").replace(_r,(function(e,t){return t?e:"([^/?]+)"})).replace(wr,"([^?]*?)"),new RegExp("^"+e+"(?:\\?([\\s\\S]*))?$")},_extractParameters:function(e,t){const n=e.exec(t).slice(1);return n.map((function(e,t){return t===n.length-1?e||null:e?decodeURIComponent(e):null}))}});class xr extends Error{}var Er=n(6632);function jr(){return So.config.get("trusted")?"sessionStorage"===Cc.settings.get("persistent_store")?"session":"persistent":"session"}function Ar(e,t){const n=t||jr(),s=So.storage[n];if(void 0===s)throw new TypeError("createStore: Could not find store for ".concat(e));return new Kn(e,s,"IndexedDB"===Cc.settings.get("persistent_store"))}function Cr(e,t,n){const s=n||jr();if(e.browserStorage=So.createStore(t,s),"persistent"===s&&"IndexedDB"===Cc.settings.get("persistent_store")){const t=()=>e.browserStorage.flush();window.addEventListener(So.unloadevent,t),e.on("destroy",(()=>window.removeEventListener(So.unloadevent,t))),e.listenTo(So,"beforeLogout",t)}}function kr(e){const t=So.promises[e];if(!t)throw new Error("Tried to replace non-existing promise: ".concat(e));if(t.replace){const n=Et();n.replace=t.replace,So.promises[e]=n}else as.debug('Not replacing promise "'.concat(e,'"'))}const Or=document.createElement("div");function Tr(e){return e&&"string"==typeof e&&(Or.innerHTML=Er.filterXSS(e),e=Or.textContent,Or.textContent=""),e}const Nr=function(e,t,n,i){if(!s(e))return e;for(var r=-1,o=(t=Si(t,e)).length,a=o-1,c=e;null!=c&&++r0&&s(c)?n>1?e(c,n-1,s,i,r):Ft(r,c):i||(r[r.length]=c)}return r},zr=function(e){return null!=e&&e.length?Dr(e,1):[]},Lr=function(e){return rt(tt(e,void 0,zr),e+"")},Pr=Lr((function(e,t){return null==e?{}:Ir(e,t)})),Fr=function(e){for(var t=-1,n=null==e?0:e.length,s=0,i=[];++t2?t[2]:void 0;for(r&&ut(t[0],t[1],r)&&(s=1);++n":">",'"':""","'":"'"},function(e){return null==Qr?void 0:Qr[e]});var Qr,Yr=/[&<>"']/g,Kr=RegExp(Yr.source);var Xr=Object.prototype.toString;const Zr=(eo=function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=Xr.call(t)),e[t]=n},to=nt(Xe),function(e,t){return function(e,t,n,s){return Ni(e,(function(e,i,r){t(s,n(e),i,r)})),s}(e,eo,to(t),{})});var eo,to;const no=function(e,t){return si(e,t)},so=function(e,t){return t.length<2?e:Ei(e,function(e,t,n){var s=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var r=Array(i);++s1),t})),qe(e,Ht(e),n),s&&(n=yn(n,7,ro));for(var i=t.length;i--;)io(n,t[i]);return n})),ao=function(e,t){let n=e||{};t||(t={}),this.preinitialize.apply(this,arguments),this.cid=qi(this.cidPrefix),this.attributes={},t.collection&&(this.collection=t.collection),t.parse&&(n=this.parse(n,t)||{});const s=sr(this,"defaults");n=Vr(Us({},s,n),s),this.set(n,t),this.changed={},this.initialize.apply(this,arguments)};ao.extend=ir,Object.assign(ao.prototype,Hi,{changed:null,validationError:null,idAttribute:"id",cidPrefix:"c",preinitialize:function(){},initialize:function(){},toJSON:function(e){return Hr(this.attributes)},sync:function(e,t,n){return lr(this)(e,t,n)},get:function(e){return this.attributes[e]},keys:function(){return Object.keys(this.attributes)},values:function(){return Object.values(this.attributes)},pairs:function(){return this.entries()},entries:function(){return Object.entries(this.attributes)},invert:function(){return Zr(this.attributes)},pick:function(...e){return 1===e.length&&Array.isArray(e[0])&&(e=e[0]),Pr(this.attributes,e)},omit:function(...e){return 1===e.length&&Array.isArray(e[0])&&(e=e[0]),oo(this.attributes,e)},isEmpty:function(){return Li(this.attributes)},escape:function(e){return t=this.get(e),(t=wi(t))&&Kr.test(t)?t.replace(Yr,Jr):t;var t},has:function(e){return null!=this.get(e)},matches:function(e){return!!function(e){return Ti("function"==typeof e?e:yn(e,1))}(e)(this.attributes)},set:function(e,t,n){if(null==e)return this;let s;if("object"==typeof e?(s=e,n=t):(s={})[e]=t,n||(n={}),!this._validate(s,n))return!1;const i=n.unset,r=n.silent,o=[],a=this._changing;this._changing=!0,a||(this._previousAttributes=Hr(this.attributes),this.changed={});const c=this.attributes,l=this.changed,u=this._previousAttributes;for(const e in s)t=s[e],no(c[e],t)||o.push(e),no(u[e],t)?delete l[e]:l[e]=t,i?delete c[e]:c[e]=t;if(this.idAttribute in s&&(this.id=this.get(this.idAttribute)),!r){o.length&&(this._pending=n);for(let e=0;et.length?n:t}),"")},co.prefixMentions=function(e){let t=e.get("message");return(e.get("references")||[]).sort(((e,t)=>t.begin-e.begin)).forEach((e=>{t="".concat(t.slice(0,e.begin),"@").concat(t.slice(e.begin))})),t},co.isValidJID=function(e){return"string"==typeof e&&2===Fr(e.split("@")).length&&!e.startsWith("@")&&!e.endsWith("@")},co.isValidMUCJID=function(e){return!e.startsWith("@")&&!e.endsWith("@")},co.isSameBareJID=function(e,t){return"string"==typeof e&&"string"==typeof t&&zs.getBareJidFromJid(e).toLowerCase()===zs.getBareJidFromJid(t).toLowerCase()},co.isSameDomain=function(e,t){return"string"==typeof e&&"string"==typeof t&&zs.getDomainFromJid(e).toLowerCase()===zs.getDomainFromJid(t).toLowerCase()},co.isNewMessage=function(e){return e instanceof Element?!(qr()('result[xmlns="'.concat(zs.NS.MAM,'"]'),e).length&&qr()('delay[xmlns="'.concat(zs.NS.DELAY,'"]'),e).length):(e instanceof ao&&(e=e.attributes),!(e.is_delayed&&e.is_archived))},co.shouldCreateMessage=function(e){return e.retracted||!co.isEmptyMessage(e)},co.shouldCreateGroupchatMessage=function(e){return e.nick&&(co.shouldCreateMessage(e)||e.is_tombstone)},co.isEmptyMessage=function(e){return e instanceof ao&&(e=e.attributes),!(e.oob_url||e.file||e.is_encrypted&&e.plaintext||e.message)},co.isOnlyChatStateNotification=function(e){return e instanceof Element?null===e.querySelector("body")&&(null!==e.querySelector("active")||null!==e.querySelector("composing")||null!==e.querySelector("inactive")||null!==e.querySelector("paused")||null!==e.querySelector("gone")):(e instanceof ao&&(e=e.attributes),e.chat_state&&co.isEmptyMessage(e))},co.isOnlyMessageDeliveryReceipt=function(e){return e instanceof Element?null===e.querySelector("body")&&null!==e.querySelector("received"):(e instanceof ao&&(e=e.attributes),e.received&&co.isEmptyMessage(e))},co.isChatRoom=function(e){return e&&"chatroom"===e.get("type")},co.isErrorObject=function(e){return e instanceof Error},co.isErrorStanza=function(e){return!!es(e)&&"error"===e.getAttribute("type")},co.isForbiddenError=function(e){return!!es(e)&&qr()('error[type="auth"] forbidden[xmlns="'.concat(zs.NS.STANZAS,'"]'),e).length>0},co.isServiceUnavailableError=function(e){return!!es(e)&&qr()('error[type="cancel"] service-unavailable[xmlns="'.concat(zs.NS.STANZAS,'"]'),e).length>0},co.merge=function e(t,n){for(const i in n)s(t[i])?e(t[i],n[i]):t[i]=n[i]},co.getOuterWidth=function(e,t=!1){let n=e.offsetWidth;if(!t)return n;const s=window.getComputedStyle(e);return n+=parseInt(s.marginLeft?s.marginLeft:0,10)+parseInt(s.marginRight?s.marginRight:0,10),n},co.stringToElement=function(e){var t=document.createElement("div");return t.innerHTML=e,t.firstElementChild},co.matchesSelector=function(e,t){const n=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;return!!n&&n.call(e,t)},co.queryChildren=function(e,t){return Array.from(e.childNodes).filter((e=>co.matchesSelector(e,t)))},co.contains=function(e,t){const n=(e,n)=>e.get(n).toLowerCase().includes(t.toLowerCase());return function(t){if("object"==typeof e)return Object.keys(e).reduce(((e,s)=>e||n(t,s)),!1);if("string"==typeof e)return n(t,e);throw new TypeError("contains: wrong attribute type. Must be string or array.")}},co.isOfType=function(e,t){return t.get("type")==e},co.isInstance=function(e,t){return t instanceof e},co.getAttribute=function(e,t){return t.get(e)},co.contains.not=function(e,t){return function(n){return!co.contains(e,t)(n)}},co.rootContains=function(e,t){return e!==document||e.contains?e.contains?e.contains(t):window.HTMLElement.prototype.contains.call(e,t):document.head.contains(t)||document.body.contains(t)},co.createFragmentFromText=function(e){var t,n=document.createDocumentFragment(),s=document.createElement("body");for(s.innerHTML=e;t=s.firstChild;)n.appendChild(t);return n},co.isPersistableModel=function(e){return e.collection&&e.collection.browserStorage},co.getResolveablePromise=Et,co.getOpenPromise=Et,co.interpolate=function(e,t){return e.replace(/{{{([^{}]*)}}}/g,((e,n)=>{var s=t[n];return"string"==typeof s||"number"==typeof s?s:e}))},co.onMultipleEvents=function(e=[],t){let n=[];function s(s){n.push(s),e.length===n.length&&(t(n),n=[])}e.forEach((e=>e.object.on(e.event,s)))},co.safeSave=ho,co.siblingIndex=function(e){for(var t=0;e=e.previousElementSibling;t++);return t},co.getCurrentWord=function(e,t,n){t||(t=e.selectionEnd||void 0);let[s]=e.value.slice(0,t).split(/\s/).slice(-1);return n&&([s]=s.split(n).slice(-1)),s},co.isMentionBoundary=e=>"@"!==e&&RegExp("(\\p{Z}|\\p{P})","u").test(e),co.replaceCurrentWord=function(e,t){const n=e.selectionEnd||void 0,s=Br(e.value.slice(0,n).split(/\s/)),i=e.value,r=co.isMentionBoundary(s[0])?s[0]:"";e.value=i.slice(0,n-s.length)+r+"".concat(t," ")+i.slice(n);const o=n-s.length+t.length+1;e.selectionEnd=r?o+1:o},co.triggerEvent=function(e,t,n="Event",s=!0,i=!0){const r=document.createEvent(n);r.initEvent(t,s,i),e.dispatchEvent(r)},co.getSelectValues=function(e){const t=[],n=e&&e.options;for(var s=0,i=n.length;s("00"+e.toString(16)).slice(-2))).join("")},co.arrayBufferToString=function(e){return new TextDecoder("utf-8").decode(e)},co.stringToArrayBuffer=function(e){return new TextEncoder("utf-8").encode(e).buffer},co.arrayBufferToBase64=function(e){return btoa(new Uint8Array(e).reduce(((e,t)=>e+String.fromCharCode(t)),""))},co.base64ToArrayBuffer=function(e){const t=window.atob(e),n=t.length,s=new Uint8Array(n);for(let e=0;ee.setSelectionRange(t,t)),1),this.scrollTop=999999},co.getUniqueId=function(e){const t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return"string"==typeof e||"number"==typeof e?t+":"+e:t},co.httpToGeoUri=function(e,t){return e.replace(t.api.settings.get("geouri_regex"),"geo:$1,$2")},co.waitUntil=function(e,t=300,n=3){try{const t=e();if(t)return Promise.resolve(t)}catch(e){return Promise.reject(e)}const s=Et(),i=new Error,r=setInterval((function(){try{const t=e();t&&(fo(o,r),s.resolve(t))}catch(e){fo(o,r),s.reject(e)}}),n),o=setTimeout((function(){fo(o,r);const e="Wait until promise timed out: \n\n".concat(i.stack);console.trace(),as.error(e),s.reject(new Error(e))}),t);return s};const go=co;let mo,po={},vo={};const bo={allow_non_roster_messaging:!1,allow_url_history_change:!0,assets_path:"/dist",authentication:"login",auto_login:!1,auto_reconnect:!0,blacklisted_plugins:[],clear_cache_on_logout:!1,connection_options:{},credentials_url:null,discover_connection_methods:!0,geouri_regex:/https\:\/\/www.openstreetmap.org\/.*#map=[0-9]+\/([\-0-9.]+)\/([\-0-9.]+)\S*/g,geouri_replacement:"https://www.openstreetmap.org/?mlat=$1&mlon=$2#map=18/$1/$2",i18n:void 0,idle_presence_timeout:300,jid:void 0,keepalive:!0,loglevel:"info",locales:["af","ar","bg","ca","cs","da","de","el","eo","es","eu","en","fa","fi","fr","gl","he","hi","hu","id","it","ja","lt","nb","nl","mr","oc","pl","pt","pt_BR","ro","ru","sv","th","tr","uk","vi","zh_CN","zh_TW"],nickname:void 0,password:void 0,persistent_store:"localStorage",rid:void 0,root:window.document,sid:void 0,singleton:!1,strict_plugin_dependencies:!1,view_mode:"overlayed",websocket_url:void 0,whitelisted_plugins:[]};function yo(){var e;if(!So.bare_jid){const e="No JID to fetch user settings for";throw as.error(e),Error(e)}if(!(null===(e=mo)||void 0===e?void 0:e.fetched)){const e="converse.user-settings.".concat(So.bare_jid);mo=new ao({id:e}),Cr(mo,e),mo.fetched=mo.fetch({promise:!0})}return mo.fetched}async function _o(){return await yo(),mo}async function wo(e,t){return await yo(),mo.save(e,t)}const So={log:as,CONNECTION_STATUS:Bs,templates:{},promises:{initialized:Et()},STATUS_WEIGHTS:{offline:6,unavailable:5,xa:4,away:3,dnd:2,chat:1,online:1},ANONYMOUS:"anonymous",CLOSED:"closed",EXTERNAL:"external",LOGIN:"login",LOGOUT:"logout",OPENED:"opened",PREBIND:"prebind",STANZA_TIMEOUT:1e4,SUCCESS:"success",FAILURE:"failure",DEFAULT_IMAGE_TYPE:"image/svg+xml",DEFAULT_IMAGE:"PD94bWwgdmVyc2lvbj0iMS4wIj8+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCI+CiA8cmVjdCB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgZmlsbD0iIzU1NSIvPgogPGNpcmNsZSBjeD0iNjQiIGN5PSI0MSIgcj0iMjQiIGZpbGw9IiNmZmYiLz4KIDxwYXRoIGQ9Im0yOC41IDExMiB2LTEyIGMwLTEyIDEwLTI0IDI0LTI0IGgyMyBjMTQgMCAyNCAxMiAyNCAyNCB2MTIiIGZpbGw9IiNmZmYiLz4KPC9zdmc+Cg==",TIMEOUTS:{PAUSED:1e4,INACTIVE:9e4},INACTIVE:"inactive",ACTIVE:"active",COMPOSING:"composing",PAUSED:"paused",GONE:"gone",PRIVATE_CHAT_TYPE:"chatbox",CHATROOMS_TYPE:"chatroom",HEADLINES_TYPE:"headline",CONTROLBOX_TYPE:"controlbox",default_connection_options:{explicitResourceBinding:!0},router:new br,TimeoutError:xr,isTestEnv:()=>"montague.lit/http-bind"===po.bosh_service_url,getDefaultStore:jr,createStore:Ar,__:(...e)=>Zn.__(...e),___:e=>e};var xo=n(8734),Eo=n.n(xo),jo=n(7484),Ao=n.n(jo),Co=Math.max,ko=Math.min;const Oo=function(e,t,n){var i,r,o,a,c,l,u=0,d=!1,h=!1,f=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function g(t){var n=i,s=r;return i=r=void 0,u=t,a=e.apply(s,n)}function m(e){return u=e,c=setTimeout(v,t),d?g(e):a}function p(e){var n=e-l;return void 0===l||n>=t||n<0||h&&e-u>=o}function v(){var e=gt();if(p(e))return b(e);c=setTimeout(v,function(e){var n=t-(e-l);return h?ko(n,o-(e-u)):n}(e))}function b(e){return c=void 0,f&&i?g(e):(i=r=void 0,a)}function y(){var e=gt(),n=p(e);if(i=arguments,r=this,l=e,n){if(void 0===c)return m(l);if(h)return clearTimeout(c),c=setTimeout(v,t),g(l)}return void 0===c&&(c=setTimeout(v,t)),a}return t=xt(t)||0,s(n)&&(d=!!n.leading,o=(h="maxWait"in n)?Co(xt(n.maxWait)||0,t):o,f="trailing"in n?!!n.trailing:f),y.cancel=function(){void 0!==c&&clearTimeout(c),u=0,i=l=r=c=void 0},y.flush=function(){return void 0===c?a:b(gt())},y},To=function(e,t,n){t=Si(t,e);var s=null==(e=so(e,t))?e:e[xi(Br(t))];return null==s?void 0:Ze(s,e,n)},No=lt(To);var Io=n(7002);function Mo(e,t,n,s,...i){return"function"==typeof n&&(void 0===this.__super__&&(this.__super__=s),this.__super__[e]=n.bind(this)),t.apply(this,i)}class Ro{constructor(e,t){this.name=t,this.plugged=e,void 0===this.plugged.__super__?this.plugged.__super__={}:"string"==typeof this.plugged.__super__&&(this.plugged.__super__={__string__:this.plugged.__super__}),this.plugged.__super__[t]=this.plugged,this.plugins={},this.initialized_plugins=[]}_overrideAttribute(e,t){const n=t.overrides[e];if("function"==typeof n){const t={};t[this.name]=this.plugged;const s=this.plugged[e];this.plugged[e]=function(...i){return Mo.apply(this,[e,n,s,t,...i])}}else this.plugged[e]=n}_extendObject(e,t){e.prototype.__super__||(e.prototype.__super__={},e.prototype.__super__[this.name]=this.plugged);for(const[n,s]of Object.entries(t))if("events"===n)e.prototype[n]=Object.assign(s,e.prototype[n]);else if("function"==typeof s){const t={};t[this.name]=this.plugged;const i=e.prototype[n];e.prototype[n]=function(...e){return Mo.apply(this,[n,s,i,t,...e])}}else e.prototype[n]=s}loadPluginDependencies(e){var t;null===(t=e.dependencies)||void 0===t||t.forEach((t=>{const n=this.plugins[t];if(n){var s;if(null===(s=n.dependencies)||void 0===s?void 0:s.includes(e.__name__))throw'Found a circular dependency between the plugins "'+e.__name__+'" and "'+t+'"';this.initializePlugin(n)}else this.throwUndefinedDependencyError('Could not find dependency "'+t+'" for the plugin "'+e.__name__+"\". If it's needed, make sure it's loaded by require.js")}))}throwUndefinedDependencyError(e){if(this.plugged.strict_plugin_dependencies)throw e;console.warn?console.warn(e):console.log(e)}applyOverrides(e){Object.keys(e.overrides||{}).forEach((t=>{const n=e.overrides[t];"object"==typeof n?void 0===this.plugged[t]?this.throwUndefinedDependencyError('Plugin "'.concat(e.__name__,'" tried to override "').concat(t,"\" but it's not found.")):this._extendObject(this.plugged[t],n):this._overrideAttribute(t,e)}))}initializePlugin(e){var t;Object.keys(this.allowed_plugins).includes(e.__name__)&&(this.initialized_plugins.includes(e.__name__)||("boolean"==typeof e.enabled&&e.enabled||(null===(t=e.enabled)||void 0===t?void 0:t.call(e,this.plugged))||null==e.enabled)&&(Object.assign(e,this.properties),e.dependencies&&this.loadPluginDependencies(e),this.applyOverrides(e),"function"==typeof e.initialize&&e.initialize.bind(e)(this),this.initialized_plugins.push(e.__name__)))}registerPlugin(e,t){if(e in this.plugins)throw new Error("Error: Plugin name "+e+" is already taken");t.__name__=e,this.plugins[e]=t}initializePlugins(e={},t=[],n=[]){if(Object.keys(this.plugins).length){this.properties=e,this.allowed_plugins={};for(const[e,s]of Object.entries(this.plugins))t.length&&!t.includes(e)||n.includes(e)||(this.allowed_plugins[e]=s);Object.values(this.allowed_plugins).forEach((e=>this.initializePlugin(e)))}}}const Do=function(e,t,n){return void 0===n&&(n="pluginSocket"),void 0===t&&(t="plugged"),e[n]=new Ro(e,t),e};var zo=n(1063);const Lo=function(e,t,n,s){for(var i=-1,r=null==e?0:e.length;++i-1},Vo=function(e,t,n){for(var s=-1,i=null==e?0:e.length;++s=200&&(r=Gs,o=!1,t=new $s(t));e:for(;++it||r&&o&&c&&!a&&!l||s&&o&&c||!n&&c||!i)return 1;if(!s&&!r&&!l&&e=a?c:c*("desc"==n[s]?-1:1)}return e.index-t.index}(e,t,n)}))},ca=lt((function(e,t){if(null==e)return[];var n=t.length;return n>1&&ut(e,t[0],t[1])?t=[]:n>2&&ut(t[0],t[1],t[2])&&(t=[t[0]]),aa(e,Dr(t,1),[])})),la=Array.prototype.slice,ua=function(e,t){t||(t={}),this.preinitialize.apply(this,arguments),t.model&&(this.model=t.model),void 0!==t.comparator&&(this.comparator=t.comparator),this._reset(),this.initialize.apply(this,arguments),e&&this.reset(e,Us({silent:!0},t))};ua.extend=ir;const da={add:!0,remove:!0,merge:!0},ha={add:!0,remove:!1},fa=function(e,t,n){n=Math.min(Math.max(n,0),e.length);const s=Array(e.length-n),i=t.length;let r;for(r=0;rthis.length&&(s=this.length),s<0&&(s+=this.length+1);const i=[],r=[],o=[],a=[],c={},l=t.add,u=t.merge,d=t.remove;let h=!1;const f=this.comparator&&null==s&&!1!==t.sort,g=_n(this.comparator)?this.comparator:null;let m,p;for(p=0;pe!==i[t])),this.models.length=0,fa(this.models,i,0),this.length=this.models.length):r.length&&(f&&(h=!0),fa(this.models,r,null==s?this.length:s),this.length=this.models.length),h&&this.sort({silent:!0}),!t.silent){for(p=0;pe)){await Promise.all(this.models.filter(t).map((t=>new Promise((n=>{t.destroy(Object.assign(e,{success:n,error:(e,t)=>{console.error(t),n()}}))}))))),await this.browserStorage.clear(),this.reset()},reset:function(e,t){t=t?Hr(t):{};for(let e=0;et.matches(e),t)},every:function(e){return function(e,t,n){var s=ve(e)?Jo:Qo;return n&&ut(e,t,n)&&(t=void 0),s(e,Ti(t))}(this.models.map((e=>e.attributes)),e)},difference:function(e){return Wo(this.models,e)},max:function(){return Math.max.apply(Math,this.models)},min:function(){return Math.min.apply(Math,this.models)},drop:function(e=1){return this.models.slice(e)},some:function(e){return Di(this.models.map((e=>e.attributes)),e)},sortBy:function(e){return ca(this.models,_(e)?e:t=>_n(e)?t.get(e):t.matches(e))},isEmpty:function(){return Li(this.models)},keyBy:function(e){return sa(this.models,e)},each:function(e,t){return this.forEach(e,t)},forEach:function(e,t){return this.models.forEach(e,t)},includes:function(e){return this.models.includes(e)},size:function(){return this.models.length},countBy:function(e){return Uo(this.models,_(e)?e:t=>_n(e)?t.get(e):t.matches(e))},groupBy:function(e){return ea(this.models,_(e)?e:t=>_n(e)?t.get(e):t.matches(e))},indexOf:function(e){return na(this.models,e)},findLastIndex:function(e,t){return function(e,t,n){var s=null==e?0:e.length;if(!s)return-1;var i=s-1;return void 0!==n&&(i=Fi(n),i=n<0?Ko(s+i,0):Xo(i,s-1)),qo(e,Ti(t),i,!0)}(this.models,_(e)?e:t=>_n(e)?t.get(e):t.matches(e),t)},lastIndexOf:function(e){return function(e,t,n){var s=null==e?0:e.length;if(!s)return-1;var i=s;return void 0!==n&&(i=(i=Fi(n))<0?ia(s+i,0):ra(i,s-1)),t==t?function(e,t,n){for(var s=n+1;s--;)if(e[s]===t)return s;return s}(e,t,i):qo(e,Ho,i,!0)}(this.models,e)},findIndex:function(e){return function(e,t,n){var s=null==e?0:e.length;if(!s)return-1;var i=null==n?0:Fi(n);return i<0&&(i=Yo(s+i,0)),qo(e,Ti(t),i)}(this.models,_(e)?e:t=>_n(e)?t.get(e):t.matches(e))},last:function(){const e=null==this.models?0:this.models.length;return e?this.models[e-1]:void 0},head:function(){return this.models[0]},first:function(){return this.head()},map:function(e,t){return this.models.map(_(e)?e:t=>_n(e)?t.get(e):t.matches(e),t)},reduce:function(e,t){return this.models.reduce(e,t||this.models[0])},reduceRight:function(e,t){return this.models.reduceRight(e,t||this.models[0])},toArray:function(){return Array.from(this.models)},get:function(e){if(null!=e)return this._byId[e]||this._byId[this.modelId(this._isModel(e)?e.attributes:e)]||e.cid&&this._byId[e.cid]},has:function(e){return null!=this.get(e)},at:function(e){return e<0&&(e+=this.length),this.models[e]},where:function(e,t){return this[t?"find":"filter"](e)},findWhere:function(e){return this.where(e,!0)},find:function(e,t){const n=_(e)?e:t=>t.matches(e);return this.models.find(n,t)},sort:function(e){let t=this.comparator;if(!t)throw new Error("Cannot sort a set without a comparator");e||(e={});const n=t.length;return _(t)&&(t=t.bind(this)),1===n||_n(t)?this.models=this.sortBy(t):this.models.sort(t),e.silent||this.trigger("sort",this,e),this},pluck:function(e){return this.map(e+"")},fetch:function(e){const t=(e=Us({parse:!0},e)).success,n=this,s=e.promise&&rr();return e.success=function(i){const r=e.reset?"reset":"set";n[r](i,e),t&&t.call(e.context,n,i,e),s&&s.resolve(),n.trigger("sync",n,i,e)},ar(this,e),s||this.sync("read",this,e)},create:function(e,t){const n=(t=t?Hr(t):{}).wait,s=t.promise,i=s&&rr();if(!(e=this._prepareModel(e,t)))return!1;n||this.add(e,t);const r=this,o=t.success,a=t.error;return t.success=function(e,t,a){n&&r.add(e,a),o&&o.call(a.context,e,t,a),s&&i.resolve(e)},t.error=function(e,t,n){a&&a.call(n.context,e,t,n),s&&i.reject(t)},e.save(null,Object.assign(t,{promise:!1})),s?i:e},parse:function(e,t){return e},clone:function(){return new this.constructor(this.models,{model:this.model,comparator:this.comparator})},modelId:function(e){var t;return e[(null===(t=this.model.prototype)||void 0===t?void 0:t.idAttribute)||"id"]},values:function(){return new ma(this,pa)},keys:function(){return new ma(this,va)},entries:function(){return new ma(this,ba)},_reset:function(){this.length=0,this.models=[],this._byId={}},_prepareModel:function(e,t){if(this._isModel(e))return e.collection||(e.collection=this),e;(t=t?Hr(t):{}).collection=this;const n=new this.model(e,t);return n.validationError?(this.trigger("invalid",this,n.validationError,t),!1):n},_removeModels:function(e,t){const n=[];for(let s=0;se.getAttribute("href"))),o=i.map((e=>e.getAttribute("href")));0===r.length&&0===o.length?as.warn("Neither BOSH nor WebSocket connection methods have been specified with XEP-0156."):(Cc.settings.set("websocket_url",o.pop()),Cc.settings.set("bosh_service_url",r.pop()),this.service=Cc.settings.get("websocket_url")||Cc.settings.get("bosh_service_url"),this.setProtocol())}async discoverConnectionMethods(e){const t={mode:"cors",headers:{Accept:"application/xrd+xml, text/xml"}},n="https://".concat(e,"/.well-known/host-meta");let s;try{s=await fetch(n,t)}catch(e){return as.error("Failed to discover alternative connection methods at ".concat(n)),void as.error(e)}s.status>=200&&s.status<400?await this.onDomainDiscovered(s):as.warn("Could not discover XEP-0156 connection methods")}async connect(e,t,n){if(Cc.settings.get("discover_connection_methods")){const t=zs.getDomainFromJid(e);await this.discoverConnectionMethods(t)}super.connect(e,t,n||this.onConnectStatusChanged,59)}async reconnect(){const{__:e}=So;return as.debug("RECONNECTING: the connection has dropped, attempting to reconnect."),this.setConnectionStatus(zs.Status.RECONNECTING,e("The connection has dropped, attempting to reconnect.")),Cc.trigger("will-reconnect"),this.reconnecting=!0,await kc(),Cc.user.login()}async onConnected(e){delete this.reconnecting,this.flush(),await So.setUserJID(this.jid),await Cc.trigger("afterResourceBinding",e,{synchronous:!0}),e?Cc.trigger("reconnected"):Cc.trigger("connected")}setDisconnectionCause(e,t,n){void 0===e?(delete this.disconnection_cause,delete this.disconnection_reason):(void 0===this.disconnection_cause||n)&&(this.disconnection_cause=e,this.disconnection_reason=t)}setConnectionStatus(e,t){this.status=e,So.connfeedback.set({connection_status:e,message:t})}async finishDisconnection(){as.debug("DISCONNECTED"),delete this.reconnecting,this.reset(),kc(),await Tc(),delete So.connection,Cc.trigger("disconnected")}onDisconnected(){if(!Cc.settings.get("auto_reconnect"))return this.finishDisconnection();{const e=this.disconnection_reason;if(this.disconnection_cause===zs.Status.AUTHFAIL)return Cc.settings.get("credentials_url")||Cc.settings.get("authentication")===So.ANONYMOUS?Cc.connection.reconnect():this.finishDisconnection();if(this.disconnection_cause===So.LOGOUT||e===zs.ErrorCondition.NO_AUTH_MECH||"host-unknown"===e||"remote-connection-failed"===e)return this.finishDisconnection();Cc.connection.reconnect()}}onConnectStatusChanged(e,t){const{__:n}=So;var s;if(as.debug("Status changed to: ".concat(So.CONNECTION_STATUS[e])),e===zs.Status.ATTACHFAIL)this.setConnectionStatus(e),null===(s=this.worker_attach_promise)||void 0===s||s.resolve(!1);else if(e===zs.Status.CONNECTED||e===zs.Status.ATTACHED){var i,r;if((null===(i=this.worker_attach_promise)||void 0===i?void 0:i.isResolved)&&this.status===zs.Status.ATTACHED)return;this.setConnectionStatus(e),null===(r=this.worker_attach_promise)||void 0===r||r.resolve(!0),So.send_initial_presence=!0,this.setDisconnectionCause(),this.reconnecting?(as.debug(e===zs.Status.CONNECTED?"Reconnected":"Reattached"),this.onConnected(!0)):(as.debug(e===zs.Status.CONNECTED?"Connected":"Attached"),this.restored&&(So.send_initial_presence=!1),this.onConnected())}else if(e===zs.Status.DISCONNECTED)this.setDisconnectionCause(e,t),this.onDisconnected();else if(e===zs.Status.BINDREQUIRED)this.bind();else if(e===zs.Status.ERROR)this.setConnectionStatus(e,n("An error occurred while connecting to the chat server."));else if(e===zs.Status.CONNECTING)this.setConnectionStatus(e);else if(e===zs.Status.AUTHENTICATING)this.setConnectionStatus(e);else if(e===zs.Status.AUTHFAIL)t||(t=n("Your XMPP address and/or password is incorrect. Please try again.")),this.setConnectionStatus(e,t),this.setDisconnectionCause(e,t,!0),this.onDisconnected();else if(e===zs.Status.CONNFAIL){var o;let s=t;"host-unknown"===t||"remote-connection-failed"==t?s=n("Sorry, we could not connect to the XMPP host with domain: %1$s",'"'.concat(zs.getDomainFromJid(this.jid),'"')):void 0!==t&&t===(null==zs||null===(o=zs.ErrorCondition)||void 0===o?void 0:o.NO_AUTH_MECH)&&(s=n("The XMPP server did not offer a supported authentication mechanism")),this.setConnectionStatus(e,s),this.setDisconnectionCause(e,t)}else e===zs.Status.DISCONNECTING&&this.setDisconnectionCause(e,t)}isType(e){return"websocket"===e.toLowerCase()?this._proto instanceof zs.Websocket:"bosh"===e.toLowerCase()?zs.Bosh&&this._proto instanceof zs.Bosh:void 0}hasResumed(){var e;return(null===(e=Cc.settings.get("connection_options"))||void 0===e?void 0:e.worker)||this.isType("bosh")?So.connfeedback.get("connection_status")===zs.Status.ATTACHED:!this.do_bind}restoreWorkerSession(){return this.attach(this.onConnectStatusChanged),this.worker_attach_promise=Et(),this.worker_attach_promise}}class _a extends ya{constructor(e,t){super(e,t),this.sent_stanzas=[],this.IQ_stanzas=[],this.IQ_ids=[],this.features=zs.xmlHtmlNode('').firstChild,this._proto._processRequest=()=>{},this._proto._disconnect=()=>this._onDisconnectTimeout(),this._proto._onDisconnectTimeout=()=>{},this._proto._connect=()=>{this.connected=!0,this.mock=!0,this.jid="romeo@montague.lit/orchard",this._changeConnectStatus(zs.Status.BINDREQUIRED)}}_processRequest(){}sendIQ(e,t,n){es(e)||(e=e.nodeTree),this.IQ_stanzas.push(e);const s=super.sendIQ(e,t,n);return this.IQ_ids.push(s),s}send(e){return es(e)?this.sent_stanzas.push(e):this.sent_stanzas.push(e.nodeTree),super.send(e)}async bind(){await Cc.trigger("beforeResourceBinding",{synchronous:!0}),this.authenticated=!0,So.no_connection_on_bind||this._changeConnectStatus(zs.Status.CONNECTED)}}var wa,Sa,xa,Ea;const ja=globalThis.trustedTypes,Aa=ja?ja.createPolicy("lit-html",{createHTML:e=>e}):void 0,Ca="lit$".concat((Math.random()+"").slice(9),"$"),ka="?"+Ca,Oa="<".concat(ka,">"),Ta=document,Na=(e="")=>Ta.createComment(e),Ia=e=>null===e||"object"!=typeof e&&"function"!=typeof e,Ma=Array.isArray,Ra=e=>{var t;return Ma(e)||"function"==typeof(null===(t=e)||void 0===t?void 0:t[Symbol.iterator])},Da=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,za=/-->/g,La=/>/g,Pa=/>|[ \n \r](?:([^\s"'>=/]+)([ \n \r]*=[ \n \r]*(?:[^ \n \r"'`<>=]|("|')|))|$)/g,Fa=/'/g,Ba=/"/g,Ua=/^(?:script|style|textarea)$/i,qa=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),Ha=qa(1),$a=(qa(2),Symbol.for("lit-noChange")),Ga=Symbol.for("lit-nothing"),Va=new WeakMap,Wa=(e,t,n)=>{var s,i;const r=null!==(s=null==n?void 0:n.renderBefore)&&void 0!==s?s:t;let o=r._$litPart$;if(void 0===o){const e=null!==(i=null==n?void 0:n.renderBefore)&&void 0!==i?i:null;r._$litPart$=o=new Za(t.insertBefore(Na(),e),e,void 0,n)}return o.I(e),o},Ja=Ta.createTreeWalker(Ta,129,null,!1),Qa=(e,t)=>{const n=e.length-1,s=[];let i,r=2===t?"":"",o=Da;for(let t=0;t"===c[0]?(o=null!=i?i:Da,l=-1):void 0===c[1]?l=-2:(l=o.lastIndex-c[2].length,a=c[1],o=void 0===c[3]?Pa:'"'===c[3]?Ba:Fa):o===Ba||o===Fa?o=Pa:o===za||o===La?o=Da:(o=Pa,i=void 0);const d=o===Pa&&e[t+1].startsWith("/>")?" ":"";r+=o===Da?n+Oa:l>=0?(s.push(a),n.slice(0,l)+"$lit$"+n.slice(l)+Ca+d):n+Ca+(-2===l?(s.push(void 0),t):d)}const a=r+(e[n]||"")+(2===t?"":"");return[void 0!==Aa?Aa.createHTML(a):a,s]};class Ya{constructor({strings:e,_$litType$:t},n){let s;this.parts=[];let i=0,r=0;const o=e.length-1,a=this.parts,[c,l]=Qa(e,t);if(this.el=Ya.createElement(c,n),Ja.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(s=Ja.nextNode())&&a.length0){s.textContent=ja?ja.emptyScript:"";for(let n=0;n2||""!==n[0]||""!==n[1]?(this.H=Array(n.length-1).fill(Ga),this.strings=n):this.H=Ga}get tagName(){return this.element.tagName}I(e,t=this,n,s){const i=this.strings;let r=!1;if(void 0===i)e=Ka(this,e,t,0),r=!Ia(e)||e!==this.H&&e!==$a,r&&(this.H=e);else{const s=e;let o,a;for(e=i[0],o=0;oe:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const n of e.cssRules)t+=n.cssText;return(e=>new cc(e+"",ac))(t)})(e):e;var dc,hc,fc,gc;const mc={toAttribute(e,t){switch(t){case Boolean:e=e?"":null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=null!==e;break;case Number:n=null===e?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch(e){n=null}}return n}},pc=(e,t)=>t!==e&&(t==t||e==e),vc={attribute:!0,type:String,converter:mc,reflect:!1,hasChanged:pc};class bc extends HTMLElement{constructor(){super(),this.Πi=new Map,this.Πo=void 0,this.Πl=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this.Πh=null,this.u()}static addInitializer(e){var t;null!==(t=this.v)&&void 0!==t||(this.v=[]),this.v.push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,n)=>{const s=this.Πp(n,t);void 0!==s&&(this.Πm.set(s,n),e.push(s))})),e}static createProperty(e,t=vc){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const n="symbol"==typeof e?Symbol():"__"+e,s=this.getPropertyDescriptor(e,n,t);void 0!==s&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,t,n){return{get(){return this[t]},set(s){const i=this[e];this[t]=s,this.requestUpdate(e,i,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||vc}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),this.elementProperties=new Map(e.elementProperties),this.Πm=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const n of t)this.createProperty(n,e[n])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const n=new Set(e.flat(1/0).reverse());for(const e of n)t.unshift(uc(e))}else void 0!==e&&t.push(uc(e));return t}static Πp(e,t){const n=t.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof e?e.toLowerCase():void 0}u(){var e;this.Πg=new Promise((e=>this.enableUpdating=e)),this.L=new Map,this.Π_(),this.requestUpdate(),null===(e=this.constructor.v)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,n;(null!==(t=this.ΠU)&&void 0!==t?t:this.ΠU=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(n=e.hostConnected)||void 0===n||n.call(e))}removeController(e){var t;null===(t=this.ΠU)||void 0===t||t.splice(this.ΠU.indexOf(e)>>>0,1)}Π_(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this.Πi.set(t,this[t]),delete this[t])}))}createRenderRoot(){var e;const t=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return((e,t)=>{oc?e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):t.forEach((t=>{const n=document.createElement("style");n.textContent=t.cssText,e.appendChild(n)}))})(t,this.constructor.elementStyles),t}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this.ΠU)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)})),this.Πl&&(this.Πl(),this.Πo=this.Πl=void 0)}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this.ΠU)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)})),this.Πo=new Promise((e=>this.Πl=e))}attributeChangedCallback(e,t,n){this.K(e,n)}Πj(e,t,n=vc){var s,i;const r=this.constructor.Πp(e,n);if(void 0!==r&&!0===n.reflect){const o=(null!==(i=null===(s=n.converter)||void 0===s?void 0:s.toAttribute)&&void 0!==i?i:mc.toAttribute)(t,n.type);this.Πh=e,null==o?this.removeAttribute(r):this.setAttribute(r,o),this.Πh=null}}K(e,t){var n,s,i;const r=this.constructor,o=r.Πm.get(e);if(void 0!==o&&this.Πh!==o){const e=r.getPropertyOptions(o),a=e.converter,c=null!==(i=null!==(s=null===(n=a)||void 0===n?void 0:n.fromAttribute)&&void 0!==s?s:"function"==typeof a?a:null)&&void 0!==i?i:mc.fromAttribute;this.Πh=o,this[o]=c(t,e.type),this.Πh=null}}requestUpdate(e,t,n){let s=!0;void 0!==e&&(((n=n||this.constructor.getPropertyOptions(e)).hasChanged||pc)(this[e],t)?(this.L.has(e)||this.L.set(e,t),!0===n.reflect&&this.Πh!==e&&(void 0===this.Πk&&(this.Πk=new Map),this.Πk.set(e,n))):s=!1),!this.isUpdatePending&&s&&(this.Πg=this.Πq())}async Πq(){this.isUpdatePending=!0;try{for(await this.Πg;this.Πo;)await this.Πo}catch(e){Promise.reject(e)}const e=this.performUpdate();return null!=e&&await e,!this.isUpdatePending}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this.Πi&&(this.Πi.forEach(((e,t)=>this[t]=e)),this.Πi=void 0);let t=!1;const n=this.L;try{t=this.shouldUpdate(n),t?(this.willUpdate(n),null===(e=this.ΠU)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(n)):this.Π$()}catch(e){throw t=!1,this.Π$(),e}t&&this.E(n)}willUpdate(e){}E(e){var t;null===(t=this.ΠU)||void 0===t||t.forEach((e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}Π$(){this.L=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this.Πg}shouldUpdate(e){return!0}update(e){void 0!==this.Πk&&(this.Πk.forEach(((e,t)=>this.Πj(t,this[t],e))),this.Πk=void 0),this.Π$()}updated(e){}firstUpdated(e){}}var yc,_c,wc,Sc,xc,Ec;bc.finalized=!0,bc.shadowRootOptions={mode:"open"},null===(hc=(dc=globalThis).reactiveElementPlatformSupport)||void 0===hc||hc.call(dc,{ReactiveElement:bc}),(null!==(fc=(gc=globalThis).reactiveElementVersions)&&void 0!==fc?fc:gc.reactiveElementVersions=[]).push("1.0.0-rc.1"),(null!==(yc=(Ec=globalThis).litElementVersions)&&void 0!==yc?yc:Ec.litElementVersions=[]).push("3.0.0-rc.1");class jc extends bc{constructor(){super(...arguments),this.renderOptions={host:this},this.Φt=void 0}createRenderRoot(){var e,t;const n=super.createRenderRoot();return null!==(e=(t=this.renderOptions).renderBefore)&&void 0!==e||(t.renderBefore=n.firstChild),n}update(e){const t=this.render();super.update(e),this.Φt=Wa(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),null===(e=this.Φt)||void 0===e||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this.Φt)||void 0===e||e.setConnected(!1)}render(){return $a}}jc.finalized=!0,jc._$litElement$=!0,null===(wc=(_c=globalThis).litElementHydrateSupport)||void 0===wc||wc.call(_c,{LitElement:jc}),null===(xc=(Sc=globalThis).litElementPlatformSupport)||void 0===xc||xc.call(Sc,{LitElement:jc}),Ao().extend(Eo()),zs.addNamespace("CARBONS","urn:xmpp:carbons:2"),zs.addNamespace("CHATSTATES","http://jabber.org/protocol/chatstates"),zs.addNamespace("CSI","urn:xmpp:csi:0"),zs.addNamespace("DELAY","urn:xmpp:delay"),zs.addNamespace("FASTEN","urn:xmpp:fasten:0"),zs.addNamespace("FORWARD","urn:xmpp:forward:0"),zs.addNamespace("HINTS","urn:xmpp:hints"),zs.addNamespace("HTTPUPLOAD","urn:xmpp:http:upload:0"),zs.addNamespace("IDLE","urn:xmpp:idle:1"),zs.addNamespace("MAM","urn:xmpp:mam:2"),zs.addNamespace("MARKERS","urn:xmpp:chat-markers:0"),zs.addNamespace("MENTIONS","urn:xmpp:mmn:0"),zs.addNamespace("MESSAGE_CORRECT","urn:xmpp:message-correct:0"),zs.addNamespace("MODERATE","urn:xmpp:message-moderate:0"),zs.addNamespace("NICK","http://jabber.org/protocol/nick"),zs.addNamespace("OMEMO","eu.siacs.conversations.axolotl"),zs.addNamespace("OUTOFBAND","jabber:x:oob"),zs.addNamespace("PUBSUB","http://jabber.org/protocol/pubsub"),zs.addNamespace("RAI","urn:xmpp:rai:0"),zs.addNamespace("RECEIPTS","urn:xmpp:receipts"),zs.addNamespace("REFERENCE","urn:xmpp:reference:0"),zs.addNamespace("REGISTER","jabber:iq:register"),zs.addNamespace("RETRACT","urn:xmpp:message-retract:0"),zs.addNamespace("ROSTERX","http://jabber.org/protocol/rosterx"),zs.addNamespace("RSM","http://jabber.org/protocol/rsm"),zs.addNamespace("SID","urn:xmpp:sid:0"),zs.addNamespace("SPOILER","urn:xmpp:spoiler:0"),zs.addNamespace("STANZAS","urn:ietf:params:xml:ns:xmpp-stanzas"),zs.addNamespace("STYLING","urn:xmpp:styling:0"),zs.addNamespace("VCARD","vcard-temp"),zs.addNamespace("VCARDUPDATE","vcard-temp:x:update"),zs.addNamespace("XFORM","jabber:x:data"),zs.addNamespace("XHTML","http://www.w3.org/1999/xhtml");const Ac=["converse-adhoc","converse-bookmarks","converse-bosh","converse-caps","converse-carbons","converse-chat","converse-chatboxes","converse-disco","converse-emoji","converse-headlines","converse-mam","converse-muc","converse-ping","converse-pubsub","converse-roster","converse-smacks","converse-status","converse-vcard"];So.VERSION_NAME="v7.0.3dev",Object.assign(So,Hi),Do(So,"_converse","pluggable");const Cc=So.api={connection:{connected(){var e;return(null==So||null===(e=So.connection)||void 0===e?void 0:e.connected)&&!0},disconnect(){So.connection&&So.connection.disconnect()},async reconnect(){var e;const t=So.connfeedback.get("connection_status");if(Cc.settings.get("authentication")===So.ANONYMOUS&&(await kc(),await Tc()),t===zs.Status.CONNFAIL?Cc.connection.isType("websocket")&&Cc.settings.get("bosh_service_url")?(await So.setUserJID(So.bare_jid),So.connection._proto._doDisconnect(),So.connection._proto=new zs.Bosh(So.connection),So.connection.service=Cc.settings.get("bosh_service_url")):Cc.connection.isType("bosh")&&Cc.settings.get("websocket_url")&&(Cc.settings.get("authentication")===So.ANONYMOUS?await So.setUserJID(Cc.settings.get("jid")):await So.setUserJID(So.bare_jid),So.connection._proto._doDisconnect(),So.connection._proto=new zs.Websocket(So.connection),So.connection.service=Cc.settings.get("websocket_url")):t===zs.Status.AUTHFAIL&&Cc.settings.get("authentication")===So.ANONYMOUS&&await So.setUserJID(Cc.settings.get("jid")),!(null===(e=So.connection)||void 0===e?void 0:e.reconnecting))return So.connection.reconnect();So.connection.debouncedReconnect()},isType:e=>So.connection.isType(e)},async trigger(e){if(!So._events)return;const t=Array.from(arguments),n=t.pop();if(n&&n.synchronous){const n=So._events[e]||[],s=t.splice(1);await Promise.all(n.map((e=>e.callback.apply(e.ctx,s))))}else So.trigger.apply(So,arguments);const s=So.promises[e];void 0!==s&&s.resolve()},hook(e,t,n){const s=So._events[e]||[];if(s.length){const e=s.reduce(((e,n)=>e.then((e=>n.callback(t,e)))),Promise.resolve(n));return e.catch((e=>{throw as.error(e),e})),e}return n},user:{jid:()=>So.connection.jid,async login(e,t,n=!1){var s,i;if(e=e||So.jid,(!(null===(s=So.connection)||void 0===s?void 0:s.jid)||e&&!go.isSameDomain(So.connection.jid,e))&&await So.initConnection(),(null===(i=Cc.settings.get("connection_options"))||void 0===i?void 0:i.worker)&&await So.connection.restoreWorkerSession())return;e&&(e=await So.setUserJID(e));const r=So.pluggable.plugins["converse-bosh"];if(r&&r.enabled()){if(await So.restoreBOSHSession())return;if(Cc.settings.get("authentication")===So.PREBIND&&(!n||Cc.settings.get("auto_login")))return So.startNewPreboundBOSHSession()}t=t||Cc.settings.get("password"),async function(e,t){const{api:n}=So;n.settings.get("authentication")===So.LOGIN?e?Oc(e):So.api.settings.get("credentials_url")?Oc(await async function(){let e,t=0;for(;!e;){try{e=await Ic(t)}catch(e){as.error("Could not fetch login credentials"),as.error(e)}t=2e3}return e}()):So.jid&&(So.api.settings.get("password")||So.connection.pass)?Oc():!So.isTestEnv()&&"credentials"in navigator?Oc(await async function(){try{const e=await navigator.credentials.get({password:!0});if(e&&"password"==e.type&&go.isValidJID(e.id))return await So.setUserJID(e.id),{jid:e.id,password:e.password}}catch(e){as.error(e)}}()):!So.isTestEnv()&&as.warn("attemptNonPreboundSession: Couldn't find credentials to log in with"):![So.ANONYMOUS,So.EXTERNAL].includes(So.api.settings.get("authentication"))||t&&!So.api.settings.get("auto_login")||Oc()}(e&&t?{jid:e,password:t}:null,n)},async logout(){await Cc.trigger("beforeLogout",{synchronous:!0});const e=Et(),t=()=>{Object.keys(So.promises).forEach(kr),delete So.jid,Cc.trigger("logout"),e.resolve()};return So.connection.setDisconnectionCause(So.LOGOUT,void 0,!0),void 0!==So.connection?(Cc.listen.once("disconnected",(()=>t())),So.connection.disconnect()):t(),e},settings:{getModel:()=>_o(),async get(e,t){const n=await _o();return void 0===n.get(e)?t:n.get(e)},set(e,t){if(s(e))return wo(e,{promise:!0});{const n={};return n[e]=t,wo(n,{promise:!0})}},clear:()=>async function(){return await yo(),mo.clear()}()}},settings:{extend:e=>function(e){go.merge(bo,e);const t=Object.keys(Pr(e,Object.keys(bo))),n=Pr(po,t),s=Us(Pr(e,t),n);go.merge(vo,s),go.merge(So,s)}(e),update(e){return as.warn("The api.settings.update method has been deprecated and will be removed. Please use api.settings.extend instead."),this.extend(e)},get:e=>function(e){if(Object.keys(bo).includes(e))return vo[e]}(e),set(e,t){!function(e,t){const n={};s(e)?(Us(So,Pr(e,Object.keys(bo))),Us(vo,Pr(e,Object.keys(bo)))):"string"==typeof e&&(n[e]=t,Us(So,Pr(n,Object.keys(bo))),Us(vo,Pr(n,Object.keys(bo))))}(e,t)}},promises:{add(e,t=!0){(e=Array.isArray(e)?e:[e]).forEach((e=>{const n=Et();n.replace=t,So.promises[e]=n}))}},listen:{once:So.once.bind(So),on:So.on.bind(So),not:So.off.bind(So),stanza(e,t,n){_(t)?(n=t,t={}):t=t||{},So.connection.addHandler(n,t.ns,e,t.type,t.id,t.from,t)}},waitUntil(e){if(_(e))return go.waitUntil(e);{const t=So.promises[e];return void 0===t?null:t}},send(e){var t;return Cc.connection.connected()?("string"==typeof e?e=go.toStanza(e):(null===(t=e)||void 0===t?void 0:t.nodeTree)&&(e=e.nodeTree),"iq"===e.tagName?Cc.sendIQ(e):(So.connection.send(e),void Cc.trigger("send",e))):(as.warn("Not sending stanza because we're not connected!"),void as.warn(zs.serialize(e)))},sendIQ(e,t=So.STANZA_TIMEOUT,n=!0){var s,i;let r;return e=null!==(s=null===(i=e)||void 0===i?void 0:i.nodeTree)&&void 0!==s?s:e,["get","set"].includes(e.getAttribute("type"))?(t=t||So.STANZA_TIMEOUT,n?(r=new Promise(((n,s)=>So.connection.sendIQ(e,n,s,t))),r.catch((n=>{if(null===n)throw new xr("Timeout error after ".concat(t,"ms for the following IQ stanza: ").concat(zs.serialize(e)))}))):r=new Promise((n=>So.connection.sendIQ(e,n,n,t)))):(So.connection.sendIQ(e),r=Promise.resolve()),Cc.trigger("send",e),r}};async function kc(){return await So.api.trigger("beforeTearDown",{synchronous:!0}),window.removeEventListener("click",So.onUserActivity),window.removeEventListener("focus",So.onUserActivity),window.removeEventListener("keypress",So.onUserActivity),window.removeEventListener("mousemove",So.onUserActivity),window.removeEventListener(So.unloadevent,So.onUserActivity),window.clearInterval(So.everySecondTrigger),So.api.trigger("afterTearDown"),So}function Oc(e){if([So.ANONYMOUS,So.EXTERNAL].includes(So.api.settings.get("authentication"))){if(!So.jid)throw new Error("Config Error: when using anonymous login you need to provide the server's domain via the 'jid' option. Either when calling converse.initialize, or when calling _converse.api.user.login.");So.connection.reconnecting||So.connection.reset(),So.connection.connect(So.jid.toLowerCase())}else if(So.api.settings.get("authentication")===So.LOGIN){var t;const n=e?e.password:(null===(t=So.connection)||void 0===t?void 0:t.pass)||So.api.settings.get("password");if(!n){if(So.api.settings.get("auto_login"))throw new Error("autoLogin: If you use auto_login and authentication='login' then you also need to provide a password.");return So.connection.setDisconnectionCause(zs.Status.AUTHFAIL,void 0,!0),void So.api.connection.disconnect()}So.connection.reconnecting||So.connection.reset(),So.connection.connect(So.jid,n)}}function Tc(){var e;return null===(e=So.session)||void 0===e||e.destroy(),delete So.session,So.shouldClearCache()&&So.api.user.settings.clear(),So.api.trigger("clearSession",{synchronous:!0})}function Nc(e){e=So.session.get("jid")||e,So.api.settings.get("authentication")===So.ANONYMOUS||zs.getResourceFromJid(e)||(e=e.toLowerCase()+ya.generateResource()),So.jid=e,So.bare_jid=zs.getBareJidFromJid(e),So.resource=zs.getResourceFromJid(e),So.domain=zs.getDomainFromJid(e),So.session.save({jid:e,bare_jid:So.bare_jid,resource:So.resource,domain:So.domain,active:!0}),So.connection.jid=e}function Ic(e=0){return new Promise(Oo(((e,t)=>{const n=new XMLHttpRequest;n.open("GET",Cc.settings.get("credentials_url"),!0),n.setRequestHeader("Accept","application/json, text/javascript"),n.onload=()=>{if(n.status>=200&&n.status<400){const t=JSON.parse(n.responseText);So.setUserJID(t.jid).then((()=>{e({jid:t.jid,password:t.password})}))}else t(new Error("".concat(n.status,": ").concat(n.responseText)))},n.onerror=t,n.send()}),e))}So.isUniView=function(){return["mobile","fullscreen","embedded"].includes(Cc.settings.get("view_mode"))},So.shouldClearCache=()=>!So.config.get("trusted")||Cc.settings.get("clear_cache_on_logout")||So.isTestEnv(),So.initConnection=function(){const e=So.api;if(!e.settings.get("bosh_service_url")){if(e.settings.get("authentication")===So.PREBIND)throw new Error("authentication is set to 'prebind' but we don't have a BOSH connection");if(!e.settings.get("websocket_url"))throw new Error("initConnection: you must supply a value for either the bosh_service_url or websocket_url or both.")}const t=So.isTestEnv()?_a:ya;if(("WebSocket"in window||"MozWebSocket"in window)&&e.settings.get("websocket_url"))So.connection=new t(e.settings.get("websocket_url"),Object.assign(So.default_connection_options,e.settings.get("connection_options")));else{if(!e.settings.get("bosh_service_url"))throw new Error("initConnection: this browser does not support websockets and bosh_service_url wasn't specified.");So.connection=new t(e.settings.get("bosh_service_url"),Object.assign(So.default_connection_options,e.settings.get("connection_options"),{keepalive:e.settings.get("keepalive")}))}!function(){const e={};e[zs.LogLevel.DEBUG]="debug",e[zs.LogLevel.INFO]="info",e[zs.LogLevel.WARN]="warn",e[zs.LogLevel.ERROR]="error",e[zs.LogLevel.FATAL]="fatal",zs.log=(t,n)=>as.log(n,e[t]),zs.error=e=>as.error(e),So.connection.xmlInput=e=>as.debug(e.outerHTML,"color: darkgoldenrod"),So.connection.xmlOutput=e=>as.debug(e.outerHTML,"color: darkcyan")}(),e.trigger("connectionInitialized")},So.setUserJID=async function(e){return await async function(e){var t;const n=Cc.settings.get("connection_options").worker,s=zs.getBareJidFromJid(e).toLowerCase(),i="converse.session-".concat(s);(null===(t=So.session)||void 0===t?void 0:t.get("id"))!==i?(function(){if("sessionStorage"===Cc.settings.get("persistent_store"))return;if("BrowserExtLocal"===So.api.settings.get("persistent_store"))return Kn.localForage.defineDriver(Io.Z).then((()=>Kn.localForage.setDriver("webExtensionLocalStorage"))),void(So.storage.persistent=Kn.localForage);if("BrowserExtSync"===So.api.settings.get("persistent_store"))return Kn.localForage.defineDriver(zo.Z).then((()=>Kn.localForage.setDriver("webExtensionSyncStorage"))),void(So.storage.persistent=Kn.localForage);const e={name:So.isTestEnv()?"converse-test-persistent":"converse-persistent",storeName:So.bare_jid};"localStorage"===So.api.settings.get("persistent_store")?(e.description="localStorage instance",e.driver=[Kn.localForage.LOCALSTORAGE]):"IndexedDB"===So.api.settings.get("persistent_store")&&(e.description="indexedDB instance",e.driver=[Kn.localForage.INDEXEDDB]),So.storage.persistent=Kn.localForage.createInstance(e)}(),So.session=new ao({id:i}),Cr(So.session,i,n?"persistent":"session"),await new Promise((e=>So.session.fetch({success:e,error:e}))),!n&&So.session.get("active")&&(So.session.clear(),So.session.save({id:i})),Nc(e),So.api.trigger("userSessionInitialized")):Nc(e)}(e),So.api.trigger("setUserJID"),e},So.saveWindowState=function(e){let t;const n={focus:"visible",focusin:"visible",pageshow:"visible",blur:"hidden",focusout:"hidden",pagehide:"hidden"};t=(e=e||document.createEvent("Events")).type in n?n[e.type]:document.hidden?"hidden":"visible",So.windowState=t,Cc.trigger("windowStateChanged",{state:t})},So.ConnectionFeedback=ao.extend({defaults:{connection_status:zs.Status.DISCONNECTED,message:""},initialize(){this.on("change",(()=>Cc.trigger("connfeedback",So.connfeedback)))}});const Mc=window.converse||{};Object.assign(Mc,{CHAT_STATES:["active","composing","gone","inactive","paused"],keycodes:{TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESCAPE:27,LEFT_ARROW:37,UP_ARROW:38,RIGHT_ARROW:39,DOWN_ARROW:40,FORWARD_SLASH:47,AT:50,META:91,META_RIGHT:93},async initialize(e){if(await async function(){var e;await Cc.trigger("cleanup",{synchronous:!0}),So.router.history.stop(),document.removeEventListener("visibilitychange",So.saveWindowState),Cc.trigger("unregisteredGlobalEventHandlers"),null===(e=So.connection)||void 0===e||e.reset(),So.stopListening(),So.off(),So.promises.initialized.isResolved&&Cc.promises.add("initialized")}(),"onpagehide"in window?So.unloadevent="pagehide":"onbeforeunload"in window?So.unloadevent="beforeunload":"onunload"in window&&(So.unloadevent="unload"),function(e){po=e,vo={};const t=Pr(e,Object.keys(bo));Us(So,bo,t),Us(vo,bo,t)}(e),So.strict_plugin_dependencies=e.strict_plugin_dependencies,as.setLogLevel(Cc.settings.get("loglevel")),Cc.settings.get("authentication")===So.ANONYMOUS&&Cc.settings.get("auto_login")&&!Cc.settings.get("jid"))throw new Error("Config Error: you need to provide the server's domain via the 'jid' option when using anonymous authentication with auto_login.");So.router.route(/^converse\?loglevel=(debug|info|warn|error|fatal)$/,"loglevel",(e=>as.setLogLevel(e))),So.connfeedback=new So.ConnectionFeedback,So.send_initial_presence=!0,await async function(){await Kn.sessionStorageInitialized,So.storage={session:Kn.localForage.createInstance({name:So.isTestEnv()?"converse-test-session":"converse-session",description:"sessionStorage instance",driver:["sessionStorageWrapper"]})}}(),await async function(){const e="converse.client-config";So.config=new ao({id:e,trusted:!0}),So.config.browserStorage=Ar(e,"session"),await new Promise((e=>So.config.fetch({success:e,error:e}))),So.api.trigger("clientConfigInitialized")}(),await Zn.initialize(),function(){So.pluggable.initialized_plugins=[];const e=Ac.concat(So.api.settings.get("whitelisted_plugins"));So.api.settings.get("singleton")&&["converse-bookmarks","converse-controlbox","converse-headline","converse-register"].forEach((e=>So.api.settings.get("blacklisted_plugins").push(e))),So.pluggable.initializePlugins({_converse:So},e,So.api.settings.get("blacklisted_plugins")),So.api.trigger("pluginsInitialized")}(),document.addEventListener("visibilitychange",So.saveWindowState),So.saveWindowState({type:document.hidden?"blur":"focus"}),Cc.trigger("registeredGlobalEventHandlers");try{!History.started&&So.router.history.start()}catch(e){as.error(e)}Cc.settings.get("idle_presence_timeout")>0&&Cc.listen.on("addClientFeatures",(()=>Cc.disco.own.features.add(zs.NS.IDLE)));const t=So.pluggable.plugins;if((Cc.settings.get("auto_login")||Cc.settings.get("keepalive")&&No(t["converse-bosh"],"enabled"))&&await Cc.user.login(null,null,!0),Cc.trigger("initialized"),So.isTestEnv())return So},plugins:{add(e,t){if(t.__name__=e,void 0!==So.pluggable.plugins[e])throw new TypeError('Error: plugin with name "'.concat(e,'" has already been ')+"registered!");So.pluggable.plugins[e]=t}},env:{$build:Is,$iq:Rs,$msg:Ms,$pres:Ds,utils:go,Collection:ua,Model:ao,Promise,Strophe:zs,dayjs:Ao(),html:Ha,log:as,sizzle:qr(),sprintf:Xn.sprintf,u:go}});const Rc=Mc.env.utils;function Dc(e,t){Cc.send(Ms({to:e.getAttribute("from"),type:"error",id:e.getAttribute("id")}).c("error",{type:"cancel"}).c("not-allowed",{xmlns:"urn:ietf:params:xml:ns:xmpp-stanzas"}).up().c("text",{xmlns:"urn:ietf:params:xml:ns:xmpp-stanzas"}).t(t)),as.warn("Rejecting message stanza with the following reason: ".concat(t)),as.warn(e)}function zc(e,t,n,s){const i=Ms({from:So.connection.jid,id:Rc.getUniqueId(),to:e,type:s||"chat"}).c(n,{xmlns:zs.NS.MARKERS,id:t});Cc.send(i)}const{NS:Lc}=zs;class Pc extends Error{constructor(e,t){super(e,t),this.name="StanzaParseError",this.stanza=t}}function Fc(e,t){const n={},s=qr()('stanza-id[xmlns="'.concat(zs.NS.SID,'"]'),e).reduce(((e,t)=>(e["stanza_id ".concat(t.getAttribute("by"))]=t.getAttribute("id"),e)),{});Object.assign(n,s);const i=qr()('message > result[xmlns="'.concat(zs.NS.MAM,'"]'),t).pop();if(i){const e=t.getAttribute("from")||So.bare_jid;n["stanza_id ".concat(e)]=i.getAttribute("id")}const r=qr()('origin-id[xmlns="'.concat(zs.NS.SID,'"]'),e).pop();return r&&(n.origin_id=r.getAttribute("id")),n}function Bc(e,t){var n;const s=qr()('encrypted[xmlns="'.concat(zs.NS.OMEMO,'"]'),e).pop(),i={is_encrypted:!!s};if(!s||Cc.settings.get("clear_cache_on_logout"))return i;const r=s.querySelector("header");i.encrypted={device_id:r.getAttribute("sid")};const o=null===(n=t.omemo_store)||void 0===n?void 0:n.get("device_id"),a=o&&qr()('key[rid="'.concat(o,'"]'),s).pop();var c;return a&&Object.assign(i.encrypted,{iv:r.querySelector("iv").textContent,key:a.textContent,payload:(null===(c=s.querySelector("payload"))||void 0===c?void 0:c.textContent)||null,prekey:["true","1"].includes(a.getAttribute("prekey"))}),i}function Uc(e,t){const n=qr()('> apply-to[xmlns="'.concat(zs.NS.FASTEN,'"]'),e).pop();if(n){const e=n.getAttribute("id");if(qr()('> retract[xmlns="'.concat(zs.NS.RETRACT,'"]'),n).pop()){const n=qr()('delay[xmlns="'.concat(zs.NS.DELAY,'"]'),t).pop();return{editable:!1,retracted:n?Ao()(n.getAttribute("stamp")).toISOString():(new Date).toISOString(),retracted_id:e}}}else{const t=qr()('> retracted[xmlns="'.concat(zs.NS.RETRACT,'"]'),e).pop();if(t)return{editable:!1,is_tombstone:!0,retracted:t.getAttribute("stamp")}}return{}}function qc(e,t){const n=qr()('replace[xmlns="'.concat(zs.NS.MESSAGE_CORRECT,'"]'),e).pop();if(n){const e=n.getAttribute("id"),s=e;if(e){const n=qr()('delay[xmlns="'.concat(zs.NS.DELAY,'"]'),t).pop();return{msgid:s,replace_id:e,edited:n?Ao()(n.getAttribute("stamp")).toISOString():(new Date).toISOString()}}}return{}}function Hc(e){const t=qr()('spoiler[xmlns="'.concat(zs.NS.SPOILER,'"]'),e).pop();return{is_spoiler:!!t,spoiler_hint:null==t?void 0:t.textContent}}function $c(e){const t=qr()('x[xmlns="'.concat(zs.NS.OUTOFBAND,'"]'),e).pop();var n,s;return t?{oob_url:null===(n=t.querySelector("url"))||void 0===n?void 0:n.textContent,oob_desc:null===(s=t.querySelector("desc"))||void 0===s?void 0:s.textContent}:{}}function Gc(e){if("error"===e.getAttribute("type")){const t=e.querySelector("error"),n=qr()('text[xmlns="'.concat(zs.NS.STANZAS,'"]'),t).pop();return{is_error:!0,error_text:null==n?void 0:n.textContent,error_type:t.getAttribute("type"),error_condition:t.firstElementChild.nodeName}}return{}}function Vc(e){var t;const n=null===(t=e.querySelector("body"))||void 0===t?void 0:t.textContent;return qr()('reference[xmlns="'.concat(zs.NS.REFERENCE,'"]'),e).map((e=>{const t=e.getAttribute("begin"),s=e.getAttribute("end");return{begin:t,end:s,type:e.getAttribute("type"),value:n.slice(t,s),uri:e.getAttribute("uri")}}))}function Wc(e){const t=qr()('received[xmlns="'.concat(zs.NS.RECEIPTS,'"]'),e).pop();return null==t?void 0:t.getAttribute("id")}function Jc(e){const t=zs.NS.CARBONS;return qr()('message > received[xmlns="'.concat(t,'"]'),e).length>0||qr()('message > sent[xmlns="'.concat(t,'"]'),e).length>0}function Qc(e){var t;return null===(t=qr()('\n composing[xmlns="'.concat(Lc.CHATSTATES,'"],\n paused[xmlns="').concat(Lc.CHATSTATES,'"],\n inactive[xmlns="').concat(Lc.CHATSTATES,'"],\n active[xmlns="').concat(Lc.CHATSTATES,'"],\n gone[xmlns="').concat(Lc.CHATSTATES,'"]'),e).pop())||void 0===t?void 0:t.nodeName}function Yc(e,t){return"me"!==t.sender&&!t.is_carbon&&!t.is_archived&&qr()('request[xmlns="'.concat(zs.NS.RECEIPTS,'"]'),e).length}function Kc(e){if(qr()('message > forwarded[xmlns="'.concat(zs.NS.FORWARD,'"]'),e).length){Dc(e,"Forwarded messages not part of an encapsulating protocol are not supported");const t=e.getAttribute("from");return new Pc("Ignoring unencapsulated forwarded message from ".concat(t),e)}}function Xc(e){return qr()('\n acknowledged[xmlns="'.concat(zs.NS.MARKERS,'"],\n displayed[xmlns="').concat(zs.NS.MARKERS,'"],\n received[xmlns="').concat(zs.NS.MARKERS,'"]'),e).pop()}function Zc(e){return"headline"===e.getAttribute("type")}function el(e){if(qr()('mentions[xmlns="'.concat(zs.NS.MENTIONS,'"]'),e).pop())return!1;const t=e.getAttribute("from");return!("error"===e.getAttribute("type")||!t||t.includes("@"))}function tl(e){return!!qr()('message > result[xmlns="'.concat(zs.NS.MAM,'"]'),e).pop()}function nl(e){return e.getAttributeNames().reduce(((t,n)=>(t[n]=zs.xmlunescape(e.getAttribute(n)),t)),{})}const{Strophe:sl}=Mc.env;let il,rl;sl.addNamespace("ADHOC","http://jabber.org/protocol/commands");const ol={adhoc:{async getCommands(e){let t=[];try{n=await rl.disco.items(e,sl.NS.ADHOC),t=qr()('query[xmlns="'.concat(sl.NS.DISCO_ITEMS,'"][node="').concat(sl.NS.ADHOC,'"] item'),n).map(nl)}catch(t){null===t?as.error("Error: timeout while fetching ad-hoc commands for ".concat(e)):(as.error("Error while fetching ad-hoc commands for ".concat(e)),as.error(t))}var n;return t}}};Mc.plugins.add("converse-adhoc",{dependencies:["converse-disco"],initialize(){il=this._converse,rl=il.api,Object.assign(rl,ol)}});const al=ao.extend({initialize(){this.rosterContactAdded=Et()},async setRosterContact(e){const t=await Cc.contacts.get(e);t&&(this.contact=t,this.set("nickname",t.get("nickname")),this.rosterContactAdded.resolve())}});var cl=n(4009),ll=n.n(cl);const{Strophe:ul,sizzle:dl}=Mc.env;async function hl(e,t){var n,s,i,r,o,a;const c=Kc(e);if(c)return c;let l=e.getAttribute("to");const u=ul.getResourceFromJid(l);if(Cc.settings.get("filter_by_resource")&&u&&u!==t.resource)return new Pc("Ignoring incoming message intended for a different resource: ".concat(l),e);const d=e;let h=e.getAttribute("from")||t.bare_jid;if(Jc(e)){if(h!==t.bare_jid)return Dc(e,"Rejecting carbon from invalid JID"),new Pc("Rejecting carbon from invalid JID ".concat(l),e);{const t='[xmlns="'.concat(ul.NS.CARBONS,'"] > forwarded[xmlns="').concat(ul.NS.FORWARD,'"] > message');l=(e=dl(t,e).pop()).getAttribute("to"),h=e.getAttribute("from")}}const f=tl(e);if(f){if(h!==t.bare_jid)return new Pc("Invalid Stanza: alleged MAM message from ".concat(e.getAttribute("from")),e);{const t='[xmlns="'.concat(ul.NS.MAM,'"] > forwarded[xmlns="').concat(ul.NS.FORWARD,'"] > message');l=(e=dl(t,e).pop()).getAttribute("to"),h=e.getAttribute("from")}}const g=ul.getBareJidFromJid(h),m=g===t.bare_jid;if(m&&null===l)return new Pc("Don't know how to handle message stanza without 'to' attribute. ".concat(e.outerHTML),e);const p=Zc(e),v=el(e);let b,y;if(!p&&!v&&(y=m?ul.getBareJidFromJid(l):g,b=await Cc.contacts.get(y),void 0===b&&!Cc.settings.get("allow_non_roster_messaging")))return as.error(e),new Pc("Blocking messaging with a JID not in our roster because allow_non_roster_messaging is false.",e);const _=dl('delay[xmlns="'.concat(ul.NS.DELAY,'"]'),d).pop(),w=Xc(e),S=(new Date).toISOString();let x=Object.assign({contact_jid:y,is_archived:f,is_headline:p,is_server_message:v,body:null===(n=e.querySelector("body"))||void 0===n||null===(s=n.textContent)||void 0===s?void 0:s.trim(),chat_state:Qc(e),from:ul.getBareJidFromJid(e.getAttribute("from")),is_carbon:Jc(d),is_delayed:!!_,is_markable:!!dl('markable[xmlns="'.concat(ul.NS.MARKERS,'"]'),e).length,is_marker:!!w,is_unstyled:!!dl('unstyled[xmlns="'.concat(ul.NS.STYLING,'"]'),e).length,marker_id:w&&w.getAttribute("id"),msgid:e.getAttribute("id")||d.getAttribute("id"),nick:null===(i=b)||void 0===i||null===(r=i.attributes)||void 0===r?void 0:r.nickname,receipt_id:Wc(e),received:(new Date).toISOString(),references:Vc(e),sender:m?"me":"them",subject:null===(o=e.querySelector("subject"))||void 0===o?void 0:o.textContent,thread:null===(a=e.querySelector("thread"))||void 0===a?void 0:a.textContent,time:_?Ao()(_.getAttribute("stamp")).toISOString():S,to:e.getAttribute("to"),type:e.getAttribute("type")},Gc(e),$c(e),Hc(e),qc(e,d),Fc(e,d),Uc(e,d),Bc(e,t));if(x.is_archived){const n=d.getAttribute("from");if(n&&n!==t.bare_jid)return new Pc("Invalid Stanza: Forged MAM message from ".concat(n),e)}return await Cc.emojis.initialize(),x=Object.assign({message:x.body||x.error,is_only_emojis:!!x.body&&go.isOnlyEmojis(x.body),is_valid_receipt_request:Yc(e,x)},x),x.id=x.origin_id||x["stanza_id ".concat(x.from)]||go.getUniqueId(),Cc.hook("parseMessage",e,x)}const{Strophe:fl,$msg:gl}=Mc.env,ml=Mc.env.utils,pl=al.extend({defaults(){return{bookmarked:!1,chat_state:void 0,hidden:So.isUniView()&&!Cc.settings.get("singleton"),message_type:"chat",nickname:void 0,num_unread:0,time_sent:new Date(0).toISOString(),time_opened:this.get("time_opened")||(new Date).getTime(),type:So.PRIVATE_CHAT_TYPE,url:""}},async initialize(){this.initialized=Et(),al.prototype.initialize.apply(this,arguments);const e=this.get("jid");e&&(this.set({box_id:"box-".concat(e)}),this.initNotifications(),this.initMessages(),this.initUI(),this.get("type")===So.PRIVATE_CHAT_TYPE&&(this.presence=So.presences.findWhere({jid:e})||So.presences.create({jid:e}),await this.setRosterContact(e),this.presence.on("change:show",(e=>this.onPresenceChanged(e)))),this.on("change:chat_state",this.sendChatState,this),this.on("change:scrolled",(()=>!this.get("scrolled")&&this.clearUnreadMsgCounter())),await this.fetchMessages(),await Cc.trigger("chatBoxInitialized",this,{Synchronous:!0}),this.initialized.resolve())},getMessagesCollection:()=>new So.Messages,getMessagesCacheKey(){return"converse.messages-".concat(this.get("jid"),"-").concat(So.bare_jid)},initMessages(){this.messages=this.getMessagesCollection(),this.messages.fetched=Et(),this.messages.fetched.then((()=>{Cc.trigger("afterMessagesFetched",this)})),this.messages.chatbox=this,Cr(this.messages,this.getMessagesCacheKey()),this.listenTo(this.messages,"change:upload",(e=>{e.get("upload")===So.SUCCESS&&Cc.send(this.createMessageStanza(e))}))},initUI(){this.ui=new ao},initNotifications(){this.notifications=new ao},getNotificationsText(){var e,t,n;const{__:s}=So;return(null===(e=this.notifications)||void 0===e?void 0:e.get("chat_state"))===So.COMPOSING?s("%1$s is typing",this.getDisplayName()):(null===(t=this.notifications)||void 0===t?void 0:t.get("chat_state"))===So.PAUSED?s("%1$s has stopped typing",this.getDisplayName()):(null===(n=this.notifications)||void 0===n?void 0:n.get("chat_state"))===So.GONE?s("%1$s has gone away",this.getDisplayName()):""},afterMessagesFetched(e){this.most_recent_cached_message=e?this.getMostRecentMessage(e):null,Cc.trigger("afterMessagesFetched",this)},fetchMessages(){if(this.messages.fetched_flag)return void as.info("Not re-fetching messages for ".concat(this.get("jid")));this.most_recent_cached_message=null,this.messages.fetched_flag=!0;const e=this.messages.fetched.resolve;return this.messages.fetch({add:!0,success:t=>{this.afterMessagesFetched(t),e()},error:()=>{this.afterMessagesFetched(),e()}}),this.messages.fetched},async handleErrorMessageStanza(e){const{__:t}=So,n=await hl(e,So);if(!await this.shouldShowErrorMessage(n))return;const s=this.getMessageReferencedByError(n);if(s){const e={error:n.error,error_condition:n.error_condition,error_text:n.error_text,error_type:n.error_type,editable:!1};n.msgid===s.get("retraction_id")?(e.retraction_id=void 0,n.error||("forbidden"===n.error_condition?e.error=t("You're not allowed to retract your message."):e.error=t("Sorry, an error occurred while trying to retract your message."))):n.error||("forbidden"===n.error_condition?e.error=t("You're not allowed to send a message."):e.error=t("Sorry, an error occurred while trying to send your message.")),s.save(e)}else this.createMessage(n)},queueMessage(e){return this.msg_chain=(this.msg_chain||this.messages.fetched).then((()=>this.onMessage(e))).catch((e=>as.error(e))),this.msg_chain},async onMessage(e){if(e=await e,ml.isErrorObject(e))return e.stanza&&as.error(e.stanza),as.error(e.message);const t=this.getDuplicateMessage(e);if(t)this.updateMessage(t,e);else if(!this.handleReceipt(e)&&!this.handleChatMarker(e)&&!await this.handleRetraction(e)&&(this.setEditable(e,e.time),e.chat_state&&"them"===e.sender&&this.notifications.set("chat_state",e.chat_state),ml.shouldCreateMessage(e))){const t=this.handleCorrection(e)||await this.createMessage(e);this.notifications.set({chat_state:null}),this.handleUnreadMessage(t)}},async clearMessages(){try{await this.messages.clearStore()}catch(e){this.messages.trigger("reset"),as.error(e)}finally{delete this.msg_chain,delete this.messages.fetched_flag,this.messages.fetched=Et()}},async close(){Cc.connection.connected()&&(this.setChatState(So.INACTIVE),this.sendChatState());try{await new Promise(((e,t)=>this.destroy({success:e,error:(e,n)=>t(n)})))}catch(e){as.error(e)}finally{Cc.settings.get("clear_messages_on_reconnection")&&await this.clearMessages()}Cc.trigger("chatBoxClosed",this)},announceReconnection(){Cc.trigger("chatReconnected",this)},async onReconnection(){Cc.settings.get("clear_messages_on_reconnection")&&await this.clearMessages(),this.announceReconnection()},onPresenceChanged(e){const{__:t}=So,n=e.get("show"),s=this.getDisplayName();let i;"offline"===n?i=t("%1$s has gone offline",s):"away"===n?i=t("%1$s has gone away",s):"dnd"===n?i=t("%1$s is busy",s):"online"===n&&(i=t("%1$s is online",s)),i&&this.createMessage({message:i,type:"info"})},validate(e){if(!e.jid)return"Ignored ChatBox without JID";const t=Cc.settings.get("auto_join_rooms").map((e=>s(e)?e.jid:e)),n=Cc.settings.get("auto_join_private_chats").concat(t);if(Cc.settings.get("singleton")&&!n.includes(e.jid)&&!Cc.settings.get("auto_join_on_invite")){const t="".concat(e.jid," is not allowed because singleton is true and it's not being auto_joined");return as.warn(t),t}},getDisplayName(){return this.contact?this.contact.getDisplayName():this.vcard?this.vcard.getDisplayName():this.get("jid")},async createMessageFromError(e){e instanceof So.TimeoutError&&((await this.createMessage({type:"error",message:e.message,retry_event_id:e.retry_event_id})).error=e)},editEarlierMessage(){let e,t=this.messages.findLastIndex("correcting");if(t>=0)for(this.messages.at(t).save("correcting",!1);t>0;){t-=1;const n=this.messages.at(t);if(n.get("editable")){e=n;break}}e=e||this.messages.filter({sender:"me"}).reverse().find((e=>e.get("editable"))),e&&e.save("correcting",!0)},editLaterMessage(){let e,t=this.messages.findLastIndex("correcting");if(t>=0)for(this.messages.at(t).save("correcting",!1);t=0;t--){const n=e.at(t);if(n.get("type")===this.get("message_type"))return n}},getUpdatedMessageAttributes:(e,t)=>(({is_archived:e})=>({is_archived:e}))(t),updateMessage(e,t){const n=this.getUpdatedMessageAttributes(e,t);n&&e.save(n)},setChatState(e,t){return void 0!==this.chat_state_timeout&&(window.clearTimeout(this.chat_state_timeout),delete this.chat_state_timeout),e===So.COMPOSING?this.chat_state_timeout=window.setTimeout(this.setChatState.bind(this),So.TIMEOUTS.PAUSED,So.PAUSED):e===So.PAUSED&&(this.chat_state_timeout=window.setTimeout(this.setChatState.bind(this),So.TIMEOUTS.INACTIVE,So.INACTIVE)),this.set("chat_state",e,t),this},getMessageReferencedByError(e){const t=e.msgid;return t&&this.messages.models.find((e=>[e.get("msgid"),e.get("retraction_id")].includes(t)))},shouldShowErrorMessage(e){if(this.getMessageReferencedByError(e)||e.body)return!0},isSameUser:(e,t)=>ml.isSameBareJID(e,t),findDanglingRetraction(e){if(!e.origin_id||!this.messages.length)return null;if(this.messages.last().get("time")>e.time){const t=Array.from(this.messages.models);return t.reverse(),t.find((({attributes:t})=>t.retracted_id===e.origin_id&&t.from===e.from&&!t.moderated_by))}},async handleRetraction(e){const t=["retracted","retracted_id","editable"];if(e.retracted){if(e.is_tombstone)return!1;const n=this.messages.findWhere({origin_id:e.retracted_id,from:e.from});return n?(n.save(Pr(e,t)),!0):(e.dangling_retraction=!0,await this.createMessage(e),!0)}{const n=this.findDanglingRetraction(e);if(n){const s=Pr(n.attributes,t),i=Object.assign({dangling_retraction:!1},e,s);return delete i.id,n.save(i),!0}}return!1},handleCorrection(e){if(!e.replace_id||!e.from)return;const t=this.messages.findWhere({msgid:e.replace_id,from:e.from});if(!t)return;const n=t.get("older_versions")||{};return e.timee));return this.messages.models.find((e=>t.reduce(((t,n)=>t||function(e,t){return e===t||ii(e,t,oi(t))}(e.attributes,n)),!1)))},getOriginIdQueryAttrs:e=>e.origin_id&&{origin_id:e.origin_id,from:e.from},getStanzaIdQueryAttrs:e=>Object.keys(e).filter((e=>e.startsWith("stanza_id "))).map((t=>{const n=t.replace(/^stanza_id /,""),s={};return s["stanza_id ".concat(n)]=e[t],s})),getMessageBodyQueryAttrs(e){if(e.message&&e.msgid){const t={from:e.from,msgid:e.msgid};return e.is_encrypted||(t.message=e.message),t}},retractOwnMessage(e){this.sendRetractionMessage(e),e.save({retracted:(new Date).toISOString(),retracted_id:e.get("origin_id"),retraction_id:e.get("id"),is_ephemeral:!0,editable:!1})},sendRetractionMessage(e){const t=e.get("origin_id");if(!t)throw new Error("Can't retract message without a XEP-0359 Origin ID");const n=gl({id:ml.getUniqueId(),to:this.get("jid"),type:"chat"}).c("store",{xmlns:fl.NS.HINTS}).up().c("apply-to",{id:t,xmlns:fl.NS.FASTEN}).c("retract",{xmlns:fl.NS.RETRACT});return So.connection.send(n)},sendMarkerForLastMessage(e="displayed",t=!1){const n=Array.from(this.messages.models);n.reverse();const s=n.find((e=>"them"===e.get("sender")&&(t||e.get("is_markable"))));s&&this.sendMarkerForMessage(s,e,t)},sendMarkerForMessage(e,t="displayed",n=!1){e&&Cc.settings.get("send_chat_markers").includes(t)&&((null==e?void 0:e.get("is_markable"))||n)&&zc(fl.getBareJidFromJid(e.get("from")),e.get("msgid"),t,e.get("type"))},handleChatMarker(e){if(fl.getBareJidFromJid(e.to)!==So.bare_jid)return!1;if(e.is_markable)return!this.contact||e.is_archived||e.is_carbon||zc(e.from,e.msgid,"received"),!1;if(e.marker_id){const t=this.messages.findWhere({msgid:e.marker_id}),n="marker_".concat(e.marker);return t&&!t.get(n)&&t.save({field_name:(new Date).toISOString()}),!0}},sendReceiptStanza(e,t){const n=gl({from:So.connection.jid,id:ml.getUniqueId(),to:e,type:"chat"}).c("received",{xmlns:fl.NS.RECEIPTS,id:t}).up().c("store",{xmlns:fl.NS.HINTS}).up();Cc.send(n)},handleReceipt(e){if("them"===e.sender)if(e.is_valid_receipt_request)this.sendReceiptStanza(e.from,e.msgid);else if(e.receipt_id){const t=this.messages.findWhere({msgid:e.receipt_id});return t&&!t.get("received")&&t.save({received:(new Date).toISOString()}),!0}return!1},createMessageStanza(e){const t=gl({from:So.connection.jid,to:this.get("jid"),type:this.get("message_type"),id:e.get("edited")&&ml.getUniqueId()||e.get("msgid")}).c("body").t(e.get("message")).up().c(So.ACTIVE,{xmlns:fl.NS.CHATSTATES}).root();return"chat"===e.get("type")&&t.c("request",{xmlns:fl.NS.RECEIPTS}).root(),e.get("is_spoiler")&&(e.get("spoiler_hint")?t.c("spoiler",{xmlns:fl.NS.SPOILER},e.get("spoiler_hint")).root():t.c("spoiler",{xmlns:fl.NS.SPOILER}).root()),(e.get("references")||[]).forEach((e=>{const n={xmlns:fl.NS.REFERENCE,begin:e.begin,end:e.end,type:e.type};e.uri&&(n.uri=e.uri),t.c("reference",n).root()})),e.get("oob_url")&&t.c("x",{xmlns:fl.NS.OUTOFBAND}).c("url").t(e.get("oob_url")).root(),e.get("edited")&&t.c("replace",{xmlns:fl.NS.MESSAGE_CORRECT,id:e.get("msgid")}).root(),e.get("origin_id")&&t.c("origin-id",{xmlns:fl.NS.SID,id:e.get("origin_id")}).root(),t},getOutgoingMessageAttributes(e,t){const n=this.get("composing_spoiler"),s=ml.getUniqueId(),i=e?ml.httpToGeoUri(ml.shortnamesToUnicode(e),So):void 0;return{from:So.bare_jid,fullname:So.xmppstatus.get("fullname"),id:s,is_only_emojis:!!e&&ml.isOnlyEmojis(e),jid:this.get("jid"),message:i,msgid:s,nickname:this.get("nickname"),sender:"me",spoiler_hint:n?t:void 0,time:(new Date).toISOString(),type:this.get("message_type"),body:i,is_spoiler:n,origin_id:s}},setEditable(e,t){if(!e.is_headline&&!ml.isEmptyMessage(e)&&"me"===e.sender)if("all"===Cc.settings.get("allow_message_corrections"))e.editable=!(e.file||e.retracted||"oob_url"in e);else if("last"===Cc.settings.get("allow_message_corrections")&&t>this.get("time_sent")){this.set({time_sent:t});const n=this.messages.findWhere({editable:!0});n&&n.save({editable:!1}),e.editable=!(e.file||e.retracted||"oob_url"in e)}},async createMessage(e,t){return e.time=e.time||(new Date).toISOString(),await this.messages.fetched,this.messages.create(e,t)},async sendMessage(e,t){const n=this.getOutgoingMessageAttributes(e,t);let s=this.messages.findWhere("correcting");if(s){const e=s.get("older_versions")||{};e[s.get("time")]=s.get("message"),s.save({correcting:!1,edited:(new Date).toISOString(),message:n.message,older_versions:e,references:n.references,is_only_emojis:n.is_only_emojis,origin_id:ml.getUniqueId(),received:void 0})}else this.setEditable(n,(new Date).toISOString()),s=await this.createMessage(n);return Cc.send(this.createMessageStanza(s)),Cc.trigger("sendMessage",{chatbox:this,message:s}),s},sendChatState(){if(Cc.settings.get("send_chat_state_notifications")&&this.get("chat_state")){const e=Cc.settings.get("send_chat_state_notifications");if(Array.isArray(e)&&!e.includes(this.get("chat_state")))return;Cc.send(gl({id:ml.getUniqueId(),to:this.get("jid"),type:"chat"}).c(this.get("chat_state"),{xmlns:fl.NS.CHATSTATES}).up().c("no-store",{xmlns:fl.NS.HINTS}).up().c("no-permanent-store",{xmlns:fl.NS.HINTS}))}},async sendFiles(e){var t;const{__:n}=So,s=(await Cc.disco.features.get(fl.NS.HTTPUPLOAD,So.domain)).pop();if(!s)return void this.createMessage({message:n("Sorry, looks like file upload is not supported by your server."),type:"error",is_ephemeral:!0});const i=s.dataforms.where({FORM_TYPE:{value:fl.NS.HTTPUPLOAD,type:"hidden"}}).pop(),r=window.parseInt(null===(t=((null==i?void 0:i.attributes)||{})["max-file-size"])||void 0===t?void 0:t.value),o=null==s?void 0:s.id;o?Array.from(e).forEach((async e=>{if(!window.isNaN(r)&&window.parseInt(e.size)>r)return this.createMessage({message:n("The size of your file, %1$s, exceeds the maximum allowed by your server, which is %2$s.",e.name,ll()(r)),type:"error",is_ephemeral:!0});{const t=Object.assign(this.getOutgoingMessageAttributes(),{file:!0,progress:0,slot_request_url:o});this.setEditable(t,(new Date).toISOString());const n=await this.createMessage(t,{silent:!0});n.file=e,this.messages.trigger("add",n),n.getRequestSlotURL()}})):this.createMessage({message:n("Sorry, looks like file upload is not supported by your server."),type:"error",is_ephemeral:!0})},maybeShow(e){if(!So.isUniView())return ml.safeSave(this,{hidden:!1}),this.trigger("show"),this;{const t=e=>!e.get("hidden")&&e.get("jid")!==this.get("jid")&&"controlbox"!==e.get("id"),n=So.chatboxes.filter(t);(e||0===n.length)&&(n.forEach((e=>ml.safeSave(e,{hidden:!0}))),ml.safeSave(this,{hidden:!1}))}},isHidden(){return So.isUniView()&&this.get("hidden")||this.isScrolledUp()||"hidden"===So.windowState},handleUnreadMessage(e){if((null==e?void 0:e.get("body"))&&ml.isNewMessage(e))if("me"===e.get("sender"))this.model.set("scrolled",!1);else if(this.isHidden()||this.get("scrolled")){const t={num_unread:this.get("num_unread")+1};0===this.get("num_unread")&&(t.first_unread_id=e.get("id")),this.save(t)}else this.sendMarkerForMessage(e)},clearUnreadMsgCounter(){this.get("num_unread")>0&&this.sendMarkerForMessage(this.messages.last()),ml.safeSave(this,{num_unread:0})},isScrolledUp(){return this.get("scrolled")}}),vl=Mc.env.utils,{Strophe:bl}=Mc.env,yl={defaults:()=>({msgid:vl.getUniqueId(),time:(new Date).toISOString(),is_ephemeral:!1}),async initialize(){this.checkValidity()&&(this.initialized=Et(),"chat"===this.get("type")&&(al.prototype.initialize.apply(this,arguments),this.setRosterContact(bl.getBareJidFromJid(this.get("from")))),this.get("file")&&this.on("change:put",this.uploadFile,this),this.setTimerForEphemeralMessage(),await Cc.trigger("messageInitialized",this,{Synchronous:!0}),this.initialized.resolve())},setTimerForEphemeralMessage(){const e=()=>{this.ephemeral_timer=window.setTimeout(this.safeDestroy.bind(this),1e4)};return this.isEphemeral()?(e(),!0):(this.on("change:is_ephemeral",(()=>this.isEphemeral()?e():clearTimeout(this.ephemeral_timer))),!1)},checkValidity(){return 3!==Object.keys(this.attributes).length||(this.validationError="Empty message",this.safeDestroy(),!1)},mayBeRetracted(){const e="me"===this.get("sender"),t="cancel"!==this.get("error_type");return e&&t&&["all","own"].includes(Cc.settings.get("allow_message_retraction"))},safeDestroy(){try{this.destroy()}catch(e){as.error(e)}},isEphemeral(){return this.get("is_ephemeral")},getDisplayName(){return"groupchat"===this.get("type")?this.get("nick"):this.contact?this.contact.getDisplayName():this.vcard?this.vcard.getDisplayName():this.get("from")},getMessageText(){const{__:e}=So;return this.get("is_encrypted")?this.get("plaintext")||this.get("body")||e("Undecryptable OMEMO message"):this.get("message")},isMeCommand(){const e=this.getMessageText();return!!e&&e.startsWith("/me ")},sendSlotRequestStanza(){if(!this.file)return Promise.reject(new Error("file is undefined"));const e=Mc.env.$iq({from:So.jid,to:this.get("slot_request_url"),type:"get"}).c("request",{xmlns:bl.NS.HTTPUPLOAD,filename:this.file.name,size:this.file.size,"content-type":this.file.type});return Cc.sendIQ(e)},async getRequestSlotURL(){const{__:e}=So;let t;try{t=await this.sendSlotRequestStanza()}catch(t){return as.error(t),this.save({type:"error",message:e("Sorry, could not determine upload URL."),is_ephemeral:!0})}const n=t.querySelector("slot");if(!n)return this.save({type:"error",message:e("Sorry, could not determine file upload URL."),is_ephemeral:!0});this.save({get:n.querySelector("get").getAttribute("url"),put:n.querySelector("put").getAttribute("url")})},uploadFile(){const e=new XMLHttpRequest;e.onreadystatechange=()=>{e.readyState===XMLHttpRequest.DONE&&(as.info("Status: "+e.status),200===e.status||201===e.status?this.save({upload:So.SUCCESS,oob_url:this.get("get"),message:this.get("get")}):e.onerror())},e.upload.addEventListener("progress",(e=>{e.lengthComputable&&this.set("progress",e.loaded/e.total)}),!1),e.onerror=()=>{const{__:t}=So;let n;n=e.responseText?t('Sorry, could not succesfully upload your file. Your server’s response: "%1$s"',e.responseText):t("Sorry, could not succesfully upload your file."),this.save({type:"error",upload:So.FAILURE,message:n,is_ephemeral:!0})},e.open("PUT",this.get("put"),!0),e.setRequestHeader("Content-type",this.file.type),e.send(this.file)}},_l={chats:{async create(e,t){if("string"==typeof e){if(t&&!(null==t?void 0:t.fullname)){var n;const s=await Cc.contacts.get(e);t.fullname=null==s||null===(n=s.attributes)||void 0===n?void 0:n.fullname}return Cc.chats.get(e,t,!0)||void as.error("Could not open chatbox for JID: "+e)}return Array.isArray(e)?Promise.all(e.forEach((async n=>{var s;const i=await Cc.contacts.get(e);return t.fullname=null==i||null===(s=i.attributes)||void 0===s?void 0:s.fullname,Cc.chats.get(n,t,!0).maybeShow()}))):(as.error("chats.create: You need to provide at least one JID"),null)},async open(e,t,n){if("string"==typeof e){const s=await Cc.chats.get(e,t,!0);return s?s.maybeShow(n):s}if(Array.isArray(e))return Promise.all(e.map((e=>Cc.chats.get(e,t,!0).then((e=>e&&e.maybeShow(n))))).filter((e=>e)));const s="chats.open: You need to provide at least one JID";throw as.error(s),new Error(s)},async get(e,t={},n=!1){async function s(e){let s=await Cc.chatboxes.get(e);return!s&&n?s=await Cc.chatboxes.create(e,t,So.ChatBox):(s=s&&s.get("type")===So.PRIVATE_CHAT_TYPE?s:null,s&&Object.keys(t).length&&s.save(t)),s}return await Cc.waitUntil("chatBoxesFetched"),void 0===e?(await Cc.chatboxes.get()).filter((e=>e.get("type")===So.PRIVATE_CHAT_TYPE)):"string"==typeof e?s(e):Promise.all(e.map((e=>s(e))))}}},{Strophe:wl,sizzle:Sl,utils:xl}=Mc.env,El=Mc.env.utils;Mc.plugins.add("converse-chat",{dependencies:["converse-chatboxes","converse-disco"],initialize(){Object.assign(Cc,_l),Cc.settings.extend({allow_message_corrections:"all",allow_message_retraction:"all",allow_message_styling:!0,auto_join_private_chats:[],clear_messages_on_reconnection:!1,filter_by_resource:!1,send_chat_markers:["received","displayed","acknowledged"],send_chat_state_notifications:!0}),So.Message=al.extend(yl),So.Messages=ua.extend({model:So.Message,comparator:"time"}),So.ChatBox=pl,So.handleMessageStanza=async function(e){if(el(e)){const t=e.getAttribute("from");return as.info("handleMessageStanza: Ignoring incoming server message from JID: ".concat(t))}const t=await hl(e,So);if(El.isErrorObject(t))return t.stanza&&as.error(t.stanza),as.error(t.message);const n=!!Sl('body, encrypted[xmlns="'.concat(wl.NS.OMEMO,'"]'),e).length,s=await Cc.chats.get(t.contact_jid,{nickname:t.nick},n);await(null==s?void 0:s.queueMessage(t));const i={stanza:e,attrs:t,chatbox:s};Cc.trigger("message",i)},So.router.route("converse/chat?jid=:jid",(function(e){if(!xl.isValidJID(e))return as.warn('Invalid JID "'.concat(e,'" provided in URL fragment'));Cc.chats.open(e)})),Cc.listen.on("chatBoxesFetched",(function(){Cc.settings.get("auto_join_private_chats").forEach((e=>{So.chatboxes.where({jid:e}).length||("string"==typeof e?Cc.chats.open(e):as.error('Invalid jid criteria specified for "auto_join_private_chats"'))})),Cc.trigger("privateChatsAutoJoined")})),Cc.listen.on("presencesInitialized",(function(){So.connection.addHandler((e=>Sl('message > result[xmlns="'.concat(wl.NS.MAM,'"]'),e).pop()?(as.warn('Received a MAM message with type "chat".'),!0):(So.handleMessageStanza(e),!0)),null,"message","chat"),So.connection.addHandler((e=>(null!==e.getAttribute("type")||So.handleMessageStanza(e),!0)),wl.NS.RECEIPTS,"message"),So.connection.addHandler((e=>(async function(e){const t=wl.getBareJidFromJid(e.getAttribute("from"));if(xl.isSameBareJID(t,So.bare_jid))return;const n=await Cc.chatboxes.get(t);null==n||n.handleErrorMessageStanza(e)}(e),!0)),null,"message","error")})),Cc.listen.on("clearSession",(async()=>{if(So.shouldClearCache()){await Promise.all(So.chatboxes.map((e=>e.messages&&e.messages.clearStore({silent:!0}))));const e=e=>e.get("type")!==So.CONTROLBOX_TYPE;So.chatboxes.clearStore({silent:!0},e)}}))}});const{Strophe:jl}=Mc.env,Al=ao.extend({idAttribute:"jid",initialize(e,t){this.waitUntilFeaturesDiscovered=Et(),this.dataforms=new ua;let n="converse.dataforms-".concat(this.get("jid"));this.dataforms.browserStorage=So.createStore(n,"session"),this.features=new ua,n="converse.features-".concat(this.get("jid")),this.features.browserStorage=So.createStore(n,"session"),this.listenTo(this.features,"add",this.onFeatureAdded),this.fields=new ua,n="converse.fields-".concat(this.get("jid")),this.fields.browserStorage=So.createStore(n,"session"),this.listenTo(this.fields,"add",this.onFieldAdded),this.identities=new ua,n="converse.identities-".concat(this.get("jid")),this.identities.browserStorage=So.createStore(n,"session"),this.fetchFeatures(t),this.items=new So.DiscoEntities,n="converse.disco-items-".concat(this.get("jid")),this.items.browserStorage=So.createStore(n,"session"),this.items.fetch()},async getIdentity(e,t){return await this.waitUntilFeaturesDiscovered,this.identities.findWhere({category:e,type:t})},async hasFeature(e){if(await this.waitUntilFeaturesDiscovered,this.features.findWhere({var:e}))return this},onFeatureAdded(e){e.entity=this,Cc.trigger("serviceDiscovered",e)},onFieldAdded(e){e.entity=this,Cc.trigger("discoExtensionFieldDiscovered",e)},async fetchFeatures(e){if(e.ignore_cache)this.queryInfo();else{const e=this.features.browserStorage.name,t=await this.features.browserStorage.store.getItem(e);t&&0===t.length||null===t?this.queryInfo():(this.features.fetch({add:!0,success:()=>{this.waitUntilFeaturesDiscovered.resolve(this),this.trigger("featuresDiscovered")}}),this.identities.fetch({add:!0}))}},async queryInfo(){let e;try{e=await Cc.disco.info(this.get("jid"),null)}catch(e){return null===e?as.error("Timeout for disco#info query for ".concat(this.get("jid"))):as.error(e),void this.waitUntilFeaturesDiscovered.resolve(this)}this.onInfo(e)},onDiscoItems(e){qr()('query[xmlns="'.concat(jl.NS.DISCO_ITEMS,'"] item'),e).forEach((e=>{if(e.getAttribute("node"))return;const t=e.getAttribute("jid");if(void 0===this.items.get(t)){const e=So.disco_entities.get(t);e?this.items.add(e):this.items.create({jid:t})}}))},async queryForItems(){if(0===this.identities.where({category:"server"}).length)return;const e=await Cc.disco.items(this.get("jid"));this.onDiscoItems(e)},onInfo(e){Array.from(e.querySelectorAll("identity")).forEach((e=>{this.identities.create({category:e.getAttribute("category"),type:e.getAttribute("type"),name:e.getAttribute("name")})})),qr()('x[type="result"][xmlns="'.concat(jl.NS.XFORM,'"]'),e).forEach((e=>{const t={};qr()("field",e).forEach((e=>{var n;t[e.getAttribute("var")]={value:null===(n=e.querySelector("value"))||void 0===n?void 0:n.textContent,type:e.getAttribute("type")}})),this.dataforms.create(t)})),e.querySelector('feature[var="'.concat(jl.NS.DISCO_ITEMS,'"]'))&&this.queryForItems(),Array.from(e.querySelectorAll("feature")).forEach((t=>{this.features.create({var:t.getAttribute("var"),from:e.getAttribute("from")})})),qr()('x[type="result"][xmlns="jabber:x:data"] field',e).forEach((t=>{var n;this.fields.create({var:t.getAttribute("var"),value:null===(n=t.querySelector("value"))||void 0===n?void 0:n.textContent,from:e.getAttribute("from")})})),this.waitUntilFeaturesDiscovered.resolve(this),this.trigger("featuresDiscovered")}}),Cl=ua.extend({model:Al,fetchEntities(){return new Promise(((e,t)=>{this.fetch({add:!0,success:e,error(e,n){as.error(n),t(new Error("Could not fetch disco entities"))}})}))}}),{Strophe:kl,$iq:Ol}=Mc.env;async function Tl(){Cc.disco.own.identities.add("client","web","Converse"),Cc.disco.own.features.add(kl.NS.CHATSTATES),Cc.disco.own.features.add(kl.NS.DISCO_INFO),Cc.disco.own.features.add(kl.NS.ROSTERX),Cc.settings.get("message_carbons")&&Cc.disco.own.features.add(kl.NS.CARBONS),Cc.trigger("addClientFeatures"),So.connection.addHandler((e=>function(e){const t=e.getElementsByTagName("query")[0].getAttribute("node"),n={xmlns:kl.NS.DISCO_INFO};t&&(n.node=t);const s=Ol({type:"result",id:e.getAttribute("id")}),i=e.getAttribute("from");return null!==i&&s.attrs({to:i}),s.c("query",n),So.disco._identities.forEach((e=>{const t={category:e.category,type:e.type};e.name&&(t.name=e.name),e.lang&&(t["xml:lang"]=e.lang),s.c("identity",t).up()})),So.disco._features.forEach((e=>s.c("feature",{var:e}).up())),Cc.send(s.tree()),!0}(e)),kl.NS.DISCO_INFO,"iq","get",null,null),So.disco_entities=new So.DiscoEntities;const e="converse.disco-entities-".concat(So.bare_jid);So.disco_entities.browserStorage=So.createStore(e,"session");const t=await So.disco_entities.fetchEntities();0!==t.length&&t.get(So.domain)||So.disco_entities.create({jid:So.domain}),Cc.trigger("discoInitialized")}function Nl(){if(!So.stream_features){const e=kl.getBareJidFromJid(So.jid),t="converse.stream-features-".concat(e);Cc.promises.add("streamFeaturesAdded"),So.stream_features=new ua,So.stream_features.browserStorage=So.createStore(t,"session")}}function Il(){Cc.trigger("streamFeaturesAdded")}function Ml(){Nl(),Array.from(So.connection.features.childNodes).forEach((e=>{So.stream_features.create({name:e.nodeName,xmlns:e.getAttribute("xmlns")})})),Il()}const{Strophe:Rl,$iq:Dl}=Mc.env,zl={disco:{stream:{async getFeature(e,t){if(await Cc.waitUntil("streamFeaturesAdded"),!e||!t)throw new Error("name and xmlns need to be provided when calling disco.stream.getFeature");if(void 0!==So.stream_features||Cc.connection.connected())return So.stream_features.findWhere({name:e,xmlns:t});{const n="Tried to get feature ".concat(e," ").concat(t," but _converse.stream_features has been torn down");as.warn(n)}}},own:{identities:{add(e,t,n,s){for(var i=0;iSo.disco._identities},features:{add(e){for(var t=0;tSo.disco._features}},info(e,t){const n={xmlns:Rl.NS.DISCO_INFO};t&&(n.node=t);const s=Dl({from:So.connection.jid,to:e,type:"get"}).c("query",n);return Cc.sendIQ(s)},items(e,t){const n={xmlns:Rl.NS.DISCO_ITEMS};return t&&(n.node=t),Cc.sendIQ(Dl({from:So.connection.jid,to:e,type:"get"}).c("query",n))},entities:{async get(e,t=!1){if(await Cc.waitUntil("discoInitialized"),!e)return So.disco_entities;if(void 0===So.disco_entities&&!Cc.connection.connected()){const t="Tried to look up entity ".concat(e," but _converse.disco_entities has been torn down");return void as.warn(t)}const n=So.disco_entities.get(e);return n||!t?n:Cc.disco.entities.create(e)},create:(e,t)=>So.disco_entities.create({jid:e},t)},features:{async get(e,t){if(!t)throw new TypeError("You need to provide an entity JID");await Cc.waitUntil("discoInitialized");let n=await Cc.disco.entities.get(t,!0);if(void 0===So.disco_entities&&!Cc.connection.connected()){const n="Tried to get feature ".concat(e," for ").concat(t," but _converse.disco_entities has been torn down");return void as.warn(n)}n=await n.waitUntilFeaturesDiscovered;const i=[...n.items.map((t=>t.hasFeature(e))),n.hasFeature(e)];return(await Promise.all(i)).filter(s)}},supports:async(e,t)=>(await Cc.disco.features.get(e,t)).length>0,async refresh(e){if(!e)throw new TypeError("api.disco.refresh: You need to provide an entity JID");await Cc.waitUntil("discoInitialized");let t=await Cc.disco.entities.get(e);return t?(t.features.reset(),t.fields.reset(),t.identities.reset(),t.waitUntilFeaturesDiscovered.isPending||(t.waitUntilFeaturesDiscovered=Et()),t.queryInfo()):t=await Cc.disco.entities.create(e,{ignore_cache:!0}),t.waitUntilFeaturesDiscovered},refreshFeatures:e=>Cc.refresh(e),async getFeatures(e){if(!e)throw new TypeError("api.disco.getFeatures: You need to provide an entity JID");await Cc.waitUntil("discoInitialized");let t=await Cc.disco.entities.get(e,!0);return t=await t.waitUntilFeaturesDiscovered,t.features},async getFields(e){if(!e)throw new TypeError("api.disco.getFields: You need to provide an entity JID");await Cc.waitUntil("discoInitialized");let t=await Cc.disco.entities.get(e,!0);return t=await t.waitUntilFeaturesDiscovered,t.fields},async getIdentity(e,t,n){const s=await Cc.disco.entities.get(n,!0);if(void 0!==s||Cc.connection.connected())return s.getIdentity(e,t);{const t="Tried to look up category ".concat(e," for ").concat(n," but _converse.disco_entities has been torn down");as.warn(t)}}}},{Strophe:Ll}=Mc.env;Mc.plugins.add("converse-disco",{initialize(){Object.assign(Cc,zl),Cc.promises.add("discoInitialized"),Cc.promises.add("streamFeaturesAdded"),So.DiscoEntity=Al,So.DiscoEntities=Cl,So.disco={_identities:[],_features:[]},Cc.listen.on("userSessionInitialized",(async()=>{Nl(),So.connfeedback.get("connection_status")===Ll.Status.ATTACHED&&(await new Promise(((e,t)=>So.stream_features.fetch({success:e,error:t}))),Il())})),Cc.listen.on("beforeResourceBinding",Ml),Cc.listen.on("reconnected",Tl),Cc.listen.on("connected",Tl),Cc.listen.on("beforeTearDown",(async()=>{Cc.promises.add("streamFeaturesAdded"),So.stream_features&&(await So.stream_features.clearStore(),delete So.stream_features)})),Cc.listen.on("clearSession",(()=>{So.shouldClearCache()&&So.disco_entities&&(Array.from(So.disco_entities.models).forEach((e=>e.features.clearStore())),Array.from(So.disco_entities.models).forEach((e=>e.identities.clearStore())),Array.from(So.disco_entities.models).forEach((e=>e.dataforms.clearStore())),Array.from(So.disco_entities.models).forEach((e=>e.fields.clearStore())),So.disco_entities.clearStore(),delete So.disco_entities)}))}});const Pl=new RegExp("]*>.*?|]*>.*?|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|((\\s|^)(\\*\\\\0\\/\\*|\\*\\\\O\\/\\*|\\-___\\-|\\:'\\-\\)|'\\:\\-\\)|'\\:\\-D|\\>\\:\\-\\)|>\\:\\-\\)|'\\:\\-\\(|\\>\\:\\-\\(|>\\:\\-\\(|\\:'\\-\\(|O\\:\\-\\)|0\\:\\-3|0\\:\\-\\)|0;\\^\\)|O;\\-\\)|0;\\-\\)|O\\:\\-3|\\-__\\-|\\:\\-Þ|\\:\\-Þ|\\<\\/3|<\\/3|\\:'\\)|\\:\\-D|'\\:\\)|'\\=\\)|'\\:D|'\\=D|\\>\\:\\)|>\\:\\)|\\>;\\)|>;\\)|\\>\\=\\)|>\\=\\)|;\\-\\)|\\*\\-\\)|;\\-\\]|;\\^\\)|'\\:\\(|'\\=\\(|\\:\\-\\*|\\:\\^\\*|\\>\\:P|>\\:P|X\\-P|\\>\\:\\[|>\\:\\[|\\:\\-\\(|\\:\\-\\[|\\>\\:\\(|>\\:\\(|\\:'\\(|;\\-\\(|\\>\\.\\<|>\\.<|#\\-\\)|%\\-\\)|X\\-\\)|\\\\0\\/|\\\\O\\/|0\\:3|0\\:\\)|O\\:\\)|O\\=\\)|O\\:3|B\\-\\)|8\\-\\)|B\\-D|8\\-D|\\-_\\-|\\>\\:\\\\|>\\:\\\\|\\>\\:\\/|>\\:\\/|\\:\\-\\/|\\:\\-\\.|\\:\\-P|\\:Þ|\\:Þ|\\:\\-b|\\:\\-O|O_O|\\>\\:O|>\\:O|\\:\\-X|\\:\\-#|\\:\\-\\)|\\(y\\)|\\<3|<3|\\:D|\\=D|;\\)|\\*\\)|;\\]|;D|\\:\\*|\\=\\*|\\:\\(|\\:\\[|\\=\\(|\\:@|;\\(|D\\:|\\:\\$|\\=\\$|#\\)|%\\)|X\\)|B\\)|8\\)|\\:\\/|\\:\\\\|\\=\\/|\\=\\\\|\\:L|\\=L|\\:P|\\=P|\\:b|\\:O|\\:X|\\:#|\\=X|\\=#|\\:\\)|\\=\\]|\\=\\)|\\:\\])(?=\\s|$|[!,.?]))","gi"),Fl=/(?:\ud83d\udc68\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffc-\udfff]|\ud83d\udc68\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffd-\udfff]|\ud83d\udc68\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc68\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffd\udfff]|\ud83d\udc68\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffe]|\ud83d\udc69\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffc-\udfff]|\ud83d\udc69\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffc-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffd-\udfff]|\ud83d\udc69\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb\udffd-\udfff]|\ud83d\udc69\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc69\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb\udffc\udffe\udfff]|\ud83d\udc69\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffd\udfff]|\ud83d\udc69\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb-\udffd\udfff]|\ud83d\udc69\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[\udffb-\udffe]|\ud83d\udc69\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83d\udc69\ud83c[\udffb-\udffe]|\ud83e\uddd1\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffc\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffd\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udffe\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\ud83c\udfff\u200d\ud83e\udd1d\u200d\ud83e\uddd1\ud83c[\udffb-\udfff]|\ud83e\uddd1\u200d\ud83e\udd1d\u200d\ud83e\uddd1|\ud83d\udc6b\ud83c[\udffb-\udfff]|\ud83d\udc6c\ud83c[\udffb-\udfff]|\ud83d\udc6d\ud83c[\udffb-\udfff]|\ud83d[\udc6b-\udc6d])|(?:\ud83d[\udc68\udc69]|\ud83e\uddd1)(?:\ud83c[\udffb-\udfff])?\u200d(?:\u2695\ufe0f|\u2696\ufe0f|\u2708\ufe0f|\ud83c[\udf3e\udf73\udf93\udfa4\udfa8\udfeb\udfed]|\ud83d[\udcbb\udcbc\udd27\udd2c\ude80\ude92]|\ud83e[\uddaf-\uddb3\uddbc\uddbd])|(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75]|\u26f9)((?:\ud83c[\udffb-\udfff]|\ufe0f)\u200d[\u2640\u2642]\ufe0f)|(?:\ud83c[\udfc3\udfc4\udfca]|\ud83d[\udc6e\udc71\udc73\udc77\udc81\udc82\udc86\udc87\ude45-\ude47\ude4b\ude4d\ude4e\udea3\udeb4-\udeb6]|\ud83e[\udd26\udd35\udd37-\udd39\udd3d\udd3e\uddb8\uddb9\uddcd-\uddcf\uddd6-\udddd])(?:\ud83c[\udffb-\udfff])?\u200d[\u2640\u2642]\ufe0f|(?:\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83c\udff3\ufe0f\u200d\u26a7\ufe0f|\ud83c\udff3\ufe0f\u200d\ud83c\udf08|\ud83c\udff4\u200d\u2620\ufe0f|\ud83d\udc15\u200d\ud83e\uddba|\ud83d\udc41\u200d\ud83d\udde8|\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc6f\u200d\u2640\ufe0f|\ud83d\udc6f\u200d\u2642\ufe0f|\ud83e\udd3c\u200d\u2640\ufe0f|\ud83e\udd3c\u200d\u2642\ufe0f|\ud83e\uddde\u200d\u2640\ufe0f|\ud83e\uddde\u200d\u2642\ufe0f|\ud83e\udddf\u200d\u2640\ufe0f|\ud83e\udddf\u200d\u2642\ufe0f)|[#*0-9]\ufe0f?\u20e3|(?:[©®\u2122\u265f]\ufe0f)|(?:\ud83c[\udc04\udd70\udd71\udd7e\udd7f\ude02\ude1a\ude2f\ude37\udf21\udf24-\udf2c\udf36\udf7d\udf96\udf97\udf99-\udf9b\udf9e\udf9f\udfcd\udfce\udfd4-\udfdf\udff3\udff5\udff7]|\ud83d[\udc3f\udc41\udcfd\udd49\udd4a\udd6f\udd70\udd73\udd76-\udd79\udd87\udd8a-\udd8d\udda5\udda8\uddb1\uddb2\uddbc\uddc2-\uddc4\uddd1-\uddd3\udddc-\uddde\udde1\udde3\udde8\uddef\uddf3\uddfa\udecb\udecd-\udecf\udee0-\udee5\udee9\udef0\udef3]|[\u203c\u2049\u2139\u2194-\u2199\u21a9\u21aa\u231a\u231b\u2328\u23cf\u23ed-\u23ef\u23f1\u23f2\u23f8-\u23fa\u24c2\u25aa\u25ab\u25b6\u25c0\u25fb-\u25fe\u2600-\u2604\u260e\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262a\u262e\u262f\u2638-\u263a\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267b\u267f\u2692-\u2697\u2699\u269b\u269c\u26a0\u26a1\u26a7\u26aa\u26ab\u26b0\u26b1\u26bd\u26be\u26c4\u26c5\u26c8\u26cf\u26d1\u26d3\u26d4\u26e9\u26ea\u26f0-\u26f5\u26f8\u26fa\u26fd\u2702\u2708\u2709\u270f\u2712\u2714\u2716\u271d\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u2764\u27a1\u2934\u2935\u2b05-\u2b07\u2b1b\u2b1c\u2b50\u2b55\u3030\u303d\u3297\u3299])(?:\ufe0f|(?!\ufe0e))|(?:(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75\udd90]|[\u261d\u26f7\u26f9\u270c\u270d])(?:\ufe0f|(?!\ufe0e))|(?:\ud83c[\udf85\udfc2-\udfc4\udfc7\udfca]|\ud83d[\udc42\udc43\udc46-\udc50\udc66-\udc69\udc6e\udc70-\udc78\udc7c\udc81-\udc83\udc85-\udc87\udcaa\udd7a\udd95\udd96\ude45-\ude47\ude4b-\ude4f\udea3\udeb4-\udeb6\udec0\udecc]|\ud83e[\udd0f\udd18-\udd1c\udd1e\udd1f\udd26\udd30-\udd39\udd3d\udd3e\uddb5\uddb6\uddb8\uddb9\uddbb\uddcd-\uddcf\uddd1-\udddd]|[\u270a\u270b]))(?:\ud83c[\udffb-\udfff])?|(?:\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc65\udb40\udc6e\udb40\udc67\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc73\udb40\udc63\udb40\udc74\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc77\udb40\udc6c\udb40\udc73\udb40\udc7f|\ud83c\udde6\ud83c[\udde8-\uddec\uddee\uddf1\uddf2\uddf4\uddf6-\uddfa\uddfc\uddfd\uddff]|\ud83c\udde7\ud83c[\udde6\udde7\udde9-\uddef\uddf1-\uddf4\uddf6-\uddf9\uddfb\uddfc\uddfe\uddff]|\ud83c\udde8\ud83c[\udde6\udde8\udde9\uddeb-\uddee\uddf0-\uddf5\uddf7\uddfa-\uddff]|\ud83c\udde9\ud83c[\uddea\uddec\uddef\uddf0\uddf2\uddf4\uddff]|\ud83c\uddea\ud83c[\udde6\udde8\uddea\uddec\udded\uddf7-\uddfa]|\ud83c\uddeb\ud83c[\uddee-\uddf0\uddf2\uddf4\uddf7]|\ud83c\uddec\ud83c[\udde6\udde7\udde9-\uddee\uddf1-\uddf3\uddf5-\uddfa\uddfc\uddfe]|\ud83c\udded\ud83c[\uddf0\uddf2\uddf3\uddf7\uddf9\uddfa]|\ud83c\uddee\ud83c[\udde8-\uddea\uddf1-\uddf4\uddf6-\uddf9]|\ud83c\uddef\ud83c[\uddea\uddf2\uddf4\uddf5]|\ud83c\uddf0\ud83c[\uddea\uddec-\uddee\uddf2\uddf3\uddf5\uddf7\uddfc\uddfe\uddff]|\ud83c\uddf1\ud83c[\udde6-\udde8\uddee\uddf0\uddf7-\uddfb\uddfe]|\ud83c\uddf2\ud83c[\udde6\udde8-\udded\uddf0-\uddff]|\ud83c\uddf3\ud83c[\udde6\udde8\uddea-\uddec\uddee\uddf1\uddf4\uddf5\uddf7\uddfa\uddff]|\ud83c\uddf4\ud83c\uddf2|\ud83c\uddf5\ud83c[\udde6\uddea-\udded\uddf0-\uddf3\uddf7-\uddf9\uddfc\uddfe]|\ud83c\uddf6\ud83c\udde6|\ud83c\uddf7\ud83c[\uddea\uddf4\uddf8\uddfa\uddfc]|\ud83c\uddf8\ud83c[\udde6-\uddea\uddec-\uddf4\uddf7-\uddf9\uddfb\uddfd-\uddff]|\ud83c\uddf9\ud83c[\udde6\udde8\udde9\uddeb-\udded\uddef-\uddf4\uddf7\uddf9\uddfb\uddfc\uddff]|\ud83c\uddfa\ud83c[\udde6\uddec\uddf2\uddf3\uddf8\uddfe\uddff]|\ud83c\uddfb\ud83c[\udde6\udde8\uddea\uddec\uddee\uddf3\uddfa]|\ud83c\uddfc\ud83c[\uddeb\uddf8]|\ud83c\uddfd\ud83c\uddf0|\ud83c\uddfe\ud83c[\uddea\uddf9]|\ud83c\uddff\ud83c[\udde6\uddf2\uddfc]|\ud83c[\udccf\udd8e\udd91-\udd9a\udde6-\uddff\ude01\ude32-\ude36\ude38-\ude3a\ude50\ude51\udf00-\udf20\udf2d-\udf35\udf37-\udf7c\udf7e-\udf84\udf86-\udf93\udfa0-\udfc1\udfc5\udfc6\udfc8\udfc9\udfcf-\udfd3\udfe0-\udff0\udff4\udff8-\udfff]|\ud83d[\udc00-\udc3e\udc40\udc44\udc45\udc51-\udc65\udc6a\udc6f\udc79-\udc7b\udc7d-\udc80\udc84\udc88-\udca9\udcab-\udcfc\udcff-\udd3d\udd4b-\udd4e\udd50-\udd67\udda4\uddfb-\ude44\ude48-\ude4a\ude80-\udea2\udea4-\udeb3\udeb7-\udebf\udec1-\udec5\uded0-\uded2\uded5\udeeb\udeec\udef4-\udefa\udfe0-\udfeb]|\ud83e[\udd0d\udd0e\udd10-\udd17\udd1d\udd20-\udd25\udd27-\udd2f\udd3a\udd3c\udd3f-\udd45\udd47-\udd71\udd73-\udd76\udd7a-\udda2\udda5-\uddaa\uddae-\uddb4\uddb7\uddba\uddbc-\uddca\uddd0\uddde-\uddff\ude70-\ude73\ude78-\ude7a\ude80-\ude82\ude90-\ude95]|[\u23e9-\u23ec\u23f0\u23f3\u267e\u26ce\u2705\u2728\u274c\u274e\u2753-\u2755\u2795-\u2797\u27b0\u27bf\ue50a])|\ufe0f/g;function Bl(){const e=Hl(['','']);return Bl=function(){return e},e}function Ul(){const e=Hl(['','']);return Ul=function(){return e},e}function ql(){const e=Hl(['',""]);return ql=function(){return e},e}function Hl(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}const $l=Mc.env.utils;Mc.emojis={initialized:!1,initialized_promise:Et()};const Gl={"*\\0/*":"1f646","*\\O/*":"1f646","-___-":"1f611",":'-)":"1f602","':-)":"1f605","':-D":"1f605",">:-)":"1f606","':-(":"1f613",">:-(":"1f620",":'-(":"1f622","O:-)":"1f607","0:-3":"1f607","0:-)":"1f607","0;^)":"1f607","O;-)":"1f607","0;-)":"1f607","O:-3":"1f607","-__-":"1f611",":-Þ":"1f61b",":)":"1f606",">;)":"1f606",">=)":"1f606",";-)":"1f609","*-)":"1f609",";-]":"1f609",";^)":"1f609","':(":"1f613","'=(":"1f613",":-*":"1f618",":^*":"1f618",">:P":"1f61c","X-P":"1f61c",">:[":"1f61e",":-(":"1f61e",":-[":"1f61e",">:(":"1f620",":'(":"1f622",";-(":"1f622",">.<":"1f623","#-)":"1f635","%-)":"1f635","X-)":"1f635","\\0/":"1f646","\\O/":"1f646","0:3":"1f607","0:)":"1f607","O:)":"1f607","O=)":"1f607","O:3":"1f607","B-)":"1f60e","8-)":"1f60e","B-D":"1f60e","8-D":"1f60e","-_-":"1f611",">:\\":"1f615",">:/":"1f615",":-/":"1f615",":-.":"1f615",":-P":"1f61b",":Þ":"1f61b",":-b":"1f61b",":-O":"1f62e",O_O:"1f62e",">:O":"1f62e",":-X":"1f636",":-#":"1f636",":-)":"1f642","(y)":"1f44d","<3":"2764",":D":"1f603","=D":"1f603",";)":"1f609","*)":"1f609",";]":"1f609",";D":"1f609",":*":"1f618","=*":"1f618",":(":"1f61e",":[":"1f61e","=(":"1f61e",":@":"1f620",";(":"1f622","D:":"1f628",":$":"1f633","=$":"1f633","#)":"1f635","%)":"1f635","X)":"1f635","B)":"1f60e","8)":"1f60e",":/":"1f615",":\\":"1f615","=/":"1f615","=\\":"1f615",":L":"1f615","=L":"1f615",":P":"1f61b","=P":"1f61b",":b":"1f61b",":O":"1f62e",":X":"1f636",":#":"1f636","=X":"1f636","=#":"1f636",":)":"1f642","=]":"1f642","=)":"1f642",":]":"1f642"};function Vl(e){if(e.indexOf("-")>-1){const t=[],n=e.split("-");for(let e=0;e=65536&&s<=1114111){const e=Math.floor((s-65536)/1024)+55296,t=(s-65536)%1024+56320;s=String.fromCharCode(e)+String.fromCharCode(t)}else s=String.fromCharCode(s);t.push(s)}return t.join("")}return function(e){let t="string"==typeof e?parseInt(e,16):e;return t<65536?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t)))}(e)}function Wl(e){return e.replace(Pl,((e,t,n,s)=>void 0!==s&&""!==s&&$l.unescapeHTML(s)in Gl?(s=$l.unescapeHTML(s),n+Vl(Gl[s].toUpperCase())):e))}function Jl(e,t={unicode_only:!1,add_title_wrapper:!1}){const n=e.emoji,s=e.shortname;if(n){if(t.unicode_only)return n;if(Cc.settings.get("use_system_emojis"))return t.add_title_wrapper&&s?Ha(ql(),s,n):n;{const t=Cc.settings.get("emoji_image_path");return Ha(Ul(),s,n,t,e.cp)}}return t.unicode_only?s:Ha(Bl(),s,s,Mc.emojis.by_sn[s].url)}function Ql(e){if(!Mc.emojis.initialized)throw new Error("getShortnameReferences called before emojis are initialized. To avoid this problem, first await the converse.emojis.initilaized_promise.");return[...e.matchAll(Mc.emojis.shortnames_regex)].filter((e=>e[0].length>0)).map((e=>{const t=Mc.emojis.by_sn[e[0]].cp;return{cp:t,begin:e.index,end:e.index+e[0].length,shortname:e[0],emoji:t?Vl(t):null}}))}function Yl(e){const t=[];return function(e,n){const s=/\uFE0F/g,i=String.fromCharCode(8205);String(e).replace(Fl,((e,n,r)=>{const o=function(e){const t=[];let n=0,s=0;for(;s{var i;t.push({begin:s,cp:e,emoji:n,end:s+n.length,shortname:(null===(i=$l.getEmojisByAtrribute("cp")[e])||void 0===i?void 0:i.sn)||""})})(o,e,r)}))}(e),t}Mc.plugins.add("converse-emoji",{initialize(){const{___:e}=So;Cc.settings.extend({emoji_image_path:"https://twemoji.maxcdn.com/v/12.1.6/",emoji_categories:{smileys:":grinning:",people:":thumbsup:",activity:":soccer:",travel:":motorcycle:",objects:":bomb:",nature:":rainbow:",food:":hotdog:",symbols:":musical_note:",flags:":flag_ac:",custom:null},emoji_category_labels:{smileys:e("Smileys and emotions"),people:e("People"),activity:e("Activities"),travel:e("Travel"),objects:e("Objects"),nature:e("Animals and nature"),food:e("Food and drink"),symbols:e("Symbols"),flags:e("Flags"),custom:e("Stickers")}}),So.EmojiPicker=ao.extend({defaults:{current_category:"smileys",current_skintone:"",scroll_position:0}});const t={};Object.assign($l,{shortnamesToEmojis:(e,t={unicode_only:!1,add_title_wrapper:!1})=>function(e,t){let n=[e];return[...Ql(e),...Yl(e)].sort(((e,t)=>t.begin-e.begin)).forEach((e=>{const s=n.shift(),i=Jl(e,t);n="string"==typeof i?[s.slice(0,e.begin)+i+s.slice(e.end),...n]:[s.slice(0,e.begin),i,s.slice(e.end),...n]})),n}(e=Wl(e),t),shortnamesToUnicode:e=>$l.shortnamesToEmojis(e,{unicode_only:!0})[0],isOnlyEmojis(e){const t=e.trim().split(/\s+/);return!(0===t.length||t.length>3)&&t.filter((e=>{const t=Yl($l.shortnamesToUnicode(e));return 1===t.length&&(e===t[0].shortname||e===t[0].emoji)})).length===t.length},getEmojisByAtrribute(e){if(t[e])return t[e];if("category"===e)return Mc.emojis.json;const n=Mc.emojis.list.map((t=>t[e])).filter(((e,t,n)=>n.indexOf(e)==t));return t[e]={},n.forEach((n=>t[e][n]=Mc.emojis.list.find((t=>t[e]===n)))),t[e]}}),Object.assign(Cc,{emojis:{async initialize(){if(!Mc.emojis.initialized){Mc.emojis.initialized=!0;const{default:t}=await n.e(4610).then(n.t.bind(n,7530,19));Mc.emojis.json=t,Mc.emojis.by_sn=Object.keys(t).reduce(((e,n)=>Object.assign(e,t[n])),{}),Mc.emojis.list=Object.values(Mc.emojis.by_sn),Mc.emojis.list.sort(((e,t)=>e.snt.sn?1:0)),Mc.emojis.shortnames=Mc.emojis.list.map((e=>e.sn));const s=()=>Mc.emojis.shortnames.map((e=>e.replace(/[+]/g,"\\$&"))).join("|");Mc.emojis.shortnames_regex=new RegExp(s(),"gi"),Mc.emojis.toned=(Mc.emojis.toned||(Mc.emojis.toned=(e=Object.values(Mc.emojis.json.people).filter((e=>e.sn.includes("_tone"))).map((e=>e.sn.replace(/_tone[1-5]/,""))),[...new Set(e)])),Mc.emojis.toned),Mc.emojis.initialized_promise.resolve()}var e;return Mc.emojis.initialized_promise}}})}});const Kl={initialize(){this.checkValidity()&&(this.get("file")&&this.on("change:put",this.uploadFile,this),this.setTimerForEphemeralMessage()||this.setOccupant(),Cc.trigger("chatRoomMessageInitialized",this))},mayBeModerated(){return["all","moderator"].includes(Cc.settings.get("allow_message_retraction"))&&this.collection.chatbox.canModerateMessages()},checkValidity(){const e=So.Message.prototype.checkValidity.call(this);return!e&&this.collection.chatbox.debouncedRejoin(),e},onOccupantRemoved(){var e;this.stopListening(this.occupant),delete this.occupant;const t=null==this||null===(e=this.collection)||void 0===e?void 0:e.chatbox;if(!t)return as.error("Could not get collection.chatbox for message: ".concat(JSON.stringify(this.toJSON())));this.listenTo(t.occupants,"add",this.onOccupantAdded)},onOccupantAdded(e){if(e.get("nick")===zs.getResourceFromJid(this.get("from"))){var t;this.occupant=e,this.trigger("occupantAdded"),this.listenTo(this.occupant,"destroy",this.onOccupantRemoved);const n=null==this||null===(t=this.collection)||void 0===t?void 0:t.chatbox;if(!n)return as.error("Could not get collection.chatbox for message: ".concat(JSON.stringify(this.toJSON())));this.stopListening(n.occupants,"add",this.onOccupantAdded)}},setOccupant(){var e;if("groupchat"!==this.get("type"))return;const t=null==this||null===(e=this.collection)||void 0===e?void 0:e.chatbox;if(!t)return as.error("Could not get collection.chatbox for message: ".concat(JSON.stringify(this.toJSON())));const n=zs.getResourceFromJid(this.get("from"));if(this.occupant=t.occupants.findWhere({nick:n}),!this.occupant&&Cc.settings.get("muc_send_probes")){this.occupant=t.occupants.create({nick:n,type:"unavailable"});const e="".concat(t.get("jid"),"/").concat(n);Cc.user.presence.send("probe",e)}this.occupant?this.listenTo(this.occupant,"destroy",this.onOccupantRemoved):this.listenTo(t.occupants,"add",this.onOccupantAdded)}},Xl={},Zl=(e,t)=>e.replace(RegExp("\\"+t,"ig"),"\\"+t);Xl.escapeCharacters=e=>t=>e.split("").reduce(Zl,t),Xl.escapeRegexString=Xl.escapeCharacters("[\\^$.?*+(){}|"),Xl.findFirstMatchInArray=e=>t=>{for(let n=0;n{let i=e,{begin:r,end:o}=n;const{value:a}=n;return r-=s,o=o-s-1,i="".concat(i.slice(0,r)).concat(a).concat(i.slice(o+1)),[i,[...t,{...n,begin:r,end:o}]]};Xl.reduceTextFromReferences=(e,t)=>t.reduce(eu,[e,[]]);const tu=Xl;go.webForm2xForm=function(e){const t=e.getAttribute("name");if(!t)return null;let n;return n="checkbox"===e.getAttribute("type")?e.checked?1:0:"TEXTAREA"==e.tagName?e.value.split("\n").filter((e=>e.trim())):"SELECT"==e.tagName?go.getSelectValues(e):e.value,go.toStanza('\n \n ').concat(n.constructor===Array?n.map((e=>"".concat(e,""))):"".concat(n,""),"\n "))};const nu=go,su=function(e,t){return function(e,t,n){for(var s=-1,i=e.length,r=t.length,o={};++s forwarded[xmlns="').concat(au.FORWARD,'"] > message'),u=e;if(e=ru(l,e).pop()||e,ru('message > forwarded[xmlns="'.concat(iu.NS.FORWARD,'"]'),e).length)return new Pc("Invalid Stanza: Forged MAM groupchat message from ".concat(e.getAttribute("from")),e);const d=ru('delay[xmlns="'.concat(iu.NS.DELAY,'"]'),u).pop(),h=e.getAttribute("from"),f=iu.unescapeNode(iu.getResourceFromJid(h)),g=Xc(e),m=(new Date).toISOString();let p=Object.assign({from:h,nick:f,body:null===(s=e.querySelector("body"))||void 0===s||null===(i=s.textContent)||void 0===i?void 0:i.trim(),chat_state:Qc(e),from_muc:iu.getBareJidFromJid(h),from_real_jid:null===(r=t.occupants.findOccupant({nick:f}))||void 0===r?void 0:r.get("jid"),is_archived:tl(u),is_carbon:Jc(u),is_delayed:!!d,is_headline:Zc(e),is_markable:!!ru('markable[xmlns="'.concat(iu.NS.MARKERS,'"]'),e).length,is_marker:!!g,is_unstyled:!!ru('unstyled[xmlns="'.concat(iu.NS.STYLING,'"]'),e).length,marker_id:g&&g.getAttribute("id"),msgid:e.getAttribute("id")||u.getAttribute("id"),receipt_id:Wc(e),received:(new Date).toISOString(),references:Vc(e),subject:null===(o=e.querySelector("subject"))||void 0===o?void 0:o.textContent,thread:null===(a=e.querySelector("thread"))||void 0===a?void 0:a.textContent,time:d?Ao()(d.getAttribute("stamp")).toISOString():m,to:e.getAttribute("to"),type:e.getAttribute("type")},Gc(e),$c(e),Hc(e),qc(e,u),Fc(e,u),function(e){const t=qr()('> apply-to[xmlns="'.concat(zs.NS.FASTEN,'"]'),e).pop();if(t){const e=t.getAttribute("id"),n=qr()('> meta[xmlns="'.concat(zs.NS.XHTML,'"]'),t);if(n.length){const t=Cc.settings.get("message_limit"),s=n.reduce(((e,n)=>{const s=n.getAttribute("property");if(s){let i=Tr(n.getAttribute("content")||"");t&&"og:description"===s&&i.length>=t&&(i="".concat(i.slice(0,t)).concat(Tr("…"))),e[s]=i}return e}),{ogp_for_id:e});if("og:description"in s||"og:title"in s||"og:image"in s)return s}}return{}}(e),Uc(e,u),function(e){const t=ru('apply-to[xmlns="'.concat(iu.NS.FASTEN,'"]'),e).pop();if(t){const e=t.getAttribute("id"),s=ru('moderated[xmlns="'.concat(iu.NS.MODERATE,'"]'),t).pop();var n;if(s&&ru('retract[xmlns="'.concat(iu.NS.RETRACT,'"]'),s).pop())return{editable:!1,moderated:"retracted",moderated_by:s.getAttribute("by"),moderated_id:e,moderation_reason:null===(n=s.querySelector("reason"))||void 0===n?void 0:n.textContent}}else{const t=ru('> moderated[xmlns="'.concat(iu.NS.MODERATE,'"]'),e).pop();var s;if(t&&ru('retracted[xmlns="'.concat(iu.NS.RETRACT,'"]'),t).pop())return{editable:!1,is_tombstone:!0,moderated_by:t.getAttribute("by"),retracted:t.getAttribute("stamp"),moderation_reason:null===(s=t.querySelector("reason"))||void 0===s?void 0:s.textContent}}return{}}(e),Bc(e,n));return await Cc.emojis.initialize(),p=Object.assign({is_only_emojis:!!p.body&&ou.isOnlyEmojis(p.body),is_valid_receipt_request:Yc(e,p),message:p.body||p.error,sender:p.nick===t.get("nick")?"me":"them"},p),p.is_archived&&u.getAttribute("from")!==p.from_muc?new Pc("Invalid Stanza: Forged MAM message from ".concat(u.getAttribute("from")),e):p.is_archived&&u.getAttribute("from")!==t.get("jid")?new Pc("Invalid Stanza: Forged MAM groupchat message from ".concat(e.getAttribute("from")),e):p.is_carbon?new Pc("Invalid Stanza: MUC messages SHOULD NOT be XEP-0280 carbon copied",e):(p.id=p.origin_id||p["stanza_id ".concat(p.from_muc||p.from)]||ou.getUniqueId(),Cc.hook("parseMUCMessage",e,p))}const{Strophe:lu,$iq:uu,u:du}=Mc.env;async function hu(e,t){const n=uu({to:t,type:"get"}).c("query",{xmlns:lu.NS.MUC_ADMIN}).c("item",{affiliation:e}),s=await Cc.sendIQ(n,null,!1);if(null===s){const n="Error: timeout while fetching ".concat(e," list for MUC ").concat(t),i=new Error(n);return as.warn(n),as.warn(s),i}if(du.isErrorStanza(s)){const n="Error: not allowed to fetch ".concat(e," list for MUC ").concat(t),i=new Error(n);return as.warn(n),as.warn(s),i}return function(e){return ru('query[xmlns="'.concat(iu.NS.MUC_ADMIN,'"] item'),e).map((e=>{const t={affiliation:e.getAttribute("affiliation")},n=e.getAttribute("jid");ou.isValidJID(n)?t.jid=n:t.nick=n;const s=e.getAttribute("nick");return s&&(t.nick=s),e.getAttribute("role")&&(t.role=s),t}))}(s).filter((e=>e)).sort(((e,t)=>e.nickt.nick?1:0))}function fu(e,t){const n=[...new Set(t.map((e=>e.affiliation)))];return Promise.all(n.map((n=>gu(n,e,t))))}function gu(e,t,n){return Array.isArray(t)||(t=[t]),n=n.filter((t=>[void 0,e].includes(t.affiliation))),Promise.all(t.reduce(((t,s)=>[...t,...n.map((t=>function(e,t,n){const s=uu({to:t,type:"set"}).c("query",{xmlns:lu.NS.MUC_ADMIN}).c("item",{affiliation:n.affiliation||e,nick:n.nick,jid:n.jid});return void 0!==n.reason&&s.c("reason",n.reason),Cc.sendIQ(s)}(e,s,t)))]),[]))}function mu(e,t,n,s){const i=n.map((e=>e.jid)),r=s.map((e=>e.jid));let o=Wo(i,r).map((e=>n[na(i,e)]));return e||(o=o.concat(n.filter((e=>{const t=na(r,e.jid);return t>=0&&e.affiliation!==s[t].affiliation})))),t&&(o=o.concat(Wo(r,i).map((e=>({jid:e,affiliation:"none"}))))),o}const pu=["owner"],vu=["admin","ban","deop","destroy","member","op","revoke"],bu=["kick","mute","voice","modtools"],yu=["nick"],_u=["og:article:author","og:article:published_time","og:description","og:image","og:image:height","og:image:width","og:site_name","og:title","og:type","og:url","og:video:height","og:video:secure_url","og:video:tag","og:video:type","og:video:url","og:video:width"],wu=["301","303","333","307","321","322"],Su=ao.extend({defaults:()=>({connection_status:Mc.ROOMSTATUS.DISCONNECTED})}),xu={defaults(){return{bookmarked:!1,chat_state:void 0,has_activity:!1,hidden:So.isUniView()&&!Cc.settings.get("singleton"),hidden_occupants:!!Cc.settings.get("hide_muc_participants"),message_type:"groupchat",name:"",num_unread_general:0,num_unread:0,roomconfig:{},time_opened:this.get("time_opened")||(new Date).getTime(),time_sent:new Date(0).toISOString(),type:So.CHATROOMS_TYPE}},async initialize(){this.initialized=Et(),this.debouncedRejoin=Oo(this.rejoin,250),this.set("box_id","box-".concat(this.get("jid"))),this.initNotifications(),this.initMessages(),this.initUI(),this.initOccupants(),this.initDiscoModels(),this.registerHandlers(),this.on("change:chat_state",this.sendChatState,this),this.on("change:hidden",this.onHiddenChange,this),this.on("change:scrolled",(()=>!this.get("scrolled")&&this.clearUnreadMsgCounter())),this.on("destroy",this.removeHandlers,this),await this.restoreSession(),this.session.on("change:connection_status",this.onConnectionStatusChanged,this),this.listenTo(this.occupants,"add",this.onOccupantAdded),this.listenTo(this.occupants,"remove",this.onOccupantRemoved),this.listenTo(this.occupants,"change:show",this.onOccupantShowChanged),this.listenTo(this.occupants,"change:affiliation",this.createAffiliationChangeMessage),this.listenTo(this.occupants,"change:role",this.createRoleChangeMessage),await this.restoreFromCache()||this.join(),await Cc.trigger("chatRoomInitialized",this,{Synchronous:!0}),this.initialized.resolve()},async restoreFromCache(){return this.session.get("connection_status")===Mc.ROOMSTATUS.ENTERED&&await this.isJoined()?(await new Promise((e=>this.features.fetch({success:e,error:e}))),await this.fetchOccupants().catch((e=>as.error(e))),await this.fetchMessages().catch((e=>as.error(e))),!0):(this.clearCache(),!1)},async join(e,t){if(this.session.get("connection_status")===Mc.ROOMSTATUS.ENTERED)return this;if(this.session.save("connection_status",Mc.ROOMSTATUS.CONNECTING),await this.refreshDiscoInfo(),!(e=await this.getAndPersistNickname(e)))return nu.safeSave(this.session,{connection_status:Mc.ROOMSTATUS.NICKNAME_REQUIRED}),Cc.settings.get("muc_show_logs_before_join")&&await this.fetchMessages(),this;const n=Ds({from:So.connection.jid,to:this.getRoomJIDAndNick()}).c("x",{xmlns:zs.NS.MUC}).c("history",{maxstanzas:this.features.get("mam_enabled")?0:Cc.settings.get("muc_history_max_stanzas")}).up();return(t=t||this.get("password"))&&n.cnode(zs.xmlElement("password",[],t)),Cc.send(n),this},rejoin(){return this.registerHandlers(),this.clearCache(),this.join()},clearCache(){this.session.save("connection_status",Mc.ROOMSTATUS.DISCONNECTED),this.occupants.length?this.occupants.filter((e=>!e.isMember())).forEach((e=>e.destroy())):this.occupants.clearStore()},sendMarkerForMessage(e,t="displayed",n=!1){if(e&&Cc.settings.get("send_chat_markers").includes(t)&&((null==e?void 0:e.get("is_markable"))||n)){const n="stanza_id ".concat(this.get("jid")),s=e.get(n);if(!s)return void as.error("Can't send marker for message without stanza ID: ".concat(n));zc(zs.getBareJidFromJid(e.get("from")),s,t,e.get("type"))}},enableRAI(){if(Cc.settings.get("muc_subscribe_to_rai")){const e=zs.getDomainFromJid(this.get("jid"));Cc.user.presence.send(null,e,null,Is("rai",{xmlns:zs.NS.RAI}))}},async onHiddenChange(){const e=this.session.get("connection_status");this.get("hidden")&&e===Mc.ROOMSTATUS.ENTERED?Cc.settings.get("muc_subscribe_to_rai")&&"none"!==this.getOwnAffiliation()&&(e!==Mc.ROOMSTATUS.DISCONNECTED&&(this.sendMarkerForLastMessage("received",!0),await this.leave()),this.enableRAI()):e===Mc.ROOMSTATUS.DISCONNECTED&&this.rejoin()},onOccupantAdded(e){So.isInfoVisible(Mc.MUC_TRAFFIC_STATES.ENTERED)&&this.session.get("connection_status")===Mc.ROOMSTATUS.ENTERED&&"online"===e.get("show")&&this.updateNotifications(e.get("nick"),Mc.MUC_TRAFFIC_STATES.ENTERED)},onOccupantRemoved(e){So.isInfoVisible(Mc.MUC_TRAFFIC_STATES.EXITED)&&this.session.get("connection_status")===Mc.ROOMSTATUS.ENTERED&&"online"===e.get("show")&&this.updateNotifications(e.get("nick"),Mc.MUC_TRAFFIC_STATES.EXITED)},onOccupantShowChanged(e){e.get("states").includes("303")||("offline"===e.get("show")&&So.isInfoVisible(Mc.MUC_TRAFFIC_STATES.EXITED)?this.updateNotifications(e.get("nick"),Mc.MUC_TRAFFIC_STATES.EXITED):"online"===e.get("show")&&So.isInfoVisible(Mc.MUC_TRAFFIC_STATES.ENTERED)&&this.updateNotifications(e.get("nick"),Mc.MUC_TRAFFIC_STATES.ENTERED))},async onRoomEntered(){await this.occupants.fetchMembers(),Cc.settings.get("clear_messages_on_reconnection")?(await this.messages.clearStore(),this.messages.fetched.resolve()):await this.fetchMessages(),Cc.trigger("enteredNewRoom",this),Cc.settings.get("auto_register_muc_nickname")&&await Cc.disco.supports(zs.NS.MUC_REGISTER,this.get("jid"))&&this.registerNickname()},async onConnectionStatusChanged(){this.session.get("connection_status")===Mc.ROOMSTATUS.ENTERED&&(this.get("hidden")&&Cc.settings.get("muc_subscribe_to_rai")&&"none"!==this.getOwnAffiliation()?(await this.leave(),this.enableRAI()):await this.onRoomEntered())},async onReconnection(){await this.rejoin(),this.announceReconnection()},getMessagesCollection:()=>new So.ChatRoomMessages,restoreSession(){const e="muc.session-".concat(So.bare_jid,"-").concat(this.get("jid"));return this.session=new Su({id:e}),Cr(this.session,e,"session"),new Promise((e=>this.session.fetch({success:e,error:e})))},initDiscoModels(){let e="converse.muc-features-".concat(So.bare_jid,"-").concat(this.get("jid"));this.features=new ao(Object.assign({id:e},su(Mc.ROOM_FEATURES,Mc.ROOM_FEATURES.map((()=>!1))))),this.features.browserStorage=So.createStore(e,"session"),this.features.listenTo(So,"beforeLogout",(()=>this.features.browserStorage.flush())),e="converse.muc-config-{_converse.bare_jid}-".concat(this.get("jid")),this.config=new ao,this.config.browserStorage=So.createStore(e,"session"),this.config.listenTo(So,"beforeLogout",(()=>this.config.browserStorage.flush()))},initOccupants(){this.occupants=new So.ChatRoomOccupants;const e="converse.occupants-".concat(So.bare_jid).concat(this.get("jid"));this.occupants.browserStorage=So.createStore(e,"session"),this.occupants.chatroom=this,this.occupants.listenTo(So,"beforeLogout",(()=>this.occupants.browserStorage.flush()))},fetchOccupants(){return this.occupants.fetched=new Promise((e=>{this.occupants.fetch({add:!0,silent:!0,success:e,error:e})})),this.occupants.fetched},handleAffiliationChangedMessage(e){const t=qr()('x[xmlns="'.concat(zs.NS.MUC_USER,'"] item'),e).pop();if(t){const n=e.getAttribute("from"),s=e.getAttribute("type"),i=t.getAttribute("affiliation"),r=t.getAttribute("jid"),o={from:n,type:s,affiliation:i,states:[],show:"unavailable"==s?"offline":"online",role:t.getAttribute("role"),jid:zs.getBareJidFromJid(r),resource:zs.getResourceFromJid(r)},a=this.occupants.findOccupant({jid:o.jid});a?a.save(o):this.occupants.create(o)}},async handleErrorMessageStanza(e){const{__:t}=So,n=await cu(e,this,So);if(!await this.shouldShowErrorMessage(n))return;const s=this.getMessageReferencedByError(n);if(s){const e={error:n.error,error_condition:n.error_condition,error_text:n.error_text,error_type:n.error_type,editable:!1};n.msgid===s.get("retraction_id")?(e.retraction_id=void 0,n.error||("forbidden"===n.error_condition?e.error=t("You're not allowed to retract your message."):"not-acceptable"===n.error_condition?e.error=t("Your retraction was not delivered because you're not present in the groupchat."):e.error=t("Sorry, an error occurred while trying to retract your message."))):n.error||("forbidden"===n.error_condition?e.error=t("Your message was not delivered because you weren't allowed to send it."):"not-acceptable"===n.error_condition?e.error=t("Your message was not delivered because you're not present in the groupchat."):e.error=t("Sorry, an error occurred while trying to send your message.")),s.save(e)}else this.createMessage(n)},handleMessageFromMUCHost(e){if(this.session.get("connection_status")===Mc.ROOMSTATUS.ENTERED)return;const t=qr()('rai[xmlns="'.concat(zs.NS.RAI,'"]'),e).pop();Array.from((null==t?void 0:t.querySelectorAll("activity"))||[]).map((e=>e.textContent)).includes(this.get("jid"))&&this.save({has_activity:!0,num_unread_general:0})},handleForwardedMentions(e){if(this.session.get("connection_status")===Mc.ROOMSTATUS.ENTERED)return;const t=qr()('mentions[xmlns="'.concat(zs.NS.MENTIONS,'"] forwarded[xmlns="').concat(zs.NS.FORWARD,'"] message[type="groupchat"]'),e),n=this.get("jid"),s=t.filter((e=>zs.getBareJidFromJid(e.getAttribute("from"))===n));s.length&&(this.save({has_activity:!0,num_unread:this.get("num_unread")+s.length}),s.forEach((async e=>{const t={stanza:e,attrs:await cu(e,this,So),chatbox:this};Cc.trigger("message",t)})))},async handleMessageStanza(e){if("groupchat"!==e.getAttribute("type"))return void this.handleForwardedMentions(e);if(tl(e))return as.warn('Received a MAM message with type "groupchat"');this.createInfoMessages(e),this.fetchFeaturesIfConfigurationChanged(e);const t=await cu(e,this,So),n={stanza:e,attrs:t,chatbox:this};return Cc.trigger("message",n),t&&this.queueMessage(t)},registerHandlers(){const e=this.get("jid"),t=zs.getDomainFromJid(e);this.removeHandlers(),this.presence_handler=So.connection.addHandler((e=>this.onPresence(e)||!0),null,"presence",null,null,e,{ignoreNamespaceFragment:!0,matchBareFromJid:!0}),this.domain_presence_handler=So.connection.addHandler((e=>this.onPresenceFromMUCHost(e)||!0),null,"presence",null,null,t),this.message_handler=So.connection.addHandler((e=>!!this.handleMessageStanza(e)||!0),null,"message",null,null,e,{matchBareFromJid:!0}),this.domain_message_handler=So.connection.addHandler((e=>this.handleMessageFromMUCHost(e)||!0),null,"message",null,null,t),this.affiliation_message_handler=So.connection.addHandler((e=>this.handleAffiliationChangedMessage(e)||!0),zs.NS.MUC_USER,"message",null,null,e)},removeHandlers(){return this.message_handler&&(So.connection&&So.connection.deleteHandler(this.message_handler),delete this.message_handler),this.domain_message_handler&&(So.connection&&So.connection.deleteHandler(this.domain_message_handler),delete this.domain_message_handler),this.presence_handler&&(So.connection&&So.connection.deleteHandler(this.presence_handler),delete this.presence_handler),this.domain_presence_handler&&(So.connection&&So.connection.deleteHandler(this.domain_presence_handler),delete this.domain_presence_handler),this.affiliation_message_handler&&(So.connection&&So.connection.deleteHandler(this.affiliation_message_handler),delete this.affiliation_message_handler),this},invitesAllowed(){return Cc.settings.get("allow_muc_invitations")&&(this.features.get("open")||"owner"===this.getOwnAffiliation())},getDisplayName(){return this.get("name")||("hidden"===Cc.settings.get("locked_muc_domain")?zs.getNodeFromJid(this.get("jid")):this.get("jid"))},sendTimedMessage(e){"function"==typeof e.tree&&(e=e.tree());let t=e.getAttribute("id");t||(t=this.getUniqueId("sendIQ"),e.setAttribute("id",t));const n=Et(),s=So.connection.addTimedHandler(So.STANZA_TIMEOUT,(()=>(So.connection.deleteHandler(i),n.reject(new So.TimeoutError("Timeout Error: No response from server")),!1))),i=So.connection.addHandler((e=>{s&&So.connection.deleteTimedHandler(s),"groupchat"===e.getAttribute("type")?n.resolve(e):n.reject(e)}),null,"message",["error","groupchat"],t);return Cc.send(e),n},async retractOwnMessage(e){const t=So.__,n=e.get("origin_id");if(!n)throw new Error("Can't retract message without a XEP-0359 Origin ID");const s=e.get("editable"),i=Ms({id:nu.getUniqueId(),to:this.get("jid"),type:"groupchat"}).c("store",{xmlns:zs.NS.HINTS}).up().c("apply-to",{id:n,xmlns:zs.NS.FASTEN}).c("retract",{xmlns:zs.NS.RETRACT});e.set({retracted:(new Date).toISOString(),retracted_id:n,retraction_id:i.nodeTree.getAttribute("id"),editable:!1});try{await this.sendTimedMessage(i)}catch(n){throw e.save({editable:s,error_type:"timeout",error:t("A timeout happened while while trying to retract your message."),retracted:void 0,retracted_id:void 0}),n}},async retractOtherMessage(e,t){const n=e.get("editable");e.save({moderated:"retracted",moderated_by:So.bare_jid,moderated_id:e.get("msgid"),moderation_reason:t,editable:!1});const s=await this.sendRetractionIQ(e,t);return(null===s||nu.isErrorStanza(s))&&e.save({editable:n,moderated:void 0,moderated_by:void 0,moderated_id:void 0,moderation_reason:void 0}),s},sendRetractionIQ(e,t){const n=Rs({to:this.get("jid"),type:"set"}).c("apply-to",{id:e.get("stanza_id ".concat(this.get("jid"))),xmlns:zs.NS.FASTEN}).c("moderate",{xmlns:zs.NS.MODERATE}).c("retract",{xmlns:zs.NS.RETRACT}).up().c("reason").t(t||"");return Cc.sendIQ(n,null,!1)},sendDestroyIQ(e,t){const n=Is("destroy");t&&n.attrs({jid:t});const s=Rs({to:this.get("jid"),type:"set"}).c("query",{xmlns:zs.NS.MUC_OWNER}).cnode(n.node);return e&&e.length>0&&s.c("reason",e),Cc.sendIQ(s)},async leave(e){var t;this.features.destroy();const n=null===(t=So.disco_entities)||void 0===t?void 0:t.get(this.get("jid"));n&&await new Promise(((e,t)=>n.destroy({success:e,error:t}))),Cc.connection.connected()&&Cc.user.presence.send("unavailable",this.getRoomJIDAndNick(),e),nu.safeSave(this.session,{connection_status:Mc.ROOMSTATUS.DISCONNECTED})},async close(e){return await this.leave(),"unregister"===Cc.settings.get("auto_register_muc_nickname")&&await Cc.disco.supports(zs.NS.MUC_REGISTER,this.get("jid"))&&this.unregisterNickname(),this.occupants.clearStore(),"closeAllChatBoxes"!==(null==e?void 0:e.name)&&Cc.settings.get("muc_clear_messages_on_leave")&&this.clearMessages(),await new Promise((e=>this.session.destroy({success:e,error:(t,n)=>{as.error(n),e()}}))),await new Promise((e=>this.features.destroy({success:e,error:(t,n)=>{as.error(n),e()}}))),So.ChatBox.prototype.close.call(this)},canModerateMessages(){const e=this.getOwnOccupant();return e&&e.isModerator()&&Cc.disco.supports(zs.NS.MODERATE,this.get("jid"))},getAllKnownNicknames(){return[...new Set([...this.occupants.map((e=>e.get("nick"))),...this.messages.map((e=>e.get("nick")))])].filter((e=>e))},getAllKnownNicknamesRegex(){const e=this.getAllKnownNicknames().map((e=>tu.escapeRegexString(e))).join("|");return RegExp("(?:\\p{P}|\\p{Z}|^)@(".concat(e,")(?![\\w@-])"),"uig")},getOccupantByJID(e){return this.occupants.findOccupant({jid:e})},getOccupantByNickname(e){return this.occupants.findOccupant({nick:e})},parseTextForReferences(e){if(!e||!/(\p{P}|\p{Z}|^)([@][\w_-]+(?:\.\w+)*)/giu.test(e))return[e,[]];const t=tu.findFirstMatchInArray(this.getAllKnownNicknames()),n=e=>{const t=this.get("jid"),n=this.getOccupant(e)||this.getOccupant(t),s=this.features.get("nonanonymous")&&(null==n?void 0:n.get("jid"))||"".concat(t,"/").concat(e);return encodeURI("xmpp:".concat(s))},s=this.getAllKnownNicknamesRegex(),i=[...e.matchAll(s)].filter((e=>!e[0].startsWith("/"))).map((e=>{let s=e[0].indexOf("@");"@"===e[0][s+1]&&(s+=1);const i=e.index+s,r=i+e[0].length-s,o=t(e[1]);return{begin:i,end:r,value:o,type:"mention",uri:n(o)}})),[r,o]=tu.reduceTextFromReferences(e,i);return[r,o]},getOutgoingMessageAttributes(e,t){const n=this.get("composing_spoiler"),[s,i]=this.parseTextForReferences(e),r=nu.getUniqueId(),o=s?nu.httpToGeoUri(nu.shortnamesToUnicode(s),So):void 0;return{body:o,is_spoiler:n,origin_id:r,references:i,id:r,msgid:r,from:"".concat(this.get("jid"),"/").concat(this.get("nick")),fullname:this.get("nick"),is_only_emojis:!!s&&nu.isOnlyEmojis(s),message:o,nick:this.get("nick"),sender:"me",spoiler_hint:n?t:void 0,type:"groupchat"}},getRoomJIDAndNick(){const e=this.get("nick");return zs.getBareJidFromJid(this.get("jid"))+(null!==e?"/".concat(e):"")},sendChatState(){if(!Cc.settings.get("send_chat_state_notifications")||!this.get("chat_state")||this.session.get("connection_status")!==Mc.ROOMSTATUS.ENTERED||this.features.get("moderated")&&"visitor"===this.getOwnRole())return;const e=Cc.settings.get("send_chat_state_notifications");if(Array.isArray(e)&&!e.includes(this.get("chat_state")))return;const t=this.get("chat_state");t!==So.GONE&&Cc.send(Ms({to:this.get("jid"),type:"groupchat"}).c(t,{xmlns:zs.NS.CHATSTATES}).up().c("no-store",{xmlns:zs.NS.HINTS}).up().c("no-permanent-store",{xmlns:zs.NS.HINTS}))},directInvite(e,t){this.features.get("membersonly")&&this.updateMemberLists([{jid:e,affiliation:"member",reason:t}]);const n={xmlns:"jabber:x:conference",jid:this.get("jid")};null!==t&&(n.reason=t),this.get("password")&&(n.password=this.get("password"));const s=Ms({from:So.connection.jid,to:e,id:nu.getUniqueId()}).c("x",n);Cc.send(s),Cc.trigger("roomInviteSent",{room:this,recipient:e,reason:t})},refreshDiscoInfo(){return Cc.disco.refresh(this.get("jid")).then((()=>this.getDiscoInfo())).catch((e=>as.error(e)))},getDiscoInfo(){return Cc.disco.getIdentity("conference","text",this.get("jid")).then((e=>this.save({name:null==e?void 0:e.get("name")}))).then((()=>this.getDiscoInfoFields())).then((()=>this.getDiscoInfoFeatures())).catch((e=>as.error(e)))},async getDiscoInfoFields(){const e=(await Cc.disco.getFields(this.get("jid"))).reduce(((e,t)=>{const n=t.get("var");return n&&n.startsWith("muc#roominfo_")&&(e[n.replace("muc#roominfo_","")]=t.get("value")),e}),{});this.config.save(e)},async getDiscoInfoFeatures(){const e=await Cc.disco.getFeatures(this.get("jid")),t=Object.assign(su(Mc.ROOM_FEATURES,Mc.ROOM_FEATURES.map((()=>!1))),{fetched:(new Date).toISOString()});e.each((e=>{const n=e.get("var");n.startsWith("muc_")?t[n.replace("muc_","")]=!0:n===zs.NS.MAM&&(t.mam_enabled=!0)})),this.features.save(t)},addFieldValue(e){const t=e.getAttribute("type");if("fixed"===t)return e;const n=e.getAttribute("var").replace("muc#roomconfig_",""),s=this.get("roomconfig");if(n in s){let i;switch(t){case"boolean":i=[s[n]?1:0];break;case"list-multi":i=s[n];break;default:i=[s[n]]}e.innerHTML=i.map((e=>Is("value").t(e))).join("")}return e},async autoConfigureChatRoom(){const e=await this.fetchRoomConfiguration(),t=qr()("field",e).map((e=>this.addFieldValue(e)));if(t.length)return this.sendConfiguration(t)},fetchRoomConfiguration(){return Cc.sendIQ(Rs({to:this.get("jid"),type:"get"}).c("query",{xmlns:zs.NS.MUC_OWNER}))},sendConfiguration(e=[]){const t=Rs({to:this.get("jid"),type:"set"}).c("query",{xmlns:zs.NS.MUC_OWNER}).c("x",{xmlns:zs.NS.XFORM,type:"submit"});return e.forEach((e=>t.cnode(e).up())),Cc.sendIQ(t)},onCommandError(e){const{__:t}=So;as.fatal(e);const n=t("Sorry, an error happened while running the command.")+" "+t("Check your browser's developer console for details.");this.createMessage({message:n,type:"error"})},getNickOrJIDFromCommandArgs(e){const{__:t}=So;if(nu.isValidJID(e.trim()))return e.trim();e.startsWith("@")||(e="@"+e);const[n,s]=this.parseTextForReferences(e);if(!s.length){const e=t("Error: couldn't find a groupchat participant based on your arguments");return void this.createMessage({message:e,type:"error"})}if(s.length>1){const e=t("Error: found multiple groupchat participant based on your arguments");return void this.createMessage({message:e,type:"error"})}const i=s.pop().value,r=e.split(i,2)[1];if(!r||r.startsWith(" "))return i;{const e=t("Error: couldn't find a groupchat participant based on your arguments");this.createMessage({message:e,type:"error"})}},validateRoleOrAffiliationChangeArgs(e,t){const{__:n}=So;if(!t){const t=n('Error: the "%1$s" command takes two arguments, the user\'s nickname and optionally a reason.',e);return this.createMessage({message:t,type:"error"}),!1}return!0},getAllowedCommands(){let e=["clear","help","me","nick","register"];(this.config.get("changesubject")||["owner","admin"].includes(this.getOwnAffiliation()))&&(e=[...e,"subject","topic"]);const t=this.occupants.findWhere({jid:So.bare_jid});return this.verifyAffiliations(["owner"],t,!1)?e=e.concat(pu).concat(vu):this.verifyAffiliations(["admin"],t,!1)&&(e=e.concat(vu)),this.verifyRoles(["moderator"],t,!1)?e=e.concat(bu).concat(yu):this.verifyRoles(["visitor","participant","moderator"],t,!1)||(e=e.concat(yu)),e.sort(),Array.isArray(Cc.settings.get("muc_disable_slash_commands"))?e.filter((e=>!Cc.settings.get("muc_disable_slash_commands").includes(e))):e},verifyAffiliations(e,t,n=!0){const{__:s}=So;if(!Array.isArray(e))throw new TypeError("affiliations must be an Array");if(!e.length)return!0;if(t=t||this.occupants.findWhere({jid:So.bare_jid})){const n=t.get("affiliation");if(e.includes(n))return!0}if(n){const e=s("Forbidden: you do not have the necessary affiliation in order to do that.");this.createMessage({message:e,type:"error"})}return!1},verifyRoles(e,t,n=!0){const{__:s}=So;if(!Array.isArray(e))throw new TypeError("roles must be an Array");if(!e.length)return!0;if(t=t||this.occupants.findWhere({jid:So.bare_jid})){const n=t.get("role");if(e.includes(n))return!0}if(n){const e=s("Forbidden: you do not have the necessary role in order to do that.");this.createMessage({message:e,type:"error"})}return!1},getOwnRole(){var e,t;return null===(e=this.getOwnOccupant())||void 0===e||null===(t=e.attributes)||void 0===t?void 0:t.role},getOwnAffiliation(){var e,t;return(null===(e=this.getOwnOccupant())||void 0===e||null===(t=e.attributes)||void 0===t?void 0:t.affiliation)||"none"},getOwnOccupant(){return this.occupants.findWhere({jid:So.bare_jid})},setRole(e,t,n,s,i){const r=Is("item",{nick:e.get("nick"),role:t}),o=Rs({to:this.get("jid"),type:"set"}).c("query",{xmlns:zs.NS.MUC_ADMIN}).cnode(r.node);return null!==n&&o.c("reason",n),Cc.sendIQ(o).then(s).catch(i)},getOccupant(e){return nu.isValidJID(e)?this.getOccupantByJID(e):this.getOccupantByNickname(e)},getOccupantsWithRole(e){return this.getOccupantsSortedBy("nick").filter((t=>t.get("role")===e)).map((e=>({jid:e.get("jid"),nick:e.get("nick"),role:e.get("role")})))},getOccupantsWithAffiliation(e){return this.getOccupantsSortedBy("nick").filter((t=>t.get("affiliation")===e)).map((e=>({jid:e.get("jid"),nick:e.get("nick"),affiliation:e.get("affiliation")})))},getOccupantsSortedBy(e){return Array.from(this.occupants.models).sort(((t,n)=>t.get(e)n.get(e)?1:0))},async updateMemberLists(e){const t=this.get("jid"),n=(await Promise.all(["member","admin","owner"].map((e=>hu(e,t))))).reduce(((e,t)=>nu.isErrorObject(t)?e:[...t,...e]),[]);await fu(t,mu(!0,!1,e,n)),await this.occupants.fetchMembers()},async getAndPersistNickname(e){return(e=e||this.get("nick")||await this.getReservedNick()||So.getDefaultMUCNickname())&&this.save({nick:e},{silent:!0}),e},async getReservedNick(){const e=Rs({to:this.get("jid"),from:So.connection.jid,type:"get"}).c("query",{xmlns:zs.NS.DISCO_INFO,node:"x-roomuser-item"}),t=await Cc.sendIQ(e,null,!1);if(nu.isErrorObject(t))throw t;const n=t.querySelector('query[node="x-roomuser-item"] identity');return n?n.getAttribute("name"):null},async registerNickname(){const{__:e}=So,t=this.get("nick"),n=this.get("jid");let s,i;try{s=await Cc.sendIQ(Rs({to:n,type:"get"}).c("query",{xmlns:zs.NS.MUC_REGISTER}))}catch(t){return qr()('not-allowed[xmlns="'.concat(zs.NS.STANZAS,'"]'),t).length?i=e("You're not allowed to register yourself in this groupchat."):qr()('registration-required[xmlns="'.concat(zs.NS.STANZAS,'"]'),t).length&&(i=e("You're not allowed to register in this groupchat because it's members-only.")),as.error(t),i}const r=qr()("field required",s).map((e=>e.parentElement));if(r.length>1&&"muc#register_roomnick"!==r[0].getAttribute("var"))return as.error("Can't register the user register in the groupchat ".concat(n," due to the required fields"));try{await Cc.sendIQ(Rs({to:n,type:"set"}).c("query",{xmlns:zs.NS.MUC_REGISTER}).c("x",{xmlns:zs.NS.XFORM,type:"submit"}).c("field",{var:"FORM_TYPE"}).c("value").t("http://jabber.org/protocol/muc#register").up().up().c("field",{var:"muc#register_roomnick"}).c("value").t(t))}catch(t){return qr()('service-unavailable[xmlns="'.concat(zs.NS.STANZAS,'"]'),t).length?i=e("Can't register your nickname in this groupchat, it doesn't support registration."):qr()('bad-request[xmlns="'.concat(zs.NS.STANZAS,'"]'),t).length&&(i=e("Can't register your nickname in this groupchat, invalid data form supplied.")),as.error(i),as.error(t),i}},async unregisterNickname(){const e=this.get("jid");let t;try{t=await Cc.sendIQ(Rs({to:e,type:"set"}).c("query",{xmlns:zs.NS.MUC_REGISTER}))}catch(e){return as.error(e),e}if(qr()('query[xmlns="'.concat(zs.NS.MUC_REGISTER,'"] registered'),t).pop()){const t=Rs({to:e,type:"set"}).c("query",{xmlns:zs.NS.MUC_REGISTER}).c("remove");return Cc.sendIQ(t).catch((e=>as.error(e)))}},updateOccupantsOnPresence(e){var t,n;const s=function(e){const t=e.getAttribute("from"),n=e.getAttribute("type"),s={from:t,nick:iu.getResourceFromJid(t),type:n,states:[],hats:[],show:"unavailable"!==n?"online":"offline"};return Array.from(e.children).forEach((e=>{if(e.matches("status"))s.status=e.textContent||null;else if(e.matches("show"))s.show=e.textContent||"online";else if(e.matches("x")&&e.getAttribute("xmlns")===iu.NS.MUC_USER)Array.from(e.children).forEach((e=>{"item"===e.nodeName?(s.affiliation=e.getAttribute("affiliation"),s.role=e.getAttribute("role"),s.jid=e.getAttribute("jid"),s.nick=e.getAttribute("nick")||s.nick):"status"==e.nodeName&&e.getAttribute("code")&&s.states.push(e.getAttribute("code"))}));else if(e.matches("x")&&e.getAttribute("xmlns")===iu.NS.VCARDUPDATE){var t;s.image_hash=null===(t=e.querySelector("photo"))||void 0===t?void 0:t.textContent}else e.matches("hats")&&e.getAttribute("xmlns")===iu.NS.MUC_HATS&&(s.hats=Array.from(e.children).map((e=>e.matches("hat")&&{title:e.getAttribute("title"),uri:e.getAttribute("uri")})))})),s}(e);if("error"===s.type||!s.jid&&!s.nick)return!0;const i=this.occupants.findOccupant(s);if("unavailable"===s.type&&i&&!s.states.includes(Mc.MUC_NICK_CHANGED_CODE)&&!["admin","owner","member"].includes(s.affiliation))return i.set(s),void i.destroy();const r=s.jid||"",o=Object.assign(s,{jid:zs.getBareJidFromJid(r)||(null==i||null===(t=i.attributes)||void 0===t?void 0:t.jid),resource:zs.getResourceFromJid(r)||(null==i||null===(n=i.attributes)||void 0===n?void 0:n.resource)});i?i.save(o):this.occupants.create(o)},fetchFeaturesIfConfigurationChanged(e){const t=["104","170","171","172","173","174"];qr()("status",e).filter((e=>t.includes(e.getAttribute("status")))).length&&this.refreshDiscoInfo()},isSameUser(e,t){const n=zs.getBareJidFromJid(e),s=zs.getBareJidFromJid(t),i=zs.getResourceFromJid(e),r=zs.getResourceFromJid(t);return nu.isSameBareJID(e,t)?n!==this.get("jid")||i===r:(n===this.get("jid")?this.occupants.findOccupant({nick:i}):this.occupants.findOccupant({jid:n}))===(s===this.get("jid")?this.occupants.findOccupant({nick:r}):this.occupants.findOccupant({jid:s}))},async isSubjectHidden(){return(await Cc.user.settings.get("mucs_with_hidden_subject",[])).includes(this.get("jid"))},async toggleSubjectHiddenState(){const e=this.get("jid"),t=await Cc.user.settings.get("mucs_with_hidden_subject",[]);t.includes(this.get("jid"))?Cc.user.settings.set("mucs_with_hidden_subject",t.filter((t=>t!==e))):Cc.user.settings.set("mucs_with_hidden_subject",[...t,e])},async handleSubjectChange(e){const t=So.__;if("string"==typeof e.subject&&!e.thread&&!e.message){const n=e.subject,s=e.nick;if(nu.safeSave(this,{subject:{author:s,text:e.subject||""}}),!e.is_delayed&&s){const i=t(n?"Topic set by %1$s":"Topic cleared by %1$s",s),r=this.messages.last();(null==r?void 0:r.get("nick"))===e.nick&&"info"===(null==r?void 0:r.get("type"))&&(null==r?void 0:r.get("message"))===i||this.createMessage({message:i,nick:e.nick,type:"info"}),await this.isSubjectHidden()&&this.toggleSubjectHiddenState()}return!0}return!1},setSubject(e=""){Cc.send(Ms({to:this.get("jid"),from:So.connection.jid,type:"groupchat"}).c("subject",{xmlns:"jabber:client"}).t(e).tree())},ignorableCSN(e){return e.chat_state&&!e.body&&(e.is_delayed||this.isOwnMessage(e))},isOwnMessage(e){let t;return t=es(e)?e.getAttribute("from"):e instanceof So.Message?e.get("from"):e.from,zs.getResourceFromJid(t)==this.get("nick")},getUpdatedMessageAttributes(e,t){const n=So.ChatBox.prototype.getUpdatedMessageAttributes.call(this,e,t);if(this.isOwnMessage(t)){const s=Object.keys(t).filter((e=>e.startsWith("stanza_id")));Object.assign(n,Pr(t,s)),e.get("received")||(n.received=(new Date).toISOString())}return n},async isJoined(){const e=this.get("jid"),t=Rs({to:"".concat(e,"/").concat(this.get("nick")),type:"get"}).c("ping",{xmlns:zs.NS.PING});try{await Cc.sendIQ(t)}catch(t){return null===t?as.warn("isJoined: Timeout error while checking whether we're joined to MUC: ".concat(e)):as.warn("isJoined: Apparently we're no longer connected to MUC: ".concat(e)),!1}return!0},async rejoinIfNecessary(){if(!await this.isJoined())return this.rejoin(),!0},async shouldShowErrorMessage(e){return("not-acceptable"!==e.error_condition||!await this.rejoinIfNecessary())&&So.ChatBox.prototype.shouldShowErrorMessage.call(this,e)},findDanglingModeration(e){if(!this.messages.length)return null;if(this.messages.last().get("time")>e.time){const t=Array.from(this.messages.models),n=e["stanza_id ".concat(this.get("jid"))];return n?(t.reverse(),t.find((({attributes:e})=>"retracted"===e.moderated&&e.moderated_id===n&&e.moderated_by))):null}},async handleModeration(e){const t=["editable","moderated","moderated_by","moderated_id","moderation_reason"];if("retracted"===e.moderated){const n={};n["stanza_id ".concat(this.get("jid"))]=e.moderated_id;const s=this.messages.findWhere(n);return s?(s.save(Pr(e,t)),!0):(e.dangling_moderation=!0,await this.createMessage(e),!0)}{const n=this.findDanglingModeration(e);if(n){const s=Pr(n.attributes,t),i=Object.assign({dangling_moderation:!1},e,s);return delete i.id,n.save(i),!0}}return!1},getNotificationsText(){const{__:e}=So,t=this.notifications.toJSON(),n=Cc.settings.get("muc_show_info_messages").filter((e=>Mc.MUC_ROLE_CHANGES_LIST.includes(e))),s=Cc.settings.get("muc_show_info_messages").filter((e=>Mc.MUC_TRAFFIC_STATES_LIST.includes(e)));return[...Mc.CHAT_STATES,...s,...n].reduce(((n,s)=>{const i=t[s];if(!(null==i?void 0:i.length))return n;const r=i.map((e=>{var t;return(null===(t=this.getOccupant(e))||void 0===t?void 0:t.getDisplayName())||e}));if(1===r.length){if("composing"===s)return"".concat(n).concat(e("%1$s is typing",r[0]),"\n");if("paused"===s)return"".concat(n).concat(e("%1$s has stopped typing",r[0]),"\n");if(s===So.GONE)return"".concat(n).concat(e("%1$s has gone away",r[0]),"\n");if("entered"===s)return"".concat(n).concat(e("%1$s has entered the groupchat",r[0]),"\n");if("exited"===s)return"".concat(n).concat(e("%1$s has left the groupchat",r[0]),"\n");if("op"===s)return"".concat(n).concat(e("%1$s is now a moderator",r[0]),"\n");if("deop"===s)return"".concat(n).concat(e("%1$s is no longer a moderator",r[0]),"\n");if("voice"===s)return"".concat(n).concat(e("%1$s has been given a voice",r[0]),"\n");if("mute"===s)return"".concat(n).concat(e("%1$s has been muted",r[0]),"\n")}else if(r.length>1){let t;if(r.length>3)t="".concat(Array.from(r).slice(0,2).join(", ")," and others");else{const n=r.pop();t=e("%1$s and %2$s",r.join(", "),n)}if("composing"===s)return"".concat(n).concat(e("%1$s are typing",t),"\n");if("paused"===s)return"".concat(n).concat(e("%1$s have stopped typing",t),"\n");if(s===So.GONE)return"".concat(n).concat(e("%1$s have gone away",t),"\n");if("entered"===s)return"".concat(n).concat(e("%1$s have entered the groupchat",t),"\n");if("exited"===s)return"".concat(n).concat(e("%1$s have left the groupchat",t),"\n");if("op"===s)return"".concat(n).concat(e("%1$s are now moderators",r[0]),"\n");if("deop"===s)return"".concat(n).concat(e("%1$s are no longer moderators",r[0]),"\n");if("voice"===s)return"".concat(n).concat(e("%1$s have been given voices",r[0]),"\n");if("mute"===s)return"".concat(n).concat(e("%1$s have been muted",r[0]),"\n")}return n}),"")},removeNotification(e,t){const n=this.notifications.toJSON();(t=Array.isArray(t)?t:[t]).forEach((t=>{const s=Array.from(n[t]||[]);if(s.includes(e)){const n=s.indexOf(e);s.splice(n,1),this.notifications.set(t,Array.from(s))}}))},updateNotifications(e,t){const n=this.notifications.toJSON(),s=n[t]||[];if(s.includes(e))return;const i=(i,r)=>(i[r]=r===t?[...s,e]:(n[r]||[]).filter((t=>t!==e)),i),r=Mc.CHAT_STATES.reduce(i,{}),o=Mc.MUC_TRAFFIC_STATES_LIST.reduce(i,{}),a=Mc.MUC_ROLE_CHANGES_LIST.reduce(i,{});this.notifications.set(Object.assign(r,o,a)),window.setTimeout((()=>this.removeNotification(e,t)),1e4)},handleMetadataFastening(e){if(!Cc.settings.get("muc_show_ogp_unfurls"))return!1;if(e.ogp_for_id){if(e.from!==this.get("jid"))return!1;const t=this.messages.findWhere({origin_id:e.ogp_for_id});if(t){const n=t.get("ogp_metadata")||[];if(n.filter((t=>t["og:url"]===e["og:url"])).length)return!1;const s=[...n,Pr(e,_u)];return t.save("ogp_metadata",s),!0}}return!1},async onMessage(e){if(e=await e,nu.isErrorObject(e))return e.stanza&&as.error(e.stanza),as.error(e.message);const t=this.getDuplicateMessage(e);if(t)return this.updateMessage(t,e);if(!(e.is_valid_receipt_request||e.is_marker||this.ignorableCSN(e)))if(this.handleMetadataFastening(e)||await this.handleRetraction(e)||await this.handleModeration(e)||await this.handleSubjectChange(e))e.nick&&this.removeNotification(e.nick,["composing","paused"]);else if(this.setEditable(e,e.time),e.chat_state&&this.updateNotifications(e.nick,e.chat_state),nu.shouldCreateGroupchatMessage(e)){const t=this.handleCorrection(e)||await this.createMessage(e);this.removeNotification(e.nick,["composing","paused"]),this.handleUnreadMessage(t)}},handleModifyError(e){var t;const n=null===(t=e.querySelector("error text"))||void 0===t?void 0:t.textContent;if(n)if(this.session.get("connection_status")===Mc.ROOMSTATUS.CONNECTING)this.setDisconnectionState(n);else{const e={type:"error",message:n,is_ephemeral:!0};this.createMessage(e)}},handleDisconnection(e){var t;const n=null!==e.querySelector("status[code='110']"),s=qr()('x[xmlns="'.concat(zs.NS.MUC_USER,'"]'),e).pop();if(!s)return;const i=Object.keys(So.muc.disconnect_messages),r=qr()("status",s).map((e=>e.getAttribute("code"))).filter((e=>i.includes(e)));if(!(n&&r.length>0))return;const o=s.querySelector("item"),a=o?null===(t=o.querySelector("reason"))||void 0===t?void 0:t.textContent:void 0,c=o?No(o.querySelector("actor"),"getAttribute","nick"):void 0,l=So.muc.disconnect_messages[r[0]],u=r.includes("301")?Mc.ROOMSTATUS.BANNED:Mc.ROOMSTATUS.DISCONNECTED;this.setDisconnectionState(l,a,c,u)},getActionInfoMessage(e,t,n){const s=So.__;return"301"===e?n?s("%1$s has been banned by %2$s",t,n):s("%1$s has been banned",t):"303"===e?s("%1$s's nickname has changed",t):"307"===e?n?s("%1$s has been kicked out by %2$s",t,n):s("%1$s has been kicked out",t):"321"===e?s("%1$s has been removed because of an affiliation change",t):"322"===e?s("%1$s has been removed for not being a member",t):void 0},createAffiliationChangeMessage(e){const t=So.__,n=e._previousAttributes.affiliation;if(!n)return;const s=e.get("affiliation");"admin"===n&&So.isInfoVisible(Mc.AFFILIATION_CHANGES.EXADMIN)?this.createMessage({type:"info",message:t("%1$s is no longer an admin of this groupchat",e.get("nick"))}):"owner"===n&&So.isInfoVisible(Mc.AFFILIATION_CHANGES.EXOWNER)?this.createMessage({type:"info",message:t("%1$s is no longer an owner of this groupchat",e.get("nick"))}):"outcast"===n&&So.isInfoVisible(Mc.AFFILIATION_CHANGES.EXOUTCAST)&&this.createMessage({type:"info",message:t("%1$s is no longer banned from this groupchat",e.get("nick"))}),"none"===s&&"member"===n&&So.isInfoVisible(Mc.AFFILIATION_CHANGES.EXMEMBER)&&this.createMessage({type:"info",message:t("%1$s is no longer a member of this groupchat",e.get("nick"))}),"member"===s&&So.isInfoVisible(Mc.AFFILIATION_CHANGES.MEMBER)?this.createMessage({type:"info",message:t("%1$s is now a member of this groupchat",e.get("nick"))}):("admin"===s&&So.isInfoVisible(Mc.AFFILIATION_CHANGES.ADMIN)||"owner"==s&&So.isInfoVisible(Mc.AFFILIATION_CHANGES.OWNER))&&this.createMessage({type:"info",message:t("%1$s is now an %2$s of this groupchat",e.get("nick"),s)})},createRoleChangeMessage(e,t){if("none"===t||e.changed.affiliation)return;const n=e._previousAttributes.role;"moderator"===n&&So.isInfoVisible(Mc.MUC_ROLE_CHANGES.DEOP)?this.updateNotifications(e.get("nick"),Mc.MUC_ROLE_CHANGES.DEOP):"visitor"===n&&So.isInfoVisible(Mc.MUC_ROLE_CHANGES.VOICE)&&this.updateNotifications(e.get("nick"),Mc.MUC_ROLE_CHANGES.VOICE),"visitor"===e.get("role")&&So.isInfoVisible(Mc.MUC_ROLE_CHANGES.MUTE)?this.updateNotifications(e.get("nick"),Mc.MUC_ROLE_CHANGES.MUTE):"moderator"===e.get("role")&&!["owner","admin"].includes(e.get("affiliation"))&&So.isInfoVisible(Mc.MUC_ROLE_CHANGES.OP)&&this.updateNotifications(e.get("nick"),Mc.MUC_ROLE_CHANGES.OP)},createInfoMessage(e,t,n){const s=So.__,i={type:"info"};if(So.isInfoVisible(e)&&"110"!==e&&("100"!==e||n)){if(e in So.muc.info_messages)i.message=So.muc.info_messages[e];else if(!n&&wu.includes(e)){var r,o;const n=zs.getResourceFromJid(t.getAttribute("from")),s=qr()('x[xmlns="'.concat(zs.NS.MUC_USER,'"] item'),t).pop();i.actor=s?null===(r=s.querySelector("actor"))||void 0===r?void 0:r.getAttribute("nick"):void 0,i.reason=s?null===(o=s.querySelector("reason"))||void 0===o?void 0:o.textContent:void 0,i.message=this.getActionInfoMessage(e,n,i.actor)}else if(n&&e in So.muc.new_nickname_messages){let r;n&&"210"===e?r=zs.getResourceFromJid(t.getAttribute("from")):n&&"303"===e&&(r=qr()('x[xmlns="'.concat(zs.NS.MUC_USER,'"] item'),t).pop().getAttribute("nick")),this.save("nick",r),i.message=s(So.muc.new_nickname_messages[e],r)}if(i.message){if("201"===e&&this.messages.findWhere(i))return;if(e in So.muc.info_messages&&this.messages.length&&this.messages.pop().get("message")===i.message)return;this.createMessage(i)}}},createInfoMessages(e){const t=qr()('x[xmlns="'.concat(zs.NS.MUC_USER,'"] status'),e).map((e=>e.getAttribute("code")));t.includes("333")&&t.includes("307")&&t.splice(t.indexOf("307"),1);const n=t.includes("110");t.forEach((t=>this.createInfoMessage(t,e,n)))},setDisconnectionState(e,t,n,s=Mc.ROOMSTATUS.DISCONNECTED){this.session.save({connection_status:s,disconnection_actor:n,disconnection_message:e,disconnection_reason:t})},onNicknameClash(e){const t=So.__;if(Cc.settings.get("muc_nickname_from_jid")){const t=e.getAttribute("from").split("/")[1];if(t===So.getDefaultMUCNickname())this.join(t+"-2");else{const e=t.lastIndexOf("-"),n=t.substring(e+1,t.length);this.join(t.substring(0,e+1)+String(Number(n)+1))}}else this.save({nickname_validation_message:t("The nickname you chose is reserved or currently in use, please choose a different one.")}),this.session.save({connection_status:Mc.ROOMSTATUS.NICKNAME_REQUIRED})},onErrorPresence(e){var t;const n=So.__,s=e.querySelector("error"),i=s.getAttribute("type"),r=null===(t=qr()('text[xmlns="'.concat(zs.NS.STANZAS,'"]'),s).pop())||void 0===t?void 0:t.textContent;if("modify"===i)this.handleModifyError(e);else if("auth"===i)if(qr()('not-authorized[xmlns="'.concat(zs.NS.STANZAS,'"]'),s).length&&(this.save({password_validation_message:r||n("Password incorrect")}),this.session.save({connection_status:Mc.ROOMSTATUS.PASSWORD_REQUIRED})),s.querySelector("registration-required")){const e=n("You are not on the member list of this groupchat.");this.setDisconnectionState(e,r)}else s.querySelector("forbidden")&&this.setDisconnectionState(So.muc.disconnect_messages[301],r,null,Mc.ROOMSTATUS.BANNED);else if("cancel"===i)if(s.querySelector("not-allowed")){const e=n("You are not allowed to create new groupchats.");this.setDisconnectionState(e,r)}else if(s.querySelector("not-acceptable")){const e=n("Your nickname doesn't conform to this groupchat's policies.");this.setDisconnectionState(e,r)}else if(qr()('gone[xmlns="'.concat(zs.NS.STANZAS,'"]'),s).length){var o;const e=null===(o=qr()('gone[xmlns="'.concat(zs.NS.STANZAS,'"]'),s).pop())||void 0===o?void 0:o.textContent.replace(/^xmpp:/,"").replace(/\?join$/,"");this.save({moved_jid:e,destroyed_reason:r}),this.session.save({connection_status:Mc.ROOMSTATUS.DESTROYED})}else if(s.querySelector("conflict"))this.onNicknameClash(e);else if(s.querySelector("item-not-found")){const e=n("This groupchat does not (yet) exist.");this.setDisconnectionState(e,r)}else if(s.querySelector("service-unavailable")){const e=n("This groupchat has reached its maximum number of participants.");this.setDisconnectionState(e,r)}else if(s.querySelector("remote-server-not-found")){const e=n("Remote server not found"),t=r?n('The explanation given is: "%1$s".',r):void 0;this.setDisconnectionState(e,t)}},onPresenceFromMUCHost(e){if("error"===e.getAttribute("type")){const t=e.querySelector("error");"wait"===(null==t?void 0:t.getAttribute("type"))&&(null==t?void 0:t.querySelector("resource-constraint"))&&this.session.get("connection_status")===Mc.ROOMSTATUS.DISCONNECTED&&this.rejoin()}},onPresence(e){if("error"===e.getAttribute("type"))return this.onErrorPresence(e);this.createInfoMessages(e),e.querySelector("status[code='110']")?(this.onOwnPresence(e),"none"!==this.getOwnRole()&&this.session.get("connection_status")===Mc.ROOMSTATUS.CONNECTING&&this.session.save("connection_status",Mc.ROOMSTATUS.CONNECTED)):this.updateOccupantsOnPresence(e)},async onOwnPresence(e){await this.occupants.fetched;const t=this.session.get("connection_status");if("unavailable"!==e.getAttribute("type")&&t!==Mc.ROOMSTATUS.ENTERED?(this.session.save("connection_status",Mc.ROOMSTATUS.ENTERED,{silent:!0}),this.updateOccupantsOnPresence(e),this.session.trigger("change:connection_status",this.session,t)):this.updateOccupantsOnPresence(e),"unavailable"!==e.getAttribute("type")){if(e.querySelector("status[code='201']"))if(this.get("auto_configure"))this.autoConfigureChatRoom().then((()=>this.refreshDiscoInfo()));else{if(!Cc.settings.get("muc_instant_rooms"))return void this.session.save({view:Mc.MUC.VIEWS.CONFIG});this.sendConfiguration().then((()=>this.refreshDiscoInfo()))}else this.features.get("fetched")||("owner"===this.getOwnAffiliation()&&this.get("auto_configure")?this.autoConfigureChatRoom().then((()=>this.refreshDiscoInfo())):this.getDiscoInfo());this.session.save({connection_status:Mc.ROOMSTATUS.ENTERED})}else this.handleDisconnection(e)},isUserMentioned(e){const t=this.get("nick");return e.get("references").length?e.get("references").filter((e=>"mention"===e.type)).map((e=>e.value)).includes(t):new RegExp("\\b".concat(t,"\\b")).test(e.get("message"))},handleUnreadMessage(e){if((null==e?void 0:e.get("body"))&&nu.isNewMessage(e))if("me"===e.get("sender"))this.model.set("scrolled",!1);else if(this.isHidden()||this.get("scrolled")){const t={num_unread_general:this.get("num_unread_general")+1};0===this.get("num_unread_general")&&(t.first_unread_id=e.get("id")),this.isUserMentioned(e)&&(t.num_unread=this.get("num_unread")+1),this.save(t)}else this.sendMarkerForMessage(e)},clearUnreadMsgCounter(){(this.get("num_unread_general")>0||this.get("num_unread")>0||this.get("has_activity"))&&this.sendMarkerForMessage(this.messages.last()),nu.safeSave(this,{has_activity:!1,num_unread:0,num_unread_general:0})}},Eu=ao.extend({defaults:{hats:[],show:"offline",states:[]},initialize(e){this.set(Object.assign({id:nu.getUniqueId()},e)),this.on("change:image_hash",this.onAvatarChanged,this)},onAvatarChanged(){const e=this.get("image_hash"),t=[];this.get("jid")&&t.push(So.vcards.findWhere({jid:this.get("jid")})),t.push(So.vcards.findWhere({jid:this.get("from")})),t.filter((e=>e)).forEach((t=>{e&&t.get("image_hash")!==e&&Cc.vcard.update(t,!0)}))},getDisplayName(){return this.get("nick")||this.get("jid")},isMember(){return["admin","owner","member"].includes(this.get("affiliation"))},isModerator(){return["admin","owner"].includes(this.get("affiliation"))||"moderator"===this.get("role")},isSelf(){return this.get("states").includes("110")}}),ju={moderator:1,participant:2,visitor:3,none:2},Au=ua.extend({model:Eu,comparator(e,t){const n=e.get("role")||"none",s=t.get("role")||"none";if(ju[n]===ju[s]){const n=e.getDisplayName().toLowerCase(),s=t.getDisplayName().toLowerCase();return ns?1:0}return ju[n]hu(e,t)))),s=n.reduce(((e,t)=>nu.isErrorObject(t)?e:[...t,...e]),[]),i=e.filter((t=>!nu.isErrorObject(n[e.indexOf(t)]))),r=s.map((e=>e.jid)).filter((e=>void 0!==e)),o=s.map((e=>!e.jid&&e.nick||void 0)).filter((e=>void 0!==e));this.filter((e=>i.includes(e.get("affiliation"))&&!o.includes(e.get("nick"))&&!r.includes(e.get("jid")))).forEach((e=>{e.get("jid")!==So.bare_jid&&("offline"===e.get("show")?e.destroy():e.save("affiliation",null))})),s.forEach((e=>{const t=e.jid?this.findOccupant({jid:e.jid}):this.findOccupant({nick:e.nick});t?t.save(e):this.create(e)})),Cc.trigger("membersFetched")},findOccupant(e){const t=zs.getBareJidFromJid(e.jid);return t&&this.findWhere({jid:t})||this.findWhere({nick:e.nick})}}),Cu={affiliations:{set:(e,t)=>(t=Array.isArray(t)?t:[t],fu(e=Array.isArray(e)?e:[e],t))}},ku={rooms:{create(e,t={}){if(!(t="string"==typeof t?{nick:t}:t||{}).nick&&Cc.settings.get("muc_nickname_from_jid")&&(t.nick=zs.getNodeFromJid(So.bare_jid)),void 0===e)throw new TypeError("rooms.create: You need to provide at least one JID");return"string"==typeof e?Cc.rooms.get(nu.getJIDFromURI(e),t,!0):e.map((e=>Cc.rooms.get(nu.getJIDFromURI(e),t,!0)))},async open(e,t={},n=!1){if(await Cc.waitUntil("chatBoxesFetched"),void 0===e){const e="rooms.open: You need to provide at least one JID";throw as.error(e),new TypeError(e)}if("string"==typeof e){const s=await Cc.rooms.get(e,t,!0);return!t.hidden&&(null==s||s.maybeShow(n)),s}{const s=await Promise.all(e.map((e=>Cc.rooms.get(e,t,!0))));return s.forEach((e=>!t.hidden&&e.maybeShow(n))),s}},async get(e,t={},n=!1){async function s(e){e=nu.getJIDFromURI(e);let s=await Cc.chatboxes.get(e);return!s&&n?s=await Cc.chatboxes.create(e,t,So.ChatRoom):(s=s&&s.get("type")===So.CHATROOMS_TYPE?s:null,s&&Object.keys(t).length&&s.save(t)),s}return await Cc.waitUntil("chatBoxesFetched"),void 0===e?(await Cc.chatboxes.get()).filter((e=>e.get("type")===So.CHATROOMS_TYPE)):"string"==typeof e?s(e):Promise.all(e.map((e=>s(e))))}}},Ou=["moderator","participant","visitor"],Tu=["owner","admin","member","outcast","none"];Mc.AFFILIATION_CHANGES={OWNER:"owner",ADMIN:"admin",MEMBER:"member",EXADMIN:"exadmin",EXOWNER:"exowner",EXOUTCAST:"exoutcast",EXMEMBER:"exmember"},Mc.AFFILIATION_CHANGES_LIST=Object.values(Mc.AFFILIATION_CHANGES),Mc.MUC_TRAFFIC_STATES={ENTERED:"entered",EXITED:"exited"},Mc.MUC_TRAFFIC_STATES_LIST=Object.values(Mc.MUC_TRAFFIC_STATES),Mc.MUC_ROLE_CHANGES={OP:"op",DEOP:"deop",VOICE:"voice",MUTE:"mute"},Mc.MUC_ROLE_CHANGES_LIST=Object.values(Mc.MUC_ROLE_CHANGES),Mc.MUC={},Mc.MUC.INFO_CODES={visibility_changes:["100","102","103","172","173","174"],self:["110"],non_privacy_changes:["104","201"],muc_logging_changes:["170","171"],nickname_changes:["210","303"],disconnected:["301","307","321","322","332","333"],affiliation_changes:[...Mc.AFFILIATION_CHANGES_LIST],join_leave_events:[...Mc.MUC_TRAFFIC_STATES_LIST],role_changes:[...Mc.MUC_ROLE_CHANGES_LIST]};const{Strophe:Nu,sizzle:Iu}=Mc.env;function Mu(){So.connection.addHandler((e=>(So.onDirectMUCInvitation(e),!0)),"jabber:x:conference","message")}function Ru(){return So.chatboxes.filter((e=>e.get("type")===So.CHATROOMS_TYPE)).forEach((e=>e.session.save({connection_status:Mc.ROOMSTATUS.DISCONNECTED})))}async function Du(e){"visible"===e.state&&Cc.connection.connected()&&(await Cc.rooms.get()).forEach((e=>e.rejoinIfNecessary()))}async function zu(e){if(!nu.isValidMUCJID(e))return as.warn('invalid jid "'.concat(e,'" provided in url fragment'));await Cc.waitUntil("roomsAutoJoined"),Cc.settings.get("allow_bookmarks")&&await Cc.waitUntil("bookmarksInitialized"),Cc.rooms.open(e)}async function Lu(){await Promise.all(Cc.settings.get("auto_join_rooms").map((e=>"string"==typeof e?So.chatboxes.where({jid:e}).length?Promise.resolve():Cc.rooms.open(e):s(e)?Cc.rooms.open(e.jid,{...e}):(as.error('Invalid muc criteria specified for "auto_join_rooms"'),Promise.resolve())))),Cc.trigger("roomsAutoJoined")}Nu.addNamespace("MUC_ADMIN",Nu.NS.MUC+"#admin"),Nu.addNamespace("MUC_OWNER",Nu.NS.MUC+"#owner"),Nu.addNamespace("MUC_REGISTER","jabber:iq:register"),Nu.addNamespace("MUC_ROOMCONF",Nu.NS.MUC+"#roomconfig"),Nu.addNamespace("MUC_USER",Nu.NS.MUC+"#user"),Nu.addNamespace("MUC_HATS","xmpp:prosody.im/protocol/hats:1"),Mc.MUC_NICK_CHANGED_CODE="303",Mc.ROOM_FEATURES=["passwordprotected","unsecured","hidden","publicroom","membersonly","open","persistent","temporary","nonanonymous","semianonymous","moderated","unmoderated","mam_enabled"],Mc.ROOMSTATUS={CONNECTED:0,CONNECTING:1,NICKNAME_REQUIRED:2,PASSWORD_REQUIRED:3,DISCONNECTED:4,ENTERED:5,DESTROYED:6,BANNED:7},Mc.plugins.add("converse-muc",{dependencies:["converse-chatboxes","converse-chat","converse-disco","converse-controlbox"],overrides:{ChatBoxes:{model(e,t){const{_converse:n}=this.__super__;return e&&e.type==n.CHATROOMS_TYPE?new n.ChatRoom(e,t):this.__super__.model.apply(this,arguments)}}},initialize(){const{__:e,___:t}=So;if(Cc.settings.extend({allow_muc:!0,allow_muc_invitations:!0,auto_join_on_invite:!1,auto_join_rooms:[],auto_register_muc_nickname:!1,hide_muc_participants:!1,locked_muc_domain:!1,muc_clear_messages_on_leave:!0,muc_domain:void 0,muc_fetch_members:!0,muc_history_max_stanzas:void 0,muc_instant_rooms:!0,muc_nickname_from_jid:!1,muc_send_probes:!1,muc_show_info_messages:[...Mc.MUC.INFO_CODES.visibility_changes,...Mc.MUC.INFO_CODES.self,...Mc.MUC.INFO_CODES.non_privacy_changes,...Mc.MUC.INFO_CODES.muc_logging_changes,...Mc.MUC.INFO_CODES.nickname_changes,...Mc.MUC.INFO_CODES.disconnected,...Mc.MUC.INFO_CODES.affiliation_changes,...Mc.MUC.INFO_CODES.join_leave_events,...Mc.MUC.INFO_CODES.role_changes],muc_show_logs_before_join:!1,muc_show_ogp_unfurls:!0,muc_subscribe_to_rai:!1}),Cc.promises.add(["roomsAutoJoined"]),Cc.settings.get("locked_muc_domain")&&"string"!=typeof Cc.settings.get("muc_domain"))throw new Error("Config Error: it makes no sense to set locked_muc_domain to true when muc_domain is not set");Mc.env.muc_utils={computeAffiliationsDelta:mu},Object.assign(Cc,ku),Object.assign(Cc.rooms,Cu),So.muc={info_messages:{100:e("This groupchat is not anonymous"),102:e("This groupchat now shows unavailable members"),103:e("This groupchat does not show unavailable members"),104:e("The groupchat configuration has changed"),170:e("Groupchat logging is now enabled"),171:e("Groupchat logging is now disabled"),172:e("This groupchat is now no longer anonymous"),173:e("This groupchat is now semi-anonymous"),174:e("This groupchat is now fully-anonymous"),201:e("A new groupchat has been created")},new_nickname_messages:{210:t("Your nickname has been automatically set to %1$s"),303:t("Your nickname has been changed to %1$s")},disconnect_messages:{301:e("You have been banned from this groupchat"),333:e("You have exited this groupchat due to a technical problem"),307:e("You have been kicked from this groupchat"),321:e("You have been removed from this groupchat because of an affiliation change"),322:e("You have been removed from this groupchat because the groupchat has changed to members-only and you're not a member"),332:e("You have been removed from this groupchat because the service hosting it is being shut down")}},So.isInfoVisible=function(e){return!!Cc.settings.get("muc_show_info_messages").includes(e)},So.router.route("converse/room?jid=:jid",zu),So.ChatRoom=So.ChatBox.extend(xu),So.ChatRoomMessage=So.Message.extend(Kl),So.ChatRoomOccupants=Au,So.ChatRoomOccupant=Eu,So.getDefaultMUCNickname=function(){if(!So.xmppstatus)throw new Error("Can't call _converse.getDefaultMUCNickname before the statusInitialized has been fired.");return So.xmppstatus.getNickname()||(Cc.settings.get("muc_nickname_from_jid")?Nu.unescapeNode(Nu.getNodeFromJid(So.bare_jid)):void 0)},So.ChatRoomMessages=ua.extend({model:So.ChatRoomMessage,comparator:"time"}),So.onDirectMUCInvitation=async function(t){const n=Iu('x[xmlns="jabber:x:conference"]',t).pop(),s=Nu.getBareJidFromJid(t.getAttribute("from")),i=n.getAttribute("jid"),r=n.getAttribute("reason");let o;if(Cc.settings.get("auto_join_on_invite"))o=!0;else{let t=So.roster.get(s);t=t?t.getDisplayName():s,o=r?confirm(e('%1$s has invited you to join a groupchat: %2$s, and left the following reason: "%3$s"',t,i,r)):confirm(e("%1$s has invited you to join a groupchat: %2$s",t,i))}!0===o&&(await async function(e,t){t.type=So.CHATROOMS_TYPE,t.id=e;const n=await Cc.rooms.get(e,t,!0);return n.maybeShow(!0),n}(i,{password:n.getAttribute("password")})).session.get("connection_status")===Mc.ROOMSTATUS.DISCONNECTED&&So.chatboxes.get(i).rejoin()},Cc.settings.get("allow_muc_invitations")&&(Cc.listen.on("connected",Mu),Cc.listen.on("reconnected",Mu)),Cc.listen.on("beforeTearDown",(()=>{So.chatboxes.where({type:So.CHATROOMS_TYPE}).forEach((e=>nu.safeSave(e.session,{connection_status:Mc.ROOMSTATUS.DISCONNECTED})))})),Cc.listen.on("windowStateChanged",Du),Cc.listen.on("addClientFeatures",(()=>{Cc.settings.get("allow_muc")&&Cc.disco.own.features.add(Nu.NS.MUC),Cc.settings.get("allow_muc_invitations")&&Cc.disco.own.features.add("jabber:x:conference")})),Cc.listen.on("chatBoxesFetched",Lu),Cc.listen.on("beforeResourceBinding",(()=>{So.connection.addHandler((e=>{const t=Nu.getBareJidFromJid(e.getAttribute("from"));return So.chatboxes.get(t)||Cc.waitUntil("chatBoxesFetched").then((async()=>{const n=So.chatboxes.get(t);n&&(await n.initialized,n.message_handler.run(e))})),!0}),null,"message","groupchat")})),Cc.listen.on("disconnected",Ru),Cc.listen.on("statusInitialized",(()=>{window.addEventListener(So.unloadevent,(()=>{!Cc.connection.isType("websocket")||Cc.settings.get("enable_smacks")&&So.session.get("smacks_stream_id")||Ru()}))}))}});const{Strophe:Pu}=Mc.env,Fu=ao.extend({idAttribute:"jid",getDisplayName(){return Pu.xmlunescape(this.get("name"))}});var Bu=n(2353),Uu=n.n(Bu);function qu(e,t){return"string"==typeof e&&t.includes(e)}function Hu(e,t){return"string"!=typeof e||"en"!==e&&!t(e)?function(e){let t;if(window.navigator.userLanguage&&(t=$u(window.navigator.userLanguage,e)),window.navigator.languages&&!t)for(let n=0;nHu(e,(e=>qu(e,t))),translate(e){if(!Gu)return Uu().sprintf.apply(Uu(),arguments);const t=Gu.translate(e);return arguments.length>1?t.fetch.apply(t,[].slice.call(arguments,1)):t.fetch()},async initialize(){if(So.isTestEnv())So.locale="en";else try{const e=Cc.settings.get("i18n");So.locale=Zn.getLocale(e,Cc.settings.get("locales")),await async function(e){const{api:t,locale:s}=e,i=s.toLowerCase().replace("_","-");if(!qu(s,t.settings.get("locales"))||"en"===s)return;const{default:r}=await n(7521)("./".concat(s,"/LC_MESSAGES/converse.po"));await n(9434)("./".concat(i,".js")),Ao().locale(Hu(i,(e=>Ao().locale(e)))),Gu=new(Uu())(r)}(So)}catch(e){as.fatal(e.message),So.locale="en"}},__:(...e)=>Zn.translate(...e)});const Vu=Zn.__,{Strophe:Wu,$iq:Ju,sizzle:Qu}=Mc.env,Yu={model:Fu,comparator:e=>e.get("name").toLowerCase(),initialize(){this.on("add",(e=>this.openBookmarkedRoom(e).then((e=>this.markRoomAsBookmarked(e))).catch((e=>as.fatal(e))))),this.on("remove",this.markRoomAsUnbookmarked,this),this.on("remove",this.sendBookmarkStanza,this);const e="converse.room-bookmarks".concat(So.bare_jid);this.fetched_flag=e+"fetched",Cr(this,e)},openBookmarkedRoom:async e=>(Cc.settings.get("muc_respect_autojoin")&&e.get("autojoin")&&(await Cc.rooms.create(e.get("jid"),{nick:e.get("nick")})).maybeShow(),e),fetchBookmarks(){const e=Et();return window.sessionStorage.getItem(this.fetched_flag)?this.fetch({success:()=>e.resolve(),error:()=>e.resolve()}):this.fetchBookmarksFromServer(e),e},createBookmark(e){this.create(e),this.sendBookmarkStanza().catch((t=>this.onBookmarkError(t,e)))},sendBookmarkStanza(){const e=Ju({type:"set",from:So.connection.jid}).c("pubsub",{xmlns:Wu.NS.PUBSUB}).c("publish",{node:Wu.NS.BOOKMARKS}).c("item",{id:"current"}).c("storage",{xmlns:Wu.NS.BOOKMARKS});return this.forEach((t=>{e.c("conference",{name:t.get("name"),autojoin:t.get("autojoin"),jid:t.get("jid")}).c("nick").t(t.get("nick")).up().up()})),e.up().up().up(),e.c("publish-options").c("x",{xmlns:Wu.NS.XFORM,type:"submit"}).c("field",{var:"FORM_TYPE",type:"hidden"}).c("value").t("http://jabber.org/protocol/pubsub#publish-options").up().up().c("field",{var:"pubsub#persist_items"}).c("value").t("true").up().up().c("field",{var:"pubsub#access_model"}).c("value").t("whitelist"),Cc.sendIQ(e)},onBookmarkError(e,t){as.error("Error while trying to add bookmark"),as.error(e),Cc.alert("error",Vu("Error"),[Vu("Sorry, something went wrong while trying to save your bookmark.")]),this.findWhere({jid:t.jid}).destroy()},fetchBookmarksFromServer(e){const t=Ju({from:So.connection.jid,type:"get"}).c("pubsub",{xmlns:Wu.NS.PUBSUB}).c("items",{node:Wu.NS.BOOKMARKS});Cc.sendIQ(t).then((t=>this.onBookmarksReceived(e,t))).catch((t=>this.onBookmarksReceivedError(e,t)))},markRoomAsBookmarked(e){const t=So.chatboxes.get(e.get("jid"));void 0!==t&&t.save("bookmarked",!0)},markRoomAsUnbookmarked(e){const t=So.chatboxes.get(e.get("jid"));void 0!==t&&t.save("bookmarked",!1)},createBookmarksFromStanza(e){const t=Wu.NS.BOOKMARKS,n='items[node="'.concat(t,'"] item storage[xmlns="').concat(t,'"] conference');Qu(n,e).forEach((e=>{var t;const n=e.getAttribute("jid"),s=this.get(n),i={jid:n,name:e.getAttribute("name")||n,autojoin:"true"===e.getAttribute("autojoin"),nick:(null===(t=e.querySelector("nick"))||void 0===t?void 0:t.textContent)||""};s?s.save(i):this.create(i)}))},onBookmarksReceived(e,t){if(this.createBookmarksFromStanza(t),window.sessionStorage.setItem(this.fetched_flag,!0),void 0!==e)return e.resolve()},onBookmarksReceivedError(e,t){if(null===t)as.error("Error: timeout while fetching bookmarks"),Cc.alert("error",Vu("Timeout Error"),[Vu("The server did not return your bookmarks within the allowed time. You can reload the page to request them again.")]);else{if(e)return t.querySelector('error[type="cancel"] item-not-found')?(window.sessionStorage.setItem(this.fetched_flag,!0),e.resolve()):(as.error("Error while fetching bookmarks"),as.error(t),e.reject(new Error("Could not fetch bookmarks")));as.error("Error while fetching bookmarks"),as.error(t)}},getUnopenedBookmarks(){return this.filter((e=>!So.chatboxes.get(e.get("jid"))))}},{Strophe:Ku}=Mc.env;async function Xu(){const e=await Cc.disco.getIdentity("pubsub","pep",So.bare_jid);return So.allow_public_bookmarks?!!e:Cc.disco.supports(Ku.NS.PUBSUB+"#publish-options",So.bare_jid)}const{Strophe:Zu,sizzle:ed}=Mc.env;function td(e){return ed('event[xmlns="'.concat(Zu.NS.PUBSUB,'#event"] items[node="').concat(Zu.NS.BOOKMARKS,'"]'),e).length&&Cc.waitUntil("bookmarksInitialized").then((()=>So.bookmarks.createBookmarksFromStanza(e))).catch((e=>as.fatal(e))),!0}Zu.addNamespace("BOOKMARKS","storage:bookmarks"),Mc.plugins.add("converse-bookmarks",{dependencies:["converse-chatboxes","converse-muc"],overrides:{ChatRoom:{getDisplayName(){const{_converse:e}=this.__super__;if(this.get("bookmarked")&&e.bookmarks){const t=e.bookmarks.findWhere({jid:this.get("jid")});if(t)return t.get("name")}return this.__super__.getDisplayName.apply(this,arguments)},getAndPersistNickname(e){return e=e||function(e){if(!So.bookmarks||!Cc.settings.get("allow_bookmarks"))return null;const t=So.bookmarks.findWhere({jid:e});return t?t.get("nick"):void 0}(this.get("jid")),this.__super__.getAndPersistNickname.call(this,e)}}},initialize(){Cc.settings.extend({allow_bookmarks:!0,allow_public_bookmarks:!1,muc_respect_autojoin:!0}),Cc.promises.add("bookmarksInitialized"),So.Bookmark=Fu,So.Bookmarks=ua.extend(Yu),So.BookmarksList=ao.extend({defaults:{"toggle-state":So.OPENED}}),Cc.listen.on("addClientFeatures",(()=>{Cc.settings.get("allow_bookmarks")&&Cc.disco.own.features.add(Zu.NS.BOOKMARKS+"+notify")})),Cc.listen.on("clearSession",(()=>{void 0!==So.bookmarks&&(So.bookmarks.clearStore({silent:!0}),window.sessionStorage.removeItem(So.bookmarks.fetched_flag),delete So.bookmarks)})),Cc.listen.on("connected",(async()=>{const{connection:e}=So;e.addHandler(td,null,"message","headline",null,So.bare_jid),await Promise.all([Cc.waitUntil("chatBoxesFetched")]),async function(){Cc.settings.get("allow_bookmarks")&&await Xu()&&(So.bookmarks=new So.Bookmarks,await So.bookmarks.fetchBookmarks(),Cc.trigger("bookmarksInitialized"))}()}))}});const{Strophe:nd}=Mc.env,sd="converse.bosh-session";Mc.plugins.add("converse-bosh",{enabled:()=>!So.api.settings.get("blacklisted_plugins").includes("converse-bosh"),initialize(){Cc.settings.extend({bosh_service_url:void 0,prebind_url:null}),So.startNewPreboundBOSHSession=function(){if(!Cc.settings.get("prebind_url"))throw new Error("startNewPreboundBOSHSession: If you use prebind then you MUST supply a prebind_url");const e=new XMLHttpRequest;e.open("GET",Cc.settings.get("prebind_url"),!0),e.setRequestHeader("Accept","application/json, text/javascript"),e.onload=async function(){if(e.status>=200&&e.status<400){const t=JSON.parse(e.responseText),n=await So.setUserJID(t.jid);So.connection.attach(n,t.sid,t.rid,So.connection.onConnectStatusChanged)}else e.onerror()},e.onerror=function(){delete So.connection,Cc.trigger("noResumeableBOSHSession",So)},e.send()},So.restoreBOSHSession=async function(){const e=(await async function(){const e=sd;if(So.bosh_session||(So.bosh_session=new ao({id:e}),So.bosh_session.browserStorage=So.createStore(e,"session"),await new Promise((e=>So.bosh_session.fetch({success:e,error:e})))),So.jid){if(So.bosh_session.get("jid")!==So.jid){const e=await So.setUserJID(So.jid);So.bosh_session.clear({silent:!0}),So.bosh_session.save({jid:e})}}else{const e=So.bosh_session.get("jid");e&&await So.setUserJID(e)}return So.bosh_session}()).get("jid");if(e&&So.connection._proto instanceof nd.Bosh)try{return So.connection.restore(e,So.connection.onConnectStatusChanged),!0}catch(t){return!So.isTestEnv()&&as.warn("Could not restore session for jid: "+e+" Error message: "+t.message),!1}return!1},Cc.listen.on("clearSession",(()=>{if(void 0===So.bosh_session){const e=sd;sessionStorage.removeItem(e),sessionStorage.removeItem("".concat(e,"-").concat(e))}else So.bosh_session.destroy(),delete So.bosh_session})),Cc.listen.on("setUserJID",(()=>{void 0!==So.bosh_session&&So.bosh_session.save({jid:So.jid})})),Cc.listen.on("addClientFeatures",(()=>Cc.disco.own.features.add(nd.NS.BOSH))),Object.assign(Cc,{tokens:{get:e=>void 0===So.connection?null:"rid"===e.toLowerCase()?So.connection.rid||So.connection._proto.rid:"sid"===e.toLowerCase()?So.connection.sid||So.connection._proto.sid:void 0}})}});const{Strophe:id,$build:rd}=Mc.env;function od(e,t){return e.sort(((e,n)=>e[t]>n[t]?-1:1))}function ad(){const e=So.api.disco.own.identities.get(),t=So.api.disco.own.features.get();e.length>1&&(od(e,"category"),od(e,"type"),od(e,"lang"));let n=e.reduce(((e,t)=>{var n;return"".concat(e).concat(t.category,"/").concat(t.type,"/").concat(null!==(n=null==t?void 0:t.lang)&&void 0!==n?n:"","/").concat(t.name,"<")}),"");return t.sort(),n=t.reduce(((e,t)=>"".concat(e).concat(t,"<")),n),Ts.b64_sha1(n)}const{Strophe:cd}=Mc.env;function ld(e){var t,n;if(e&&(null===(n=So.session)||void 0===n||n.set({carbons_enabled:!1})),!Cc.settings.get("message_carbons")||(null===(t=So.session)||void 0===t?void 0:t.get("carbons_enabled")))return;const s=new zs.Builder("iq",{from:So.connection.jid,id:"enablecarbons",type:"set"}).c("enable",{xmlns:zs.NS.CARBONS});So.connection.addHandler((e=>{e.querySelectorAll("error").length>0?as.warn("An error occurred while trying to enable message carbons."):(So.session.set({carbons_enabled:!0}),as.debug("Message carbons have been enabled.")),So.session.save()}),null,"iq",null,"enablecarbons"),So.connection.send(s)}cd.addNamespace("CAPS","http://jabber.org/protocol/caps"),Mc.plugins.add("converse-caps",{dependencies:["converse-status"],initialize(){Cc.listen.on("constructedPresence",((e,t)=>t.root().cnode(rd("c",{xmlns:id.NS.CAPS,hash:"sha-1",node:"https://conversejs.org",ver:ad()}).nodeTree).up()&&t))}}),Mc.plugins.add("converse-carbons",{initialize(){Cc.settings.extend({message_carbons:!0}),Cc.listen.on("afterResourceBinding",ld)}});const ud=ua.extend({comparator:"time_opened",model:(e,t)=>new So.ChatBox(e,t),onChatBoxesFetched(e){e.filter((e=>!e.isValid())).forEach((e=>e.destroy())),Cc.trigger("chatBoxesFetched")},onConnected(e){e||(Cr(this,"converse.chatboxes-".concat(So.bare_jid)),this.fetch({add:!0,success:e=>this.onChatBoxesFetched(e)}))}}),{Strophe:dd}=Mc.env;async function hd(e,t,n){let s;e=dd.getBareJidFromJid(e.toLowerCase()),Object.assign(t,{jid:e,id:e});try{s=new n(t,{collection:So.chatboxes})}catch(e){return as.error(e),null}return await s.initialized,s.isValid()?(So.chatboxes.add(s),s):(s.destroy(),null)}const fd={create:async(e=[],t={},n)=>(await Cc.waitUntil("chatBoxesFetched"),"string"==typeof e?hd(e,t,n):Promise.all(e.map((e=>hd(e,t,n))))),get:async e=>(await Cc.waitUntil("chatBoxesFetched"),void 0===e?So.chatboxes.models:"string"==typeof e?So.chatboxes.get(e.toLowerCase()):(e=e.map((e=>e.toLowerCase())),So.chatboxes.models.filter((t=>e.includes(t.get("jid"))))))},{Strophe:gd}=Mc.env;Mc.plugins.add("converse-chatboxes",{dependencies:["converse-emoji","converse-roster","converse-vcard"],initialize(){Cc.promises.add(["chatBoxesFetched","chatBoxesInitialized","privateChatsAutoJoined"]),Object.assign(Cc,{chatboxes:fd}),So.ChatBoxes=ud,Cc.listen.on("addClientFeatures",(()=>{Cc.disco.own.features.add(gd.NS.MESSAGE_CORRECT),Cc.disco.own.features.add(gd.NS.HTTPUPLOAD),Cc.disco.own.features.add(gd.NS.OUTOFBAND)})),Cc.listen.on("pluginsInitialized",(()=>{So.chatboxes=new So.ChatBoxes,Cc.trigger("chatBoxesInitialized")})),Cc.listen.on("presencesInitialized",(e=>So.chatboxes.onConnected(e))),Cc.listen.on("reconnected",(()=>So.chatboxes.forEach((e=>e.onReconnection()))))}}),Mc.plugins.add("converse-headlines",{dependencies:["converse-chat"],overrides:{ChatBoxes:{model(e,t){const{_converse:n}=this.__super__;return e.type==n.HEADLINES_TYPE?new n.HeadlinesBox(e,t):this.__super__.model.apply(this,arguments)}}},initialize(){function e(){So.connection.addHandler((e=>async function(e){if(Zc(e)||el(e)){const t=e.getAttribute("from");if(t.includes("@")&&!So.roster.get(t)&&!Cc.settings.get("allow_non_roster_messaging"))return;if(null===e.querySelector("body"))return;const n=So.chatboxes.create({id:t,jid:t,type:So.HEADLINES_TYPE,from:t}),s=await hl(e,So);await n.createMessage(s),Cc.trigger("message",{chatbox:n,stanza:e,attrs:s})}}(e)||!0),null,"message")}So.HeadlinesBox=So.ChatBox.extend({defaults(){return{bookmarked:!1,hidden:["mobile","fullscreen"].includes(Cc.settings.get("view_mode")),message_type:"headline",num_unread:0,time_opened:this.get("time_opened")||(new Date).getTime(),type:So.HEADLINES_TYPE}},async initialize(){this.set({box_id:"box-".concat(this.get("jid"))}),this.initMessages(),await this.fetchMessages(),Cc.trigger("headlinesBoxInitialized",this)}}),Cc.listen.on("connected",e),Cc.listen.on("reconnected",e),Object.assign(Cc,{headlines:{async get(e,t={},n=!1){async function s(e){let s=await Cc.chatboxes.get(e);return!s&&n?s=await Cc.chatboxes.create(e,t,So.HeadlinesBox):(s=s&&s.get("type")===So.HEADLINES_TYPE?s:null,s&&Object.keys(t).length&&s.save(t)),s}return void 0===e?(await Cc.chatboxes.get()).filter((e=>e.get("type")===So.HEADLINES_TYPE)):"string"==typeof e?s(e):Promise.all(e.map((e=>s(e))))}}})}});const{Strophe:md,$build:pd}=Mc.env;md.addNamespace("RSM","http://jabber.org/protocol/rsm");const vd=["after","before","index","max"],bd=e=>Number(e),yd=e=>e.toString(),_d={after:yd,before:yd,count:bd,first:yd,index:bd,last:yd,max:bd},wd=e=>void 0===e,Sd=Object.keys(_d);class xd{static getQueryParameters(e={}){return Pr(e,vd)}static parseXMLResult(e){const t={};for(var n=0;nwd(this.query[t])?e:e.c(t).t((this.query[t]||"").toString()).up()),e).tree()}next(e,t){const n=Object.assign({},this.query,{after:this.result.last,before:t,max:e});return new xd(n)}previous(e,t){const n=Object.assign({},this.query,{after:t,before:this.result.first,max:e});return new xd(n)}}So.RSM_ATTRIBUTES=Sd,So.RSM=xd;const{Strophe:Ed,$iq:jd,dayjs:Ad}=Mc.env,{NS:Cd}=Ed,kd=Mc.env.utils,Od={archive:{async query(e){if(!Cc.connection.connected())throw new Error("Can't call `api.archive.query` before having established an XMPP session");const t={type:"set"};if(e&&e.groupchat){if(!e.with)throw new Error('You need to specify a "with" value containing the chat room JID, when querying groupchat messages.');t.to=e.with}const n=t.to||So.bare_jid;if(!await Cc.disco.supports(Cd.MAM,n))return as.warn("Did not fetch MAM archive for ".concat(n," because it doesn't support ").concat(Cd.MAM)),{messages:[]};const s=kd.getUniqueId(),i=jd(t).c("query",{xmlns:Cd.MAM,queryid:s});if(e){i.c("x",{xmlns:Cd.XFORM,type:"submit"}).c("field",{var:"FORM_TYPE",type:"hidden"}).c("value").t(Cd.MAM).up().up(),e.with&&!e.groupchat&&i.c("field",{var:"with"}).c("value").t(e.with).up().up(),["start","end"].forEach((t=>{if(e[t]){const n=Ad(e[t]);if(!n.isValid())throw new TypeError("archive.query: invalid date provided for: ".concat(t));i.c("field",{var:t}).c("value").t(n.toISOString()).up().up()}})),i.up();const t=new xd(e);Object.keys(t.query).length&&i.cnode(t.toXML())}const r=[],o=So.connection.addHandler((t=>{const n=qr()('message > result[xmlns="'.concat(Cd.MAM,'"]'),t).pop();if(void 0===n||n.getAttribute("queryid")!==s)return!0;const i=t.getAttribute("from")||So.bare_jid;if(e.groupchat){if(i!==e.with)return as.warn("Ignoring alleged groupchat MAM message from ".concat(t.getAttribute("from"))),!0}else if(i!==So.bare_jid)return as.warn("Ignoring alleged MAM message from ".concat(t.getAttribute("from"))),!0;return r.push(t),!0}),Cd.MAM);let a;const c=await Cc.sendIQ(i,Cc.settings.get("message_archiving_timeout"),!1);if(null===c){const{__:e}=So,t=e("Timeout while trying to fetch archived messages.");return as.error(t),a=new So.TimeoutError(t),{messages:r,error:a}}if(kd.isErrorStanza(c)){const{__:e}=So,t=e("An error occurred while querying for archived messages.");return as.error(t),as.error(c),a=new Error(t),{messages:r,error:a}}let l;So.connection.deleteHandler(o);const u=c&&qr()('fin[xmlns="'.concat(Cd.MAM,'"]'),c).pop(),d="true"===(null==u?void 0:u.getAttribute("complete")),h=qr()('set[xmlns="'.concat(Cd.RSM,'"]'),u).pop();return h&&(l=new xd({...e,xml:h})),{messages:r,rsm:l,complete:d}}}},{Strophe:Td,$iq:Nd}=Mc.env,{NS:Id}=Td,Md=Mc.env.utils;function Rd(e){(null==e?void 0:e.querySelectorAll("feature-not-implemented").length)?as.warn("Message Archive Management (XEP-0313) not supported by ".concat(e.getAttribute("from"))):(as.error("Error while trying to set archiving preferences for ".concat(e.getAttribute("from"),".")),as.error(e))}function Dd(e,t){const n=qr()('prefs[xmlns="'.concat(Id.MAM,'"]'),e).pop();if(n.getAttribute("default")!==Cc.settings.get("message_archiving")){const e=Nd({type:"set"}).c("prefs",{xmlns:Id.MAM,default:Cc.settings.get("message_archiving")});Array.from(n.children).forEach((t=>e.cnode(t).up())),Cc.sendIQ(e).then((()=>t.save({preferences:{default:Cc.settings.get("message_archiving")}}))).catch(So.onMAMError)}else t.save({preferences:{default:Cc.settings.get("message_archiving")}})}function zd(e){const t=e.get("preferences")||{};e.get("var")===Id.MAM&&void 0!==Cc.settings.get("message_archiving")&&t.default!==Cc.settings.get("message_archiving")&&Cc.sendIQ(Nd({type:"get"}).c("prefs",{xmlns:Id.MAM})).then((t=>So.onMAMPreferences(t,e))).catch(So.onMAMError)}function Ld(e){Cc.settings.get("muc_show_logs_before_join")&&e.features.get("mam_enabled")&&!e.get("prejoin_mam_fetched")&&(Bd(e),e.save({prejoin_mam_fetched:!0}))}async function Pd(e,t,n,s,i){await Cc.emojis.initialize();const r=e.get("type")===So.CHATROOMS_TYPE;t.messages=t.messages.map((t=>r?cu(t,e,So):hl(t,So)));const o={query:n,chatbox:e,messages:t.messages};if(await Cc.trigger("MAMResult",o,{synchronous:!0}),t.messages.forEach((t=>e.queueMessage(t))),t.error){const n=t.error.retry_event_id=Md.getUniqueId();Cc.listen.once(n,(()=>Fd(e,s,i))),e.createMessageFromError(t.error)}}async function Fd(e,t={},n=null){if(e.disable_mam)return;const s=e.get("type")===So.CHATROOMS_TYPE,i=s?e.get("jid"):So.bare_jid;if(!await Cc.disco.supports(Id.MAM,i))return;const r=Cc.settings.get("archived_messages_page_size"),o=Object.assign({groupchat:s,max:r,with:e.get("jid")},t),a=await Cc.archive.query(o);return await Pd(e,a,o,t,n),a.rsm&&!a.complete&&n?("forwards"===n?t=a.rsm.next(r,t.before).query:"backwards"===n&&(t=a.rsm.previous(r,t.after).query),Fd(e,t,n)):void 0}function Bd(e){if(e.disable_mam)return;const t=e.most_recent_cached_message;if(t&&!Cc.settings.get("clear_messages_on_reconnection"))if(Cc.settings.get("mam_request_all_pages")){const n=t.get("stanza_id ".concat(e.get("jid")));Fd(e,n?{after:n}:{start:t.get("time")},"forwards")}else Fd(e,{before:"",start:t.get("time")});else Fd(e,{before:""})}const{Strophe:Ud}=Mc.env,{NS:qd}=Ud;Mc.plugins.add("converse-mam",{dependencies:["converse-disco","converse-muc"],initialize(){Cc.settings.extend({archived_messages_page_size:"50",mam_request_all_pages:!0,message_archiving:void 0,message_archiving_timeout:2e4}),Object.assign(Cc,Od),Object.assign(So,{onMAMError:Rd,onMAMPreferences:Dd,handleMAMResult:Pd}),Cc.listen.on("addClientFeatures",(()=>Cc.disco.own.features.add(qd.MAM))),Cc.listen.on("serviceDiscovered",zd),Cc.listen.on("chatRoomViewInitialized",(e=>{Cc.settings.get("muc_show_logs_before_join")&&(Ld(e.model),e.model.features.on("change:mam_enabled",(()=>Ld(e.model))))})),Cc.listen.on("enteredNewRoom",(e=>e.features.get("mam_enabled")&&Bd(e))),Cc.listen.on("chatReconnected",(e=>{e.get("type")===So.PRIVATE_CHAT_TYPE&&Bd(e)})),Cc.listen.on("afterMessagesFetched",(e=>{e.get("type")!==So.PRIVATE_CHAT_TYPE||So.connection.restored||Bd(e)}))}});const{Strophe:Hd,$iq:$d}=Mc.env;let Gd;function Vd(e){"visible"===e.state&&Cc.connection.connected()&&Cc.ping(null,5e3)}function Wd(e){Gd=new Date;const t=e.getAttribute("from"),n=e.getAttribute("id"),s=$d({type:"result",to:t,id:n});return So.connection.sendIQ(s),!0}function Jd(){void 0!==So.connection.disco&&Cc.disco.own.features.add(Hd.NS.PING),So.connection.addHandler(Wd,Hd.NS.PING,"iq","get"),So.connection.addHandler((()=>{if(Cc.settings.get("ping_interval")>0)return Gd=new Date,!0}))}function Qd(){if(So.isTestEnv()||!Cc.connection.connected())return;const e=Cc.settings.get("ping_interval");if(e>0){const t=new Date;Gd||(Gd=t),(t-Gd)/1e3>e&&Cc.ping()}}const{Strophe:Yd,$iq:Kd,u:Xd}=Mc.env,Zd={async ping(e,t){var n;if(n=new Date,Gd=n,e=e||Yd.getDomainFromJid(So.bare_jid),So.connection){const n=Kd({type:"get",to:e,id:Xd.getUniqueId("ping")}).c("ping",{xmlns:Yd.NS.PING}),s=await Cc.sendIQ(n,t||1e4,!1);return null===s?(as.warn("Timeout while pinging ".concat(e)),e===Yd.getDomainFromJid(So.bare_jid)&&Cc.connection.reconnect()):Xd.isErrorStanza(s)&&(as.error("Error while pinging ".concat(e)),as.error(s)),!0}return!1}},{Strophe:eh}=Mc.env;eh.addNamespace("PING","urn:xmpp:ping"),Mc.plugins.add("converse-ping",{initialize(){Cc.settings.extend({ping_interval:60}),Object.assign(Cc,Zd),setInterval(Qd,1e3),Cc.listen.on("connected",Jd),Cc.listen.on("reconnected",Jd),Cc.listen.on("windowStateChanged",Vd)}});const{Strophe:th,$iq:nh}=Mc.env;th.addNamespace("PUBSUB_ERROR",th.NS.PUBSUB+"#errors"),Mc.plugins.add("converse-pubsub",{dependencies:["converse-disco"],initialize(){Object.assign(So.api,{pubsub:{async publish(e,t,n,s,i=!0){const r=nh({from:So.bare_jid,type:"set",to:e}).c("pubsub",{xmlns:th.NS.PUBSUB}).c("publish",{node:t}).cnode(n.tree()).up().up();s&&(e=e||So.bare_jid,await Cc.disco.supports(th.NS.PUBSUB+"#publish-options",e)?(r.c("publish-options").c("x",{xmlns:th.NS.XFORM,type:"submit"}).c("field",{var:"FORM_TYPE",type:"hidden"}).c("value").t("".concat(th.NS.PUBSUB,"#publish-options")).up().up(),Object.keys(s).forEach((e=>r.c("field",{var:e}).c("value").t(s[e]).up().up()))):as.warn("_converse.api.publish: ".concat(e," does not support #publish-options, ")+"so we didn't set them even though they were provided."));try{await Cc.sendIQ(r)}catch(e){if(!(e instanceof Element&&i&&e.querySelector('precondition-not-met[xmlns="'.concat(th.NS.PUBSUB_ERROR,'"]'))))throw e;{const e=r.nodeTree;e.querySelector("publish-options").outerHTML="",as.warn("PubSub: Republishing without publish options. ".concat(e.outerHTML)),await Cc.sendIQ(e)}}}}})}});const sh=function(e){return function(e){return"number"==typeof e||de(e)&&"[object Number]"==y(e)}(e)&&e!=+e},{Strophe:ih,$pres:rh}=Mc.env,oh=ao.extend({defaults:()=>({status:Cc.settings.get("default_state")}),initialize(){this.on("change",(e=>{s(e.changed)&&("status"in e.changed||"status_message"in e.changed)&&Cc.user.presence.send(this.get("status"),null,this.get("status_message"))}))},getNickname:()=>So.nickname,getFullname:()=>"",async constructPresence(e,t=null,n){let s;e="string"==typeof e?e:this.get("status")||Cc.settings.get("default_state"),n="string"==typeof n?n:this.get("status_message");const i={to:t};"unavailable"===e||"probe"===e||"error"===e||"unsubscribe"===e||"unsubscribed"===e||"subscribe"===e||"subscribed"===e?(i.type=e,s=rh(i)):"offline"===e?(i.type="unavailable",s=rh(i)):s="online"===e?rh(i):rh(i).c("show").t(e).up(),n&&s.c("status").t(n).up();const r=Cc.settings.get("priority");if(s.c("priority").t(sh(Number(r))?0:r).up(),So.idle){const e=new Date;e.setSeconds(e.getSeconds()-So.idle_seconds),s.c("idle",{xmlns:ih.NS.IDLE,since:e.toISOString()})}return s=await Cc.hook("constructedPresence",null,s),s}}),ah={presence:{async send(e,t,n,s){await Cc.waitUntil("statusInitialized");const i=await So.xmppstatus.constructPresence(e,t,n);s&&(Array.isArray(s)||(s=[s]),s.map((e=>{var t;return null!==(t=null==e?void 0:e.tree())&&void 0!==t?t:e})).forEach((e=>i.cnode(e).up()))),Cc.send(i)}},status:{get:async()=>(await Cc.waitUntil("statusInitialized"),So.xmppstatus.get("status")),async set(e,t){const n={status:e};if(!Object.keys(So.STATUS_WEIGHTS).includes(e))throw new Error("Invalid availability value. See https://xmpp.org/rfcs/rfc3921.html#rfc.section.2.2.2.1");"string"==typeof t&&(n.status_message=t),await Cc.waitUntil("statusInitialized"),So.xmppstatus.save(n)},message:{get:async()=>(await Cc.waitUntil("statusInitialized"),So.xmppstatus.get("status_message")),async set(e){await Cc.waitUntil("statusInitialized"),So.xmppstatus.save({status_message:e})}}}},{Strophe:ch,$build:lh}=Mc.env;function uh(e){Cc.trigger("statusInitialized",e)}function dh(e){if(e=void 0!==So.xmppstatus&&e)uh(e);else{const t="converse.xmppstatus-".concat(So.bare_jid);So.xmppstatus=new So.XMPPStatus({id:t}),Cr(So.xmppstatus,t,"session"),So.xmppstatus.fetch({success:()=>uh(e),error:()=>uh(e),silent:!0})}}function hh(){var e;So.idle_seconds>0&&(So.idle_seconds=0),(null===(e=So.connection)||void 0===e?void 0:e.authenticated)&&(So.inactive&&So.sendCSI(So.ACTIVE),So.idle&&(So.idle=!1,Cc.user.presence.send()),!0===So.auto_changed_status&&(So.auto_changed_status=!1,So.xmppstatus.set("status",Cc.settings.get("default_state"))))}function fh(){var e;if(!(null===(e=So.connection)||void 0===e?void 0:e.authenticated))return;const t=So.xmppstatus.get("status");So.idle_seconds++,Cc.settings.get("csi_waiting_time")>0&&So.idle_seconds>Cc.settings.get("csi_waiting_time")&&!So.inactive&&So.sendCSI(So.INACTIVE),Cc.settings.get("idle_presence_timeout")>0&&So.idle_seconds>Cc.settings.get("idle_presence_timeout")&&!So.idle&&(So.idle=!0,Cc.user.presence.send()),Cc.settings.get("auto_away")>0&&So.idle_seconds>Cc.settings.get("auto_away")&&"away"!==t&&"xa"!==t&&"dnd"!==t?(So.auto_changed_status=!0,So.xmppstatus.set("status","away")):Cc.settings.get("auto_xa")>0&&So.idle_seconds>Cc.settings.get("auto_xa")&&"xa"!==t&&"dnd"!==t&&(So.auto_changed_status=!0,So.xmppstatus.set("status","xa"))}function gh(e){Cc.send(lh(e,{xmlns:ch.NS.CSI})),So.inactive=e===So.INACTIVE}function mh(){if(Cc.settings.get("auto_away")<1&&Cc.settings.get("auto_xa")<1&&Cc.settings.get("csi_waiting_time")<1&&Cc.settings.get("idle_presence_timeout")<1)return;So.idle_seconds=0,So.auto_changed_status=!1;const{unloadevent:e}=So;window.addEventListener("click",So.onUserActivity),window.addEventListener("focus",So.onUserActivity),window.addEventListener("keypress",So.onUserActivity),window.addEventListener("mousemove",So.onUserActivity),window.addEventListener(e,So.onUserActivity,{once:!0,passive:!0}),window.addEventListener(e,(()=>{var e;return null===(e=So.session)||void 0===e?void 0:e.save("active",!1)})),So.everySecondTrigger=window.setInterval(So.onEverySecond,1e3)}Mc.plugins.add("converse-status",{initialize(){Cc.settings.extend({auto_away:0,auto_xa:0,csi_waiting_time:0,default_state:"online",priority:0}),Cc.promises.add(["statusInitialized"]),So.XMPPStatus=oh,So.onUserActivity=hh,So.onEverySecond=fh,So.sendCSI=gh,So.registerIntervalHandler=mh,Object.assign(So.api.user,ah),Cc.listen.on("presencesInitialized",(e=>{e||So.registerIntervalHandler()})),Cc.listen.on("clearSession",(()=>{So.shouldClearCache()&&So.xmppstatus&&(So.xmppstatus.destroy(),delete So.xmppstatus,Cc.promises.add(["statusInitialized"]))})),Cc.listen.on("connected",(()=>dh(!1))),Cc.listen.on("reconnected",(()=>dh(!0)))}});const{Strophe:ph,$iq:vh,$pres:bh}=Mc.env,yh=ao.extend({defaults:{chat_state:void 0,image:So.DEFAULT_IMAGE,image_type:So.DEFAULT_IMAGE_TYPE,num_unread:0,status:void 0},async initialize(e){this.initialized=Et(),this.setPresence();const{jid:t}=e,n=ph.getBareJidFromJid(t).toLowerCase();e.jid=n,this.set(Object.assign({groups:[],id:n,jid:n,user_id:ph.getNodeFromJid(t)},e)),this.listenTo(this.presence,"change:show",(()=>Cc.trigger("contactPresenceChanged",this))),this.listenTo(this.presence,"change:show",(()=>this.trigger("presenceChanged"))),await Cc.trigger("rosterContactInitialized",this,{Synchronous:!0}),this.initialized.resolve()},setPresence(){const e=this.get("jid");this.presence=So.presences.findWhere({jid:e})||So.presences.create({jid:e})},openChat(){const e=this.attributes;Cc.chats.open(e.jid,e,!0)},getFilterCriteria(){const e=this.get("nickname"),t=this.get("jid");let n=this.getDisplayName();return n=n.includes(t)?n:n.concat(" ".concat(t)),n=n.includes(e)?n:n.concat(" ".concat(e)),n.toLowerCase()},getDisplayName(){return this.get("nickname")?this.get("nickname"):this.get("jid")},getFullname(){return this.get("jid")},subscribe(e){const t=bh({to:this.get("jid"),type:"subscribe"});e&&""!==e&&t.c("status").t(e).up();const n=So.xmppstatus.getNickname()||So.xmppstatus.getFullname();return n&&t.c("nick",{xmlns:ph.NS.NICK}).t(n).up(),Cc.send(t),this.save("ask","subscribe"),this},ackSubscribe(){Cc.send(bh({type:"subscribe",to:this.get("jid")}))},ackUnsubscribe(){Cc.send(bh({type:"unsubscribe",to:this.get("jid")})),this.removeFromRoster(),this.destroy()},unauthorize(e){return So.rejectPresenceSubscription(this.get("jid"),e),this},authorize(e){const t=bh({to:this.get("jid"),type:"subscribed"});return e&&""!==e&&t.c("status").t(e),Cc.send(t),this},removeFromRoster(){const e=vh({type:"set"}).c("query",{xmlns:ph.NS.ROSTER}).c("item",{jid:this.get("jid"),subscription:"remove"});return Cc.sendIQ(e)}}),{Strophe:_h,$iq:wh,sizzle:Sh}=Mc.env,xh=Mc.env.utils,Eh=ua.extend({model:yh,initialize(){const e="roster.state-".concat(So.bare_jid,"-").concat(this.get("jid"));this.state=new ao({id:e,collapsed_groups:[]}),Cr(this.state,e),this.state.fetch()},onConnected(){this.registerRosterHandler(),this.registerRosterXHandler()},registerRosterHandler(){So.connection.addHandler((e=>(So.roster.onRosterPush(e),!0)),_h.NS.ROSTER,"iq","set")},registerRosterXHandler(){let e=0;So.connection.addHandler((function(t){return window.setTimeout((function(){So.connection.flush(),So.roster.subscribeToSuggestedItems.bind(So.roster)(t)}),e),e+=250*t.querySelectorAll("item").length,!0}),_h.NS.ROSTERX,"message",null)},async fetchRosterContacts(){const e=await new Promise(((e,t)=>{this.fetch({add:!0,silent:!0,success:e,error:(e,n)=>t(n)})}));if(xh.isErrorObject(e)&&(as.error(e),So.session.save("roster_cached",!1),this.data.save("version",void 0)),!So.session.get("roster_cached"))return So.send_initial_presence=!0,So.roster.fetchFromServer();Cc.trigger("cachedRoster",e)},subscribeToSuggestedItems:e=>(Array.from(e.querySelectorAll("item")).forEach((e=>{"add"===e.getAttribute("action")&&So.roster.addAndSubscribe(e.getAttribute("jid"),So.xmppstatus.getNickname()||So.xmppstatus.getFullname())})),!0),isSelf:e=>xh.isSameBareJID(e,So.connection.jid),async addAndSubscribe(e,t,n,s,i){const r=await this.addContactToRoster(e,t,n,i);r instanceof So.RosterContact&&r.subscribe(s)},sendContactAddIQ(e,t,n){t=t||null;const s=wh({type:"set"}).c("query",{xmlns:_h.NS.ROSTER}).c("item",{jid:e,name:t});return n.forEach((e=>s.c("group").t(e).up())),Cc.sendIQ(s)},async addContactToRoster(e,t,n,s){await Cc.waitUntil("rosterContactsFetched"),n=n||[];try{await this.sendContactAddIQ(e,t,n)}catch(n){return as.error(n),alert(Vu("Sorry, there was an error while trying to add %1$s as a contact.",t||e)),n}return this.create(Object.assign({ask:void 0,nickname:t,groups:n,jid:e,requesting:!1,subscription:"none"},s),{sort:!1})},async subscribeBack(e,t){const n=this.get(e);if(n instanceof So.RosterContact)n.authorize().subscribe();else{var s;const n=(null===(s=Sh('nick[xmlns="'.concat(_h.NS.NICK,'"]'),t).pop())||void 0===s?void 0:s.textContent)||null,i=await this.addContactToRoster(e,n,[],{subscription:"from"});i instanceof So.RosterContact&&i.authorize().subscribe()}},getNumOnlineContacts(){const e=["offline","unavailable"];return(t=this.models.filter((t=>!e.includes(t.presence.get("show")))))&&t.length?function(e,t){for(var n,s=-1,i=e.length;++s1)throw as.error(e),new Error('Roster push query may not contain more than one "item" element.');if(0===i.length)return as.warn(e),void as.warn('Received a roster push stanza without an "item" element.');this.updateContact(i.pop()),Cc.trigger("rosterPush",e)},rosterVersioningSupported(){return Cc.disco.stream.getFeature("ver","urn:xmpp:features:rosterver")&&this.data.get("version")},async fetchFromServer(){const e=wh({type:"get",id:xh.getUniqueId("roster")}).c("query",{xmlns:_h.NS.ROSTER});this.rosterVersioningSupported()&&e.attrs({ver:this.data.get("version")});const t=await Cc.sendIQ(e,null,!1);if("error"!==t.getAttribute("type")){const e=Sh('query[xmlns="'.concat(_h.NS.ROSTER,'"]'),t).pop();e&&(Sh("item",e).forEach((e=>this.updateContact(e))),this.data.save("version",e.getAttribute("ver")))}else if(!xh.isServiceUnavailableError(t))return as.error(t),void as.error("Error while trying to fetch roster from the server");So.session.save("roster_cached",!0),Cc.trigger("roster",t)},updateContact(e){const t=e.getAttribute("jid"),n=this.get(t),s=e.getAttribute("subscription"),i=e.getAttribute("ask"),r=Array.from(e.getElementsByTagName("group")).map((e=>e.textContent));if(n){if("remove"===s)return n.destroy();n.save({subscription:s,ask:i,nickname:e.getAttribute("name"),requesting:null,groups:r})}else{if("none"===s&&null===i||"remove"===s)return;this.create({ask:i,nickname:e.getAttribute("name"),groups:r,jid:t,subscription:s},{sort:!1})}},createRequestingContact(e){var t;const n={jid:_h.getBareJidFromJid(e.getAttribute("from")),subscription:"none",ask:null,requesting:!0,nickname:(null===(t=Sh('nick[xmlns="'.concat(_h.NS.NICK,'"]'),e).pop())||void 0===t?void 0:t.textContent)||null};Cc.trigger("contactRequest",this.create(n))},handleIncomingSubscription(e){const t=e.getAttribute("from"),n=_h.getBareJidFromJid(t),s=this.get(n);Cc.settings.get("allow_contact_requests")||So.rejectPresenceSubscription(t,Vu("This client does not allow presence subscriptions")),Cc.settings.get("auto_subscribe")?s&&"to"===s.get("subscription")?s.authorize():this.subscribeBack(n,e):s?("none"!==s.get("subscription")||"subscribe"===s.get("ask"))&&s.authorize():this.createRequestingContact(e)},handleOwnPresence(e){const t=e.getAttribute("from"),n=_h.getResourceFromJid(t),s=e.getAttribute("type");if(So.connection.jid!==t&&"unavailable"!==s&&(!0===Cc.settings.get("synchronize_availability")||Cc.settings.get("synchronize_availability")===n)){var i,r;const t=(null===(i=e.querySelector("show"))||void 0===i?void 0:i.textContent)||"online";So.xmppstatus.save({status:t},{silent:!0});const n=null===(r=e.querySelector("status"))||void 0===r?void 0:r.textContent;n&&So.xmppstatus.save({status_message:n})}So.jid===t&&"unavailable"===s&&Cc.user.presence.send()},presenceHandler(e){var t;const n=e.getAttribute("type");if("error"===n)return!0;const s=e.getAttribute("from"),i=_h.getBareJidFromJid(s);if(this.isSelf(i))return this.handleOwnPresence(e);if(Sh('query[xmlns="'.concat(_h.NS.MUC,'"]'),e).length)return;const r=null===(t=e.querySelector("status"))||void 0===t?void 0:t.textContent,o=this.get(i);if(o&&r!==o.get("status")&&o.save({status:r}),"subscribed"===n&&o)o.ackSubscribe();else if("unsubscribed"===n&&o)o.ackUnsubscribe();else{if("unsubscribe"===n)return;if("subscribe"===n)this.handleIncomingSubscription(e);else if("unavailable"===n&&o){const e=_h.getResourceFromJid(s);o.presence.removeResource(e)}else o&&o.presence.addResource(e)}}}),{Strophe:jh}=Mc.env,Ah={contacts:{async get(e){await Cc.waitUntil("rosterContactsFetched");const t=e=>So.roster.get(jh.getBareJidFromJid(e));if(void 0===e)e=So.roster.pluck("jid");else if("string"==typeof e)return t(e);return e.map(t)},async add(e,t){if(await Cc.waitUntil("rosterContactsFetched"),"string"!=typeof e||!e.includes("@"))throw new TypeError("contacts.add: invalid jid");return So.roster.addAndSubscribe(e,t)}}},{Strophe:Ch,dayjs:kh,sizzle:Oh}=Mc.env,Th=ao.extend({idAttribute:"name"}),Nh=ua.extend({model:Th}),Ih=ao.extend({defaults:{show:"offline"},initialize(){this.resources=new Nh;const e="converse.identities-".concat(this.get("jid"));Cr(this.resources,e,"session"),this.listenTo(this.resources,"update",this.onResourcesChanged),this.listenTo(this.resources,"change",this.onResourcesChanged)},onResourcesChanged(){var e;const t=this.getHighestPriorityResource(),n=(null==t||null===(e=t.attributes)||void 0===e?void 0:e.show)||"offline";this.get("show")!==n&&this.save({show:n})},getHighestPriorityResource(){return this.resources.sortBy((e=>"".concat(e.get("priority"),"-").concat(e.get("timestamp")))).reverse()[0]},addResource(e){var t,n,s,i;const r=e.getAttribute("from"),o=Ch.getResourceFromJid(r),a=Oh('delay[xmlns="'.concat(Ch.NS.DELAY,'"]'),e).pop(),c=null!==(t=null===(n=e.querySelector("priority"))||void 0===n?void 0:n.textContent)&&void 0!==t?t:0,l=this.resources.get(o),u={name:o,priority:sh(parseInt(c,10))?0:parseInt(c,10),show:null!==(s=null===(i=e.querySelector("show"))||void 0===i?void 0:i.textContent)&&void 0!==s?s:"online",timestamp:a?kh(a.getAttribute("stamp")).toISOString():(new Date).toISOString()};l?l.save(u):this.resources.create(u)},removeResource(e){const t=this.resources.get(e);t&&t.destroy()}}),Mh=ua.extend({model:Ih});function Rh(e){const t=So.roster&&So.roster.findWhere({jid:e.get("jid")});void 0!==t&&t.save({num_unread:e.get("num_unread")})}async function Dh(){var e;await(null===(e=So.presences)||void 0===e?void 0:e.clearStore())}function zh(e,t){const n=e.presence.get("show")||"offline",s=t.presence.get("show")||"offline";if(So.STATUS_WEIGHTS[n]===So.STATUS_WEIGHTS[s]){const n=e.getDisplayName().toLowerCase(),s=t.getDisplayName().toLowerCase();return ns?1:0}return So.STATUS_WEIGHTS[n]t.toLowerCase()?1:0;if(r&&o)return s[e]s[t]?1:0;if(!r&&o){const e=So.HEADER_CURRENT_CONTACTS;return s[e]s[t]?1:0}if(r&&!o){const t=So.HEADER_CURRENT_CONTACTS;return s[e]s[t]?1:0}}const{$pres:Ph}=Mc.env;Mc.plugins.add("converse-roster",{dependencies:["converse-status"],initialize(){Cc.settings.extend({allow_contact_requests:!0,auto_subscribe:!1,synchronize_availability:!0}),Cc.promises.add(["cachedRoster","roster","rosterContactsFetched","rosterInitialized"]),Object.assign(So.api,Ah),So.HEADER_CURRENT_CONTACTS=Vu("My contacts"),So.HEADER_PENDING_CONTACTS=Vu("Pending contacts"),So.HEADER_REQUESTING_CONTACTS=Vu("Contact requests"),So.HEADER_UNGROUPED=Vu("Ungrouped"),So.HEADER_UNREAD=Vu("New messages"),So.registerPresenceHandler=function(){So.unregisterPresenceHandler(),So.presence_ref=So.connection.addHandler((e=>(So.roster.presenceHandler(e),!0)),null,"presence",null)},So.rejectPresenceSubscription=function(e,t){const n=Ph({to:e,type:"unsubscribed"});t&&""!==t&&n.c("status").t(t),Cc.send(n)},So.sendInitialPresence=function(){So.send_initial_presence&&Cc.user.presence.send()},So.populateRoster=async function(e=!1){e&&(So.send_initial_presence=!0);try{await So.roster.fetchRosterContacts(),Cc.trigger("rosterContactsFetched")}catch(e){as.error(e)}finally{So.sendInitialPresence()}},So.Presence=Ih,So.Presences=Mh,So.RosterContact=yh,So.RosterContacts=Eh,So.unregisterPresenceHandler=function(){void 0!==So.presence_ref&&(So.connection.deleteHandler(So.presence_ref),delete So.presence_ref)},Cc.listen.on("chatBoxesInitialized",(()=>{So.chatboxes.on("change:num_unread",Rh),So.chatboxes.on("add",(e=>{e.get("type")===So.PRIVATE_CHAT_TYPE&&e.setRosterContact(e.get("jid"))}))})),Cc.listen.on("beforeTearDown",(()=>So.unregisterPresenceHandler())),Cc.waitUntil("rosterContactsFetched").then((()=>{So.roster.on("add",(e=>{const t=So.chatboxes.findWhere({jid:e.get("jid")});t&&t.setRosterContact(e.get("jid"))}))})),Cc.listen.on("streamResumptionFailed",(()=>So.session.set("roster_cached",!1))),Cc.listen.on("clearSession",(async()=>{await Dh(),So.shouldClearCache()&&(So.rostergroups&&(await So.rostergroups.clearStore(),delete So.rostergroups),So.roster&&(No(So,"roster.data.destroy"),await So.roster.clearStore(),delete So.roster))})),Cc.listen.on("statusInitialized",(async e=>{if(e)!So.connection.hasResumed()&&await Dh();else{So.presences=new So.Presences;const e="converse.presences-".concat(So.bare_jid);Cr(So.presences,e,"session"),So.presences.fetch()}Cc.trigger("presencesInitialized",e)})),Cc.listen.on("presencesInitialized",(async e=>{e?Cc.trigger("rosterReadyAfterReconnection"):await async function(){await Cc.waitUntil("VCardsInitialized"),So.roster=new So.RosterContacts;let e="converse.contacts-".concat(So.bare_jid);Cr(So.roster,e),So.roster.data=new ao,e="converse-roster-model-".concat(So.bare_jid),So.roster.data.id=e,Cr(So.roster.data,e),So.roster.data.fetch(),Cc.trigger("rosterInitialized")}(),So.roster.onConnected(),So.registerPresenceHandler(),So.populateRoster(!So.connection.restored)}))}});const{Strophe:Fh}=Mc.env,Bh=Mc.env.utils;function Uh(){return!(Cc.connection.isType("bosh")&&!So.isTestEnv())&&Cc.disco.stream.getFeature("sm",Fh.NS.SM)}function qh(e){if(!So.session.get("smacks_enabled"))return!0;const t=parseInt(e.getAttribute("h"),10),n=So.session.get("num_stanzas_handled_by_server"),s=t-n;if(s<0){const e="New reported stanza count lower than previous. "+"New: ".concat(t," - Previous: ").concat(n);as.error(e)}const i=So.session.get("unacked_stanzas");if(s>i.length){const e="Higher reported acknowledge count than unacknowledged stanzas. "+"Reported Acknowledged Count: ".concat(s," -")+"Unacknowledged Stanza Count: ".concat(i.length," -")+"New: ".concat(t," - Previous: ").concat(n);as.error(e)}return So.session.save({num_stanzas_handled_by_server:t,num_stanzas_since_last_ack:0,unacked_stanzas:i.slice(s)}),!0}function Hh(){if(So.session.get("smacks_enabled")){const e=So.session.get("num_stanzas_handled"),t=Bh.toStanza(''));Cc.send(t)}return!0}function $h(e){if(So.session.get("smacks_enabled")&&(Bh.isTagEqual(e,"iq")||Bh.isTagEqual(e,"presence")||Bh.isTagEqual(e,"message"))){const e=So.session.get("num_stanzas_handled");So.session.save("num_stanzas_handled",e+1)}return!0}function Gh(){So.session.save({smacks_enabled:So.session.get("smacks_enabled")||!1,num_stanzas_handled:So.session.get("num_stanzas_handled")||0,num_stanzas_handled_by_server:So.session.get("num_stanzas_handled_by_server")||0,num_stanzas_since_last_ack:So.session.get("num_stanzas_since_last_ack")||0,unacked_stanzas:So.session.get("unacked_stanzas")||[]})}function Vh(){So.session&&So.session.save({smacks_enabled:!1,num_stanzas_handled:0,num_stanzas_handled_by_server:0,num_stanzas_since_last_ack:0,unacked_stanzas:[]})}function Wh(e){const t={smacks_enabled:!0};return["1","true"].includes(e.getAttribute("resume"))&&(t.smacks_stream_id=e.getAttribute("id")),So.session.save(t),!0}function Jh(e){return e.querySelector("item-not-found")?as.warn("Could not resume previous SMACKS session, session id not found. A new session will be established."):(as.error("Failed to enable stream management"),as.error(e.outerHTML)),Vh(),Cc.trigger("streamResumptionFailed"),!0}async function Qh(){if(Cc.settings.get("enable_smacks")&&!So.session.get("smacks_enabled")&&await Uh()){const e=Et();So.connection._addSysHandler((t=>e.resolve(Wh(t))),Fh.NS.SM,"enabled"),So.connection._addSysHandler((t=>e.resolve(Jh(t))),Fh.NS.SM,"failed");const t=Cc.connection.isType("websocket")||So.isTestEnv(),n=Bh.toStanza(''));Cc.send(n),So.connection.flush(),await e}}const Yh=[];async function Kh(){if(!Cc.settings.get("enable_smacks"))return;if(!await Uh())return;const e=So.connection;for(;Yh.length;)e.deleteHandler(Yh.pop());Yh.push(e.addHandler($h)),Yh.push(e.addHandler(Hh,Fh.NS.SM,"r")),Yh.push(e.addHandler(qh,Fh.NS.SM,"a")),So.session.get("smacks_stream_id")?await async function(){const e=Et();So.connection._addSysHandler((t=>e.resolve(function(e){Wh(e),qh(e),function(){const e=So.session.get("unacked_stanzas");So.session.save("unacked_stanzas",[]),e.forEach((e=>Cc.send(e)))}(),So.connection.do_bind=!1,So.connection.authenticated=!0,So.connection.restored=!0,So.connection._changeConnectStatus(Fh.Status.CONNECTED,null)}(t))),Fh.NS.SM,"resumed"),So.connection._addSysHandler((t=>e.resolve(Jh(t))),Fh.NS.SM,"failed");const t=So.session.get("smacks_stream_id"),n=So.session.get("num_stanzas_handled"),s=Bh.toStanza(''));Cc.send(s),So.connection.flush(),await e}():Vh()}function Xh(e){if(So.session){if(So.session.get("smacks_enabled")&&(Bh.isTagEqual(e,"iq")||Bh.isTagEqual(e,"presence")||Bh.isTagEqual(e,"message"))){const t=Fh.serialize(e);So.session.save("unacked_stanzas",(So.session.get("unacked_stanzas")||[]).concat([t]));const n=Cc.settings.get("smacks_max_unacked_stanzas");if(n>0){const e=So.session.get("num_stanzas_since_last_ack")+1;e%n==0&&Cc.send(Bh.toStanza(''))),So.session.save({num_stanzas_since_last_ack:e})}}}else as.warn("No _converse.session!")}const{Strophe:Zh}=Mc.env;Zh.addNamespace("SM","urn:xmpp:sm:3"),Mc.plugins.add("converse-smacks",{initialize(){Cc.settings.extend({enable_smacks:!0,smacks_max_unacked_stanzas:5}),Cc.listen.on("afterResourceBinding",Qh),Cc.listen.on("beforeResourceBinding",Kh),Cc.listen.on("send",Xh),Cc.listen.on("userSessionInitialized",Gh)}});const{Strophe:ef,$iq:tf,dayjs:nf}=Mc.env,sf=Mc.env.utils;Mc.plugins.add("converse-vcard",{dependencies:["converse-status","converse-roster"],overrides:{XMPPStatus:{getNickname(){const{_converse:e}=this.__super__,t=this.__super__.getNickname.apply(this);return!t&&e.xmppstatus.vcard?e.xmppstatus.vcard.get("nickname"):t},getFullname(){const{_converse:e}=this.__super__,t=this.__super__.getFullname.apply(this);return!t&&e.xmppstatus.vcard?e.xmppstatus.vcard.get("fullname"):t}},RosterContact:{getDisplayName(){return!this.get("nickname")&&this.vcard?this.vcard.getDisplayName():this.__super__.getDisplayName.apply(this)},getFullname(){return this.vcard?this.vcard.get("fullname"):this.__super__.getFullname.apply(this)}}},initialize(){function e(e,t,n){const s=tf(t?{type:e,to:t}:{type:e});return n?s.cnode(n):s.c("vCard",{xmlns:ef.NS.VCARD}),s}async function t(t,n){const s=ef.getBareJidFromJid(n)===t.bare_jid?null:n;let i;try{i=await Cc.sendIQ(e("get",s))}catch(i){return{stanza:i,jid:n,vcard_error:(new Date).toISOString()}}return async function(e,t){const n=t.querySelector("vCard");let s={};var i,r,o,a,c,l,u;if(null!==n&&(s={stanza:t,fullname:null===(i=n.querySelector("FN"))||void 0===i?void 0:i.textContent,nickname:null===(r=n.querySelector("NICKNAME"))||void 0===r?void 0:r.textContent,image:null===(o=n.querySelector("PHOTO BINVAL"))||void 0===o?void 0:o.textContent,image_type:null===(a=n.querySelector("PHOTO TYPE"))||void 0===a?void 0:a.textContent,url:null===(c=n.querySelector("URL"))||void 0===c?void 0:c.textContent,role:null===(l=n.querySelector("ROLE"))||void 0===l?void 0:l.textContent,email:null===(u=n.querySelector("EMAIL USERID"))||void 0===u?void 0:u.textContent,vcard_updated:(new Date).toISOString(),vcard_error:void 0}),s.image){const e=sf.base64ToArrayBuffer(s.image),t=await crypto.subtle.digest("SHA-1",e);s.image_hash=sf.arrayBufferToHex(t)}return s}(0,i)}async function n(e){let t;if(e instanceof So.Message){if("error"===e.get("type"))return;t=e.get("from")}else t=e.get("jid");await Cc.waitUntil("VCardsInitialized"),e.vcard=So.vcards.findWhere({jid:t}),e.vcard||(e.vcard=So.vcards.create({jid:t})),e.vcard.on("change",(()=>e.trigger("vcard:change")))}Cc.promises.add("VCardsInitialized"),So.VCard=ao.extend({defaults:{image:So.DEFAULT_IMAGE,image_type:So.DEFAULT_IMAGE_TYPE},set(e,t,n){let s;return"object"==typeof e?(s=e,n=t):(s={})[e]=t,"image"in s&&!s.image?(s.image=So.DEFAULT_IMAGE,s.image_type=So.DEFAULT_IMAGE_TYPE,ao.prototype.set.call(this,s,n)):ao.prototype.set.apply(this,arguments)},getDisplayName(){return this.get("nickname")||this.get("fullname")||this.get("jid")}}),So.VCards=ua.extend({model:So.VCard,initialize(){this.on("add",(e=>e.get("jid")&&Cc.vcard.update(e)))}}),So.initVCardCollection=async function(){So.vcards=new So.VCards;const e="".concat(So.bare_jid,"-converse.vcards");Cr(So.vcards,e),await new Promise((e=>{So.vcards.fetch({success:e,error:e},{silent:!0})}));const t=So.vcards;if(So.session){const e=So.session.get("bare_jid");So.xmppstatus.vcard=t.findWhere({jid:e})||t.create({jid:e})}Cc.trigger("VCardsInitialized")},Cc.listen.on("chatBoxInitialized",(e=>n(e))),Cc.listen.on("chatRoomInitialized",(e=>n(e))),Cc.listen.on("chatRoomMessageInitialized",(e=>async function(e){await Cc.waitUntil("VCardsInitialized"),["error","info"].includes(e.get("type"))||(e.vcard=function(e){var t;const n=null==e||null===(t=e.collection)||void 0===t?void 0:t.chatbox,s=ef.getResourceFromJid(e.get("from"));if(n&&n.get("nick")===s)return So.xmppstatus.vcard;{const t=e.occupant&&e.occupant.get("jid")||e.get("from");return t?So.vcards.findWhere({jid:t})||So.vcards.create({jid:t}):void as.error("Could not assign VCard for message because no JID found! msgid: ".concat(e.get("msgid")))}}(e))}(e))),Cc.listen.on("addClientFeatures",(()=>Cc.disco.own.features.add(ef.NS.VCARD))),Cc.listen.on("clearSession",(()=>{So.shouldClearCache()&&(Cc.promises.add("VCardsInitialized"),So.vcards&&(So.vcards.clearStore(),delete So.vcards))})),Cc.listen.on("messageInitialized",(e=>n(e))),Cc.listen.on("rosterContactInitialized",(e=>n(e))),Cc.listen.on("statusInitialized",So.initVCardCollection),Object.assign(So.api,{vcard:{async set(t,n){if(!t)throw Error("No jid provided for the VCard data");const s=document.createElement("div"),i=sf.toStanza('\n \n '.concat(n.fn,"\n ").concat(n.nickname,"\n ").concat(n.url,"\n ").concat(n.role,"\n ").concat(n.email,"\n \n ").concat(n.image_type,"\n ").concat(n.image,"\n \n "),s);let r;try{r=await Cc.sendIQ(e("set",t,i))}catch(e){throw e}return await Cc.vcard.update(t,!0),r},get(e,n){if("string"==typeof e)return t(So,e);if(!n&&e.get("vcard_updated")&&nf(e.get("vcard_error")).isSame(new Date,"day"))return Promise.resolve({});{const n=e.get("jid");return n||as.error("No JID to get vcard for"),t(So,n)}},async update(e,t){const n=await this.get(e,t);(e="string"==typeof e?So.vcards.findWhere({jid:e}):e)?(delete n.stanza,e.save(n)):as.error("Could not find a VCard model for ".concat(e))}}})}});const rf={};function of(){const e=(t=['\n
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n
\n \n e.toggleBookmark(t),a_class:"toggle-bookmark",icon_class:"fa-bookmark",name:"bookmark"},i=t.map((e=>e.name)).indexOf("details"),r=Xu().then((e=>e?s:""));return i>-1?[...t.slice(0,i),r,...t.slice(i)]:[r,...t]}return t}function hf(e){e.preventDefault();const t=e.target.getAttribute("data-bookmark-name"),n=e.target.getAttribute("data-room-jid");confirm(Vu('Are you sure you want to remove the bookmark "%1$s"?',t))&&uf(So.bookmarks.where({jid:n}),ao.prototype.destroy)}async function ff(e){e.preventDefault();const t=e.target.getAttribute("data-room-jid");(await Cc.rooms.open(t,{bring_to_foreground:!0})).session.save("view",Mc.MUC.VIEWS.BOOKMARK)}function gf(e){e.preventDefault();const{Strophe:t}=Mc.env,n=e.target.textContent,s=e.target.getAttribute("data-room-jid"),i={name:n||t.unescapeNode(t.getNodeFromJid(s))||s};Cc.rooms.open(s,i,!0)}function mf(){const e=(t=['\n
\n \n\n \n \n\n \n ','\n
\n ',"\n
\n
\n "],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return pf=function(){return e},e}"undefined"!=typeof Element&&Element.prototype;const vf=/^(\S+)\s*(.*)$/,bf=["model","collection","events"];class yf extends HTMLElement{constructor(e){var t,n,s;super(),s={},(n="events")in(t=this)?Object.defineProperty(t,n,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[n]=s,this.cid=qi("view"),this._domEvents=[],Us(this,Pr(e,bf))}createRenderRoot(){return this}connectedCallback(){this._initialized||(this.preinitialize.apply(this,arguments),this.initialize.apply(this,arguments),this._initialized=!0),this.delegateEvents()}disconnectedCallback(){this.undelegateEvents(),this.stopListening()}preinitialize(){}initialize(){}render(){return _(this.beforeRender)&&this.beforeRender(),_(this.toHTML)&&Wa(this.toHTML(),this),_(this.afterRender)&&this.afterRender(),this}delegateEvents(){if(!this.events)return this;this.undelegateEvents();for(const e in this.events){let t=this.events[e];if(_(t)||(t=this[t]),!t)continue;const n=e.match(vf);this.delegate(n[1],n[2],t.bind(this))}return this}delegate(e,t,n){const s=this;if(!s)return this;if("function"==typeof t&&(n=t,t=null),-1!==["focus","blur"].indexOf(e)){const s=this.querySelectorAll(t);for(let t=0,i=s.length;tthis.render(),error:(e,t)=>{as.error(t),this.render()}})}render(){Wa((e=>{const t=!!So.bookmarks.getUnopenedBookmarks().length,n=Vu("Click to toggle the bookmarks list"),s=Vu("Bookmarks");return Ha(pf(),t?"":"hidden",n,e.toggleBookmarksList,e.toggle_state===So.OPENED?"fa-caret-down":"fa-caret-right",s,e.toggle_state!==So.OPENED?"hidden":"",So.bookmarks.map((t=>(e=>{const t=e.bm.get("jid"),n=!(!Cc.settings.get("hide_open_bookmarks")||!So.chatboxes.get(t)),s=Vu("Unbookmark this groupchat"),i=Vu("Click to open this groupchat");return Ha(mf(),n?"hidden":"",t,t,i,gf,e.bm.getDisplayName(),e.bm.get("bookmarked")?"button-on":"",t,e.bm.getDisplayName(),s,hf)})(Object.assign({bm:t},e)))))})({toggleBookmarksList:e=>this.toggleBookmarksList(e),toggle_state:this.model.get("toggle-state")}),this)}toggleBookmarksList(e){e&&e.preventDefault&&e.preventDefault();const t=e.target.matches(".fa")?e.target:e.target.querySelector(".fa");_f.hasClass("fa-caret-down",t)?(_f.slideIn(this.querySelector(".bookmarks")),this.model.save({"toggle-state":So.CLOSED}),t.classList.remove("fa-caret-down"),t.classList.add("fa-caret-right")):(t.classList.remove("fa-caret-right"),t.classList.add("fa-caret-down"),_f.slideOut(this.querySelector(".bookmarks")),this.model.save({"toggle-state":So.OPENED}))}}Cc.elements.define("converse-bookmarks",wf);const{u:Sf}=Mc.env,xf={setBookmarkState(){void 0!==So.bookmarks&&(So.bookmarks.where({jid:this.model.get("jid")}).length?this.model.save("bookmarked",!0):this.model.save("bookmarked",!1))},renderBookmarkForm(){this.bookmark_form||(this.bookmark_form=new So.MUCBookmarkForm({model:this.model,chatroomview:this}),this.querySelector(".chatroom-body").insertAdjacentElement("beforeend",this.bookmark_form.el)),Sf.showElement(this.bookmark_form.el)},toggleBookmark(e){null==e||e.preventDefault();const t=So.bookmarks.where({jid:this.model.get("jid")});t.length?t.forEach((e=>e.destroy())):this.model.session.set("view",Mc.MUC.VIEWS.BOOKMARK)}};function Ef(){const e=(t=['\n
\n
\n
\n \n Logo Converse\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n converse.js\n \n \n
\n
'],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return Ef=function(){return e},e}n(5561),Mc.plugins.add("converse-bookmark-views",{dependencies:["converse-chatboxes","converse-muc","converse-muc-views"],initialize(){Cc.settings.extend({hide_open_bookmarks:!0}),So.removeBookmarkViaEvent=hf,So.addBookmarkViaEvent=ff,Object.assign(So.ChatRoomView.prototype,xf),So.MUCBookmarkForm=lf,So.BookmarksView=wf,Cc.listen.on("getHeadingButtons",df),Cc.listen.on("chatRoomViewInitialized",(e=>e.setBookmarkState()))}});const jf=e=>(...t)=>({_$litDirective$:e,values:t});class Af{constructor(e){}T(e,t,n){this.Σdt=e,this.M=t,this.Σct=n}S(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}const{et:Cf}=rc,kf=()=>document.createComment(""),Of=(e,t,n)=>{var s;const i=e.A.parentNode,r=void 0===t?e.B:t.A;if(void 0===n){const t=i.insertBefore(kf(),r),s=i.insertBefore(kf(),r);n=new Cf(t,s,e,e.options)}else{const t=n.B.nextSibling,o=n.M!==e;if(o&&(null===(s=n.Q)||void 0===s||s.call(n,e),n.M=e),t!==r||o){let e=n.A;for(;e!==t;){const t=e.nextSibling;i.insertBefore(e,r),e=t}}}return n},Tf=(e,t,n=e)=>(e.I(t,n),e),Nf={},If=e=>{var t;null===(t=e.P)||void 0===t||t.call(e,!1,!0);let n=e.A;const s=e.B.nextSibling;for(;n!==s;){const e=n.nextSibling;n.remove(),n=e}},Mf=(e,t,n)=>{const s=new Map;for(let i=t;i<=n;i++)s.set(e[i],i);return s},Rf=jf(class extends Af{constructor(e){if(super(e),2!==e.type)throw Error("repeat() can only be used in text expressions")}Mt(e,t,n){let s;void 0===n?n=t:void 0!==t&&(s=t);const i=[],r=[];let o=0;for(const t of e)i[o]=s?s(t,o):o,r[o]=n(t,o),o++;return{values:r,keys:i}}render(e,t,n){return this.Mt(e,t,n).values}update(e,[t,n,s]){var i;const r=(e=>e.H)(e),{values:o,keys:a}=this.Mt(t,n,s);if(!r)return this.Pt=a,o;const c=null!==(i=this.Pt)&&void 0!==i?i:this.Pt=[],l=[];let u,d,h=0,f=r.length-1,g=0,m=o.length-1;for(;h<=f&&g<=m;)if(null===r[h])h++;else if(null===r[f])f--;else if(c[h]===a[g])l[g]=Tf(r[h],o[g]),h++,g++;else if(c[f]===a[m])l[m]=Tf(r[f],o[m]),f--,m--;else if(c[h]===a[m])l[m]=Tf(r[h],o[m]),Of(e,l[m+1],r[h]),h++,m--;else if(c[f]===a[g])l[g]=Tf(r[f],o[g]),Of(e,r[h],r[f]),f--,g++;else if(void 0===u&&(u=Mf(a,g,m),d=Mf(c,h,f)),u.has(c[h]))if(u.has(c[f])){const t=d.get(a[g]),n=void 0!==t?r[t]:null;if(null===n){const t=Of(e,r[h]);Tf(t,o[g]),l[g]=t}else l[g]=Tf(n,o[g]),Of(e,r[h],n),r[t]=null;g++}else If(r[f]),f--;else If(r[h]),h++;for(;g<=m;){const t=Of(e,l[m+1]);Tf(t,o[g]),l[g++]=t}for(;h<=f;){const e=r[h++];null!==e&&If(e)}return this.Pt=a,((e,t=Nf)=>{e.H=t})(e,l),$a}});function Df(){const e=qf(['\n \n ']);return Df=function(){return e},e}function zf(){const e=qf(['\n \n ']);return zf=function(){return e},e}function Lf(){const e=qf(['\n \n ']);return Lf=function(){return e},e}function Pf(){const e=qf(['']);return Pf=function(){return e},e}function Ff(){const e=qf(["\n ",'\n \n ']);return Ff=function(){return e},e}function Bf(){const e=qf([""]);return Bf=function(){return e},e}function Uf(){const e=qf(["\n ","\n ","\n "]);return Uf=function(){return e},e}function qf(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Hf(e){const{CONTROLBOX_TYPE:t}=So;return e.get("type")===t||!(e.get("hidden")||e.get("minimized"))}Cc.elements.define("converse-chats",class extends yf{initialize(){this.model=So.chatboxes,this.listenTo(this.model,"add",this.render),this.listenTo(this.model,"change:closed",this.render),this.listenTo(this.model,"change:hidden",this.render),this.listenTo(this.model,"change:jid",this.render),this.listenTo(this.model,"change:minimized",this.render),this.listenTo(this.model,"destroy",this.render),this.listenTo(So,"connected",this.render),this.listenTo(So,"reconnected",this.render),this.listenTo(So,"disconnected",this.render);const e=document.getElementById("conversejs-bg");e&&!e.innerHTML.trim()&&Wa(Ha(Ef()),e),document.querySelector("body").classList.add("converse-".concat(Cc.settings.get("view_mode"))),this.render(),Cc.trigger("chatBoxViewsInitialized")}render(){Wa((()=>{const{chatboxes:e,CONTROLBOX_TYPE:t,CHATROOMS_TYPE:n,HEADLINES_TYPE:s}=So,i=Cc.settings.get("view_mode"),r=null==So?void 0:So.connection,o=!(null==r?void 0:r.connected)||!(null==r?void 0:r.authenticated)||(null==r?void 0:r.disconnecting);return Ha(Uf(),"overlayed"===i?Ha(Bf()):"",Rf(e.filter(Hf),(e=>e.get("jid")),(e=>e.get("type")===t?Ha(Ff(),"overlayed"===i?Ha(Pf(),e.get("closed")?"":"hidden"):"",e.get("closed")?"hidden":"",o?"logged-out":"",e.get("width")?"width: ".concat(e.get("width")):""):e.get("type")===n?Ha(Lf(),e.get("jid")):e.get("type")===s?Ha(zf(),e.get("jid")):Ha(Df(),e.get("jid")))))})(),this)}});function $f(){const e=(t=['\n \n \n '],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return $f=function(){return e},e}const Gf=e=>{return e.image?Ha($f(),e.classes,e.width,e.height,e.width,e.height,(t=e.image,n=e.image_type,t.startsWith("data:")?t:"data:".concat(n,";base64,").concat(t))):"";var t,n},Vf=/^\s*e.close({name:"closeAllChatBoxes"}))))}},Cc.listen.on("chatBoxesInitialized",(()=>{So.chatboxes.on("destroy",(e=>So.chatboxviews.remove(e.get("jid"))))})),Cc.listen.on("cleanup",(()=>delete So.chatboxviews)),Cc.listen.on("clearSession",(()=>So.chatboxviews.closeAllChatBoxes())),Cc.listen.on("chatBoxViewsInitialized",eg),window.addEventListener("resize",eg),Object.assign(Mc,{insertInto(e){var t;const n=null===(t=So.chatboxviews)||void 0===t?void 0:t.el;if(n&&!e.contains(n))e.insertAdjacentElement("afterBegin",n),Cc.chatviews.get().filter((e=>"controlbox"!==e.model.get("id"))).forEach((e=>e.maintainScrollTop()));else if(!n)throw new Error("Cannot insert non-existing #conversejs element into the DOM")}})}});var tg=n(2919),ng=n.n(tg);function sg(){const e=(t=['"],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return sg=function(){return e},e}n(552);const{sizzle:ig}=Mc.env,rg=Mc.env.utils,og=Wf.extend({className:"modal",persistent:!1,events:{"click .nav-item .nav-link":"switchTab"},initialize(e){if(!this.id)throw new Error("Each modal class must have a unique id attribute");Object.assign(this,e),this.render(),this.el.setAttribute("tabindex","-1"),this.el.setAttribute("role","dialog"),this.el.setAttribute("aria-hidden","true");const t=this.el.querySelector(".modal-title").getAttribute("id");t&&this.el.setAttribute("aria-labelledby",t),this.insertIntoDOM();const n=ng().Modal;this.modal=new n(this.el,{backdrop:!0,keyboard:!0}),this.el.addEventListener("hide.bs.modal",(()=>this.onHide()),!1)},onHide(){rg.removeClass("selected",this.trigger_el),!this.persistent&&Cc.modal.remove(this)},insertIntoDOM(){document.querySelector("#converse-modals").insertAdjacentElement("beforeEnd",this.el)},switchTab(e){e.stopPropagation(),e.preventDefault(),ig(".nav-link.active",this.el).forEach((e=>{rg.removeClass("active",this.el.querySelector(e.getAttribute("href"))),rg.removeClass("active",e)})),rg.addClass("active",e.target),rg.addClass("active",this.el.querySelector(e.target.getAttribute("href")))},alert(e,t="primary"){const n=this.el.querySelector(".modal-alert");if(null===n)return void as.error("Could not find a .modal-alert element in the modal to show an alert message in!");Wa((e=>Ha(sg(),e.type,e.message))({type:"alert-".concat(t),message:e}),n);const s=n.firstElementChild;setTimeout((()=>{rg.addClass("fade-out",s),setTimeout((()=>rg.removeElement(s)),600)}),5e3)},show(e){e&&(e.preventDefault(),this.trigger_el=e.target,!rg.hasClass("chat-image",this.trigger_el)&&rg.addClass("selected",this.trigger_el)),this.modal.show()}});function ag(){const e=lg(['']);return ag=function(){return e},e}function cg(){const e=lg(['"]);return cg=function(){return e},e}function lg(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}const ug=Ha(cg(),Vu("Close")),dg=Ha(ag(),Vu("Close"));function hg(){const e=gg(["

","

"]);return hg=function(){return e},e}function fg(){const e=gg(['\n \n"]);return fg=function(){return e},e}function gg(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}const mg=og.extend({id:"alert-modal",initialize(){og.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change",this.render)},toHTML(){return(e=>Ha(fg(),e.level,e.title,dg,e.messages.map((e=>Ha(hg(),e)))))(Object.assign({__:Vu},this.model.toJSON()))}});function pg(){const e=yg(["

","

"]);return pg=function(){return e},e}function vg(){const e=yg(['\n \n']);return vg=function(){return e},e}function bg(){const e=yg(['\n
\n \n
\n']);return bg=function(){return e},e}function yg(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}const _g=og.extend({id:"confirm-modal",events:{"submit .confirm":"onConfimation"},initialize(){this.confirmation=Et(),og.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change",this.render),this.el.addEventListener("closed.bs.modal",(()=>this.confirmation.reject()),!1)},toHTML(){return(e=>Ha(vg(),e.level||"",e.title,e.messages.map((e=>Ha(pg(),e))),e.fields.map((e=>(e=>Ha(bg(),e.label||"",e.name,e.challenge_failed?"error":"",e.required,e.placeholder))(e))),Vu("OK"),Vu("Cancel")))(this.model.toJSON())},afterRender(){this.close_handler_registered||(this.el.addEventListener("closed.bs.modal",(()=>{this.confirmation.isResolved||this.confirmation.reject()}),!1),this.close_handler_registered=!0)},onConfimation(e){e.preventDefault();const t=new FormData(e.target),n=(this.model.get("fields")||[]).map((e=>{const n=t.get(e.name).trim();return e.value=n,e.challenge&&(e.challenge_failed=n!==e.challenge),e}));if(n.filter((e=>e.challenge_failed)).length)return this.model.set("fields",n),void this.model.trigger("change");this.confirmation.resolve(n),this.modal.hide()}});Mc.env.BootstrapModal=og;let wg=[];const Sg={modal:{show(e,t,n){const s=this.get(e.id)||this.create(e,t);return s.show(n),s},get:e=>wg.filter((t=>t.id==e)).pop(),create(e,t){const n=new e(t);return wg.push(n),n},remove(e){wg=wg.filter((t=>t!==e)),e.remove()},removeAll(){wg.forEach((e=>e.remove())),wg=[]}},async confirm(e,t=[],n=[]){"string"==typeof t&&(t=[t]);const s=new ao({title:e,messages:t,fields:n,type:"confirm"}),i=new _g({model:s});let r;i.show();try{r=await i.confirmation}catch(e){r=!1}return i.remove(),r},async prompt(e,t=[],n=""){"string"==typeof t&&(t=[t]);const s=new ao({title:e,messages:t,fields:[{name:"reason",placeholder:n}],type:"prompt"}),i=new _g({model:s});let r;i.show();try{var o;r=null===(o=(await i.confirmation).pop())||void 0===o?void 0:o.value}catch(e){r=!1}return i.remove(),r},alert(e,t,n){let s;"string"==typeof n&&(n=[n]),"error"===e?s="alert-danger":"info"===e?s="alert-info":"warn"===e&&(s="alert-warning");const i=new ao({title:t,messages:n,level:s,type:"alert"});Cc.modal.show(mg,{model:i})}};Mc.plugins.add("converse-modal",{initialize(){Cc.listen.on("disconnect",(()=>{const e=document.querySelector("#converse-modals");e&&(e.innerHTML="")})),Cc.listen.on("clearSession",(()=>Cc.modal.removeAll())),Object.assign(So.api,Sg)}});const xg=(e,t)=>{var n,s;const i=e.N;if(void 0===i)return!1;for(const e of i)null===(s=(n=e).O)||void 0===s||s.call(n,t,!1),xg(e,t);return!0},Eg=e=>{let t,n;do{if(void 0===(t=e.M))break;n=t.N,n.delete(e),e=t}while(0===(null==n?void 0:n.size))},jg=e=>{for(let t;t=e.M;e=t){let n=t.N;if(void 0===n)t.N=n=new Set;else if(n.has(e))break;n.add(e),kg(t)}};function Ag(e){void 0!==this.N?(Eg(this),this.M=e,jg(this)):this.M=e}function Cg(e,t=!1,n=0){const s=this.H,i=this.N;if(void 0!==i&&0!==i.size)if(t)if(Array.isArray(s))for(let e=n;e{var t,n,s,i;2==e.type&&(null!==(t=(s=e).P)&&void 0!==t||(s.P=Cg),null!==(n=(i=e).Q)&&void 0!==n||(i.Q=Ag))};class Og extends Af{constructor(){super(...arguments),this.isConnected=!0,this.ut=$a,this.N=void 0}T(e,t,n){super.T(e,t,n),jg(this)}O(e,t=!0){this.at(e),t&&(xg(this,e),Eg(this))}at(e){var t,n;e!==this.isConnected&&(e?(this.isConnected=!0,this.ut!==$a&&(this.setValue(this.ut),this.ut=$a),null===(t=this.reconnected)||void 0===t||t.call(this)):(this.isConnected=!1,null===(n=this.disconnected)||void 0===n||n.call(this)))}S(e,t){if(!this.isConnected)throw Error("AsyncDirective ".concat(this.constructor.name," was rendered while its tree was disconnected."));return super.S(e,t)}setValue(e){if(this.isConnected)if((e=>void 0===this.Σdt.strings)())this.Σdt.I(e,this);else{const t=[...this.Σdt.H];t[this.Σct]=e,this.Σdt.I(t,this,0)}else this.ut=e}disconnected(){}reconnected(){}}const Tg=e=>!(e=>null===e||"object"!=typeof e&&"function"!=typeof e)(e)&&"function"==typeof e.then,Ng=jf(class extends Og{constructor(){super(...arguments),this.Ct=2147483647,this.Rt=[]}render(...e){var t;return null!==(t=e.find((e=>!Tg(e))))&&void 0!==t?t:$a}update(e,t){const n=this.Rt;let s=n.length;this.Rt=t;for(let e=0;ethis.Ct);e++){const i=t[e];if(!Tg(i))return this.Ct=e,i;e{const t=this.Rt.indexOf(i);t>-1&&t\n \n ',"\n \n "]);return Ig=function(){return e},e}function Mg(){const e=Dg(['this.onMessageEditButtonClicked(e),button_class:"chat-msg__action-edit",icon_class:"fa fa-pencil-alt",name:"edit"});const t="groupchat"===this.model.get("type")&&await this.model.mayBeModerated();!this.is_retracted&&(this.model.mayBeRetracted()||t)&&e.push({i18n_text:Vu("Retract"),handler:e=>this.onMessageRetractButtonClicked(e),button_class:"chat-msg__action-retract",icon_class:"fas fa-trash-alt",name:"retract"});const n=this.model.get("ogp_metadata")||[];if(this.model.collection.chatbox.get("type")===So.CHATROOMS_TYPE&&Cc.settings.get("muc_show_ogp_unfurls")&&n.length){let t;const s=this.hide_url_previews;t=n.length>1?Vu(s?"Show URL previews":"Hide URL previews"):Vu(s?"Show URL preview":"Hide URL preview"),e.push({i18n_text:t,handler:e=>this.onHidePreviewsButtonClicked(e),button_class:"chat-msg__action-hide-previews",icon_class:this.hide_url_previews?"fas fa-eye":"fas fa-eye-slash",name:"hide"})}return Cc.hook("getMessageActionButtons",this,e)}}function Fg(){const e=(t=['\n "],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return Fg=function(){return e},e}Cc.elements.define("converse-message-actions",Pg);const Bg=og.extend({id:"image-modal",toHTML(){return(e=>Ha(Fg(),Vu("Image: "),e.src,e.src,dg,e.src,e.onload,ug))({src:this.src,onload:e=>e.target.parentElement.style.height="".concat(e.target.height,"px")})}});var Ug=n(2369),qg=n.n(Ug);function Hg(){const e=Gg(["",""]);return Hg=function(){return e},e}function $g(){const e=Gg(["",""]);return $g=function(){return e},e}function Gg(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}const Vg=jf(class extends Af{render(e,t,n,s){const i=new gm(e,t,n,Object.assign(s,{show_images:!1}));return Ha($g(),Ng(async function(e){return await e.addTemplates(),e.payload}(i),Ha(Hg(),i)))}});function Wg(){const e=Zg(['*','*']);return Wg=function(){return e},e}function Jg(){const e=Zg(['~','~']);return Jg=function(){return e},e}function Qg(){const e=Zg(["
","
"]);return Qg=function(){return e},e}function Yg(){const e=Zg(['
```
','
```
'],['
\\`\\`\\`
','
\\`\\`\\`
']);return Yg=function(){return e},e}function Kg(){const e=Zg(['`','`'],['\\`','\\`']);return Kg=function(){return e},e}function Xg(){const e=Zg(['_','_']);return Xg=function(){return e},e}function Zg(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}const em=["*","_","~","`","```",">"],tm={"*":{name:"strong",type:"span"},_:{name:"emphasis",type:"span"},"~":{name:"strike",type:"span"},"`":{name:"preformatted",type:"span"},"```":{name:"preformatted_block",type:"block"},">":{name:"quote",type:"block"}},nm=["_",">","`","~"],sm={emphasis:(e,t,n,s)=>Ha(Xg(),Vg(e,t,n,s)),preformatted:e=>Ha(Kg(),e),preformatted_block:e=>Ha(Yg(),e),quote:(e,t,n,s)=>Ha(Qg(),Vg(e,t,n,s)),strike:(e,t,n,s)=>Ha(Jg(),Vg(e,t,n,s)),strong:(e,t,n,s)=>Ha(Wg(),Vg(e,t,n,s))};function im(e,t,n=!0){let s;if(!/(^```\s*\n|^```\s*$)/.test(e.slice(t))||0!==t&&"\n"!==e[t-1]&&">"!==e[t-1]){if(!em.includes(e.slice(t,t+1)))return null;if(s=e.slice(t,t+1),!function(e,t,n,s){if(s){const s=RegExp(nm.includes(e)?"^(\\p{L}|\\p{N})".concat(e):"^(\\p{L}|\\p{N})\\".concat(e),"u");if(n>1&&s.test(t.slice(n-1)))return!1;const i=am(e);if(i&&n>0&&"\n"!==t[n-1])return!1;if(!i&&e===t[n+1])return!1}else{const s=RegExp(nm.includes(e)?"^".concat(e,"(\\p{L}|\\p{N})"):"^\\".concat(e,"(\\p{L}|\\p{N})"),"u");if(n]/).shift().length)-s;if("span"===tm[e].type){const s=t.slice(n+1).split("\n").shift();let i=0,r=s.indexOf(e);for(;-1!==r;){if(rm(e,n+1+r,t))return r+1+2*e.length;r=s.indexOf(e,i++)}return 0}{const s=t.slice(n+1);let i=0,r=s.indexOf(e);for(;-1!==r;){if(rm(e,n+1+r,t))return r+1+2*e.length;r=s.indexOf(e,i++)}return 0}}(n,e,t):0;return s>0?{d:n,length:s}:{}}const am=e=>[">",">"].includes(e);function cm(e,t,n,s,i){const r=sm[tm[e].name];return am(e)?r(t.replace(/\n>/g,"\n").replace(/\n$/,""),n,s,i):r(t,n,s,i)}function lm(){const e=dm(['',""]);return lm=function(){return e},e}function um(){const e=dm(['',""]);return um=function(){return e},e}function dm(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}const hm=Mc.env.utils,fm=e=>"string"==typeof e;class gm extends String{constructor(e,t=0,n=[],s={}){super(e),this.mentions=n,this.nick=null==s?void 0:s.nick,this.offset=t,this.onImgClick=null==s?void 0:s.onImgClick,this.onImgLoad=null==s?void 0:s.onImgLoad,this.options=s,this.payload=[],this.references=[],this.render_styling=null==s?void 0:s.render_styling,this.show_images=null==s?void 0:s.show_images}addHyperlinks(e,t){const n=[];try{const t={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|xmpp:|mailto:|www\.)/gi};qg().withinString(e,((e,t,s)=>(n.push({url:e,start:t,end:s}),e)),t)}catch(e){return void as.debug(e)}n.forEach((n=>{const s=e.slice(n.start,n.end),i=hm.filterQueryParamsFromURL(s);this.addTemplateResult(n.start+t,n.end+t,this.show_images&&hm.isImageURL(s)&&hm.isImageDomainAllowed(s)?hm.convertToImageTag(i,this.onImgLoad,this.onImgClick):hm.convertUrlToHyperlink(i))}))}addMapURLs(e,t){const n=/geo:([\-0-9.]+),([\-0-9.]+)(?:,([\-0-9.]+))?(?:\?(.*))?/g,s=e.matchAll(n);for(const e of s)this.addTemplateResult(e.index+t,e.index+e[0].length+t,hm.convertUrlToHyperlink(e[0].replace(n,So.geouri_replacement)))}addEmojis(e,t){[...Ql(e.toString()),...Yl(e.toString())].forEach((e=>{this.addTemplateResult(e.begin+t,e.end+t,Jl(e,{add_title_wrapper:!0}))}))}addMentions(e,t){var n;const s=t+this.offset;null===(n=this.mentions)||void 0===n||n.forEach((n=>{const i=Number(n.begin)-s;if(i<0||i>=s+e.length)return;const r=Number(n.end)-s,o=e.slice(i,r);o===this.nick?this.addTemplateResult(i+t,r+t,(e=>Ha(um(),e.mention))({mention:o})):this.addTemplateResult(i+t,r+t,(e=>Ha(lm(),e.mention))({mention:o}))}))}addStyling(){const e=[];if(function(e){for(let t=0;tArray.from({length:Number(e.end)},((t,n)=>Number(e.begin)+n))));let n=0;for(;ne.includes(n))).length){n++;continue}const{d:s,length:i}=om(this,n);if(s&&i){const t=am(s),r=n+i,o=t?r:r-s.length;let a="```"===s?n+s.length+1:n+s.length;t&&" "===this[a]&&(a+=1);const c=a,l=this.slice(a,o);e.push({begin:n,template:cm(s,l,c,this.mentions,this.options),end:r}),n=r}n++}}e.forEach((e=>this.addTemplateResult(e.begin,e.end,e.template)))}trimMeMessage(){0===this.offset&&this.isMeCommand()&&(this.payload[0]=this.payload[0].substring(4))}addAnnotations(e){const t=this.marshall();let n=0;for(const s of t)s&&(fm(s)?(e.call(this,s,n),n+=s.length):n=s.end)}async addTemplates(){await Cc.trigger("beforeMessageBodyTransformed",this,{Synchronous:!0}),this.render_styling&&this.addStyling(),this.addAnnotations(this.addMentions),this.addAnnotations(this.addHyperlinks),this.addAnnotations(this.addMapURLs),await Cc.emojis.initialize(),this.addAnnotations(this.addEmojis),await Cc.trigger("afterMessageBodyTransformed",this,{Synchronous:!0}),this.payload=this.marshall(),this.options.show_me_message&&this.trimMeMessage(),this.payload=this.payload.map((e=>fm(e)?e:e.template))}addTemplateResult(e,t,n){this.references.push({begin:e,end:t,template:n})}isMeCommand(){const e=this.toString();return!!e&&e.startsWith("/me ")}marshall(){let e=[this.toString()];return this.references.sort(((e,t)=>t.begin-e.begin)).forEach((t=>{const n=e.shift();e=[n.slice(0,t.begin),t,n.slice(t.end),...e]})),e.reduce(((e,t)=>{return fm(t)?[...e,Wl((n=t,n.replace(/\n\n+/g,(e=>"\n".concat("​".repeat(e.length-2),"\n")))))]:[...e,t];var n}),[])}}function mm(){const e=vm(["",""]);return mm=function(){return e},e}function pm(){const e=vm(["",""]);return pm=function(){return e},e}function vm(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}class bm{constructor(e,t,n=[],s={}){this.mentions=n,this.offset=t,this.options=s,this.text=e}async transform(){const e=new gm(this.text,this.offset,this.mentions,this.options);return await e.addTemplates(),e.payload}render(){return Ha(pm(),Ng(this.transform(),Ha(mm(),this.text)))}}const ym=jf(class extends Af{render(e,t,n,s,i){const r=new bm(e,t,n,s).render();return null==i||i(),r}});function _m(){const e=(t=['\n \n ',"\n"],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return _m=function(){return e},e}function wm(){const e=(t=['',""],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return wm=function(){return e},e}Cc.elements.define("converse-chat-message-body",class extends af{static get properties(){return{model:{type:Object},is_me_message:{type:Boolean},show_images:{type:Boolean},text:{type:String}}}onImgClick(e){e.preventDefault(),Cc.modal.create(Bg,{src:e.target.src},e).show(e)}onImgLoad(){this.dispatchEvent(new CustomEvent("imageLoaded",{detail:this,bubbles:!0}))}render(){const e=this.model.get("references"),t={nick:this.model.collection.chatbox.get("nick"),onImgClick:this.onImgClick,onImgLoad:()=>this.onImgLoad(),render_styling:!this.model.get("is_unstyled")&&Cc.settings.get("allow_message_styling"),show_images:this.show_images,show_me_message:!0};return ym(this.text,0,e,t,(()=>{var e;return null===(e=this.model.collection)||void 0===e?void 0:e.trigger("rendered",this.model)}))}});const Sm=e=>Ha(wm(),e.url,e.label_download);function xm(){const e=jm([""]);return xm=function(){return e},e}function Em(){const e=jm(['\n
\n ','\n \n \n
\n']);return Em=function(){return e},e}function jm(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Am(){const e=(t=['\n
\n \n \n
"],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return Am=function(){return e},e}function Cm(){const e=(t=['

',"

"],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return Cm=function(){return e},e}function km(){const e=Nm(['\n \n ']);return km=function(){return e},e}function Om(){const e=Nm(['"]);return Om=function(){return e},e}function Tm(){const e=Nm(['\n
\n ',"\n\n \x3c!-- This is a hack to prevent Chrome from auto-filling the username in\n any of the other input fields in the MUC configuration form. --\x3e\n ",'\n\n \n \n \n
"]);return Mm=function(){return e},e}function Rm(){const e=Dm(['"]);return Rm=function(){return e},e}function Dm(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function zm(){const e=(t=['\n \n \n"],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return zm=function(){return e},e}function Lm(){const e=(t=["\n "],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return Lm=function(){return e},e}const Pm=e=>Ha(Lm(),e.label,e.value,e.value);function Fm(){const e=Um([""]);return Fm=function(){return e},e}function Bm(){const e=Um(['\n
\n ','\n
\n
\n \n
',"
\n
\n
\n
"]);return Bm=function(){return e},e}function Um(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}const qm=e=>Ha(Bm(),e.label?Ha(Fm(),e.label):"",e.name,e.type,e.value||"",e.required,e.domain,e.domain);function Hm(){const e=(t=[''],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return Vm=function(){return e},e}function Wm(){const e=Qm(['',""]);return Wm=function(){return e},e}function Jm(){const e=Qm(['\n ',""]);return Jm=function(){return e},e}function Qm(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}const{sizzle:Ym}=Mc.env,Km=["http","https","xmpp","mailto"];function Xm(e,t){return{"muc#roomconfig_lang":"language","muc#roomconfig_roomsecret":(null==t?void 0:t.new_password)?"new-password":"current-password"}[e]}const Zm={"text-private":"password","text-single":"text",fixed:"label",boolean:"checkbox",hidden:"hidden","jid-multi":"textarea","list-single":"dropdown","list-multi":"dropdown"};function ep(e){try{return e instanceof qg()?e:new(qg())(e)}catch(e){return as.debug(e),null}}function tp(e,t){const n=ep(t);if(null===n||!function(e){return"http:"===window.location.protocol||"https:"===window.location.protocol&&"https"===e.protocol().toLowerCase()}(n))return!1;const s=n.filename().toLowerCase();return!!e.filter((e=>s.endsWith(e))).length}function np(e){try{return decodeURI(e.filename())}catch(t){return as.debug(t),e.filename()}}function sp(e){e.preventDefault(),Cc.rooms.open(e.target.href)}function ip(e,t){e.classList.remove("visible"),_(t)&&t()}go.getURI=ep,go.isAudioURL=e=>tp([".ogg",".mp3",".m4a"],e),go.isVideoURL=e=>tp([".mp4",".webm"],e),go.isURLWithImageExtension=e=>tp([".jpg",".jpeg",".png",".gif",".bmp",".tiff",".svg"],e),go.isImageURL=e=>{const t=Cc.settings.get("image_urls_regex");return(null==t?void 0:t.test(e))||go.isURLWithImageExtension(e)},go.isImageDomainAllowed=e=>{const t=Cc.settings.get("show_images_inline");if(!Array.isArray(t))return!0;try{const n=ep(e).domain();return t.includes(n)}catch(e){return as.debug(e),!0}},go.getOOBURLMarkup=function(e,t){const n=ep(t);return null===n?t:go.isVideoURL(n)?(e=>Ha(Vm(),e.url))({url:t}):go.isAudioURL(n)?function(e,t){const{__:n}=e;return(e=>Ha(_m(),e.url,e.url,e.label_download))({url:t.toString(),label_download:n('Download audio file "%1$s"',np(t))})}(e,n):go.isImageURL(n)?function(e,t){const{__:n}=e;return Sm({url:t.toString(),label_download:n('Download image file "%1$s"',np(t))})}(e,n):function(e,t){const{__:n}=e;return Sm({url:t.toString(),label_download:n('Download file "%1$s"',np(t))})}(e,n)},go.calculateElementHeight=function(e){return Array.from(e.children).reduce(((e,t)=>e+t.offsetHeight),0)},go.getNextElement=function(e,t="*"){let n=e.nextElementSibling;for(;null!==n&&!Ym.matchesSelector(n,t);)n=n.nextElementSibling;return n},go.getPreviousElement=function(e,t="*"){let n=e.previousElementSibling;for(;null!==n&&!Ym.matchesSelector(n,t);)n=n.previousElementSibling;return n},go.getFirstChildElement=function(e,t="*"){let n=e.firstElementChild;for(;null!==n&&!Ym.matchesSelector(n,t);)n=n.nextElementSibling;return n},go.getLastChildElement=function(e,t="*"){let n=e.lastElementChild;for(;null!==n&&!Ym.matchesSelector(n,t);)n=n.previousElementSibling;return n},go.hasClass=function(e,t){return t instanceof Element&&t.classList.contains(e)},go.toggleClass=function(e,t){go.hasClass(e,t)?go.removeClass(e,t):go.addClass(e,t)},go.addClass=function(e,t){return t instanceof Element&&t.classList.add(e),t},go.removeClass=function(e,t){return t instanceof Element&&t.classList.remove(e),t},go.removeElement=function(e){return e instanceof Element&&e.parentNode&&e.parentNode.removeChild(e),e},go.getElementFromTemplateResult=function(e){const t=document.createElement("div");return Wa(e,t),t.firstElementChild},go.showElement=e=>{go.removeClass("collapsed",e),go.removeClass("hidden",e)},go.hideElement=function(e){return e instanceof Element&&e.classList.add("hidden"),e},go.ancestor=function(e,t){let n=e;for(;null!==n&&!Ym.matchesSelector(n,t);)n=n.parentElement;return n},go.nextUntil=function(e,t){const n=[];let s=e.nextElementSibling;for(;null!==s&&!s.matches(t);)n.push(s),s=s.nextElementSibling;return n},go.unescapeHTML=function(e){var t=document.createElement("div");return t.innerHTML=e,t.innerText},go.escapeHTML=function(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""")},go.convertToImageTag=function(e,t,n){return(e=>Ha(Gm(),$m(e.url,e.url,e.onLoad,e.onClick)))({url:e,onClick:n,onLoad:t})},go.convertURIoHyperlink=function(e,t){let n=e.normalize()._string;const s=e._parts.urn?n:e.readable(),i=t||s;return e._parts.protocol||n.startsWith("http://")||n.startsWith("https://")||(n="http://"+n),"xmpp"===e._parts.protocol&&"join"===e._parts.query?Ha(Jm(),sp,n,i):Ha(Wm(),n,i)},go.convertUrlToHyperlink=function(e){const t=RegExp("^w{3}.","ig").test(e)?"http://".concat(e):e,n=ep(e);return null===n||!function(e){try{return!!new URL(e)}catch(e){return!1}}(t)||!function(e,t=Km){return!!t.includes(e)}(n._parts.protocol)&&n._parts.protocol?e:this.convertURIoHyperlink(n,e)},go.filterQueryParamsFromURL=function(e){const t=Cc.settings.get("filter_url_query_params");return t?ep(e).removeQuery(t).toString():e},go.slideInAllElements=function(e,t=300){return Promise.all(Array.from(e).map((e=>go.slideIn(e,t))))},go.slideToggleElement=function(e,t){return go.hasClass("collapsed",e)||go.hasClass("hidden",e)?go.slideOut(e,t):go.slideIn(e,t)},go.slideOut=function(e,t=200){return new Promise(((n,s)=>{if(!e){const e="An element needs to be passed in to slideOut";return as.warn(e),void s(new Error(e))}const i=e.getAttribute("data-slider-marker");i&&(e.removeAttribute("data-slider-marker"),window.cancelAnimationFrame(i));const r=go.calculateElementHeight(e);if(window.converse_disable_effects)return e.style.height=r+"px",function(e){e.removeAttribute("data-slider-marker"),e.classList.remove("collapsed"),e.style.overflow="",e.style.height=""}(e),void n();if(!go.hasClass("collapsed",e)&&!go.hasClass("hidden",e))return void n();const o=t/17;let a=0;e.style.height="0",e.style.overflow="hidden",e.classList.remove("hidden"),e.classList.remove("collapsed"),e.setAttribute("data-slider-marker",window.requestAnimationFrame((function t(){a+=r/o,a{if(!e){const e="An element needs to be passed in to slideIn";return as.warn(e),s(new Error(e))}if(go.hasClass("collapsed",e))return n(e);if(window.converse_disable_effects)return e.classList.add("collapsed"),e.style.height="",n(e);const i=e.getAttribute("data-slider-marker");i&&(e.removeAttribute("data-slider-marker"),window.cancelAnimationFrame(i));const r=e.offsetHeight,o=t/17;let a=r;e.style.overflow="hidden",e.setAttribute("data-slider-marker",window.requestAnimationFrame((function t(){a-=r/o,a>0?(e.style.height=a+"px",e.setAttribute("data-slider-marker",window.requestAnimationFrame(t))):(e.removeAttribute("data-slider-marker"),e.classList.add("collapsed"),e.style.height="",n(e))})))}))},go.isInDOM=function(e){return document.querySelector("body").contains(e)},go.isVisible=function(e){return null!==e&&!go.hasClass("hidden",e)&&(e.offsetWidth>0||e.offsetHeight>0||e.getClientRects().length>0)},go.fadeIn=function(e,t){if(e||as.warn("An element needs to be passed in to fadeIn"),window.converse_disable_effects)return e.classList.remove("hidden"),ip(e,t);go.hasClass("hidden",e)?(e.classList.add("visible"),e.classList.remove("hidden"),e.addEventListener("webkitAnimationEnd",(()=>ip(e,t))),e.addEventListener("animationend",(()=>ip(e,t))),e.addEventListener("oanimationend",(()=>ip(e,t)))):ip(e,t)},go.xForm2TemplateResult=function(e,t,n){if("list-single"===e.getAttribute("type")||"list-multi"===e.getAttribute("type")){const t=go.queryChildren(e,"value").map((e=>null==e?void 0:e.textContent));return(e=>{var t;return Ha(Mm(),e.id,e.label,e.id,e.name,e.multiple,null===(t=e.options)||void 0===t?void 0:t.map((e=>(e=>Ha(Rm(),e.value,e.selected,e.label))(e))))})({options:go.queryChildren(e,"option").map((n=>{var s;const i=null===(s=n.querySelector("value"))||void 0===s?void 0:s.textContent;return{value:i,label:n.getAttribute("label"),selected:t.includes(i),required:!!e.querySelector("required")}})),id:go.getUniqueId(),label:e.getAttribute("label"),multiple:"list-multi"===e.getAttribute("type"),name:e.getAttribute("var"),required:!!e.querySelector("required")})}var s,i,r,o;if("fixed"===e.getAttribute("type"))return(e=>Ha(Cm(),e.text))({text:null===(s=e.querySelector("value"))||void 0===s?void 0:s.textContent});if("jid-multi"===e.getAttribute("type"))return(e=>Ha(zm(),e.label,e.name,e.value))({name:e.getAttribute("var"),label:e.getAttribute("label")||"",value:null===(i=e.querySelector("value"))||void 0===i?void 0:i.textContent,required:!!e.querySelector("required")});if("boolean"===e.getAttribute("type")){var a;const t=null===(a=e.querySelector("value"))||void 0===a?void 0:a.textContent;return(e=>Ha(Am(),e.id,e.name,e.checked,e.required,e.id,e.label))({id:go.getUniqueId(),name:e.getAttribute("var"),label:e.getAttribute("label")||"",checked:"1"===t||"true"===t?'checked="1"':"",required:!!e.querySelector("required")})}if("url"===e.getAttribute("var"))return Pm({label:e.getAttribute("label")||"",value:null===(r=e.querySelector("value"))||void 0===r?void 0:r.textContent});if("username"===e.getAttribute("var"))return qm({domain:" @"+n.domain,name:e.getAttribute("var"),type:Zm[e.getAttribute("type")],label:e.getAttribute("label")||"",value:null===(o=e.querySelector("value"))||void 0===o?void 0:o.textContent,required:!!e.querySelector("required")});if("ocr"===e.getAttribute("var")){const n=e.querySelector("uri"),s=Ym('data[cid="'+n.textContent.replace(/^cid:/,"")+'"]',t)[0];return(e=>Ha(Em(),e.label?Ha(xm(),e.label):"",e.type,e.data,e.name,e.required))({label:e.getAttribute("label"),name:e.getAttribute("var"),data:null==s?void 0:s.textContent,type:n.getAttribute("type"),required:!!e.querySelector("required")})}{var c;const t=e.getAttribute("var");return Im({id:go.getUniqueId(),label:e.getAttribute("label")||"",name:t,fixed_username:null==n?void 0:n.fixed_username,autocomplete:Xm(t,n),placeholder:null,required:!!e.querySelector("required"),type:Zm[e.getAttribute("type")],value:null===(c=e.querySelector("value"))||void 0===c?void 0:c.textContent})}};const rp=go,{keycodes:op}=Mc;function ap(e){let t=0;do{isNaN(e.offsetTop)||(t+=e.offsetTop)}while(e=e.offsetParent);return t}function cp(e){let t=0;do{isNaN(e.offsetLeft)||(t+=e.offsetLeft)}while(e=e.offsetParent);return t}class lp{static get DIRECTION(){return{down:"down",end:"end",home:"home",left:"left",right:"right",up:"up"}}static get DEFAULTS(){return{home:["".concat(op.SHIFT,"+").concat(op.UP_ARROW)],end:["".concat(op.SHIFT,"+").concat(op.DOWN_ARROW)],up:[op.UP_ARROW],down:[op.DOWN_ARROW],left:[op.LEFT_ARROW,"".concat(op.SHIFT,"+").concat(op.TAB)],right:[op.RIGHT_ARROW,op.TAB],getSelector:null,jump_to_picked:null,jump_to_picked_direction:null,jump_to_picked_selector:"picked",onSelected:null,selected:"selected",selector:"li"}}static getClosestElement(e,t){return e.reduce(((e,n)=>{const s=t(n);return sthis.keys[e]=lp.DIRECTION.down)),this.options.end.forEach((e=>this.keys[e]=lp.DIRECTION.end)),this.options.home.forEach((e=>this.keys[e]=lp.DIRECTION.home)),this.options.left.forEach((e=>this.keys[e]=lp.DIRECTION.left)),this.options.right.forEach((e=>this.keys[e]=lp.DIRECTION.right)),this.options.up.forEach((e=>this.keys[e]=lp.DIRECTION.up))}enable(){this.getElements(),this.keydownHandler=e=>this.handleKeydown(e),this.doc.addEventListener("keydown",this.keydownHandler),this.enabled=!0}disable(){this.keydownHandler&&this.doc.removeEventListener("keydown",this.keydownHandler),this.unselect(),this.elements={},this.enabled=!1}destroy(){this.disable(),this.container.domNavigator&&delete this.container.domNavigator}getNextElement(e){let t;if(e===lp.DIRECTION.home)t=this.getElements(e)[0];else if(e===lp.DIRECTION.end)t=Array.from(this.getElements(e)).pop();else if(this.selected)if(e===lp.DIRECTION.right){const n=this.getElements(e);t=n.slice(n.indexOf(this.selected))[1]}else if(e==lp.DIRECTION.left){const n=this.getElements(e);t=n.slice(0,n.indexOf(this.selected)).pop()||this.selected}else if(e==lp.DIRECTION.down){const e=this.selected.offsetLeft,n=this.selected.offsetTop+this.selected.offsetHeight,s=this.elementsAfter(0,n),i=t=>Math.abs(t.offsetLeft-e)+Math.abs(t.offsetTop-n);t=lp.getClosestElement(s,i)}else{if(e!=lp.DIRECTION.up)throw new Error("getNextElement: invalid direction value");{const e=this.selected.offsetLeft,n=this.selected.offsetTop-1,s=this.elementsBefore(1/0,n),i=t=>Math.abs(e-t.offsetLeft)+Math.abs(n-t.offsetTop);t=lp.getClosestElement(s,i)}}else t=e===lp.DIRECTION.right||e===lp.DIRECTION.down?this.getElements(e)[1]:this.getElements(e)[0];return this.options.jump_to_picked&&t&&t.matches(this.options.jump_to_picked)&&e===this.options.jump_to_picked_direction&&(t=this.container.querySelector(this.options.jump_to_picked_selector)||t),t}select(e,t){e&&e!==this.selected&&(this.unselect(),t&&this.scrollTo(e,t),e.matches("input")?e.focus():rp.addClass(this.options.selected,e),this.selected=e,this.options.onSelected&&this.options.onSelected(e))}unselect(){this.selected&&(rp.removeClass(this.options.selected,this.selected),delete this.selected)}scrollTo(e,t){if(this.inScrollContainerViewport(e)){if(!function(e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=window.innerHeight&&t.right<=window.innerWidth}(e))switch(t){case lp.DIRECTION.left:document.body.scrollLeft=cp(e)-document.body.offsetLeft;break;case lp.DIRECTION.up:document.body.scrollTop=ap(e)-document.body.offsetTop;break;case lp.DIRECTION.right:document.body.scrollLeft=cp(e)-document.body.offsetLeft-(document.documentElement.clientWidth-e.offsetWidth);break;case lp.DIRECTION.down:document.body.scrollTop=ap(e)-document.body.offsetTop-(document.documentElement.clientHeight-e.offsetHeight)}}else{const n=this.scroll_container;if(!n.contains(e))return;switch(t){case lp.DIRECTION.left:n.scrollLeft=e.offsetLeft-n.offsetLeft,n.scrollTop=e.offsetTop-n.offsetTop;break;case lp.DIRECTION.up:n.scrollTop=e.offsetTop-n.offsetTop;break;case lp.DIRECTION.right:n.scrollLeft=e.offsetLeft-n.offsetLeft-(n.offsetWidth-e.offsetWidth),n.scrollTop=e.offsetTop-n.offsetTop-(n.offsetHeight-e.offsetHeight);break;case lp.DIRECTION.down:n.scrollTop=e.offsetTop-n.offsetTop-(n.offsetHeight-e.offsetHeight)}}}inScrollContainerViewport(e){const t=this.scroll_container;return!(e.offsetLeft-t.scrollLeftt.offsetLeft+t.offsetWidth||e.offsetTop+e.offsetHeight-t.scrollTop>t.offsetTop+t.offsetHeight)}getElements(e){const t=this.options.getSelector?this.options.getSelector(e):this.options.selector;return this.elements[t]||(this.elements[t]=Array.from(this.container.querySelectorAll(t))),this.elements[t]}elementsAfter(e,t){return this.getElements(lp.DIRECTION.down).filter((n=>n.offsetLeft>=e&&n.offsetTop>=t))}elementsBefore(e,t){return this.getElements(lp.DIRECTION.up).filter((n=>n.offsetLeft<=e&&n.offsetTop<=t))}handleKeydown(e){const t=op,n=e.shiftKey?this.keys["".concat(t.SHIFT,"+").concat(e.which)]:this.keys[e.which];if(n){e.preventDefault(),e.stopPropagation();const t=this.getNextElement(n,e);this.select(t,n)}}}const up=lp;function dp(){const e=(t=['\n
\n \n \n
\n "],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return dp=function(){return e},e}const hp=Mc.env.utils;class fp extends af{firstUpdated(){this.menu=this.querySelector(".dropdown-menu"),this.dropdown=this.firstElementChild,this.button=this.dropdown.querySelector("button"),this.dropdown.addEventListener("click",(e=>this.toggleMenu(e))),this.dropdown.addEventListener("keyup",(e=>this.handleKeyUp(e))),document.addEventListener("click",(e=>!this.contains(e.composedPath()[0])&&this.hideMenu(e)))}hideMenu(){var e,t;hp.removeClass("show",this.menu),null===(e=this.button)||void 0===e||e.setAttribute("aria-expanded",!1),null===(t=this.button)||void 0===t||t.blur()}showMenu(){hp.addClass("show",this.menu),this.button.setAttribute("aria-expanded",!0)}toggleMenu(e){e.preventDefault(),hp.hasClass("show",this.menu)?this.hideMenu():this.showMenu()}handleKeyUp(e){e.keyCode===Mc.keycodes.ESCAPE?this.hideMenu():e.keyCode===Mc.keycodes.DOWN_ARROW&&this.navigator&&!this.navigator.enabled&&this.enableArrowNavigation(e)}}function gp(){const e=pp(['

: ","

"]);return gp=function(){return e},e}function mp(){const e=pp(['\n \n"]);return mp=function(){return e},e}function pp(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}Cc.elements.define("converse-dropdown",class extends fp{static get properties(){return{icon_classes:{type:String},items:{type:Array}}}render(){const e=this.icon_classes||"fa fa-bars";return Ha(dp(),e,this.items.map((e=>Ng(e,""))))}hideMenu(){super.hideMenu(),this.navigator.disable()}firstUpdated(){super.firstUpdated(),this.initArrowNavigation()}initArrowNavigation(){if(!this.navigator){const e={selector:".dropdown-item",onSelected:e=>e.focus()};this.navigator=new up(this.menu,e)}}enableArrowNavigation(e){e&&(e.preventDefault(),e.stopPropagation()),this.navigator.enable(),this.navigator.select(this.menu.firstElementChild)}handleKeyUp(e){super.handleKeyUp(e),e.keyCode!==Mc.keycodes.DOWN_ARROW||this.navigator.enabled||this.enableArrowNavigation(e)}});const vp=og.extend({id:"message-versions-modal",toHTML(){return(e=>Ha(mp(),Vu("Message versions"),dg,Object.keys(e.older_versions).map((t=>Ha(gp(),Ao()(t).format("MMM D, YYYY, HH:mm:ss"),e.older_versions[t]))),e.message,ug))(this.model.toJSON())}}),bp=jf(class extends Af{render(e){const t={classes:e.classes?"".concat(e.classes," avatar"):"avatar",height:e.width||36,image:e.image,image_type:e.image_type,width:e.height||36};return Gf(t)}});function yp(){const e=(t=['\n \n "],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return yp=function(){return e},e}const _p=og.extend({initialize(){og.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change",this.render),Cc.trigger("occupantModalInitialized",this.model)},toHTML(){return(e=>Ha(yp(),e.display_name,dg,bp(e.avatar_data),ug))(Object.assign(this.model.toJSON(),{avatar_data:this.getAvatarData(),display_name:this.model.getDisplayName()}))},getAvatarData(){const e=So.vcards.findWhere({jid:this.model.get("jid")});return{classes:"chat-msg__avatar",height:120,width:120,image:"data:"+((null==e?void 0:e.get("image_type"))||So.DEFAULT_IMAGE_TYPE)+";base64,"+((null==e?void 0:e.get("image"))||So.DEFAULT_IMAGE)}}});So.OccupantModal=_p;const wp=_p;function Sp(){const e=Mp(["

","

"]);return Sp=function(){return e},e}function xp(){const e=Mp(["

',"

"]);return xp=function(){return e},e}function Ep(){const e=Mp(["

',"

"]);return Ep=function(){return e},e}function jp(){const e=Mp(["

","

"]);return jp=function(){return e},e}function Ap(){const e=Mp(["

","

"]);return Ap=function(){return e},e}function Cp(){const e=Mp(['
',"
"]);return Cp=function(){return e},e}function kp(){const e=Mp(['\n \n "]);return kp=function(){return e},e}function Op(){const e=Mp(['\n \n "]);return Op=function(){return e},e}function Tp(){const e=Mp(['
  • ',"
  • "]);return Tp=function(){return e},e}function Np(){const e=Mp(['\n
    \n
      \n
    • ',"
    • \n ","\n
    \n "]);return Np=function(){return e},e}function Ip(){const e=Mp(['\n
  • \n
    \n
    \n
    \n ',"\n
    \n
  • \n "]);return Ip=function(){return e},e}function Mp(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}const Rp=e=>{const t=Vu("XMPP Address"),n=Vu("Email"),s=Vu("Full Name"),i=Vu("Nickname"),r=Vu("The User's Profile Image"),o=Vu("Refresh"),a=Vu("Role"),c=Vu("URL"),l={alt_text:r,extra_classes:"mb-3",height:"120",width:"120"};return Ha(kp(),e.display_name,dg,e.image?Ha(Cp(),Gf(Object.assign(e,l))):"",e.fullname?Ha(Ap(),s,e.fullname):"",t,e.jid,e.jid,e.nickname?Ha(jp(),i,e.nickname):"",e.url?Ha(Ep(),c,e.url,e.url):"",e.email?Ha(xp(),n,e.email,e.email):"",e.role?Ha(Sp(),a,e.role):"",e._converse.pluggable.plugins["converse-omemo"].enabled(e._converse)?(e=>{const t=Vu("OMEMO Fingerprints"),n=Vu("No OMEMO-enabled devices found"),s=e.view.devicelist.devices;return Ha(Np(),t,s.length?s.map((t=>(e=>{const t=Vu("Trusted"),n=Vu("Untrusted");return e.device.get("bundle")&&e.device.get("bundle").fingerprint?Ha(Ip(),-1!==e.device.get("trusted")?"btn-primary active":"btn-secondary",e.device.get("id"),-1!==e.device.get("trusted"),t,-1!==e.device.get("trusted")?"btn-primary active":"btn-secondary",e.device.get("id"),-1===e.device.get("trusted"),n,e.utils.formatFingerprint(e.device.get("bundle").fingerprint)):""})(Object.assign({device:t},e)))):Ha(Tp(),n))})(e):"",ug,o,e.allow_contact_removal&&e.is_roster_contact?(e=>{const t=Vu("Remove as contact");return Ha(Op(),e.removeContact,t)})(e):"")},Dp=Mc.env.utils,zp=og.extend({id:"user-details-modal",persistent:!0,events:{"click button.refresh-contact":"refreshContact","click .fingerprint-trust .btn input":"toggleDeviceTrust"},initialize(){og.prototype.initialize.apply(this,arguments),this.model.rosterContactAdded.then((()=>this.registerContactEventHandlers())),this.listenTo(this.model,"change",this.render),this.registerContactEventHandlers(),Cc.trigger("userDetailsModalInitialized",this.model)},toHTML(){var e;const t=null===(e=this.model)||void 0===e?void 0:e.vcard,n=t?t.toJSON():{};return Rp(Object.assign(this.model.toJSON(),n,{_converse:So,allow_contact_removal:Cc.settings.get("allow_contact_removal"),display_name:this.model.getDisplayName(),is_roster_contact:void 0!==this.model.contact,removeContact:e=>this.removeContact(e),view:this,utils:Dp}))},registerContactEventHandlers(){void 0!==this.model.contact&&(this.listenTo(this.model.contact,"change",this.render),this.listenTo(this.model.contact.vcard,"change",this.render),this.model.contact.on("destroy",(()=>{delete this.model.contact,this.render()})))},async refreshContact(e){e&&e.preventDefault&&e.preventDefault();const t=this.el.querySelector(".fa-refresh");Dp.addClass("fa-spin",t);try{await Cc.vcard.update(this.model.contact.vcard,!0)}catch(e){as.fatal(e),this.alert(Vu("Sorry, something went wrong while trying to refresh"),"danger")}Dp.removeClass("fa-spin",t)},removeContact(e){var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),Cc.settings.get("allow_contact_removal")&&!0===confirm(Vu("Are you sure you want to remove this contact?"))&&(setTimeout((()=>function(e){e.removeFromRoster((()=>e.destroy()),(t=>{t&&as.error(t),Cc.alert("error",Vu("Error"),[Vu("Sorry, there was an error while trying to remove %1$s as a contact.",e.getDisplayName())])}))}(this.model.contact)),1),this.modal.hide())}});So.UserDetailsModal=zp;const Lp=zp;var Pp=n(6755),Fp=n.n(Pp);function Bp(){const e=qp(['\n ','\n
    \n
    ','
    \n

    \n

    ',"

    \n
    \n "]);return Up=function(){return e},e}function qp(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}const Hp=Mc.env.utils;function $p(){const e=Kp(['']);return $p=function(){return e},e}function Gp(){const e=Kp(['\n  \n ',""," "]);return Gp=function(){return e},e}function Vp(){const e=Kp(['']);return Vp=function(){return e},e}function Wp(){const e=Kp(['',""]);return Wp=function(){return e},e}function Jp(){const e=Kp(['\n \n ',"\n ","\n "]);return Jp=function(){return e},e}function Qp(){const e=Kp(['

    ',"
    "]);return Qp=function(){return e},e}function Yp(){const e=Kp(["\n ",'\n
    "]);return Yp=function(){return e},e}function Kp(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Xp(){const e=(t=[''],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return Xp=function(){return e},e}n(4867),Cc.elements.define("converse-message-unfurl",class extends af{static get properties(){return{description:{type:String},image:{type:String},jid:{type:String},title:{type:String},url:{type:String}}}render(){return(e=>Ha(Up(),e.image&&Hp.isImageDomainAllowed(e.image)?Ha(Bp(),e.url,e.image,e.onload):"",e.url,e.title,e.description,e.url,Hp.getURI(e.url).domain()))(Object.assign({onload:()=>this.onImageLoad()},{description:this.description||"",image:this.image||"",title:this.title||"",url:this.url||""}))}onImageLoad(){this.dispatchEvent(new CustomEvent("imageLoaded",{detail:this,bubbles:!0}))}});const Zp=(e={})=>Ha(Xp(),e.classes||"");function ev(){const e=fv(['
    ',"
    "]);return ev=function(){return e},e}function tv(){const e=fv(['
    ']);return nv=function(){return e},e}function sv(){const e=fv(['
    ',"
    "]);return sv=function(){return e},e}function iv(){const e=fv(["\n ","\n ",'\n \n \n ',"\n ","\n \n ",'\n
    ',"
    \n "]);return iv=function(){return e},e}function rv(){const e=fv(['\n
    \n "]);return rv=function(){return e},e}function ov(){const e=fv(['',""]);return ov=function(){return e},e}function av(){const e=fv(["\n
    ","
    \n ","\n "]);return av=function(){return e},e}function cv(){const e=fv(['\n
    \n ','\n
    \n '," ",", ",'\n \n
    \n
    ']);return cv=function(){return e},e}function lv(){const e=fv(['',""]);return uv=function(){return e},e}function dv(){const e=fv(['',""]);return dv=function(){return e},e}function hv(){const e=fv(['\n
    \n\n
    \n ',"\n
    \n ","\n ","\n ","\n
    "]);return hv=function(){return e},e}function fv(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}const{Strophe:gv}=Mc.env,mv=Mc.env.utils;function pv(){const e=(t=['\n
    \n
    \n \n
    \n"],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return pv=function(){return e},e}function vv(){const e=yv(['']);return vv=function(){return e},e}function bv(){const e=yv(["",""]);return bv=function(){return e},e}function yv(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}Cc.elements.define("converse-chat-message",class extends af{static get properties(){return{jid:{type:String},mid:{type:String}}}render(){return this.show_spinner?Zp():this.model.get("file")&&!this.model.get("oob_url")?this.renderFileProgress():["error","info"].includes(this.model.get("type"))?this.renderInfoMessage():this.renderChatMessage()}connectedCallback(){super.connectedCallback(),this.chatbox=So.chatboxes.get(this.jid),this.model=this.chatbox.messages.get(this.mid),this.listenTo(this.chatbox,"change:first_unread_id",this.requestUpdate),this.listenTo(this.model,"change",this.requestUpdate),this.model.vcard&&this.listenTo(this.model.vcard,"change",this.requestUpdate),"groupchat"===this.model.get("type")&&(this.model.occupant?this.listenTo(this.model.occupant,"change",this.requestUpdate):this.listenTo(this.model,"occupantAdded",(()=>{this.listenTo(this.model.occupant,"change",this.requestUpdate)})))}getProps(){return Object.assign(this.model.toJSON(),this.getDerivedMessageProps())}renderInfoMessage(){const e=Ao()(this.model.get("time")).toISOString(),t=Vu("Retry");return Ha(hv(),this.model.get("type"),e,this.data_name,this.data_value,this.model.getMessageText(),this.model.get("reason")?Ha(dv(),this.model.get("reason")):"",this.model.get("error_text")?Ha(uv(),this.model.get("error_text")):"",this.model.get("retry_event_id")?Ha(lv(),this.onRetryClicked,t):"")}renderFileProgress(){const e=Vu("Uploading file:"),t=this.model.file.name,n=Fp()(this.model.file.size);return Ha(cv(),bp(this.getAvatarData()),e,t,n,this.model.get("progress"))}renderChatMessage(){return((e,t)=>{var n,s;const i=Vu("New messages");return Ha(Yp(),t.is_first_unread?Ha(Qp(),i):"",e.getExtraMessageClasses(),t.time,t.msgid,t.from,t.is_encrypted,t.msgid,e.showUserModal,t.should_show_avatar?bp(e.getAvatarData()):"",t.sender,t.is_me_message?"chat-msg__content--action":"",t.is_me_message?"":Ha(Jp(),e.showUserModal,t.username,t.hats.map((e=>Ha(Wp(),e.title))),e.model.get("edited")||e.model.get("time"),t.pretty_time,t.is_encrypted?Ha(Vp()):""),t.message_type,t.received?"chat-msg__body--received":"",t.is_delayed?"chat-msg__body--delayed":"",t.is_me_message?Ha(Gp(),t.edited||t.time,t.pretty_time,t.is_me_message?"**":"",t.username):"",t.is_retracted?e.renderRetraction():e.renderMessageText(),e.model,t.correcting,t.editable,t.is_retracted,e.model.get("hide_url_previews"),null===(n=e.model.get("ogp_metadata"))||void 0===n?void 0:n.length,t.message_type,e.model.get("hide_url_previews")?"":null===(s=e.model.get("ogp_metadata"))||void 0===s?void 0:s.map((t=>{var n;return Ha($p(),e.onUnfurlAnimationEnd,e.model.get("url_preview_transition"),null===(n=e.chatbox)||void 0===n?void 0:n.get("jid"),t["og:description"]||"",t["og:title"]||"",t["og:image"]||"",t["og:url"]||"")})))})(this,this.getProps())}shouldShowAvatar(){return Cc.settings.get("show_message_avatar")&&!this.model.isMeCommand()&&"headline"!==this.type}getAvatarData(){var e,t;return{classes:"chat-msg__avatar",height:36,width:36,image:"data:"+((null===(e=this.model.vcard)||void 0===e?void 0:e.get("image_type"))||So.DEFAULT_IMAGE_TYPE)+";base64,"+((null===(t=this.model.vcard)||void 0===t?void 0:t.get("image"))||So.DEFAULT_IMAGE)}}onUnfurlAnimationEnd(){"fade-out"===this.model.get("url_preview_transition")&&this.model.save({hide_url_previews:!this.model.get("hide_url_previews"),url_preview_transition:"fade-in"})}async onRetryClicked(){this.show_spinner=!0,this.requestUpdate(),await Cc.trigger(this.model.get("retry_event_id"),{synchronous:!0}),this.model.destroy(),this.parentElement.removeChild(this)}isFollowup(){const e=this.model.collection.models,t=e.indexOf(this.model),n=t?e[t-1]:null;if(null===n)return!1;const s=Ao()(this.model.get("time"));return this.model.get("from")===n.get("from")&&!this.model.isMeCommand()&&!n.isMeCommand()&&"info"!==this.model.get("type")&&"info"!==n.get("type")&&s.isBefore(Ao()(n.get("time")).add(10,"minutes"))&&!!this.model.get("is_encrypted")==!!n.get("is_encrypted")}isRetracted(){return this.model.get("retracted")||"retracted"===this.model.get("moderated")}hasMentions(){return"groupchat"===this.model.get("type")&&"them"===this.model.get("sender")&&this.chatbox.isUserMentioned(this.model)}getOccupantAffiliation(){var e;return null===(e=this.model.occupant)||void 0===e?void 0:e.get("affiliation")}getOccupantRole(){var e;return null===(e=this.model.occupant)||void 0===e?void 0:e.get("role")}getExtraMessageClasses(){const e=[this.isFollowup()?"chat-msg--followup":null,this.model.get("is_delayed")?"delayed":null,this.model.isMeCommand()?"chat-msg--action":null,this.isRetracted()?"chat-msg--retracted":null,this.model.get("type"),this.shouldShowAvatar()?"chat-msg--with-avatar":null].map((e=>e));var t,n;return"groupchat"===this.model.get("type")&&(e.push(null!==(t=this.getOccupantRole())&&void 0!==t?t:""),e.push(null!==(n=this.getOccupantAffiliation())&&void 0!==n?n:""),"them"===this.model.get("sender")&&this.hasMentions()&&e.push("mentioned")),this.model.get("correcting")&&e.push("correcting"),e.filter((e=>e)).join(" ")}getDerivedMessageProps(){const e=Cc.settings.get("time_format");return{pretty_time:Ao()(this.model.get("edited")||this.model.get("time")).format(e),has_mentions:this.hasMentions(),hats:So.getHats(this.model),is_first_unread:this.chatbox.get("first_unread_id")===this.model.get("id"),is_me_message:this.model.isMeCommand(),is_retracted:this.isRetracted(),username:this.model.getDisplayName(),should_show_avatar:this.shouldShowAvatar()}}getRetractionText(){if("groupchat"===this.model.get("type")&&this.model.get("moderated_by")){const e=this.model.get("moderated_by"),t=this.model.collection.chatbox;this.model.mod||(this.model.mod=t.occupants.findOccupant({jid:e})||t.occupants.findOccupant({nick:gv.getResourceFromJid(e)}));const n=this.model.mod?this.model.mod.getDisplayName():"A moderator";return Vu("%1$s has removed this message",n)}return Vu("%1$s has removed this message",this.model.getDisplayName())}renderRetraction(){const e=this.isRetracted()?this.getRetractionText():null;return Ha(av(),e,this.model.get("moderation_reason")?Ha(ov(),this.model.get("moderation_reason")):"")}renderMessageText(){const e=Vu("This message has been edited"),t=Vu("Show more"),n="groupchat"===this.model.get("type"),s=Vu("Show less"),i=Ha(rv(),this.model.get("spoiler_hint"),this.toggleSpoilerMessage,this.model.get("is_spoiler_visible")?"fa-eye-slash":"fa-eye",this.model.get("is_spoiler_visible")?s:t),r=this.model.get("is_spoiler")?"spoiler ".concat(this.model.get("is_spoiler_visible")?"":"hidden"):"",o=this.model.getMessageText();return Ha(iv(),this.model.get("is_spoiler")?i:"",this.model.get("subject")?Ha(sv(),this.model.get("subject")):"",this.model.get("is_only_emojis")?"chat-msg__text--larger":"",r,this.model,this.model.isMeCommand(),Cc.settings.get("show_images_inline"),o,!this.model.get("received")||this.model.isMeCommand()||n?"":Ha(nv()),this.model.get("edited")?Ha(tv(),e,this.showMessageVersionsModal):"",this.model.get("oob_url")?Ha(ev(),mv.getOOBURLMarkup(So,this.model.get("oob_url"))):"",this.model.get("error_text")||this.model.get("error"))}showUserModal(e){if("me"===this.model.get("sender"))So.xmppstatusview.showProfileModal(e);else if("groupchat"===this.model.get("type"))e.preventDefault(),Cc.modal.show(wp,{model:this.model.occupant},e);else{e.preventDefault();const t=this.model.collection.chatbox;Cc.modal.show(Lp,{model:t},e)}}showMessageVersionsModal(e){e.preventDefault(),Cc.modal.show(vp,{model:this.model},e)}toggleSpoilerMessage(e){null==e||e.preventDefault(),this.model.save({is_spoiler_visible:!this.model.get("is_spoiler_visible")})}}),So.getHats=function(e){if("groupchat"===e.get("type")){var t;const n=Cc.settings.get("muc_hats").filter((e=>e)).map((e=>e.toLowerCase()));let s=[];n.includes("vcard_roles")&&(s=e.vcard?e.vcard.get("role"):null,s=s?s.split(",").filter((e=>e)).map((e=>({title:e}))):[]);const i=[...e.occupant?[e.occupant.get("role")]:[],...e.occupant?[e.occupant.get("affiliation")]:[]].filter((e=>e)).filter((e=>n.includes(e.toLowerCase()))).map((e=>({title:e})));return[...n.includes("xep317")&&(null===(t=e.occupant)||void 0===t?void 0:t.get("hats"))||[],...s,...i]}return[]},Cc.elements.define("converse-message-history",class extends af{static get properties(){return{model:{type:Object},messages:{type:Array}}}render(){const e=this.messages;return e.length?Ha(bv(),Rf(e,(e=>e.get("id")),(e=>this.renderMessage(e)))):""}renderMessage(e){if(e.get("dangling_retraction")||e.get("is_only_key"))return"";const t=function(e){const t=e.collection.models,n=t.indexOf(e),s=t[n-1];if(!s||Ao()(e.get("time")).isAfter(Ao()(s.get("time")),"day")){const t=Ao()(e.get("time")).startOf("day");return(e=>Ha(pv(),e.time,e.time,e.datestring))({type:"date",time:t.toISOString(),datestring:t.format("dddd MMM Do YYYY")})}}(e);return[...t?[t]:[],Ha(vv(),this.model.get("jid"),e.get("id"))]}});var _v=n(3279),wv=n.n(_v);function Sv(e){if(!e.isHidden()&&Cc.settings.get("allow_url_history_change")){const t=window.location.hash;t&&e.messages.get(t.slice(1))&&So.router.history.navigate()}}function xv(){const e=jv(['']);return xv=function(){return e},e}function Ev(){const e=jv(['\n
    ',"
    \n \n \n ","\n "]);return Ev=function(){return e},e}function jv(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Av(){const e=kv([' ']);return Av=function(){return e},e}function Cv(){const e=kv(["\n :host {\n display: inline-block;\n padding: 0;\n margin: 0;\n }\n "]);return Cv=function(){return e},e}function kv(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}n(9023),Cc.elements.define("converse-chat-content",class extends af{static get properties(){return{jid:{type:String}}}connectedCallback(){super.connectedCallback(),this.markScrolled=wv()(this._markScrolled,50),this.model=So.chatboxes.get(this.jid),this.listenTo(this.model,"change:hidden_occupants",this.requestUpdate),this.listenTo(this.model,"change:scrolled",this.scrollDown),this.listenTo(this.model.messages,"add",this.requestUpdate),this.listenTo(this.model.messages,"change",this.requestUpdate),this.listenTo(this.model.messages,"remove",this.requestUpdate),this.listenTo(this.model.messages,"rendered",this.requestUpdate),this.listenTo(this.model.messages,"reset",this.requestUpdate),this.listenTo(this.model.notifications,"change",this.requestUpdate),this.listenTo(this.model.ui,"change",this.requestUpdate),this.model.occupants&&this.listenTo(this.model.occupants,"change",this.requestUpdate),this.addEventListener("scroll",(()=>this.markScrolled()))}render(){var e;return Ha(Ev(),this.model.getNotificationsText(),this.model,[...this.model.messages.models],(null===(e=this.model.ui)||void 0===e?void 0:e.get("chat-content-spinner-top"))?Ha(xv()):"")}_markScrolled(){let e=!0;const t=0===this.scrollTop,n=Math.ceil(this.clientHeight-this.scrollTop)>=this.scrollHeight-Math.ceil(this.scrollHeight/20);t?(e=!1,Sv(this.model)):n&&Cc.trigger("chatBoxScrolledUp",this),this.model.get("scolled")!==e&&ho(this.model,{scrolled:e})}scrollDown(){if(!this.model.get("scrolled")){if(this.scrollTo){const e=this.scrollTop?"smooth":"auto";this.scrollTo({top:0,behavior:e})}else this.scrollTop=0;Cc.trigger("chatBoxScrolledDown",{chatbox:this.model})}}}),customElements.define("converse-icon",class extends af{static get properties(){return{color:String,class_name:{attribute:"class"},style:String,size:String}}static get styles(){return((e,...t)=>{const n=t.reduce(((t,n,s)=>t+(e=>{if(e instanceof cc)return e.cssText;if("number"==typeof e)return e;throw Error(`Value passed to 'css' function must be a 'css' function result: ${e}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`)})(n)+e[s+1]),e[0]);let s=lc.get(n);return void 0===s&&lc.set(n,s=new cc(n,ac)),s})(Cv())}constructor(){super(),this.class_name="",this.style="",this.size="",this.color=""}getSource(){return"#icon-".concat(this.class_name.split(" ")[1].replace("fa-",""))}getStyles(){return"\n ".concat(this.size?"width: ".concat(this.size,";"):"","\n ").concat(this.size?"height: ".concat(this.size,";"):"","\n ").concat(this.color?"fill: ".concat(this.color,";"):"","\n ").concat(this.style,"\n ")}render(){return Ha(Av(),this.getStyles(),this.getSource())}});class Ov extends Af{constructor(e){if(super(e),this.vt=Ga,2!==e.type)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===Ga)return this.Vt=void 0,this.vt=e;if(e===$a)return e;if("string"!=typeof e)throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.vt)return this.Vt;this.vt=e;const t=[e];return t.raw=t,this.Vt={_$litType$:this.constructor.resultType,strings:t,values:[]}}}Ov.directiveName="unsafeHTML",Ov.resultType=1;const Tv=jf(Ov);function Nv(){const e=Mv(['
    ',"
    "]);return Nv=function(){return e},e}function Iv(){const e=Mv(['']);return Iv=function(){return e},e}function Mv(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Rv(){const e=Hv(["']);return Rv=function(){return e},e}function Dv(){const e=Hv(['\n
    \n \n \n
      ',"
    \n
    "]);return Dv=function(){return e},e}function zv(){const e=Hv(['\n
  • \n \n ',"\n "]);return Lv=function(){return e},e}function Pv(){const e=Hv(['\n ','\n
      \n ',"\n
    "]);return Pv=function(){return e},e}function Fv(){const e=Hv(["\n \n ','\n
      \n ',"\n
    \n
    \n "]);return Fv=function(){return e},e}function Bv(){const e=Hv(['\n
  • \n ',"\n
  • \n "]);return Bv=function(){return e},e}function Uv(){const e=Hv(["
      ","
    "]);return Uv=function(){return e},e}function qv(){const e=Hv(['\n
  • \n\n '," \n
  • \n "]);return qv=function(){return e},e}function Hv(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}Cc.elements.define("converse-chat-help",class extends af{static get properties(){return{chat_type:{type:String},messages:{type:Array},model:{type:Object},type:{type:String}}}render(){const e=(new Date).toISOString();return[Ha(Iv(),this.close,Cc.settings.get("assets_path")),...this.messages.map((t=>this.renderHelpMessage({isodate:e,markup:Er.filterXSS(t,{whiteList:{strong:[]}})})))]}close(){this.model.set({show_help_messages:!1})}renderHelpMessage(e){return Ha(Nv(),this.type,e.isodate,Tv(e.markup))}});const $v=Mc.env.utils,Gv=e=>Ha(Bv(),e.shouldBeHidden(e.emoji.sn)?"hidden":"",e.emoji.sn,e.emoji.sn,e.insertEmoji,e.emoji.sn,$v.shortnamesToEmojis(e.emoji.sn)),Vv=e=>{const t=Vu("Search");return Ha(Dv(),t,e.query||"",e.onSearchInputKeyDown,e.onSearchInputBlurred,e.onSearchInputFocus,e.query?"":(e=>{const t=Cc.settings.get("emoji_categories");return Ha(Uv(),Object.keys(t).map((n=>t[n]?(e=>Ha(qv(),e.category,e.category,e.current_category===e.category?"picked":"",Vu(Cc.settings.get("emoji_category_labels")[e.category]),e.onCategoryPicked,e.category,e.category,e.emoji))(Object.assign({category:n,emoji:e.sn2Emoji(t[n])},e)):"")))})(e),e.render_emojis?Ha(Rv(),e.chatview,e.model,e.search_results,e.current_skintone,e.query):"",["tone1","tone2","tone3","tone4","tone5"].map((t=>(e=>Ha(zv(),e.skintone,e.current_skintone===e.skintone?"picked":"",e.skintone,e.onSkintonePicked,$v.shortnamesToEmojis(":"+e.skintone+":")))(Object.assign({skintone:t},e)))))};function Wv(){const e=(t=['\n
    \n ',"\n ","\n
    \n "],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return Wv=function(){return e},e}const{sizzle:Jv}=Mc.env;function Qv(){const e=Kv(["\n ']);return Qv=function(){return e},e}function Yv(){const e=Kv(['\n
    \n \n \n
    "]);return Yv=function(){return e},e}function Kv(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}Cc.elements.define("converse-emoji-picker-content",class extends af{static get properties(){return{chatview:{type:Object},search_results:{type:Array},current_skintone:{type:String},model:{type:Object},query:{type:String}}}render(){const e={current_skintone:this.current_skintone,insertEmoji:e=>this.insertEmoji(e),query:this.query,search_results:this.search_results,shouldBeHidden:e=>this.shouldBeHidden(e)};return Ha(Wv(),(e=>{const t=Vu("Search results");return Ha(Fv(),!e.query,t,e.search_results.map((t=>Gv(Object.assign({emoji:t},e)))))})(e),(e=>{const t=Cc.settings.get("emoji_categories");return Ha(Lv(),e.query,Object.keys(t).map((n=>t[n]?(e=>Ha(Pv(),e.category,e.category,Vu(Cc.settings.get("emoji_category_labels")[e.category]),e.category,Object.values(Mc.emojis.json[e.category]).map((t=>Gv(Object.assign({emoji:t},e))))))(Object.assign({category:n},e)):"")))})(e))}firstUpdated(){this.initIntersectionObserver()}initIntersectionObserver(){if(window.IntersectionObserver){if(this.observer)this.observer.disconnect();else{const e={root:this.querySelector(".emoji-picker__lists"),threshold:[.1]},t=e=>this.setCategoryOnVisibilityChange(e);this.observer=new IntersectionObserver(t,e)}Jv(".emoji-picker",this).forEach((e=>this.observer.observe(e)))}}setCategoryOnVisibilityChange(e){const t=this.parentElement.navigator.selected;let n;if(n=e.filter((e=>e.target.contains(t))).pop()||e.reduce(((e,t)=>t.intersectionRatio>=((null==e?void 0:e.intersectionRatio)||0)?t:e),null),n&&n.isIntersecting){const e=n.target.getAttribute("data-category");e!==this.model.get("current_category")&&(this.parentElement.preserve_scroll=!0,this.model.save({current_category:e}))}}insertEmoji(e){e.preventDefault(),e.stopPropagation();const t="IMG"===e.target.nodeName?e.target.parentElement:e.target;this.parentElement.insertIntoTextArea(t.getAttribute("data-emoji"))}shouldBeHidden(e){if(e.includes("_tone")){if(!this.current_skintone||!e.includes(this.current_skintone))return!0}else if(this.current_skintone&&Mc.emojis.toned.includes(e))return!0;return!(!this.query||So.FILTER_CONTAINS(e,this.query))}}),n(3796);const Xv=Mc.env.utils;function Zv(){const e=(t=['',""],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return Zv=function(){return e},e}function eb(){const e=ub(["",""]);return eb=function(){return e},e}function tb(){const e=ub(['\n ']);return tb=function(){return e},e}function nb(){const e=ub(['\n \n ']);return nb=function(){return e},e}function sb(){const e=ub(['\n ']);return sb=function(){return e},e}function ib(){const e=ub(["",""]);return ib=function(){return e},e}function rb(){const e=ub(["\n \n ']);return rb=function(){return e},e}function ob(){const e=ub(['\n ']);return ob=function(){return e},e}function ab(){const e=ub(["
    "]);return ab=function(){return e},e}function cb(){const e=ub(['']);return cb=function(){return e},e}function lb(){const e=ub(['\n ',"\n ","\n "]);return lb=function(){return e},e}function ub(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}Cc.elements.define("converse-emoji-dropdown",class extends fp{static get properties(){return{chatview:{type:Object}}}constructor(){super(),this.render_emojis=!1}initModel(){return this.init_promise||(this.init_promise=(async()=>{await Cc.emojis.initialize();const e="converse.emoji-".concat(So.bare_jid,"-").concat(this.chatview.model.get("jid"));this.model=new So.EmojiPicker({id:e}),Cr(this.model,e),await new Promise((e=>this.model.fetch({success:e,error:e}))),this.model.set({autocompleting:null,ac_position:null})})()),this.init_promise}render(){return Ha(Yv(),Vu("Insert emojis"),Cc.settings.get("assets_path"),Ng(this.initModel().then((()=>Ha(Qv(),this.chatview,this.model,this.render_emojis,this.model.get("current_category")||"",this.model.get("current_skintone")||"",this.model.get("query")||""))),""))}connectedCallback(){super.connectedCallback(),this.render_emojis=!1}toggleMenu(e){e.stopPropagation(),e.preventDefault(),Xv.hasClass("show",this.menu)?Xv.ancestor(e.target,".toggle-emojis")&&this.hideMenu():this.showMenu()}async showMenu(){await this.initModel(),this.render_emojis||(this.render_emojis=!0,await this.requestUpdate()),super.showMenu(),setTimeout((()=>{var e;return null===(e=this.querySelector(".emoji-search"))||void 0===e?void 0:e.focus()}))}}),Cc.elements.define("converse-emoji-picker",class extends af{static get properties(){return{chatview:{type:Object},current_category:{type:String,reflect:!0},current_skintone:{type:String,reflect:!0},model:{type:Object},query:{type:String,reflet:!0},render_emojis:{type:Boolean}}}firstUpdated(){this.listenTo(this.model,"change",(e=>this.onModelChanged(e.changed))),this.initArrowNavigation()}constructor(){super(),this._search_results=[],this.debouncedFilter=Oo((e=>this.model.set({query:e.value})),250),this.registerEvents()}get search_results(){return this._search_results}set search_results(e){this._search_results=e,this.requestUpdate()}render(){return Vv({chatview:this.chatview,current_category:this.current_category,current_skintone:this.current_skintone,model:this.model,onCategoryPicked:e=>this.chooseCategory(e),onSearchInputBlurred:e=>this.chatview.emitFocused(e),onSearchInputFocus:e=>this.onSearchInputFocus(e),onSearchInputKeyDown:e=>this.onKeyDown(e),onSkintonePicked:e=>this.chooseSkinTone(e),query:this.query,search_results:this.search_results,render_emojis:this.render_emojis,sn2Emoji:e=>Xv.shortnamesToEmojis(this.getTonedShortname(e))})}updated(e){e.has("query")&&this.updateSearchResults(e),e.has("current_category")&&this.setScrollPosition()}onModelChanged(e){"current_category"in e&&(this.current_category=e.current_category),"current_skintone"in e&&(this.current_skintone=e.current_skintone),"query"in e&&(this.query=e.query)}setScrollPosition(){if(this.preserve_scroll)return void(this.preserve_scroll=!1);const e=this.querySelector(".emoji-lists__container--browse"),t=this.querySelector("#emoji-picker-".concat(this.current_category));t&&(e.scrollTop=t.offsetTop-3*t.offsetHeight+4)}updateSearchResults(e){const t=e.get("query"),n=So.FILTER_CONTAINS;if(this.query){if(this.query===t)return this.search_results;t&&this.query.includes(t)?this.search_results=this.search_results.filter((e=>n(e.sn,this.query))):this.search_results=Mc.emojis.list.filter((e=>n(e.sn,this.query)))}else this.search_results.length&&(this.search_results=[]);this.requestUpdate()}registerEvents(){this.onGlobalKeyDown=e=>this._onGlobalKeyDown(e),document.querySelector("body").addEventListener("keydown",this.onGlobalKeyDown)}connectedCallback(){super.connectedCallback(),this.registerEvents()}disconnectedCallback(){document.querySelector("body").removeEventListener("keydown",this.onGlobalKeyDown),super.disconnectedCallback()}_onGlobalKeyDown(e){this.navigator&&(e.keyCode===Mc.keycodes.ENTER&&this.navigator.selected&&Xv.isVisible(this)?this.onEnterPressed(e):e.keyCode===Mc.keycodes.DOWN_ARROW&&!this.navigator.enabled&&Xv.isVisible(this)&&this.enableArrowNavigation(e))}setCategoryForElement(e){const t=this.current_category,n=(null==e?void 0:e.getAttribute("data-category"))||t;t!==n&&this.model.save({current_category:n})}insertIntoTextArea(e){const t=this.model.get("autocompleting"),n=this.model.get("ac_position");this.chatview.getMessageForm().insertIntoTextArea(e,t,!1,n),this.model.set({autocompleting:null,query:"",ac_position:null})}chooseSkinTone(e){e.preventDefault(),e.stopPropagation();const t=("IMG"===e.target.nodeName?e.target.parentElement:e.target).getAttribute("data-skintone").trim();this.current_skintone===t?this.model.save({current_skintone:""}):this.model.save({current_skintone:t})}chooseCategory(e){e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation();const t=e.target.matches("li")?e.target:Xv.ancestor(e.target,"li");this.setCategoryForElement(t),this.navigator.select(t),!this.navigator.enabled&&this.navigator.enable()}onKeyDown(e){if(e.keyCode===Mc.keycodes.TAB)if(e.target.value){e.preventDefault();const t=Mc.emojis.shortnames.find((t=>So.FILTER_CONTAINS(t,e.target.value)));t&&this.model.set({query:t})}else this.navigator.enabled||this.enableArrowNavigation(e);else e.keyCode!==Mc.keycodes.DOWN_ARROW||this.navigator.enabled?e.keyCode===Mc.keycodes.ENTER?this.onEnterPressed(e):e.keyCode===Mc.keycodes.ESCAPE?(Xv.ancestor(this,"converse-emoji-dropdown").hideMenu(),this.chatview.el.querySelector(".chat-textarea").focus(),e.stopPropagation(),e.preventDefault()):e.keyCode!==Mc.keycodes.ENTER&&e.keyCode!==Mc.keycodes.DOWN_ARROW&&this.debouncedFilter(e.target):this.enableArrowNavigation(e)}onEnterPressed(e){e.emoji_keypress_handled||(e.preventDefault(),e.stopPropagation(),e.emoji_keypress_handled=!0,Mc.emojis.shortnames.includes(e.target.value)?this.insertIntoTextArea(e.target.value):1===this.search_results.length?this.insertIntoTextArea(this.search_results[0].sn):this.navigator.selected&&this.navigator.selected.matches(".insert-emoji")?this.insertIntoTextArea(this.navigator.selected.getAttribute("data-emoji")):this.navigator.selected&&this.navigator.selected.matches(".emoji-category")&&this.chooseCategory({target:this.navigator.selected}))}onSearchInputFocus(e){this.chatview.emitBlurred(e),this.disableArrowNavigation()}getTonedShortname(e){return Mc.emojis.toned.includes(e)&&this.current_skintone?"".concat(e.slice(0,e.length-1),"_").concat(this.current_skintone,":"):e}initArrowNavigation(){if(!this.navigator){const e="li:not(.hidden):not(.emoji-skintone), .emoji-search",t={jump_to_picked:".emoji-category",jump_to_picked_selector:".emoji-category.picked",jump_to_picked_direction:up.DIRECTION.down,picked_selector:".picked",scroll_container:this.querySelector(".emoji-picker__lists"),getSelector:t=>{if(t===up.DIRECTION.down){const t=this.navigator.selected&&this.navigator.selected.getAttribute("data-category");return t?'ul[data-category="'.concat(t,'"] li:not(.hidden):not(.emoji-skintone), .emoji-search'):e}return e},onSelected:e=>{e.matches(".insert-emoji")&&this.setCategoryForElement(e.parentElement),e.matches(".insert-emoji, .emoji-category")&&e.firstElementChild.focus(),e.matches(".emoji-search")&&e.focus()}};this.navigator=new up(this,t)}}disableArrowNavigation(){this.navigator.disable()}enableArrowNavigation(e){var t,n;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),null==e||null===(n=e.stopPropagation)||void 0===n||n.call(e),this.disableArrowNavigation(),this.navigator.enable(),this.navigator.handleKeydown(e)}}),Cc.elements.define("converse-message-limit-indicator",class extends af{static get properties(){return{model:{type:Object}}}connectedCallback(){super.connectedCallback(),this.listenTo(this.model,"change:draft",this.requestUpdate)}render(){const e=Cc.settings.get("message_limit");return e?(e=>{const t=Vu("Message characters remaining");return Ha(Zv(),e<1?"error":"",t,e)})(e-(this.model.get("draft")||"").length):""}}),n(4837);const db=Mc.env.Strophe;function hb(){const e=yb(['

    ',"

    "]);return hb=function(){return e},e}function fb(){const e=yb([""]);return fb=function(){return e},e}function gb(){const e=yb(['']);return pb=function(){return e},e}function vb(){const e=yb(['\n
    \n
    \n ',"\n ",'\n
    \n ','\n
    \n
    \n
    \n ',"\n ","\n
    \n
    \n ","\n "]);return vb=function(){return e},e}function bb(){const e=yb(['',""]);return bb=function(){return e},e}function yb(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function _b(){const e=Sb(['\n
    \n ']);return _b=function(){return e},e}function wb(){const e=Sb(['\n ',"\n "]);return wb=function(){return e},e}function Sb(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}async function xb(e){const t=await e;return Ha(wb(),t.a_class,t.handler,t.i18n_title,t.icon_class,t.i18n_text)}async function Eb(e){const t=await e;return Ha(_b(),t.a_class,t.icon_class,t.handler,t.i18n_title)}async function jb(e){!0===confirm(Vu("Are you sure you want to clear the messages from this conversation?"))&&await e.clearMessages()}function Ab(e,t){const n=t.replace(/^\s*/,"").match(/^\/(.*)\s*$/);if(n){if("clear"===n[1])return jb(e),!0;var s;if("close"===n[1])return null===(s=So.chatboxviews.get(e.get("jid")))||void 0===s||s.close(),!0;if("help"===n[1])return e.set({show_help_messages:!1},{silent:!0}),e.set({show_help_messages:!0}),!0}}function Cb(e){if(e.target.value){const t=e.target.scrollHeight+"px";e.target.style.height!=t&&(e.target.style.height="auto",e.target.style.height=t)}else e.target.style=""}window.customElements.define("converse-chat-toolbar",class extends af{static get properties(){return{composing_spoiler:{type:Boolean},hidden_occupants:{type:Boolean},is_groupchat:{type:Boolean},message_limit:{type:Number},model:{type:Object},show_call_button:{type:Boolean},show_emoji_button:{type:Boolean},show_occupants_toggle:{type:Boolean},show_send_button:{type:Boolean},show_spoiler_button:{type:Boolean}}}connectedCallback(){super.connectedCallback(),this.listenTo(this.model,"change:composing_spoiler",this.requestUpdate)}render(){const e=Vu("Send the message");return Ha(lb(),Ng(this.getButtons(),""),this.show_send_button?Ha(cb(),e):"")}firstUpdated(){Cc.trigger("renderToolbar",this)}getButtons(){const e=[];if(this.show_emoji_button){const t=So.chatboxviews.get(this.model.get("jid"));e.push(Ha(ab(),t))}if(this.show_call_button){const t=Vu("Start a call");e.push(Ha(ob(),this.toggleCall,t))}Cc.settings.get("message_limit")&&e.push(Ha(rb(),this.model)),this.show_spoiler_button&&e.push(this.getSpoilerButton());const t=Cc.disco.supports(db.NS.HTTPUPLOAD,So.domain);if(e.push(Ha(ib(),Ng(t.then((e=>this.getHTTPUploadButton(e))),""))),this.show_occupants_toggle){const t=Vu("Hide participants"),n=Vu("Show participants");e.push(Ha(sb(),this.hidden_occupants?n:t,this.toggleOccupants,this.hidden_occupants?"fa-angle-double-left":"fa-angle-double-right",Cc.settings.get("assets_path")))}return So.api.hook("getToolbarButtons",this,e)}getHTTPUploadButton(e){if(e){const e=Vu("Choose a file to send");return Ha(nb(),e,this.toggleFileUpload,Cc.settings.get("assets_path"),this.onFileSelection)}return""}getSpoilerButton(){var e;const t=this.model;if(!this.is_groupchat&&!(null===(e=t.presence)||void 0===e?void 0:e.resources.length))return;let n;n=this.composing_spoiler?Vu("Click to write as a normal (non-spoiler) message"):Vu("Click to write your message as a spoiler");const s=Ha(tb(),n,this.toggleComposeSpoilerMessage,this.composing_spoiler?"fa-eye-slash":"fa-eye",Cc.settings.get("assets_path"));if(this.is_groupchat)return s;{const e=t.get("jid"),n=Promise.all(t.presence.resources.map((t=>Cc.disco.supports(db.NS.SPOILER,"".concat(e,"/").concat(t.get("name")))))).then((e=>e.reduce(((e,t)=>e&&t),!0)));return Ha(eb(),Ng(n.then((()=>s)),""))}}toggleFileUpload(e){var t,n;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),null==e||null===(n=e.stopPropagation)||void 0===n||n.call(e),this.querySelector(".fileupload").click()}onFileSelection(e){this.model.sendFiles(e.target.files)}toggleComposeSpoilerMessage(e){var t,n;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),null==e||null===(n=e.stopPropagation)||void 0===n||n.call(e),this.model.set("composing_spoiler",!this.model.get("composing_spoiler"))}toggleOccupants(e){var t,n;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),null==e||null===(n=e.stopPropagation)||void 0===n||n.call(e),this.model.save({hidden_occupants:!this.model.get("hidden_occupants")})}toggleCall(e){var t,n;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),null==e||null===(n=e.stopPropagation)||void 0===n||n.call(e),Cc.trigger("callButtonClicked",{connection:So.connection,model:this.model})}}),n(4311);class kb extends yf{async render(){const e=await this.generateHeadingTemplate();Wa(e,this)}connectedCallback(){var e;super.connectedCallback(),this.model=So.chatboxes.get(this.getAttribute("jid")),this.debouncedRender=Oo(this.render,100),this.listenTo(this.model,"vcard:change",this.debouncedRender),this.model.contact&&this.listenTo(this.model.contact,"destroy",this.debouncedRender),null===(e=this.model.rosterContactAdded)||void 0===e||e.then((()=>{this.listenTo(this.model.contact,"change:nickname",this.debouncedRender),this.debouncedRender()})),this.render()}showUserDetailsModal(e){e.preventDefault(),Cc.modal.show(Lp,{model:this.model},e)}close(){var e;null===(e=So.chatboxviews.get(this.getAttribute("jid")))||void 0===e||e.close()}getHeadingButtons(){const e=[{a_class:"show-user-details-modal",handler:e=>this.showUserDetailsModal(e),i18n_text:Vu("Details"),i18n_title:Vu("See more information about this person"),icon_class:"fa-id-card",name:"details",standalone:"overlayed"===Cc.settings.get("view_mode")}];Cc.settings.get("singleton")||e.push({a_class:"close-chatbox-button",handler:e=>this.close(e),i18n_text:Vu("Close"),i18n_title:Vu("Close and end this conversation"),icon_class:"fa-times",name:"close",standalone:"overlayed"===Cc.settings.get("view_mode")});const t=So.chatboxviews.get(this.getAttribute("jid"));return t?So.api.hook("getHeadingButtons",t,e):e}async generateHeadingTemplate(){var e;const t=null===(e=this.model)||void 0===e?void 0:e.vcard,n=t?t.toJSON():{},s=Vu("The User's Profile Image"),i=Object.assign({alt_text:s,extra_classes:"",height:40,width:40},n),r=await this.getHeadingButtons(),o=r.filter((e=>e.standalone)),a=r.filter((e=>!e.standalone));return(e=>{const t=Ha(bb(),bp(e.avatar_data));return Ha(vb(),e.status?"":"chatbox-title--no-desc",So.api.settings.get("singleton")?"":Ha(pb(),e.jid),e.type!==So.HEADLINES_TYPE?Ha(mb(),e.showUserDetailsModal,t):"",e.jid,e.type!==So.HEADLINES_TYPE?Ha(gb(),e.showUserDetailsModal,e.display_name):e.display_name,e.dropdown_btns.length?Ha(fb(),e.dropdown_btns):"",e.standalone_btns.length?(e=>e.standalone_btns.reverse().map((e=>Ng(e,""))))(e):"",e.status?Ha(hb(),e.status):"")})(Object.assign(this.model.toJSON(),{avatar_data:i,display_name:this.model.getDisplayName(),dropdown_btns:a.map((e=>xb(e))),showUserDetailsModal:e=>this.showUserDetailsModal(e),standalone_btns:o.map((e=>Eb(e)))}))}}function Ob(){const e=(t=['\n
    \n \n ',"\n "],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return Ob=function(){return e},e}Cc.elements.define("converse-chat-heading",kb);const{u:Tb}=Mc.env;class Nb extends yf{async connectedCallback(){super.connectedCallback(),this.model=So.chatboxes.get(this.getAttribute("jid")),await this.model.initialized,this.listenTo(this.model.messages,"change:correcting",this.onMessageCorrecting),this.render()}toHTML(){var e,t;return(e=>{const t=e.composing_spoiler?Vu("Hidden message"):Vu("Message"),n=Vu("Optional hint"),s=Cc.settings.get("show_send_button");return Ha(Ob(),n||"",e.hint_value||"",e.composing_spoiler?"":"hidden",e.onDrop,Cb,e.onKeyDown,e.onKeyUp,e.onPaste,e.onChange,s?"chat-textarea-send-button":"",e.composing_spoiler?"spoiler":"",t,e.message_value||"")})(Object.assign(this.model.toJSON(),{onDrop:e=>this.onDrop(e),hint_value:null===(e=this.querySelector(".spoiler-hint"))||void 0===e?void 0:e.value,message_value:null===(t=this.querySelector(".chat-textarea"))||void 0===t?void 0:t.value,onChange:e=>this.model.set({draft:e.target.value}),onKeyDown:e=>this.onKeyDown(e),onKeyUp:e=>this.onKeyUp(e),onPaste:e=>this.onPaste(e),viewUnreadMessages:e=>this.viewUnreadMessages(e)}))}insertIntoTextArea(e,t=!1,n=!1,s){const i=this.querySelector(".chat-textarea");if(n?Tb.addClass("correcting",i):Tb.removeClass("correcting",i),t)i.value=s&&"string"==typeof t?i.value.replace(new RegExp(t,"g"),((n,i)=>i==s-t.length?e+" ":n)):e;else{let t=i.value;t&&" "!==t[t.length-1]&&(t+=" "),i.value=t+e+" "}const r=document.createEvent("HTMLEvents");r.initEvent("change",!1,!0),i.dispatchEvent(r),Tb.placeCaretAtEnd(i)}onMessageCorrecting(e){if(e.get("correcting"))this.insertIntoTextArea(Tb.prefixMentions(e),!0,!0);else{const t=this.model.messages.findWhere("correcting");t&&t!==e?this.insertIntoTextArea(Tb.prefixMentions(e),!0,!0):this.insertIntoTextArea("",!0,!1)}}onEscapePressed(e){e.preventDefault();const t=this.model.messages.findLastIndex("correcting"),n=t>=0?this.model.messages.at(t):null;n&&n.save("correcting",!1),this.insertIntoTextArea("",!0,!1)}onPaste(e){if(e.stopPropagation(),0!==e.clipboardData.files.length)return e.preventDefault(),void this.model.sendFiles(Array.from(e.clipboardData.files));this.model.set({draft:e.clipboardData.getData("text/plain")})}onKeyUp(e){this.model.set({draft:e.target.value})}onKeyDown(e){if(!e.ctrlKey){if(!e.shiftKey&&!e.altKey&&!e.metaKey)if(e.keyCode===Mc.keycodes.TAB){const t=Tb.getCurrentWord(e.target,null,/(:.*?:)/g);t.startsWith(":")&&(e.preventDefault(),e.stopPropagation(),this.model.trigger("emoji-picker-autocomplete",e.target,t))}else{if(e.keyCode===Mc.keycodes.FORWARD_SLASH)return;if(e.keyCode===Mc.keycodes.ESCAPE)return this.onEscapePressed(e,this);if(e.keyCode===Mc.keycodes.ENTER)return this.onFormSubmitted(e);if(e.keyCode!==Mc.keycodes.UP_ARROW||e.target.selectionEnd){if(e.keyCode===Mc.keycodes.DOWN_ARROW&&e.target.selectionEnd===e.target.value.length&&Tb.hasClass("correcting",this.querySelector(".chat-textarea")))return this.model.editLaterMessage()}else{const e=this.querySelector(".chat-textarea");if(!e.value||Tb.hasClass("correcting",e))return this.model.editEarlierMessage()}}[Mc.keycodes.SHIFT,Mc.keycodes.META,Mc.keycodes.META_RIGHT,Mc.keycodes.ESCAPE,Mc.keycodes.ALT].includes(e.keyCode)||this.model.get("chat_state")!==So.COMPOSING&&this.model.setChatState(So.COMPOSING)}}parseMessageForCommands(e){return Ab(this.model,e)}async onFormSubmitted(e){var t,n;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e);const s=this.querySelector(".chat-textarea"),i=s.value.trim();if(Cc.settings.get("message_limit")&&i.length>Cc.settings.get("message_limit")||!i.replace(/\s/g,"").length)return;if(!So.connection.authenticated){const e=Vu("Sorry, the connection has been lost, and your message could not be sent");return Cc.alert("error",Vu("Error"),e),void Cc.connection.reconnect()}let r,o={};this.model.get("composing_spoiler")&&(o=this.querySelector("form.sendXMPPMessage input.spoiler-hint"),r=o.value),Tb.addClass("disabled",s),s.setAttribute("disabled","disabled"),null===(n=this.querySelector("converse-emoji-dropdown"))||void 0===n||n.hideMenu();const a=this.parseMessageForCommands(i),c=a?null:await this.model.sendMessage(i,r);(a||c)&&(o.value="",s.value="",Tb.removeClass("correcting",s),s.style.height="auto",this.model.set({draft:""})),"overlayed"===Cc.settings.get("view_mode")&&(So.chatboxviews.get(this.getAttribute("jid")).querySelector(".chat-content__messages").parentElement.style.display="none"),s.removeAttribute("disabled"),Tb.removeClass("disabled",s),"overlayed"===Cc.settings.get("view_mode")&&(So.chatboxviews.get(this.getAttribute("jid")).querySelector(".chat-content__messages").parentElement.style.display=""),this.model.setChatState(So.ACTIVE,{silent:!0}),s.focus()}}function Ib(){const e=Db(['\n ']);return Ib=function(){return e},e}function Mb(){const e=Db(['
    \n ']);return Rb=function(){return e},e}function Db(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}Cc.elements.define("converse-message-form",Nb),n(6694);class zb extends yf{constructor(...e){var t,n,s;super(...e),s={"click .send-button":"sendButtonClicked","click .toggle-clear":"clearMessages"},(n="events")in(t=this)?Object.defineProperty(t,n,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[n]=s}async connectedCallback(){super.connectedCallback(),this.debouncedRender=Oo(this.render,100),this.model=So.chatboxes.get(this.getAttribute("jid")),await this.model.initialized,this.listenTo(this.model,"change:num_unread",this.debouncedRender),this.listenTo(this.model,"emoji-picker-autocomplete",this.autocompleteInPicker),this.addEventListener("focusin",(e=>this.emitFocused(e))),this.addEventListener("focusout",(e=>this.emitBlurred(e))),this.render()}render(){Wa((e=>{const t=Vu("You have unread messages"),n=Cc.settings.get("message_limit"),s=Cc.settings.get("visible_toolbar_buttons").call,i=Cc.settings.get("visible_toolbar_buttons").emoji,r=Cc.settings.get("show_send_button"),o=Cc.settings.get("visible_toolbar_buttons").spoiler,a=Cc.settings.get("show_toolbar");return Ha(Rb(),e.model.get("scrolled")&&e.model.get("num_unread")?Ha(Mb(),(t=>e.viewUnreadMessages(t)),t):"",Cc.settings.get("show_toolbar")?Ha(Ib(),e.model,e.model.get("composing_spoiler"),s,i,r,o,a,n):"",e.model.get("jid"))})({model:this.model,viewUnreadMessages:e=>this.viewUnreadMessages(e)}),this)}sendButtonClicked(e){var t;null===(t=this.querySelector("converse-message-form"))||void 0===t||t.onFormSubmitted(e)}viewUnreadMessages(e){var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),this.model.save({scrolled:!1})}emitFocused(e){var t;null===(t=So.chatboxviews.get(this.getAttribute("jid")))||void 0===t||t.emitFocused(e)}emitBlurred(e){var t;null===(t=So.chatboxviews.get(this.getAttribute("jid")))||void 0===t||t.emitBlurred(e)}getToolbarOptions(){return{}}onDrop(e){0!=e.dataTransfer.files.length&&(e.preventDefault(),this.model.sendFiles(e.dataTransfer.files))}onDragOver(e){e.preventDefault()}clearMessages(e){var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),jb(this.model)}async autocompleteInPicker(e,t){await Cc.emojis.initialize();const n=this.querySelector("converse-emoji-picker");if(n){n.model.set({ac_position:e.selectionStart,autocompleting:t,query:t});const s=this.querySelector("converse-emoji-dropdown");null==s||s.showMenu()}}}Cc.elements.define("converse-chat-bottom-panel",zb);const Lb=Mc.env.utils;class Pb extends af{static get properties(){return{jid:{type:String}}}disconnectedCallback(){super.disconnectedCallback(),So.chatboxviews.remove(this.jid,this)}updated(){this.model&&this.jid!==this.model.get("jid")&&(this.stopListening(),delete this.model,this.requestUpdate(),this.initialize())}maybeFocus(){Cc.settings.get("auto_focus")&&this.focus()}focus(){const e=this.getElementsByClassName("chat-textarea")[0];return e&&document.activeElement!==e&&e.focus(),this}emitBlurred(e){this.contains(document.activeElement)||this.contains(e.relatedTarget)||Cc.trigger("chatBoxBlurred",this,e)}emitFocused(e){this.contains(e.relatedTarget)||Cc.trigger("chatBoxFocused",this,e)}onStatusMessageChanged(e){this.renderHeading(),Cc.trigger("contactStatusMessageChanged",{contact:e.attributes,message:e.get("status")})}getBottomPanel(){return this.model.get("type")===So.CHATROOMS_TYPE?this.querySelector("converse-muc-bottom-panel"):this.querySelector("converse-chat-bottom-panel")}getMessageForm(){return this.model.get("type")===So.CHATROOMS_TYPE?this.querySelector("converse-muc-message-form"):this.querySelector("converse-message-form")}scrollDown(e){var t,n;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),null==e||null===(n=e.stopPropagation)||void 0===n||n.call(e),this.model.get("scrolled")&&Lb.safeSave(this.model,{scrolled:!1}),Sv(this.model)}onWindowStateChanged(e){"visible"===e.state?this.model.isHidden()||this.model.clearUnreadMsgCounter():"hidden"===e.state&&(this.model.setChatState(So.INACTIVE,{silent:!0}),this.model.sendChatState())}}function Fb(){const e=qb(['
    \n
    ']);return Fb=function(){return e},e}function Bb(){const e=qb(['\n \n
    \n
    \n \n\n ','\n
    \n \n
    \n ']);return Bb=function(){return e},e}function Ub(){const e=qb(['\n
    \n \n ',"\n
    \n"]);return Ub=function(){return e},e}function qb(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}class Hb extends Pb{constructor(...e){var t,n;super(...e),(n="length")in(t=this)?Object.defineProperty(t,n,{value:200,enumerable:!0,configurable:!0,writable:!0}):t[n]=200}connectedCallback(){super.connectedCallback(),this.initialize()}async initialize(){So.chatboxviews.add(this.jid,this),this.model=So.chatboxes.get(this.jid),this.listenTo(So,"windowStateChanged",this.onWindowStateChanged),this.listenTo(this.model,"change:hidden",(()=>!this.model.get("hidden")&&this.afterShown())),this.listenTo(this.model,"change:show_help_messages",this.requestUpdate),this.listenTo(this.model,"change:status",this.onStatusMessageChanged),await this.model.messages.fetched,!this.model.get("hidden")&&this.afterShown(),Cc.trigger("chatBoxViewInitialized",this)}render(){return(e=>Ha(Ub(),e.model?Ha(Bb(),e.jid,e.show_send_button?"chat-content-sendbutton":"",e.jid,e.show_help_messages?Ha(Fb(),e.model,e.help_messages,!e.show_help_messages,So.CHATROOMS_TYPE):"",e.jid):""))(Object.assign({model:this.model,help_messages:this.getHelpMessages(),show_help_messages:this.model.get("show_help_messages")},this.model.toJSON()))}getHelpMessages(){return["/clear: ".concat(Vu("Remove messages")),"/close: ".concat(Vu("Close this chat")),"/me: ".concat(Vu("Write in the third person")),"/help: ".concat(Vu("Show this menu"))]}showControlBox(){var e;null===(e=So.chatboxviews.get("controlbox"))||void 0===e||e.show()}close(e){var t;return null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),So.router.history.getFragment()==="converse/chat?jid="+this.model.get("jid")&&So.router.navigate(""),this.model.close(e)}afterShown(){this.model.setChatState(So.ACTIVE),this.maybeFocus()}}Cc.elements.define("converse-chat",Hb);const $b={chatviews:{get:e=>void 0===e?Object.values(So.chatboxviews.getAll()):"string"==typeof e?So.chatboxviews.get(e):e.map((e=>So.chatboxviews.get(e)))}};n(9475);const{Strophe:Gb}=Mc.env;function Vb(){const e=Jb(['\n

    ','

    \n

    \n Open Source XMPP chat client\n brought to you by Opkode\n

    \n

    \n Translate\n it into your own language\n

    \n ']);return Vb=function(){return e},e}function Wb(){const e=Jb(["\n ","\n "]);return Wb=function(){return e},e}function Jb(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Qb(){const e=Kb(['\n \n ']);return Qb=function(){return e},e}function Yb(){const e=Kb(['\n \n \n \n \n "]);return Yb=function(){return e},e}function Kb(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Xb(){const e=(t=["\n \n \n "],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return Xb=function(){return e},e}function Zb(){const e=ay(['\n \n
    \n
    \n \n \n
    \n ","\n
    \n"]);return Zb=function(){return e},e}function ey(){const e=ay(["

    ","

    "]);return ey=function(){return e},e}function ty(){const e=ay(['']);return ty=function(){return e},e}function ny(){const e=ay(["\n ","\n ","\n ","\n "]);return ny=function(){return e},e}function sy(){const e=ay(['\n
    \n \n \n
    \n ',"\n ",'\n
    \n \n
    \n ',"\n "]);return sy=function(){return e},e}function iy(){const e=ay(['\n
    \n

    ','

    \n

    \n
    \n "]);return iy=function(){return e},e}function ry(){const e=ay(['\n
    \n \n \n
    \n ']);return ry=function(){return e},e}function oy(){const e=ay(['\n \n ']);return oy=function(){return e},e}function ay(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}Mc.plugins.add("converse-chatview",{dependencies:["converse-chatboxviews","converse-chat","converse-disco","converse-modal"],initialize(){Cc.settings.extend({auto_focus:!0,debounced_content_rendering:!0,filter_url_query_params:null,image_urls_regex:null,message_limit:0,muc_hats:["xep317"],show_images_inline:!0,show_message_avatar:!0,show_retraction_warning:!0,show_send_button:!0,show_toolbar:!0,time_format:"HH:mm",use_system_emojis:!0,visible_toolbar_buttons:{call:!1,clear:!0,emoji:!0,spoiler:!0}}),Object.assign(Cc,$b),So.ChatBoxView=Hb,Cc.listen.on("connected",(()=>Cc.disco.own.features.add(Gb.NS.SPOILER)))}}),Cc.elements.define("converse-brand-byline",class extends af{render(){const e="fullscreen"===Cc.settings.get("view_mode");return Ha(Wb(),e?Ha(Vb(),So.VERSION_NAME):"")}}),Cc.elements.define("converse-brand-logo",class extends af{render(){const e="fullscreen"===Cc.settings.get("view_mode");return Ha(Yb(),e?"brand-name-wrapper--fullscreen":"",e?Ha(Qb()):"")}}),Cc.elements.define("converse-brand-heading",class extends af{render(){return Ha(Xb())}});const cy=e=>Ha(Zb(),e.conn_feedback_subject?e.conn_feedback_class:"hidden",e.conn_feedback_subject,e.conn_feedback_message?"":"hidden",e.conn_feedback_message,"CONNECTING"===So.CONNECTION_STATUS[e.connection_status]?Zp({classes:"hor_centered"}):(e=>{const t=Vu("Disconnected"),n=Vu("Click here to log in anonymously");return Ha(ny(),e.authentication==e.LOGIN||e.authentication==e.EXTERNAL?(e=>{const t=Vu("Log in"),n=Vu("XMPP Address");return Ha(sy(),n,!!Cc.settings.get("auto_focus"),e.placeholder_username,e.authentication!==e.EXTERNAL?(()=>{const e=Vu("Password");return Ha(ry(),e,e)})():"",e.show_trust_checkbox?(e=>{const t=Vu("To improve performance, we cache your data in this browser. Uncheck this box if this is a public computer or if you want your data to be deleted when you log out. It's important that you explicitly log out, otherwise not all cached data might be deleted. Please note, when using an untrusted device, OMEMO encryption is NOT available."),n=Vu("This is a trusted device");return Ha(oy(),e,n,t)})("off"!==e.show_trust_checkbox):"",t,So.allow_registration&&!Cc.settings.get("auto_login")&&So.pluggable.plugins["converse-register"].enabled(So)?(()=>{const e=Vu("Create an account"),t=Vu("Don't have a chat account?");return Ha(iy(),t,e)})():"")})(e):"",e.authentication==e.ANONYMOUS?Ha(ty(),n):"",e.authentication==e.PREBIND?Ha(ey(),t):"")})(e));function ly(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const uy=Mc.env.utils,{Strophe:dy}=Mc.env,hy=[0,1,2,3,4,7,10],fy={0:"Error",1:"Connecting",2:"Connection failure",3:"Authenticating",4:"Authentication failure",5:"Connected",6:"Disconnected",7:"Disconnecting",8:"Attached",9:"Redirect",10:"Reconnecting"},gy={Error:"error",Connecting:"info","Connection failure":"error",Authenticating:"info","Authentication failure":"error",Connected:"info",Disconnected:"error",Disconnecting:"warn",Attached:"info",Redirect:"info",Reconnecting:"warn"},my=ao.extend({defaults:{errors:[]}});Cc.elements.define("converse-login-panel",class extends yf{constructor(...e){super(...e),ly(this,"id","converse-login-panel"),ly(this,"className","controlbox-pane fade-in row no-gutters"),ly(this,"events",{"submit form#converse-login":"authenticate","change input":"validate"})}initialize(){this.model=new my,this.listenTo(this.model,"change",this.render),this.listenTo(So.connfeedback,"change",this.render),this.render(),this.initPopovers()}render(){const e=So.connfeedback.get("connection_status");let t,n;hy.includes(e)&&(n=fy[e],t=gy[n]),Wa(cy(Object.assign(this.model.toJSON(),{_converse:So,ANONYMOUS:So.ANONYMOUS,EXTERNAL:So.EXTERNAL,LOGIN:So.LOGIN,PREBIND:So.PREBIND,auto_login:Cc.settings.get("auto_login"),authentication:Cc.settings.get("authentication"),connection_status:e,conn_feedback_class:t,conn_feedback_subject:n,conn_feedback_message:So.connfeedback.get("message"),placeholder_username:(Cc.settings.get("locked_domain")||Cc.settings.get("default_domain"))&&Vu("Username")||Vu("user@domain"),show_trust_checkbox:Cc.settings.get("allow_user_trust_override")})),this)}initPopovers(){Array.from(this.querySelectorAll("[data-title]")).forEach((e=>{new(ng().Popover)(e,{trigger:"mobile"===Cc.settings.get("view_mode")?"click":"hover",dismissible:"mobile"===Cc.settings.get("view_mode"),container:this.parentElement.parentElement.parentElement})}))}validate(){const e=this.querySelector("form").querySelector("input[name=jid]");return!e.value||Cc.settings.get("locked_domain")||Cc.settings.get("default_domain")||uy.isValidJID(e.value)?(e.setCustomValidity(""),!0):(e.setCustomValidity(Vu("Please enter a valid XMPP address")),!1)}authenticate(e){if(null==e||e.preventDefault(),Cc.settings.get("authentication")===So.ANONYMOUS)return this.connect(So.jid,null);if(!this.validate())return;const t=new FormData(e.target);So.config.save({trusted:!!t.get("trusted")});let n=t.get("jid");if(Cc.settings.get("locked_domain")){const e="@"+Cc.settings.get("locked_domain");n.endsWith(e)&&(n=n.substr(0,n.length-e.length)),n=dy.escapeNode(n)+e}else Cc.settings.get("default_domain")&&!n.includes("@")&&(n=n+"@"+Cc.settings.get("default_domain"));this.connect(n,t.get("password"))}connect(e,t){["converse/login","converse/register"].includes(So.router.history.getFragment())&&So.router.navigate("",{replace:!0}),So.connection&&So.connection.reset(),Cc.user.login(e,t)}});const py=Mc.env.utils;function vy(){var e;const t=So.chatboxes.add(new So.ControlBox({id:"controlbox"}));return null===(e=So.chatboxviews.get("controlbox"))||void 0===e||e.setModel(),t}function by(e){var t;null==e||null===(t=e.preventDefault)||void 0===t||t.call(e);const n=So.chatboxes.get("controlbox")||vy();py.safeSave(n,{closed:!1})}function yy(){const e=(t=['',""],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return Sy=function(){return e},e}class xy extends af{async connectedCallback(){super.connectedCallback(),await Cc.waitUntil("initialized"),this.model=So.chatboxes.get("controlbox"),this.listenTo(this.model,"change:closed",(()=>this.requestUpdate())),this.requestUpdate()}render(){var e;return(e=>{const t=Cc.connection.connected()?Vu("Chat Contacts"):Vu("Toggle chat");return Ha(Sy(),e.hide?"hidden":"",e.onClick,t)})({onClick:by,hide:!(null===(e=this.model)||void 0===e?void 0:e.get("closed"))})}}Cc.elements.define("converse-controlbox-toggle",xy);const Ey=xy;function jy(){const e=Ny([""]);return jy=function(){return e},e}function Ay(){const e=Ny([""]);return Ay=function(){return e},e}function Cy(){const e=Ny(['
    ']);return Cy=function(){return e},e}function ky(){const e=Ny(['\n \n \n
    \n \n \n
    \n ',""]);return ky=function(){return e},e}function Oy(){const e=Ny(['\n \n \n
    \n ','\n
    \n
    \n
    \n ',"\n
    \n
    \n
    \n"]);return Ty=function(){return e},e}function Ny(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}const Iy=Mc.env.utils;class My extends yf{initialize(){this.setModel(),this.render(),So.chatboxviews.add("controlbox",this),Cc.trigger("controlBoxInitialized",this)}setModel(){this.model=So.chatboxes.get("controlbox"),this.initEventHandlers()}initEventHandlers(){this.listenTo(this.model,"change:active-form",this.render),this.listenTo(this.model,"change:connected",this.render),this.listenTo(this.model,"change:closed",(()=>!this.model.get("closed")&&this.afterShown()))}render(){Wa((e=>Ha(Ty(),e.sticky_controlbox?"":Ha(Oy(),e.close),e.connected?Ha(ky(),Cc.settings.get("authentication")===So.ANONYMOUS?"":Ha(Cy())):"register"===e["active-form"]?Ha(Ay()):Ha(jy())))({sticky_controlbox:Cc.settings.get("sticky_controlbox"),...this.model.toJSON(),close:e=>this.close(e)}),this)}afterRender(){this.model.get("connected")&&void 0===this.model.get("closed")&&this.model.set("closed",!Cc.settings.get("show_controlbox_by_default"))}close(e){var t;if(null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),("closeAllChatBoxes"!==(null==e?void 0:e.name)||So.disconnection_cause===So.LOGOUT&&!Cc.settings.get("show_controlbox_by_default"))&&!Cc.settings.get("sticky_controlbox"))return Iy.safeSave(this.model,{closed:!0}),Cc.trigger("controlBoxClosed",this),this}afterShown(){return Cc.trigger("controlBoxOpened",this),this}showHelpMessages(){}}Cc.elements.define("converse-controlbox",My);const Ry=My,{u:Dy}=Mc.env,zy={controlbox:{async open(){await Cc.waitUntil("chatBoxesFetched");const e=await Cc.chatboxes.get("controlbox")||Cc.chatboxes.create("controlbox",{},So.Controlbox);return Dy.safeSave(e,{closed:!1}),e},get:()=>So.chatboxviews.get("controlbox")}};n(9980);const Ly=Mc.env.utils;function Py(){const e=So.chatboxviews.get("controlbox");return e.model.set({connected:!1}),e}function Fy(){const e=null==So?void 0:So.chatboxviews,t=e&&e.get("controlbox");t&&(Ly.safeSave(t.model,{connected:!1}),(null==t?void 0:t.controlbox_pane)&&(t.controlbox_pane.remove(),delete t.controlbox_pane))}function By(){(So.chatboxes.get("controlbox")||vy()).save({connected:!0})}Mc.plugins.add("converse-controlbox",{dependencies:["converse-modal","converse-chatboxes","converse-chat","converse-rosterview","converse-chatview"],enabled:e=>!e.api.settings.get("singleton"),overrides:{ChatBoxes:{model(e,t){const{_converse:n}=this.__super__;return e&&"controlbox"==e.id?new n.ControlBox(e,t):this.__super__.model.apply(this,arguments)}}},initialize(){Cc.settings.extend({allow_logout:!0,allow_user_trust_override:!0,default_domain:void 0,locked_domain:void 0,show_controlbox_by_default:!1,sticky_controlbox:!1}),Cc.promises.add("controlBoxInitialized"),Object.assign(Cc,zy),So.ControlBoxView=Ry,So.ControlBox=So.ChatBox.extend(wy),So.ControlBoxToggle=Ey,Cc.listen.on("chatBoxesFetched",By),Cc.listen.on("cleanup",(()=>delete So.controlboxtoggle)),Cc.listen.on("clearSession",Fy),Cc.listen.on("will-reconnect",Py),Cc.waitUntil("chatBoxViewsInitialized").then(vy).catch((e=>as.fatal(e)))}});const{u:Uy}=Mc.env;function qy(e,t=!0){if(!Cc.settings.get("allow_dragresize"))return!0;e.preventDefault();const n=Uy.ancestor(e.target,".box-flyout"),s=window.getComputedStyle(n),i=n.parentElement;i.height=parseInt(s.height.replace(/px$/,""),10),So.resizing={chatbox:i,direction:"top"},i.prev_pageY=e.pageY,t&&Cc.trigger("startVerticalResize",i)}function Hy(e,t=!0){if(!Cc.settings.get("allow_dragresize"))return!0;e.preventDefault();const n=Uy.ancestor(e.target,".box-flyout"),s=window.getComputedStyle(n),i=n.parentElement;i.width=parseInt(s.width.replace(/px$/,""),10),So.resizing={chatbox:i,direction:"left"},i.prev_pageX=e.pageX,t&&Cc.trigger("startHorizontalResize",i)}function $y(e){Hy(e,!1),qy(e,!1),So.resizing.direction="topleft",Cc.trigger("startDiagonalResize",this)}function Gy(e,t){if(void 0!==e)return void 0===t?e:e!==t&&Math.abs(e-t)<10?t:e}function Vy(e){if(!So.resizing||!Cc.settings.get("allow_dragresize"))return!0;e.preventDefault(),So.resizing.chatbox.resizeChatBox(e)}function Wy(e){if(!So.resizing||!Cc.settings.get("allow_dragresize"))return!0;e.preventDefault();const t=Gy(So.resizing.chatbox.height,So.resizing.chatbox.model.get("default_height")),n=Gy(So.resizing.chatbox.width,So.resizing.chatbox.model.get("default_width"));Cc.connection.connected()?(So.resizing.chatbox.model.save({height:t}),So.resizing.chatbox.model.save({width:n})):(So.resizing.chatbox.model.set({height:t}),So.resizing.chatbox.model.set({width:n})),So.resizing=null}function Jy(){const e=(t=['\n
    \n
    \n
    \n'],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return Jy=function(){return e},e}customElements.define("converse-dragresize",class extends af{render(){return Ha(Jy(),qy,$y,Hy)}});const Qy={initDragResize(){var e;const t=this,n=Oo((()=>t.setDimensions()));window.addEventListener("resize",t.debouncedSetDimensions),this.listenTo(this.model,"destroy",(()=>window.removeEventListener("resize",n)));const s=this.querySelector(".box-flyout"),i=window.getComputedStyle(s);if(void 0===this.model.get("height")){const e=parseInt(i.height.replace(/px$/,""),10),t=parseInt(i.width.replace(/px$/,""),10);this.model.set("height",e),this.model.set("default_height",e),this.model.set("width",t),this.model.set("default_width",t)}const r=i["min-width"],o=i["min-height"];return this.model.set("min_width",r.endsWith("px")?Number(r.replace(/px$/,"")):0),this.model.set("min_height",o.endsWith("px")?Number(o.replace(/px$/,"")):0),this.prev_pageY=0,this.prev_pageX=0,(null===(e=So.connection)||void 0===e?void 0:e.connected)&&(this.height=this.model.get("height"),this.width=this.model.get("width")),this},resizeChatBox(e){let t;0===So.resizing.direction.indexOf("top")&&(t=e.pageY-this.prev_pageY,t&&(this.height=this.height-t>(this.model.get("min_height")||0)?this.height-t:this.model.get("min_height"),this.prev_pageY=e.pageY,this.setChatBoxHeight(this.height))),So.resizing.direction.includes("left")&&(t=this.prev_pageX-e.pageX,t&&(this.width=this.width+t>(this.model.get("min_width")||0)?this.width+t:this.model.get("min_width"),this.prev_pageX=e.pageX,this.setChatBoxWidth(this.width)))},setDimensions(){this.adjustToViewport(),this.setChatBoxHeight(this.model.get("height")),this.setChatBoxWidth(this.model.get("width"))},setChatBoxHeight(e){e=e?Gy(e,this.model.get("default_height"))+"px":"";const t=this.querySelector(".box-flyout");null!==t&&(t.style.height=e)},setChatBoxWidth(e){e=e?Gy(e,this.model.get("default_width"))+"px":"",this.style.width=e;const t=this.querySelector(".box-flyout");null!==t&&(t.style.width=e)},adjustToViewport(){const e=Math.max(document.documentElement.clientWidth,window.innerWidth||0),t=Math.max(document.documentElement.clientHeight,window.innerHeight||0);e<=480?(this.model.set("height",void 0),this.model.set("width",void 0)):e<=this.model.get("width")?this.model.set("width",void 0):t<=this.model.get("height")&&this.model.set("height",void 0)}};function Yy(){const e=e_(['

    ',"

    "]);return Yy=function(){return e},e}function Ky(){const e=e_([""]);return Ky=function(){return e},e}function Xy(){const e=e_(['']);return Xy=function(){return e},e}function Zy(){const e=e_(['\n
    \n
    \n ','\n
    ','
    \n
    \n
    \n ',"\n ","\n
    \n
    \n ","\n "]);return Zy=function(){return e},e}function e_(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function t_(){const e=s_(['\n \n \n
    \n
    \n \n
    \n
    ']);return t_=function(){return e},e}function n_(){const e=s_(['\n
    \n \n ',"\n
    \n"]);return n_=function(){return e},e}function s_(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function i_(){const e=o_(['\n
    \n
    \n ',"\n
    \n
    \n"]);return i_=function(){return e},e}function r_(){const e=o_(['\n
    \n"]);return r_=function(){return e},e}function o_(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}Mc.plugins.add("converse-dragresize",{dependencies:["converse-chatview","converse-headlines-view","converse-muc-views"],enabled:e=>"overlayed"==e.api.settings.get("view_mode"),overrides:{ChatBox:{initialize(){const e=this.__super__.initialize.apply(this,arguments),t=this.get("height"),n=this.get("width");return("controlbox"===this.get("id")?e=>this.set(e):e=>this.save(e))({height:Gy(t,this.get("default_height")),width:Gy(n,this.get("default_width"))}),e}}},initialize(){Cc.settings.extend({allow_dragresize:!0}),Object.assign(So.ChatBoxView.prototype,Qy),Object.assign(So.ChatRoomView.prototype,Qy),Object.assign(So.ControlBoxView.prototype,Qy),Cc.listen.on("registeredGlobalEventHandlers",(function(){document.addEventListener("mousemove",Vy),document.addEventListener("mouseup",Wy)})),Cc.listen.on("unregisteredGlobalEventHandlers",(function(){document.removeEventListener("mousemove",Vy),document.removeEventListener("mouseup",Wy)})),Cc.listen.on("beforeShowingChatView",(e=>e.initDragResize().setDimensions()))}}),Mc.plugins.add("converse-singleton",{enabled:e=>e.api.settings.get("singleton"),initialize(){if(Cc.settings.extend({allow_logout:!1,allow_muc_invitations:!1,hide_muc_server:!0}),!Array.isArray(Cc.settings.get("auto_join_rooms"))&&!Array.isArray(Cc.settings.get("auto_join_private_chats")))throw new Error("converse-singleton: auto_join_rooms must be an Array");if(Cc.settings.get("auto_join_rooms").length>1||Cc.settings.get("auto_join_private_chats").length>1)throw new Error("It doesn't make sense to have singleton set to true and auto_join_rooms or auto_join_private_chats set to more then one, since only one chat room may be open at any time.")}}),n(2366),n(553),Mc.plugins.add("converse-fullscreen",{enabled:e=>e.isUniView(),initialize(){Cc.settings.extend({chatview_avatar_height:50,chatview_avatar_width:50,hide_open_bookmarks:!0,show_controlbox_by_default:!0,sticky_controlbox:!0})}}),Cc.elements.define("converse-headlines-heading",class extends kb{async connectedCallback(){super.connectedCallback(),this.model=So.chatboxes.get(this.getAttribute("jid")),await this.model.initialized,this.render()}async generateHeadingTemplate(){const e=await this.getHeadingButtons(),t=e.filter((e=>e.standalone)),n=e.filter((e=>!e.standalone));return(e=>Ha(Zy(),e.status?"":"chatbox-title--no-desc",So.api.settings.get("singleton")?"":Ha(Xy(),e.jid),e.jid,e.display_name,e.dropdown_btns.length?Ha(Ky(),e.dropdown_btns):"",e.standalone_btns.length?(e=>e.standalone_btns.reverse().map((e=>Ng(e,""))))(e):"",e.status?Ha(Yy(),e.status):""))(Object.assign(this.model.toJSON(),{display_name:this.model.getDisplayName(),dropdown_btns:n.map((e=>xb(e))),standalone_btns:t.map((e=>Eb(e)))}))}getHeadingButtons(){const e=[];return Cc.settings.get("singleton")||e.push({a_class:"close-chatbox-button",handler:e=>this.close(e),i18n_text:Vu("Close"),i18n_title:Vu("Close these announcements"),icon_class:"fa-times",name:"close",standalone:"overlayed"===Cc.settings.get("view_mode")}),So.api.hook("getHeadingButtons",this,e)}}),Cc.elements.define("converse-headlines",class extends Pb{connectedCallback(){super.connectedCallback(),this.initialize()}async initialize(){So.chatboxviews.add(this.jid,this),this.model=So.chatboxes.get(this.jid),this.model.disable_mam=!0,this.listenTo(So,"windowStateChanged",this.onWindowStateChanged),this.listenTo(this.model,"change:hidden",(()=>this.afterShown())),this.listenTo(this.model,"destroy",this.remove),this.listenTo(this.model,"show",this.show),this.listenTo(this.model.messages,"add",this.requestUpdate),this.listenTo(this.model.messages,"remove",this.requestUpdate),this.listenTo(this.model.messages,"reset",this.requestUpdate),await this.model.messages.fetched,this.model.maybeShow(),Cc.trigger("headlinesBoxViewInitialized",this)}render(){return(e=>Ha(n_(),e?Ha(t_(),e.get("jid"),e.get("jid")):""))(this.model)}async close(e){var t;return null==e||null===(t=e.preventDefault)||void 0===t||t.call(e),So.router.history.getFragment()==="converse/chat?jid="+this.model.get("jid")&&So.router.navigate(""),await this.model.close(e),Cc.trigger("chatBoxClosed",this),this}getNotifications(){return[]}afterShown(){}});function a_(){const e=(t=['\n
    \n
    \n ',"\n
    \n
    \n ","\n"],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return a_=function(){return e},e}class c_ extends yf{constructor(...e){var t,n,s;super(...e),s={"click .open-headline":"openHeadline"},(n="events")in(t=this)?Object.defineProperty(t,n,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[n]=s}initialize(){this.model=So.chatboxes,this.listenTo(this.model,"add",this.renderIfHeadline),this.listenTo(this.model,"remove",this.renderIfHeadline),this.listenTo(this.model,"destroy",this.renderIfHeadline),this.render()}toHTML(){return(e=>Ha(a_(),e.headlineboxes.length?"":"hidden",e.heading_headline,(e=>Ha(i_(),e.headlineboxes.length?"":"hidden",e.headlineboxes.map((t=>(e=>Ha(r_(),e.headlinebox.get("jid"),e.headlinebox.get("jid"),e.open_title,e.headlinebox.get("jid")))(Object.assign({headlinebox:t},e))))))(e)))({heading_headline:Vu("Announcements"),headlineboxes:this.model.filter((e=>e.get("type")===So.HEADLINES_TYPE)),open_title:Vu("Click to open this server message")})}renderIfHeadline(e){return e&&e.get("type")===So.HEADLINES_TYPE&&this.render()}openHeadline(e){e.preventDefault();const t=e.target.getAttribute("data-headline-jid");So.chatboxes.get(t).maybeShow(!0)}}async function l_(e){if(e.model.messages.length){const t=e.model.get("type")===So.CHATROOMS_TYPE,n=e.model.getOldestMessage();if(n){const s=t?e.model.get("jid"):So.bare_jid,i=n&&n.get("stanza_id ".concat(s));e.model.ui.set("chat-content-spinner-top",!0),i?await Fd(e.model,{before:i}):await Fd(e.model,{end:n.get("time")}),Cc.settings.get("allow_url_history_change")&&So.router.history.navigate("#".concat(n.get("msgid"))),setTimeout((()=>e.model.ui.set("chat-content-spinner-top",!1)),250)}}}function u_(){const e=h_(['',""]);return u_=function(){return e},e}function d_(){const e=h_(['\n
    \n \n \n ','\n \n
    \n ',"\n
    \n
    "]);return x_=function(){return e},e}function E_(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}class j_ extends yf{async initialize(){this.model=So.chatboxes,await this.initToggle(),this.render(),this.listenTo(this.minchats,"change:collapsed",this.render),this.listenTo(this.model,"add",this.render),this.listenTo(this.model,"change:fullname",this.render),this.listenTo(this.model,"change:jid",this.render),this.listenTo(this.model,"change:minimized",this.render),this.listenTo(this.model,"change:name",this.render),this.listenTo(this.model,"change:num_unread",this.render),this.listenTo(this.model,"remove",this.render)}render(){const e=this.model.where({minimized:!0}),t=e.reduce(((e,t)=>e+t.get("num_unread")),0),n=e.reduce(((e,t)=>e+(t.get("minimized")?1:0)),0),s={chats:e,num_unread:t,num_minimized:n,collapsed:this.minchats.get("collapsed")};s.toggle=e=>this.toggle(e),Wa((e=>Ha(x_(),e.chats.length?"":"hidden",e.toggle,e.num_minimized,Vu("Minimized"),e.num_unread?"":"unread-message-count-hidden",e.num_unread,e.collapsed?"hidden":"",e.chats.map((e=>Ha(S_(),e,e.getDisplayName(),e.get("type"),e.get("num_unread"))))))(s),this)}async initToggle(){const e="converse.minchatstoggle-".concat(So.bare_jid);this.minchats=new w_({id:e}),Cr(this.minchats,e,"session"),await new Promise((e=>this.minchats.fetch({success:e,error:e})))}toggle(e){null==e||e.preventDefault(),this.minchats.save({collapsed:!this.minchats.get("collapsed")})}}Cc.elements.define("converse-minimized-chats",j_),n(6123);const{dayjs:A_}=Mc.env;Mc.plugins.add("converse-minimize",{dependencies:["converse-chatview","converse-controlbox","converse-muc-views","converse-headlines-view","converse-dragresize"],enabled:e=>"overlayed"===e.api.settings.get("view_mode"),overrides:{ChatBox:{initialize(){this.__super__.initialize.apply(this,arguments),this.on("change:hidden",(e=>!e.get("hidden")&&y_(this)),this),"controlbox"!==this.get("id")&&this.save({minimized:this.get("minimized")||!1,time_minimized:this.get("time_minimized")||A_()})},maybeShow(e){return!e&&this.get("minimized")?this:this.__super__.maybeShow.apply(this,arguments)},isHidden(){return this.__super__.isHidden.call(this)||this.get("minimized")}},ChatBoxView:{isNewMessageHidden(){return this.model.get("minimized")||this.__super__.isNewMessageHidden.apply(this,arguments)},setChatBoxHeight(e){if(!this.model.get("minimized"))return this.__super__.setChatBoxHeight.call(this,e)},setChatBoxWidth(e){if(!this.model.get("minimized"))return this.__super__.setChatBoxWidth.call(this,e)}}},initialize(){function e(e){e.on("change:minimized",(()=>function(e){e.get("minimized")?function(e){Cc.trigger("chatBoxMinimized",e)}(e):function(e){e.isScrolledUp()||e.clearUnreadMsgCounter(),e.setChatState(So.ACTIVE),Cc.trigger("chatBoxMaximized",e)}(e)}(e)))}Cc.settings.extend({no_trimming:!1}),Cc.promises.add("minimizedChatsInitialized"),So.MinimizedChatsToggle=w_,So.MinimizedChats=j_,So.minimize={},So.minimize.trimChats=v_,So.minimize.minimize=__,So.minimize.maximize=y_,Cc.listen.on("chatBoxViewInitialized",(e=>So.minimize.trimChats(e))),Cc.listen.on("chatRoomViewInitialized",(e=>So.minimize.trimChats(e))),Cc.listen.on("chatBoxMaximized",(e=>So.minimize.trimChats(e))),Cc.listen.on("controlBoxOpened",(e=>So.minimize.trimChats(e))),Cc.listen.on("chatBoxInitialized",e),Cc.listen.on("chatRoomInitialized",e),Cc.listen.on("getHeadingButtons",((e,t)=>e.model.get("type")===So.CHATROOMS_TYPE?function(e,t){const n={a_class:"toggle-chatbox-button",handler:t=>__(t,e.model),i18n_text:Vu("Minimize"),i18n_title:Vu("Minimize this groupchat"),icon_class:"fa-minus",name:"minimize",standalone:"overlayed"===So.api.settings.get("view_mode")},s=t.map((e=>e.name)).indexOf("signout");return s>-1?[...t.slice(0,s),n,...t.slice(s)]:[n,...t]}(e,t):function(e,t){const n={a_class:"toggle-chatbox-button",handler:t=>__(t,e.model),i18n_text:Vu("Minimize"),i18n_title:Vu("Minimize this chat"),icon_class:"fa-minus",name:"minimize",standalone:"overlayed"===So.api.settings.get("view_mode")},s=t.map((e=>e.name)).indexOf("close");return s>-1?[...t.slice(0,s),n,...t.slice(s)]:[n,...t]}(e,t)));const t=Oo((()=>So.minimize.trimChats()),250);Cc.listen.on("registeredGlobalEventHandlers",(()=>window.addEventListener("resize",t))),Cc.listen.on("unregisteredGlobalEventHandlers",(()=>window.removeEventListener("resize",t)))}});const C_=Mc.env.utils,k_={getElement:(e,t)=>"string"==typeof e?(t||document).querySelector(e):e||null,bind(e,t){if(e)for(var n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const s=t[n];n.split(/\s+/).forEach((t=>e.addEventListener(t,s)))}},unbind(e,t){if(e)for(var n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const s=t[n];n.split(/\s+/).forEach((t=>e.removeEventListener(t,s)))}},regExpEscape:e=>e.replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&"),isMention:(e,t)=>t.includes(e[0])||C_.isMentionBoundary(e[0])&&t.includes(e[1])},O_=function(e,t){return RegExp(k_.regExpEscape(t.trim()),"i").test(e)},T_=function(e,t){return RegExp("^"+k_.regExpEscape(t.trim()),"i").test(e)},N_=function(e,t){const n=e.query.toLowerCase(),s=e.label.toLowerCase().indexOf(n),i=t.label.toLowerCase().indexOf(n);return s===i?function(e,t){return e.length!==t.length?e.length-t.length:e{t=t.trim();const n=document.createElement("li");n.setAttribute("aria-selected","false");const s=new RegExp("("+t+")","ig");return(t?e.split(s):[e]).forEach((e=>{if(t&&e.match(s)){const t=document.createElement("mark");t.textContent=e,n.appendChild(t)}else n.appendChild(document.createTextNode(e))})),n},M_=class extends String{constructor(e,t){super();const n=Array.isArray(e)?{label:e[0],value:e[1]}:"object"==typeof e&&"label"in e&&"value"in e?e:{label:e,value:e};this.label=n.label||n.value,this.value=n.value,this.query=t}get lenth(){return this.label.length}toString(){return""+this.label}valueOf(){return this.toString()}},R_=Mc.env.utils;class D_{constructor(e,t={}){this.suggestions=[],this.is_opened=!1,R_.hasClass("suggestion-box",e)?this.container=e:this.container=e.querySelector(".suggestion-box"),this.input=this.container.querySelector(".suggestion-box__input"),this.input.setAttribute("aria-autocomplete","list"),this.ul=this.container.querySelector(".suggestion-box__results"),this.status=this.container.querySelector(".suggestion-box__additions"),Object.assign(this,{match_current_word:!1,ac_triggers:[],include_triggers:[],min_chars:2,max_items:10,auto_evaluate:!0,auto_first:!1,data:e=>e,filter:O_,sort:!1!==t.sort&&N_,item:I_},t),this.index=-1,this.bindEvents(),this.input.hasAttribute("list")?(this.list="#"+this.input.getAttribute("list"),this.input.removeAttribute("list")):this.list=this.input.getAttribute("data-list")||t.list||[]}bindEvents(){const e={blur:()=>this.close({reason:"blur"})};this.auto_evaluate&&(e.input=()=>this.evaluate()),this._events={input:e,form:{submit:()=>this.close({reason:"submit"})},ul:{mousedown:e=>this.onMouseDown(e),mouseover:e=>this.onMouseOver(e)}},k_.bind(this.input,this._events.input),k_.bind(this.input.form,this._events.form),k_.bind(this.ul,this._events.ul)}set list(e){if(Array.isArray(e)||"function"==typeof e)this._list=e;else if("string"==typeof e&&e.includes(","))this._list=e.split(/\s*,\s*/);else{var t;const n=(null===(t=k_.getElement(e))||void 0===t?void 0:t.children)||[];this._list=Array.from(n).filter((e=>!e.disabled)).map((e=>{const t=e.textContent.trim(),n=e.value||t,s=e.label||t;return""!==n?{label:s,value:n}:null})).filter((e=>e))}document.activeElement===this.input&&this.evaluate()}get list(){return this._list}get selected(){return this.index>-1}get opened(){return this.is_opened}close(e){this.opened&&(this.ul.setAttribute("hidden",""),this.is_opened=!1,this.index=-1,this.trigger("suggestion-box-close",e||{}))}insertValue(e){this.match_current_word?R_.replaceCurrentWord(this.input,e.value):this.input.value=e.value}open(){this.ul.removeAttribute("hidden"),this.is_opened=!0,this.auto_first&&-1===this.index&&this.goto(0),this.trigger("suggestion-box-open")}destroy(){k_.unbind(this.input,this._events.input),k_.unbind(this.input.form,this._events.form),this.input.removeAttribute("aria-autocomplete")}next(){const e=this.ul.children.length;this.goto(this.index-1&&t.length>0&&(t[e].setAttribute("aria-selected","true"),t[e].focus(),this.status.textContent=t[e].textContent,this.ul.scrollTop=t[e].offsetTop-this.ul.clientHeight+t[e].clientHeight,this.trigger("suggestion-box-highlight",{text:this.suggestions[this.index]}))}select(e){if(e?this.index=R_.siblingIndex(e):e=this.ul.children[this.index],e){const e=this.suggestions[this.index];this.insertValue(e),this.close({reason:"select"}),this.auto_completing=!1,this.trigger("suggestion-box-selectcomplete",{text:e})}}onMouseOver(e){const t=R_.ancestor(e.target,"li");t&&this.goto(Array.prototype.slice.call(this.ul.children).indexOf(t))}onMouseDown(e){if(0!==e.button)return;const t=R_.ancestor(e.target,"li");t&&(e.preventDefault(),this.select(t,e.target))}onKeyDown(e){if(this.opened){if([Mc.keycodes.ENTER,Mc.keycodes.TAB].includes(e.keyCode)&&this.selected)return e.preventDefault(),e.stopPropagation(),this.select(),!0;if(e.keyCode===Mc.keycodes.ESCAPE)return this.close({reason:"esc"}),!0;if([Mc.keycodes.UP_ARROW,Mc.keycodes.DOWN_ARROW].includes(e.keyCode))return e.preventDefault(),e.stopPropagation(),this[e.keyCode===Mc.keycodes.UP_ARROW?"previous":"next"](),!0}if(![Mc.keycodes.SHIFT,Mc.keycodes.META,Mc.keycodes.META_RIGHT,Mc.keycodes.ESCAPE,Mc.keycodes.ALT].includes(e.keyCode))if(this.ac_triggers.includes(e.key))"Tab"===e.key&&e.preventDefault(),this.auto_completing=!0;else if("Backspace"===e.key){const t=R_.getCurrentWord(e.target,e.target.selectionEnd-1);k_.isMention(t,this.ac_triggers)&&(this.auto_completing=!0)}}async evaluate(e){const t=this.selected&&e&&(e.keyCode===Mc.keycodes.UP_ARROW||e.keyCode===Mc.keycodes.DOWN_ARROW);if(!this.auto_evaluate&&!this.auto_completing||t)return;const n="function"==typeof this._list?await this._list():this._list;if(0===n.length)return;let s=this.match_current_word?R_.getCurrentWord(this.input):this.input.value;const i=k_.isMention(s,this.ac_triggers);i&&(this.auto_completing=!0,this.include_triggers.includes(e.key)||(s=R_.isMentionBoundary(s[0])?s.slice("2"):s.slice("1"))),(i||s.length)&&s.length>=this.min_chars?(this.index=-1,this.ul.innerHTML="",this.suggestions=n.map((e=>new M_(this.data(e,s),s))).filter((e=>this.filter(e,s))),!1!==this.sort&&(this.suggestions=this.suggestions.sort(this.sort)),this.suggestions=this.suggestions.slice(0,this.max_items),this.suggestions.forEach((e=>this.ul.appendChild(this.item(e,s)))),0===this.ul.children.length?this.close({reason:"nomatches"}):this.open()):(this.close({reason:"nomatches"}),i||(this.auto_completing=!1))}}Object.assign(D_.prototype,Hi);const z_=D_;function L_(){const e=(t=['\n
    \n \n \n \n
    \n '],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return L_=function(){return e},e}function P_(){const e=B_(['"]);return P_=function(){return e},e}function F_(){const e=B_(["\n
    \n ",'\n
    \n \n \n\n

    ',"

    \n ",'\n
    \n
    \n \n \n
    \n ',"\n
    \n ","\n \n"],n||(n=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(n)}})));var t,n;return U_=function(){return e},e}Cc.elements.define("converse-autocomplete",class extends af{static get properties(){return{getAutoCompleteList:{type:Function},auto_evaluate:{type:Boolean},auto_first:{type:Boolean},filter:{type:String},include_triggers:{type:String},min_chars:{type:Number},name:{type:String},placeholder:{type:String},triggers:{type:String}}}constructor(){super(),this.auto_evaluate=!0,this.auto_first=!1,this.filter="contains",this.include_triggers="",this.match_current_word=!1,this.max_items=10,this.min_chars=1,this.triggers=""}render(){return Ha(L_(),this.name,this.onKeyDown,this.onKeyUp,this.placeholder)}firstUpdated(){this.auto_complete=new z_(this.firstElementChild,{ac_triggers:this.triggers.split(" "),auto_evaluate:this.auto_evaluate,auto_first:this.auto_first,filter:"contains"==this.filter?O_:T_,include_triggers:[],list:()=>this.getAutoCompleteList(),match_current_word:!0,max_items:this.max_items,min_chars:this.min_chars}),this.auto_complete.on("suggestion-box-selectcomplete",(()=>this.auto_completing=!1))}onKeyDown(e){this.auto_complete.onKeyDown(e)}onKeyUp(e){this.auto_complete.evaluate(e)}}),n(6657),So.FILTER_CONTAINS=O_,So.FILTER_STARTSWITH=T_,So.AutoComplete=z_;function q_(){const e=lw(['
  • ',"
  • "]);return q_=function(){return e},e}function H_(){const e=lw(['
  • ',"
  • "]);return H_=function(){return e},e}function $_(){const e=lw(['

    ',"

    "]);return $_=function(){return e},e}function G_(){const e=lw(['']);return G_=function(){return e},e}function V_(){const e=lw(['
  • ',"
  • "]);return V_=function(){return e},e}function W_(){const e=lw(['
  • ',"
  • "]);return W_=function(){return e},e}function J_(){const e=lw(['
  • ',"
  • "]);return J_=function(){return e},e}function Q_(){const e=lw(['

    ',"

    "]);return Q_=function(){return e},e}function Y_(){const e=lw(['']);return Y_=function(){return e},e}function K_(){const e=lw(['\n "]);return K_=function(){return e},e}function X_(){const e=lw(['\n