1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/converse_ynh.git synced 2024-09-03 18:25:53 +02:00
converse_ynh/sources/dist/converse.min.js

2168 lines
1 MiB
JavaScript
Raw Normal View History

2021-07-03 16:04:46 +02:00
!function(e){function t(t){for(var n,i,s=t[0],o=t[1],a=0,l=[];a<s.length;a++)i=s[a],Object.prototype.hasOwnProperty.call(r,i)&&r[i]&&l.push(r[i][0]),r[i]=0;for(n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n]);for(c&&c(t);l.length;)l.shift()()}var n={},r={178:0};function i(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.e=function(e){var t=[],n=r[e];if(0!==n)if(n)t.push(n[2]);else{var s=new Promise((function(t,i){n=r[e]=[t,i]}));t.push(n[2]=s);var o,a=document.createElement("script");a.charset="utf-8",a.timeout=120,i.nc&&a.setAttribute("nonce",i.nc),a.src=function(e){return i.p+""+({0:"locales/dayjs/af",1:"locales/dayjs/ar",2:"locales/dayjs/ar-dz",3:"locales/dayjs/ar-kw",4:"locales/dayjs/ar-ly",5:"locales/dayjs/ar-ma",6:"locales/dayjs/ar-sa",7:"locales/dayjs/ar-tn",8:"locales/dayjs/az",9:"locales/dayjs/be",10:"locales/dayjs/bg",11:"locales/dayjs/bi",12:"locales/dayjs/bm",13:"locales/dayjs/bn",14:"locales/dayjs/bo",15:"locales/dayjs/br",16:"locales/dayjs/bs",17:"locales/dayjs/ca",18:"locales/dayjs/cs",19:"locales/dayjs/cv",20:"locales/dayjs/cy",21:"locales/dayjs/da",22:"locales/dayjs/de",23:"locales/dayjs/de-at",24:"locales/dayjs/de-ch",25:"locales/dayjs/dv",26:"locales/dayjs/el",27:"locales/dayjs/en",28:"locales/dayjs/en-SG",29:"locales/dayjs/en-au",30:"locales/dayjs/en-ca",31:"locales/dayjs/en-gb",32:"locales/dayjs/en-ie",33:"locales/dayjs/en-il",34:"locales/dayjs/en-in",35:"locales/dayjs/en-nz",36:"locales/dayjs/en-tt",37:"locales/dayjs/eo",38:"locales/dayjs/es",39:"locales/dayjs/es-do",40:"locales/dayjs/es-pr",41:"locales/dayjs/es-us",42:"locales/dayjs/et",43:"locales/dayjs/eu",44:"locales/dayjs/fa",45:"locales/dayjs/fi",46:"locales/dayjs/fo",47:"locales/dayjs/fr",48:"locales/dayjs/fr-ca",49:"locales/dayjs/fr-ch",50:"locales/dayjs/fy",51:"locales/dayjs/ga",52:"locales/dayjs/gd",53:"locales/dayjs/gl",54:"locales/dayjs/gom-latn",55:"locales/dayjs/gu",56:"locales/dayjs/he",57:"locales/dayjs/hi",58:"locales/dayjs/hr",59:"locales/dayjs/ht",60:"locales/dayjs/hu",61:"locales/dayjs/hy-am",62:"locales/dayjs/id",63:"locales/dayjs/is",64:"locales/dayjs/it",65:"locales/dayjs/it-ch",66:"locales/dayjs/ja",67:"locales/dayjs/jv",68:"locales/dayjs/ka",69:"locales/dayjs/kk",70:"locales/dayjs/km",71:"locales/dayjs/kn",72:"locales/dayjs/ko",73:"locales/dayjs/ku",74:"locales/dayjs/ky",75:"locales/dayjs/lb",76:"locales/dayjs/lo",77:"locales/dayjs/lt",78:"locales/dayjs/lv",79:"locales/dayjs/me",80:"locales/dayjs/mi",81:"locales/dayjs/mk",82:"locales/dayjs/ml",83:"locales/dayjs/mn",84:"locales/dayjs/mr",85:"locales/dayjs/ms",86:"locales/dayjs/ms-my",87:"locales/dayjs/mt",88:"locales/dayjs/my",89:"locales/dayjs/nb",90:"locales/dayjs/ne",91:"locales/dayjs/nl",92:"locales/dayjs/nl-be",93:"locales/dayjs/nn",94:"locales/dayjs/oc-lnc",95:"locales/dayjs/pa-in",96:"locales/dayjs/pl",97:"locales/dayjs/pt",98:"locales/dayjs/pt-br",99:"locales/dayjs/ro",100:"locales/dayjs/ru",101:"locales/dayjs/rw",102:"locales/dayjs/sd",103:"locales/dayjs/se",104:"locales/dayjs/si",105:"locales/dayjs/sk",106:"locales/dayjs/sl",107:"locales/dayjs/sq",108:"locales/dayjs/sr",109:"locales/dayjs/sr-cyrl",110:"locales/dayjs/ss",111:"locales/dayjs/sv",112:"locales/dayjs/sw",113:"locales/dayjs/ta",114:"locales/dayjs/te",115:"locales/dayjs/tet",116:"locales/dayjs/tg",117:"locales/dayjs/th",118:"locales/dayjs/tk",119:"locales/dayjs/tl-ph",120:"locales/dayjs/tlh",121:"locales/dayjs/tr",122:"locales/dayjs/tzl",123:"locales/dayjs/tzm",124:"locales/dayjs/tzm-latn",125:"locales/dayjs/ug-cn",126:"locales/dayjs/uk",127:"locales/dayjs/ur",128:"locales/dayjs/uz",129:"locales/dayjs/uz-latn",130:"locales/dayjs/vi",131:"locales/dayjs/x-pseudo",132:"locales/dayjs/yo",133:"locales/dayjs/zh",134:"locales/dayjs/zh-cn",135:"locales/dayjs/zh-hk",136:"locales/dayjs/zh-tw",137:"emojis",138:"icons",139:"locales/af-LC_MESSAGES-converse-po",140:"locales/ar-LC_MESSAGES-converse-po",141:"locales/bg-LC_MESSAGES-converse-po",142:"locales/ca-LC_MESSAGES-converse-po",143:"locales/cs-LC_MESSAGES-converse-po",144:"local
2021-01-29 23:34:36 +01:00
/*!
2021-03-19 19:26:15 +01:00
* Sizzle CSS Selector Engine v2.3.6
2021-01-29 23:34:36 +01:00
* https://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Released under the MIT license
* https://js.foundation/
*
2021-03-19 19:26:15 +01:00
* Date: 2021-02-16
2021-07-03 16:04:46 +02:00
*/!function(i){var s,o,a,c,l,u,d,h,f,p,g,m,v,_,b,y,w,S,x,E="sizzle"+1*new Date,A=i.document,C=0,k=0,j=he(),T=he(),O=he(),N=he(),I=function(e,t){return e===t&&(g=!0),0},M={}.hasOwnProperty,R=[],$=R.pop,D=R.push,P=R.push,L=R.slice,z=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},F="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",B="[\\x20\\t\\r\\n\\f]",q="(?:\\\\[\\da-fA-F]{1,6}"+B+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",U="\\["+B+"*("+q+")(?:"+B+"*([*^$|!~]?=)"+B+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+q+"))|)"+B+"*\\]",H=":("+q+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+U+")*)|.*)\\)|)",V=new RegExp(B+"+","g"),W=new RegExp("^"+B+"+|((?:^|[^\\\\])(?:\\\\.)*)"+B+"+$","g"),G=new RegExp("^"+B+"*,"+B+"*"),J=new RegExp("^"+B+"*([>+~]|"+B+")"+B+"*"),Q=new RegExp(B+"|>"),Y=new RegExp(H),K=new RegExp("^"+q+"$"),X={ID:new RegExp("^#("+q+")"),CLASS:new RegExp("^\\.("+q+")"),TAG:new RegExp("^("+q+"|[*])"),ATTR:new RegExp("^"+U),PSEUDO:new RegExp("^"+H),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+B+"*(even|odd|(([+-]|)(\\d*)n|)"+B+"*(?:([+-]|)"+B+"*(\\d+)|))"+B+"*\\)|)","i"),bool:new RegExp("^(?:"+F+")$","i"),needsContext:new RegExp("^"+B+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+B+"*((?:-\\d)?\\d*)"+B+"*\\)|)(?=[^-]|$)","i")},Z=/HTML$/i,ee=/^(?:input|select|textarea|button)$/i,te=/^h\d$/i,ne=/^[^{]+\{\s*\[native \w/,re=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ie=/[+~]/,se=new RegExp("\\\\[\\da-fA-F]{1,6}"+B+"?|\\\\([^\\r\\n\\f])","g"),oe=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},ae=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ce=function(e,t){return t?"\0"===e?"<EFBFBD>":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},le=function(){m()},ue=Ee((function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()}),{dir:"parentNode",next:"legend"});try{P.apply(R=L.call(A.childNodes),A.childNodes),R[A.childNodes.length].nodeType}catch(e){P={apply:R.length?function(e,t){D.apply(e,L.call(t))}:function(e,t){for(var n=e.length,r=0;e[n++]=t[r++];);e.length=n-1}}}function de(e,t,n,r){var i,s,a,c,l,d,f,p=t&&t.ownerDocument,g=t?t.nodeType:9;if(n=n||[],"string"!=typeof e||!e||1!==g&&9!==g&&11!==g)return n;if(!r&&(m(t),t=t||v,b)){if(11!==g&&(l=re.exec(e)))if(i=l[1]){if(9===g){if(!(a=t.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(p&&(a=p.getElementById(i))&&x(t,a)&&a.id===i)return n.push(a),n}else{if(l[2])return P.apply(n,t.getElementsByTagName(e)),n;if((i=l[3])&&o.getElementsByClassName&&t.getElementsByClassName)return P.apply(n,t.getElementsByClassName(i)),n}if(o.qsa&&!N[e+" "]&&(!y||!y.test(e))&&(1!==g||"object"!==t.nodeName.toLowerCase())){if(f=e,p=t,1===g&&(Q.test(e)||J.test(e))){for((p=ie.test(e)&&we(t.parentNode)||t)===t&&o.scope||((c=t.getAttribute("id"))?c=c.replace(ae,ce):t.setAttribute("id",c=E)),s=(d=u(e)).length;s--;)d[s]=(c?"#"+c:":scope")+" "+xe(d[s]);f=d.join(",")}try{return P.apply(n,p.querySelectorAll(f)),n}catch(t){N(e,!0)}finally{c===E&&t.removeAttribute("id")}}}return h(e.replace(W,"$1"),t,n,r)}function he(){var e=[];return function t(n,r){return e.push(n+" ")>a.cacheLength&&delete t[e.shift()],t[n+" "]=r}}function fe(e){return e[E]=!0,e}function pe(e){var t=v.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function ge(e,t){for(var n=e.split("|"),r=n.length;r--;)a.attrHandle[n[r]]=t}function me(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function ve(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}function _e(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function be(e){return function(t){return"form"in t?t.parentNode&&!1===t.d
2021-01-29 23:34:36 +01:00
/*!
* URI.js - Mutating URLs
*
2021-03-19 19:26:15 +01:00
* Version: 1.19.6
2021-01-29 23:34:36 +01:00
*
* Author: Rodney Rehm
* Web: http://medialize.github.io/URI.js/
*
* Licensed under
* MIT License http://www.opensource.org/licenses/mit-license
*
2021-03-19 19:26:15 +01:00
*/!function(o,a){"use strict";e.exports?e.exports=a(n(153),n(154),n(155)):(i=[n(153),n(154),n(155)],void 0===(s="function"==typeof(r=a)?r.apply(t,i):r)||(e.exports=s))}(0,(function(e,t,n,r){"use strict";var i=r&&r.URI;function s(e,t){var n=arguments.length>=1,r=arguments.length>=2;if(!(this instanceof s))return n?r?new s(e,t):new s(e):new s;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}s.version="1.19.6";var o=s.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,r,i={};if("RegExp"===l(t))i=null;else if(u(t))for(n=0,r=t.length;n<r;n++)i[t[n]]=!0;else i[t]=!0;for(n=0,r=e.length;n<r;n++){(i&&void 0!==i[e[n]]||!i&&t.test(e[n]))&&(e.splice(n,1),r--,n--)}return e}function h(e,t){var n,r;if(u(t)){for(n=0,r=t.length;n<r;n++)if(!h(e,t[n]))return!1;return!0}var i=l(t);for(n=0,r=e.length;n<r;n++)if("RegExp"===i){if("string"==typeof e[n]&&e[n].match(t))return!0}else if(e[n]===t)return!0;return!1}function f(e,t){if(!u(e)||!u(t))return!1;if(e.length!==t.length)return!1;e.sort(),t.sort();for(var n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}function p(e){return e.replace(/^\/+|\/+$/g,"")}function g(e){return escape(e)}function m(e){return encodeURIComponent(e).replace(/[!'()*]/g,g).replace(/\*/g,"%2A")}s._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,preventInvalidHostname:s.preventInvalidHostname,duplicateQueryParameters:s.duplicateQueryParameters,escapeQuerySpace:s.escapeQuerySpace}},s.preventInvalidHostname=!1,s.duplicateQueryParameters=!1,s.escapeQuerySpace=!0,s.protocol_expression=/^[a-z][a-z0-9.+-]*$/i,s.idn_expression=/[^a-z0-9\._-]/i,s.punycode_expression=/(xn--)/i,s.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,s.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,s.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi,s.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?«»“”„‘’]+$/,parens:/(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g},s.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},s.hostProtocols=["http","https"],s.invalid_hostname_characters=/[^a-zA-Z0-9\.\-:_]/,s.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"},s.getDomAttribute=function(e){if(e&&e
2021-01-29 23:34:36 +01:00
/**
* @license
* Lodash <https://lodash.com/>
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
2021-07-03 16:04:46 +02:00
*/(function(){var s="Expected a function",o="__lodash_placeholder__",a=[["ary",128],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",32],["partialRight",64],["rearg",256]],c="[object Arguments]",l="[object Array]",u="[object Boolean]",d="[object Date]",h="[object Error]",f="[object Function]",p="[object GeneratorFunction]",g="[object Map]",m="[object Number]",v="[object Object]",_="[object RegExp]",b="[object Set]",y="[object String]",w="[object Symbol]",S="[object WeakMap]",x="[object ArrayBuffer]",E="[object DataView]",A="[object Float32Array]",C="[object Float64Array]",k="[object Int8Array]",j="[object Int16Array]",T="[object Int32Array]",O="[object Uint8Array]",N="[object Uint16Array]",I="[object Uint32Array]",M=/\b__p \+= '';/g,R=/\b(__p \+=) '' \+/g,$=/(__e\(.*?\)|\b__t\)) \+\n'';/g,D=/&(?:amp|lt|gt|quot|#39);/g,P=/[&<>"']/g,L=RegExp(D.source),z=RegExp(P.source),F=/<%-([\s\S]+?)%>/g,B=/<%([\s\S]+?)%>/g,q=/<%=([\s\S]+?)%>/g,U=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,H=/^\w*$/,V=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,W=/[\\^$.*+?()[\]{}|]/g,G=RegExp(W.source),J=/^\s+/,Q=/\s/,Y=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,K=/\{\n\/\* \[wrapped with (.+)\] \*/,X=/,? & /,Z=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ee=/[()=,{}\[\]\/\s]/,te=/\\(\\)?/g,ne=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,re=/\w*$/,ie=/^[-+]0x[0-9a-f]+$/i,se=/^0b[01]+$/i,oe=/^\[object .+?Constructor\]$/,ae=/^0o[0-7]+$/i,ce=/^(?:0|[1-9]\d*)$/,le=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ue=/($^)/,de=/['\n\r\u2028\u2029\\]/g,he="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",fe="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",pe="[\\ud800-\\udfff]",ge="["+fe+"]",me="["+he+"]",ve="\\d+",_e="[\\u2700-\\u27bf]",be="[a-z\\xdf-\\xf6\\xf8-\\xff]",ye="[^\\ud800-\\udfff"+fe+ve+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",we="\\ud83c[\\udffb-\\udfff]",Se="[^\\ud800-\\udfff]",xe="(?:\\ud83c[\\udde6-\\uddff]){2}",Ee="[\\ud800-\\udbff][\\udc00-\\udfff]",Ae="[A-Z\\xc0-\\xd6\\xd8-\\xde]",Ce="(?:"+be+"|"+ye+")",ke="(?:"+Ae+"|"+ye+")",je="(?:"+me+"|"+we+")"+"?",Te="[\\ufe0e\\ufe0f]?"+je+("(?:\\u200d(?:"+[Se,xe,Ee].join("|")+")[\\ufe0e\\ufe0f]?"+je+")*"),Oe="(?:"+[_e,xe,Ee].join("|")+")"+Te,Ne="(?:"+[Se+me+"?",me,xe,Ee,pe].join("|")+")",Ie=RegExp("[']","g"),Me=RegExp(me,"g"),Re=RegExp(we+"(?="+we+")|"+Ne+Te,"g"),$e=RegExp([Ae+"?"+be+"+(?:['](?:d|ll|m|re|s|t|ve))?(?="+[ge,Ae,"$"].join("|")+")",ke+"+(?:['](?:D|LL|M|RE|S|T|VE))?(?="+[ge,Ae+Ce,"$"].join("|")+")",Ae+"?"+Ce+"+(?:['](?:d|ll|m|re|s|t|ve))?",Ae+"+(?:['](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ve,Oe].join("|"),"g"),De=RegExp("[\\u200d\\ud800-\\udfff"+he+"\\ufe0e\\ufe0f]"),Pe=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Le=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ze=-1,Fe={};Fe[A]=Fe[C]=Fe[k]=Fe[j]=Fe[T]=Fe[O]=Fe["[object Uint8ClampedArray]"]=Fe[N]=Fe[I]=!0,Fe[c]=Fe[l]=Fe[x]=Fe[u]=Fe[E]=Fe[d]=Fe[h]=Fe[f]=Fe[g]=Fe[m]=Fe[v]=Fe[_]=Fe[b]=Fe[y]=Fe[S]=!1;var Be={};Be[c]=Be[l]=Be[x]=Be[E]=Be[u]=Be[d]=Be[A]=Be[C]=Be[k]=Be[j]=Be[T]=Be[g]=Be[m]=Be[v]=Be[_]=Be[b]=Be[y]=Be[w]=Be[O]=Be["[object Uint8ClampedArray]"]=Be[N]=Be[I]=!0,Be[h]=Be[f]=Be[S]=!1;var qe={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ue=parseFloat,He=parseInt,Ve="object"==typeof e&&e&&e.Object===Object&&e,We="object"==typeof self&&self&&self.Object===Object&&self,Ge=Ve||We||Function("return this")(),Je=t&&!t.nodeType&&t,Qe
/*!
2020 Jason Mulligan <jason.mulligan@avoidwork.com>
@version 6.3.0
*/
e.exports=function(){"use strict";var e=/^(b|B)$/,t={iec:{bits:["b","Kib","Mib","Gib","Tib","Pib","Eib","Zib","Yib"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["b","Kb","Mb","Gb","Tb","Pb","Eb","Zb","Yb"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},n={iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]},r={floor:Math.floor,ceil:Math.ceil};function i(i){var s,o,a,c,l,u,d,h,f,p,g,m,v,_,b,y,w,S,x,E,A=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},C=[],k=0;if(isNaN(i))throw new TypeError("Invalid number");if(a=!0===A.bits,b=!0===A.unix,m=!0===A.pad,o=A.base||2,v=void 0!==A.round?A.round:b?1:2,d=void 0!==A.locale?A.locale:"",h=A.localeOptions||{},y=void 0!==A.separator?A.separator:"",w=void 0!==A.spacer?A.spacer:b?"":" ",x=A.symbols||{},S=2===o&&A.standard||"jedec",g=A.output||"string",l=!0===A.fullform,u=A.fullforms instanceof Array?A.fullforms:[],s=void 0!==A.exponent?A.exponent:-1,E=r[A.roundingMethod]||Math.round,c=o>2?1e3:1024,(f=(p=Number(i))<0)&&(p=-p),(-1===s||isNaN(s))&&(s=Math.floor(Math.log(p)/Math.log(c)))<0&&(s=0),s>8&&(s=8),"exponent"===g)return s;if(0===p)C[0]=0,_=C[1]=b?"":t[S][a?"bits":"bytes"][s];else{k=p/(2===o?Math.pow(2,10*s):Math.pow(1e3,s)),a&&(k*=8)>=c&&s<8&&(k/=c,s++);var j=Math.pow(10,s>0?v:0);C[0]=E(k*j)/j,C[0]===c&&s<8&&void 0===A.exponent&&(C[0]=1,s++),_=C[1]=10===o&&1===s?a?"kb":"kB":t[S][a?"bits":"bytes"][s],b&&(C[1]="jedec"===S?C[1].charAt(0):s>0?C[1].replace(/B$/,""):C[1],e.test(C[1])&&(C[0]=Math.floor(C[0]),C[1]=""))}if(f&&(C[0]=-C[0]),C[1]=x[C[1]]||C[1],!0===d?C[0]=C[0].toLocaleString():d.length>0?C[0]=C[0].toLocaleString(d,h):y.length>0&&(C[0]=C[0].toString().replace(".",y)),m&&!1===Number.isInteger(C[0])&&v>0){var T=y||".",O=C[0].toString().split(T),N=O[1]||"",I=N.length,M=v-I;C[0]="".concat(O[0]).concat(T).concat(N.padEnd(I+M,"0"))}return l&&(C[1]=u[s]?u[s]:n[S][s]+(a?"bit":"byte")+(1===C[0]?"":"s")),"array"===g?C:"object"===g?{value:C[0],symbol:C[1],exponent:s,unit:_}:C.join(w)}return i.partial=function(e){return function(t){return i(t,e)}},i}()},function(e,t,n){var r={escape:n(7)};e.exports=function(e){var t="",n=r.escape;Array.prototype.join;return t+='\x3c!-- src/templates/form_input.html --\x3e\n<div class="form-group">\n ',"hidden"!==e.type&&(t+='\n <label for="'+n(e.id)+'">'+n(e.label)+"</label>\n "),t+="\n ","password"===e.type&&e.fixed_username&&(t+='\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 <input class="hidden-username" type="text" autocomplete="username" value="'+n(e.fixed_username)+'"></input>\n '),t+='\n <input \n class="form-control" name="'+n(e.name)+'" type="'+n(e.type)+'" id="'+n(e.id)+'"\n ',e.autocomplete&&(t+=' autocomplete="'+n(e.autocomplete)+'" '),t+="\n ",e.placeholder&&(t+=' placeholder="'+n(e.placeholder)+'" '),t+="\n ",e.value&&(t+=' value="'+n(e.value)+'" '),t+="\n ",e.required&&(t+=' required="required" '),t+=" />\n</div>\n"}},function(e,t,n){var r={escape:n(7)};e.exports=function(e){var t="",n=r.escape;Array.prototype.join;return t+='\x3c!-- src/templates/form_username.html --\x3e\n<div class="form-group">\n ',e.label&&(t+="\n <label>\n "+n(e.label)+"\n </label>\n "),t+='\n <div class="input-group">\n <div class="input-group-prepend">\n <input name="'+n(e.name)+'" type="'+n(e.type)+'"\n ',e.value&&(t+=' value="'+n(e.value)+'" '),t+="\n ",e.required&&(t+=' required="required" '),t+=' />\n <div class="input-group-text col" title="'+n(e.domain)+'">'+n(e.domain)+"</div>\n </div>\n </div>\n</div>\n"}},function(e,t,n){var r,i;r=[n(39)],void 0===(i=function(e){return e.noConflict()}.apply(t,r))||(e.exports=i)},function(e,t,n){
2021-01-29 23:34:36 +01:00
/**
* @preserve jed.js https://github.com/SlexAxton/Jed
*/
2021-07-03 16:04:46 +02:00
!function(n,r){var i=Array.prototype,s=Object.prototype,o=i.slice,a=s.hasOwnProperty,c=i.forEach,l={},u={forEach:function(e,t,n){var r,i,s;if(null!==e)if(c&&e.forEach===c)e.forEach(t,n);else if(e.length===+e.length){for(r=0,i=e.length;r<i;r++)if(r in e&&t.call(n,e[r],r,e)===l)return}else for(s in e)if(a.call(e,s)&&t.call(n,e[s],s,e)===l)return},extend:function(e){return this.forEach(o.call(arguments,1),(function(t){for(var n in t)e[n]=t[n]})),e}},d=function(e){if(this.defaults={locale_data:{messages:{"":{domain:"messages",lang:"en",plural_forms:"nplurals=2; plural=(n != 1);"}}},domain:"messages",debug:!1},this.options=u.extend({},this.defaults,e),this.textdomain(this.options.domain),e.domain&&!this.options.locale_data[this.options.domain])throw new Error("Text domain set to non-existent domain: `"+e.domain+"`")};function h(e){return d.PF.compile(e||"nplurals=2; plural=(n != 1);")}function f(e,t){this._key=e,this._i18n=t}d.context_delimiter=String.fromCharCode(4),u.extend(f.prototype,{onDomain:function(e){return this._domain=e,this},withContext:function(e){return this._context=e,this},ifPlural:function(e,t){return this._val=e,this._pkey=t,this},fetch:function(e){return"[object Array]"!={}.toString.call(e)&&(e=[].slice.call(arguments,0)),(e&&e.length?d.sprintf:function(e){return e})(this._i18n.dcnpgettext(this._domain,this._context,this._key,this._pkey,this._val),e)}}),u.extend(d.prototype,{translate:function(e){return new f(e,this)},textdomain:function(e){if(!e)return this._textdomain;this._textdomain=e},gettext:function(e){return this.dcnpgettext.call(this,void 0,void 0,e)},dgettext:function(e,t){return this.dcnpgettext.call(this,e,void 0,t)},dcgettext:function(e,t){return this.dcnpgettext.call(this,e,void 0,t)},ngettext:function(e,t,n){return this.dcnpgettext.call(this,void 0,void 0,e,t,n)},dngettext:function(e,t,n,r){return this.dcnpgettext.call(this,e,void 0,t,n,r)},dcngettext:function(e,t,n,r){return this.dcnpgettext.call(this,e,void 0,t,n,r)},pgettext:function(e,t){return this.dcnpgettext.call(this,void 0,e,t)},dpgettext:function(e,t,n){return this.dcnpgettext.call(this,e,t,n)},dcpgettext:function(e,t,n){return this.dcnpgettext.call(this,e,t,n)},npgettext:function(e,t,n,r){return this.dcnpgettext.call(this,void 0,e,t,n,r)},dnpgettext:function(e,t,n,r,i){return this.dcnpgettext.call(this,e,t,n,r,i)},dcnpgettext:function(e,t,n,r,i){var s;if(r=r||n,e=e||this._textdomain,!this.options)return(s=new d).dcnpgettext.call(s,void 0,void 0,n,r,i);if(!this.options.locale_data)throw new Error("No locale data provided.");if(!this.options.locale_data[e])throw new Error("Domain `"+e+"` was not found.");if(!this.options.locale_data[e][""])throw new Error("No locale meta information provided.");if(!n)throw new Error("No translation key found.");var o,a,c,l=t?t+d.context_delimiter+n:n,u=this.options.locale_data,f=u[e],p=(u.messages||this.defaults.locale_data.messages)[""],g=f[""].plural_forms||f[""]["Plural-Forms"]||f[""]["plural-forms"]||p.plural_forms||p["Plural-Forms"]||p["plural-forms"];if(void 0===i)c=0;else{if("number"!=typeof i&&(i=parseInt(i,10),isNaN(i)))throw new Error("The number that was passed in is not a number.");c=h(g)(i)}if(!f)throw new Error("No domain named `"+e+"` could be found.");return!(o=f[l])||c>o.length?(this.options.missing_key_callback&&this.options.missing_key_callback(l,e),a=[n,r],!0===this.options.debug&&console.log(a[h(g)(i)]),a[h()(i)]):(a=o[c])||(a=[n,r])[h()(i)]}});var p,g,m=function(){function e(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function t(e,t){for(var n=[];t>0;n[--t]=e);return n.join("")}var n=function(){return n.cache.hasOwnProperty(arguments[0])||(n.cache[arguments[0]]=n.parse(arguments[0])),n.format.call(null,n.cache[arguments[0]],arguments)};return n.format=function(n,r){var i,s,o,a,c,l,u,d=1,h=n.length,f="",p=[];for(s=0;s<h;s++)if("string"===(f=e(n[s])))p.push(n[s]);else if("array"===f){if((a=n[s])[2])for(i=r[d],o=0;o<a[2].length;o++){if(!i.hasOwnProperty(a[2][o]))throw m('[sprintf] property "%s" does not exist',a[2][o]);i=i[a[2][o]]}else i=a[1]?r[a[1]]:r[d
2021-01-29 23:34:36 +01:00
/*!
* URI.js - Mutating URLs
* IPv6 Support
*
2021-03-19 19:26:15 +01:00
* Version: 1.19.6
2021-01-29 23:34:36 +01:00
*
* Author: Rodney Rehm
* Web: http://medialize.github.io/URI.js/
*
* Licensed under
* MIT License http://www.opensource.org/licenses/mit-license
*
2021-03-19 19:26:15 +01:00
*/!function(s,o){"use strict";e.exports?e.exports=o():void 0===(i="function"==typeof(r=o)?r.call(t,n,t,e):r)||(e.exports=i)}(0,(function(e){"use strict";var t=e&&e.IPv6;return{best:function(e){var t,n,r=e.toLowerCase().split(":"),i=r.length,s=8;for(""===r[0]&&""===r[1]&&""===r[2]?(r.shift(),r.shift()):""===r[0]&&""===r[1]?r.shift():""===r[i-1]&&""===r[i-2]&&r.pop(),-1!==r[(i=r.length)-1].indexOf(".")&&(s=7),t=0;t<i&&""!==r[t];t++);if(t<s)for(r.splice(t,1,"0000");r.length<s;)r.splice(t,0,"0000");for(var o=0;o<s;o++){n=r[o].split("");for(var a=0;a<3&&("0"===n[0]&&n.length>1);a++)n.splice(0,1);r[o]=n.join("")}var c=-1,l=0,u=0,d=-1,h=!1;for(o=0;o<s;o++)h?"0"===r[o]?u+=1:(h=!1,u>l&&(c=d,l=u)):"0"===r[o]&&(h=!0,d=o,u=1);u>l&&(c=d,l=u),l>1&&r.splice(c,l,""),i=r.length;var f="";for(""===r[0]&&(f=":"),o=0;o<i&&(f+=r[o],o!==i-1);o++)f+=":";return""===r[i-1]&&(f+=":"),f},noConflict:function(){return e.IPv6===this&&(e.IPv6=t),this}}}))},function(e,t,n){var r,i;
2021-01-29 23:34:36 +01:00
/*!
* URI.js - Mutating URLs
* Second Level Domain (SLD) Support
*
2021-03-19 19:26:15 +01:00
* Version: 1.19.6
2021-01-29 23:34:36 +01:00
*
* Author: Rodney Rehm
* Web: http://medialize.github.io/URI.js/
*
* Licensed under
* MIT License http://www.opensource.org/licenses/mit-license
*
2021-03-19 19:26:15 +01:00
*/!function(s,o){"use strict";e.exports?e.exports=o():void 0===(i="function"==typeof(r=o)?r.call(t,n,t,e):r)||(e.exports=i)}(0,(function(e){"use strict";var t=e&&e.SecondLevelDomains,n={list:{ac:" com gov mil net org ",ae:" ac co gov mil name net org pro sch ",af:" com edu gov net org ",al:" com edu gov mil net org ",ao:" co ed gv it og pb ",ar:" com edu gob gov int mil net org tur ",at:" ac co gv or ",au:" asn com csiro edu gov id net org ",ba:" co com edu gov mil net org rs unbi unmo unsa untz unze ",bb:" biz co com edu gov info net org store tv ",bh:" biz cc com edu gov info net org ",bn:" com edu gov net org ",bo:" com edu gob gov int mil net org tv ",br:" adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ",bs:" com edu gov net org ",bz:" du et om ov rg ",ca:" ab bc mb nb nf nl ns nt nu on pe qc sk yk ",ck:" biz co edu gen gov info net org ",cn:" ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ",co:" com edu gov mil net nom org ",cr:" ac c co ed fi go or sa ",cy:" ac biz com ekloges gov ltd name net org parliament press pro tm ",do:" art com edu gob gov mil net org sld web ",dz:" art asso com edu gov net org pol ",ec:" com edu fin gov info med mil net org pro ",eg:" com edu eun gov mil name net org sci ",er:" com edu gov ind mil net org rochest w ",es:" com edu gob nom org ",et:" biz com edu gov info name net org ",fj:" ac biz com info mil name net org pro ",fk:" ac co gov net nom org ",fr:" asso com f gouv nom prd presse tm ",gg:" co net org ",gh:" com edu gov mil org ",gn:" ac com gov net org ",gr:" com edu gov mil net org ",gt:" com edu gob ind mil net org ",gu:" com edu gov net org ",hk:" com edu gov idv net org ",hu:" 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ",id:" ac co go mil net or sch web ",il:" ac co gov idf k12 muni net org ",in:" ac co edu ernet firm gen gov i ind mil net nic org res ",iq:" com edu gov i mil net org ",ir:" ac co dnssec gov i id net org sch ",it:" edu gov ",je:" co net org ",jo:" com edu gov mil name net org sch ",jp:" ac ad co ed go gr lg ne or ",ke:" ac co go info me mobi ne or sc ",kh:" com edu gov mil net org per ",ki:" biz com de edu gov info mob net org tel ",km:" asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ",kn:" edu gov net org ",kr:" ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ",kw:" com edu gov net org ",ky:" com edu gov net org ",kz:" com edu gov mil net org ",lb:" com edu gov net org ",lk:" assn com edu gov grp hotel int ltd net ngo org sch soc web ",lr:" com edu gov net org ",lv:" asn com conf edu gov id mil net org ",ly:" com edu gov id med net org plc sch ",ma:" ac co gov m net org press ",mc:" asso tm ",me:" ac co edu gov its net org priv ",mg:" com edu gov mil nom org prd tm ",mk:" com edu gov inf name net org pro ",ml:" com edu gov net org presse ",mn:" edu gov org ",mo:" com edu gov net org ",mt:" com edu gov net org ",mv:" aero biz com coop edu gov info int mil museum name net org pro ",mw:" ac co com coop edu gov int museum net org ",mx:" com edu gob net org ",my:" com edu gov mil name net org sch ",nf:" arts com firm info net other per rec store web ",ng:" biz com edu gov mil mobi name net org sch ",ni:" ac co com edu gob mil net nom org ",np:" com edu gov mil net org ",nr:" biz com edu gov info net org ",om:" ac biz co com edu gov med mil museum net org pro sch ",pe:" com edu gob mil net nom org sld ",ph:" com edu gov i mil net ngo org ",pk:" biz com edu fam gob gok gon gop gos gov net org web ",pl:" art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olszt
2021-01-29 23:34:36 +01:00
/**
* @license MIT or GPL-2.0
* @fileOverview Favico animations
* @author Miroslav Magda, http://blog.ejci.net
* @source: https://github.com/ejci/favico.js
* @version 0.3.10
2021-07-03 16:04:46 +02:00
*/i=function(e){"use strict";e=e||{};var t,n,r,i,s,o,a,c,l,u,d,h,f,p,g={bgColor:"#d00",textColor:"#fff",fontFamily:"sans-serif",fontStyle:"bold",type:"circle",position:"down",animation:"slide",elementId:!1,element:null,dataUrl:!1,win:window};(h={}).ff="undefined"!=typeof InstallTrigger,h.chrome=!!window.chrome,h.opera=!!window.opera||navigator.userAgent.indexOf("Opera")>=0,h.ie=
/*@cc_on!@*/
!1,h.safari=Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")>0,h.supported=h.chrome||h.ff||h.opera;var m=[];d=function(){},c=!1;var v={ready:function(){c=!0,v.reset(),d()},reset:function(){c&&(m=[],l=!1,u=!1,o.clearRect(0,0,i,r),o.drawImage(a,0,0,i,r),y.setIcon(s),window.clearTimeout(f),window.clearTimeout(void 0))},start:function(){if(c&&!u&&m.length>0){u=!0;var e=function(){["type","animation","bgColor","textColor","fontFamily","fontStyle"].forEach((function(e){e in m[0].options&&(t[e]=m[0].options[e])})),x.run(m[0].options,(function(){l=m[0],u=!1,m.length>0&&(m.shift(),v.start())}),!1)};l?x.run(l.options,(function(){e()}),!0):e()}}},_={},b=function(e){return e.n="number"==typeof e.n?Math.abs(0|e.n):e.n,e.x=i*e.x,e.y=r*e.y,e.w=i*e.w,e.h=r*e.h,e.len=(""+e.n).length,e};_.circle=function(e){var n=!1;2===(e=b(e)).len?(e.x=e.x-.4*e.w,e.w=1.4*e.w,n=!0):e.len>=3&&(e.x=e.x-.65*e.w,e.w=1.65*e.w,n=!0),o.clearRect(0,0,i,r),o.drawImage(a,0,0,i,r),o.beginPath(),o.font=t.fontStyle+" "+Math.floor(e.h*(e.n>99?.85:1))+"px "+t.fontFamily,o.textAlign="center",n?(o.moveTo(e.x+e.w/2,e.y),o.lineTo(e.x+e.w-e.h/2,e.y),o.quadraticCurveTo(e.x+e.w,e.y,e.x+e.w,e.y+e.h/2),o.lineTo(e.x+e.w,e.y+e.h-e.h/2),o.quadraticCurveTo(e.x+e.w,e.y+e.h,e.x+e.w-e.h/2,e.y+e.h),o.lineTo(e.x+e.h/2,e.y+e.h),o.quadraticCurveTo(e.x,e.y+e.h,e.x,e.y+e.h-e.h/2),o.lineTo(e.x,e.y+e.h/2),o.quadraticCurveTo(e.x,e.y,e.x+e.h/2,e.y)):o.arc(e.x+e.w/2,e.y+e.h/2,e.h/2,0,2*Math.PI),o.fillStyle="rgba("+t.bgColor.r+","+t.bgColor.g+","+t.bgColor.b+","+e.o+")",o.fill(),o.closePath(),o.beginPath(),o.stroke(),o.fillStyle="rgba("+t.textColor.r+","+t.textColor.g+","+t.textColor.b+","+e.o+")","number"==typeof e.n&&e.n>999?o.fillText((e.n>9999?9:Math.floor(e.n/1e3))+"k+",Math.floor(e.x+e.w/2),Math.floor(e.y+e.h-.2*e.h)):o.fillText(e.n,Math.floor(e.x+e.w/2),Math.floor(e.y+e.h-.15*e.h)),o.closePath()},_.rectangle=function(e){2===(e=b(e)).len?(e.x=e.x-.4*e.w,e.w=1.4*e.w):e.len>=3&&(e.x=e.x-.65*e.w,e.w=1.65*e.w),o.clearRect(0,0,i,r),o.drawImage(a,0,0,i,r),o.beginPath(),o.font=t.fontStyle+" "+Math.floor(e.h*(e.n>99?.9:1))+"px "+t.fontFamily,o.textAlign="center",o.fillStyle="rgba("+t.bgColor.r+","+t.bgColor.g+","+t.bgColor.b+","+e.o+")",o.fillRect(e.x,e.y,e.w,e.h),o.fillStyle="rgba("+t.textColor.r+","+t.textColor.g+","+t.textColor.b+","+e.o+")","number"==typeof e.n&&e.n>999?o.fillText((e.n>9999?9:Math.floor(e.n/1e3))+"k+",Math.floor(e.x+e.w/2),Math.floor(e.y+e.h-.2*e.h)):o.fillText(e.n,Math.floor(e.x+e.w/2),Math.floor(e.y+e.h-.15*e.h)),o.closePath()};var y={};function w(e){e=e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(function(e,t,n,r){return t+t+n+n+r+r}));var t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return!!t&&{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}}function S(e,t){var n,r={};for(n in e)r[n]=e[n];for(n in t)r[n]=t[n];return r}y.getIcons=function(){var e=[];return t.element?e=[t.element]:t.elementId?(e=[p.getElementById(t.elementId)])[0].setAttribute("href",e[0].getAttribute("src")):0===(e=function(){for(var e=[],t=p.getElementsByTagName("head")[0].getElementsByTagName("link"),n=0;n<t.length;n++)/(^|\s)icon(\s|$)/i.test(t[n].getAttribute("rel"))&&e.push(t[n]);return e}()).length&&((e=[p.createElement("link")])[0].setAttribute("rel","icon"),p.getElementsByTagName("head")[0].appendChild(e[0])),e.forEach((function(e){e.setAttribute("type","image/png")})),e},y.setIcon=function(e){var t=e.toDataURL("image/png");y.setIconSrc(t)},y.setIconSrc=function(e){if(t.dataUrl&&t.dataUrl(e),t.element)t.element.setAttribute("href",e),t.element.setAttribute("src",e);else if(t.elementId){var r=p.getElementById(t.elementId);r.setAttribute("href",e),r.setAttribute("src",e)}else if(h.ff||h.opera){var i=n[n.length-1],s=p.createElement("link");n=[s],h.opera&&s.setAttribute("rel","icon"),s.setAttribute("rel","icon"),s.setAttribute("type","image/png"),p.getElementsByTagName("head")[0].appendChild(s),s.setAttribute("href",e),i.parentNode&&i.parentNode.removeChild(i)}else n.forEach((function(t){t.setAttribute("href",e)}))};var x={duration:40,types:{}};return x.typ
2021-01-29 23:34:36 +01:00
/**
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
* @description This is the core utilities module.
2021-03-19 19:26:15 +01:00
*/const Us=gr.g.Strophe,Hs={isTagEqual:function(e,t){if(e.nodeTree)return Hs.isTagEqual(e.nodeTree,t);if(e instanceof Element)return Us.isTagEqual(e,t);throw Error("isTagEqual called with value which isn't an element or Strophe.Builder instance")}},Vs=new DOMParser,Ws=Vs.parseFromString("invalid","text/xml").getElementsByTagName("parsererror")[0].namespaceURI;
2021-01-29 23:34:36 +01:00
/**
* Clears the specified timeout and interval.
* @method u#clearTimers
* @param {number} timeout - Id if the timeout to clear.
* @param {number} interval - Id of the interval to clear.
* @private
* @copyright Simen Bekkhus 2016
* @license MIT
*/
2021-03-19 19:26:15 +01:00
function Gs(e,t){clearTimeout(e),clearInterval(t)}
2021-01-29 23:34:36 +01:00
/**
* Creates a {@link Promise} that resolves if the passed in function returns a truthy value.
* Rejects if it throws or does not return truthy within the given max_wait.
* @method u#waitUntil
* @param {Function} func - The function called every check_delay,
* and the result of which is the resolved value of the promise.
* @param {number} [max_wait=300] - The time to wait before rejecting the promise.
* @param {number} [check_delay=3] - The time to wait before each invocation of {func}.
* @returns {Promise} A promise resolved with the value of func,
* or rejected with the exception thrown by it or it times out.
* @copyright Simen Bekkhus 2016
* @license MIT
2021-03-19 19:26:15 +01:00
*/Hs.getJIDFromURI=function(e){return e.startsWith("xmpp:")&&e.endsWith("?join")?e.replace(/^xmpp:/,"").replace(/\?join$/,""):e},Hs.toStanza=function(e){const t=Vs.parseFromString(e,"text/xml");if(t.getElementsByTagNameNS(Ws,"parsererror").length)throw new Error("Parser Error: "+e);return t.firstElementChild},Hs.getLongestSubstring=function(e,t){return t.reduce((function(t,n){return e.startsWith(n)&&n.length>t.length?n:t}),"")},Hs.prefixMentions=function(e){let t=e.get("message");return(e.get("references")||[]).sort((e,t)=>t.begin-e.begin).forEach(e=>{t=`${t.slice(0,e.begin)}@${t.slice(e.begin)}`}),t},Hs.isValidJID=function(e){return"string"==typeof e&&(2===qs(e.split("@")).length&&!e.startsWith("@")&&!e.endsWith("@"))},Hs.isValidMUCJID=function(e){return!e.startsWith("@")&&!e.endsWith("@")},Hs.isSameBareJID=function(e,t){return"string"==typeof e&&"string"==typeof t&&Us.getBareJidFromJid(e).toLowerCase()===Us.getBareJidFromJid(t).toLowerCase()},Hs.isSameDomain=function(e,t){return"string"==typeof e&&"string"==typeof t&&Us.getDomainFromJid(e).toLowerCase()===Us.getDomainFromJid(t).toLowerCase()},Hs.isNewMessage=function(e){return e instanceof Element?!(pr()(`result[xmlns="${Us.NS.MAM}"]`,e).length&&pr()(`delay[xmlns="${Us.NS.DELAY}"]`,e).length):(e instanceof Bs&&(e=e.attributes),!(e.is_delayed&&e.is_archived))},Hs.shouldCreateMessage=function(e){return e.retracted||!Hs.isEmptyMessage(e)},Hs.shouldCreateGroupchatMessage=function(e){return e.nick&&(Hs.shouldCreateMessage(e)||e.is_tombstone)},Hs.isEmptyMessage=function(e){return e instanceof Bs&&(e=e.attributes),!(e.oob_url||e.file||e.is_encrypted&&e.plaintext||e.message)},Hs.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 Bs&&(e=e.attributes),e.chat_state&&Hs.isEmptyMessage(e))},Hs.isOnlyMessageDeliveryReceipt=function(e){return e instanceof Element?null===e.querySelector("body")&&null!==e.querySelector("received"):(e instanceof Bs&&(e=e.attributes),e.received&&Hs.isEmptyMessage(e))},Hs.isChatRoom=function(e){return e&&"chatroom"===e.get("type")},Hs.isErrorObject=function(e){return e instanceof Error},Hs.isErrorStanza=function(e){return!!Mn(e)&&"error"===e.getAttribute("type")},Hs.isForbiddenError=function(e){return!!Mn(e)&&pr()(`error[type="auth"] forbidden[xmlns="${Us.NS.STANZAS}"]`,e).length>0},Hs.isServiceUnavailableError=function(e){return!!Mn(e)&&pr()(`error[type="cancel"] service-unavailable[xmlns="${Us.NS.STANZAS}"]`,e).length>0},Hs.merge=function e(t,n){for(const r in n)N(t[r])?e(t[r],n[r]):t[r]=n[r]},Hs.getOuterWidth=function(e,t=!1){let n=e.offsetWidth;if(!t)return n;const r=window.getComputedStyle(e);return n+=parseInt(r.marginLeft?r.marginLeft:0,10)+parseInt(r.marginRight?r.marginRight:0,10),n},Hs.stringToElement=function(e){var t=document.createElement("div");return t.innerHTML=e,t.firstElementChild},Hs.matchesSelector=function(e,t){const n=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;return!!n&&n.call(e,t)},Hs.queryChildren=function(e,t){return Array.from(e.childNodes).filter(e=>Hs.matchesSelector(e,t))},Hs.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,r)=>e||n(t,r),!1);if("string"==typeof e)return n(t,e);throw new TypeError("contains: wrong attribute type. Must be string or array.")}},Hs.isOfType=function(e,t){return t.get("type")==e},Hs.isInstance=function(e,t){return t instanceof e},Hs.getAttribute=function(e,t){return t.get(e)},Hs.contains.not=function(e,t){return function(n){return!Hs.contains(e,t)(n)}},Hs.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)},Hs.createFragmentFromText=function(e){var t,n
2021-01-29 23:34:36 +01:00
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
2021-03-19 19:26:15 +01:00
*/
const Da="undefined"!=typeof window&&null!=window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,Pa=(e,t,n=null,r=null)=>{for(;t!==n;){const n=t.nextSibling;e.insertBefore(t,r),t=n}},La=(e,t,n=null)=>{for(;t!==n;){const n=t.nextSibling;e.removeChild(t),t=n}},za=`{{lit-${String(Math.random()).slice(2)}}}`,Fa=`\x3c!--${za}--\x3e`,Ba=new RegExp(`${za}|${Fa}`);class qa{constructor(e,t){this.parts=[],this.element=t;const n=[],r=[],i=document.createTreeWalker(t.content,133,null,!1);let s=0,o=-1,a=0;const{strings:c,values:{length:l}}=e;for(;a<l;){const e=i.nextNode();if(null!==e){if(o++,1===e.nodeType){if(e.hasAttributes()){const t=e.attributes,{length:n}=t;let r=0;for(let e=0;e<n;e++)Ua(t[e].name,"$lit$")&&r++;for(;r-- >0;){const t=c[a],n=Wa.exec(t)[2],r=n.toLowerCase()+"$lit$",i=e.getAttribute(r);e.removeAttribute(r);const s=i.split(Ba);this.parts.push({type:"attribute",index:o,name:n,strings:s}),a+=s.length-1}}"TEMPLATE"===e.tagName&&(r.push(e),i.currentNode=e.content)}else if(3===e.nodeType){const t=e.data;if(t.indexOf(za)>=0){const r=e.parentNode,i=t.split(Ba),s=i.length-1;for(let t=0;t<s;t++){let n,s=i[t];if(""===s)n=Va();else{const e=Wa.exec(s);null!==e&&Ua(e[2],"$lit$")&&(s=s.slice(0,e.index)+e[1]+e[2].slice(0,-"$lit$".length)+e[3]),n=document.createTextNode(s)}r.insertBefore(n,e),this.parts.push({type:"node",index:++o})}""===i[s]?(r.insertBefore(Va(),e),n.push(e)):e.data=i[s],a+=s}}else if(8===e.nodeType)if(e.data===za){const t=e.parentNode;null!==e.previousSibling&&o!==s||(o++,t.insertBefore(Va(),e)),s=o,this.parts.push({type:"node",index:o}),null===e.nextSibling?e.data="":(n.push(e),o--),a++}else{let t=-1;for(;-1!==(t=e.data.indexOf(za,t+1));)this.parts.push({type:"node",index:-1}),a++}}else i.currentNode=r.pop()}for(const e of n)e.parentNode.removeChild(e)}}const Ua=(e,t)=>{const n=e.length-t.length;return n>=0&&e.slice(n)===t},Ha=e=>-1!==e.index,Va=()=>document.createComment(""),Wa=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function Ga(e,t){const{element:{content:n},parts:r}=e,i=document.createTreeWalker(n,133,null,!1);let s=Qa(r),o=r[s],a=-1,c=0;const l=[];let u=null;for(;i.nextNode();){a++;const e=i.currentNode;for(e.previousSibling===u&&(u=null),t.has(e)&&(l.push(e),null===u&&(u=e)),null!==u&&c++;void 0!==o&&o.index===a;)o.index=null!==u?-1:o.index-c,s=Qa(r,s),o=r[s]}l.forEach(e=>e.parentNode.removeChild(e))}const Ja=e=>{let t=11===e.nodeType?0:1;const n=document.createTreeWalker(e,133,null,!1);for(;n.nextNode();)t++;return t},Qa=(e,t=-1)=>{for(let n=t+1;n<e.length;n++){const t=e[n];if(Ha(t))return n}return-1};
2021-01-29 23:34:36 +01:00
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
2021-03-19 19:26:15 +01:00
const Ya=new WeakMap,Ka=e=>(...t)=>{const n=e(...t);return Ya.set(n,!0),n},Xa=e=>"function"==typeof e&&Ya.has(e),Za={},ec={};
2021-01-29 23:34:36 +01:00
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
2021-03-19 19:26:15 +01:00
class tc{constructor(e,t,n){this.__parts=[],this.template=e,this.processor=t,this.options=n}update(e){let t=0;for(const n of this.__parts)void 0!==n&&n.setValue(e[t]),t++;for(const e of this.__parts)void 0!==e&&e.commit()}_clone(){const e=Da?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),t=[],n=this.template.parts,r=document.createTreeWalker(e,133,null,!1);let i,s=0,o=0,a=r.nextNode();for(;s<n.length;)if(i=n[s],Ha(i)){for(;o<i.index;)o++,"TEMPLATE"===a.nodeName&&(t.push(a),r.currentNode=a.content),null===(a=r.nextNode())&&(r.currentNode=t.pop(),a=r.nextNode());if("node"===i.type){const e=this.processor.handleTextExpression(this.options);e.insertAfterNode(a.previousSibling),this.__parts.push(e)}else this.__parts.push(...this.processor.handleAttributeExpressions(a,i.name,i.strings,this.options));s++}else this.__parts.push(void 0),s++;return Da&&(document.adoptNode(e),customElements.upgrade(e)),e}}
2021-01-29 23:34:36 +01:00
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
2021-03-19 19:26:15 +01:00
*/const nc=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:e=>e}),rc=` ${za} `;class ic{constructor(e,t,n,r){this.strings=e,this.values=t,this.type=n,this.processor=r}getHTML(){const e=this.strings.length-1;let t="",n=!1;for(let r=0;r<e;r++){const e=this.strings[r],i=e.lastIndexOf("\x3c!--");n=(i>-1||n)&&-1===e.indexOf("--\x3e",i+1);const s=Wa.exec(e);t+=null===s?e+(n?rc:Fa):e.substr(0,s.index)+s[1]+s[2]+"$lit$"+s[3]+za}return t+=this.strings[e],t}getTemplateElement(){const e=document.createElement("template");let t=this.getHTML();return void 0!==nc&&(t=nc.createHTML(t)),e.innerHTML=t,e}}
2021-01-29 23:34:36 +01:00
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
2021-03-19 19:26:15 +01:00
const sc=e=>null===e||!("object"==typeof e||"function"==typeof e),oc=e=>Array.isArray(e)||!(!e||!e[Symbol.iterator]);class ac{constructor(e,t,n){this.dirty=!0,this.element=e,this.name=t,this.strings=n,this.parts=[];for(let e=0;e<n.length-1;e++)this.parts[e]=this._createPart()}_createPart(){return new cc(this)}_getValue(){const e=this.strings,t=e.length-1,n=this.parts;if(1===t&&""===e[0]&&""===e[1]){const e=n[0].value;if("symbol"==typeof e)return String(e);if("string"==typeof e||!oc(e))return e}let r="";for(let i=0;i<t;i++){r+=e[i];const t=n[i];if(void 0!==t){const e=t.value;if(sc(e)||!oc(e))r+="string"==typeof e?e:String(e);else for(const t of e)r+="string"==typeof t?t:String(t)}}return r+=e[t],r}commit(){this.dirty&&(this.dirty=!1,this.element.setAttribute(this.name,this._getValue()))}}class cc{constructor(e){this.value=void 0,this.committer=e}setValue(e){e===Za||sc(e)&&e===this.value||(this.value=e,Xa(e)||(this.committer.dirty=!0))}commit(){for(;Xa(this.value);){const e=this.value;this.value=Za,e(this)}this.value!==Za&&this.committer.commit()}}class lc{constructor(e){this.value=void 0,this.__pendingValue=void 0,this.options=e}appendInto(e){this.startNode=e.appendChild(Va()),this.endNode=e.appendChild(Va())}insertAfterNode(e){this.startNode=e,this.endNode=e.nextSibling}appendIntoPart(e){e.__insert(this.startNode=Va()),e.__insert(this.endNode=Va())}insertAfterPart(e){e.__insert(this.startNode=Va()),this.endNode=e.endNode,e.endNode=this.startNode}setValue(e){this.__pendingValue=e}commit(){if(null===this.startNode.parentNode)return;for(;Xa(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=Za,e(this)}const e=this.__pendingValue;e!==Za&&(sc(e)?e!==this.value&&this.__commitText(e):e instanceof ic?this.__commitTemplateResult(e):e instanceof Node?this.__commitNode(e):oc(e)?this.__commitIterable(e):e===ec?(this.value=ec,this.clear()):this.__commitText(e))}__insert(e){this.endNode.parentNode.insertBefore(e,this.endNode)}__commitNode(e){this.value!==e&&(this.clear(),this.__insert(e),this.value=e)}__commitText(e){const t=this.startNode.nextSibling,n="string"==typeof(e=null==e?"":e)?e:String(e);t===this.endNode.previousSibling&&3===t.nodeType?t.data=n:this.__commitNode(document.createTextNode(n)),this.value=e}__commitTemplateResult(e){const t=this.options.templateFactory(e);if(this.value instanceof tc&&this.value.template===t)this.value.update(e.values);else{const n=new tc(t,e.processor,this.options),r=n._clone();n.update(e.values),this.__commitNode(r),this.value=n}}__commitIterable(e){Array.isArray(this.value)||(this.value=[],this.clear());const t=this.value;let n,r=0;for(const i of e)n=t[r],void 0===n&&(n=new lc(this.options),t.push(n),0===r?n.appendIntoPart(this):n.insertAfterPart(t[r-1])),n.setValue(i),n.commit(),r++;r<t.length&&(t.length=r,this.clear(n&&n.endNode))}clear(e=this.startNode){La(this.startNode.parentNode,e.nextSibling,this.endNode)}}class uc{constructor(e,t,n){if(this.value=void 0,this.__pendingValue=void 0,2!==n.length||""!==n[0]||""!==n[1])throw new Error("Boolean attributes can only contain a single expression");this.element=e,this.name=t,this.strings=n}setValue(e){this.__pendingValue=e}commit(){for(;Xa(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=Za,e(this)}if(this.__pendingValue===Za)return;const e=!!this.__pendingValue;this.value!==e&&(e?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name),this.value=e),this.__pendingValue=Za}}class dc extends ac{constructor(e,t,n){super(e,t,n),this.single=2===n.length&&""===n[0]&&""===n[1]}_createPart(){return new hc(this)}_getValue(){return this.single?this.parts[0].value:super._getValue()}commit(){this.dirty&&(this.dirty=!1,this.element[this.name]=this._getValue())}}class hc extends cc{}let fc=!1;(()=>{try{const e={get capture(){return fc=!0,!1}};window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){}})();class pc{constructor(e,t,n){this.value=void 0,this.__pendingValue=void 0,this.element=e,this.eventName=t,this.eventContext=n,this.__boundHandleEvent=e=>this.handleEven
2021-01-29 23:34:36 +01:00
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
2021-03-19 19:26:15 +01:00
*/;function mc(e){let t=vc.get(e.type);void 0===t&&(t={stringsArray:new WeakMap,keyString:new Map},vc.set(e.type,t));let n=t.stringsArray.get(e.strings);if(void 0!==n)return n;const r=e.strings.join(za);return n=t.keyString.get(r),void 0===n&&(n=new qa(e,e.getTemplateElement()),t.keyString.set(r,n)),t.stringsArray.set(e.strings,n),n}const vc=new Map,_c=new WeakMap,bc=(e,t,n)=>{let r=_c.get(t);void 0===r&&(La(t,t.firstChild),_c.set(t,r=new lc(Object.assign({templateFactory:mc},n))),r.appendInto(t)),r.setValue(e),r.commit()};
2021-01-29 23:34:36 +01:00
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
2021-03-19 19:26:15 +01:00
*/const yc=new
2021-01-29 23:34:36 +01:00
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
2021-03-19 19:26:15 +01:00
class{handleAttributeExpressions(e,t,n,r){const i=t[0];if("."===i){return new dc(e,t.slice(1),n).parts}if("@"===i)return[new pc(e,t.slice(1),r.eventContext)];if("?"===i)return[new uc(e,t.slice(1),n)];return new ac(e,t,n).parts}handleTextExpression(e){return new lc(e)}};
2021-01-29 23:34:36 +01:00
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
2021-03-19 19:26:15 +01:00
*/"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.3.0");const wc=(e,...t)=>new ic(e,t,"html",yc),Sc=(e,t)=>`${e}--${t}`;let xc=!0;void 0===window.ShadyCSS?xc=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),xc=!1);const Ec=e=>t=>{const n=Sc(t.type,e);let r=vc.get(n);void 0===r&&(r={stringsArray:new WeakMap,keyString:new Map},vc.set(n,r));let i=r.stringsArray.get(t.strings);if(void 0!==i)return i;const s=t.strings.join(za);if(i=r.keyString.get(s),void 0===i){const n=t.getTemplateElement();xc&&window.ShadyCSS.prepareTemplateDom(n,e),i=new qa(t,n),r.keyString.set(s,i)}return r.stringsArray.set(t.strings,i),i},Ac=["html","svg"],Cc=new Set,kc=(e,t,n)=>{Cc.add(e);const r=n?n.element:document.createElement("template"),i=t.querySelectorAll("style"),{length:s}=i;if(0===s)return void window.ShadyCSS.prepareTemplateStyles(r,e);const o=document.createElement("style");for(let e=0;e<s;e++){const t=i[e];t.parentNode.removeChild(t),o.textContent+=t.textContent}(e=>{Ac.forEach(t=>{const n=vc.get(Sc(t,e));void 0!==n&&n.keyString.forEach(e=>{const{element:{content:t}}=e,n=new Set;Array.from(t.querySelectorAll("style")).forEach(e=>{n.add(e)}),Ga(e,n)})})})(e);const a=r.content;n?function(e,t,n=null){const{element:{content:r},parts:i}=e;if(null==n)return void r.appendChild(t);const s=document.createTreeWalker(r,133,null,!1);let o=Qa(i),a=0,c=-1;for(;s.nextNode();){c++;for(s.currentNode===n&&(a=Ja(t),n.parentNode.insertBefore(t,n));-1!==o&&i[o].index===c;){if(a>0){for(;-1!==o;)i[o].index+=a,o=Qa(i,o);return}o=Qa(i,o)}}}(n,o,a.firstChild):a.insertBefore(o,a.firstChild),window.ShadyCSS.prepareTemplateStyles(r,e);const c=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==c)t.insertBefore(c.cloneNode(!0),t.firstChild);else if(n){a.insertBefore(o,a.firstChild);const e=new Set;e.add(o),Ga(n,e)}};window.JSCompiler_renameProperty=(e,t)=>e;const jc={toAttribute(e,t){switch(t){case Boolean:return e?"":null;case Object:case Array:return null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){switch(t){case Boolean:return null!==e;case Number:return null===e?null:Number(e);case Object:case Array:return JSON.parse(e)}return e}},Tc=(e,t)=>t!==e&&(t==t||e==e),Oc={attribute:!0,type:String,converter:jc,reflect:!1,hasChanged:Tc};class Nc extends HTMLElement{constructor(){super(),this.initialize()}static get observedAttributes(){this.finalize();const e=[];return this._classProperties.forEach((t,n)=>{const r=this._attributeNameForProperty(n,t);void 0!==r&&(this._attributeToPropertyMap.set(r,n),e.push(r))}),e}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const e=Object.getPrototypeOf(this)._classProperties;void 0!==e&&e.forEach((e,t)=>this._classProperties.set(t,e))}}static createProperty(e,t=Oc){if(this._ensureClassProperties(),this._classProperties.set(e,t),t.noAccessor||this.prototype.hasOwnProperty(e))return;const n="symbol"==typeof e?Symbol():"__"+e,r=this.getPropertyDescriptor(e,n,t);void 0!==r&&Object.defineProperty(this.prototype,e,r)}static getPropertyDescriptor(e,t,n){return{get(){return this[t]},set(r){const i=this[e];this[t]=r,this.requestUpdateInternal(e,i,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this._classProperties&&this._classProperties.get(e)||Oc}static finalize(){const e=Object.getPrototypeOf(this);if(e.hasOwnProperty("finalized")||e.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const e=this.properties,t=[...Object.getOwnPropertyNames(e),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e):[]];for(const n of t)this.createProperty(n,e[n])}}static _attributeNameForProperty(e,t){const n=t.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof e?e.toLowerCase():
2021-01-29 23:34:36 +01:00
/**
@license
Copyright (c) 2019 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at
http://polymer.github.io/LICENSE.txt The complete set of authors may be found at
http://polymer.github.io/AUTHORS.txt The complete set of contributors may be
found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as
part of the polymer project is also subject to an additional IP rights grant
found at http://polymer.github.io/PATENTS.txt
*/
2021-03-19 19:26:15 +01:00
const Mc=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Rc=Symbol();class $c{constructor(e,t){if(t!==Rc)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e}get styleSheet(){return void 0===this._styleSheet&&(Mc?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const Dc=(e,...t)=>{const n=t.reduce((t,n,r)=>t+(e=>{if(e instanceof $c)return e.cssText;if("number"==typeof e)return e;throw new 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[r+1],e[0]);return new $c(n,Rc)};
2021-01-29 23:34:36 +01:00
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
2021-03-19 19:26:15 +01:00
(window.litElementVersions||(window.litElementVersions=[])).push("2.4.0");const Pc={};class Lc extends Nc{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const e=this.getStyles();if(Array.isArray(e)){const t=(e,n)=>e.reduceRight((e,n)=>Array.isArray(n)?t(n,e):(e.add(n),e),n),n=t(e,new Set),r=[];n.forEach(e=>r.unshift(e)),this._styles=r}else this._styles=void 0===e?[]:[e];this._styles=this._styles.map(e=>{if(e instanceof CSSStyleSheet&&!Mc){const t=Array.prototype.slice.call(e.cssRules).reduce((e,t)=>e+t.cssText,"");return new $c(String(t),Rc)}return e})}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const e=this.constructor._styles;0!==e.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?Mc?this.renderRoot.adoptedStyleSheets=e.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(e.map(e=>e.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(e){const t=this.render();super.update(e),t!==Pc&&this.constructor.render(t,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(e=>{const t=document.createElement("style");t.textContent=e.cssText,this.renderRoot.appendChild(t)}))}render(){return Pc}}Lc.finalized=!0,Lc.render=(e,t,n)=>{if(!n||"object"!=typeof n||!n.scopeName)throw new Error("The `scopeName` option is required.");const r=n.scopeName,i=_c.has(t),s=xc&&11===t.nodeType&&!!t.host,o=s&&!Cc.has(r),a=o?document.createDocumentFragment():t;if(bc(e,a,Object.assign({templateFactory:Ec(r)},n)),o){const e=_c.get(a);_c.delete(a);const n=e.value instanceof tc?e.value.template:void 0;kc(r,a,n),La(t,t.firstChild),t.appendChild(a),_c.set(t,e)}!i&&s&&window.ShadyCSS.styleElement(t.host)};var zc=n(91);
2021-01-29 23:34:36 +01:00
/**
* @module converse-core
* @copyright The Converse.js contributors
* @license Mozilla Public License (MPLv2)
2021-07-03 16:04:46 +02:00
*/Sn.a.extend(yn.a),Ta.e.addNamespace("CARBONS","urn:xmpp:carbons:2"),Ta.e.addNamespace("CHATSTATES","http://jabber.org/protocol/chatstates"),Ta.e.addNamespace("CSI","urn:xmpp:csi:0"),Ta.e.addNamespace("DELAY","urn:xmpp:delay"),Ta.e.addNamespace("FASTEN","urn:xmpp:fasten:0"),Ta.e.addNamespace("FORWARD","urn:xmpp:forward:0"),Ta.e.addNamespace("HINTS","urn:xmpp:hints"),Ta.e.addNamespace("HTTPUPLOAD","urn:xmpp:http:upload:0"),Ta.e.addNamespace("IDLE","urn:xmpp:idle:1"),Ta.e.addNamespace("MAM","urn:xmpp:mam:2"),Ta.e.addNamespace("MODERATE","urn:xmpp:message-moderate:0"),Ta.e.addNamespace("NICK","http://jabber.org/protocol/nick"),Ta.e.addNamespace("OMEMO","eu.siacs.conversations.axolotl"),Ta.e.addNamespace("OUTOFBAND","jabber:x:oob"),Ta.e.addNamespace("PUBSUB","http://jabber.org/protocol/pubsub"),Ta.e.addNamespace("REGISTER","jabber:iq:register"),Ta.e.addNamespace("RETRACT","urn:xmpp:message-retract:0"),Ta.e.addNamespace("ROSTERX","http://jabber.org/protocol/rosterx"),Ta.e.addNamespace("RSM","http://jabber.org/protocol/rsm"),Ta.e.addNamespace("SID","urn:xmpp:sid:0"),Ta.e.addNamespace("SPOILER","urn:xmpp:spoiler:0"),Ta.e.addNamespace("STANZAS","urn:ietf:params:xml:ns:xmpp-stanzas"),Ta.e.addNamespace("VCARD","vcard-temp"),Ta.e.addNamespace("VCARDUPDATE","vcard-temp:x:update"),Ta.e.addNamespace("XFORM","jabber:x:data");class Fc extends Error{}const Bc=["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"],qc={allow_non_roster_messaging:!1,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","de","eo","es","eu","en","fi","fr","gl","he","hi","hu","id","it","ja","nb","nl","mr","oc","pl","pt","pt_BR","ro","ru","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:[]},Uc={};Uc[Ta.e.Status.ATTACHED]="ATTACHED",Uc[Ta.e.Status.AUTHENTICATING]="AUTHENTICATING",Uc[Ta.e.Status.AUTHFAIL]="AUTHFAIL",Uc[Ta.e.Status.CONNECTED]="CONNECTED",Uc[Ta.e.Status.CONNECTING]="CONNECTING",Uc[Ta.e.Status.CONNFAIL]="CONNFAIL",Uc[Ta.e.Status.DISCONNECTED]="DISCONNECTED",Uc[Ta.e.Status.DISCONNECTING]="DISCONNECTING",Uc[Ta.e.Status.ERROR]="ERROR",Uc[Ta.e.Status.RECONNECTING]="RECONNECTING",Uc[Ta.e.Status.REDIRECT]="REDIRECT";const Hc={initialize(){},__:(...e)=>Object(zc.sprintf)(...e)},Vc={log:Dn,CONNECTION_STATUS:Uc,templates:{},promises:{initialized:Js.getResolveablePromise()},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:{exp
2021-01-29 23:34:36 +01:00
/**
* @module converse-chat
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
2021-03-19 19:26:15 +01:00
*/const{$msg:gl,Strophe:ml,sizzle:vl,utils:_l}=sl.env,bl=sl.env.utils;sl.plugins.add("converse-chat",{dependencies:["converse-chatboxes","converse-disco"],initialize(){const{__:e}=Vc;Qc.settings.extend({allow_message_corrections:"all",allow_message_retraction:"all",auto_join_private_chats:[],clear_messages_on_reconnection:!1,filter_by_resource:!1,send_chat_state_notifications:!0});const t=Bs.extend({initialize(){this.rosterContactAdded=bl.getResolveablePromise()},async setRosterContact(e){const t=await Qc.contacts.get(e);t&&(this.contact=t,this.set("nickname",t.get("nickname")),this.rosterContactAdded.resolve())}});Vc.Message=t.extend({defaults:()=>({msgid:bl.getUniqueId(),time:(new Date).toISOString(),is_ephemeral:!1}),async initialize(){this.checkValidity()&&(this.initialized=bl.getResolveablePromise(),"chat"===this.get("type")&&(t.prototype.initialize.apply(this,arguments),this.setRosterContact(ml.getBareJidFromJid(this.get("from")))),this.get("file")&&this.on("change:put",this.uploadFile,this),this.setTimerForEphemeralMessage(),await Qc.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(){return"me"===this.get("sender")&&["all","own"].includes(Qc.settings.get("allow_message_retraction"))},safeDestroy(){try{this.destroy()}catch(e){Dn.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(){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=sl.env.$iq({from:Vc.jid,to:this.get("slot_request_url"),type:"get"}).c("request",{xmlns:ml.NS.HTTPUPLOAD,filename:this.file.name,size:this.file.size,"content-type":this.file.type});return Qc.sendIQ(e)},async getRequestSlotURL(){let t;try{t=await this.sendSlotRequestStanza()}catch(t){return Dn.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 t=new XMLHttpRequest;t.onreadystatechange=()=>{t.readyState===XMLHttpRequest.DONE&&(Dn.info("Status: "+t.status),200===t.status||201===t.status?this.save({upload:Vc.SUCCESS,oob_url:this.get("get"),message:this.get("get")}):t.onerror())},t.upload.addEventListener("progress",e=>{e.lengthComputable&&this.set("progress",e.loaded/e.total)},!1),t.onerror=()=>{let n;n=t.responseText?e('Sorry, could not succesfully upload your file. Your servers response: "%1$s"',t.responseText):e("Sorry, could not succesfully upload your file."),this.save({type:"error",upload:Vc.FAILURE,message:n,is_ephemeral:!0})},t.open("PUT",this.get("put"),!0),t.setRequestHeader("Content-type",this.file.type),t.send(this.file)}}),Vc.Messages=ia.extend({model:Vc.Message,comparator:"time"}),Vc.ChatBox=t.extend({messagesCollection:Vc.Messages,defaults(){return{bookmarked:!1,chat_state:void 0,hidden:Vc.isUniView()&&!Qc.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:Vc.PRIVATE_CHAT_TYPE,url:""}},async initialize(){this.initialized=bl.getResolveablePromise(),t.prototype.initialize.apply(this,ar
2021-01-29 23:34:36 +01:00
/**
* @module converse-disco
* @copyright The Converse.js contributors
* @license Mozilla Public License (MPLv2)
* @description Converse plugin which add support for XEP-0030: Service Discovery
*/
2021-03-19 19:26:15 +01:00
const{Strophe:yl,$iq:wl,utils:Sl}=sl.env;sl.plugins.add("converse-disco",{initialize(){function e(){if(!Vc.stream_features){const e="converse.stream-features-"+yl.getBareJidFromJid(Vc.jid);Qc.promises.add("streamFeaturesAdded"),Vc.stream_features=new ia,Vc.stream_features.browserStorage=Vc.createStore(e,"session")}}function t(){Qc.trigger("streamFeaturesAdded")}Qc.promises.add("discoInitialized"),Qc.promises.add("streamFeaturesAdded"),Vc.DiscoEntity=Bs.extend({idAttribute:"jid",initialize(e,t){this.waitUntilFeaturesDiscovered=Sl.getResolveablePromise(),this.dataforms=new ia;let n="converse.dataforms-"+this.get("jid");this.dataforms.browserStorage=Vc.createStore(n,"session"),this.features=new ia,n="converse.features-"+this.get("jid"),this.features.browserStorage=Vc.createStore(n,"session"),this.listenTo(this.features,"add",this.onFeatureAdded),this.fields=new ia,n="converse.fields-"+this.get("jid"),this.fields.browserStorage=Vc.createStore(n,"session"),this.listenTo(this.fields,"add",this.onFieldAdded),this.identities=new ia,n="converse.identities-"+this.get("jid"),this.identities.browserStorage=Vc.createStore(n,"session"),this.fetchFeatures(t),this.items=new Vc.DiscoEntities,n="converse.disco-items-"+this.get("jid"),this.items.browserStorage=Vc.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,Qc.trigger("serviceDiscovered",e)},onFieldAdded(e){e.entity=this,Qc.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 Qc.disco.info(this.get("jid"),null)}catch(e){return null===e?Dn.error("Timeout for disco#info query for "+this.get("jid")):Dn.error(e),void this.waitUntilFeaturesDiscovered.resolve(this)}this.onInfo(e)},onDiscoItems(e){pr()(`query[xmlns="${yl.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=Vc.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 Qc.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")})}),pr()(`x[type="result"][xmlns="${yl.NS.XFORM}"]`,e).forEach(e=>{const t={};pr()("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="${yl.NS.DISCO_ITEMS}"]`)&&this.queryForItems(),Array.from(e.querySelectorAll("feature")).forEach(t=>{this.features.create({var:t.getAttribute("var"),from:e.getAttribute("from")})}),pr()('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")}}),Vc.DiscoEntities=ia.extend({model:Vc.DiscoEntity,fetchEntities(){return new Promise((e,t)=>{this.fetch({add:!0,success:e,error(e,n){Dn.error(n),t(new Error("Could not fetch disco entities"))}})})}});const n=this;function r(e){const t=e.getElementsByTagName("query")[0].getAttribute("node"),r={xmlns:yl.NS.DISCO_INFO};t&&(r.node=t);const i=wl({type:"result",id:e.getAttribute("id")}),s=e.getAttribute("from");return null!==s&&i.
draggable="false"
title="${r}"
alt="${n}"
src="${t}/72x72/${e.cp}.png"/>`}}return t.unicode_only?r:wc`<img class="emoji"
draggable="false"
title="${r}"
alt="${r}"
src="${sl.emojis.by_sn[r].url}">`}function Nl(e){if(!sl.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(sl.emojis.shortnames_regex)].filter(e=>e[0].length>0).map(e=>{const t=sl.emojis.by_sn[e[0]].cp;return{cp:t,begin:e.index,end:e.index+e[0].length,shortname:e[0],emoji:t?kl(t):null}})}function Il(e){const t=[];return function(e,t){const n=/\uFE0F/g,r=String.fromCharCode(8205);String(e).replace(El,(e,i,s)=>{const o=function(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=e.charCodeAt(r++);n?(t.push((65536+(n-55296<<10)+(i-56320)).toString(16)),n=0):55296<=i&&i<=56319?n=i:t.push(i.toString(16))}return t.join("-")}(e.indexOf(r)<0?e.replace(n,""):e);o&&t(o,e,s)})}(e,(e,n,r)=>{var i;t.push({begin:r,cp:e,emoji:n,end:r+n.length,shortname:(null===(i=Al.getEmojisByAtrribute("cp")[e])||void 0===i?void 0:i.sn)||""})}),t}sl.plugins.add("converse-emoji",{initialize(){const{___:e}=Vc;Qc.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")}}),Vc.EmojiPicker=Bs.extend({defaults:{current_category:"smileys",current_skintone:"",scroll_position:0}});const t={};Object.assign(Al,{shortnamesToEmojis:(e,t={unicode_only:!1,add_title_wrapper:!1})=>function(e,t){let n=[e];return[...Nl(e),...Il(e)].sort((e,t)=>t.begin-e.begin).forEach(e=>{const r=n.shift(),i=Ol(e,t);n="string"==typeof i?[r.slice(0,e.begin)+i+r.slice(e.end),...n]:[r.slice(0,e.begin),i,r.slice(e.end),...n]}),n}(e=Tl(e),t),shortnamesToUnicode:e=>Al.shortnamesToEmojis(e,{unicode_only:!0})[0],isOnlyEmojis(e){const t=e.trim().split(/\s+/);if(0===t.length||t.length>3)return!1;return t.filter(e=>{const t=Il(Al.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 sl.emojis.json;const n=sl.emojis.list.map(t=>t[e]).filter((e,t,n)=>n.indexOf(e)==t);return t[e]={},n.forEach(n=>t[e][n]=sl.emojis.list.find(t=>t[e]===n)),t[e]}}),Object.assign(Qc,{emojis:{async initialize(){if(!sl.emojis.initialized){sl.emojis.initialized=!0;const{default:e}=await n.e(137).then(n.t.bind(null,542,3));sl.emojis.json=e,sl.emojis.by_sn=Object.keys(e).reduce((t,n)=>Object.assign(t,e[n]),{}),sl.emojis.list=Object.values(sl.emojis.by_sn),sl.emojis.list.sort((e,t)=>e.sn<t.sn?-1:e.sn>t.sn?1:0),sl.emojis.shortnames=sl.emojis.list.map(e=>e.sn);const t=()=>sl.emojis.shortnames.map(e=>e.replace(/[+]/g,"\\$&")).join("|");sl.emojis.shortnames_regex=new RegExp(t(),"gi"),sl.emojis.toned=jl(),sl.emojis.initialized_promise.resolve()}return sl.emojis.initialized_promise}}})}});var Ml=function(e,t,n){for(var r=-1,i=e.length,s=t.length,o={};++r<i;){var a=r<s?t[r]:void 0;n(o,e[r],a)}return o};var Rl=function(e,t){return Ml(e||[],t||[],we)},$l=Math.min;var Dl=function(e,t,n){for(var r=n?jo:ko,i=e[0].length,s=e.length,o=s,a=Array(s),c=1/0,l=[];o--;){var u=e[o];o&&t&&(u=zr(u,Pe(t))),c=$l(u.length,c),a[o]=!n&&(t||i>=120&&u.length>=120)?new Yi(o&&u):void 0}u=e[0];var d=-1,h=a[0];e:for(;++d<i&&l.length<c;){var f=u[d],p=t?t(f):f;if(f=n||0!==f?f:0,!(h?Xi(h,p):r(l,p,n))){for(o=s;--o;){var g=a[o];if(!(g?Xi(g,p):r(e[o],p,n)))continue e}h&&h.push(p),l.push(f)}}return l};var Pl=function(e){return Oo(e)?e:[]},Ll=Ar((function(e){var t=zr(e,Pl);return t.length&&t[0]===e[0]?Dl(t):[]}));
2021-01-29 23:34:36 +01:00
/**
* @copyright The Converse.js contributors
* @license Mozilla Public License (MPLv2)
* @description This is the MUC utilities module.
*/
2021-03-19 19:26:15 +01:00
const{Strophe:zl,sizzle:Fl}=sl.env;var Bl={computeAffiliationsDelta(e,t,n,r){const i=n.map(e=>e.jid),s=r.map(e=>e.jid);let o=No(i,s).map(e=>n[Uo(i,e)]);return e||(o=o.concat(n.filter(e=>{const t=Uo(s,e.jid);return t>=0&&e.affiliation!==r[t].affiliation}))),t&&(o=o.concat(No(s,i).map(e=>({jid:e,affiliation:"none"})))),o},parseMemberListIQ:e=>Fl(`query[xmlns="${zl.NS.MUC_ADMIN}"] item`,e).map(e=>{const t={affiliation:e.getAttribute("affiliation")},n=e.getAttribute("jid");Js.isValidJID(n)?t.jid=n:t.nick=n;const r=e.getAttribute("nick");r&&(t.nick=r);return e.getAttribute("role")&&(t.role=r),t})};
2021-01-29 23:34:36 +01:00
/**
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
* @description This is the form utilities module.
2021-03-19 19:26:15 +01:00
*/Js.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?Js.getSelectValues(e):e.value,Js.toStanza(`\n <field var="${t}">\n ${n.constructor===Array?n.map(e=>`<value>${e}</value>`):`<value>${n}</value>`}\n </field>`)};var ql=Js;
2021-01-29 23:34:36 +01:00
/**
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
* @description Pure functions to help funcitonally parse messages.
* @todo Other parsing helpers can be made more abstract and placed here.
2021-03-19 19:26:15 +01:00
*/const Ul={mention_regex:/(?:\s|^)([@][\w_-]+(?:\.\w+)*)/gi,matchRegexInText:e=>t=>e.matchAll(t)},Hl=(e,t)=>e.replace(RegExp("\\"+t,"ig"),"\\"+t);Ul.escapeCharacters=e=>t=>e.split("").reduce(Hl,t),Ul.escapeRegexString=Ul.escapeCharacters("[\\^$.?*+(){}"),Ul.findFirstMatchInArray=e=>t=>{for(let n=0;n<e.length;n++)if(0===t.localeCompare(e[n],void 0,{sensitivity:"base"}))return e[n];return null};const Vl=([e,t],n,r)=>{let i=e,{begin:s,end:o}=n;const{value:a}=n;return s-=r,o=o-r-1,i=`${i.slice(0,s)}${a}${i.slice(o+1)}`,[i,[...t,{...n,begin:s,end:o}]]};Ul.reduceTextFromReferences=(e,t)=>t.reduce(Vl,[e,[]]);var Wl=Ul;
2021-01-29 23:34:36 +01:00
/**
* @module converse-muc
* @copyright The Converse.js contributors
* @license Mozilla Public License (MPLv2)
* @description Implements the non-view logic for XEP-0045 Multi-User Chat
2021-07-03 16:04:46 +02:00
*/const Gl=["moderator","participant","visitor"],Jl=["owner","admin","member","outcast","none"];sl.MUC_TRAFFIC_STATES=["entered","exited"],sl.MUC_ROLE_CHANGES=["op","deop","voice","mute"];const Ql=["301","303","333","307","321","322"],Yl={moderator:1,participant:2,visitor:3,none:2},{Strophe:Kl,$iq:Xl,$build:Zl,$msg:eu,$pres:tu,sizzle:nu}=sl.env;Kl.addNamespace("MUC_ADMIN",Kl.NS.MUC+"#admin"),Kl.addNamespace("MUC_OWNER",Kl.NS.MUC+"#owner"),Kl.addNamespace("MUC_REGISTER","jabber:iq:register"),Kl.addNamespace("MUC_ROOMCONF",Kl.NS.MUC+"#roomconfig"),Kl.addNamespace("MUC_USER",Kl.NS.MUC+"#user"),Kl.addNamespace("MUC_HATS","xmpp:prosody.im/protocol/hats:1"),sl.MUC_NICK_CHANGED_CODE="303",sl.ROOM_FEATURES=["passwordprotected","unsecured","hidden","publicroom","membersonly","open","persistent","temporary","nonanonymous","semianonymous","moderated","unmoderated","mam_enabled"],sl.ROOMSTATUS={CONNECTED:0,CONNECTING:1,NICKNAME_REQUIRED:2,PASSWORD_REQUIRED:3,DISCONNECTED:4,ENTERED:5,DESTROYED:6},sl.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}=Vc;if(Qc.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_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_join_leave:!0,muc_show_logs_before_join:!1}),Qc.promises.add(["roomsAutoJoined"]),Qc.settings.get("locked_muc_domain")&&"string"!=typeof Qc.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");Vc.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")}},Vc.router.route("converse/room?jid=:jid",(async function(e){if(!ql.isValidMUCJID(e))return Dn.warn(`invalid jid "${e}" provided in url fragment`);await Qc.waitUntil("roomsAutoJoined"),Qc.settings.get("allow_bookmarks")&&await Qc.waitUntil("bookmarksInitialized"),Qc.rooms.open(e)})),Vc.getDefaultMUCNickname=function(){if(!Vc.xmppstatus)throw new Error("Can't call _converse.getDefaultMUCNickname before the statusInitialized has been fired.");const e=Vc.xmppstatus.getNickname();return e||(Qc.settings.get("muc_nickname_from_jid")?Kl.unescapeNode(Kl.getNodeFromJid(Vc.bare_jid)):void 0)},Vc.ChatRoomMessage=Vc.Message.extend({initialize(){this.checkValidity()&&(this.get("file")&&this.on("change:put",this.uploadFile,this),this.setTimerForEphemeralMessage()||this.setOccupant(),Qc.trigger("chatRoomMessageInitialized",this))},mayBeModerated(){return["all","moderator"].includes(Qc.settings.get("allow_message_retraction"))&&this.collection.chatbox.canModerateMessages()},checkValidity(){const e=Vc.Message.prototype.checkValidity.call(this);r
2021-01-29 23:34:36 +01:00
/**
* @module converse-bookmarks
* @description
* Converse.js plugin which adds views for bookmarks specified in XEP-0048.
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/
2021-03-19 19:26:15 +01:00
const{Strophe:ru,$iq:iu,sizzle:su}=sl.env,ou=sl.env.utils;function au(e){return su(`event[xmlns="${ru.NS.PUBSUB}#event"] items[node="${ru.NS.BOOKMARKS}"]`,e).length&&Qc.waitUntil("bookmarksInitialized").then(()=>Vc.bookmarks.createBookmarksFromStanza(e)).catch(e=>Dn.fatal(e)),!0}ru.addNamespace("BOOKMARKS","storage:bookmarks"),sl.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){const{_converse:t}=this.__super__;return e=e||t.getNicknameFromBookmark(this.get("jid")),this.__super__.getAndPersistNickname.call(this,e)}}},initialize(){const{__:e}=Vc;Qc.settings.extend({allow_bookmarks:!0,allow_public_bookmarks:!1,muc_respect_autojoin:!0}),Qc.promises.add("bookmarksInitialized"),Vc.getNicknameFromBookmark=function(e){if(!Vc.bookmarks||!Qc.settings.get("allow_bookmarks"))return null;const t=Vc.bookmarks.findWhere({jid:e});return t?t.get("nick"):void 0},Vc.Bookmark=Bs.extend({idAttribute:"jid",getDisplayName(){return ru.xmlunescape(this.get("name"))}}),Vc.Bookmarks=ia.extend({model:Vc.Bookmark,comparator:e=>e.get("name").toLowerCase(),initialize(){this.on("add",e=>this.openBookmarkedRoom(e).then(e=>this.markRoomAsBookmarked(e)).catch(e=>Dn.fatal(e))),this.on("remove",this.markRoomAsUnbookmarked,this),this.on("remove",this.sendBookmarkStanza,this);const e="converse.room-bookmarks"+Vc.bare_jid;this.fetched_flag=e+"fetched",this.browserStorage=Vc.createStore(e)},async openBookmarkedRoom(e){if(Qc.settings.get("muc_respect_autojoin")&&e.get("autojoin")){(await Qc.rooms.create(e.get("jid"),{nick:e.get("nick")})).maybeShow()}return e},fetchBookmarks(){const e=ou.getResolveablePromise();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=iu({type:"set",from:Vc.connection.jid}).c("pubsub",{xmlns:ru.NS.PUBSUB}).c("publish",{node:ru.NS.BOOKMARKS}).c("item",{id:"current"}).c("storage",{xmlns:ru.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:ru.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"),Qc.sendIQ(e)},onBookmarkError(t,n){Dn.error("Error while trying to add bookmark"),Dn.error(t),Qc.alert("error",e("Error"),[e("Sorry, something went wrong while trying to save your bookmark.")]),this.findWhere({jid:n.jid}).destroy()},fetchBookmarksFromServer(e){const t=iu({from:Vc.connection.jid,type:"get"}).c("pubsub",{xmlns:ru.NS.PUBSUB}).c("items",{node:ru.NS.BOOKMARKS});Qc.sendIQ(t).then(t=>this.onBookmarksReceived(e,t)).catch(t=>this.onBookmarksReceivedError(e,t))},markRoomAsBookmarked(e){const t=Vc.chatboxes.get(e.get("jid"));void 0!==t&&t.save("bookmarked",!0)},markRoomAsUnbookmarked(e){const t=Vc.chatboxes.get(e.get("jid"));void 0!==t&&t.save("bookmarked",!1)},createBookmarksFromStanza(e){const t=ru.NS.BOOKMARKS;su(`items[node="${t}"] item storage[xmlns="${t}"] conference`,e).forEach(e=>{var t;const n=e.getAttribute("jid"),r=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)||""};r?r.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(t,n){if(null===n)Dn.error("Error:
2021-01-29 23:34:36 +01:00
/**
* @module converse-bosh
* @copyright The Converse.js contributors
* @license Mozilla Public License (MPLv2)
* @description Converse.js plugin which add support for XEP-0206: XMPP Over BOSH
2021-03-19 19:26:15 +01:00
*/const{Strophe:cu}=sl.env;sl.plugins.add("converse-bosh",{enabled:()=>!Vc.api.settings.get("blacklisted_plugins").includes("converse-bosh"),initialize(){Qc.settings.extend({bosh_service_url:void 0,prebind_url:null}),Vc.startNewPreboundBOSHSession=function(){if(!Qc.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",Qc.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 Vc.setUserJID(t.jid);Vc.connection.attach(n,t.sid,t.rid,Vc.connection.onConnectStatusChanged)}else e.onerror()},e.onerror=function(){delete Vc.connection,Qc.trigger("noResumeableBOSHSession",Vc)},e.send()},Vc.restoreBOSHSession=async function(){const e=(await async function(){const e="converse.bosh-session";if(Vc.bosh_session||(Vc.bosh_session=new Bs({id:e}),Vc.bosh_session.browserStorage=Vc.createStore(e,"session"),await new Promise(e=>Vc.bosh_session.fetch({success:e,error:e}))),Vc.jid){if(Vc.bosh_session.get("jid")!==Vc.jid){const e=await Vc.setUserJID(Vc.jid);Vc.bosh_session.clear({silent:!0}),Vc.bosh_session.save({jid:e})}}else{const e=Vc.bosh_session.get("jid");e&&await Vc.setUserJID(e)}return Vc.bosh_session}()).get("jid");if(e&&Vc.connection._proto instanceof cu.Bosh)try{return Vc.connection.restore(e,Vc.connection.onConnectStatusChanged),!0}catch(t){return!Vc.isTestEnv()&&Dn.warn("Could not restore session for jid: "+e+" Error message: "+t.message),!1}return!1},Qc.listen.on("clearSession",()=>{if(void 0===Vc.bosh_session){const e="converse.bosh-session";sessionStorage.removeItem(e),sessionStorage.removeItem(`${e}-${e}`)}else Vc.bosh_session.destroy(),delete Vc.bosh_session}),Qc.listen.on("setUserJID",()=>{void 0!==Vc.bosh_session&&Vc.bosh_session.save({jid:Vc.jid})}),Qc.listen.on("addClientFeatures",()=>Qc.disco.own.features.add(cu.NS.BOSH)),Object.assign(Qc,{tokens:{get:e=>void 0===Vc.connection?null:"rid"===e.toLowerCase()?Vc.connection.rid||Vc.connection._proto.rid:"sid"===e.toLowerCase()?Vc.connection.sid||Vc.connection._proto.sid:void 0}})}});var lu=n(6);
2021-01-29 23:34:36 +01:00
/**
* @module converse-caps
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
2021-03-19 19:26:15 +01:00
*/const{Strophe:uu,$build:du}=sl.env;function hu(e,t){return e.sort((e,n)=>e[t]>n[t]?-1:1)}function fu(e){const t=e.api.disco.own.identities.get(),n=e.api.disco.own.features.get();t.length>1&&(hu(t,"category"),hu(t,"type"),hu(t,"lang"));let r=t.reduce((e,t)=>{var n;return`${e}${t.category}/${t.type}/${null!==(n=null==t?void 0:t.lang)&&void 0!==n?n:""}/${t.name}<`},"");return n.sort(),r=n.reduce((e,t)=>`${e}${t}<`,r),lu.a.b64_sha1(r)}
2021-01-29 23:34:36 +01:00
/**
* @module converse-carbons
* @copyright The Converse.js contributors
* @license Mozilla Public License (MPLv2)
* @description Implements support for XEP-0280 Message Carbons
*/
2021-03-19 19:26:15 +01:00
function pu(e){var t,n;e&&(null===(n=Vc.session)||void 0===n||n.set({carbons_enabled:!1}));if(!Qc.settings.get("message_carbons")||null!==(t=Vc.session)&&void 0!==t&&t.get("carbons_enabled"))return;const r=new Ta.e.Builder("iq",{from:Vc.connection.jid,id:"enablecarbons",type:"set"}).c("enable",{xmlns:Ta.e.NS.CARBONS});Vc.connection.addHandler(e=>{e.querySelectorAll("error").length>0?Dn.warn("An error occurred while trying to enable message carbons."):(Vc.session.set({carbons_enabled:!0}),Dn.debug("Message carbons have been enabled.")),Vc.session.save()},null,"iq",null,"enablecarbons"),Vc.connection.send(r)}uu.addNamespace("CAPS","http://jabber.org/protocol/caps"),sl.plugins.add("converse-caps",{overrides:{XMPPStatus:{constructPresence(){const e=this.__super__.constructPresence.apply(this,arguments);var t;return e.root().cnode((t=this.__super__._converse,du("c",{xmlns:uu.NS.CAPS,hash:"sha-1",node:"https://conversejs.org",ver:fu(t)}).nodeTree)),e}}}}),sl.plugins.add("converse-carbons",{initialize(){Qc.settings.extend({message_carbons:!0}),Qc.listen.on("afterResourceBinding",pu)}});
2021-01-29 23:34:36 +01:00
/**
* @module converse-chatboxes
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/
2021-03-19 19:26:15 +01:00
const{Strophe:gu}=sl.env;gu.addNamespace("MESSAGE_CORRECT","urn:xmpp:message-correct:0"),gu.addNamespace("RECEIPTS","urn:xmpp:receipts"),gu.addNamespace("REFERENCE","urn:xmpp:reference:0"),gu.addNamespace("MARKERS","urn:xmpp:chat-markers:0"),sl.plugins.add("converse-chatboxes",{dependencies:["converse-emoji","converse-roster","converse-vcard"],initialize(){async function e(e,t,n){let r;e=gu.getBareJidFromJid(e.toLowerCase()),Object.assign(t,{jid:e,id:e});try{r=new n(t,{collection:Vc.chatboxes})}catch(e){return Dn.error(e),null}return await r.initialized,r.isValid()?(Vc.chatboxes.add(r),r):(r.destroy(),null)}Qc.promises.add(["chatBoxesFetched","chatBoxesInitialized","privateChatsAutoJoined"]),Vc.ChatBoxes=ia.extend({comparator:"time_opened",model:(e,t)=>new Vc.ChatBox(e,t),onChatBoxesFetched(e){e.filter(e=>!e.isValid()).forEach(e=>e.destroy()),Qc.trigger("chatBoxesFetched")},onConnected(e){e||(this.browserStorage=Vc.createStore("converse.chatboxes-"+Vc.bare_jid),this.fetch({add:!0,success:e=>this.onChatBoxesFetched(e)}))}}),Qc.listen.on("addClientFeatures",()=>{Qc.disco.own.features.add(gu.NS.MESSAGE_CORRECT),Qc.disco.own.features.add(gu.NS.HTTPUPLOAD),Qc.disco.own.features.add(gu.NS.OUTOFBAND)}),Qc.listen.on("pluginsInitialized",()=>{Vc.chatboxes=new Vc.ChatBoxes,Qc.trigger("chatBoxesInitialized")}),Qc.listen.on("presencesInitialized",e=>Vc.chatboxes.onConnected(e)),Qc.listen.on("reconnected",()=>Vc.chatboxes.forEach(e=>e.onReconnection())),Object.assign(Qc,{chatboxes:{create:async(t=[],n={},r)=>(await Qc.waitUntil("chatBoxesFetched"),"string"==typeof t?e(t,n,r):Promise.all(t.map(t=>e(t,n,r)))),get:async e=>(await Qc.waitUntil("chatBoxesFetched"),void 0===e?Vc.chatboxes.models:"string"==typeof e?Vc.chatboxes.get(e.toLowerCase()):(e=e.map(e=>e.toLowerCase()),Vc.chatboxes.models.filter(t=>e.includes(t.get("jid")))))}})}}),sl.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(){Vc.connection.addHandler(e=>async function(e){if(go.isHeadline(e)||go.isServerMessage(e)){const t=e.getAttribute("from");if(t.includes("@")&&!Vc.roster.get(t)&&!Qc.settings.get("allow_non_roster_messaging"))return;if(null===e.querySelector("body"))return;const n=Vc.chatboxes.create({id:t,jid:t,type:Vc.HEADLINES_TYPE,from:t}),r=await go.parseMessage(e,Vc);await n.createMessage(r),Qc.trigger("message",{chatbox:n,stanza:e,attrs:r})}}(e)||!0,null,"message")}Vc.HeadlinesBox=Vc.ChatBox.extend({defaults(){return{bookmarked:!1,hidden:["mobile","fullscreen"].includes(Qc.settings.get("view_mode")),message_type:"headline",num_unread:0,time_opened:this.get("time_opened")||(new Date).getTime(),type:Vc.HEADLINES_TYPE}},async initialize(){this.set({box_id:"box-"+this.get("jid")}),this.initMessages(),await this.fetchMessages(),Qc.trigger("headlinesBoxInitialized",this)}}),Qc.listen.on("connected",e),Qc.listen.on("reconnected",e),Object.assign(Qc,{headlines:{async get(e,t={},n=!1){async function r(e){let r=await Qc.chatboxes.get(e);return!r&&n?r=await Qc.chatboxes.create(e,t,Vc.HeadlinesBox):(r=r&&r.get("type")===Vc.HEADLINES_TYPE?r:null,r&&Object.keys(t).length&&r.save(t)),r}if(void 0===e){return(await Qc.chatboxes.get()).filter(e=>e.get("type")===Vc.HEADLINES_TYPE)}return"string"==typeof e?r(e):Promise.all(e.map(e=>r(e)))}}})}});
2021-01-29 23:34:36 +01:00
/**
* @module converse-rsm
* @copyright The Converse.js contributors
* @license Mozilla Public License (MPLv2)
* @description XEP-0059 Result Set Management
* Some code taken from the Strophe RSM plugin, licensed under the MIT License
* Copyright 2006-2017 Strophe (https://github.com/strophe/strophejs)
*/
2021-03-19 19:26:15 +01:00
const{Strophe:mu,$build:vu}=sl.env;mu.addNamespace("RSM","http://jabber.org/protocol/rsm");const _u=["after","before","index","max"],bu=e=>Number(e),yu=e=>e.toString(),wu={after:yu,before:yu,count:bu,first:yu,index:bu,last:yu,max:bu},Su=e=>void 0===e,xu=Object.keys(wu);class Eu{static getQueryParameters(e={}){return Fs(e,_u)}static parseXMLResult(e){const t={};for(var n=0;n<xu.length;n++){const r=xu[n],i=e.getElementsByTagName(r)[0];Su(i)||null===i||(t[r]=wu[r](mu.getText(i)),"first"==r&&(t.index=wu.index(i.getAttribute("index"))))}return t}constructor(e={}){this.query=Eu.getQueryParameters(e),this.result=e.xml?Eu.parseXMLResult(e.xml):{}}toXML(){const e=vu("set",{xmlns:mu.NS.RSM});return _u.reduce((e,t)=>Su(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 Eu(n)}previous(e,t){const n=Object.assign({},this.query,{after:t,before:this.result.first,max:e});return new Eu(n)}}Vc.RSM_ATTRIBUTES=xu,Vc.RSM=Eu;
2021-01-29 23:34:36 +01:00
/**
* @module converse-mam
* @description XEP-0313 Message Archive Management
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
2021-03-19 19:26:15 +01:00
*/
const{Strophe:Au,$iq:Cu,dayjs:ku}=sl.env,{NS:ju}=Au,Tu=sl.env.utils,Ou={fetchNewestMessages(){if(this.disable_mam)return;const e=this.getMostRecentMessage();if(e&&!Qc.settings.get("clear_messages_on_reconnection")){const t=e.get("stanza_id "+this.get("jid"));t?this.fetchArchivedMessages({after:t},"forwards"):this.fetchArchivedMessages({start:e.get("time")},"forwards")}else this.fetchArchivedMessages({before:""})},async handleMAMResult(e,t,n,r){await Qc.emojis.initialize();const i=this.get("type")===Vc.CHATROOMS_TYPE;e.messages=e.messages.map(e=>i?go.parseMUCMessage(e,this,Vc):go.parseMessage(e,Vc));const s={query:t,chatbox:this,messages:e.messages};if(await Qc.trigger("MAMResult",s,{synchronous:!0}),e.messages.forEach(e=>this.queueMessage(e)),e.error){const t=e.error.retry_event_id=Tu.getUniqueId();Qc.listen.once(t,()=>this.fetchArchivedMessages(n,r)),this.createMessageFromError(e.error)}},async fetchArchivedMessages(e={},t){if(this.disable_mam)return;const n=this.get("type")===Vc.CHATROOMS_TYPE,r=n?this.get("jid"):Vc.bare_jid;if(!await Qc.disco.supports(ju.MAM,r))return;const i=Qc.settings.get("archived_messages_page_size"),s=Object.assign({groupchat:n,max:i,with:this.get("jid")},e),o=await Qc.archive.query(s);return await this.handleMAMResult(o,s,e,t),t&&o.rsm&&!o.complete?("forwards"===t?e=o.rsm.next(i,e.before).query:"backwards"===t&&(e=o.rsm.previous(i,e.after).query),this.fetchArchivedMessages(e,t)):void 0}};sl.plugins.add("converse-mam",{dependencies:["converse-disco","converse-muc"],initialize(){function e(e){Qc.settings.get("muc_show_logs_before_join")&&e.features.get("mam_enabled")&&!e.get("prejoin_mam_fetched")&&(e.fetchNewestMessages(),e.save({prejoin_mam_fetched:!0}))}Qc.settings.extend({archived_messages_page_size:"50",message_archiving:void 0,message_archiving_timeout:2e4}),Object.assign(Vc.ChatBox.prototype,Ou),Vc.onMAMError=function(e){null!=e&&e.querySelectorAll("feature-not-implemented").length?Dn.warn("Message Archive Management (XEP-0313) not supported by "+e.getAttribute("from")):(Dn.error(`Error while trying to set archiving preferences for ${e.getAttribute("from")}.`),Dn.error(e))},Vc.onMAMPreferences=function(e,t){const n=pr()(`prefs[xmlns="${ju.MAM}"]`,e).pop();if(n.getAttribute("default")!==Qc.settings.get("message_archiving")){const e=Cu({type:"set"}).c("prefs",{xmlns:ju.MAM,default:Qc.settings.get("message_archiving")});Array.from(n.children).forEach(t=>e.cnode(t).up()),Qc.sendIQ(e).then(()=>t.save({preferences:{default:Qc.settings.get("message_archiving")}})).catch(Vc.onMAMError)}else t.save({preferences:{default:Qc.settings.get("message_archiving")}})},Qc.listen.on("addClientFeatures",()=>Qc.disco.own.features.add(ju.MAM)),Qc.listen.on("serviceDiscovered",(function(e){const t=e.get("preferences")||{};e.get("var")===ju.MAM&&void 0!==Qc.settings.get("message_archiving")&&t.default!==Qc.settings.get("message_archiving")&&Qc.sendIQ(Cu({type:"get"}).c("prefs",{xmlns:ju.MAM})).then(t=>Vc.onMAMPreferences(t,e)).catch(Vc.onMAMError)})),Qc.listen.on("chatRoomViewInitialized",t=>{Qc.settings.get("muc_show_logs_before_join")&&(e(t.model),t.model.features.on("change:mam_enabled",()=>e(t.model)))}),Qc.listen.on("enteredNewRoom",e=>e.features.get("mam_enabled")&&e.fetchNewestMessages()),Qc.listen.on("chatReconnected",e=>{e.get("type")===Vc.PRIVATE_CHAT_TYPE&&e.fetchNewestMessages()}),Qc.listen.on("afterMessagesFetched",e=>{e.get("type")!==Vc.PRIVATE_CHAT_TYPE||Vc.connection.restored||e.fetchNewestMessages()}),Object.assign(Qc,{archive:{async query(e){if(!Qc.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||Vc.bare_jid;if(!await Qc.disco.supports(ju.MAM,n))return Dn.warn(`Did not fetch MAM archive for ${n} because it doesn't support ${ju.MAM}`),{messages:[]};const r=Tu.getUniqueId(),i=Cu(t).c("query",{xmlns:ju.MAM,queryid:r});if(e){i.c("x",{xmlns:ju
2021-01-29 23:34:36 +01:00
/**
* @module converse-ping
* @description
* Converse.js plugin which add support for application-level pings
* as specified in XEP-0199 XMPP Ping.
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/
2021-03-19 19:26:15 +01:00
const{Strophe:Nu,$iq:Iu}=sl.env,Mu=sl.env.utils;Nu.addNamespace("PING","urn:xmpp:ping"),sl.plugins.add("converse-ping",{initialize(){let e;function t(t){e=new Date;const n=t.getAttribute("from"),r=t.getAttribute("id"),i=Iu({type:"result",to:n,id:r});return Vc.connection.sendIQ(i),!0}Qc.settings.extend({ping_interval:60}),setTimeout(()=>{if(Qc.settings.get("ping_interval")>0){const t=new Date;return e||(e=t),!((t-e)/1e3>Qc.settings.get("ping_interval"))||Qc.ping()}},1e3);const n=function(){void 0!==Vc.connection.disco&&Qc.disco.own.features.add(Nu.NS.PING),Vc.connection.addHandler(t,Nu.NS.PING,"iq","get"),Vc.connection.addHandler(()=>{if(Qc.settings.get("ping_interval")>0)return e=new Date,!0})};Qc.listen.on("connected",n),Qc.listen.on("reconnected",n),Qc.listen.on("windowStateChanged",(function(e){"visible"===e.state&&Qc.connection.connected()&&Qc.ping(null,5e3)})),Object.assign(Qc,{async ping(t,n){if(e=new Date,t=t||Nu.getDomainFromJid(Vc.bare_jid),Vc.connection){const e=Iu({type:"get",to:t,id:Mu.getUniqueId("ping")}).c("ping",{xmlns:Nu.NS.PING}),r=await Qc.sendIQ(e,n||1e4,!1);return null===r?(Dn.warn("Timeout while pinging "+t),t===Nu.getDomainFromJid(Vc.bare_jid)&&Qc.connection.reconnect()):Mu.isErrorStanza(r)&&(Dn.error("Error while pinging "+t),Dn.error(r)),!0}return!1}})}});
2021-01-29 23:34:36 +01:00
/**
* @module converse-pubsub
* @copyright The Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/
2021-03-19 19:26:15 +01:00
const{Strophe:Ru,$iq:$u}=sl.env;Ru.addNamespace("PUBSUB_ERROR",Ru.NS.PUBSUB+"#errors"),sl.plugins.add("converse-pubsub",{dependencies:["converse-disco"],initialize(){Object.assign(Vc.api,{pubsub:{async publish(e,t,n,r,i=!0){const s=$u({from:Vc.bare_jid,type:"set",to:e}).c("pubsub",{xmlns:Ru.NS.PUBSUB}).c("publish",{node:t}).cnode(n.tree()).up().up();r&&(e=e||Vc.bare_jid,await Qc.disco.supports(Ru.NS.PUBSUB+"#publish-options",e)?(s.c("publish-options").c("x",{xmlns:Ru.NS.XFORM,type:"submit"}).c("field",{var:"FORM_TYPE",type:"hidden"}).c("value").t(Ru.NS.PUBSUB+"#publish-options").up().up(),Object.keys(r).forEach(e=>s.c("field",{var:e}).c("value").t(r[e]).up().up())):Dn.warn(`_converse.api.publish: ${e} does not support #publish-options, so we didn't set them even though they were provided.`));try{await Qc.sendIQ(s)}catch(e){if(!(e instanceof Element&&i&&e.querySelector(`precondition-not-met[xmlns="${Ru.NS.PUBSUB_ERROR}"]`)))throw e;{const e=s.nodeTree;e.querySelector("publish-options").outerHTML="",Dn.warn("PubSub: Republishing without publish options. "+e.outerHTML),await Qc.sendIQ(e)}}}}})}});var Du=function(e){return"number"==typeof e||Ee(e)&&"[object Number]"==O(e)};var Pu=function(e){return Du(e)&&e!=+e};
2021-01-29 23:34:36 +01:00
/**
* @module converse-status
* @copyright The Converse.js contributors
* @license Mozilla Public License (MPLv2)
2021-03-19 19:26:15 +01:00
*/const{Strophe:Lu,$build:zu,$pres:Fu}=sl.env;sl.plugins.add("converse-status",{initialize(){function e(e){Qc.trigger("statusInitialized",e)}function t(t){if(t=void 0!==Vc.xmppstatus&&t)e(t);else{const n="converse.xmppstatus-"+Vc.bare_jid;Vc.xmppstatus=new Vc.XMPPStatus({id:n}),Vc.xmppstatus.browserStorage=Vc.createStore(n,"session"),Vc.xmppstatus.fetch({success:()=>e(t),error:()=>e(t),silent:!0})}}Qc.settings.extend({auto_away:0,auto_xa:0,csi_waiting_time:0,default_state:"online",priority:0}),Qc.promises.add(["statusInitialized"]),Vc.XMPPStatus=Bs.extend({defaults:()=>({status:Qc.settings.get("default_state")}),initialize(){this.on("change",e=>{N(e.changed)&&("status"in e.changed||"status_message"in e.changed)&&Qc.user.presence.send(this.get("status"),null,this.get("status_message"))})},getNickname:()=>Vc.nickname,getFullname:()=>"",constructPresence(e,t=null,n){let r;e="string"==typeof e?e:this.get("status")||Qc.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,r=Fu(i)):"offline"===e?(i.type="unavailable",r=Fu(i)):r="online"===e?Fu(i):Fu(i).c("show").t(e).up(),n&&r.c("status").t(n).up();const s=Qc.settings.get("priority");if(r.c("priority").t(Pu(Number(s))?0:s).up(),Vc.idle){const e=new Date;e.setSeconds(e.getSeconds()-Vc.idle_seconds),r.c("idle",{xmlns:Lu.NS.IDLE,since:e.toISOString()})}return r}}),Vc.sendCSI=function(e){Qc.send(zu(e,{xmlns:Lu.NS.CSI})),Vc.inactive=e===Vc.INACTIVE},Vc.onUserActivity=function(){var e;Vc.idle_seconds>0&&(Vc.idle_seconds=0),null!==(e=Vc.connection)&&void 0!==e&&e.authenticated&&(Vc.inactive&&Vc.sendCSI(Vc.ACTIVE),Vc.idle&&(Vc.idle=!1,Qc.user.presence.send()),!0===Vc.auto_changed_status&&(Vc.auto_changed_status=!1,Vc.xmppstatus.set("status",Qc.settings.get("default_state"))))},Vc.onEverySecond=function(){var e;if(null===(e=Vc.connection)||void 0===e||!e.authenticated)return;const t=Vc.xmppstatus.get("status");Vc.idle_seconds++,Qc.settings.get("csi_waiting_time")>0&&Vc.idle_seconds>Qc.settings.get("csi_waiting_time")&&!Vc.inactive&&Vc.sendCSI(Vc.INACTIVE),Qc.settings.get("idle_presence_timeout")>0&&Vc.idle_seconds>Qc.settings.get("idle_presence_timeout")&&!Vc.idle&&(Vc.idle=!0,Qc.user.presence.send()),Qc.settings.get("auto_away")>0&&Vc.idle_seconds>Qc.settings.get("auto_away")&&"away"!==t&&"xa"!==t&&"dnd"!==t?(Vc.auto_changed_status=!0,Vc.xmppstatus.set("status","away")):Qc.settings.get("auto_xa")>0&&Vc.idle_seconds>Qc.settings.get("auto_xa")&&"xa"!==t&&"dnd"!==t&&(Vc.auto_changed_status=!0,Vc.xmppstatus.set("status","xa"))},Vc.registerIntervalHandler=function(){if(Qc.settings.get("auto_away")<1&&Qc.settings.get("auto_xa")<1&&Qc.settings.get("csi_waiting_time")<1&&Qc.settings.get("idle_presence_timeout")<1)return;Vc.idle_seconds=0,Vc.auto_changed_status=!1;const{unloadevent:e}=Vc;window.addEventListener("click",Vc.onUserActivity),window.addEventListener("focus",Vc.onUserActivity),window.addEventListener("keypress",Vc.onUserActivity),window.addEventListener("mousemove",Vc.onUserActivity),window.addEventListener(e,Vc.onUserActivity,{once:!0,passive:!0}),window.addEventListener(e,()=>{var e;return null===(e=Vc.session)||void 0===e?void 0:e.save("active",!1)}),Vc.everySecondTrigger=window.setInterval(Vc.onEverySecond,1e3)},Qc.listen.on("presencesInitialized",e=>{e||Vc.registerIntervalHandler()}),Qc.listen.on("clearSession",()=>{Vc.shouldClearCache()&&Vc.xmppstatus&&(Vc.xmppstatus.destroy(),delete Vc.xmppstatus,Qc.promises.add(["statusInitialized"]))}),Qc.listen.on("connected",()=>t(!1)),Qc.listen.on("reconnected",()=>t(!0)),Object.assign(Vc.api.user,{presence:{async send(e,t,n){await Qc.waitUntil("statusInitialized"),Qc.send(Vc.xmppstatus.constructPresence(e,t,n))}},status:{get:async()=>(await Qc.waitUntil("statusInitialized"),Vc.xmppstatus.get("status")),async set(e,t){const n={status:e};if(!Object.keys(Vc.STATUS_WEIGHTS).includes(e))throw new Error("Invalid availability value. See https://xmpp.org/rfcs/rfc3921.html#rfc.
2021-01-29 23:34:36 +01:00
/**
* @module converse-roster
* @copyright The Converse.js contributors
* @license Mozilla Public License (MPLv2)
2021-03-19 19:26:15 +01:00
*/const{Strophe:Hu,$iq:Vu,$pres:Wu,dayjs:Gu,sizzle:Ju}=sl.env,Qu=sl.env.utils;sl.plugins.add("converse-roster",{dependencies:["converse-status"],initialize(){const{__:e}=Vc;Qc.settings.extend({allow_contact_requests:!0,auto_subscribe:!1,synchronize_availability:!0}),Qc.promises.add(["cachedRoster","roster","rosterContactsFetched","rosterGroupsFetched","rosterInitialized"]),Vc.HEADER_CURRENT_CONTACTS=e("My contacts"),Vc.HEADER_PENDING_CONTACTS=e("Pending contacts"),Vc.HEADER_REQUESTING_CONTACTS=e("Contact requests"),Vc.HEADER_UNGROUPED=e("Ungrouped"),Vc.HEADER_UNREAD=e("New messages");const t={};t[Vc.HEADER_UNREAD]=0,t[Vc.HEADER_REQUESTING_CONTACTS]=1,t[Vc.HEADER_CURRENT_CONTACTS]=2,t[Vc.HEADER_UNGROUPED]=3,t[Vc.HEADER_PENDING_CONTACTS]=4,Vc.registerPresenceHandler=function(){Vc.unregisterPresenceHandler(),Vc.presence_ref=Vc.connection.addHandler(e=>(Vc.roster.presenceHandler(e),!0),null,"presence",null)},Vc.rejectPresenceSubscription=function(e,t){const n=Wu({to:e,type:"unsubscribed"});t&&""!==t&&n.c("status").t(t),Qc.send(n)},Vc.sendInitialPresence=function(){Vc.send_initial_presence&&Qc.user.presence.send()},Vc.populateRoster=async function(e=!1){e&&(Vc.send_initial_presence=!0);try{await Vc.rostergroups.fetchRosterGroups(),Qc.trigger("rosterGroupsFetched"),await Vc.roster.fetchRosterContacts(),Qc.trigger("rosterContactsFetched")}catch(e){Dn.error(e)}finally{Vc.sendInitialPresence()}};const n=Bs.extend({idAttribute:"name"}),r=ia.extend({model:n});function i(e){const t=Vc.roster&&Vc.roster.findWhere({jid:e.get("jid")});void 0!==t&&t.save({num_unread:e.get("num_unread")})}async function s(){Vc.presences&&await Vc.presences.clearStore()}Vc.Presence=Bs.extend({defaults:{show:"offline"},initialize(){this.resources=new r;const e="converse.identities-"+this.get("jid");this.resources.browserStorage=Vc.createStore(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=>`${e.get("priority")}-${e.get("timestamp")}`).reverse()[0]},addResource(e){const t=e.getAttribute("from"),n=Hu.getResourceFromJid(t),r=Ju(`delay[xmlns="${Hu.NS.DELAY}"]`,e).pop(),i=Bu(e.querySelector("priority"))("textContent")||0,s=this.resources.get(n),o={name:n,priority:Pu(parseInt(i,10))?0:parseInt(i,10),show:Bu(e.querySelector("show"))("textContent")||"online",timestamp:r?Gu(r.getAttribute("stamp")).toISOString():(new Date).toISOString()};s?s.save(o):this.resources.create(o)},removeResource(e){const t=this.resources.get(e);t&&t.destroy()}}),Vc.Presences=ia.extend({model:Vc.Presence}),Vc.RosterContact=Bs.extend({defaults:{chat_state:void 0,image:Vc.DEFAULT_IMAGE,image_type:Vc.DEFAULT_IMAGE_TYPE,num_unread:0,status:void 0},async initialize(e){this.initialized=Qu.getResolveablePromise(),this.setPresence();const{jid:t}=e,n=Hu.getBareJidFromJid(t).toLowerCase();e.jid=n,this.set(Object.assign({groups:[],id:n,jid:n,user_id:Hu.getNodeFromJid(t)},e)),this.listenTo(this.presence,"change:show",()=>Qc.trigger("contactPresenceChanged",this)),this.listenTo(this.presence,"change:show",()=>this.trigger("presenceChanged")),await Qc.trigger("rosterContactInitialized",this,{Synchronous:!0}),this.initialized.resolve()},setPresence(){const e=this.get("jid");this.presence=Vc.presences.findWhere({jid:e})||Vc.presences.create({jid:e})},openChat(){const e=this.attributes;Qc.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(" "+t),n=n.includes(e)?n:n.concat(" "+e),n.toLowerCase()},getDisplayName(){return this.get("nickname")?this.get("nickname"):this.get("jid")},getFullname(){return this.get("jid")},subscribe(e){const t=Wu({to:this.get("jid"),type:"subscribe"});e&&""!==e&&t.c("status").t(e).up();const n=Vc.xmppstatus.getNickname()||Vc.xmppstatus.getFul
2021-01-29 23:34:36 +01:00
/**
* @module converse-smacks
* @copyright The Converse.js contributors
* @license Mozilla Public License (MPLv2)
* @description Converse.js plugin which adds support for XEP-0198: Stream Management
*/
2021-03-19 19:26:15 +01:00
const{Strophe:Yu}=sl.env,Ku=sl.env.utils;function Xu(){return!(Qc.connection.isType("bosh")&&!Vc.isTestEnv())&&Qc.disco.stream.getFeature("sm",Yu.NS.SM)}function Zu(e){if(!Vc.session.get("smacks_enabled"))return!0;const t=parseInt(e.getAttribute("h"),10),n=Vc.session.get("num_stanzas_handled_by_server"),r=t-n;if(r<0){const e=`New reported stanza count lower than previous. New: ${t} - Previous: ${n}`;Dn.error(e)}const i=Vc.session.get("unacked_stanzas");if(r>i.length){const e=`Higher reported acknowledge count than unacknowledged stanzas. Reported Acknowledged Count: ${r} -Unacknowledged Stanza Count: ${i.length} -New: ${t} - Previous: ${n}`;Dn.error(e)}return Vc.session.save({num_stanzas_handled_by_server:t,num_stanzas_since_last_ack:0,unacked_stanzas:i.slice(r)}),!0}function ed(){if(Vc.session.get("smacks_enabled")){const e=Vc.session.get("num_stanzas_handled"),t=Ku.toStanza(`<a xmlns="${Yu.NS.SM}" h="${e}"/>`);Qc.send(t)}return!0}function td(e){if(Vc.session.get("smacks_enabled")&&(Ku.isTagEqual(e,"iq")||Ku.isTagEqual(e,"presence")||Ku.isTagEqual(e,"message"))){const e=Vc.session.get("num_stanzas_handled");Vc.session.save("num_stanzas_handled",e+1)}return!0}function nd(){Vc.session.save({smacks_enabled:Vc.session.get("smacks_enabled")||!1,num_stanzas_handled:Vc.session.get("num_stanzas_handled")||0,num_stanzas_handled_by_server:Vc.session.get("num_stanzas_handled_by_server")||0,num_stanzas_since_last_ack:Vc.session.get("num_stanzas_since_last_ack")||0,unacked_stanzas:Vc.session.get("unacked_stanzas")||[]})}function rd(){Vc.session&&Vc.session.save({smacks_enabled:!1,num_stanzas_handled:0,num_stanzas_handled_by_server:0,num_stanzas_since_last_ack:0,unacked_stanzas:[]})}function id(e){const t={smacks_enabled:!0};return["1","true"].includes(e.getAttribute("resume"))&&(t.smacks_stream_id=e.getAttribute("id")),Vc.session.save(t),!0}function sd(e){return e.querySelector("item-not-found")?Dn.warn("Could not resume previous SMACKS session, session id not found. A new session will be established."):(Dn.error("Failed to enable stream management"),Dn.error(e.outerHTML)),rd(),Qc.trigger("streamResumptionFailed"),!0}function od(e){id(e),Zu(e),function(){const e=Vc.session.get("unacked_stanzas");Vc.session.save("unacked_stanzas",[]),e.forEach(e=>Qc.send(e))}(),Vc.connection.do_bind=!1,Vc.connection.authenticated=!0,Vc.connection.restored=!0,Vc.connection._changeConnectStatus(Yu.Status.CONNECTED,null)}async function ad(){if(Qc.settings.get("enable_smacks")&&!Vc.session.get("smacks_enabled")&&await Xu()){const e=Ku.getResolveablePromise();Vc.connection._addSysHandler(t=>e.resolve(id(t)),Yu.NS.SM,"enabled"),Vc.connection._addSysHandler(t=>e.resolve(sd(t)),Yu.NS.SM,"failed");const t=Qc.connection.isType("websocket")||Vc.isTestEnv(),n=Ku.toStanza(`<enable xmlns="${Yu.NS.SM}" resume="${t}"/>`);Qc.send(n),Vc.connection.flush(),await e}}Yu.addNamespace("SM","urn:xmpp:sm:3");const cd=[];async function ld(){if(!Qc.settings.get("enable_smacks"))return;if(!await Xu())return;const e=Vc.connection;for(;cd.length;)e.deleteHandler(cd.pop());cd.push(e.addHandler(td)),cd.push(e.addHandler(ed,Yu.NS.SM,"r")),cd.push(e.addHandler(Zu,Yu.NS.SM,"a")),Vc.session.get("smacks_stream_id")?await async function(){const e=Ku.getResolveablePromise();Vc.connection._addSysHandler(t=>e.resolve(od(t)),Yu.NS.SM,"resumed"),Vc.connection._addSysHandler(t=>e.resolve(sd(t)),Yu.NS.SM,"failed");const t=Vc.session.get("smacks_stream_id"),n=Vc.session.get("num_stanzas_handled"),r=Ku.toStanza(`<resume xmlns="${Yu.NS.SM}" h="${n}" previd="${t}"/>`);Qc.send(r),Vc.connection.flush(),await e}():rd()}function ud(e){if(Vc.session){if(Vc.session.get("smacks_enabled")&&(Ku.isTagEqual(e,"iq")||Ku.isTagEqual(e,"presence")||Ku.isTagEqual(e,"message"))){const t=Yu.serialize(e);Vc.session.save("unacked_stanzas",(Vc.session.get("unacked_stanzas")||[]).concat([t]));const n=Qc.settings.get("smacks_max_unacked_stanzas");if(n>0){const e=Vc.session.get("num_stanzas_since_last_ack")+1;e%n==0&&Qc.send(Ku.toStanza(`<r xmlns="${Yu.NS.SM}"/>`)),Vc.session.save({num_stanzas_since_last_ack:e})}}}else D
2021-01-29 23:34:36 +01:00
/**
* @module converse-vcard
* @copyright The Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/
2021-03-19 19:26:15 +01:00
const{Strophe:dd,$iq:hd,dayjs:fd}=sl.env,pd=sl.env.utils;sl.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 r=hd(t?{type:e,to:t}:{type:e});return n?r.cnode(n):r.c("vCard",{xmlns:dd.NS.VCARD}),r}async function t(t,n){const r=dd.getBareJidFromJid(n)===t.bare_jid?null:n;let i;try{i=await Qc.sendIQ(e("get",r))}catch(i){return{stanza:i,jid:n,vcard_error:(new Date).toISOString()}}return async function(e,t){const n=t.querySelector("vCard");let r={};var i,s,o,a,c,l,u;if(null!==n&&(r={stanza:t,fullname:null===(i=n.querySelector("FN"))||void 0===i?void 0:i.textContent,nickname:null===(s=n.querySelector("NICKNAME"))||void 0===s?void 0:s.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}),r.image){const e=pd.base64ToArrayBuffer(r.image),t=await crypto.subtle.digest("SHA-1",e);r.image_hash=pd.arrayBufferToHex(t)}return r}(0,i)}async function n(e){let t;if(e instanceof Vc.Message){if("error"===e.get("type"))return;t=e.get("from")}else t=e.get("jid");await Qc.waitUntil("VCardsInitialized"),e.vcard=Vc.vcards.findWhere({jid:t}),e.vcard||(e.vcard=Vc.vcards.create({jid:t})),e.vcard.on("change",()=>e.trigger("vcard:change"))}async function r(e){await Qc.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,r=dd.getResourceFromJid(e.get("from"));if(n&&n.get("nick")===r)return Vc.xmppstatus.vcard;{const t=e.occupant&&e.occupant.get("jid")||e.get("from");return t?Vc.vcards.findWhere({jid:t})||Vc.vcards.create({jid:t}):void Dn.error("Could not assign VCard for message because no JID found! msgid: "+e.get("msgid"))}}(e))}Qc.promises.add("VCardsInitialized"),Vc.VCard=Bs.extend({defaults:{image:Vc.DEFAULT_IMAGE,image_type:Vc.DEFAULT_IMAGE_TYPE},set(e,t,n){let r;return"object"==typeof e?(r=e,n=t):(r={})[e]=t,"image"in r&&!r.image?(r.image=Vc.DEFAULT_IMAGE,r.image_type=Vc.DEFAULT_IMAGE_TYPE,Bs.prototype.set.call(this,r,n)):Bs.prototype.set.apply(this,arguments)},getDisplayName(){return this.get("nickname")||this.get("fullname")||this.get("jid")}}),Vc.VCards=ia.extend({model:Vc.VCard,initialize(){this.on("add",e=>e.get("jid")&&Qc.vcard.update(e))}}),Vc.initVCardCollection=async function(){Vc.vcards=new Vc.VCards,Vc.vcards.browserStorage=Vc.createStore(Vc.bare_jid+"-converse.vcards"),await new Promise(e=>{Vc.vcards.fetch({success:e,error:e},{silent:!0})});const e=Vc.vcards;if(Vc.session){const t=Vc.session.get("bare_jid");Vc.xmppstatus.vcard=e.findWhere({jid:t})||e.create({jid:t})}Qc.trigger("VCardsInitialized")},Qc.listen.on("chatBoxInitialized",e=>n(e)),Qc.listen.on("chatRoomInitialized",e=>n(e)),Qc.listen.on("chatRoomMessageInitialized",e=>r(e)),Qc.listen.on("addClientFeatures",()=>Qc.disco.own.features.add(dd.NS.VCARD)),Qc.listen.on("clearSession",()=>{Vc.shouldClearCache()&&(Qc.promises.add("VCardsInitialized"),Vc.vcards&&(Vc.vcards.clearStore(),delete Vc.vcards))}),Qc.listen.on("messageInitialized",e=>n(e)),Qc.listen.on("rosterContactInitialized",e=>n(e)),Qc.listen.on("statusInitialized",
2021-01-29 23:34:36 +01:00
/**
* @module i18n
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
* @description This is the internationalization module
*/
2021-03-19 19:26:15 +01:00
function(e){let t;if(window.navigator.userLanguage&&(t=bd(window.navigator.userLanguage,e)),window.navigator.languages&&!t)for(let n=0;n<window.navigator.languages.length&&!t;n++)t=bd(window.navigator.languages[n],e);return window.navigator.browserLanguage&&!t&&(t=bd(window.navigator.browserLanguage,e)),window.navigator.language&&!t&&(t=bd(window.navigator.language,e)),window.navigator.systemLanguage&&!t&&(t=bd(window.navigator.systemLanguage,e)),t||"en"}(t)||"en":e}function bd(e,t){if(t(e))return e;var n=e.split("-")[0];return n!==e&&t(n)?n:void 0}let yd;Object.assign(Hc,{getLocale:(e,t)=>_d(e,e=>vd(e,t)),translate(e){if(!yd)return md.a.sprintf.apply(md.a,arguments);const t=yd.translate(e);return arguments.length>1?t.fetch.apply(t,[].slice.call(arguments,1)):t.fetch()},async initialize(){if(Vc.isTestEnv())Vc.locale="en";else try{const e=Qc.settings.get("i18n");Vc.locale=Hc.getLocale(e,Qc.settings.get("locales")),await async function(e){const{api:t,locale:r}=e,i=r.toLowerCase().replace("_","-");if(!vd(r,t.settings.get("locales"))||"en"===r)return;const{default:s}=await n(492)(`./${r}/LC_MESSAGES/converse.po`);await n(493)("./"+i),Sn.a.locale(_d(i,e=>Sn.a.locale(e))),yd=new md.a(s)}(Vc)}catch(e){Dn.fatal(e.message),Vc.locale="en"}},__:(...e)=>Hc.translate(...e)});const wd=Hc.__,Sd={};Qc.elements={registry:Sd,define:function(e,t){this.registry[e]=t},register:function(){Object.keys(Sd).forEach(e=>{customElements.get(e)||customElements.define(e,Sd[e])})}};
2021-01-29 23:34:36 +01:00
/**
* @module converse-autocomplete
* @copyright Lea Verou and the Converse.js contributors
* @description
* Converse.js plugin which started as a fork of Lea Verou's Awesomplete
* https://leaverou.github.io/awesomplete/
* @license Mozilla Public License (MPLv2)
*/
2021-03-19 19:26:15 +01:00
const xd=sl.env.utils,Ed=function(e,t){return RegExp(jd.regExpEscape(t.trim()),"i").test(e)},Ad=function(e,t){return RegExp("^"+jd.regExpEscape(t.trim()),"i").test(e)},Cd=function(e,t){const n=e.query.toLowerCase(),r=e.label.toLowerCase().indexOf(n),i=t.label.toLowerCase().indexOf(n);return r===i?function(e,t){return e.length!==t.length?e.length-t.length:e<t?-1:1}(e,t):(-1===r?1/0:r)<(-1===i?1/0:i)?-1:1},kd=(e,t)=>{t=t.trim();const n=document.createElement("li");n.setAttribute("aria-selected","false");const r=new RegExp("("+t+")","ig");return(t?e.split(r):[e]).forEach(e=>{if(t&&e.match(r)){const t=document.createElement("mark");t.textContent=e,n.appendChild(t)}else n.appendChild(document.createTextNode(e))}),n},jd={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 r=t[n];n.split(/\s+/).forEach(t=>e.addEventListener(t,r))}},unbind(e,t){if(e)for(var n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const r=t[n];n.split(/\s+/).forEach(t=>e.removeEventListener(t,r))}},regExpEscape:e=>e.replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&")};class Td 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()}}class Od{constructor(e,t={}){this.is_opened=!1,xd.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:Ed,sort:!1!==t.sort&&Cd,item:kd},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)}},jd.bind(this.input,this._events.input),jd.bind(this.input.form,this._events.form),jd.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=jd.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,r=e.label||t;return""!==n?{label:r,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?xd.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(){jd.unbind(this.input,this._events.input),jd.unbind(this.input.form,this._events.form),this.input.removeAttribute("aria-autocomplete")}next(){const e=this.ul.children.length;this.goto(this.index<e-1?this.index+1:e?0:-1)}previous(){const e=this.ul.children.length,t=this.index-1;this.goto(this.selected&&-1!==t?t:e-1)}goto(e){const t=this.ul.children;this.selected&&t[this.index].setAttribute("aria-selected","false"),this.index=e,e>-1&&t.length>0&&(t[e].setAttribute("aria-selected","true"),t[e].focus(),this.statu
<div class="list-container list-container--bookmarks ${e.hidden?"":"hidden"}">
<a class="list-toggle bookmarks-toggle controlbox-padded"
title="${t}"
@click=${e.toggleBookmarksList}>
<span class="fa ${e.toggle_state===e._converse.OPENED?"fa-caret-down":"fa-caret-right"}">
</span> ${n}</a>
<div class="items-list bookmarks rooms-list ${e.toggle_state!==e._converse.OPENED?"hidden":""}">
${e.bookmarks.map(t=>(e=>{const t=wd("Unbookmark this groupchat"),n=wd("Click to open this groupchat");return wc`
<div class="list-item controlbox-padded room-item available-chatroom d-flex flex-row ${e.is_hidden(e.bm)?"hidden":""}" data-room-jid="${e.bm.get("jid")}">
<a class="list-item-link open-room w-100" data-room-jid="${e.bm.get("jid")}"
title="${n}"
@click=${e.openRoom}>${e.bm.getDisplayName()}</a>
<a class="list-item-action remove-bookmark fa fa-bookmark align-self-center ${e.bm.get("bookmarked")?"button-on":""}"
data-room-jid="${e.bm.get("jid")}"
data-bookmark-name="${e.bm.getDisplayName()}"
title="${t}"
@click=${e.removeBookmark}></a>
</div>
`})(Object.assign({bm:t},e)))}
</div>
</div>
`};const Id=/^\s*</,Md=("undefined"!=typeof Element&&Element.prototype,function(e){this.cid=_i("view"),this._domEvents=[],this.preinitialize.apply(this,arguments),kr(this,Fs(e,$d)),this._ensureElement(),this.initialize.apply(this,arguments)});Md.extend=Qr;const Rd=/^(\S+)\s*(.*)$/,$d=["model","collection","el","id","attributes","className","tagName","events"];Object.assign(Md.prototype,bi,{tagName:"div",$:function(e){return this.el.querySelectorAll(e)},preinitialize:function(){},initialize:function(){},render:function(){return M(this.beforeRender)&&this.beforeRender(),M(this.toHTML)&&bc(this.toHTML(),this.el),M(this.afterRender)&&this.afterRender(),this},remove:function(){return this._removeElement(),this.stopListening(),this},_removeElement:function(){this.undelegateEvents(),this.el.parentNode&&this.el.parentNode.removeChild(this.el)},setElement:function(e){return this.undelegateEvents(),this._setElement(e),this.delegateEvents(),this},_setElement:function(e){if("string"==typeof e)if(Id.test(e)){const t=document.createElement("div");t.innerHTML=e,this.el=t.firstChild}else this.el=document.querySelector(e);else e&&!Mn(e)&&e.length?this.el=e[0]:this.el=e},delegateEvents:function(e){if(e||(e=Jr(this,"events")),!e)return this;this.undelegateEvents();for(const t in e){let n=e[t];if(M(n)||(n=this[n]),!n)continue;const r=t.match(Rd);this.delegate(r[1],r[2],n.bind(this))}return this},delegate:function(e,t,n){const r=this.el;if(!r)return this;if("function"==typeof t&&(n=t,t=null),-1!==["focus","blur"].indexOf(e)){const r=this.el.querySelectorAll(t);for(let t=0,i=r.length;t<i;t++){const i=r[t];i.addEventListener(e,n,!1),this._domEvents.push({el:i,eventName:e,handler:n})}return n}const i=t?function(e){let i=e.target||e.srcElement;for(;i&&i!=r;i=i.parentNode)i.matches(t)&&(e.delegateTarget=i,n(e))}:n;return this.el.addEventListener(e,i,!1),this._domEvents.push({el:this.el,eventName:e,handler:i,listener:n,selector:t}),this},undelegateEvents:function(){if(this.el){for(let e=0,t=this._domEvents.length;e<t;e++){const t=this._domEvents[e];t.el.removeEventListener(t.eventName,t.handler,!1)}this._domEvents.length=0}return this},undelegate:function(e,t,n){if("function"==typeof t&&(n=t,t=null),this.el){const r=this._domEvents.slice();let i=r.length;for(;i--;){const s=r[i];!(s.eventName!==e||n&&s.listener!==n||t&&s.selector!==t)&&(s.el.removeEventListener(s.eventName,s.handler,!1),this._domEvents.splice(i,1))}}return this},_createElement:function(e){return document.createElement(e)},_ensureElement:function(){if(this.el)this.setElement(Jr(this,"el"));else{const e=kr({},Jr(this,"attributes"));this.id&&(e.id=Jr(this,"id")),this.className&&(e.class=Jr(this,"className")),this.setElement(this._createElement(Jr(this,"tagName"))),this._setAttributes(e)}},_setAttributes:function(e){for(const t in e)t in this.el?this.el[t]=e[t]:this.el.setAttribute(t,e[t])}});var Dd=Ar((function(e,t,n){var r=-1,i="function"==typeof t,s=Qe(e)?Array(e.length):[];return _o(e,(function(e){s[++r]=i?_r(t,e,n):Ra(e,t,n)})),s}));
2021-01-29 23:34:36 +01:00
/**
* @module converse-bookmark-views
* @description Converse.js plugin which adds views for XEP-0048 bookmarks
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/
2021-03-19 19:26:15 +01:00
const{Strophe:Pd}=sl.env,Ld=sl.env.utils;sl.plugins.add("converse-bookmark-views",{dependencies:["converse-chatboxes","converse-muc","converse-muc-views"],initialize(){Qc.settings.extend({hide_open_bookmarks:!0}),Object.assign(Vc,{removeBookmarkViaEvent(e){e.preventDefault();const t=e.target.getAttribute("data-bookmark-name"),n=e.target.getAttribute("data-room-jid");confirm(wd('Are you sure you want to remove the bookmark "%1$s"?',t))&&Dd(Vc.bookmarks.where({jid:n}),Bs.prototype.destroy)},addBookmarkViaEvent(e){e.preventDefault();const t=e.target.getAttribute("data-room-jid");Qc.rooms.open(t,{bring_to_foreground:!0}),Vc.chatboxviews.get(t).renderBookmarkForm()}});const e={setBookmarkState(){if(void 0!==Vc.bookmarks){Vc.bookmarks.where({jid:this.model.get("jid")}).length?this.model.save("bookmarked",!0):this.model.save("bookmarked",!1)}},renderBookmarkForm(){if(this.hideChatRoomContents(),!this.bookmark_form){this.bookmark_form=new Vc.MUCBookmarkForm({model:this.model,chatroomview:this});this.el.querySelector(".chatroom-body").insertAdjacentElement("beforeend",this.bookmark_form.el)}Ld.showElement(this.bookmark_form.el)},toggleBookmark(e){null==e||e.preventDefault();const t=Vc.bookmarks.where({jid:this.model.get("jid")});t.length?t.forEach(e=>e.destroy()):this.renderBookmarkForm()}};Object.assign(Vc.ChatRoomView.prototype,e),Vc.MUCBookmarkForm=Md.extend({className:"muc-bookmark-form chatroom-form-container",initialize(e){this.chatroomview=e.chatroomview,this.render()},toHTML(){return(e=>{const t=wd("Bookmark this groupchat"),n=wd("Would you like this groupchat to be automatically joined upon startup?"),r=wd("Cancel"),i=wd("The name for this bookmark:"),s=wd("What should your nickname for this groupchat be?"),o=wd("Save");return wc`
<form class="converse-form chatroom-form" @submit=${e.onSubmit}>
<legend>${t}</legend>
<fieldset class="form-group">
<label for="converse_muc_bookmark_name">${i}</label>
<input class="form-control" type="text" value="${e.name}" name="name" required="required" id="converse_muc_bookmark_name"/>
</fieldset>
<fieldset class="form-group">
<label for="converse_muc_bookmark_nick">${s}</label>
<input class="form-control" type="text" name="nick" value="${e.nick||""}" id="converse_muc_bookmark_nick"/>
</fieldset>
<fieldset class="form-group form-check">
<input class="form-check-input" id="converse_muc_bookmark_autojoin" type="checkbox" name="autojoin"/>
<label class="form-check-label" for="converse_muc_bookmark_autojoin">${n}</label>
</fieldset>
<fieldset class="form-group">
<input class="btn btn-primary" type="submit" value="${o}">
<input class="btn btn-secondary button-cancel" type="button" value="${r}" @click=${e.onCancel}>
</fieldset>
</form>
`})(Object.assign(this.model.toJSON(),{onCancel:e=>this.closeBookmarkForm(e),onSubmit:e=>this.onBookmarkFormSubmitted(e)}))},onBookmarkFormSubmitted(e){var t,n,r;e.preventDefault(),Vc.bookmarks.createBookmark({jid:this.model.get("jid"),autojoin:(null===(t=e.target.querySelector('input[name="autojoin"]'))||void 0===t?void 0:t.checked)||!1,name:null===(n=e.target.querySelector("input[name=name]"))||void 0===n?void 0:n.value,nick:null===(r=e.target.querySelector("input[name=nick]"))||void 0===r?void 0:r.value}),this.closeBookmarkForm(e)},closeBookmarkForm(e){e.preventDefault(),this.chatroomview.closeForm()}}),Vc.BookmarksView=Md.extend({tagName:"span",initialize(){this.listenTo(this.model,"add",this.render),this.listenTo(this.model,"remove",this.render),this.listenTo(Vc.chatboxes,"add",this.render),this.listenTo(Vc.chatboxes,"remove",this.render);const e=`converse.room-bookmarks${Vc.bare_jid}-list-model`;this.list_model=new Vc.BookmarksList({id:e}),this.list_model.browserStorage=Vc.createStore(e);const t=()=>{this.render(),this.insertIntoControlBox()};this.list_model.fetch({success:t,error:t})},toHTML(){return Nd({_converse:Vc,bookmarks:this.model,hidden:this.model.getUnopenedBookmarks().length&&!0,is_hidden:e=>!(!Qc.settings.get("hide_open_bookmarks")||!Vc.chatboxes.get(e.get("jid"))),openRoom:e=>this.openRoom(e),removeBookmark:e=>this.removeBookmark(e),toggleBookmarksList:e=>this.toggleBookmarksList(e),toggle_state:this.list_model.get("toggle-state")})},insertIntoControlBox(){const e=Vc.chatboxviews.get("controlbox");if(void 0!==e&&!Ld.rootContains(Vc.root,this.el)){const t=e.el.querySelector(".list-container--bookmarks");t&&t.parentNode.replaceChild(this.el,t)}},openRoom(e){e.preventDefault();const t=e.target.textContent,n=e.target.getAttribute("data-room-jid"),r={name:t||Pd.unescapeNode(Pd.getNodeFromJid(n))||n};Qc.rooms.open(n,r,!0)},removeBookmark:Vc.removeBookmarkViaEvent,toggleBookmarksList(e){e&&e.preventDefault&&e.preventDefault();const t=e.target.matches(".fa")?e.target:e.target.querySelector(".fa");Ld.hasClass("fa-caret-down",t)?(Ld.slideIn(this.el.querySelector(".bookmarks")),this.list_model.save({"toggle-state":Vc.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"),Ld.slideOut(this.el.querySelector(".bookmarks")),this.list_model.save({"toggle-state":Vc.OPENED}))}});Qc.listen.on("getHeadingButtons",(e,t)=>{if(Vc.allow_bookmarks&&e.model.get("type")===Vc.CHATROOMS_TYPE){const n=e.model.get("bookmarked"),r={i18n_title:wd(n?"Unbookmark this groupchat":"Bookmark this groupchat"),i18n_text:wd(n?"Unbookmark":"Bookmark"),handler:t=>e.toggleBookmark(t),a_class:"toggle-bookmark",icon_class:"fa-bookmark",name:"bookmark"},i=t.map(e=>e.name).indexOf("details"),s=Vc.checkBookmarksSupport().then(e=>e?r:"");return i>-1?[...t.slice(0,i),s,...t.slice(i)]:[s,...t]}return t}),Qc.listen.on("bookmarksInitialized",(async function(){await Qc.waitUntil("roomsPanelRendered"),Vc.bookmarksview=new Vc.BookmarksView({model:Vc.bookmarks}),Qc.trigger("bookmarkViewsInitialized")})),Qc.listen.on("chatRoomViewInitialized",e=>e.setBookmarkState())}});var zd=n(30),Fd=n.n(zd);const Bd=wc`<button type="button" class="btn btn-secondary" data-dismiss="modal">${wd("Close")}</button>`,qd=wc`<button type="button" class="close" data-dismiss="modal" aria-label="${wd("Close")}"><span aria-hidden="true">×</span></button>`;var Ud=e=>wc`
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header ${e.level||""}">
<h5 class="modal-title">${e.title}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<span class="modal-alert"></span>
<form class="converse-form converse-form--modal confirm" action="#">
<div class="form-group">
${e.messages.map(e=>wc`<p>${e}</p>`)}
</div>
${e.fields.map(e=>(e=>wc`
<div class="form-group">
<label>
${e.label||""}
<input type="text"
name="${e.name}"
class="${e.challenge_failed?"error":""} form-control form-control--labeled"
?required="${e.required}"
placeholder="${e.placeholder}" />
</label>
</div>
`)(e))}
<div class="form-group">
<button type="submit" class="btn btn-primary">${wd("OK")}</button>
<input type="button" class="btn btn-secondary" data-dismiss="modal" value="${wd("Cancel")}"/>
</div>
</form>
</div>
</div>
</div>
`;
2021-01-29 23:34:36 +01:00
/**
* @module converse-modal
* @copyright The Converse.js contributors
* @license Mozilla Public License (MPLv2)
2021-03-19 19:26:15 +01:00
*/const{sizzle:Hd}=sl.env,Vd=sl.env.utils;let Wd;const Gd=Md.extend({className:"modal",events:{"click .nav-item .nav-link":"switchTab"},initialize(){this.render(),this.el.setAttribute("tabindex","-1"),this.el.setAttribute("role","dialog"),this.el.setAttribute("aria-hidden","true");const e=this.el.querySelector(".modal-title").getAttribute("id");e&&this.el.setAttribute("aria-labelledby",e),this.insertIntoDOM();const t=Fd.a.Modal;this.modal=new t(this.el,{backdrop:!0,keyboard:!0}),this.el.addEventListener("hide.bs.modal",()=>Vd.removeClass("selected",this.trigger_el),!1)},insertIntoDOM(){Wd.chatboxviews.el.querySelector("#converse-modals").insertAdjacentElement("beforeEnd",this.el)},switchTab(e){e.stopPropagation(),e.preventDefault(),Hd(".nav-link.active",this.el).forEach(e=>{Vd.removeClass("active",this.el.querySelector(e.getAttribute("href"))),Vd.removeClass("active",e)}),Vd.addClass("active",e.target),Vd.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 Dn.error("Could not find a .modal-alert element in the modal to show an alert message in!");var r;bc(wc`<div class="alert ${(r={type:"alert-"+t,message:e}).type}" role="alert"><p>${r.message}</p></div>`,n);const i=n.firstElementChild;setTimeout(()=>{Vd.addClass("fade-out",i),setTimeout(()=>Vd.removeElement(i),600)},5e3)},show(e){e&&(e.preventDefault(),this.trigger_el=e.target,this.trigger_el.classList.add("selected")),this.modal.show()}});sl.env.BootstrapModal=Gd;const Jd=Gd.extend({events:{"submit .confirm":"onConfimation"},initialize(){this.confirmation=Vd.getResolveablePromise(),Gd.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change",this.render),this.el.addEventListener("closed.bs.modal",()=>this.confirmation.reject(),!1)},toHTML(){return Ud(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()}}),Qd=Gd.extend({initialize(){Gd.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change",this.render)},toHTML(){return e=Object.assign({__:wd},this.model.toJSON()),wc`
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header ${e.level}">
<h5 class="modal-title">${e.title}</h5>
${qd}
</div>
<div class="modal-body">
<span class="modal-alert"></span>
${e.messages.map(e=>wc`<p>${e}</p>`)}
</div>
</div>
</div>
`;var e}});sl.plugins.add("converse-modal",{initialize(){let e;Wd=this._converse,Wd.api.listen.on("disconnect",()=>{const e=document.querySelector("#converse-modals");e&&(e.innerHTML="")}),Object.assign(Wd.api,{async confirm(e,t=[],n=[]){"string"==typeof t&&(t=[t]);const r=new Bs({title:e,messages:t,fields:n,type:"confirm"}),i=new Jd({model:r});let s;i.show();try{s=await i.confirmation}catch(e){s=!1}return i.remove(),s},async prompt(e,t=[],n=""){"string"==typeof t&&(t=[t]);const r=new Bs({title:e,messages:t,fields:[{name:"reason",placeholder:n}],type:"prompt"}),i=new Jd({model:r});let s;i.show();try{var o;s=null===(o=(await i.confirmation).pop())||void 0===o?void 0:o.value}catch(e){s=!1}return i.remove(),s},alert(t,n,r){let i;if("string"==typeof r&&(r=[r]),"error"===t?i="alert-danger":"info"===t?i="alert-info":"warn"===t&&(i="alert-warning"),void 0===e){const t=new Bs({title:n,messages:r,level:i,type:"alert"});e=new Qd({model:t})}else e.model.set({title:n,messages:r,level:i});e.show()}})}});var Yd=Gd.extend({toHTML(){return e={src:this.src,onload:e=>e.target.parentElement.style.height=e.target.height+"px"},wc`
<div class="modal-dialog fit-content" role="document">
<div class="modal-content fit-content">
<div class="modal-header">
<h4 class="modal-title" id="message-versions-modal-label">${wd("Image: ")}<a target="_blank" rel="noopener" href="${e.src}">${e.src}</a></h4>
${qd}
</div>
<div class="modal-body modal-body--image fit-content">
<img class="chat-image" src="${e.src}" @load=${e.onload}>
</div>
<div class="modal-footer">${Bd}</div>
</div>
</div>`;var e}});class Kd extends Lc{constructor(){super(),Object.assign(this,bi)}createRenderRoot(){return this}disconnectedCallback(){super.disconnectedCallback(),this.stopListening()}}var Xd=n(31),Zd=n.n(Xd);
2021-01-29 23:34:36 +01:00
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
2021-03-19 19:26:15 +01:00
const eh=new WeakMap,th=Ka((...e)=>t=>{let n=eh.get(t);void 0===n&&(n={lastRenderedIndex:2147483647,values:[]},eh.set(t,n));const r=n.values;let i=r.length;n.values=e;for(let s=0;s<e.length&&!(s>n.lastRenderedIndex);s++){const o=e[s];if(sc(o)||"function"!=typeof o.then){t.setValue(o),n.lastRenderedIndex=s;break}s<i&&o===r[s]||(n.lastRenderedIndex=2147483647,i=0,Promise.resolve(o).then(e=>{const r=n.values.indexOf(o);r>-1&&r<n.lastRenderedIndex&&(n.lastRenderedIndex=r,t.setValue(e),t.commit())}))}}),nh=sl.env.utils;class rh extends String{constructor(e){super(e),this.references=[]}addTemplateResult(e,t,n){this.references.push({begin:e,end:t,template:n})}isMeCommand(){const e=this.toString();return!!e&&e.startsWith("/me ")}static replaceText(e){return Tl(e.replace(/\n\n+/g,"\n\n"))}marshall(){let e=[this.toString()];this.references.sort((e,t)=>t.begin-e.begin).forEach(t=>{const n=e.shift();e=[n.slice(0,t.begin),t.template,n.slice(t.end),...e]}),this.isMeCommand()&&(e[0]=e[0].substring(4));return e.reduce((e,t)=>"string"==typeof t?[...e,rh.replaceText(t)]:[...e,t],[])}}function ih(e,t){var n;if(!t.collection)return void Dn.debug("addReferences: ignoring dangling model");const r=t.collection.chatbox.get("nick");null===(n=t.get("references"))||void 0===n||n.forEach(t=>{const n=e.slice(t.begin,t.end);n===r?e.addTemplateResult(t.begin,t.end,wc`<span class="mention mention--self badge badge-info">${{mention:n}.mention}</span>`):e.addTemplateResult(t.begin,t.end,(e=>wc`<span class="mention">${e.mention}</span>`)({mention:n}))})}class sh{constructor(e){var t;this.model=e.model,this.component=e,this.chatview=null===(t=nh.ancestor(this.component,"converse-chat-message"))||void 0===t?void 0:t.chatview,this.was_scrolled_up=this.chatview.model.get("scrolled"),this.text=this.component.model.getMessageText()}scrollDownOnImageLoad(){this.was_scrolled_up||this.chatview.scrollDown()}async transform(){const e=new rh(this.text);return await Qc.trigger("beforeMessageBodyTransformed",this.model,e,{Synchronous:!0}),function(e,t,n){const r=[];try{const t={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|xmpp:|mailto:|www\.)/gi};Zd.a.withinString(e,(e,t,n)=>(r.push({url:e,start:t,end:n}),e),t)}catch(e){return void Dn.debug(e)}const i=Qc.settings.get("show_images_inline");r.forEach(r=>{const s=e.slice(r.start,r.end),o=nh.filterQueryParamsFromURL(s);e.addTemplateResult(r.start,r.end,i&&nh.isImageURL(s)&&nh.isImageDomainAllowed(s)?nh.convertToImageTag(o,t,n):nh.convertUrlToHyperlink(o))})}(e,()=>this.scrollDownOnImageLoad(),e=>this.component.showImageModal(e)),function(e){const t=/geo:([\-0-9.]+),([\-0-9.]+)(?:,([\-0-9.]+))?(?:\?(.*))?/g,n=e.matchAll(t);for(const r of n)e.addTemplateResult(r.index,r.index+r.input.length,nh.convertUrlToHyperlink(r.input.replace(t,Vc.geouri_replacement)))}(e),await async function(e){await Qc.emojis.initialize(),[...Nl(e.toString()),...Il(e.toString())].forEach(t=>{e.addTemplateResult(t.begin,t.end,Ol(t,{add_title_wrapper:!0}))})}(e),ih(e,this.model),await Qc.trigger("afterMessageBodyTransformed",this.model,e,{Synchronous:!0}),e.marshall()}render(){return wc`${th(this.transform(),wc`${this.text}`)}`}}const oh=Ka(e=>t=>{var n;const r=new sh(e);t.setValue(r.render());const i=e.model;null===(n=i.collection)||void 0===n||n.trigger("rendered",i)});Qc.elements.define("converse-chat-message-body",class extends Kd{static get properties(){return{model:{type:Object},is_me_message:{type:Boolean},text:{type:String}}}showImageModal(e){e.preventDefault(),void 0===this.image_modal&&(this.image_modal=new Yd),this.image_modal.src=e.target.src,this.image_modal.render(),this.image_modal.show(e)}render(){return oh(this)}});var ah=e=>wc`<a target="_blank" rel="noopener" href="${e.url}">${e.label_download}</a>`,ch=n(166),lh=n.n(ch),uh=n(167),dh=n.n(uh),hh=n(61),fh=n.n(hh),ph=n(168),gh=n.n(ph),mh=n(169),vh=n.n(mh),_h=n(170),bh=n.n(_h),yh=n(62),wh=n.n(yh);const Sh=Ka((e,t,n,r)=>i=>{i.setValue(wc`<a href="${t}"
class="chat-image__link"
target="_blank"
rel="noopener"
><img class="chat-image img-thumbnail" src="${e}" @click=${r} @error=${function(){const s=sl.env.utils;s.isURLWithImageExtension(e)?(i.setValue(s.convertUrlToHyperlink(t)),i.commit()):(i.setValue(Sh(e+".png",t,n,r)),i.commit())}} @load=${n}/></a>`)});var xh=n(171),Eh=n.n(xh);
2021-01-29 23:34:36 +01:00
/**
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
* @description This is the DOM/HTML utilities module.
2021-03-19 19:26:15 +01:00
*/
const{sizzle:Ah}=sl.env,Ch=["http","https","xmpp","mailto"];function kh(e,t){return{"muc#roomconfig_lang":"language","muc#roomconfig_roomsecret":null!=t&&t.new_password?"new-password":"current-password"}[e]}const jh={"text-private":"password","text-single":"text",fixed:"label",boolean:"checkbox",hidden:"hidden","jid-multi":"textarea","list-single":"dropdown","list-multi":"dropdown"};function Th(e){try{return e instanceof Zd.a?e:new Zd.a(e)}catch(e){return Dn.debug(e),null}}function Oh(e,t){const n=Th(t);if(null===n||!function(e){return"http:"===window.location.protocol||"https:"===window.location.protocol&&"https"===e.protocol().toLowerCase()}(n))return!1;const r=n.filename().toLowerCase();return!!e.filter(e=>r.endsWith(e)).length}function Nh(e){try{return decodeURI(e.filename())}catch(t){return Dn.debug(t),e.filename()}}function Ih(e,t){const{__:n}=e;return r={url:t.toString(),label_download:n('Download audio file "%1$s"',Nh(t))},wc`
<audio controls src="${r.url}"></audio>
<a target="_blank" rel="noopener" href="${r.url}">${r.label_download}</a>
`;var r}function Mh(e,t){e.classList.remove("visible"),M(t)&&t()}Js.isAudioURL=e=>Oh([".ogg",".mp3",".m4a"],e),Js.isVideoURL=e=>Oh([".mp4",".webm"],e),Js.isURLWithImageExtension=e=>Oh([".jpg",".jpeg",".png",".gif",".bmp",".tiff",".svg"],e),Js.isImageURL=e=>{const t=Qc.settings.get("image_urls_regex");return(null==t?void 0:t.test(e))||Js.isURLWithImageExtension(e)},Js.isImageDomainAllowed=e=>{const t=Qc.settings.get("show_images_inline");if(!Array.isArray(t))return!0;try{const n=Th(e).domain();return t.includes(n)}catch(e){return Dn.debug(e),!0}},Js.getOOBURLMarkup=function(e,t){const n=Th(t);return null===n?t:Js.isVideoURL(n)?wc`<video controls preload="metadata" src="${{url:t}.url}" style="max-height: 50vh"></video>`:Js.isAudioURL(n)?Ih(e,n):Js.isImageURL(n)?function(e,t){const{__:n}=e;return ah({url:t.toString(),label_download:n('Download image file "%1$s"',Nh(t))})}(e,n):function(e,t){const{__:n}=e;return ah({url:t.toString(),label_download:n('Download file "%1$s"',Nh(t))})}(e,n)},Js.applyDragResistance=function(e,t){if(void 0===e)return;if(void 0===t)return e;return e!==t&&Math.abs(e-t)<10?t:e},Js.calculateElementHeight=function(e){return Array.from(e.children).reduce((e,t)=>e+t.offsetHeight,0)},Js.getNextElement=function(e,t="*"){let n=e.nextElementSibling;for(;null!==n&&!Ah.matchesSelector(n,t);)n=n.nextElementSibling;return n},Js.getPreviousElement=function(e,t="*"){let n=e.previousElementSibling;for(;null!==n&&!Ah.matchesSelector(n,t);)n=n.previousElementSibling;return n},Js.getFirstChildElement=function(e,t="*"){let n=e.firstElementChild;for(;null!==n&&!Ah.matchesSelector(n,t);)n=n.nextElementSibling;return n},Js.getLastChildElement=function(e,t="*"){let n=e.lastElementChild;for(;null!==n&&!Ah.matchesSelector(n,t);)n=n.previousElementSibling;return n},Js.hasClass=function(e,t){return t instanceof Element&&t.classList.contains(e)},Js.toggleClass=function(e,t){Js.hasClass(e,t)?Js.removeClass(e,t):Js.addClass(e,t)},Js.addClass=function(e,t){return t instanceof Element&&t.classList.add(e),t},Js.removeClass=function(e,t){return t instanceof Element&&t.classList.remove(e),t},Js.removeElement=function(e){return e instanceof Element&&e.parentNode&&e.parentNode.removeChild(e),e},Js.getElementFromTemplateResult=function(e){const t=document.createElement("div");return bc(e,t),t.firstElementChild},Js.showElement=e=>{Js.removeClass("collapsed",e),Js.removeClass("hidden",e)},Js.hideElement=function(e){return e instanceof Element&&e.classList.add("hidden"),e},Js.ancestor=function(e,t){let n=e;for(;null!==n&&!Ah.matchesSelector(n,t);)n=n.parentElement;return n},Js.nextUntil=function(e,t){const n=[];let r=e.nextElementSibling;for(;null!==r&&!r.matches(t);)n.push(r),r=r.nextElementSibling;return n},Js.unescapeHTML=function(e){var t=document.createElement("div");return t.innerHTML=e,t.innerText},Js.escapeHTML=function(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},Js.convertToImageTag=function(e,t,n){return wc`${Sh((r={url:e,onClick:n,onLoad:t}).url,r.url,r.onLoad,r.onClick)}`;var r},Js.convertURIoHyperlink=function(e,t){let n=e.normalize()._string;const r=e._parts.urn?n:e.readable(),i=t||r;return e._parts.protocol||n.startsWith("http://")||n.startsWith("https://")||(n="http://"+n),"xmpp"===e._parts.protocol&&"join"===e._parts.query?wc`
<a target="_blank"
rel="noopener"
@click=${e=>Qc.rooms.open(e.target.href)}
href="${n}">${i}</a>`:wc`<a target="_blank" rel="noopener" href="${n}">${i}</a>`},Js.convertUrlToHyperlink=function(e){const t=RegExp("^w{3}.","ig").test(e)?"http://"+e:e,n=Th(e);return null===n||!function(e){try{return!!new URL(e)}catch(e){return!1}}(t)||!function(e,t=Ch){return!!t.includes(e)}(n._parts.protocol)&&n._parts.protocol?e:this.convertURIoHyperlink(n,e)},Js.filterQueryParamsFromURL=function(e){const t=Qc.settings.get("filter_url_query_params");if(!t)return e;return Th(e).removeQuery(t).toString()},Js.addHyperlinks=function(e){const t=[],n={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|xmpp:|mailto:|www\.)/gi};try{Zd.a.withinString(e,(e,n,r)=>(t.push({url:e,start:n,end:r}),e),n)}catch(t){return Dn.debug(t),[e]}let r=[e];return t.length?t.sort((e,t)=>t.start-e.start).forEach(e=>{const t=r.shift(),n=t.slice(e.start,e.end);r=[t.slice(0,e.start),Js.convertUrlToHyperlink(n),t.slice(e.end),...r]}):r=[e],r},Js.httpToGeoUri=function(e,t){return e.replace(t.api.settings.get("geouri_regex"),"geo:$1,$2")},Js.slideInAllElements=function(e,t=300){return Promise.all(Array.from(e).map(e=>Js.slideIn(e,t)))},Js.slideToggleElement=function(e,t){return Js.hasClass("collapsed",e)||Js.hasClass("hidden",e)?Js.slideOut(e,t):Js.slideIn(e,t)},Js.slideOut=function(e,t=200){return new Promise((n,r)=>{if(!e){const e="An element needs to be passed in to slideOut";return Dn.warn(e),void r(new Error(e))}const i=e.getAttribute("data-slider-marker");i&&(e.removeAttribute("data-slider-marker"),window.cancelAnimationFrame(i));const s=Js.calculateElementHeight(e);if(window.converse_disable_effects)return e.style.height=s+"px",function(e){e.removeAttribute("data-slider-marker"),e.classList.remove("collapsed"),e.style.overflow="",e.style.height=""}(e),void n();if(!Js.hasClass("collapsed",e)&&!Js.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+=s/o,a<s?(e.style.height=a+"px",e.setAttribute("data-slider-marker",window.requestAnimationFrame(t))):(e.removeAttribute("data-slider-marker"),e.style.height=Js.calculateElementHeight(e)+"px",e.style.overflow="",e.style.height="",n())})))})},Js.slideIn=function(e,t=200){return new Promise((n,r)=>{if(!e){const e="An element needs to be passed in to slideIn";return Dn.warn(e),r(new Error(e))}if(Js.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 s=e.offsetHeight,o=t/17;let a=s;e.style.overflow="hidden",e.setAttribute("data-slider-marker",window.requestAnimationFrame((function t(){a-=s/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))})))})},Js.isInDOM=function(e){return document.querySelector("body").contains(e)},Js.isVisible=function(e){return null!==e&&(!Js.hasClass("hidden",e)&&(e.offsetWidth>0||e.offsetHeight>0||e.getClientRects().length>0))},Js.fadeIn=function(e,t){if(e||Dn.warn("An element needs to be passed in to fadeIn"),window.converse_disable_effects)return e.classList.remove("hidden"),Mh(e,t);Js.hasClass("hidden",e)?(e.classList.add("visible"),e.classList.remove("hidden"),e.addEventListener("webkitAnimationEnd",()=>Mh(e,t)),e.addEventListener("animationend",()=>Mh(e,t)),e.addEventListener("oanimationend",()=>Mh(e,t))):Mh(e,t)},Js.xForm2webForm=function(e,t,n){if("list-single"===e.getAttribute("type")||"list-multi"===e.getAttribute("type")){const t=Js.queryChildren(e,"value").map(e=>null==e?void 0:e.textContent),n=Js.queryChildren(e,"option").map(n=>{var r;const i=null===(r=n.querySelector("value"))||void 0===r?void 0:r.textContent;return Eh()({value:i,label:n.getAttribute("label"),selected:t.includes(i),required:!!e.querySelector("required")})});return gh(
<div class="dropleft">
<button type="button" class="btn btn--transparent btn--standalone" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="${e} only-icon"></i>
</button>
<div class="dropdown-menu">
${this.items.map(e=>th(e,""))}
</div>
</div>
`}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 zh(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!==sl.keycodes.DOWN_ARROW||this.navigator.enabled||this.enableArrowNavigation(e)}});class qh extends Kd{static get properties(){return{chatview:{type:Object},model:{type:Object},editable:{type:Boolean},correcting:{type:Boolean},message_type:{type:String},is_retracted:{type:Boolean}}}render(){return wc`${th(this.renderActions(),"")}`}static getActionsDropdownItem(e){return wc`
<button class="chat-msg__action ${e.button_class}" @click=${e.handler}>
<converse-icon class="${e.icon_class}"
path-prefix="${Qc.settings.get("assets_path")}"
color="var(--text-color-lighten-15-percent)"
size="1em"></converse-icon>
${e.i18n_text}
</button>
`}onMessageEditButtonClicked(e){e.preventDefault(),this.chatview.onMessageEditButtonClicked(this.model)}onMessageRetractButtonClicked(e){e.preventDefault(),this.chatview.onMessageRetractButtonClicked(this.model)}async renderActions(){const e=[];this.editable&&e.push({i18n_text:this.correcting?wd("Cancel Editing"):wd("Edit"),handler:e=>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:wd("Retract"),handler:e=>this.onMessageRetractButtonClicked(e),button_class:"chat-msg__action-retract",icon_class:"fas fa-trash-alt",name:"retract"});const n=e.map(e=>qh.getActionsDropdownItem(e));return n.length?wc`<converse-dropdown class="chat-msg__actions" .items=${n}></converse-dropdown>`:""}}Qc.elements.define("converse-message-actions",qh);var Uh=Gd.extend({id:"message-versions-modal",toHTML(){return e=this.model.toJSON(),wc`
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="message-versions-modal-label">${wd("Message versions")}</h4>
${qd}
</div>
<div class="modal-body">
<h4>Older versions</h4>
${Object.keys(e.older_versions).map(t=>wc`<p class="older-msg"><time>${Sn()(t).format("MMM D, YYYY, HH:mm:ss")}</time>: ${e.older_versions[t]}</p>`)}
<hr/>
<h4>Current version</h4>
<p>${e.message}</p>
</div>
<div class="modal-footer">${Bd}</div>
</div>
</div>
`;var e}});var Hh=e=>{return wc`
<svg xmlns="http://www.w3.org/2000/svg" class="avatar ${e.classes}" width="${e.width}" height="${e.height}">
<image width="${e.width}" height="${e.height}" preserveAspectRatio="xMidYMid meet" href="${t=e.image,n=e.image_type,t.startsWith("data:")?t:`data:${n};base64,${t}`}"/>
</svg>`;var t,n};const Vh=Ka(e=>t=>{const n={classes:e.classes?e.classes+" avatar":"avatar",height:e.width||36,image:e.image,image_type:e.image_type,width:e.height||36};t.setValue(Hh(n))});var Wh=(e={})=>wc`<span class="spinner fa fa-spinner centered ${e.classes||""}"/>`;const{Strophe:Gh}=sl.env,Jh=sl.env.utils;class Qh extends Kd{static get properties(){return{chatview:{type:Object},correcting:{type:Boolean},editable:{type:Boolean},edited:{type:String},error:{type:String},error_text:{type:String},from:{type:String},has_mentions:{type:Boolean},hats:{type:Array},is_delayed:{type:Boolean},is_encrypted:{type:Boolean},is_first_unread:{type:Boolean},is_me_message:{type:Boolean},is_only_emojis:{type:Boolean},is_retracted:{type:Boolean},is_spoiler:{type:Boolean},is_spoiler_visible:{type:Boolean},message_type:{type:String},model:{type:Object},moderated_by:{type:String},moderation_reason:{type:String},msgid:{type:String},occupant_affiliation:{type:String},occupant_role:{type:String},oob_url:{type:String},progress:{type:Number},reason:{type:String},received:{type:String},retractable:{type:Boolean},retry_event_id:{type:String},sender:{type:String},show_spinner:{type:Boolean},spoiler_hint:{type:String},subject:{type:String},time:{type:String},username:{type:String}}}render(){const e=Qc.settings.get("time_format");return this.pretty_time=Sn()(this.edited||this.time).format(e),this.show_spinner?Wh():this.model.get("file")&&!this.model.get("oob_url")?this.renderFileProgress():["error","info"].includes(this.message_type)?this.renderInfoMessage():this.renderChatMessage()}connectedCallback(){super.connectedCallback(),this.listenTo(this.model,"change",e=>{const t=this.model.collection.chatbox;Object.assign(this,af(t,this.model)),Object.keys(e.changed).filter(e=>Object.keys(Qh.properties).includes(e)).forEach(t=>this[t]=e.changed[t])});const e=this.model.vcard;e&&this.listenTo(e,"change",()=>this.requestUpdate())}updated(){var e;(this.show_spinner||this.model.get("file")&&!this.model.get("oob_url")||["error","info"].includes(this.message_type))&&(null===(e=this.model.collection)||void 0===e||e.trigger("rendered",this.model))}renderInfoMessage(){const e=Sn()(this.model.get("time")).toISOString(),t=wd("Retry");return wc`
<div class="message chat-info chat-${this.message_type}"
data-isodate="${e}"
data-type="${this.data_name}"
data-value="${this.data_value}">
<div class="chat-info__message">
${this.model.getMessageText()}
</div>
${this.reason?wc`<q class="reason">${this.reason}</q>`:""}
${this.error_text?wc`<q class="reason">${this.error_text}</q>`:""}
${this.retry_event_id?wc`<a class="retry" @click=${this.onRetryClicked}>${t}</a>`:""}
</div>
`}renderFileProgress(){const e=wd("Uploading file:"),t=this.model.file.name,n=hl()(this.model.file.size);return wc`
<div class="message chat-msg">
${Vh(this.getAvatarData())}
<div class="chat-msg__content">
<span class="chat-msg__text">${e} <strong>${t}</strong>, ${n}</span>
<progress value="${this.progress}"/>
</div>
</div>`}renderChatMessage(){return(e=>{const t=wd("New messages");return wc`
${e.is_first_unread?wc`<div class="message separator"><hr class="separator"><span class="separator-text">${t}</span></div>`:""}
<div class="message chat-msg ${e.getExtraMessageClasses()}"
data-isodate="${e.time}"
data-msgid="${e.msgid}"
data-from="${e.from}"
data-encrypted="${e.is_encrypted}">
<!-- Anchor to allow us to scroll the message into view -->
<a id="${e.msgid}"></a>
${e.shouldShowAvatar()?Vh(e.getAvatarData()):""}
<div class="chat-msg__content chat-msg__content--${e.sender} ${e.is_me_message?"chat-msg__content--action":""}">
${e.is_me_message?"":wc`
<span class="chat-msg__heading">
<span class="chat-msg__author">${e.username}</span>
${e.renderAvatarByline()}
${e.is_encrypted?wc`<span class="fa fa-lock"></span>`:""}
</span>`}
<div class="chat-msg__body chat-msg__body--${e.message_type} ${e.received?"chat-msg__body--received":""} ${e.is_delayed?"chat-msg__body--delayed":""}">
<div class="chat-msg__message">
${e.is_me_message?wc`
<time timestamp="${e.edited||e.time}" class="chat-msg__time">${e.pretty_time}</time>&nbsp;
<span class="chat-msg__author">${e.is_me_message?"**":""}${e.username}</span>&nbsp;`:""}
${e.is_retracted?e.renderRetraction():e.renderMessageText()}
</div>
<converse-message-actions
.chatview=${e.chatview}
.model=${e.model}
?correcting="${e.correcting}"
?editable="${e.editable}"
?is_retracted="${e.is_retracted}"
message_type="${e.message_type}"></converse-message-actions>
</div>
</div>
</div>`})(this)}shouldShowAvatar(){return Qc.settings.get("show_message_avatar")&&!this.is_me_message&&"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"))||Vc.DEFAULT_IMAGE_TYPE)+";base64,"+((null===(t=this.model.vcard)||void 0===t?void 0:t.get("image"))||Vc.DEFAULT_IMAGE)}}async onRetryClicked(){this.show_spinner=!0,await Qc.trigger(this.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 r=Sn()(this.time);return this.from===n.get("from")&&!this.is_me_message&&!n.isMeCommand()&&"info"!==this.message_type&&"info"!==n.get("type")&&r.isBefore(Sn()(n.get("time")).add(10,"minutes"))&&!!this.is_encrypted==!!n.get("is_encrypted")}getExtraMessageClasses(){const e=[this.isFollowup()?"chat-msg--followup":null,this.is_delayed?"delayed":null,this.is_me_message?"chat-msg--action":null,this.is_retracted?"chat-msg--retracted":null,this.message_type,this.shouldShowAvatar()?"chat-msg--with-avatar":null].map(e=>e);return"groupchat"===this.message_type&&(this.occupant_role&&e.push(this.occupant_role),this.occupant_affiliation&&e.push(this.occupant_affiliation),"them"===this.sender&&this.has_mentions&&e.push("mentioned")),this.correcting&&e.push("correcting"),e.filter(e=>e).join(" ")}getRetractionText(){if("groupchat"===this.message_type&&this.moderated_by){const e=this.moderated_by,t=this.model.collection.chatbox;this.model.mod||(this.model.mod=t.occupants.findOccupant({jid:e})||t.occupants.findOccupant({nick:Gh.getResourceFromJid(e)}));const n=this.model.mod?this.model.mod.getDisplayName():"A moderator";return wd("%1$s has removed this message",n)}return wd("%1$s has removed this message",this.model.getDisplayName())}renderRetraction(){const e=this.is_retracted?this.getRetractionText():null;return wc`
<div>${e}</div>
${this.moderation_reason?wc`<q class="chat-msg--retracted__reason">${this.moderation_reason}</q>`:""}
`}renderMessageText(){const e=wd("This message has been edited"),t=wd("Show more"),n="groupchat"===this.message_type,r=wd("Show less"),i=wc`
<div class="chat-msg__spoiler-hint">
<span class="spoiler-hint">${this.spoiler_hint}</span>
<a class="badge badge-info spoiler-toggle" href="#" @click=${this.toggleSpoilerMessage}>
<i class="fa ${this.is_spoiler_visible?"fa-eye-slash":"fa-eye"}"></i>
${this.is_spoiler_visible?r:t}
</a>
</div>
`,s=this.is_spoiler?"spoiler "+(this.is_spoiler_visible?"":"hidden"):"";return wc`
${this.is_spoiler?i:""}
${this.subject?wc`<div class="chat-msg__subject">${this.subject}</div>`:""}
<span>
<converse-chat-message-body
class="chat-msg__text ${this.is_only_emojis?"chat-msg__text--larger":""} ${s}"
.model="${this.model}"
?is_me_message="${this.is_me_message}"
?is_only_emojis="${this.is_only_emojis}"
?is_spoiler="${this.is_spoiler}"
?is_spoiler_visible="${this.is_spoiler_visible}"
text="${this.model.getMessageText()}"></converse-chat-message-body>
${!this.received||this.is_me_message||n?"":wc`<span class="fa fa-check chat-msg__receipt"></span>`}
${this.edited?wc`<i title="${e}" class="fa fa-edit chat-msg__edit-modal" @click=${this.showMessageVersionsModal}></i>`:""}
</span>
${this.oob_url?wc`<div class="chat-msg__media">${Jh.getOOBURLMarkup(Vc,this.oob_url)}</div>`:""}
<div class="chat-msg__error">${this.error_text||this.error}</div>
`}renderAvatarByline(){return wc`
${this.hats.map(e=>wc`<span class="badge badge-secondary">${e.title}</span>`)}
<time timestamp="${this.edited||this.time}" class="chat-msg__time">${this.pretty_time}</time>
`}showMessageVersionsModal(e){e.preventDefault(),void 0===this.message_versions_modal&&(this.message_versions_modal=new Uh({model:this.model})),this.message_versions_modal.show(e)}toggleSpoilerMessage(e){null==e||e.preventDefault(),this.model.save({is_spoiler_visible:!this.model.get("is_spoiler_visible")})}}Qc.elements.define("converse-chat-message",Qh);
2021-01-29 23:34:36 +01:00
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
2021-03-19 19:26:15 +01:00
const Yh=(e,t)=>{const n=e.startNode.parentNode,r=void 0===t?e.endNode:t.startNode,i=n.insertBefore(Va(),r);n.insertBefore(Va(),r);const s=new lc(e.options);return s.insertAfterNode(i),s},Kh=(e,t)=>(e.setValue(t),e.commit(),e),Xh=(e,t,n)=>{const r=e.startNode.parentNode,i=n?n.startNode:e.endNode,s=t.endNode.nextSibling;s!==i&&Pa(r,t.startNode,s,i)},Zh=e=>{La(e.startNode.parentNode,e.startNode,e.endNode.nextSibling)},ef=(e,t,n)=>{const r=new Map;for(let i=t;i<=n;i++)r.set(e[i],i);return r},tf=new WeakMap,nf=new WeakMap,rf=Ka((e,t,n)=>{let r;return void 0===n?n=t:void 0!==t&&(r=t),t=>{if(!(t instanceof lc))throw new Error("repeat can only be used in text bindings");const i=tf.get(t)||[],s=nf.get(t)||[],o=[],a=[],c=[];let l,u,d=0;for(const t of e)c[d]=r?r(t,d):d,a[d]=n(t,d),d++;let h=0,f=i.length-1,p=0,g=a.length-1;for(;h<=f&&p<=g;)if(null===i[h])h++;else if(null===i[f])f--;else if(s[h]===c[p])o[p]=Kh(i[h],a[p]),h++,p++;else if(s[f]===c[g])o[g]=Kh(i[f],a[g]),f--,g--;else if(s[h]===c[g])o[g]=Kh(i[h],a[g]),Xh(t,i[h],o[g+1]),h++,g--;else if(s[f]===c[p])o[p]=Kh(i[f],a[p]),Xh(t,i[f],i[h]),f--,p++;else if(void 0===l&&(l=ef(c,p,g),u=ef(s,h,f)),l.has(s[h]))if(l.has(s[f])){const e=u.get(c[p]),n=void 0!==e?i[e]:null;if(null===n){const e=Yh(t,i[h]);Kh(e,a[p]),o[p]=e}else o[p]=Kh(n,a[p]),Xh(t,n,i[h]),i[e]=null;p++}else Zh(i[f]),f--;else Zh(i[h]),h++;for(;p<=g;){const e=Yh(t,o[g+1]);Kh(e,a[p]),o[p++]=e}for(;h<=f;){const e=i[h++];null!==e&&Zh(e)}tf.set(t,o),nf.set(t,c)}}),sf=wd("No message history available.");function of(e){const t=e.collection.models,n=t.indexOf(e),r=t[n-1];if(!r||Sn()(e.get("time")).isAfter(Sn()(r.get("time")),"day")){const t=Sn()(e.get("time")).startOf("day");return i={type:"date",time:t.toISOString(),datestring:t.format("dddd MMM Do YYYY")},wc`
<div class="message date-separator" data-isodate="${i.time}">
<hr class="separator"/>
<time class="separator-text" datetime="${i.time}"><span>${i.datestring}</span></time>
</div>
`}var i}function af(e,t){return{has_mentions:"groupchat"===t.get("type")&&"them"===t.get("sender")&&e.isUserMentioned(t),hats:Vc.getHats(t),is_first_unread:e.get("first_unread_id")===t.get("id"),is_me_message:t.isMeCommand(),is_retracted:t.get("retracted")||"retracted"===t.get("moderated"),username:t.getDisplayName()}}Vc.getHats=function(e){if("groupchat"===e.get("type")){var t;const n=Qc.settings.get("muc_hats").filter(e=>e).map(e=>e.toLowerCase());let r=[];n.includes("vcard_roles")&&(r=e.vcard?e.vcard.get("role"):null,r=r?r.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"))||[],...r,...i]}return[]};Qc.elements.define("converse-message-history",class extends Kd{static get properties(){return{chatview:{type:Object},messages:{type:Array}}}render(){const e=this.messages;return e.length?wc`${rf(e,e=>e.get("id"),e=>this.renderMessage(e))}`:wc`<div class="empty-history-feedback form-help"><span>${sf}</span></div>`}renderMessage(e){if(e.get("dangling_retraction")||e.get("is_only_key"))return"";const t=of(e);var n;return[...t?[t]:[],(n=Object.assign(e.toJSON(),af(this.chatview.model,e),{chatview:this.chatview,model:e}),wc`
<converse-chat-message
.chatview=${n.chatview}
.hats=${n.hats}
.model=${n.model}
?correcting=${n.correcting}
?editable=${n.editable}
?has_mentions=${n.has_mentions}
?is_delayed=${n.is_delayed}
?is_encrypted=${!!n.is_encrypted}
?is_first_unread=${n.is_first_unread}
?is_me_message=${n.is_me_message}
?is_only_emojis=${n.is_only_emojis}
?is_retracted=${n.is_retracted}
?is_spoiler=${n.is_spoiler}
?is_spoiler_visible=${n.is_spoiler_visible}
?retractable=${n.retractable}
edited=${n.edited||""}
error=${n.error||""}
error_text=${n.error_text||""}
filename=${n.filename||""}
filesize=${n.filesize||""}
from=${n.from}
message_type=${n.type||""}
moderated_by=${n.moderated_by||""}
moderation_reason=${n.moderation_reason||""}
msgid=${n.msgid}
occupant_affiliation=${n.model.occupant?n.model.occupant.get("affiliation"):""}
occupant_role=${n.model.occupant?n.model.occupant.get("role"):""}
oob_url=${n.oob_url||""}
pretty_type=${n.pretty_type}
progress=${n.progress||0}
reason=${n.reason||""}
received=${n.received||""}
retry_event_id=${n.retry_event_id||""}
sender=${n.sender}
spoiler_hint=${n.spoiler_hint||""}
subject=${n.subject||""}
time=${n.time}
username=${n.username}></converse-chat-message>
`)]}});var cf=n(14),lf=n.n(cf);
2021-01-29 23:34:36 +01:00
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
2021-03-19 19:26:15 +01:00
const uf=new WeakMap,df=Ka(e=>t=>{if(!(t instanceof lc))throw new Error("unsafeHTML can only be used in text bindings");const n=uf.get(t);if(void 0!==n&&sc(e)&&e===n.value&&t.value===n.fragment)return;const r=document.createElement("template");r.innerHTML=e;const i=document.importNode(r.content,!0);t.setValue(i),uf.set(t,{value:e,fragment:i})});Qc.elements.define("converse-chat-content",class extends Kd{static get properties(){return{chatview:{type:Object},messages:{type:Array},notifications:{type:String}}}render(){const e=lf.a.filterXSS(this.notifications,{whiteList:{}});return wc`
<converse-message-history
.chatview=${this.chatview}
.messages=${this.messages}>
</converse-message-history>
<div class="chat-content__notifications">${df(e)}</div>
`}});customElements.define("converse-icon",
2021-01-29 23:34:36 +01:00
/**
* @module icons.js
* @copyright Alfredo Medrano Sánchez and the Converse.js contributors
* @description
* Component inspired by the one from fa-icons
* https://github.com/obsidiansoft-io/fa-icons/blob/master/LICENSE
* @license Mozilla Public License (MPLv2)
2021-03-19 19:26:15 +01:00
*/
class extends Kd{static get properties(){return{color:String,class_name:{attribute:"class"},style:String,size:String}}static get styles(){return Dc`
:host {
display: inline-block;
padding: 0;
margin: 0;
}
`}constructor(){super(),this.class_name="",this.style="",this.size="",this.color=""}getSource(){return"#icon-"+this.class_name.split(" ")[1].replace("fa-","")}getStyles(){return`\n ${this.size?`width: ${this.size};`:""}\n ${this.size?`height: ${this.size};`:""}\n ${this.color?`fill: ${this.color};`:""}\n ${this.style}\n `}render(){return wc`<svg .style="${this.getStyles()}"> <use href="${this.getSource()}"> </use> </svg>`}});Qc.elements.define("converse-chat-help",class extends Kd{static get properties(){return{chat_type:{type:String},messages:{type:Array},model:{type:Object},type:{type:String}}}render(){const e=(new Date).toISOString();return[wc`<converse-icon class="fas fa-times close-chat-help"
@click=${this.close}
path-prefix="${Qc.settings.get("assets_path")}"
size="1em"></converse-icon>`,...this.messages.map(t=>this.renderHelpMessage({isodate:e,markup:lf.a.filterXSS(t,{whiteList:{strong:[]}})}))]}close(){this.model.set({show_help_messages:!1})}renderHelpMessage(e){return wc`<div class="message chat-${this.type}" data-isodate="${e.isodate}">${df(e.markup)}</div>`}});const hf=sl.env.utils,ff=e=>{const t=Qc.settings.get("emoji_categories");return wc`<ul>${Object.keys(t).map(n=>t[n]?(e=>wc`
<li data-category="${e.category}"
class="emoji-category ${e.category} ${e.current_category===e.category?"picked":""}"
title="${wd(Vc.emoji_category_labels[e.category])}">
<a class="pick-category"
@click=${e.onCategoryPicked}
href="#emoji-picker-${e.category}"
data-category="${e.category}">${e.emoji} </a>
</li>
`)(Object.assign({category:n,emoji:e.sn2Emoji(t[n])},e)):"")}</ul>`},pf=e=>wc`
<li class="emoji insert-emoji ${e.shouldBeHidden(e.emoji.sn)?"hidden":""}" data-emoji="${e.emoji.sn}" title="${e.emoji.sn}">
<a href="#" @click=${e.insertEmoji} data-emoji="${e.emoji.sn}">${hf.shortnamesToEmojis(e.emoji.sn)}</a>
</li>
`,gf=e=>{const t=Qc.settings.get("emoji_categories");return wc`
<span ?hidden=${e.query} class="emoji-lists__container emoji-lists__container--browse">
${Object.keys(t).map(n=>t[n]?(e=>wc`
<a id="emoji-picker-${e.category}" class="emoji-category__heading" data-category="${e.category}">${wd(Qc.settings.get("emoji_category_labels")[e.category])}</a>
<ul class="emoji-picker" data-category="${e.category}">
${Object.values(sl.emojis.json[e.category]).map(t=>pf(Object.assign({emoji:t},e)))}
</ul>`)(Object.assign({category:n},e)):"")}
</span>`},mf=e=>{const t=wd("Search");return wc`
<div class="emoji-picker__header">
<input class="form-control emoji-search" name="emoji-search" placeholder="${t}"
.value=${e.query||""}
@keydown=${e.onSearchInputKeyDown}
@blur=${e.onSearchInputBlurred}
@focus=${e.onSearchInputFocus}>
${e.query?"":ff(e)}
</div>
${e.render_emojis?wc`<converse-emoji-picker-content
.chatview=${e.chatview}
.model=${e.model}
.search_results="${e.search_results}"
current_skintone="${e.current_skintone}"
query="${e.query}"></converse-emoji-picker-content>`:""}
<div class="emoji-skintone-picker">
<label>Skin tone</label>
<ul>${["tone1","tone2","tone3","tone4","tone5"].map(t=>(e=>wc`
<li data-skintone="${e.skintone}" class="emoji-skintone ${e.current_skintone===e.skintone?"picked":""}">
<a class="pick-skintone" href="#" data-skintone="${e.skintone}" @click=${e.onSkintonePicked}>${hf.shortnamesToEmojis(":"+e.skintone+":")}</a>
</li>`)(Object.assign({skintone:t},e)))}</ul>
</div>`},{sizzle:vf}=sl.env;Qc.elements.define("converse-emoji-picker-content",class extends Kd{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 wc`
<div class="emoji-picker__lists">
${(e=>{const t=wd("Search results");return wc`
<span ?hidden=${!e.query} class="emoji-lists__container emojis-lists__container--search">
<a id="emoji-picker-search-results" class="emoji-category__heading">${t}</a>
<ul class="emoji-picker">
${e.search_results.map(t=>pf(Object.assign({emoji:t},e)))}
</ul>
</span>
`})(e)}
${gf(e)}
</div>
`}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)}vf(".emoji-picker",this).forEach(e=>this.observer.observe(e))}}setCategoryOnVisibilityChange(e){const t=this.parentElement.navigator.selected,n=e.filter(e=>e.target.contains(t)).pop();let r;if(r=n||e.reduce((e,t)=>t.intersectionRatio>=((null==e?void 0:e.intersectionRatio)||0)?t:e,null),r&&r.isIntersecting){const e=r.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&&sl.emojis.toned.includes(e))return!0;return!(!this.query||Vc.FILTER_CONTAINS(e,this.query))}});const _f=sl.env.utils;Qc.elements.define("converse-emoji-dropdown",class extends Bh{static get properties(){return{chatview:{type:Object}}}constructor(){super(),this.render_emojis=!1}initModel(){return this.init_promise||(this.init_promise=(async()=>{await Qc.emojis.initialize();const e=`converse.emoji-${Vc.bare_jid}-${this.chatview.model.get("jid")}`;this.model=new Vc.EmojiPicker({id:e}),this.model.browserStorage=Vc.createStore(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 wc`
<div class="dropup">
<button class="toggle-emojis"
title="${wd("Insert emojis")}"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false">
<converse-icon
class="fa fa-smile "
path-prefix="${Qc.settings.get("assets_path")}"
size="1em"></converse-icon>
</button>
<div class="dropdown-menu">
${th(this.initModel().then(()=>wc`
<converse-emoji-picker
.chatview=${this.chatview}
.model=${this.model}
?render_emojis=${this.render_emojis}
current_category="${this.model.get("current_category")||""}"
current_skintone="${this.model.get("current_skintone")||""}"
query="${this.model.get("query")||""}"
></converse-emoji-picker>`),"")}
</div>
</div>`}connectedCallback(){super.connectedCallback(),this.render_emojis=!1}toggleMenu(e){e.stopPropagation(),e.preventDefault(),_f.hasClass("show",this.menu)?_f.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()})}}),Qc.elements.define("converse-emoji-picker",class extends Kd{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=Ma(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 mf({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=>_f.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-"+this.current_category);t&&(e.scrollTop=t.offsetTop-3*t.offsetHeight+4)}updateSearchResults(e){const t=e.get("query"),n=Vc.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=sl.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===sl.keycodes.ENTER&&this.navigator.selected&&_f.isVisible(this)?this.onEnterPressed(e):e.keyCode===sl.keycodes.DOWN_ARROW&&!this.navigator.enabled&&_f.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){this.chatview.onEmojiReceivedFromPicker(e),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:_f.ancestor(e.target,"li");this.setCategoryForElement(t),this.navigator.select(t),!this.navigator.enabled&&this.navigator.enable()}onKeyDown(e){if(e.keyCode===sl.keycodes.TAB)if(e.target.value){e.preventDefault();const t=sl.emojis.shortnames.find(t=>Vc.FILTER_CONTAINS(t,e
${this.show_toolbar?wc`<span class="toolbar-buttons">${th(this.getButtons(),"")}</span>`:""}
${this.show_send_button?wc`<button type="submit" class="btn send-button fa fa-paper-plane" title="${e}"></button>`:""}
`}getButtons(){const e=[];if(this.show_emoji_button&&e.push(wc`<converse-emoji-dropdown .chatview=${this.chatview}></converse-dropdown>`),this.show_call_button){const t=wd("Start a call");e.push(wc`
<button class="toggle-call" @click=${this.toggleCall} title="${t}">
<converse-icon class="fa fa-phone" path-prefix="/dist" size="1em"></converse-icon>
</button>`)}const t=wd("Message characters remaining");Qc.settings.get("message_limit")&&e.push(wc`<span class="right message-limit" title="${t}">${this.message_limit}</span>`),this.show_spoiler_button&&e.push(this.getSpoilerButton());const n=Qc.disco.supports(bf.NS.HTTPUPLOAD,Vc.domain);if(e.push(wc`${th(n.then(e=>this.getHTTPUploadButton(e)),"")}`),this.show_occupants_toggle){const t=wd("Hide participants"),n=wd("Show participants");e.push(wc`
<button class="toggle_occupants right"
title="${this.hidden_occupants?n:t}"
@click=${this.toggleOccupants}>
<converse-icon class="fa ${this.hidden_occupants?"fa-angle-double-left":"fa-angle-double-right"}"
path-prefix="${Qc.settings.get("assets_path")}" size="1em"></converse-icon>
</button>`)}return Vc.api.hook("getToolbarButtons",this,e)}getHTTPUploadButton(e){if(e){const e=wd("Choose a file to send");return wc`
<button title="${e}" @click=${this.toggleFileUpload}>
<converse-icon class="fa fa-paperclip"
path-prefix="${Qc.settings.get("assets_path")}"
size="1em"></converse-icon>
</button>
<input type="file" @change=${this.onFileSelection} class="fileupload" multiple="" style="display:none"/>`}return""}getSpoilerButton(){const e=this.model;if(!this.is_groupchat&&0===e.presence.resources.length)return;let t;t=this.composing_spoiler?wd("Click to write as a normal (non-spoiler) message"):wd("Click to write your message as a spoiler");const n=wc`
<button class="toggle-compose-spoiler"
title="${t}"
@click=${this.toggleComposeSpoilerMessage}>
<converse-icon class="fa ${this.composing_spoiler?"fa-eye-slash":"fa-eye"}"
path-prefix="${Qc.settings.get("assets_path")}"
size="1em"></converse-icon>
</button>`;if(this.is_groupchat)return n;{const t=e.get("jid"),r=Promise.all(e.presence.resources.map(e=>Qc.disco.supports(bf.NS.SPOILER,`${t}/${e.get("name")}`))).then(e=>e.reduce((e,t)=>e&&t,!0));return wc`${th(r.then(()=>n),"")}`}}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),Qc.trigger("callButtonClicked",{connection:Vc.connection,model:this.model})}});class yf extends HTMLElement{async connectedCallback(){await Qc.waitUntil("initialized"),sl.insertInto(this)}}customElements.define("converse-root",yf);
2021-01-29 23:34:36 +01:00
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
2021-03-19 19:26:15 +01:00
const wf=new WeakMap,Sf=window.navigator.userAgent.indexOf("Trident/")>0,xf=Ka(e=>t=>{if(!(t instanceof lc))throw new Error("unsafeSVG can only be used in text bindings");const n=wf.get(t);if(void 0!==n&&sc(e)&&e===n.value&&t.value===n.fragment)return;const r=document.createElement("template"),i=r.content;let s;Sf?(r.innerHTML=`<svg>${e}</svg>`,s=i.firstChild):(s=document.createElementNS("http://www.w3.org/2000/svg","svg"),i.appendChild(s),s.innerHTML=e),i.removeChild(s),Pa(i,s.firstChild);const o=document.importNode(i,!0);t.setValue(o),wf.set(t,{value:e,fragment:o})});window.customElements.define("converse-fontawesome",class extends Kd{constructor(){super();const e=n.e(138).then(n.t.bind(null,543,7));this.data=e.then(e=>wc`${xf(e.default())}`)}render(){return wc`${th(this.data,"")}`}});var Ef=function(e,t,n){var r=null==e?0:e.length;return r?(t=n||void 0===t?1:pi(t),ks(e,t<0?0:t,r)):[]};var Af=function(e,t){var n=[];return _o(e,(function(e,r,i){t(e,r,i)&&n.push(e)})),n};var Cf=function(e,t){return(Oe(e)?st:Af)(e,Es(t,3))};var kf=function(e){return e&&e.length?e[0]:void 0};var jf=function(e){return"function"==typeof e?e:vr};var Tf=function(e,t){return(Oe(e)?ve:_o)(e,jf(t))};var Of=function(e,t){return zr(t,(function(t){return e[t]}))};var Nf=function(e){return null==e?[]:Of(e,Ye(e))},If=Math.max;var Mf=function(e,t,n,r){e=Qe(e)?e:Nf(e),n=n&&!r?pi(n):0;var i=e.length;return n<0&&(n=If(i+n,0)),Zt(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&Co(e,t,n)>-1};var Rf=function(e){return(null==e?0:e.length)?ks(e,0,-1):[]};var $f=function(e,t){return(Oe(e)?zr:Ko)(e,Es(t,3))};var Df=function(e,t,n){for(var r=-1,i=e.length;++r<i;){var s=e[r],o=t(s);if(null!=o&&(void 0===a?o==o&&!Or(o):n(o,a)))var a=o,c=s}return c};var Pf=function(e,t){return e>t};var Lf=function(e){return e&&e.length?Df(e,vr,Pf):void 0};var zf=function(e,t){return e<t};var Ff=function(e){return e&&e.length?Df(e,vr,zf):void 0};var Bf=function(e,t,n,r){var i=-1,s=null==e?0:e.length;for(r&&s&&(n=e[++i]);++i<s;)n=t(n,e[i],i,e);return n};var qf=function(e,t,n,r,i){return i(e,(function(e,i,s){n=r?(r=!1,e):t(n,e,i,s)})),n};var Uf=function(e,t,n){var r=Oe(e)?Bf:qf,i=arguments.length<3;return r(e,Es(t,4),n,i,_o)};var Hf=function(e,t,n,r){var i=null==e?0:e.length;for(r&&i&&(n=e[--i]);i--;)n=t(n,e[i],i,e);return n},Vf=Fi(!0);var Wf=vo((function(e,t){return e&&Vf(e,t,Ye)}),!0);var Gf=function(e,t,n){var r=Oe(e)?Hf:qf,i=arguments.length<3;return r(e,Es(t,4),n,i,Wf)};var Jf=function(e){if("function"!=typeof e)throw new TypeError("Expected a function");return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}};var Qf=function(e,t){return(Oe(e)?st:Af)(e,Jf(Es(t,3)))};var Yf=function(e,t){if("function"!=typeof e)throw new TypeError("Expected a function");return t=void 0===t?t:pi(t),Ar(e,t)},Kf=Math.floor,Xf=Math.random;var Zf=function(e,t){return e+Kf(Xf()*(t-e+1))};var ep=function(e){var t=e.length;return t?e[Zf(0,t-1)]:void 0};var tp=function(e){return ep(Nf(e))};var np=function(e){return(Oe(e)?ep:tp)(e)};var rp=function(e,t){var n=-1,r=e.length,i=r-1;for(t=void 0===t?r:t;++n<t;){var s=Zf(n,i),o=e[s];e[s]=e[n],e[n]=o}return e.length=t,e};var ip=function(e){return rp(it(e))};var sp=function(e){return rp(Nf(e))};var op=function(e){return(Oe(e)?ip:sp)(e)},ap=ws("length"),cp=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var lp=function(e){return cp.test(e)},up="[\\ud800-\\udfff]",dp="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",hp="\\ud83c[\\udffb-\\udfff]",fp="[^\\ud800-\\udfff]",pp="(?:\\ud83c[\\udde6-\\uddff]){2}",gp="[\\ud800-\\udbff][\\udc00-\\udfff]",mp="(?:"+dp+"|"+hp+")"+"?",vp="[\\ufe0e\\ufe0f]?"+mp+("(?:\\u200d(?:"+[fp,pp,gp].join("|")+")[\\ufe0e\\ufe0f]?"+mp+")*"),_p="(?:"+[fp+dp+"?",dp,pp,gp,up].join("|")+")",bp=RegExp(hp+"(?="+hp+")|"+_p+vp,"g");var yp=function(e){for(var t=bp.lastIndex=0;bp.test(e);)++t;return t};var wp=function(e){return lp(e)?yp(e):ap(e)};var Sp=function(e){if(n
2021-01-29 23:34:36 +01:00
/*!
* Copyright (c) JC Brand <jc@opkode.com>
*/
2021-03-19 19:26:15 +01:00
const Bp=function(e){this.views={},this.keys=()=>Object.keys(this.views),this.getAll=()=>this.views,this.get=e=>this.views[e],this.xget=e=>this.keys().filter(t=>t!==e).reduce((e,t)=>(e[t]=this.views[t],e),{}),this.add=(e,t)=>(this.views[e]=t,t),this.remove=e=>{void 0===e&&(new Md).remove.apply(this);const t=this.views[e];if(t)return delete this.views[e],t.remove(),t},this.removeAll=()=>(this.keys().forEach(e=>this.remove(e)),this),Md.apply(this,Array.prototype.slice.apply(arguments))},qp={includes:Mf,difference:No,drop:Ef,every:Ro,filter:Cf,find:fl,first:kf,forEach:Tf,head:kf,indexOf:Uo,initial:Rf,invoke:$a,isEmpty:ri,last:Cs,lastIndexOf:Jo,map:$f,max:Lf,min:Ff,reduce:Uf,reduceRight:Gf,reject:Qf,rest:Yf,sample:np,shuffle:op,size:Sp,some:Yo,sortBy:na,tail:xp,take:Ep,toArray:zp,without:Fp};Object.keys(qp).forEach(e=>{Bp.prototype[e]=function(){const t=Array.prototype.slice.call(arguments);return t.unshift(this.views),qp[e].apply(this,t)}}),Object.assign(Bp.prototype,Md.prototype),Bp.extend=Md.extend;const Up=Bp.extend({listItems:"model",sortEvent:"change",sortImmediatelyOnAdd:!1,listSelector:".ordered-items",ItemView:void 0,subviewIndex:"id",initialize(){this.sortEventually=Ma(()=>this.sortAndPositionAllItems(),100),this.items=vs(this,this.listItems),this.items.on("remove",this.removeView,this),this.items.on("reset",this.removeAll,this),this.items.on("add",(e,t)=>{this.sortImmediatelyOnAdd?this.sortAndPositionAllItems():this.sortEventually()}),this.sortEvent&&this.items.on(this.sortEvent,this.sortEventually,this)},createItemView(e){let t=this.get(e.get(this.subviewIndex));return t?(t.model=e,t.initialize()):(t=new this.ItemView({model:e}),this.add(e.get(this.subviewIndex),t)),t.render(),t},removeView(e){this.remove(e.get(this.subviewIndex))},sortAndPositionAllItems(){if(!this.items.length)return;this.items.sort();const e=this.el.querySelector(this.listSelector),t=document.createElement("div");e.parentNode.replaceChild(t,e),this.items.forEach(t=>{let n=this.get(t.get(this.subviewIndex));n||(n=this.createItemView(t)),e.insertAdjacentElement("beforeend",n.el)}),t.parentNode.replaceChild(e,t)}}),Hp=sl.env.utils,Vp=Md.extend({renderAvatar(e){const t=(e=e||this.el).querySelector("canvas.avatar, svg.avatar");if(null!==t&&this.model.vcard){const e={classes:t.getAttribute("class"),width:t.getAttribute("width"),height:t.getAttribute("height"),image_type:this.model.vcard.get("image_type"),image:this.model.vcard.get("image")};t.outerHTML=Hp.getElementFromTemplateResult(Hh(e)).outerHTML}}}),Wp=Bp.extend({_ensureElement(){if(this.el)this.setElement(Jr(this,"el"),!1);else{let e=Vc.root.querySelector("#conversejs");if(null===e){e=document.createElement("div"),e.setAttribute("id","conversejs"),Hp.addClass("theme-"+Qc.settings.get("theme"),e);const t=Vc.root.querySelector("body");t?t.appendChild(e):Vc.root.appendChild(e)}this.setElement(e,!1)}},initialize(){this.listenTo(this.model,"destroy",this.removeChat);const e=document.getElementById("conversejs-bg");e&&!e.innerHTML.trim()&&bc(wc`
<div class="inner-content converse-brand row">
<div class="converse-brand__padding"></div>
<div class="converse-brand__heading">
<svg height="200px"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 364 364"
version="1.1">
<title>Logo Converse</title>
<defs>
<linearGradient id="gradient" x1="92.14" y1="27.64" x2="267.65" y2="331.62" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#fff1d1"/>
<stop offset="0.05" stop-color="#fae8c1"/>
<stop offset="0.15" stop-color="#f0d5a1"/>
<stop offset="0.27" stop-color="#e7c687"/>
<stop offset="0.4" stop-color="#e1bb72"/>
<stop offset="0.54" stop-color="#dcb264"/>
<stop offset="0.71" stop-color="#daad5c"/>
<stop offset="1" stop-color="#d9ac59"/>
</linearGradient>
<filter id="shadow">
<feGaussianBlur in="SourceAlpha" stdDeviation="2.3" result="blur1"/>
<feOffset in="blur1" dx="3" dy="3" result="blur2"/>
<feColorMatrix in="blur2" type="matrix" result="blur3"
values="1 0 0 0 0.1
0 1 0 0 0.1
0 0 1 0 0.1
0 0 0 1 0"/>
<feMerge>
<feMergeNode in="blur3"/>
<feMergeNode in="SourceGraphic"/>
</feMerge>
</filter>
</defs>
<g filter="url(#shadow)">
<path d="M221.46,103.71c0,18.83-29.36,18.83-29.12,0C192.1,84.88,221.46,84.88,221.46,103.71Z" fill="#d9ac59"/>
<path d="M179.9,4.15A175.48,175.48,0,1,0,355.38,179.63,175.48,175.48,0,0,0,179.9,4.15Zm-40.79,264.5c-.23-17.82,27.58-17.82,27.58,0S138.88,286.48,139.11,268.65ZM218.6,168.24A79.65,79.65,0,0,1,205.15,174a12.76,12.76,0,0,0-6.29,4.65L167.54,222a1.36,1.36,0,0,1-2.46-.8v-35.8a2.58,2.58,0,0,0-3.06-2.53c-15.43,3-30.23,7.7-42.73,19.94-38.8,38-29.42,105.69,16.09,133.16a162.25,162.25,0,0,1-91.47-67.27C-3.86,182.26,34.5,47.25,138.37,25.66c46.89-9.75,118.25,5.16,123.73,62.83C265.15,120.64,246.56,152.89,218.6,168.24Z" fill="url(#gradient)"/>
</g>
</svg>
<span class="converse-brand__text">
<span>converse<span class="subdued">.js</span></span>
<p class="byline">messaging freedom</p>
</span>
</div>
</div>`,e);document.querySelector("body").classList.add("converse-"+Qc.settings.get("view_mode")),this.el.classList.add("converse-"+Qc.settings.get("view_mode")),Qc.settings.get("singleton")&&this.el.classList.add("converse-singleton"),this.render()},render(){this._ensureElement(),bc(wc`
<div class="converse-chatboxes row no-gutters"></div>
<div id="converse-modals" class="modals"></div>
<converse-fontawesome></converse-fontawesome>
`,this.el),this.row_el=this.el.querySelector(".row")},insertRowColumn(e){this.row_el.insertAdjacentElement("afterBegin",e)},removeChat(e){this.remove(e.get("id"))},closeAllChatBoxes(){return Promise.all(this.map(e=>e.close({name:"closeAllChatBoxes"})))}});
2021-01-29 23:34:36 +01:00
/**
* @module converse-chatboxviews
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
2021-03-19 19:26:15 +01:00
*/function Gp(){Vc.chatboxviews=new Vc.ChatBoxViews({model:Vc.chatboxes}),Qc.trigger("chatBoxViewsInitialized")}function Jp(){const e=.01*window.innerHeight;document.documentElement.style.setProperty("--vh",e+"px")}sl.plugins.add("converse-chatboxviews",{dependencies:["converse-chatboxes","converse-vcard"],initialize(){Qc.elements.register(),Qc.promises.add(["chatBoxViewsInitialized"]),Qc.settings.extend({animate:!0,theme:"default"}),Vc.ViewWithAvatar=Vp,Vc.ChatBoxViews=Wp,Qc.listen.on("chatBoxesInitialized",Gp),Qc.listen.on("cleanup",()=>delete Vc.chatboxviews),Qc.listen.on("clearSession",()=>Vc.chatboxviews.closeAllChatBoxes()),Qc.listen.on("chatBoxViewsInitialized",Jp),window.addEventListener("resize",Jp),Object.assign(sl,{insertInto(e){var t;const n=null===(t=Vc.chatboxviews)||void 0===t?void 0:t.el;if(n&&!e.contains(n))e.insertAdjacentElement("afterBegin",n),Qc.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 Qp=e=>wc`
<div class="flyout box-flyout">
<div class="chat-head chat-head-chatbox row no-gutters"></div>
<div class="chat-body">
<div class="chat-content ${e.show_send_button?"chat-content-sendbutton":""}" aria-live="polite">
<div class="chat-content__messages" @scroll=${e.markScrolled}></div>
<div class="chat-content__help"></div>
</div>
<div class="bottom-panel">
<div class="message-form-container">
</div>
</div>
</div>
`;const Yp=e=>{const t=wd("OMEMO Fingerprints"),n=wd("No OMEMO-enabled devices found"),r=e.view.devicelist.devices;return wc`
<hr/>
<ul class="list-group fingerprints">
<li class="list-group-item active">${t}</li>
${r.length?r.map(t=>(e=>{const t=wd("Trusted"),n=wd("Untrusted");return e.device.get("bundle")&&e.device.get("bundle").fingerprint?wc`
<li class="list-group-item">
<form class="fingerprint-trust">
<div class="btn-group btn-group-toggle">
<label class="btn btn--small ${-1!==e.device.get("trusted")?"btn-primary active":"btn-secondary"}">
<input type="radio" name="${e.device.get("id")}" value="1" ?checked=${-1!==e.device.get("trusted")}>${t}
</label>
<label class="btn btn--small ${-1!==e.device.get("trusted")?"btn-primary active":"btn-secondary"}">
<input type="radio" name="${e.device.get("id")}" value="-1" ?checked=${-1===e.device.get("trusted")}>${n}
</label>
</div>
<code class="fingerprint">${e.utils.formatFingerprint(e.device.get("bundle").fingerprint)}</code>
</form>
</li>
`:""})(Object.assign({device:t},e))):wc`<li class="list-group-item"> ${n} </li>`}
</ul>
`};var Kp=e=>{const t=wd("XMPP Address"),n=wd("Email"),r=wd("Full Name"),i=wd("Nickname"),s=wd("The User's Profile Image"),o=wd("Refresh"),a=wd("Role"),c=wd("URL"),l={alt_text:s,extra_classes:"mb-3",height:"120",width:"120"};return wc`
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="user-details-modal-label">${e.display_name}</h5>
${qd}
</div>
<div class="modal-body">
${e.image?wc`<div class="mb-4">${Hh(Object.assign(e,l))}</div>`:""}
${e.fullname?wc`<p><label>${r}:</label> ${e.fullname}</p>`:""}
<p><label>${t}:</label> <a href="xmpp:${e.jid}">${e.jid}</a></p>
${e.nickname?wc`<p><label>${i}:</label> ${e.nickname}</p>`:""}
${e.url?wc`<p><label>${c}:</label> <a target="_blank" rel="noopener" href="${e.url}">${e.url}</a></p>`:""}
${e.email?wc`<p><label>${n}:</label> <a href="mailto:${e.email}">${e.email}</a></p>`:""}
${e.role?wc`<p><label>${a}:</label> ${e.role}</p>`:""}
${e._converse.pluggable.plugins["converse-omemo"].enabled(e._converse)?Yp(e):""}
</div>
<div class="modal-footer">
${Bd}
<button type="button" class="btn btn-info refresh-contact"><i class="fa fa-refresh"> </i>${o}</button>
${e.allow_contact_removal&&e.is_roster_contact?(e=>{const t=wd("Remove as contact");return wc`
<button type="button" @click="${e.removeContact}" class="btn btn-danger remove-contact">
<i class="far fa-trash-alt"></i>${t}
</button>
`})(e):""}
</div>
</div>
</div>
`};
2021-01-29 23:34:36 +01:00
/**
* @module converse-chatview
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
2021-03-19 19:26:15 +01:00
*/const{Strophe:Xp,dayjs:Zp}=sl.env,eg=sl.env.utils,tg=Md.extend({length:200,className:"chatbox hidden",is_chatroom:!1,events:{"click .chatbox-navback":"showControlBox","click .new-msgs-indicator":"viewUnreadMessages","click .send-button":"onFormSubmitted","click .toggle-clear":"clearMessages","input .chat-textarea":"inputChanged","keydown .chat-textarea":"onKeyDown","keyup .chat-textarea":"onKeyUp","paste .chat-textarea":"onPaste"},async initialize(){this.initDebounced(),this.listenTo(this.model,"change:composing_spoiler",this.renderMessageForm),this.listenTo(this.model,"change:hidden",e=>e.get("hidden")?this.hide():this.show()),this.listenTo(this.model,"change:status",this.onStatusMessageChanged),this.listenTo(this.model,"destroy",this.remove),this.listenTo(this.model,"show",this.show),this.listenTo(this.model,"vcard:change",this.renderHeading),this.model.contact&&this.listenTo(this.model.contact,"destroy",this.renderHeading),this.model.rosterContactAdded&&this.model.rosterContactAdded.then(()=>{this.listenTo(this.model.contact,"change:nickname",this.renderHeading),this.renderHeading()}),this.listenTo(this.model.presence,"change:show",this.onPresenceChanged),this.render(),this.listenTo(this.model.messages,"add",this.onMessageAdded),this.listenTo(this.model.messages,"remove",this.renderChatHistory),this.listenTo(this.model.messages,"rendered",this.maybeScrollDown),this.listenTo(this.model.messages,"reset",this.renderChatHistory),this.listenTo(this.model.notifications,"change",this.renderNotifications),this.listenTo(this.model,"change:show_help_messages",this.renderHelpMessages),await this.model.messages.fetched,this.insertIntoDOM(),this.model.maybeShow(),this.scrollDown(),Qc.trigger("chatBoxViewInitialized",this)},initDebounced(){this.markScrolled=Ma(this._markScrolled,100),this.debouncedScrollDown=Ma(this.scrollDown,100),Qc.settings.get("debounced_content_rendering")?(this.renderChatHistory=Ma(()=>this.renderChatContent(!1),100),this.renderNotifications=Ma(()=>this.renderChatContent(!0),100)):(this.renderChatHistory=()=>this.renderChatContent(!1),this.renderNotifications=()=>this.renderChatContent(!0))},render(){const e=Qp(Object.assign(this.model.toJSON(),{markScrolled:e=>this.markScrolled(e)}));return bc(e,this.el),this.content=this.el.querySelector(".chat-content"),this.notifications=this.el.querySelector(".chat-content__notifications"),this.msgs_container=this.el.querySelector(".chat-content__messages"),this.help_container=this.el.querySelector(".chat-content__help"),this.renderChatContent(),this.renderMessageForm(),this.renderHeading(),this},onMessageAdded(e){this.renderChatHistory(),eg.isNewMessage(e)&&("me"===e.get("sender")?this.model.set("scrolled",!1):this.model.get("scrolled",!0)&&this.showNewMessagesIndicator())},getNotifications(){return this.model.notifications.get("chat_state")===Vc.COMPOSING?wd("%1$s is typing",this.model.getDisplayName()):this.model.notifications.get("chat_state")===Vc.PAUSED?wd("%1$s has stopped typing",this.model.getDisplayName()):this.model.notifications.get("chat_state")===Vc.GONE?wd("%1$s has gone away",this.model.getDisplayName()):""},getHelpMessages:()=>["<strong>/clear</strong>: "+wd("Remove messages"),"<strong>/close</strong>: "+wd("Close this chat"),"<strong>/me</strong>: "+wd("Write in the third person"),"<strong>/help</strong>: "+wd("Show this menu")],renderHelpMessages(){bc(wc`<converse-chat-help
.model=${this.model}
.messages=${this.getHelpMessages()}
?hidden=${!this.model.get("show_help_messages")}
type="info"
chat_type="${this.model.get("type")}"></converse-chat-help>`,this.help_container)},renderChatContent(e=!1){this.tpl_chat_content||(this.tpl_chat_content=e=>wc`
<converse-chat-content
.chatview=${this}
.messages=${e.messages}
notifications=${e.notifications}>
</converse-chat-content>`);const t=this.model.messages.models,n=e?t:Array.from(t);bc(this.tpl_chat_content({messages:n,notifications:this.getNotifications()}),this.msgs_container)},renderToolbar(){if(!Qc.settings.get("show_toolbar"))return this;const e=Object.assign({model:this.model,chatview:this},this.model.toJSON(),this.getToolbarOptions());return bc((e=>{const t=Qc.settings.get("message_limit"),n=Qc.settings.get("visible_toolbar_buttons").call,r=Qc.settings.get("visible_toolbar_buttons").emoji,i=Qc.settings.get("show_send_button"),s=Qc.settings.get("visible_toolbar_buttons").spoiler,o=Qc.settings.get("show_toolbar");return wc`
<converse-chat-toolbar
.chatview=${e.chatview}
.model=${e.model}
?composing_spoiler="${e.composing_spoiler}"
?hidden_occupants="${e.hidden_occupants}"
?is_groupchat="${e.is_groupchat}"
?show_call_button="${n}"
?show_emoji_button="${r}"
?show_occupants_toggle="${e.show_occupants_toggle}"
?show_send_button="${i}"
?show_spoiler_button="${s}"
?show_toolbar="${o}"
message_limit="${t}"
></converse-chat-toolbar>
`})(e),this.el.querySelector(".chat-toolbar")),Qc.trigger("renderToolbar",this),this},renderMessageForm(){var e,t;const n=this.el.querySelector(".message-form-container");var r;bc((r=Object.assign(this.model.toJSON(),{hint_value:null===(e=this.el.querySelector(".spoiler-hint"))||void 0===e?void 0:e.value,label_message:this.model.get("composing_spoiler")?wd("Hidden message"):wd("Message"),label_spoiler_hint:wd("Optional hint"),message_value:null===(t=this.el.querySelector(".chat-textarea"))||void 0===t?void 0:t.value,show_send_button:Qc.settings.get("show_send_button"),show_toolbar:Qc.settings.get("show_toolbar"),unread_msgs:wd("You have unread messages")}),wc`
<div class="new-msgs-indicator hidden"> ${r.unread_msgs} </div>
<form class="setNicknameButtonForm hidden">
<input type="submit" class="btn btn-primary" name="join" value="Join"/>
</form>
<form class="sendXMPPMessage">
<span class="chat-toolbar no-text-select"></span>
<input type="text" placeholder="${r.label_spoiler_hint||""}" value="${r.hint_value||""}" class="${r.composing_spoiler?"":"hidden"} spoiler-hint"/>
<div class="suggestion-box">
<ul class="suggestion-box__results suggestion-box__results--above" hidden=""></ul>
<textarea
type="text"
class="chat-textarea suggestion-box__input
${r.show_send_button?"chat-textarea-send-button":""}
${r.composing_spoile?"spoiler":""}"
placeholder="${r.label_message}">${r.message_value||""}</textarea>
<span class="suggestion-box__additions visually-hidden" role="status" aria-live="assertive" aria-relevant="additions"></span>
</div>
</form>
`),n),this.el.addEventListener("focusin",e=>this.emitFocused(e)),this.el.addEventListener("focusout",e=>this.emitBlurred(e)),this.renderToolbar()},showControlBox(){var e;null===(e=Vc.chatboxviews.get("controlbox"))||void 0===e||e.show(),this.hide()},showUserDetailsModal(e){e.preventDefault(),void 0===this.user_details_modal&&(this.user_details_modal=new Vc.UserDetailsModal({model:this.model})),this.user_details_modal.show(e)},onDragOver(e){e.preventDefault()},onDrop(e){0!=e.dataTransfer.files.length&&(e.preventDefault(),this.model.sendFiles(e.dataTransfer.files))},async renderHeading(){const e=await this.generateHeadingTemplate();bc(e,this.el.querySelector(".chat-head-chatbox"))},async getHeadingStandaloneButton(e){const t=await e;return wc`<a href="#"
class="chatbox-btn ${t.a_class} fa ${t.icon_class}"
@click=${t.handler}
title="${t.i18n_title}"></a>`},async getHeadingDropdownItem(e){const t=await e;return wc`<a href="#"
class="dropdown-item ${t.a_class}"
@click=${t.handler}
title="${t.i18n_title}"><i class="fa ${t.icon_class}"></i>${t.i18n_text}</a>`},async generateHeadingTemplate(){var e;const t=null===(e=this.model)||void 0===e?void 0:e.vcard,n=t?t.toJSON():{},r=await this.getHeadingButtons(),i=r.filter(e=>e.standalone),s=r.filter(e=>!e.standalone);return(e=>{const t={alt_text:wd("The User's Profile Image"),extra_classes:"",height:40,width:40};return wc`
<div class="chatbox-title ${e.status?"":"chatbox-title--no-desc"}">
<div class="chatbox-title--row">
${e._converse.api.settings.get("singleton")?"":wc`<div class="chatbox-navback"><i class="fa fa-arrow-left"></i></div>`}
${e.type!==e._converse.HEADLINES_TYPE?wc`<span class="mr-2">${Hh(Object.assign({},e,t))}</span>`:""}
<div class="chatbox-title__text" title="${e.jid}">
${e.url?wc`<a href="${e.url}" target="_blank" rel="noopener" class="user">${e.display_name}</a>`:e.display_name}
</div>
</div>
<div class="chatbox-title__buttons row no-gutters">
${e.dropdown_btns.length?wc`<converse-dropdown .items=${e.dropdown_btns}></converse-dropdown>`:""}
${e.standalone_btns.length?(e=>e.standalone_btns.reverse().map(e=>th(e,"")))(e):""}
</div>
</div>
${e.status?wc`<p class="chat-head__desc">${e.status}</p>`:""}
`})(Object.assign(n,this.model.toJSON(),{_converse:Vc,dropdown_btns:s.map(e=>this.getHeadingDropdownItem(e)),standalone_btns:i.map(e=>this.getHeadingStandaloneButton(e)),display_name:this.model.getDisplayName()}))},getHeadingButtons(){const e=[{a_class:"show-user-details-modal",handler:e=>this.showUserDetailsModal(e),i18n_text:wd("Details"),i18n_title:wd("See more information about this person"),icon_class:"fa-id-card",name:"details",standalone:"overlayed"===Qc.settings.get("view_mode")}];return Qc.settings.get("singleton")||e.push({a_class:"close-chatbox-button",handler:e=>this.close(e),i18n_text:wd("Close"),i18n_title:wd("Close and end this conversation"),icon_class:"fa-times",name:"close",standalone:"overlayed"===Qc.settings.get("view_mode")}),Vc.api.hook("getHeadingButtons",this,e)},getToolbarOptions:()=>({}),maybeScrollDown(e){!(!(null!=e&&e.get("is_archived"))&&"me"===(null==e?void 0:e.get("sender")))&&this.model.get("scrolled")||this.model.isHidden()||this.debouncedScrollDown()},scrollDown(e){var t,n;if(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")&&eg.safeSave(this.model,{scrolled:!1,scrollTop:null}),this.msgs_container.scrollTo){const e=this.msgs_container.scrollTop?"smooth":"auto";this.msgs_container.scrollTo({top:this.msgs_container.scrollHeight,behavior:e})}else this.msgs_container.scrollTop=this.msgs_container.scrollHeight;this.onScrolledDown()},maintainScrollTop(){const e=this.model.get("scrollTop");e?this.msgs_container.scrollTop=e:this.scrollDown()},insertIntoDOM(){return Vc.chatboxviews.insertRowColumn(this.el),Qc.trigger("chatBoxInsertedIntoDOM",this),this},addSpinner(e=!1){if(null===this.el.querySelector(".spinner")){const t=eg.getElementFromTemplateResult(Wh());e?(this.content.insertAdjacentElement("beforeend",t),this.scrollDown()):this.content.insertAdjacentElement("afterbegin",t)}},clearSpinner(){this.content.querySelectorAll(".spinner").forEach(eg.removeElement)},onStatusMessageChanged(e){this.renderHeading(),Qc.trigger("contactStatusMessageChanged",{contact:e.attributes,message:e.get("status")})},markFollowups(e){const t=e.getAttribute("data-from"),n=e.previousElementSibling,r=Zp(e.getAttribute("data-isodate")),i=e.nextElementSibling;eg.hasClass("chat-msg--action",e)||eg.hasClass("chat-msg--action",n)||eg.hasClass("chat-info",e)||eg.hasClass("chat-info",n)||n.getAttribute("data-from")!==t||!r.isBefore(Zp(n.getAttribute("data-isodate")).add(10,"minutes"))||e.getAttribute("data-encrypted")!==n.getAttribute("data-encrypted")||eg.addClass("chat-msg--followup",e),i&&(!eg.hasClass("chat-msg--action",e)&&eg.hasClass("chat-info",e)&&i.getAttribute("data-from")===t&&Zp(i.getAttribute("data-isodate")).isBefore(r.add(10,"minutes"))&&e.getAttribute("data-encrypted")===i.getAttribute("data-encrypted")?eg.addClass("chat-msg--followup",i):eg.removeClass("chat-msg--followup",i))},parseMessageForCommands(e){const t=e.replace(/^\s*/,"").match(/^\/(.*)\s*$/);if(t){if("clear"===t[1])return this.clearMessages(),!0;if("close"===t[1])return this.close(),!0;if("help"===t[1])return this.model.set({show_help_messages:!0}),!0}},async onFormSubmitted(e){var t;e.preventDefault();const n=this.el.querySelector(".chat-textarea"),r=n.value.trim();if(Qc.settings.get("message_limit")&&r.length>Qc.settings.get("message_limit")||!r.replace(/\s/g,"").length)return;if(!Vc.connection.authenticated){const e=wd("Sorry, the connection has been lost, and your message could not be sent");return Qc.alert("error",wd("Error"),e),void Qc.connection.reconnect()}let i,s={};this.model.get("composing_spoiler")&&(s=this.el.querySelector("form.sendXMPPMessage input.spoiler-hint"),i=s.value),eg.addClass("disabled",n),n.setAttribute("disabled","disabled"),null===(t=this.el.querySelector("converse-emoji-dropdown"))||void 0===t||t.hideMenu();const o=this.parseMessageForCommands(r),a=o?null:await this.model.sendMessage(r,i);(o||a)&&(s.value="",n.value="",eg.removeClass("correcting",n),n.style.height="auto",this.updateCharCounter(n.value)),a&&Qc.trigge
<a class="brand-heading" href="https://conversejs.org" target="_blank" rel="noopener">
<span class="brand-name-wrapper ${t?"brand-name-wrapper--fullscreen":""}">
<svg class="converse-svg-logo"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 364 364">
<title>Converse</title>
<g class="cls-1" id="g904">
<g data-name="Layer 2">
<g data-name="Layer 7">
<path
class="cls-3"
d="M221.46,103.71c0,18.83-29.36,18.83-29.12,0C192.1,84.88,221.46,84.88,221.46,103.71Z" />
<path
class="cls-4"
d="M179.9,4.15A175.48,175.48,0,1,0,355.38,179.63,175.48,175.48,0,0,0,179.9,4.15Zm-40.79,264.5c-.23-17.82,27.58-17.82,27.58,0S138.88,286.48,139.11,268.65ZM218.6,168.24A79.65,79.65,0,0,1,205.15,174a12.76,12.76,0,0,0-6.29,4.65L167.54,222a1.36,1.36,0,0,1-2.46-.8v-35.8a2.58,2.58,0,0,0-3.06-2.53c-15.43,3-30.23,7.7-42.73,19.94-38.8,38-29.42,105.69,16.09,133.16a162.25,162.25,0,0,1-91.47-67.27C-3.86,182.26,34.5,47.25,138.37,25.66c46.89-9.75,118.25,5.16,123.73,62.83C265.15,120.64,246.56,152.89,218.6,168.24Z" />
</g>
</g>
</g>
</svg>
<span class="brand-name">
<span class="brand-name__text">converse<span class="subdued">.js</span></span>
${t?wc`<p class="byline">messaging freedom</p>`:""}
</span>
</span>
</a>
${t?wc`
<p class="brand-subtitle">${e.version_name}</p>
<p class="brand-subtitle"><a target="_blank" rel="nofollow" href="https://conversejs.org">Open Source</a> XMPP chat client brought to you by <a target="_blank" rel="nofollow" href="https://opkode.com">Opkode</a> </p>
<p class="brand-subtitle"><a target="_blank" rel="nofollow" href="https://hosted.weblate.org/projects/conversejs/#languages">Translate</a> it into your own language</p>`:""}
`},{useShadowDOM:!1}));var jg=n(172),Tg=n.n(jg);const Og=e=>{const t=wd("Log in"),n=wd("XMPP Address");return wc`
<div class="form-group">
<label for="converse-login-jid">${n}:</label>
<input id="converse-login-jid"
?autofocus=${!!Qc.settings.get("auto_focus")}
required
class="form-control"
type="text"
name="jid"
placeholder="${e.placeholder_username}"/>
</div>
${e.authentication!==e.EXTERNAL?(()=>{const e=wd("Password");return wc`
<div class="form-group">
<label for="converse-login-password">${e}</label>
<input id="converse-login-password" class="form-control" required="required" type="password" name="password" placeholder="${e}"/>
</div>
`})():""}
${e.show_trust_checkbox?(e=>{const t=wd("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=wd("This is a trusted device");return wc`
<div class="form-group form-check login-trusted">
<input id="converse-login-trusted" type="checkbox" class="form-check-input" name="trusted" ?checked=${e}>
<label for="converse-login-trusted" class="form-check-label login-trusted__desc">${n}</label>
<i class="fa fa-info-circle" data-toggle="popover"
data-title="Trusted device?"
data-content="${t}"></i>
</div>
`})("off"!==e.show_trust_checkbox):""}
<fieldset class="buttons">
<input class="btn btn-primary" type="submit" value="${t}"/>
</fieldset>
${Vc.allow_registration&&!Qc.settings.get("auto_login")&&Vc.pluggable.plugins["converse-register"].enabled(Vc)?(()=>{const e=wd("Create an account"),t=wd("Don't have a chat account?");return wc`
<fieldset class="switch-form">
<p>${t}</p>
<p><a class="register-account toggle-register-login" href="#converse/register">${e}</a></p>
</fieldset>
`})():""}
`};var Ng=e=>wc`
<converse-brand-heading></converse-brand-heading>
<form id="converse-login" class="converse-form" method="post">
<div class="conn-feedback fade-in ${e.conn_feedback_subject?e.conn_feedback_class:"hidden"}">
<p class="feedback-subject">${e.conn_feedback_subject}</p>
<p class="feedback-message ${e.conn_feedback_message?"":"hidden"}">${e.conn_feedback_message}</p>
</div>
${"CONNECTING"===Vc.CONNECTION_STATUS[e.connection_status]?Wh({classes:"hor_centered"}):(e=>{const t=wd("Disconnected"),n=wd("Click here to log in anonymously");return wc`
${e.authentication==e.LOGIN||e.authentication==e.EXTERNAL?Og(e):""}
${e.authentication==e.ANONYMOUS?wc`<input class="btn btn-primary login-anon" type="submit" value="${n}">`:""}
${e.authentication==e.PREBIND?wc`<p>${t}</p>`:""}
`})(e)}
</form>
`;
2021-01-29 23:34:36 +01:00
/**
* @module converse-controlbox
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
2021-03-19 19:26:15 +01:00
*/const{Strophe:Ig,dayjs:Mg}=sl.env,Rg=sl.env.utils,$g={Error:"error",Connecting:"info","Connection failure":"error",Authenticating:"info","Authentication failure":"error",Connected:"info",Disconnected:"error",Disconnecting:"warn",Attached:"info",Redirect:"info",Reconnecting:"warn"},Dg={0:"Error",1:"Connecting",2:"Connection failure",3:"Authenticating",4:"Authentication failure",5:"Connected",6:"Disconnected",7:"Disconnecting",8:"Attached",9:"Redirect",10:"Reconnecting"},Pg=[0,1,2,3,4,7,10];sl.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(){function e(){const e=new Vc.ControlBox({id:"controlbox"});return Vc.chatboxes.add(e)}Qc.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}),Qc.promises.add("controlBoxInitialized"),Vc.ControlBox=Vc.ChatBox.extend({defaults(){return{bookmarked:!1,box_id:"controlbox",chat_state:void 0,closed:!Qc.settings.get("show_controlbox_by_default"),num_unread:0,time_opened:this.get("time_opened")||(new Date).getTime(),type:Vc.CONTROLBOX_TYPE,url:""}},initialize(){"controlbox"===this.get("id")?this.set({time_opened:Mg(0).valueOf()}):Vc.ChatBox.prototype.initialize.apply(this,arguments)},validate(e){return e.type===Vc.CONTROLBOX_TYPE?"embedded"===Qc.settings.get("view_mode")&&Qc.settings.get("singleton")?"Controlbox not relevant in embedded view mode":void 0:Vc.ChatBox.prototype.validate.call(this,e)},maybeShow(e){return e||"controlbox"!==this.get("id")?Vc.ChatBox.prototype.maybeShow.call(this,e):this},onReconnection:function(){}}),Vc.ControlBoxView=Vc.ChatBoxView.extend({tagName:"div",className:"chatbox",id:"controlbox",events:{"click a.close-chatbox-button":"close"},initialize(){void 0===Vc.controlboxtoggle&&(Vc.controlboxtoggle=new Vc.ControlBoxToggle),Vc.controlboxtoggle.el.insertAdjacentElement("afterend",this.el),this.listenTo(this.model,"change:connected",this.onConnected),this.listenTo(this.model,"destroy",this.hide),this.listenTo(this.model,"hide",this.hide),this.listenTo(this.model,"show",this.show),this.listenTo(this.model,"change:closed",this.ensureClosedState),this.render(),Qc.trigger("controlBoxInitialized",this)},render(){this.model.get("connected")&&void 0===this.model.get("closed")&&this.model.set("closed",!Qc.settings.get("show_controlbox_by_default"));const e=(t={sticky_controlbox:Qc.settings.get("sticky_controlbox"),...this.model.toJSON()},wc`
<div class="flyout box-flyout">
<div class="chat-head controlbox-head">
${t.sticky_controlbox?"":wc`<a class="chatbox-btn close-chatbox-button fa fa-times"></a>`}
</div>
<div class="controlbox-panes"></div>
</div>`);var t;bc(e,this.el),this.model.get("closed")?this.hide():this.show();const n=(null==Vc?void 0:Vc.connection)||{};return n.connected&&n.authenticated&&!n.disconnecting?this.model.get("connected")&&this.renderControlBoxPane():this.renderLoginPanel(),this},onConnected(){this.model.get("connected")&&this.render()},renderLoginPanel(){if(this.el.classList.add("logged-out"),this.loginpanel)this.loginpanel.render();else{this.loginpanel=new Vc.LoginPanel({model:new Vc.LoginPanelModel});const e=this.el.querySelector(".controlbox-panes");e.innerHTML="",e.appendChild(this.loginpanel.render().el)}return this.loginpanel.initPopovers(),this},renderControlBoxPane(){this.loginpanel&&(this.loginpanel.remove(),delete this.loginpanel),this.controlbox_pane&&Rg.isVisible(this.controlbox_pane.el)||(this.el.classList.remove("logged-out"),this.controlbox_pane=new Vc.ControlBoxPane,this.el.querySelector(".controlbox-panes").insertAdjacentElement("afterBegin",this.controlbox_pane.el))},async close(e){if(e&&e.preventDefault&&e.preventDefault(),"closeAllChatBoxes"===(null==e?void 0:e.name)&&(Vc.disconnection_cause!==Vc.LOGOUT||Qc.settings.get("show_controlbox_by_default")))return;if(Qc.settings.get("sticky_controlbox"))return;const t=(null==Vc?void 0:Vc.connection)||{};return t.connected&&!t.disconnecting?await new Promise((e,t)=>this.model.save({closed:!0},{success:e,error:t,wait:!0})):this.model.trigger("hide"),Qc.trigger("controlBoxClosed",this),this},ensureClosedState(){this.model.get("closed")?this.hide():this.show()},hide(e){if(!Qc.settings.get("sticky_controlbox"))return Rg.addClass("hidden",this.el),Qc.trigger("chatBoxClosed",this),Qc.connection.connected()||Vc.controlboxtoggle.render(),Vc.controlboxtoggle.show(e),this},onControlBoxToggleHidden(){this.model.set("closed",!1),this.el.classList.remove("hidden"),Qc.trigger("controlBoxOpened",this)},show(){return Vc.controlboxtoggle.hide(()=>this.onControlBoxToggleHidden()),this},showHelpMessages(){}}),Vc.LoginPanelModel=Bs.extend({defaults:{errors:[]}}),Vc.LoginPanel=Md.extend({tagName:"div",id:"converse-login-panel",className:"controlbox-pane fade-in row no-gutters",events:{"submit form#converse-login":"authenticate","change input":"validate"},initialize(){this.listenTo(this.model,"change",this.render),this.listenTo(Vc.connfeedback,"change",this.render),this.render()},toHTML(){const e=Vc.connfeedback.get("connection_status");let t,n;return Pg.includes(e)&&(n=Dg[e],t=$g[n]),Ng(Object.assign(this.model.toJSON(),{_converse:Vc,ANONYMOUS:Vc.ANONYMOUS,EXTERNAL:Vc.EXTERNAL,LOGIN:Vc.LOGIN,PREBIND:Vc.PREBIND,auto_login:Qc.settings.get("auto_login"),authentication:Qc.settings.get("authentication"),connection_status:e,conn_feedback_class:t,conn_feedback_subject:n,conn_feedback_message:Vc.connfeedback.get("message"),placeholder_username:(Qc.settings.get("locked_domain")||Qc.settings.get("default_domain"))&&wd("Username")||wd("user@domain"),show_trust_checkbox:Qc.settings.get("allow_user_trust_override")}))},initPopovers(){Array.from(this.el.querySelectorAll("[data-title]")).forEach(e=>{new Fd.a.Popover(e,{trigger:"mobile"===Qc.settings.get("view_mode")?"click":"hover",dismissible:"mobile"===Qc.settings.get("view_mode"),container:this.el.parentElement.parentElement.parentElement})})},validate(){const e=this.el.querySelector("form").querySelector("input[name=jid]");return!e.value||Qc.settings.get("locked_domain")||Qc.settings.get("default_domain")||Rg.isValidJID(e.value)?(e.setCustomValidity(""),!0):(e.setCustomValidity(wd("Please enter a valid XMPP address")),!1)},authenticate(e){if(e&&e.preventDefault&&e.preventDefault(),Qc.settings.get("authentication")===Vc.ANONYMOUS)return this.connect(Vc.jid,null);if(!this.validate())return;const t=new FormData(e.target);Vc.config.save({trusted:!!t.get("trusted")});let n=t.get("jid");if(Qc.settings.get("locked_domain")){const e="@"+Qc.settings.get("locked_domain");n.endsWith(e)&&(n=n.substr(0,n.length-e.length)),n=Ig.escapeNode(n)+e}else Qc.settings.get("default_domain")&&!n.includes("@")&&(n=n+"@"+Qc.settings.get("default_domain"));this.connect(n,t.get("
2021-01-29 23:34:36 +01:00
/**
* @module converse-dragresize
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/
2021-03-19 19:26:15 +01:00
const Fg=sl.env.utils;function Bg(e,t){const n=t.el.querySelector(".box-flyout"),r=document.createElement("div");r.innerHTML=zg()(),n.insertBefore(r,n.firstChild)}sl.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:Fg.applyDragResistance(t,this.get("default_height")),width:Fg.applyDragResistance(n,this.get("default_width"))}),e}},ChatBoxView:{events:{"mousedown .dragresize-top":"onStartVerticalResize","mousedown .dragresize-left":"onStartHorizontalResize","mousedown .dragresize-topleft":"onStartDiagonalResize"},render(){const e=this.__super__.render.apply(this,arguments);return Bg(this.__super__._converse,this),this.setWidth(),e}},HeadlinesBoxView:{events:{"mousedown .dragresize-top":"onStartVerticalResize","mousedown .dragresize-left":"onStartHorizontalResize","mousedown .dragresize-topleft":"onStartDiagonalResize"},render(){const e=this.__super__.render.apply(this,arguments);return Bg(this.__super__._converse,this),this.setWidth(),e}},ControlBoxView:{events:{"mousedown .dragresize-top":"onStartVerticalResize","mousedown .dragresize-left":"onStartHorizontalResize","mousedown .dragresize-topleft":"onStartDiagonalResize"},render(){const e=this.__super__.render.apply(this,arguments);return Bg(this.__super__._converse,this),this.setWidth(),e},renderLoginPanel(){const e=this.__super__.renderLoginPanel.apply(this,arguments);return this.initDragResize().setDimensions(),e},renderControlBoxPane(){const e=this.__super__.renderControlBoxPane.apply(this,arguments);return this.initDragResize().setDimensions(),e}},ChatRoomView:{events:{"mousedown .dragresize-top":"onStartVerticalResize","mousedown .dragresize-left":"onStartHorizontalResize","mousedown .dragresize-topleft":"onStartDiagonalResize"},render(){const e=this.__super__.render.apply(this,arguments);return Bg(this.__super__._converse,this),this.setWidth(),e}}},initialize(){Qc.settings.extend({allow_dragresize:!0});const e={initDragResize(){var e;const t=this,n=Ma(()=>t.setDimensions());window.addEventListener("resize",t.debouncedSetDimensions),this.listenTo(this.model,"destroy",()=>window.removeEventListener("resize",n));const r=this.el.querySelector(".box-flyout"),i=window.getComputedStyle(r);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 s=i["min-width"],o=i["min-height"];return this.model.set("min_width",s.endsWith("px")?Number(s.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=Vc.connection)&&void 0!==e&&e.connected&&(this.height=this.model.get("height"),this.width=this.model.get("width")),this},resizeChatBox(e){let t;0===Vc.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))),Vc.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)))},setWidth(){this.model.get("width")&&(this.el.style.width=this.model.get("width"))},setDimensions(){this.adjustToViewport(),this.setChatBoxHeight(this.model.get("height")),this.setChatBoxWidth(this.model.get("width"))},setChatBoxHeight(e){e=e?Fg.applyDragResistance(e,this.model.get("default_height"))+"px":"";const t=this.el.querySelector(".box-flyout");null!==t&&(t.style.height=e)},setChatBoxWidth(e){e=e?Fg.applyDragResistance(e,this.model.get("default_width"))+"px":"",this.el.sty
2021-01-29 23:34:36 +01:00
/**
* @module converse-singleton
* @copyright JC Brand
* @license Mozilla Public License (MPLv2)
* @description A plugin which restricts Converse to only one chat.
*/
2021-03-19 19:26:15 +01:00
sl.plugins.add("converse-singleton",{enabled:e=>e.api.settings.get("singleton"),initialize(){if(Qc.settings.extend({allow_logout:!1,allow_muc_invitations:!1,hide_muc_server:!0}),!Array.isArray(Qc.settings.get("auto_join_rooms"))&&!Array.isArray(Qc.settings.get("auto_join_private_chats")))throw new Error("converse-singleton: auto_join_rooms must be an Array");if(Qc.settings.get("auto_join_rooms").length>1||Qc.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.")}}),
2021-01-29 23:34:36 +01:00
/**
* @module converse-fullscreen
* @license Mozilla Public License (MPLv2)
* @copyright 2020, the Converse.js contributors
*/
2021-03-19 19:26:15 +01:00
sl.plugins.add("converse-fullscreen",{enabled:e=>e.isUniView(),initialize(){Qc.settings.extend({chatview_avatar_height:50,chatview_avatar_width:50,hide_open_bookmarks:!0,show_controlbox_by_default:!0,sticky_controlbox:!0})}}),
2021-01-29 23:34:36 +01:00
/**
* @module converse-mam-views
* @description
* Views for XEP-0313 Message Archive Management
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/
2021-03-19 19:26:15 +01:00
sl.plugins.add("converse-mam-views",{dependencies:["converse-mam","converse-chatview","converse-muc-views"],initialize(){Qc.listen.on("chatBoxScrolledUp",async e=>{if(e.model.messages.length){const t=e.model.get("type")===Vc.CHATROOMS_TYPE,n=e.model.getOldestMessage();if(n){const r=t?e.model.get("jid"):Vc.bare_jid,i=n&&n.get("stanza_id "+r);e.addSpinner(),i?await e.model.fetchArchivedMessages({before:i}):await e.model.fetchArchivedMessages({end:n.get("time")}),e.clearSpinner(),Vc.router.history.navigate("#"+n.get("msgid"))}}})}});Qc.elements.define("converse-minimized-chat",class extends Kd{static get properties(){return{model:{type:Object},title:{type:String},type:{type:String},num_unread:{type:Number}}}render(){return(e=>{const t=wd("Click to restore this chat");return wc`
<div class="chat-head-${e.type} chat-head row no-gutters">
<a class="restore-chat w-100 align-self-center" title="${t}" @click=${e.restore}>
${e.num_unread?wc`<span class="message-count badge badge-light">${e.num_unread}</span>`:""}
${e.title}
</a>
<a class="chatbox-btn close-chatbox-button fa fa-times" @click=${e.close}></a>
</div>`})({close:e=>this.close(e),num_unread:this.num_unread,restore:e=>this.restore(e),title:this.title,type:this.type})}close(e){null==e||e.preventDefault();const t=Vc.chatboxviews.get(this.model.get("id"));t?t.close():(this.model.destroy(),Qc.trigger("chatBoxClosed",this))}restore(e){null==e||e.preventDefault(),this.model.maximize()}});
2021-01-29 23:34:36 +01:00
/**
* @module converse-minimize
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/
2021-03-19 19:26:15 +01:00
const{dayjs:qg}=sl.env,Ug=sl.env.utils;sl.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("show",this.maximize,this),"controlbox"!==this.get("id")&&this.save({minimized:this.get("minimized")||!1,time_minimized:this.get("time_minimized")||qg()})},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:{show(){const{_converse:e}=this.__super__;return"overlayed"===e.api.settings.get("view_mode")&&this.model.get("minimized")?(this.model.minimize(),this):this.__super__.show.apply(this,arguments)},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(){Qc.settings.extend({no_trimming:!1});const e={maximize(){Ug.safeSave(this,{minimized:!1,time_opened:(new Date).getTime()})},minimize(){Ug.safeSave(this,{minimized:!0,time_minimized:(new Date).toISOString()})}};Object.assign(Vc.ChatBox.prototype,e);const t={onMaximized(){const{_converse:e}=this.__super__;return this.insertIntoDOM(),this.model.isScrolledUp()||this.model.clearUnreadMsgCounter(),this.model.setChatState(e.ACTIVE),this.show(),Qc.trigger("chatBoxMaximized",this),this},onMinimized(e){const{_converse:t}=this.__super__;return e&&e.preventDefault&&e.preventDefault(),this.model.collection&&this.model.collection.browserStorage?this.model.save({scroll:this.content.scrollTop}):this.model.set({scroll:this.content.scrollTop}),this.model.setChatState(t.INACTIVE),this.hide(),Qc.trigger("chatBoxMinimized",this),this},minimize(e){return e&&e.preventDefault&&e.preventDefault(),this.model.minimize(),this},onMinimizedChanged(e){e.get("minimized")?this.onMinimized():this.onMaximized()}};Object.assign(Vc.ChatBoxView.prototype,t);const n={getChatBoxWidth(e){if("controlbox"===e.model.get("id")){const e=this.get("controlbox");return e&&Ug.isVisible(e.el)?Ug.getOuterWidth(e.el,!0):Ug.getOuterWidth(Vc.controlboxtoggle.el,!0)}return!e.model.get("minimized")&&Ug.isVisible(e.el)?Ug.getOuterWidth(e.el,!0):0},getShownChats(){return this.filter(e=>!e.model.get("minimized")&&!e.model.get("closed")&&Ug.isVisible(e.el))},getMinimizedWidth(){var e;const t=null===(e=Vc.minimized_chats)||void 0===e?void 0:e.el;return this.model.pluck("minimized").includes(!0)?Ug.getOuterWidth(t,!0):0},getBoxesWidth(e){const t=e?e.model.get("id"):null,n=e?Ug.getOuterWidth(e.el,!0):0;return Object.values(this.xget(t)).reduce((e,t)=>e+this.getChatBoxWidth(t),n)},async trimChats(e){var t;if(Qc.settings.get("no_trimming")||!Qc.connection.connected()||"overlayed"!==Qc.settings.get("view_mode"))return;const n=this.getShownChats();if(n.length<=1)return;const r=Ug.getOuterWidth(document.querySelector("body"),!0);if(this.getChatBoxWidth(n[0])===r)return;await Qc.waitUntil("minimizedChatsInitialized");if(null===(t=Vc.minimized_chats)||void 0===t?void 0:t.el)for(;this.getMinimizedWidth()+this.getBoxesWidth(e)>r;){const t=e?e.model.get("id"):null,n=this.getOldestMaximizedChat([t]);if(!n)break;{const e=this.get(n.get("id"));e&&e.hide(),n.minimize()}}},getOldestMaximizedChat(e){e.push("controlbox");let t=0,n=this.model.sort().at(t);for(;e.includes(n.get("id"))||!0===n.get("minimized");)if(t++,n=this.model.at(t),!n)return null;return n}};Object.assign(Vc.ChatBoxViews.prototype,n),Qc.promises.add("minimizedChatsInitialized"),Vc.MinimizedChatsToggle=Bs.extend({defaults:{collapsed:!1}}),Vc.MinimizedChats=Md.extend({tagName:"span",async initialize(){await this.initToggle(),this.render(),this.listenTo(this.minchats,"change:collapsed",this.render),this.listenTo(this.model,"add",this.r
<a id="toggle-minimized-chats" class="row no-gutters" @click=${i.toggle}>
${i.num_minimized} ${wd("Minimized")}
<span class="unread-message-count ${i.num_unread?"":"unread-message-count-hidden"}" href="#">${i.num_unread}</span>
</a>
<div class="flyout minimized-chats-flyout row no-gutters ${i.collapsed?"hidden":""}">
${i.chats.map(e=>wc`<converse-minimized-chat
.model=${e}
title=${e.getDisplayName()}
type=${e.get("type")}
num_unread=${e.get("num_unread")}></converse-minimized-chat>`)}
</div>
</div>`,this.el),this.el.parentElement||Vc.chatboxviews.insertRowColumn(this.el)},async initToggle(){const e="converse.minchatstoggle-"+Vc.bare_jid;this.minchats=new Vc.MinimizedChatsToggle({id:e}),this.minchats.browserStorage=Vc.createStore(e),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")})}}),Qc.listen.on("chatBoxInsertedIntoDOM",e=>Vc.chatboxviews.trimChats(e)),Qc.listen.on("connected",()=>{return null===(e=Vc.minimized_chats)||void 0===e||e.remove(),Vc.minimized_chats=new Vc.MinimizedChats({model:Vc.chatboxes}),void Qc.trigger("minimizedChatsInitialized");var e}),Qc.listen.on("controlBoxOpened",e=>Vc.chatboxviews.trimChats(e)),Qc.listen.on("chatBoxViewInitialized",e=>e.listenTo(e.model,"change:minimized",e.onMinimizedChanged)),Qc.listen.on("chatRoomViewInitialized",e=>{e.listenTo(e.model,"change:minimized",e.onMinimizedChanged),e.model.get("minimized")&&e.hide()}),Qc.listen.on("getHeadingButtons",(e,t)=>e.model.get("type")===Vc.CHATROOMS_TYPE?function(e,t){const n={a_class:"toggle-chatbox-button",handler:t=>e.minimize(t),i18n_text:wd("Minimize"),i18n_title:wd("Minimize this groupchat"),icon_class:"fa-minus",name:"minimize",standalone:"overlayed"===Vc.api.settings.get("view_mode")},r=t.map(e=>e.name).indexOf("signout");return r>-1?[...t.slice(0,r),n,...t.slice(r)]:[n,...t]}(e,t):function(e,t){const n={a_class:"toggle-chatbox-button",handler:t=>e.minimize(t),i18n_text:wd("Minimize"),i18n_title:wd("Minimize this chat"),icon_class:"fa-minus",name:"minimize",standalone:"overlayed"===Vc.api.settings.get("view_mode")},r=t.map(e=>e.name).indexOf("close");return r>-1?[...t.slice(0,r),n,...t.slice(r)]:[n,...t]}(e,t));const r=Ma(()=>Vc.chatboxviews.trimChats(),250);Qc.listen.on("registeredGlobalEventHandlers",()=>window.addEventListener("resize",r)),Qc.listen.on("unregisteredGlobalEventHandlers",()=>window.removeEventListener("resize",r))}});Qc.elements.define("converse-autocomplete",class extends Kd{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 wc`
<div class="suggestion-box suggestion-box__name">
<ul class="suggestion-box__results suggestion-box__results--above" hidden=""></ul>
<input type="text" name="${this.name}"
autocomplete="off"
@keydown=${this.onKeyDown}
@keyup=${this.onKeyUp}
class="form-control suggestion-box__input"
placeholder="${this.placeholder}"/>
<span class="suggestion-box__additions visually-hidden" role="status" aria-live="assertive" aria-relevant="additions"></span>
</div>
`}firstUpdated(){this.auto_complete=new Od(this.firstElementChild,{ac_triggers:this.triggers.split(" "),auto_evaluate:this.auto_evaluate,auto_first:this.auto_first,filter:"contains"==this.filter?Ed:Ad,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)}});var Hg=e=>{const t=wd("Owner"),n=wd("Admin"),r=wd("Member"),i=wd("Moderator"),s=wd("Visitor");return wc`
<li class="occupant" id="${e.id}" title="${(e=>{const t=wd("This user is a moderator."),n=wd("This user can send messages in this groupchat."),r=wd("This user can NOT send messages in this groupchat."),i=e.jid+" "||"";return"moderator"===e.role?`${i}${t} ${e.hint_occupant}`:"participant"===e.role?`${i}${n} ${e.hint_occupant}`:"visitor"===e.role?`${i}${r} ${e.hint_occupant}`:["visitor","participant","moderator"].includes(e.role)?void 0:`${i}${e.hint_occupant}`})(e)}">
<div class="row no-gutters">
<div class="col-auto">
<div class="occupant-status occupant-${e.show} circle" title="${e.hint_show}"></div>
</div>
<div class="col occupant-nick-badge">
<span class="occupant-nick">${e.nick||e.jid}</span>
<span class="occupant-badges">
${"owner"===e.affiliation?wc`<span class="badge badge-groupchat">${t}</span>`:""}
${"admin"===e.affiliation?wc`<span class="badge badge-info">${n}</span>`:""}
${"member"===e.affiliation?wc`<span class="badge badge-info">${r}</span>`:""}
${"moderator"===e.role?wc`<span class="badge badge-info">${i}</span>`:""}
${"visitor"===e.role?wc`<span class="badge badge-secondary">${s}</span>`:""}
</span>
</div>
</div>
</li>
`};const Vg={offline:"Offline",unavailable:"Unavailable",xa:"Extended Away",away:"Away",dnd:"Do not disturb",chat:"Chattty",online:"Online"};const Wg=sl.env.utils;Qc.elements.define("converse-muc-sidebar",class extends Kd{static get properties(){return{chatroom:{type:Object},occupants:{type:Object}}}connectedCallback(){super.connectedCallback(),this.listenTo(this.occupants,"add",this.requestUpdate),this.listenTo(this.occupants,"remove",this.requestUpdate),this.listenTo(this.occupants,"change",this.requestUpdate)}render(){return(e=>{const t=e=>wd("Click to mention %1$s in your message.",e.get("nick")),n=wd("Participants"),r=e.occupants.map(e=>Hg(Object.assign({jid:"",hint_show:Vg[e.get("show")],hint_occupant:t(e)},e.toJSON())));return wc`
<div class="occupants-header">
<i class="hide-occupants fa fa-times"></i>
<div class="occupants-header--title">
<span class="occupants-heading">${n}</span>
</div>
</div>
<div class="dragresize dragresize-occupants-left"></div>
<ul class="occupant-list">${r}</ul>
`})(Object.assign(this.chatroom.toJSON(),{occupants:[...this.occupants.models]}))}shouldShow(){return!this.chatroom.get("hidden_occupants")&&this.chatroom.session.get("connection_status")===sl.ROOMSTATUS.ENTERED}setVisibility(){this.shouldShow()?Wg.showElement(this):Wg.hideElement(this)}});var Gg=e=>{const t=wd("Join"),n=wd("Enter a new Groupchat");return wc`
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="add-chatroom-modal-label">${n}</h5>
${qd}
</div>
<div class="modal-body">
<span class="modal-alert"></span>
<form class="converse-form add-chatroom">
<div class="form-group">
<label for="chatroom">${e.label_room_address}:</label>
${e.muc_roomid_policy_error_msg?wc`<label class="roomid-policy-error">${e.muc_roomid_policy_error_msg}</label>`:""}
<input type="text" required="required" name="chatroom" class="form-control roomjid-input" placeholder="${e.chatroom_placeholder}"/>
</div>
${e.muc_roomid_policy_hint?wc`<div class="form-group">${df(lf.a.filterXSS(e.muc_roomid_policy_hint,{whiteList:{b:[],br:[],em:[]}}))}</div>`:""}
${e._converse.locked_muc_nickname?"":(e=>{const t=wd("Nickname"),n=wd("This field is required");return wc`
<div class="form-group" >
<label for="nickname">${t}:</label>
<input type="text" title="${n}" required="required" name="nickname" value="${e.nick||""}" class="form-control"/>
</div>
`})(e)}
<input type="submit" class="btn btn-primary" name="join" value="${t||""}" ?disabled=${e.muc_roomid_policy_error_msg}>
</form>
</div>
</div>
</div>
`};const{u:Jg,Strophe:Qg}=sl.env;var Yg=Gd.extend({id:"add-chatroom-modal",events:{"submit form.add-chatroom":"openChatRoom","keyup .roomjid-input":"checkRoomidPolicy","change .roomjid-input":"checkRoomidPolicy"},initialize(){Gd.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change:muc_domain",this.render),this.muc_roomid_policy_error_msg=null},toHTML(){let e="";if(!Qc.settings.get("locked_muc_domain")){const t=this.model.get("muc_domain")||Qc.settings.get("muc_domain");e=t?"name@"+t:wd("name@conference.example.org")}return Gg(Object.assign(this.model.toJSON(),{_converse:Vc,label_room_address:Qc.settings.get("muc_domain")?wd("Groupchat name"):wd("Groupchat address"),chatroom_placeholder:e,muc_roomid_policy_error_msg:this.muc_roomid_policy_error_msg,muc_roomid_policy_hint:Qc.settings.get("muc_roomid_policy_hint")}))},afterRender(){this.el.addEventListener("shown.bs.modal",()=>{this.el.querySelector('input[name="chatroom"]').focus()},!1)},parseRoomDataFromEvent(e){const t=new FormData(e),n=t.get("chatroom");let r;if(Qc.settings.get("locked_muc_nickname")){if(r=Vc.getDefaultMUCNickname(),!r)throw new Error("Using locked_muc_nickname but no nickname found!")}else r=t.get("nickname").trim();return{jid:n,nick:r}},openChatRoom(e){e.preventDefault();const t=this.parseRoomDataFromEvent(e.target);let n;""===t.nick&&(t.nick=void 0),Qc.settings.get("locked_muc_domain")||Qc.settings.get("muc_domain")&&!Jg.isValidJID(t.jid)?n=`${Qg.escapeNode(t.jid)}@${Qc.settings.get("muc_domain")}`:(n=t.jid,this.model.setDomain(n)),Qc.rooms.open(n,Object.assign(t,{jid:n}),!0),this.modal.hide(),e.target.reset()},checkRoomidPolicy(){if(Qc.settings.get("muc_roomid_policy")&&Qc.settings.get("muc_domain")){let e=this.el.querySelector(".roomjid-input").value;!sl.locked_muc_domain&&Jg.isValidJID(e)||(e=`${Qg.escapeNode(e)}@${Qc.settings.get("muc_domain")}`);const t=Qg.getNodeFromJid(e),n=Qg.getDomainFromJid(e);Qc.settings.get("muc_domain")!==n||Qc.settings.get("muc_roomid_policy").test(t)?this.muc_roomid_policy_error_msg=null:this.muc_roomid_policy_error_msg=wd("Groupchat id is invalid."),this.render()}}});const Kg=sl.env.utils;var Xg=Gd.extend({id:"muc-invite-modal",initialize(){Gd.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change",this.render),this.initInviteWidget()},toHTML(){return(e=>{const t=wd("Invite"),n=wd("Invite someone to this groupchat"),r=wd("user@example.org"),i=wd("Please enter a valid XMPP address"),s=wd("XMPP Address"),o=wd("Optional reason for the invitation");return wc`
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="add-chatroom-modal-label">${n}</h5>
${qd}
</div>
<div class="modal-body">
<span class="modal-alert"></span>
<div class="suggestion-box room-invite">
<form @submit=${e.submitInviteForm}>
<div class="form-group">
<label class="clearfix" for="invitee_jids">${s}:</label>
${e.invalid_invite_jid?wc`<div class="error error-feedback">${i}</div>`:""}
<input class="form-control suggestion-box__input"
required="required"
name="invitee_jids"
id="invitee_jids"
placeholder="${r}"
type="text"/>
<span class="suggestion-box__additions visually-hidden" role="status" aria-live="assertive" aria-relevant="additions"></span>
<ul class="suggestion-box__results suggestion-box__results--below" hidden=""></ul>
</div>
<div class="form-group">
<label>${o}:</label>
<textarea class="form-control" name="reason"></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">${t}</button>
</div>
</form>
</div>
</div>
</div>
</div>
`})(Object.assign(this.model.toJSON(),{submitInviteForm:e=>this.submitInviteForm(e)}))},initInviteWidget(){this.invite_auto_complete&&this.invite_auto_complete.destroy();const e=Vc.roster.map(e=>({label:e.getDisplayName(),value:e.get("jid")})),t=this.el.querySelector(".suggestion-box").parentElement;this.invite_auto_complete=new Vc.AutoComplete(t,{min_chars:1,list:e})},submitInviteForm(e){e.preventDefault();const t=new FormData(e.target),n=t.get("invitee_jids"),r=t.get("reason");Kg.isValidJID(n)?(this.chatroomview.model.directInvite(n,r),this.modal.hide()):this.model.set({invalid_invite_jid:!0})}});var Zg=e=>{const t=wd("Query for Groupchats");return wc`
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="list-chatrooms-modal-label">${t}</h5>
${qd}
</div>
<div class="modal-body d-flex flex-column">
<span class="modal-alert"></span>
${e.show_form?(e=>{const t=wd("Show groupchats"),n=wd("Server address");return wc`
<form class="converse-form list-chatrooms"
@submit=${e.submitForm}>
<div class="form-group">
<label for="chatroom">${n}:</label>
<input type="text"
@change=${e.setDomainFromEvent}
value="${e.muc_domain||""}"
required="required"
name="server"
class="form-control"
placeholder="${e.server_placeholder}"/>
</div>
<input type="submit" class="btn btn-primary" name="list" value="${t}"/>
</form>
`})(e):""}
<ul class="available-chatrooms list-group">
${e.loading_items?wc`<li class="list-group-item"> ${Wh()} </li>`:""}
${e.feedback_text?wc`<li class="list-group-item active">${e.feedback_text}</li>`:""}
${rf(e.items,e=>e.jid,t=>((e,t)=>{const n=wd("Show more information on this groupchat"),r=wd("Click to open this groupchat");return wc`
<li class="room-item list-group-item">
<div class="available-chatroom d-flex flex-row">
<a class="open-room available-room w-100"
@click=${e.openRoom}
data-room-jid="${t.jid}"
data-room-name="${t.name}"
title="${r}"
href="#">${t.name||t.jid}</a>
<a class="right room-info icon-room-info"
@click=${e.toggleRoomInfo}
data-room-jid="${t.jid}"
title="${n}"
href="#"></a>
</div>
</li>
`})(e,t))}
</ul>
</div>
<div class="modal-footer">${Bd}</div>
</div>
</div>
`},em=n(174),tm=n.n(em);const{u:nm,Strophe:rm,$iq:im,sizzle:sm}=sl.env;function om(e){const t=nm.ancestor(e.target,".room-item"),n=t.querySelector("div.room-info");n?(nm.slideIn(n).then(nm.removeElement),t.querySelector("a.room-info").classList.remove("selected")):(t.insertAdjacentElement("beforeend",nm.getElementFromTemplateResult(Wh())),Qc.disco.info(e.target.getAttribute("data-room-jid"),null).then(e=>function(e,t){var n,r;e.querySelector("span.spinner").remove(),e.querySelector("a.room-info").classList.add("selected"),e.insertAdjacentHTML("beforeEnd",tm()({jid:t.getAttribute("from"),desc:null===(n=kf(sm('field[var="muc#roominfo_description"] value',t)))||void 0===n?void 0:n.textContent,occ:null===(r=kf(sm('field[var="muc#roominfo_occupants"] value',t)))||void 0===r?void 0:r.textContent,hidden:sm('feature[var="muc_hidden"]',t).length,membersonly:sm('feature[var="muc_membersonly"]',t).length,moderated:sm('feature[var="muc_moderated"]',t).length,nonanonymous:sm('feature[var="muc_nonanonymous"]',t).length,open:sm('feature[var="muc_open"]',t).length,passwordprotected:sm('feature[var="muc_passwordprotected"]',t).length,persistent:sm('feature[var="muc_persistent"]',t).length,publicroom:sm('feature[var="muc_publicroom"]',t).length,semianonymous:sm('feature[var="muc_semianonymous"]',t).length,temporary:sm('feature[var="muc_temporary"]',t).length,unmoderated:sm('feature[var="muc_unmoderated"]',t).length,label_desc:wd("Description:"),label_jid:wd("Groupchat Address (JID):"),label_occ:wd("Participants:"),label_features:wd("Features:"),label_requires_auth:wd("Requires authentication"),label_hidden:wd("Hidden"),label_requires_invite:wd("Requires an invitation"),label_moderated:wd("Moderated"),label_non_anon:wd("Non-anonymous"),label_open_room:wd("Open"),label_permanent_room:wd("Permanent"),label_public:wd("Public"),label_semi_anon:wd("Semi-anonymous"),label_temp_room:wd("Temporary"),label_unmoderated:wd("Unmoderated")}))}(t,e)).catch(e=>Dn.error(e)))}var am=Gd.extend({id:"list-chatrooms-modal",initialize(){this.items=[],this.loading_items=!1,Gd.prototype.initialize.apply(this,arguments),Qc.settings.get("muc_domain")&&!this.model.get("muc_domain")&&this.model.save("muc_domain",Qc.settings.get("muc_domain")),this.listenTo(this.model,"change:muc_domain",this.onDomainChange),this.el.addEventListener("shown.bs.modal",()=>Qc.settings.get("locked_muc_domain")?this.updateRoomsList():this.el.querySelector('input[name="server"]').focus())},toHTML(){const e=this.model.get("muc_domain")||Qc.settings.get("muc_domain");return Zg(Object.assign(this.model.toJSON(),{show_form:!Qc.settings.get("locked_muc_domain"),server_placeholder:e||wd("conference.example.org"),items:this.items,loading_items:this.loading_items,openRoom:e=>this.openRoom(e),setDomainFromEvent:e=>this.setDomainFromEvent(e),submitForm:e=>this.showRooms(e),toggleRoomInfo:e=>this.toggleRoomInfo(e)}))},openRoom(e){e.preventDefault();const t=e.target.getAttribute("data-room-jid"),n=e.target.getAttribute("data-room-name");this.modal.hide(),Qc.rooms.open(t,{name:n},!0)},toggleRoomInfo(e){e.preventDefault(),om(e)},onDomainChange(){Qc.settings.get("auto_list_rooms")&&this.updateRoomsList()},onRoomsFound(e){this.loading_items=!1;const t=e?sm("query item",e):[];return t.length?(this.model.set({feedback_text:wd("Groupchats found")},{silent:!0}),this.items=t.map(go.getAttributes)):(this.items=[],this.model.set({feedback_text:wd("No groupchats found")},{silent:!0})),this.render(),!0},updateRoomsList(){const e=im({to:this.model.get("muc_domain"),from:Vc.connection.jid,type:"get"}).c("query",{xmlns:rm.NS.DISCO_ITEMS});Qc.sendIQ(e).then(e=>this.onRoomsFound(e)).catch(()=>this.onRoomsFound())},showRooms(e){e.preventDefault(),this.loading_items=!0,this.render();const t=new FormData(e.target);this.model.setDomain(t.get("server")),this.updateRoomsList()},setDomainFromEvent(e){this.model.setDomain(e.target.value)},setNick(e){this.model.save({nick:e.target.value})}});function cm(e){return"moderator"===e?wd("Moderators are privileged users who can change the roles of other users (except those with ad
<li class="list-group-item" data-nick="${e.item.nick}">
<ul class="list-group">
<li class="list-group-item active">
<div><strong>JID:</strong> ${e.item.jid}</div>
</li>
<li class="list-group-item">
<div><strong>Nickname:</strong> ${e.item.nick}</div>
</li>
<li class="list-group-item">
<div><strong>Role:</strong> ${e.item.role} ${e.assignable_roles.length?wc`<a href="#" data-form="role-form" class="toggle-form right fa fa-wrench" @click=${e.toggleForm}></a>`:""}</div>
${e.assignable_roles.length?(e=>{const t=wd("Change role"),n=wd("New Role"),r=wd("Reason");return wc`
<form class="role-form hidden" @submit=${e.assignRole}>
<div class="form-group">
<input type="hidden" name="jid" value="${e.item.jid}"/>
<input type="hidden" name="nick" value="${e.item.nick}"/>
<div class="row">
<div class="col">
<label><strong>${n}:</strong></label>
<select class="custom-select select-role" name="role">
${e.assignable_roles.map(t=>wc`<option value="${t}" ?selected=${t===e.item.role}>${t}</option>`)}
</select>
</div>
<div class="col">
<label><strong>${r}:</strong></label>
<input class="form-control" type="text" name="reason"/>
</div>
</div>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="${t}"/>
</div>
</form>
`})(e):""}
</li>
</ul>
</li>
`,dm=e=>wc`
<li class="list-group-item" data-nick="${e.item.nick}">
<ul class="list-group">
<li class="list-group-item active">
<div><strong>JID:</strong> ${e.item.jid}</div>
</li>
<li class="list-group-item">
<div><strong>Nickname:</strong> ${e.item.nick}</div>
</li>
<li class="list-group-item">
<div><strong>Affiliation:</strong> ${e.item.affiliation} ${e.assignable_affiliations.length?wc`<a href="#" data-form="affiliation-form" class="toggle-form right fa fa-wrench" @click=${e.toggleForm}></a>`:""}</div>
${e.assignable_affiliations.length?(e=>{const t=wd("Change affiliation"),n=wd("New affiliation"),r=wd("Reason");return wc`
<form class="affiliation-form hidden" @submit=${e.assignAffiliation}>
<div class="form-group">
<input type="hidden" name="jid" value="${e.item.jid}"/>
<input type="hidden" name="nick" value="${e.item.nick}"/>
<div class="row">
<div class="col">
<label><strong>${n}:</strong></label>
<select class="custom-select select-affiliation" name="affiliation">
${e.assignable_affiliations.map(t=>wc`<option value="${t}" ?selected=${t===e.item.affiliation}>${t}</option>`)}
</select>
</div>
<div class="col">
<label><strong>${r}:</strong></label>
<input class="form-control" type="text" name="reason"/>
</div>
</div>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" name="change" value="${t}"/>
</div>
</form>
`})(e):""}
</li>
</ul>
</li>
`;var hm=e=>{const t=wd("Affiliation"),n=wd("Moderator Tools"),r=wd("No users with that affiliation found."),i=wd("No users with that role found."),s=wd("Type here to filter the search results"),o=wd("Role"),a=wd("Show users"),c=wd("Roles are assigned to users to grant or deny them certain abilities in a multi-user chat. They're assigned either explicitly or implicitly as part of an affiliation. A role that's not due to an affiliation, is only valid for the duration of the user's session."),l=wd("An affiliation is a long-lived entitlement which typically implies a certain role and which grants privileges and responsibilities. For example admins and owners automatically have the moderator role."),u=e.queryable_roles.length&&e.queryable_affiliations.length;return wc`
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="converse-modtools-modal-label">${n}</h5>
${qd}
</div>
<div class="modal-body d-flex flex-column">
<span class="modal-alert"></span>
${u?(e=>wc`
<ul class="nav nav-pills justify-content-center">
<li role="presentation" class="nav-item">
<a class="nav-link active" id="affiliations-tab" href="#affiliations-tabpanel" aria-controls="affiliations-tabpanel" role="tab" data-toggle="tab" @click=${e.switchTab}>Affiliations</a>
</li>
<li role="presentation" class="nav-item">
<a class="nav-link" id="roles-tab" href="#roles-tabpanel" aria-controls="roles-tabpanel" role="tab" data-toggle="tab" @click=${e.switchTab}>Roles</a>
</li>
</ul>
`)(e):""}
<div class="tab-content">
<div class="tab-pane tab-pane--columns ${e.queryable_affiliations.length?"active":""}" id="affiliations-tabpanel" role="tabpanel" aria-labelledby="affiliations-tab">
<form class="converse-form query-affiliation" @submit=${e.queryAffiliation}>
<p class="helptext pb-3">${l}</p>
<div class="form-group">
<label for="affiliation">
<strong>${t}:</strong>
</label>
<div class="row">
<div class="col">
<select class="custom-select select-affiliation" name="affiliation">
${e.queryable_affiliations.map(t=>(e=>wc`
<option value="${e.item||""}"
?selected=${e.item===e.affiliation}
title="${lm(e.item)}">${e.item}</option>
`)(Object.assign({item:t},e)))}
</select>
</div>
<div class="col">
<input type="submit" class="btn btn-primary" name="users_with_affiliation" value="${a}"/>
</div>
</div>
<div class="row">
<div class="col mt-3">
${Array.isArray(e.users_with_affiliation)&&e.users_with_affiliation.length>5?wc`<input class="form-control" .value="${e.affiliations_filter}" @keyup=${e.filterAffiliationResults} type="text" name="filter" placeholder="${s}"/>`:""}
</div>
</div>
${lm(e.affiliation)?wc`<div class="row"><div class="col pt-2"><p class="helptext pb-3">${lm(e.affiliation)}</p></div></div>`:""}
</div>
</form>
<div class="scrollable-container">
<ul class="list-group list-group--users">
${e.loading_users_with_affiliation?wc`<li class="list-group-item"> ${Wh()} </li>`:""}
${Array.isArray(e.users_with_affiliation)&&0===e.users_with_affiliation.length?wc`<li class="list-group-item">${r}</li>`:""}
${e.users_with_affiliation instanceof Error?wc`<li class="list-group-item">${e.users_with_affiliation.message}</li>`:(e.users_with_affiliation||[]).map(t=>(t.nick||t.jid).match(new RegExp(e.affiliations_filter,"i"))?dm(Object.assign({item:t},e)):"")}
</ul>
</div>
</div>
<div class="tab-pane tab-pane--columns ${!u&&e.queryable_roles.length?"active":""}" id="roles-tabpanel" role="tabpanel" aria-labelledby="roles-tab">
<form class="converse-form query-role" @submit=${e.queryRole}>
<p class="helptext pb-3">${c}</p>
<div class="form-group">
<label for="role"><strong>${o}:</strong></label>
<div class="row">
<div class="col">
<select class="custom-select select-role" name="role">
${e.queryable_roles.map(t=>(e=>wc`
<option value="${e.item||""}"
?selected=${e.item===e.role}
title="${cm(e.item)}">${e.item}</option>
`)(Object.assign({item:t},e)))}
</select>
</div>
<div class="col">
<input type="submit" class="btn btn-primary" name="users_with_role" value="${a}"/>
</div>
</div>
<div class="row">
<div class="col mt-3">
${Array.isArray(e.users_with_role)&&e.users_with_role.length>5?wc`<input class="form-control" .value="${e.roles_filter}" @keyup=${e.filterRoleResults} type="text" name="filter" placeholder="${s}"/>`:""}
</div>
</div>
${cm(e.role)?wc`<div class="row"><div class="col pt-2"><p class="helptext pb-3">${cm(e.role)}</p></div></div>`:""}
</div>
</form>
<div class="scrollable-container">
<ul class="list-group list-group--users">
${e.loading_users_with_role?wc`<li class="list-group-item"> ${Wh()} </li>`:""}
${e.users_with_role&&0===e.users_with_role.length?wc`<li class="list-group-item">${i}</li>`:""}
${(e.users_with_role||[]).map(t=>t.nick.match(e.roles_filter)?um(Object.assign({item:t},e)):"")}
</ul>
</div>
</div>
</div>
</div>
</div>
</div>`};const{Strophe:fm,sizzle:pm,u:gm}=sl.env;let mm;var vm=Gd.extend({id:"converse-modtools-modal",initialize(e){mm=e._converse,this.chatroomview=e.chatroomview,Gd.prototype.initialize.apply(this,arguments),this.affiliations_filter="",this.roles_filter="",this.listenTo(this.model,"change:role",()=>{this.users_with_role=this.chatroomview.model.getOccupantsWithRole(this.model.get("role")),this.render()}),this.listenTo(this.model,"change:affiliation",async()=>{this.loading_users_with_affiliation=!0,this.users_with_affiliation=null,this.render();const e=this.chatroomview.model,t=this.model.get("affiliation");this.shouldFetchAffiliationsList()?this.users_with_affiliation=await e.getAffiliationList(t):this.users_with_affiliation=e.getOccupantsWithAffiliation(t),this.loading_users_with_affiliation=!1,this.render()})},toHTML(){const e=this.chatroomview.model.occupants.findWhere({jid:mm.bare_jid});return hm(Object.assign(this.model.toJSON(),{affiliations_filter:this.affiliations_filter,assignAffiliation:e=>this.assignAffiliation(e),assignRole:e=>this.assignRole(e),assignable_affiliations:this.getAssignableAffiliations(e),assignable_roles:this.getAssignableRoles(e),filterAffiliationResults:e=>this.filterAffiliationResults(e),filterRoleResults:e=>this.filterRoleResults(e),loading_users_with_affiliation:this.loading_users_with_affiliation,queryAffiliation:e=>this.queryAffiliation(e),queryRole:e=>this.queryRole(e),queryable_affiliations:Jl.filter(e=>!mm.modtools_disable_query.includes(e)),queryable_roles:Gl.filter(e=>!mm.modtools_disable_query.includes(e)),roles_filter:this.roles_filter,switchTab:e=>this.switchTab(e),toggleForm:e=>this.toggleForm(e),users_with_affiliation:this.users_with_affiliation,users_with_role:this.users_with_role}))},getAssignableAffiliations(e){let t=Qc.settings.get("modtools_disable_assign");return Array.isArray(t)||(t=t?Jl:[]),"owner"===e.get("affiliation")?Jl.filter(e=>!t.includes(e)):"admin"===e.get("affiliation")?Jl.filter(e=>!["owner","admin",...t].includes(e)):[]},getAssignableRoles(e){let t=Qc.settings.get("modtools_disable_assign");return Array.isArray(t)||(t=t?Gl:[]),"moderator"===e.get("role")?Gl.filter(e=>!t.includes(e)):[]},shouldFetchAffiliationsList(){const e=this.model.get("affiliation");if("none"===e)return!1;return!this.chatroomview.model.occupants.getAutoFetchedAffiliationLists().includes(e)},toggleForm(e){e.stopPropagation(),e.preventDefault();const t=e.target.getAttribute("data-form"),n=gm.ancestor(e.target,".list-group-item").querySelector("."+t);gm.hasClass("hidden",n)?gm.removeClass("hidden",n):gm.addClass("hidden",n)},filterRoleResults(e){this.roles_filter=e.target.value,this.render()},filterAffiliationResults(e){this.affiliations_filter=e.target.value,this.render()},queryRole(e){e.stopPropagation(),e.preventDefault();const t=new FormData(e.target).get("role");this.model.set({role:null},{silent:!0}),this.model.set({role:t})},queryAffiliation(e){e.stopPropagation(),e.preventDefault();const t=new FormData(e.target).get("affiliation");this.model.set({affiliation:null},{silent:!0}),this.model.set({affiliation:t})},async assignAffiliation(e){e.stopPropagation(),e.preventDefault();const t=new FormData(e.target),n=t.get("affiliation"),r={jid:t.get("jid"),reason:t.get("reason")},i=this.model.get("affiliation");try{await this.chatroomview.model.setAffiliation(n,[r])}catch(e){return null===e?this.alert(wd("Timeout error while trying to set the affiliation"),"danger"):pm(`not-allowed[xmlns="${fm.NS.STANZAS}"]`,e).length?this.alert(wd("Sorry, you're not allowed to make that change"),"danger"):this.alert(wd("Sorry, something went wrong while trying to set the affiliation"),"danger"),void Dn.error(e)}this.alert(wd("Affiliation changed"),"primary"),await this.chatroomview.model.occupants.fetchMembers(),this.model.set({affiliation:null},{silent:!0}),this.model.set({affiliation:i})},assignRole(e){e.stopPropagation(),e.preventDefault();const t=new FormData(e.target),n=this.chatroomview.model.getOccupant(t.get("jid")||t.get("nick")),r=t.get("role"),i=t.get("reason"),s=this.model.get("role");this
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="room-details-modal-label">${e.display_name}</h5>
${qd}
</div>
<div class="modal-body">
<span class="modal-alert"></span>
<div class="room-info">
<p class="room-info"><strong>${h}</strong>: ${e.name}</p>
<p class="room-info"><strong>${t}</strong>: ${e.jid}</p>
<p class="room-info"><strong>${i}</strong>: ${e.config.description}</p>
${e.subject?(e=>{const t=wd("Topic"),n=wd("Topic author");return wc`
<p class="room-info"><strong>${t}</strong>: ${df(lf.a.filterXSS(e.subject.text,{whiteList:{}}))}</p>
<p class="room-info"><strong>${n}</strong>: ${e.subject&&e.subject.author}</p>
`})(e):""}
<p class="room-info"><strong>${b}</strong>: ${e.num_occupants}</p>
<p class="room-info"><strong>${s}</strong>:
<div class="chatroom-features">
<ul class="features-list">
${e.features.passwordprotected?wc`<li class="feature" ><span class="fa fa-lock"></span>${x} - <em>${S}</em></li>`:""}
${e.features.unsecured?wc`<li class="feature" ><span class="fa fa-unlock"></span>${p} - <em>${f}</em></li>`:""}
${e.features.hidden?wc`<li class="feature" ><span class="fa fa-eye-slash"></span>${o} - <em>${a}</em></li>`:""}
${e.features.public_room?wc`<li class="feature" ><span class="fa fa-eye"></span>${C} - <em>${e.__("This groupchat is publicly searchable")}</em></li>`:""}
${e.features.membersonly?wc`<li class="feature" ><span class="fa fa-address-book"></span>${l} - <em>${c}</em></li>`:""}
${e.features.open?wc`<li class="feature" ><span class="fa fa-globe"></span>${y} - <em>${w}</em></li>`:""}
${e.features.persistent?wc`<li class="feature" ><span class="fa fa-save"></span>${E} - <em>${A}</em></li>`:""}
${e.features.temporary?wc`<li class="feature" ><span class="fa fa-snowflake-o"></span>${T} - <em>${O}</em></li>`:""}
${e.features.nonanonymous?wc`<li class="feature" ><span class="fa fa-id-card"></span>${g} - <em>${m}</em></li>`:""}
${e.features.semianonymous?wc`<li class="feature" ><span class="fa fa-user-secret"></span>${k} - <em>${j}</em></li>`:""}
${e.features.moderated?wc`<li class="feature" ><span class="fa fa-gavel"></span>${u} - <em>${d}</em></li>`:""}
${e.features.unmoderated?wc`<li class="feature" ><span class="fa fa-info-circle"></span>${v} - <em>${_}</em></li>`:""}
${e.features.mam_enabled?wc`<li class="feature" ><span class="fa fa-database"></span>${n} - <em>${r}</em></li>`:""}
</ul>
</div>
</p>
</div>
</div>
<div class="modal-footer">${Bd}</div>
</div>
</div>
`},bm=Gd.extend({id:"room-details-modal",initialize(){Gd.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change",this.render),this.listenTo(this.model.features,"change",this.render),this.listenTo(this.model.occupants,"add",this.render),this.listenTo(this.model.occupants,"change",this.render)},toHTML(){return _m(Object.assign(this.model.toJSON(),{config:this.model.config.toJSON(),display_name:wd("Groupchat info for %1$s",this.model.getDisplayName()),features:this.model.features.toJSON(),num_occupants:this.model.occupants.length}))}});var ym=e=>{const t=wd("You're not allowed to send messages in this room");return e.entered?e.can_edit?wc`
<div class="emoji-picker__container dropup"></div>
<div class="message-form-container">`:wc`<div class="muc-bottom-panel">${t}</div>`:wc`<div class="muc-bottom-panel"></div>`};var wm=(e,t)=>{const n=wd("This groupchat no longer exists");return wc`
<div class="alert alert-danger">
<h3 class="alert-heading disconnect-msg">${n}</h3>
${t?wc`<p class="destroyed-reason">"${t}"</p>`:""}
${e?(e=>{const t=wd("The conversation has moved. Click below to enter.");return wc`
<p class="moved-label">${t}</p>
<p class="moved-link"><a class="switch-chat" href="#">${e}</a></p>`})(e):""}
</div>`};const Sm=sl.env.utils;var xm=e=>{const t=wd("Hide the groupchat topic"),n=wd("This groupchat is bookmarked"),r=e.subject?Sm.addHyperlinks(e.subject.text):"",i=r&&!e.subject_hidden;return wc`
<div class="chatbox-title ${i?"":"chatbox-title--no-desc"}">
${e._converse.api.settings.get("singleton")?"":wc`<div class="chatbox-navback"><i class="fa fa-arrow-left"></i></div>`}
<div class="chatbox-title__text" title="${"hidden"!==e._converse.locked_muc_domain?e.jid:""}">${e.title}
${e.bookmarked?wc`<i class="fa fa-bookmark chatbox-title__text--bookmarked" title="${n}"></i>`:""}
</div>
<div class="chatbox-title__buttons row no-gutters">
${e.standalone_btns.length?(e=>e.standalone_btns.reverse().map(e=>th(e,"")))(e):""}
${e.dropdown_btns.length?wc`<converse-dropdown .items=${e.dropdown_btns}></converse-dropdown>`:""}
</div>
</div>
${i?wc`<p class="chat-head__desc" title="${t}">${r}</p>`:""}
`};
2021-01-29 23:34:36 +01:00
/**
* @module converse-muc-views
* @copyright 2020, the Converse.js contributors
* @description XEP-0045 Multi-User Chat Views
* @license Mozilla Public License (MPLv2)
*/
2021-03-19 19:26:15 +01:00
const{Strophe:Em,sizzle:Am,$pres:Cm}=sl.env,km=sl.env.utils,jm=["owner"],Tm=["admin","ban","deop","destroy","member","op","revoke"],Om=["kick","mute","voice","modtools"],Nm=["nick"],Im={deop:"participant",kick:"none",mute:"visitor",op:"moderator",voice:"participant"},Mm={admin:"admin",ban:"outcast",member:"member",owner:"owner",revoke:"none"},Rm=tg.extend({length:300,tagName:"div",className:"chatbox chatroom hidden",is_chatroom:!0,events:{"click .chatbox-navback":"showControlBox","click .hide-occupants":"hideOccupants","click .new-msgs-indicator":"viewUnreadMessages","click .occupant-nick":function(e){this.insertIntoTextArea(e.target.textContent)},"click .send-button":"onFormSubmitted","dragover .chat-textarea":"onDragOver","drop .chat-textarea":"onDrop","input .chat-textarea":"inputChanged","keydown .chat-textarea":"onKeyDown","keyup .chat-textarea":"onKeyUp","mousedown .dragresize-occupants-left":"onStartResizeOccupants","paste .chat-textarea":"onPaste","submit .muc-nickname-form":"submitNickname"},async initialize(){this.initDebounced(),this.listenTo(this.model,"change",Ma(()=>this.renderHeading(),250)),this.listenTo(this.model,"change:composing_spoiler",this.renderMessageForm),this.listenTo(this.model,"change:hidden",e=>e.get("hidden")?this.hide():this.show()),this.listenTo(this.model,"change:hidden_occupants",this.onSidebarToggle),this.listenTo(this.model,"configurationNeeded",this.getAndRenderConfigurationForm),this.listenTo(this.model,"destroy",this.hide),this.listenTo(this.model,"show",this.show),this.listenTo(this.model.features,"change:moderated",this.renderBottomPanel),this.listenTo(this.model.features,"change:open",this.renderHeading),this.listenTo(this.model.messages,"rendered",this.maybeScrollDown),this.listenTo(this.model.session,"change:connection_status",this.onConnectionStatusChanged),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),await this.render(),this.listenTo(this.model,"change:show_help_messages",this.renderHelpMessages),this.listenTo(this.model.messages,"add",this.onMessageAdded),this.listenTo(this.model.messages,"change",this.renderChatHistory),this.listenTo(this.model.messages,"remove",this.renderChatHistory),this.listenTo(this.model.messages,"reset",this.renderChatHistory),this.listenTo(this.model.notifications,"change",this.renderNotifications),this.model.occupants.forEach(e=>this.onOccupantAdded(e)),this.listenTo(this.model.occupants,"add",this.onOccupantAdded),this.listenTo(this.model.occupants,"change",this.renderChatHistory),this.listenTo(this.model.occupants,"change:affiliation",this.onOccupantAffiliationChanged),this.listenTo(this.model.occupants,"change:role",this.onOccupantRoleChanged),this.listenTo(this.model.occupants,"change:show",this.showJoinOrLeaveNotification),this.listenTo(this.model.occupants,"remove",this.onOccupantRemoved),this.renderChatContent(),this.insertIntoDOM();const e=await Vc.api.user.settings.getModel();this.listenTo(e,"change:mucs_with_hidden_subject",this.renderHeading),this.onConnectionStatusChanged(),this.model.maybeShow(),this.scrollDown(),Qc.trigger("chatRoomViewInitialized",this)},async render(){const e=!this.shouldShowSidebar();var t;this.el.setAttribute("id",this.model.get("box_id")),bc((t={sidebar_hidden:e,model:this.model,occupants:this.model.occupants,show_sidebar:!this.model.get("hidden_occupants")&&this.model.session.get("connection_status")===sl.ROOMSTATUS.ENTERED,markScrolled:e=>this.markScrolled(e),muc_show_logs_before_join:Qc.settings.get("muc_show_logs_before_join"),show_send_button:Vc.show_send_button},wc`
<div class="flyout box-flyout">
<div class="chat-head chat-head-chatroom row no-gutters"></div>
<div class="chat-body chatroom-body row no-gutters">
<div class="chat-area col">
<div class="chat-content ${t.show_send_button?"chat-content-sendbutton":""}" aria-live="polite">
<div class="chat-content__messages" @scroll=${t.markScrolled}></div>
<div class="chat-content__help"></div>
</div>
<div class="bottom-panel"></div>
</div>
<div class="disconnect-container hidden"></div>
<converse-muc-sidebar class="occupants col-md-3 col-4 ${t.sidebar_hidden?"hidden":""}"
.occupants=${t.occupants}
.chatroom=${t.model}></converse-muc-sidebar>
</div>
</div>
`),this.el),this.notifications=this.el.querySelector(".chat-content__notifications"),this.content=this.el.querySelector(".chat-content"),this.msgs_container=this.el.querySelector(".chat-content__messages"),this.help_container=this.el.querySelector(".chat-content__help"),this.renderBottomPanel(),Qc.settings.get("muc_show_logs_before_join")||this.model.session.get("connection_status")===sl.ROOMSTATUS.ENTERED||this.showSpinner(),await this.renderHeading(),!this.model.get("hidden")&&this.show()},getNotifications(){const e=this.model.notifications.toJSON();return(Qc.settings.get("muc_show_join_leave")?[...sl.CHAT_STATES,...sl.MUC_TRAFFIC_STATES,...sl.MUC_ROLE_CHANGES]:sl.CHAT_STATES).reduce((t,n)=>{const r=e[n];if(null==r||!r.length)return t;const i=r.map(e=>{var t;return(null===(t=this.model.getOccupant(e))||void 0===t?void 0:t.getDisplayName())||e});if(1===i.length){if("composing"===n)return`${t}${wd("%1$s is typing",i[0])}\n`;if("paused"===n)return`${t}${wd("%1$s has stopped typing",i[0])}\n`;if(n===Vc.GONE)return`${t}${wd("%1$s has gone away",i[0])}\n`;if("entered"===n)return`${t}${wd("%1$s has entered the groupchat",i[0])}\n`;if("exited"===n)return`${t}${wd("%1$s has left the groupchat",i[0])}\n`;if("op"===n)return`${t}${wd("%1$s is now a moderator",i[0])}\n`;if("deop"===n)return`${t}${wd("%1$s is no longer a moderator",i[0])}\n`;if("voice"===n)return`${t}${wd("%1$s has been given a voice",i[0])}\n`;if("mute"===n)return`${t}${wd("%1$s has been muted",i[0])}\n`}else if(i.length>1){let e;if(i.length>3)e=Array.from(i).slice(0,2).join(", ")+" and others";else{const t=i.pop();e=wd("%1$s and %2$s",i.join(", "),t)}if("composing"===n)return`${t}${wd("%1$s are typing",e)}\n`;if("paused"===n)return`${t}${wd("%1$s have stopped typing",e)}\n`;if(n===Vc.GONE)return`${t}${wd("%1$s have gone away",e)}\n`;if("entered"===n)return`${t}${wd("%1$s have entered the groupchat",e)}\n`;if("exited"===n)return`${t}${wd("%1$s have left the groupchat",e)}\n`;if("op"===n)return`${t}${wd("%1$s are now moderators",i[0])}\n`;if("deop"===n)return`${t}${wd("%1$s are no longer moderators",i[0])}\n`;if("voice"===n)return`${t}${wd("%1$s have been given voices",i[0])}\n`;if("mute"===n)return`${t}${wd("%1$s have been muted",i[0])}\n`}return t},"")},getHelpMessages(){const e=Qc.settings.get("muc_disable_slash_commands"),t=Array.isArray(e)?e:[];return["<strong>/admin</strong>: "+wd("Change user's affiliation to admin"),"<strong>/ban</strong>: "+wd("Ban user by changing their affiliation to outcast"),"<strong>/clear</strong>: "+wd("Clear the chat area"),"<strong>/close</strong>: "+wd("Close this groupchat"),"<strong>/deop</strong>: "+wd("Change user role to participant"),"<strong>/destroy</strong>: "+wd("Remove this groupchat"),"<strong>/help</strong>: "+wd("Show this menu"),"<strong>/kick</strong>: "+wd("Kick user from groupchat"),"<strong>/me</strong>: "+wd("Write in 3rd person"),"<strong>/member</strong>: "+wd("Grant membership to a user"),"<strong>/modtools</strong>: "+wd("Opens up the moderator tools GUI"),"<strong>/mute</strong>: "+wd("Remove user's ability to post messages"),"<strong>/nick</strong>: "+wd("Change your nickname"),"<strong>/op</strong>: "+wd("Grant moderator role to user"),"<strong>/owner</strong>: "+wd("Grant ownership of this groupchat"),"<strong>/register</strong>: "+wd("Register your nickname"),"<strong>/revoke</strong>: "+wd("Revoke the user's current affiliation"),"<strong>/subject</strong>: "+wd("Set groupchat subject"),"<strong>/topic</strong>: "+wd("Set groupchat subject (alias for /subject)"),"<strong>/voice</strong>: "+wd("Allow muted user to post messages")].filter(e=>t.every(t=>!e.startsWith(t+"<",9))).filter(e=>this.getAllowedCommands().some(t=>e.startsWith(t+"<",9)))},async renderHeading(){const e=await this.generateHeadingTemplate();bc(e,this.el.querySelector(".chat-head-chatroom"))},renderBottomPanel(){const e=this.el.querySelector(".bottom-panel"),t=this.model.session.get("connection_status")===sl.ROOMSTATUS.ENTERED,n=t&&!(this.model.features.get("moderated")&&"visitor"===this.model.getOwnRole());bc(ym({can_edit:n,entered:
<div class="chatroom-form-container muc-nickname-form">
<form class="converse-form chatroom-form converse-centered-form">
<fieldset class="form-group">
<label>${r}</label>
<p class="validation-message">${e.nickname_validation_message}</p>
<input type="text"
required="required"
name="nick"
value="${e.nick||""}"
class="form-control ${e.nickname_validation_message?"error":""}"
placeholder="${t}"/>
</fieldset>
<fieldset class="form-group">
<input type="submit" class="btn btn-primary" name="join" value="${n}"/>
</fieldset>
</form>
</div>`})(this.model.toJSON());if(Qc.settings.get("muc_show_logs_before_join")){const t=this.el.querySelector(".muc-bottom-panel");bc(e,t),km.addClass("muc-bottom-panel--nickname",t)}else{const t=this.el.querySelector(".muc-nickname-form"),n=km.getElementFromTemplateResult(e);if(t)Am(".spinner",this.el).forEach(km.removeElement),t.outerHTML=n.outerHTML;else{this.hideChatRoomContents();this.el.querySelector(".chatroom-body").insertAdjacentElement("beforeend",n)}}km.safeSave(this.model.session,{connection_status:sl.ROOMSTATUS.NICKNAME_REQUIRED})},closeForm(){Am(".chatroom-form-container",this.el).forEach(e=>km.addClass("hidden",e)),this.renderAfterTransition()},getAndRenderConfigurationForm(){this.config_form&&km.isVisible(this.config_form.el)?this.closeForm():(this.showSpinner(),this.model.fetchRoomConfiguration().then(e=>this.renderConfigurationForm(e)).catch(e=>Dn.error(e)))},hideChatRoomContents(){const e=this.el.querySelector(".chatroom-body");null!==e&&[].forEach.call(e.children,e=>e.classList.add("hidden"))},renderPasswordForm(){this.hideChatRoomContents();const e=this.model.get("password_validation_message");if(this.model.save("password_validation_message",void 0),this.password_form)this.password_form.model.set("validation_message",e);else{this.password_form=new Vc.MUCPasswordForm({model:new Bs({validation_message:e}),chatroomview:this});this.el.querySelector(".chatroom-body").insertAdjacentElement("beforeend",this.password_form.el)}km.showElement(this.password_form.el),this.model.session.save("connection_status",sl.ROOMSTATUS.PASSWORD_REQUIRED)},showDestroyedMessage(){km.hideElement(this.el.querySelector(".chat-area")),km.hideElement(this.el.querySelector(".occupants")),Am(".spinner",this.el).forEach(km.removeElement);const e=this.model.get("destroyed_reason"),t=this.model.get("moved_jid");this.model.save({destroyed_reason:void 0,moved_jid:void 0});const n=this.el.querySelector(".disconnect-container");bc(wm(t,e),n);const r=n.querySelector("a.switch-chat");r&&r.addEventListener("click",async e=>{e.preventDefault();(await Qc.rooms.get(t,null,!0)).maybeShow(!0),this.model.destroy()}),km.showElement(n)},showDisconnectMessage(){const e=this.model.get("disconnection_message");if(!e)return;km.hideElement(this.el.querySelector(".chat-area")),km.hideElement(this.el.querySelector(".occupants")),Am(".spinner",this.el).forEach(km.removeElement);const t=[e],n=this.model.get("disconnection_actor");n&&t.push(wd("This action was done by %1$s.",n));const r=this.model.get("disconnection_reason");r&&t.push(wd('The reason given is: "%1$s".',r)),this.model.save({disconnection_message:void 0,disconnection_reason:void 0,disconnection_actor:void 0});const i=this.el.querySelector(".disconnect-container");bc((e=>wc`
<div class="alert alert-danger">
<h3 class="alert-heading disconnect-msg">${e[0]}</h3>
${e.slice(1).map(e=>wc`<p class="disconnect-msg">${e}</p>`)}
</div>`)(t),i),km.showElement(i)},onOccupantAdded(e){e.get("jid")===Vc.bare_jid&&(this.renderHeading(),this.renderBottomPanel())},getPreviousJoinOrLeaveNotification(e,t){const n=(new Date).toISOString().split("T")[0];for(;null!==e;){var r;if(!e.classList.contains("chat-info"))return;const i=e.getAttribute("data-isodate");if(i&&i.split("T")[0]!==n)return;const s=(null===(r=e)||void 0===r?void 0:r.dataset)||{};if(s.join===t||s.leave===t||s.leavejoin===t||s.joinleave===t)return e;e=e.previousElementSibling}},renderAfterTransition(){const e=this.model.session.get("connection_status");if(e==sl.ROOMSTATUS.NICKNAME_REQUIRED)this.renderNicknameForm();else if(e==sl.ROOMSTATUS.PASSWORD_REQUIRED)this.renderPasswordForm();else if(e==sl.ROOMSTATUS.ENTERED){var t;this.hideChatRoomContents(),km.showElement(this.el.querySelector(".chat-area")),null===(t=this.el.querySelector(".occupants"))||void 0===t||t.setVisibility(),this.scrollDown()}},showSpinner(){Am(".spinner",this.el).forEach(km.removeElement),this.hideChatRoomContents();this.el.querySelector(".chatroom-body").insertAdjacentElement("afterbegin",km.getElementFromTemplateResult(Wh()))},hideSpinner(){const e=this.el.querySelector(".spinner");return null!==e&&(km.removeElement(e),this.renderAfterTransition()),this}}),$m=Md.extend({tagName:"div",className:"controlbox-section",id:"chatrooms",events:{"click a.controlbox-heading__btn.show-add-muc-modal":"showAddRoomModal","click a.controlbox-heading__btn.show-list-muc-modal":"showMUCListModal"},toHTML(){return e={heading_chatrooms:wd("Groupchats"),title_new_room:wd("Add a new groupchat"),title_list_rooms:wd("Query for groupchats")},wc`
<div class="d-flex controlbox-padded">
<span class="w-100 controlbox-heading controlbox-heading--groupchats">${e.heading_chatrooms}</span>
<a class="controlbox-heading__btn show-list-muc-modal fa fa-list-ul" title="${e.title_list_rooms}" data-toggle="modal" data-target="#list-chatrooms-modal"></a>
<a class="controlbox-heading__btn show-add-muc-modal fa fa-plus" title="${e.title_new_room}" data-toggle="modal" data-target="#add-chatrooms-modal"></a>
</div>
<div class="list-container list-container--openrooms hidden"></div>
<div class="list-container list-container--bookmarks hidden"></div>`;var e},showAddRoomModal(e){void 0===this.add_room_modal&&(this.add_room_modal=new Yg({model:this.model})),this.add_room_modal.show(e)},showMUCListModal(e){void 0===this.muc_list_modal&&(this.muc_list_modal=new am({model:this.model})),this.muc_list_modal.show(e)}});sl.plugins.add("converse-muc-views",{dependencies:["converse-autocomplete","converse-modal","converse-controlbox","converse-chatview"],overrides:{ControlBoxView:{renderControlBoxPane(){this.__super__.renderControlBoxPane.apply(this,arguments),Qc.settings.get("allow_muc")&&this.renderRoomsPanel()}}},initialize(){const{_converse:e}=this;Qc.promises.add(["roomsPanelRendered"]),Qc.settings.extend({auto_list_rooms:!1,cache_muc_messages:!0,locked_muc_nickname:!1,modtools_disable_query:[],modtools_disable_assign:!1,muc_disable_slash_commands:!1,muc_mention_autocomplete_filter:"contains",muc_mention_autocomplete_min_chars:0,muc_mention_autocomplete_show_avatar:!0,muc_roomid_policy:null,muc_roomid_policy_hint:null,roomconfig_whitelist:[],show_retraction_warning:!0,visible_toolbar_buttons:{toggle_occupants:!0}}),e.ChatRoomView=Rm,e.RoomsPanel=$m;const t={renderRoomsPanel(){if(this.roomspanel&&km.isInDOM(this.roomspanel.el))return this.roomspanel;const t="converse.roomspanel"+e.bare_jid;return this.roomspanel=new e.RoomsPanel({model:new(e.RoomsPanelModel.extend({id:t,browserStorage:e.createStore(t)}))}),this.roomspanel.model.fetch(),this.el.querySelector(".controlbox-pane").insertAdjacentElement("beforeEnd",this.roomspanel.render().el),Qc.trigger("roomsPanelRendered"),this.roomspanel},getRoomsPanel(){return this.roomspanel&&km.isInDOM(this.roomspanel.el)?this.roomspanel:this.renderRoomsPanel()}};function n(e,t){t.getRoomsPanel().model.save("muc_domain",Em.getDomainFromJid(e))}function r(t){t.model.get("connected")&&(t.getRoomsPanel().model.get("muc_domain")||(void 0===Qc.settings.get("muc_domain")?function(t){function r(e){e&&e.get("var")===Em.NS.MUC&&e.entity.getIdentity("conference","text").then(r=>{r&&n(e.get("from"),t)})}Qc.waitUntil("discoInitialized").then(()=>{Qc.listen.on("serviceDiscovered",r),e.disco_entities.each(e=>r(e.features.findWhere({var:Em.NS.MUC})))}).catch(e=>Dn.error(e))}(t):n(Qc.settings.get("muc_domain"),t)))}e.ControlBoxView&&Object.assign(e.ControlBoxView.prototype,t),e.MUCConfigForm=Md.extend({className:"chatroom-form-container muc-config-form",initialize(e){this.chatroomview=e.chatroomview,this.listenTo(this.chatroomview.model.features,"change:passwordprotected",this.render),this.listenTo(this.chatroomview.model.features,"change:config_stanza",this.render),this.render()},toHTML(){var e,t;const n=km.toStanza(this.model.get("config_stanza")),r=Qc.settings.get("roomconfig_whitelist");let i=Am("field",n);r.length&&(i=i.filter(e=>r.includes(e.getAttribute("var"))));const s={new_password:!this.model.features.get("passwordprotected"),fixed_username:this.model.get("jid")};return(e=>{const t=wd("Save"),n=wd("Cancel");return wc`
<form class="converse-form chatroom-form" autocomplete="off" @submit=${e.submitConfigForm}>
<fieldset class="form-group">
<legend>${e.title}</legend>
${e.title!==e.instructions?wc`<p class="form-help">${e.instructions}</p>`:""}
<!-- Fields are generated internally, with xForm2webForm -->
${e.fields.map(e=>df(e))}
</fieldset>
<fieldset>
<input type="submit" class="btn btn-primary" value="${t}">
<input type="button" class="btn btn-secondary button-cancel" value="${n}" @click=${e.closeConfigForm}>
</fieldset>
</form>
`})({closeConfigForm:e=>this.closeConfigForm(e),fields:i.map(e=>km.xForm2webForm(e,n,s)),instructions:null===(e=n.querySelector("instructions"))||void 0===e?void 0:e.textContent,submitConfigForm:e=>this.submitConfigForm(e),title:null===(t=n.querySelector("title"))||void 0===t?void 0:t.textContent})},async submitConfigForm(e){e.preventDefault();const t=Am(":input:not([type=button]):not([type=submit])",e.target).map(km.webForm2xForm).filter(e=>e);try{await this.model.sendConfiguration(t)}catch(e){Dn.error(e);const t=wd("Sorry, an error occurred while trying to submit the config form.")+" "+wd("Check your browser's developer console for details.");Qc.alert("error",wd("Error"),t)}await this.model.refreshDiscoInfo(),this.chatroomview.closeForm()},closeConfigForm(e){e.preventDefault(),this.chatroomview.closeForm()}}),e.MUCPasswordForm=Md.extend({className:"chatroom-form-container muc-password-form",initialize(e){this.chatroomview=e.chatroomview,this.listenTo(this.model,"change:validation_message",this.render),this.render()},toHTML(){return(e=>{const t=wd("This groupchat requires a password"),n=wd("Password: "),r=wd("Submit");return wc`
<form class="converse-form chatroom-form converse-centered-form" @submit=${e.submitPassword}>
<fieldset class="form-group">
<label>${t}</label>
<p class="validation-message">${e.validation_message}</p>
<input class="hidden-username" type="text" autocomplete="username" value="${e.jid}"></input>
<input type="password"
name="password"
required="required"
class="form-control ${e.validation_message?"error":""}"
placeholder="${n}"/>
</fieldset>
<fieldset class="form-group">
<input class="btn btn-primary" type="submit" value="${r}"/>
</fieldset>
</form>
`})({jid:this.model.get("jid"),submitPassword:e=>this.submitPassword(e),validation_message:this.model.get("validation_message")})},submitPassword(e){e.preventDefault();const t=this.el.querySelector("input[type=password]").value;this.chatroomview.model.join(this.chatroomview.model.get("nick"),t),this.model.set("validation_message",null)}}),Qc.listen.on("chatBoxViewsInitialized",()=>{e.chatboxviews.delegate("click","a.open-chatroom",(function(e){e.preventDefault(),Qc.rooms.open(e.target.href)})),e.chatboxes.on("add",(async function(t){const n=e.chatboxviews;if(!n.get(t.get("id"))&&t.get("type")===e.CHATROOMS_TYPE&&t.isValid())return await t.initialized,n.add(t.get("id"),new e.ChatRoomView({model:t}))}))}),Qc.listen.on("clearSession",()=>{const t=e.chatboxviews.get("controlbox");t&&t.roomspanel&&(t.roomspanel.model.destroy(),t.roomspanel.remove(),delete t.roomspanel)}),Qc.listen.on("controlBoxInitialized",e=>{Qc.settings.get("allow_muc")&&(r(e),e.model.on("change:connected",()=>r(e)))}),Object.assign(e.api,{roomviews:{get(t){if(Array.isArray(t)){return Qc.chatviews.get(t).filter(t=>t.model.get("type")===e.CHATROOMS_TYPE)}{const n=Qc.chatviews.get(t);return n.model.get("type")===e.CHATROOMS_TYPE?n:null}},close(t){let n;return void 0===t?n=e.chatboxviews:"string"==typeof t?n=[e.chatboxviews.get(t)].filter(e=>e):Array.isArray(t)&&(n=t.map(t=>e.chatboxviews.get(t))),Promise.all(n.map(e=>e.is_chatroom&&e.model&&e.close()))}}})}});var Dm=e=>wc`
<div class="list-container list-container--headline ${e.headlineboxes.length?"":"hidden"}">
<div class="items-list rooms-list headline-list">
${e.headlineboxes.map(t=>(e=>wc`
<div class="list-item controlbox-padded d-flex flex-row"
data-headline-jid="${e.headlinebox.get("jid")}">
<a class="list-item-link open-headline available-room w-100"
data-headline-jid="${e.headlinebox.get("jid")}"
title="${e.open_title}" href="#">${e.headlinebox.get("jid")}</a>
</div>
`)(Object.assign({headlinebox:t},e)))}
</div>
</div>
`;
2021-01-29 23:34:36 +01:00
/**
* @module converse-headlines-view
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/
2021-03-19 19:26:15 +01:00
const Pm=sl.env.utils,Lm=tg.extend({className:"chatbox headlines hidden",events:{"click .close-chatbox-button":"close","click .toggle-chatbox-button":"minimize","keypress textarea.chat-textarea":"onKeyDown"},async initialize(){this.initDebounced(),this.model.disable_mam=!0,this.listenTo(this.model,"change:hidden",e=>e.get("hidden")?this.hide():this.show()),this.listenTo(this.model,"destroy",this.remove),this.listenTo(this.model,"show",this.show),this.render(),this.listenTo(this.model.messages,"add",this.onMessageAdded),this.listenTo(this.model.messages,"remove",this.renderChatHistory),this.listenTo(this.model.messages,"rendered",this.maybeScrollDown),this.listenTo(this.model.messages,"reset",this.renderChatHistory),await this.model.messages.fetched,this.insertIntoDOM(),this.model.maybeShow(),this.scrollDown(),Qc.trigger("headlinesBoxViewInitialized",this)},render(){this.el.setAttribute("id",this.model.get("box_id"));const e=Qp(Object.assign(this.model.toJSON(),{info_close:"",label_personal_message:"",show_send_button:!1,show_toolbar:!1,unread_msgs:""}));return bc(e,this.el),this.content=this.el.querySelector(".chat-content"),this.msgs_container=this.el.querySelector(".chat-content__messages"),this.renderChatContent(),this.renderHeading(),this},getNotifications:()=>[],getHeadingButtons(){const e=[];return Qc.settings.get("singleton")||e.push({a_class:"close-chatbox-button",handler:e=>this.close(e),i18n_text:wd("Close"),i18n_title:wd("Close these announcements"),icon_class:"fa-times",name:"close",standalone:"overlayed"===Qc.settings.get("view_mode")}),Vc.api.hook("getHeadingButtons",this,e)},renderMessageForm:function(){},afterShown:function(){}}),zm=Md.extend({tagName:"div",className:"controlbox-section",id:"headline",events:{"click .open-headline":"openHeadline"},initialize(){this.listenTo(this.model,"add",this.renderIfHeadline),this.listenTo(this.model,"remove",this.renderIfHeadline),this.listenTo(this.model,"destroy",this.renderIfHeadline),this.render(),this.insertIntoDOM()},toHTML(){return e={heading_headline:wd("Announcements"),headlineboxes:this.model.filter(e=>e.get("type")===Vc.HEADLINES_TYPE),open_title:wd("Click to open this server message")},wc`
<div class="d-flex controlbox-padded ${e.headlineboxes.length?"":"hidden"}">
<span class="w-100 controlbox-heading controlbox-heading--headline">${e.heading_headline}</span>
</div>
${Dm(e)}
`;var e},renderIfHeadline(e){return e&&e.get("type")===Vc.HEADLINES_TYPE&&this.render()},openHeadline(e){e.preventDefault();const t=e.target.getAttribute("data-headline-jid");Vc.chatboxes.get(t).maybeShow(!0)},insertIntoDOM(){const e=Vc.chatboxviews.get("controlbox");e&&e.el.querySelector(".controlbox-pane").insertAdjacentElement("beforeEnd",this.el)}});sl.plugins.add("converse-headlines-view",{dependencies:["converse-headlines","converse-chatview"],overrides:{ControlBoxView:{renderControlBoxPane(){this.__super__.renderControlBoxPane.apply(this,arguments),this.renderHeadlinesPanel()}}},initialize(){const e={renderHeadlinesPanel(){return this.headlinepanel&&Pm.isInDOM(this.headlinepanel.el)||(this.headlinepanel=new Vc.HeadlinesPanel({model:Vc.chatboxes}),Qc.trigger("headlinesPanelRendered")),this.headlinepanel}};Vc.ControlBoxView&&Object.assign(Vc.ControlBoxView.prototype,e),Vc.HeadlinesBoxView=Lm,Vc.HeadlinesPanel=zm,Qc.listen.on("chatBoxViewsInitialized",()=>{const e=Vc.chatboxviews;Vc.chatboxes.on("add",t=>{e.get(t.get("id"))||t.get("type")!==Vc.HEADLINES_TYPE||e.add(t.get("id"),new Vc.HeadlinesBoxView({model:t}))})})}});var Fm=n(175),Bm=n.n(Fm);
2021-01-29 23:34:36 +01:00
/**
* @module converse-notification
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/
2021-03-19 19:26:15 +01:00
const{Strophe:qm}=sl.env,Um=sl.env.utils,Hm="Notification"in window;let Vm;function Wm(){if(Qc.settings.get("update_title")){var e;Vm=null!==(e=Vm)&&void 0!==e?e:new sl.env.Favico({type:"circle",animation:"pop"});const t=Vc.chatboxes.models.reduce((e,t)=>e+(t.get("num_unread")||0),0);Vm.badge(t)}}sl.env.Favico=Bm.a,sl.plugins.add("converse-notification",{dependencies:["converse-chatboxes"],initialize(){Qc.settings.extend({update_title:!0,notify_all_room_messages:!1,show_desktop_notifications:!0,show_chat_state_notifications:!1,chatstate_notification_blacklist:[],play_sounds:!0,sounds_path:Qc.settings.get("assets_path")+"/sounds/",notification_icon:"logo/conversejs-filled.svg",notification_delay:5e3,notify_nicknames_without_references:!1}),Vc.shouldNotifyOfGroupMessage=function(e){if(null==e||!e.body)return!1;const t=e.from,n=e.from_muc,r=Qc.settings.get("notify_all_room_messages"),i=Vc.chatboxes.get(n),s=qm.getResourceFromJid(t),o=s&&qm.unescapeNode(s)||"";let a=!1;const c=i.get("nick");Qc.settings.get("notify_nicknames_without_references")&&(a=new RegExp(`\\b${c}\\b`).test(e.body));const l=e.references.map(e=>e.value).includes(c),u=o!==c,d=!0===r||Array.isArray(r)&&r.includes(n)||l||a;return u&&!!d},Vc.isMessageToHiddenChat=function(e){var t,n;return null!==(t=null===(n=Vc.chatboxes.get(e.from))||void 0===n?void 0:n.isHidden())&&void 0!==t&&t},Vc.shouldNotifyOfMessage=function(e){const{attrs:t,stanza:n}=e;if(!t||null!==n.querySelector("forwarded"))return!1;if("groupchat"===t.type)return Vc.shouldNotifyOfGroupMessage(t);if(t.is_headline)return Vc.isMessageToHiddenChat(t);const r=qm.getBareJidFromJid(t.from)===Vc.bare_jid;return!Um.isOnlyChatStateNotification(n)&&!Um.isOnlyMessageDeliveryReceipt(n)&&!r&&("all"===Qc.settings.get("show_desktop_notifications")||Vc.isMessageToHiddenChat(t))},Vc.playSoundNotification=function(){if(Qc.settings.get("play_sounds")&&void 0!==window.Audio){const e=new Audio(Qc.settings.get("sounds_path")+"msg_received.ogg"),t=e.canPlayType("audio/ogg");if("probably"===t)return e.play();const n=new Audio(Qc.settings.get("sounds_path")+"msg_received.mp3"),r=n.canPlayType("audio/mp3");"probably"===r?n.play():"maybe"===t?e.play():"maybe"===r&&n.play()}},Vc.areDesktopNotificationsEnabled=function(){return Hm&&Qc.settings.get("show_desktop_notifications")&&"granted"===Notification.permission},Vc.showMessageNotification=function(e){const{attrs:t}=e;if(t.is_error)return;if(!Vc.areDesktopNotificationsEnabled())return;let n,r;const i=t.from,s=qm.getBareJidFromJid(i);if("headline"===t.type){if(s.includes("@")&&!Qc.settings.get("allow_non_roster_messaging"))return;n=wd("Notification from %1$s",s)}else if(s.includes("@"))if("groupchat"===t.type)n=wd("%1$s says",qm.getResourceFromJid(i));else{if(void 0===Vc.roster)return void Dn.error("Could not send notification, because roster is undefined");if(r=Vc.roster.get(s),void 0!==r)n=wd("%1$s says",r.getDisplayName());else{if(!Qc.settings.get("allow_non_roster_messaging"))return;n=wd("%1$s says",s)}}else n=wd("Notification from %1$s",s);const o=t.is_encrypted?wd("Encrypted message received"):t.body;if(!o)return;const a=new Notification(n,{body:o,lang:Vc.locale,icon:Qc.settings.get("notification_icon"),requireInteraction:!Vc.notification_delay});Qc.settings.get("notification_delay")&&setTimeout(a.close.bind(a),Qc.settings.get("notification_delay")),a.onclick=function(e){e.preventDefault(),window.focus();Vc.chatboxes.get(s).maybeShow(!0)},a.onclick.bind(Vc)},Vc.showChatStateNotification=function(e){if(Vc.chatstate_notification_blacklist.includes(e.jid))return;const t=e.chat_status;let n=null;if("offline"===t?n=wd("has gone offline"):"away"===t?n=wd("has gone away"):"dnd"===t?n=wd("is busy"):"online"===t&&(n=wd("has come online")),null===n)return;const r=new Notification(e.getDisplayName(),{body:n,lang:Vc.locale,icon:Vc.notification_icon});setTimeout(r.close.bind(r),5e3)},Vc.showContactRequestNotification=function(e){const t=new Notification(e.getDisplayName(),{body:wd("wants to be your contact"),lang:Vc.locale,icon:Vc.notification_icon});setTimeout(t.close.bind(t),5e3)
<li class="room-item list-group-item">
<div class="available-chatroom d-flex flex-row">
<a class="open-room available-room w-100"
@click=${e.toggleCommandForm}
data-command-node="${t.node}"
data-command-jid="${t.jid}"
data-command-name="${t.name}"
title="${t.name}"
href="#">${t.name||t.jid}</a>
</div>
${t.node===e.showform?((e,t)=>{const n=wd("Hide"),r=wd("Execute");return wc`
<form @submit=${e.runCommand}>
${t.alert?wc`<div class="alert alert-${t.alert_type}" role="alert">${t.alert}</div>`:""}
<fieldset class="form-group">
<input type="hidden" name="command_node" value="${t.node}"/>
<input type="hidden" name="command_jid" value="${t.jid}"/>
<p class="form-help">${t.instructions}</p>
<!-- Fields are generated internally, with xForm2webForm -->
${t.fields.map(e=>df(e))}
</fieldset>
<fieldset>
<input type="submit" class="btn btn-primary" value="${r}">
<input type="button" class="btn btn-secondary button-cancel" value="${n}" @click=${e.hideCommandForm}>
</fieldset>
</form>
`})(e,t):""}
</li>
`;async function Xm(){const e=[...await Qc.rooms.get(),...await Qc.contacts.get()];return[...new Set(e.map(e=>Gm.getDomainFromJid(e.get("jid"))))]}const Zm=e=>{const t=wd("On which entity do you want to run commands?"),n=wd("Certain XMPP services and entities allow privileged users to execute ad-hoc commands on them."),r=wd("Commands found"),i=wd("List available commands"),s=wd("XMPP Address"),o=wd("No commands found");return wc`
${e.alert?wc`<div class="alert alert-${e.alert_type}" role="alert">${e.alert}</div>`:""}
<form class="converse-form" @submit=${e.fetchCommands}>
<fieldset class="form-group">
<label>
${t}
<p class="form-help">${n}</p>
<converse-autocomplete
.getAutoCompleteList="${Xm}"
placeholder="${s}"
name="jid"/>
</label>
</fieldset>
<fieldset class="form-group">
<input type="submit" class="btn btn-primary" value="${i}">
</fieldset>
${"list-commands"===e.view?wc`
<fieldset class="form-group">
<ul class="list-group">
<li class="list-group-item active">${e.commands.length?r:o}:</li>
${e.commands.map(t=>Km(e,t))}
</ul>
</fieldset>`:""}
</form>
`};Qc.elements.define("converse-adhoc-commands",class extends Kd{static get properties(){return{alert:{type:String},alert_type:{type:String},nonce:{type:String},showform:{type:String},view:{type:String}}}constructor(){super(),this.view="choose-service",this.showform="",this.commands=[]}render(){return Zm({alert:this.alert,alert_type:this.alert_type,commands:this.commands,fetchCommands:e=>this.fetchCommands(e),hideCommandForm:e=>this.hideCommandForm(e),runCommand:e=>this.runCommand(e),showform:this.showform,toggleCommandForm:e=>this.toggleCommandForm(e),view:this.view})}async fetchCommands(e){e.preventDefault(),delete this.alert_type,delete this.alert;const t=new FormData(e.target).get("jid").trim();let n;try{n=await Qc.disco.supports(Gm.NS.ADHOC,t)}catch(e){Dn.error(e)}if(n)try{this.commands=await Qc.adhoc.getCommands(t),this.view="list-commands"}catch(e){return Dn.error(e),this.alert_type="danger",this.alert=wd("Sorry, an error occurred while looking for commands on that entity."),this.commands=[],void Dn.error(e)}else this.alert_type="danger",this.alert=wd("The specified entity doesn't support ad-hoc commands")}async toggleCommandForm(e){e.preventDefault();const t=e.target.getAttribute("data-command-node"),n=this.commands.filter(e=>e.node===t)[0];this.showform!==t&&await async function(e){const t=e.node,n=e.jid,r=Jm({type:"set",to:n}).c("command",{xmlns:Gm.NS.ADHOC,node:t,action:"execute"});try{var i;const t=await Qc.sendIQ(r),n=Qm(`command[xmlns="${Gm.NS.ADHOC}"]`,t).pop();e.sessionid=n.getAttribute("sessionid"),e.instructions=null===(i=Qm('x[type="form"][xmlns="jabber:x:data"] instructions',n).pop())||void 0===i?void 0:i.textContent,e.fields=Qm('x[type="form"][xmlns="jabber:x:data"] field',n).map(e=>Ym.xForm2webForm(e,n))}catch(t){null===t?Dn.error("Error: timeout while trying to execute command for "+n):(Dn.error("Error while trying to execute command for "+n),Dn.error(t)),e.fields=[]}}(n),this.showform=t}hideCommandForm(e){e.preventDefault(),this.showform=""}async runCommand(e){e.preventDefault();const t=new FormData(e.target),n=t.get("command_jid").trim(),r=t.get("command_node").trim(),i=this.commands.filter(e=>e.node===r)[0],s=Qm(":input:not([type=button]):not([type=submit])",e.target).filter(e=>!["command_jid","command_node"].includes(e.getAttribute("name"))).map(Ym.webForm2xForm).filter(e=>e),o=Jm({to:n,type:"set"}).c("command",{sessionid:i.sessionid,node:i.node,xmlns:Gm.NS.ADHOC}).c("x",{xmlns:Gm.NS.XFORM,type:"submit"});let a;s.forEach(e=>o.cnode(e).up());try{a=await Qc.sendIQ(o)}catch(e){i.alert_type="danger",i.alert=wd("Sorry, an error occurred while trying to execute the command. See the developer console for details"),Dn.error("Error while trying to execute an ad-hoc command"),Dn.error(e)}var c;a?i.alert=null===(c=a.querySelector("note"))||void 0===c?void 0:c.textContent:i.alert="Done";i.alert_type="primary",this.nonce=Ym.getUniqueId()}});var ev=e=>{const t=wd("Settings"),n=wd("%1$s Open Source %2$s XMPP chat client brought to you by %3$s Opkode %2$s",'<a target="_blank" rel="nofollow" href="https://conversejs.org">',"</a>",'<a target="_blank" rel="nofollow" href="https://opkode.com">'),r=wd("%1$s Translate %2$s it into your own language",'<a target="_blank" rel="nofollow" href="https://hosted.weblate.org/projects/conversejs/#languages">',"</a>"),i=Qc.settings.get("show_client_info"),s=Qc.settings.get("allow_adhoc_commands");return wc`
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="converse-modtools-modal-label">${t}</h5>
${qd}
</div>
<div class="modal-body">
${i&&s?(e=>{const t=wd("About"),n=wd("Commands");return wc`
<ul class="nav nav-pills justify-content-center">
<li role="presentation" class="nav-item">
<a class="nav-link active" id="about-tab" href="#about-tabpanel" aria-controls="about-tabpanel" role="tab" data-toggle="tab" @click=${e.switchTab}>${t}</a>
</li>
<li role="presentation" class="nav-item">
<a class="nav-link" id="commands-tab" href="#commands-tabpanel" aria-controls="commands-tabpanel" role="tab" data-toggle="tab" @click=${e.switchTab}>${n}</a>
</li>
</ul>
`})(e):""}
<div class="tab-content">
<div class="tab-pane tab-pane--columns ${i?"active":""}"
id="about-tabpanel" role="tabpanel" aria-labelledby="about-tab">
<span class="modal-alert"></span>
<br/>
<div class="container">
<h6 class="brand-heading">Converse</h6>
<p class="brand-subtitle">${e.version_name}</p>
<p class="brand-subtitle">${df(lf.a.filterXSS(n,{whiteList:{a:[]}}))}</p>
<p class="brand-subtitle">${df(lf.a.filterXSS(r,{whiteList:{a:[]}}))}</p>
</div>
</div>
<div class="tab-pane tab-pane--columns ${!i&&s?"active":""}"
id="commands-tabpanel"
role="tabpanel"
aria-labelledby="commands-tab">
<converse-adhoc-commands/>
</div>
</div>
</div>
</div>
</div>
`};let tv;var nv=Gd.extend({id:"converse-client-info-modal",initialize(e){tv=e._converse,Gd.prototype.initialize.apply(this,arguments)},toHTML(){return ev(Object.assign(this.model.toJSON(),this.model.vcard.toJSON(),{version_name:tv.VERSION_NAME}))}});const rv=wd("Your avatar image");Qc.elements.define("converse-image-picker",class extends Kd{static get properties(){return{height:{type:Number},image:{type:String},width:{type:Number}}}render(){const e={height:this.height,image:this.image,width:this.width};return wc`
<a class="change-avatar" @click=${this.openFileSelection} title="${rv}">
${Vh(e)}
</a>
<input @change=${this.updateFilePreview} class="hidden" name="image" type="file"/>
`}openFileSelection(e){e.preventDefault(),this.querySelector('input[type="file"]').click()}updateFilePreview(e){const t=e.target.files[0],n=new FileReader;n.onloadend=()=>this.image=n.result,n.readAsDataURL(t)}});const iv=sl.env.utils,sv=e=>wc`
${e.device.get("bundle")&&e.device.get("bundle").fingerprint?(e=>{const t=wd("Checkbox for selecting the following fingerprint");return wc`
<li class="fingerprint-removal-item list-group-item nopadding">
<label>
<input type="checkbox" value="${e.device.get("id")}"
aria-label="${t}"/>
<span class="fingerprint">${iv.formatFingerprint(e.device.get("bundle").fingerprint)}</span>
</label>
</li>
`})(e):(e=>{const t=wd("Device without a fingerprint"),n=wd("Checkbox for selecting the following device");return wc`
<li class="fingerprint-removal-item list-group-item nopadding">
<label>
<input type="checkbox" value="${e.device.get("id")}"
aria-label="${n}"/>
<span>${t}</span>
</label>
</li>
`})(e)}
`,ov=e=>{const t=wd("This device's OMEMO fingerprint"),n=wd("Generate new keys and fingerprint");return wc`
<div class="tab-pane" id="omemo-tabpanel" role="tabpanel" aria-labelledby="omemo-tab">
<form class="converse-form fingerprint-removal">
<ul class="list-group fingerprints">
<li class="list-group-item active">${t}</li>
<li class="list-group-item">
${e.view.current_device&&e.view.current_device.get("bundle")&&e.view.current_device.get("bundle").fingerprint?(e=>wc`
<span class="fingerprint">${iv.formatFingerprint(e.view.current_device.get("bundle").fingerprint)}</span>`)(e):Wh()}
</li>
</ul>
<div class="form-group">
<button type="button" class="generate-bundle btn btn-danger">${n}</button>
</div>
${e.view.other_devices.length?(e=>{const t=wd("Other OMEMO-enabled devices"),n=wd("Checkbox to select fingerprints of all other OMEMO devices"),r=wd("Remove checked devices and close"),i=wd("Select all");return wc`
<ul class="list-group fingerprints">
<li class="list-group-item nopadding active">
<label>
<input type="checkbox" class="select-all" title="${i}" aria-label="${n}"/>
${t}
</label>
</li>
${e.view.other_devices.map(t=>sv(Object.assign({device:t},e)))}
</ul>
<div class="form-group"><button type="submit" class="save-form btn btn-primary">${r}</button></div>
`})(e):""}
</form>
</div>`};
2021-01-29 23:34:36 +01:00
/**
* @module converse-profile
* @copyright The Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/
2021-03-19 19:26:15 +01:00
const{sizzle:av,u:cv}=sl.env;sl.plugins.add("converse-profile",{dependencies:["converse-status","converse-modal","converse-vcard","converse-chatboxviews"],initialize(){Qc.settings.extend({allow_adhoc_commands:!0,show_client_info:!0}),Vc.ProfileModal=Gd.extend({id:"user-profile-modal",events:{"submit .profile-form":"onFormSubmitted"},initialize(){this.listenTo(this.model,"change",this.render),Gd.prototype.initialize.apply(this,arguments),Qc.trigger("profileModalInitialized",this.model)},toHTML(){return(e=>{const t=wd("Your Profile"),n=wd("Email"),r=wd("Full Name"),i=wd("XMPP Address (JID)"),s=wd("Nickname"),o=wd("Role"),a=wd("Save and close"),c=wd("Use commas to separate multiple roles. Your roles are shown next to your name on your chat messages."),l=wd("URL"),u=wd("OMEMO"),d=wd("Profile"),h=wc`
<ul class="nav nav-pills justify-content-center">
<li role="presentation" class="nav-item">
<a class="nav-link active" id="profile-tab" href="#profile-tabpanel" aria-controls="profile-tabpanel" role="tab" data-toggle="tab">${d}</a>
</li>
<li role="presentation" class="nav-item">
<a class="nav-link" id="omemo-tab" href="#omemo-tabpanel" aria-controls="omemo-tabpanel" role="tab" data-toggle="tab">${u}</a>
</li>
</ul>`;return wc`
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="user-profile-modal-label">${t}</h5>
${qd}
</div>
<div class="modal-body">
<span class="modal-alert"></span>
${Vc.pluggable.plugins["converse-omemo"].enabled(Vc)&&h||""}
<div class="tab-content">
<div class="tab-pane active" id="profile-tabpanel" role="tabpanel" aria-labelledby="profile-tab">
<form class="converse-form converse-form--modal profile-form" action="#">
<div class="row">
<div class="col-auto">
<converse-image-picker image="${e.image}" width="${e.width}" height="${e.height}"></converse-image-picker>
</div>
<div class="col">
<div class="form-group">
<label class="col-form-label">${i}:</label>
<div>${e.jid}</div>
</div>
</div>
</div>
<div class="form-group">
<label for="vcard-fullname" class="col-form-label">${r}:</label>
<input id="vcard-fullname" type="text" class="form-control" name="fn" value="${e.fullname||""}"/>
</div>
<div class="form-group">
<label for="vcard-nickname" class="col-form-label">${s}:</label>
<input id="vcard-nickname" type="text" class="form-control" name="nickname" value="${e.nickname||""}"/>
</div>
<div class="form-group">
<label for="vcard-url" class="col-form-label">${l}:</label>
<input id="vcard-url" type="url" class="form-control" name="url" value="${e.url||""}"/>
</div>
<div class="form-group">
<label for="vcard-email" class="col-form-label">${n}:</label>
<input id="vcard-email" type="email" class="form-control" name="email" value="${e.email||""}"/>
</div>
<div class="form-group">
<label for="vcard-role" class="col-form-label">${o}:</label>
<input id="vcard-role" type="text" class="form-control" name="role" value="${e.role||""}" aria-describedby="vcard-role-help"/>
<small id="vcard-role-help" class="form-text text-muted">${c}</small>
</div>
<hr/>
<div class="form-group">
<button type="submit" class="save-form btn btn-primary">${a}</button>
</div>
</form>
</div>
${Vc.pluggable.plugins["converse-omemo"].enabled(Vc)&&ov(e)||""}
</div>
</div>
</div>
</div>
`})(Object.assign(this.model.toJSON(),this.model.vcard.toJSON(),this.getAvatarData(),{view:this}))},getAvatarData(){return{height:128,width:128,image:"data:"+this.model.vcard.get("image_type")+";base64,"+this.model.vcard.get("image")}},afterRender(){this.tabs=av(".nav-item .nav-link",this.el).map(e=>new Fd.a.Tab(e))},async setVCard(e){try{await Qc.vcard.set(Vc.bare_jid,e)}catch(e){return Dn.fatal(e),void this.alert([wd("Sorry, an error happened while trying to save your profile data."),wd("You can check your browser's developer console for any error output.")].join(" "))}this.modal.hide()},onFormSubmitted(e){e.preventDefault();const t=new FileReader,n=new FormData(e.target),r=n.get("image"),i={fn:n.get("fn"),nickname:n.get("nickname"),role:n.get("role"),email:n.get("email"),url:n.get("url")};r.size?(t.onloadend=()=>{Object.assign(i,{image:btoa(t.result),image_type:r.type}),this.setVCard(i)},t.readAsBinaryString(r)):(Object.assign(i,{image:this.model.vcard.get("image"),image_type:this.model.vcard.get("image_type")}),this.setVCard(i))}}),Vc.ChatStatusModal=Gd.extend({id:"modal-status-change",events:{"submit form#set-xmpp-status":"onFormSubmitted","click .clear-input":"clearStatusMessage"},toHTML(){return e=Object.assign(this.model.toJSON(),this.model.vcard.toJSON(),{label_away:wd("Away"),label_busy:wd("Busy"),label_cancel:wd("Cancel"),label_close:wd("Close"),label_custom_status:wd("Custom status"),label_offline:wd("Offline"),label_online:wd("Online"),label_save:wd("Save"),label_xa:wd("Away for long"),modal_title:wd("Change chat status"),placeholder_status_message:wd("Personal status message")}),wc`
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="changeStatusModalLabel">${e.modal_title}</h5>
${qd}
</div>
<div class="modal-body">
<span class="modal-alert"></span>
<form class="converse-form set-xmpp-status" id="set-xmpp-status">
<div class="form-group">
<div class="custom-control custom-radio">
<input ?checked=${"online"===e.status}
type="radio" id="radio-online" value="online" name="chat_status" class="custom-control-input"/>
<label class="custom-control-label" for="radio-online">
<span class="fa fa-circle chat-status chat-status--online"></span>${e.label_online}</label>
</div>
<div class="custom-control custom-radio">
<input ?checked=${"busy"===e.status}
type="radio" id="radio-busy" value="dnd" name="chat_status" class="custom-control-input"/>
<label class="custom-control-label" for="radio-busy">
<span class="fa fa-minus-circle chat-status chat-status--busy"></span>${e.label_busy}</label>
</div>
<div class="custom-control custom-radio">
<input ?checked=${"away"===e.status}
type="radio" id="radio-away" value="away" name="chat_status" class="custom-control-input"/>
<label class="custom-control-label" for="radio-away">
<span class="fa fa-circle chat-status chat-status--away"></span>${e.label_away}</label>
</div>
<div class="custom-control custom-radio">
<input ?checked=${"xa"===e.status}
type="radio" id="radio-xa" value="xa" name="chat_status" class="custom-control-input"/>
<label class="custom-control-label" for="radio-xa">
<span class="far fa-circle chat-status chat-status--xa"></span>${e.label_xa}</label>
</div>
</div>
<div class="form-group">
<div class="btn-group w-100">
<input name="status_message" type="text" class="form-control"
value="${e.status_message||""}" placeholder="${e.placeholder_status_message}"/>
<span class="clear-input fa fa-times ${e.status_message?"":"hidden"}"></span>
</div>
</div>
<button type="submit" class="btn btn-primary">${e.label_save}</button>
</form>
</div>
</div>
</div>
`;var e},afterRender(){this.el.addEventListener("shown.bs.modal",()=>{this.el.querySelector('input[name="status_message"]').focus()},!1)},clearStatusMessage(e){e&&e.preventDefault&&(e.preventDefault(),cv.hideElement(this.el.querySelector(".clear-input")));this.el.querySelector('input[name="status_message"]').value=""},onFormSubmitted(e){e.preventDefault();const t=new FormData(e.target);this.model.save({status_message:t.get("status_message"),status:t.get("chat_status")}),this.modal.hide()}}),Vc.XMPPStatusView=Vc.ViewWithAvatar.extend({tagName:"div",events:{"click a.show-profile":"showProfileModal","click a.change-status":"showStatusChangeModal","click .logout":"logOut"},initialize(){this.listenTo(this.model,"change",this.render),this.listenTo(this.model.vcard,"change",this.render)},toHTML(){const e=this.model.get("status")||"offline";return(e=>{const t=wd("Log out"),n=wd("Click to change your chat status"),r=wd("Show details about this chat client"),i=Qc.settings.get("show_client_info")||Qc.settings.get("allow_adhoc_commands");return wc`
<div class="userinfo controlbox-padded">
<div class="controlbox-section profile d-flex">
<a class="show-profile" href="#">
<canvas class="avatar align-self-center" height="40" width="40"></canvas>
</a>
<span class="username w-100 align-self-center">${e.fullname}</span>
${i?wc`<a class="controlbox-heading__btn show-client-info fa fa-cog align-self-center" title="${r}" @click=${e.showUserSettingsModal}></a>`:""}
${Qc.settings.get("allow_logout")?wc`<a class="controlbox-heading__btn logout fa fa-sign-out-alt align-self-center" title="${t}"></a>`:""}
</div>
<div class="d-flex xmpp-status">
<a class="change-status" title="${n}" data-toggle="modal" data-target="#changeStatusModal">
<span class="${e.chat_status} w-100 align-self-center" data-value="${e.chat_status}">
<span class="
${"online"===e.chat_status&&"fa fa-circle chat-status chat-status--online"}
${"dnd"===e.chat_status&&"fa fa-minus-circle chat-status chat-status--busy"}
${"away"===e.chat_status&&"fa fa-circle chat-status chat-status--away"}
${"xa"===e.chat_status&&"far fa-circle chat-status chat-status--xa "}
${"offline"===e.chat_status&&"fa fa-circle chat-status chat-status--offline"}"></span> ${e.status_message}</span>
</a>
</div>
</div>
`})(Object.assign(this.model.toJSON(),this.model.vcard.toJSON(),{chat_status:e,fullname:this.model.vcard.get("fullname")||Vc.bare_jid,showUserSettingsModal:e=>this.showUserSettingsModal(e),status_message:this.model.get("status_message")||wd("I am %1$s",this.getPrettyStatus(e))}))},afterRender(){this.renderAvatar()},showProfileModal(e){e.preventDefault(),void 0===this.profile_modal&&(this.profile_modal=new Vc.ProfileModal({model:this.model})),this.profile_modal.show(e)},showStatusChangeModal(e){e.preventDefault(),void 0===this.status_modal&&(this.status_modal=new Vc.ChatStatusModal({model:this.model})),this.status_modal.show(e)},showUserSettingsModal(e){e.preventDefault(),void 0===this.user_settings_modal&&(this.user_settings_modal=new nv({model:this.model,_converse:Vc})),this.user_settings_modal.show(e)},logOut(e){e.preventDefault();!0===confirm(wd("Are you sure you want to log out?"))&&Qc.user.logout()},getPrettyStatus:e=>"chat"===e?wd("online"):"dnd"===e?wd("busy"):"xa"===e?wd("away for long"):"away"===e?wd("away"):"offline"===e?wd("offline"):wd(e)||wd("online")}),Qc.listen.on("controlBoxPaneInitialized",async e=>{await Qc.waitUntil("VCardsInitialized"),Vc.xmppstatusview=new Vc.XMPPStatusView({model:Vc.xmppstatus}),e.el.insertAdjacentElement("afterBegin",Vc.xmppstatusview.render().el)})}});var lv=function(){var e=arguments.length;if(!e)return[];for(var t=Array(e-1),n=arguments[0],r=e;r--;)t[r-1]=arguments[r];return dt(Oe(n)?it(n):[n],Ms(t,1))},uv=Math.ceil,dv=Math.max;var hv=function(e,t,n,r){for(var i=-1,s=dv(uv((t-e)/(n||1)),0),o=Array(s);s--;)o[r?s:++i]=e,e+=n;return o};var fv=function(e){return function(t,n,r){return r&&"number"!=typeof r&&Cr(t,n,r)&&(n=r=void 0),t=fi(t),void 0===n?(n=t,t=0):n=fi(n),r=void 0===r?t<n?1:-1:fi(r),hv(t,n,r,e)}}();
2021-01-29 23:34:36 +01:00
/**
* @module converse-omemo
* @copyright The Converse.js contributors
* @license Mozilla Public License (MPLv2)
2021-03-19 19:26:15 +01:00
*/
const{Strophe:pv,sizzle:gv,$build:mv,$iq:vv,$msg:_v}=sl.env,bv=sl.env.utils;pv.addNamespace("OMEMO_DEVICELIST",pv.NS.OMEMO+".devicelist"),pv.addNamespace("OMEMO_VERIFICATION",pv.NS.OMEMO+".verification"),pv.addNamespace("OMEMO_WHITELISTED",pv.NS.OMEMO+".whitelisted"),pv.addNamespace("OMEMO_BUNDLES",pv.NS.OMEMO+".bundles");const yv={name:"AES-GCM",length:128};class wv extends Error{constructor(e,t){super(e,t),this.name="IQError",this.iq=t}}function Sv(e,t){return t.is_encrypted&&t.encrypted.key?!0===t.encrypted.prekey?async function(e){const t=Cv(e.from,parseInt(e.encrypted.device_id,10)),n=bv.base64ToArrayBuffer(e.encrypted.key);let r;try{r=await t.decryptPreKeyWhisperMessage(n,"binary")}catch(t){return Dn.error(`${t.name} ${t.message}`),Object.assign(e,jv(t))}try{const t=await kv(e,r);return await Vc.omemo_store.generateMissingPreKeys(),await Vc.omemo_store.publishBundle(),t?Object.assign(e,{plaintext:t}):Object.assign(e,{is_only_key:!0})}catch(t){return Dn.error(`${t.name} ${t.message}`),Object.assign(e,jv(t))}}(t):async function(e){const t=e.from_muc?e.from_real_jid:e.from;t||Object.assign(e,{error_text:wd("Sorry, could not decrypt a received OMEMO because we don't have the JID for that user."),error_type:"Decryption",is_ephemeral:!1,is_error:!0,type:"error"});const n=Cv(t,parseInt(e.encrypted.device_id,10)),r=bv.base64ToArrayBuffer(e.encrypted.key);try{const t=await n.decryptWhisperMessage(r,"binary"),i=await kv(e,t);return Object.assign(e,{plaintext:i})}catch(t){return Dn.error(`${t.name} ${t.message}`),Object.assign(e,jv(t))}}(t):t}function xv(){Vc.chatboxes.on("add",e=>{Pv(e),e.get("type")===Vc.CHATROOMS_TYPE&&(e.occupants.on("add",t=>async function(e,t){if(t.isSelf()||!e.features.get("nonanonymous")||!e.features.get("membersonly"))return;if(e.get("omemo_active")){await Vc.contactHasOMEMOSupport(t.get("jid"))||(e.createMessage({message:wd("%1$s doesn't appear to have a client that supports OMEMO. Encrypted chat will no longer be possible in this grouchat.",t.get("nick")),type:"error"}),e.save({omemo_active:!1,omemo_supported:!1}))}}(e,t)),e.features.on("change",()=>Pv(e)))})}function Ev(e){e.listenTo(e.model.messages,"add",t=>{t.get("is_encrypted")&&!t.get("is_error")&&e.model.save("omemo_supported",!0)}),e.listenTo(e.model,"change:omemo_supported",()=>{var t;!e.model.get("omemo_supported")&&e.model.get("omemo_active")?e.model.set("omemo_active",!1):null===(t=e.el.querySelector("converse-chat-toolbar"))||void 0===t||t.requestUpdate()}),e.listenTo(e.model,"change:omemo_active",()=>{e.el.querySelector("converse-chat-toolbar").requestUpdate()})}const Av=sl.env.omemo={async encryptMessage(e){const t=crypto.getRandomValues(new window.Uint8Array(12)),n=await crypto.subtle.generateKey(yv,!0,["encrypt","decrypt"]),r={name:"AES-GCM",iv:t,tagLength:128},i=await crypto.subtle.encrypt(r,n,bv.stringToArrayBuffer(e)),s=i.byteLength-16,o=i.slice(0,s),a=i.slice(s),c=await crypto.subtle.exportKey("raw",n);return{key:c,tag:a,key_and_tag:bv.appendArrayBuffer(c,a),payload:bv.arrayBufferToBase64(o),iv:bv.arrayBufferToBase64(t)}},async decryptMessage(e){const t=await crypto.subtle.importKey("raw",e.key,yv,!0,["encrypt","decrypt"]),n=bv.appendArrayBuffer(bv.base64ToArrayBuffer(e.payload),e.tag),r={name:"AES-GCM",iv:bv.base64ToArrayBuffer(e.iv),tagLength:128};return bv.arrayBufferToString(await crypto.subtle.decrypt(r,t,n))}};function Cv(e,t){const n=new libsignal.SignalProtocolAddress(e,t);return new window.libsignal.SessionCipher(Vc.omemo_store,n)}async function kv(e,t){const n=e.encrypted,r=Vc.devicelists.getDeviceList(e.from);await r._devices_promise;let i=r.get(n.device_id);if(i||(i=await r.devices.create({id:n.device_id,jid:e.from},{promise:!0})),n.payload){const e=t.slice(0,16),r=t.slice(16),s=await Av.decryptMessage(Object.assign(n,{key:e,tag:r}));return i.save("active",!0),s}}function jv(e){return"debug"===Qc.settings.get("loglevel")?{error_text:wd("Sorry, could not decrypt a received OMEMO message due to an error.")+` ${e.name} ${e.message}`,error_type:"Decryption",is_ephemeral:!0,is_error:!0,type:"error"}:{}}function Tv(e){co
<button class="toggle-omemo"
title="${r}"
?disabled=${!n.get("omemo_supported")}
@click=${Lv}>
<converse-icon class="fa ${n.get("omemo_active")?"fa-lock":"fa-unlock"}"
path-prefix="${Qc.settings.get("assets_path")}" size="1em"
color="${n.get("omemo_active")?"var(--info-color)":"var(--error-color)"}"
></converse-icon>
2021-07-03 16:04:46 +02:00
</button>`),t}const Fv={encryptKey:(e,t)=>Cv(t.get("jid"),t.get("id")).encrypt(e).then(e=>({payload:e,device:t})),handleMessageSendError(e){if("IQError"===e.name){this.save("omemo_supported",!1);const t=[];gv(`presence-subscription-required[xmlns="${pv.NS.PUBSUB_ERROR}"]`,e.iq).length?t.push(wd("Sorry, we're unable to send an encrypted message because %1$s requires you to be subscribed to their presence in order to see their OMEMO information",e.iq.getAttribute("from"))):gv('remote-server-not-found[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]',e.iq).length?t.push(wd("Sorry, we're unable to send an encrypted message because the remote server for %1$s could not be found",e.iq.getAttribute("from"))):(t.push(wd("Unable to send an encrypted message due to an unexpected error.")),t.push(e.iq.outerHTML)),Qc.alert("error",wd("Error"),t),Dn.error(e)}else{if(!e.user_facing)throw e;Qc.alert("error",wd("Error"),[e.message]),Dn.error(e)}}};sl.plugins.add("converse-omemo",{enabled:e=>window.libsignal&&e.config.get("trusted")&&!Qc.settings.get("clear_cache_on_logout")&&!e.api.settings.get("blacklisted_plugins").includes("converse-omemo"),dependencies:["converse-chatview","converse-pubsub","converse-profile"],overrides:{ProfileModal:{events:{"change input.select-all":"selectAll","click .generate-bundle":"generateOMEMODeviceBundle","submit .fingerprint-removal":"removeSelectedFingerprints"},initialize(){return this.debouncedRender=Ma(this.render,50),this.devicelist=Vc.devicelists.get(Vc.bare_jid),this.listenTo(this.devicelist.devices,"change:bundle",this.debouncedRender),this.listenTo(this.devicelist.devices,"reset",this.debouncedRender),this.listenTo(this.devicelist.devices,"reset",this.debouncedRender),this.listenTo(this.devicelist.devices,"remove",this.debouncedRender),this.listenTo(this.devicelist.devices,"add",this.debouncedRender),this.__super__.initialize.apply(this,arguments)},beforeRender(){const e=Vc.omemo_store.get("device_id");if(e&&(this.current_device=this.devicelist.devices.get(e)),this.other_devices=this.devicelist.devices.filter(t=>t.get("id")!==e),this.__super__.beforeRender)return this.__super__.beforeRender.apply(this,arguments)},selectAll(e){let t=bv.ancestor(e.target,"li");for(;t;)t.querySelector('input[type="checkbox"]').checked=e.target.checked,t=t.nextElementSibling},removeSelectedFingerprints(e){e.preventDefault(),e.stopPropagation(),e.target.querySelector(".select-all").checked=!1;const t=gv('.fingerprint-removal-item input[type="checkbox"]:checked',e.target).map(e=>e.value);this.devicelist.removeOwnDevices(t).then(this.modal.hide).catch(e=>{Dn.error(e),Vc.api.alert(pv.LogLevel.ERROR,wd("Error"),[wd("Sorry, an error occurred while trying to remove the devices.")])})},generateOMEMODeviceBundle(e){e.preventDefault(),confirm(wd("Are you sure you want to generate new OMEMO keys? This will remove your old keys and all previously encrypted messages will no longer be decryptable on this device."))&&Qc.omemo.bundle.generate()}},UserDetailsModal:{events:{"click .fingerprint-trust .btn input":"toggleDeviceTrust"},initialize(){const e=this.model.get("jid");return this.devicelist=Vc.devicelists.getDeviceList(e),this.listenTo(this.devicelist.devices,"change:bundle",this.render),this.listenTo(this.devicelist.devices,"change:trusted",this.render),this.listenTo(this.devicelist.devices,"remove",this.render),this.listenTo(this.devicelist.devices,"add",this.render),this.listenTo(this.devicelist.devices,"reset",this.render),this.__super__.initialize.apply(this,arguments)},toggleDeviceTrust(e){const t=e.target;this.devicelist.devices.get(t.getAttribute("name")).save("trusted",parseInt(t.value,10))}},ChatBox:{async sendMessage(e,t){if(this.get("omemo_active")&&e){const n=this.getOutgoingMessageAttributes(e,t);let r,i;n.is_encrypted=!0,n.plaintext=n.message;try{const e=await Vc.getBundlesAndBuildSessions(this);r=await this.createMessage(n),i=await Vc.createOMEMOMessageStanza(this,r,e)}catch(e){return this.handleMessageSendError(e),null}return Vc.api.send(i),r}return this.__super__.sendMessage.apply(this,arguments)}}},initial
2021-01-29 23:34:36 +01:00
/**
* @module converse-push
* @description
* Converse.js plugin which add support for registering
* an "App Server" as defined in XEP-0357
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/
2021-03-19 19:26:15 +01:00
const{Strophe:Bv,$iq:qv}=sl.env;Bv.addNamespace("PUSH","urn:xmpp:push:0"),sl.plugins.add("converse-push",{initialize(){async function e(e){e=e||Vc.bare_jid;const t=Vc.session.get("push_enabled")||[];if(t.includes(e))return;const n=Qc.settings.get("push_app_servers").filter(e=>!e.disable),r=Qc.settings.get("push_app_servers").filter(e=>e.disable),i=n.map(t=>async function(e,t){if(!t.jid||!t.node)return;if(!await Qc.disco.getIdentity("pubsub","push",t.jid))return Dn.warn(`Not enabling push the service "${t.jid}", it doesn't have the right disco identtiy.`);const n=await Promise.all([Qc.disco.supports(Bv.NS.PUSH,t.jid),Qc.disco.supports(Bv.NS.PUSH,e)]);if(!n[0]&&!n[1])return void Dn.warn(`Not enabling push app server "${t.jid}", no disco support from your server.`);const r=qv({type:"set"});return e!==Vc.bare_jid&&r.attrs({to:e}),r.c("enable",{xmlns:Bv.NS.PUSH,jid:t.jid,node:t.node}),t.secret&&r.c("x",{xmlns:Bv.NS.XFORM,type:"submit"}).c("field",{var:"FORM_TYPE"}).c("value").t(Bv.NS.PUBSUB+"#publish-options").up().up().c("field",{var:"secret"}).c("value").t(t.secret),Qc.sendIQ(r)}(e,t)),s=r.map(t=>async function(e,t){if(!t.jid)return;if(!await Qc.disco.supports(Bv.NS.PUSH,e||Vc.bare_jid))return void Dn.warn(`Not disabling push app server "${t.jid}", no disco support from your server.`);const n=qv({type:"set"});e!==Vc.bare_jid&&n.attrs({to:e}),n.c("disable",{xmlns:Bv.NS.PUSH,jid:t.jid}),t.node&&n.attrs({node:t.node}),Qc.sendIQ(n).catch(e=>{Dn.error("Could not disable push app server for "+t.jid),Dn.error(e)})}(e,t));try{await Promise.all(i.concat(s))}catch(e){Dn.error("Could not enable or disable push App Server"),e&&Dn.error(e)}finally{t.push(e)}Vc.session.save("push_enabled",t)}function t(t){t.get("type")==Vc.CHATROOMS_TYPE&&e(Bv.getDomainFromJid(t.get("jid")))}Qc.settings.extend({push_app_servers:[],enable_muc_push:!1}),Qc.listen.on("statusInitialized",()=>e()),Qc.settings.get("enable_muc_push")&&Qc.listen.on("chatBoxesInitialized",()=>Vc.chatboxes.on("add",t))}});var Uv=n(176),Hv=n.n(Uv),Vv=n(177),Wv=n.n(Vv),Gv=n(178),Jv=n.n(Gv);
2021-01-29 23:34:36 +01:00
/**
* @module converse-register
* @description
* This is a Converse.js plugin which add support for in-band registration
* as specified in XEP-0077.
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/
2021-03-19 19:26:15 +01:00
const{Strophe:Qv,sizzle:Yv,$iq:Kv}=sl.env,Xv=sl.env.utils;Qv.addNamespace("REGISTER","jabber:iq:register");const Zv=Object.keys(Qv.Status).reduce((e,t)=>Math.max(e,Qv.Status[t]),0);Qv.Status.REGIFAIL=Zv+1,Qv.Status.REGISTERED=Zv+2,Qv.Status.CONFLICT=Zv+3,Qv.Status.NOTACCEPTABLE=Zv+5,sl.plugins.add("converse-register",{enabled:()=>!0,overrides:{ControlBoxView:{renderLoginPanel(){return this.__super__.renderLoginPanel.apply(this,arguments),this.renderRegistrationPanel(),this}}},initialize(){function e(e){Qc.waitUntil("controlBoxInitialized").then(()=>{Vc.chatboxes.get("controlbox").set({"active-form":e})}).catch(e=>Dn.fatal(e))}Vc.CONNECTION_STATUS[Qv.Status.REGIFAIL]="REGIFAIL",Vc.CONNECTION_STATUS[Qv.Status.REGISTERED]="REGISTERED",Vc.CONNECTION_STATUS[Qv.Status.CONFLICT]="CONFLICT",Vc.CONNECTION_STATUS[Qv.Status.NOTACCEPTABLE]="NOTACCEPTABLE",Qc.settings.extend({allow_registration:!0,domain_placeholder:wd(" e.g. conversejs.org"),providers_link:"https://compliance.conversations.im/",registration_domain:""}),Object.assign(Vc.ControlBoxView.prototype,{showLoginOrRegisterForm(){this.registerpanel&&("register"==this.model.get("active-form")?(this.loginpanel.el.classList.add("hidden"),this.registerpanel.el.classList.remove("hidden")):(this.loginpanel.el.classList.remove("hidden"),this.registerpanel.el.classList.add("hidden")))},renderRegistrationPanel(){if(Qc.settings.get("allow_registration")){this.registerpanel=new Vc.RegisterPanel({model:this.model}),this.registerpanel.render(),this.registerpanel.el.classList.add("hidden");const e=this.el.querySelector("#converse-login-panel");e&&e.insertAdjacentElement("afterend",this.registerpanel.el),this.showLoginOrRegisterForm()}return this}}),Vc.router.route("converse/login",()=>e("login")),Vc.router.route("converse/register",()=>e("register")),Vc.RegisterPanel=Md.extend({tagName:"div",id:"converse-register-panel",className:"controlbox-pane fade-in",events:{"submit form#converse-register":"onFormSubmission","click .button-cancel":"renderProviderChoiceForm"},initialize(){this.reset(),Qc.listen.on("connectionInitialized",()=>this.registerHooks())},render(){return this.model.set("registration_form_rendered",!1),this.el.innerHTML=Hv()({__:wd,default_domain:Qc.settings.get("registration_domain"),label_register:wd("Fetch registration form"),help_providers:wd("Tip: A list of public XMPP providers is available"),help_providers_link:wd("here"),href_providers:Qc.settings.get("providers_link"),domain_placeholder:Qc.settings.get("domain_placeholder")}),Qc.settings.get("registration_domain")&&this.fetchRegistrationForm(Qc.settings.get("registration_domain")),this},registerHooks(){const e=Vc.connection,t=e._connect_cb.bind(e);e._connect_cb=(e,n,r)=>{this._registering?this.getRegistrationFields(e,n)&&(this._registering=!1):t(e,n,r)}},getRegistrationFields(e,t){const n=Vc.connection;n.connected=!0;const r=n._proto._reqToData(e);if(!r)return;if(n._proto._connect_cb(r)===Qv.Status.CONNFAIL)return this.showValidationError(wd("Sorry, we're unable to connect to your chosen provider.")),!1;const i=r.getElementsByTagName("register"),s=r.getElementsByTagName("mechanism");if(0===i.length&&0===s.length)return n._proto._no_auth_received(t),!1;if(0===i.length)return n._changeConnectStatus(Qv.Status.REGIFAIL),this.showValidationError(wd("Sorry, the given provider does not support in band account registration. Please try with a different provider.")),!0;n._addSysHandler(this.onRegistrationFields.bind(this),null,"iq",null,null);const o=Kv({type:"get"}).c("query",{xmlns:Qv.NS.REGISTER}).tree();return o.setAttribute("id",n.getUniqueId("sendIQ")),n.send(o),n.connected=!1,!0},onRegistrationFields(e){return"error"===e.getAttribute("type")?(Vc.connection._changeConnectStatus(Qv.Status.REGIFAIL,wd('Something went wrong while establishing a connection with "%1$s". Are you sure it exists?',this.domain)),!1):1!==e.getElementsByTagName("query").length?(Vc.connection._changeConnectStatus(Qv.Status.REGIFAIL,"unknown"),!1):(this.setFields(e),this.model.get("registration_form_rendered")||this.renderRegistrationForm(e),!1)},rese
<div class="list-item controlbox-padded available-chatroom d-flex flex-row ${e.currently_open(e.room)?"open":""} ${e.room.get("num_unread_general")?"unread-msgs":""}"
data-room-jid="${e.room.get("jid")}">
${e.room.get("num_unread")?(e=>wc`<span class="list-item-badge badge badge--muc msgs-indicator">${e.room.get("num_unread")}</span>`)(e):""}
<a class="list-item-link open-room available-room w-100"
data-room-jid="${e.room.get("jid")}"
title="${wd("Click to open this groupchat")}"
@click=${e.openRoom}>${e.room.getDisplayName()}</a>
${e.allow_bookmarks?(e=>{const t=wd("Bookmark this groupchat"),n=wd("Unbookmark this groupchat");return e.bookmarked?wc`
<a class="list-item-action fa fa-bookmark remove-bookmark button-on"
data-room-jid="${e.room.get("jid")}"
data-bookmark-name="${e.room.getDisplayName()}"
@click=${e.removeBookmark}
title="${e.bookmarked?n:t}"></a>`:wc`
<a class="list-item-action fa fa-bookmark add-bookmark"
data-room-jid="${e.room.get("jid")}"
data-bookmark-name="${e.room.getDisplayName()}"
@click=${e.addBookmark}
title="${e.bookmarked?n:t}"></a>`})(e):""}
<a class="list-item-action room-info fa fa-info-circle"
data-room-jid="${e.room.get("jid")}"
title="${wd("Show more information on this groupchat")}"
@click=${e.showRoomDetailsModal}></a>
<a class="list-item-action fa fa-sign-out-alt close-room"
data-room-jid="${e.room.get("jid")}"
data-room-name="${e.room.getDisplayName()}"
title="${t}"
@click=${e.closeRoom}></a>
</div>`};
2021-01-29 23:34:36 +01:00
/**
* @module converse-roomslist
* @description
* Converse.js plugin which shows a list of currently open
* rooms in the "Rooms Panel" of the ControlBox.
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/
2021-03-19 19:26:15 +01:00
const{Strophe:t_}=sl.env,n_=sl.env.utils;sl.plugins.add("converse-roomslist",{dependencies:["converse-singleton","converse-controlbox","converse-muc","converse-bookmarks"],initialize(){Qc.promises.add("roomsListInitialized"),Vc.RoomsList=Bs.extend({defaults:{"toggle-state":Vc.OPENED}}),Vc.RoomsListView=Md.extend({tagName:"span",initialize(){this.listenTo(this.model,"add",this.renderIfChatRoom),this.listenTo(this.model,"remove",this.renderIfChatRoom),this.listenTo(this.model,"destroy",this.renderIfChatRoom),this.listenTo(this.model,"change",this.renderIfRelevantChange);const e="converse.roomslist"+Vc.bare_jid;this.list_model=new Vc.RoomsList({id:e}),this.list_model.browserStorage=Vc.createStore(e),this.list_model.fetch(),this.render(),this.insertIntoControlBox()},renderIfChatRoom(e){n_.isChatRoom(e)&&this.render()},renderIfRelevantChange(e){const t=["bookmarked","hidden","name","num_unread","num_unread_general"],n=e.changed||{};n_.isChatRoom(e)&&Object.keys(n).filter(e=>t.includes(e)).length&&this.render()},toHTML(){return(e=>{const t=wd("Click to toggle the list of open groupchats");return wc`
<div class="list-container list-container--openrooms ${e.rooms.length?"":"hidden"}">
<a class="list-toggle open-rooms-toggle controlbox-padded" title="${t}" @click=${e.toggleRoomsList}>
<span class="fa ${e.toggle_state===e._converse.OPENED?"fa-caret-down":"fa-caret-right"}"></span> ${wd("Open Groupchats")}</a>
<div class="items-list rooms-list open-rooms-list ${e.collapsed&&"collapsed"}">
${e.rooms.map(t=>e_(Object.assign({room:t},e)))}
</div>
</div>`})({_converse:Vc,addBookmark:e=>this.addBookmark(e),allow_bookmarks:Vc.allow_bookmarks&&Vc.bookmarks,closeRoom:e=>this.closeRoom(e),collapsed:this.list_model.get("toggle-state")!==Vc.OPENED,currently_open:e=>Vc.isUniView()&&!e.get("hidden"),openRoom:e=>this.openRoom(e),removeBookmark:e=>this.removeBookmark(e),rooms:this.model.filter(e=>e.get("type")===Vc.CHATROOMS_TYPE),showRoomDetailsModal:e=>this.showRoomDetailsModal(e),toggleRoomsList:e=>this.toggleRoomsList(e),toggle_state:this.list_model.get("toggle-state")})},insertIntoControlBox(){const e=Vc.chatboxviews.get("controlbox");if(void 0!==e&&!n_.rootContains(Vc.root,this.el)){const t=e.el.querySelector(".list-container--openrooms");t&&t.parentNode.replaceChild(this.el,t)}},showRoomDetailsModal(e){const t=e.target.getAttribute("data-room-jid"),n=Vc.chatboxes.get(t);e.preventDefault(),void 0===n.room_details_modal&&(n.room_details_modal=new bm({model:n})),n.room_details_modal.show(e)},async openRoom(e){e.preventDefault();const t=e.target.textContent,n=e.target.getAttribute("data-room-jid"),r={name:t||t_.unescapeNode(t_.getNodeFromJid(n))||n};await Qc.rooms.open(n,r,!0),Qc.chatviews.get(n).maybeFocus()},closeRoom(e){e.preventDefault();const t=e.target.getAttribute("data-room-name"),n=e.target.getAttribute("data-room-jid");confirm(wd("Are you sure you want to leave the groupchat %1$s?",t))&&Vc.chatboxviews.get(n).close()},removeBookmark:Vc.removeBookmarkViaEvent,addBookmark:Vc.addBookmarkViaEvent,toggleRoomsList(e){e&&e.preventDefault&&e.preventDefault();const t=e.target.matches(".fa")?e.target:e.target.querySelector(".fa");t.classList.contains("fa-caret-down")?n_.slideIn(this.el.querySelector(".open-rooms-list")).then(()=>{this.list_model.save({"toggle-state":Vc.CLOSED}),t.classList.remove("fa-caret-down"),t.classList.add("fa-caret-right")}):n_.slideOut(this.el.querySelector(".open-rooms-list")).then(()=>{this.list_model.save({"toggle-state":Vc.OPENED}),t.classList.remove("fa-caret-right"),t.classList.add("fa-caret-down")})}});const e=function(){Vc.rooms_list_view=new Vc.RoomsListView({model:Vc.chatboxes}),Qc.trigger("roomsListInitialized")};Qc.listen.on("connected",async()=>{Vc.allow_bookmarks?await Qc.waitUntil("bookmarksInitialized"):await Promise.all([Qc.waitUntil("chatBoxesFetched"),Qc.waitUntil("roomsPanelRendered")]),e()}),Qc.listen.on("reconnected",e)}});var r_=n(179),i_=n.n(r_),s_=n(180),o_=n.n(s_),a_=n(181),c_=n.n(a_),l_=n(182),u_=n.n(l_),d_=n(183),h_=n.n(d_);
2021-01-29 23:34:36 +01:00
/**
* @module converse-rosterview
* @copyright 2020, the Converse.js contributors
* @license Mozilla Public License (MPLv2)
*/
2021-03-19 19:26:15 +01:00
const{Strophe:f_}=sl.env,p_=sl.env.utils;sl.plugins.add("converse-rosterview",{dependencies:["converse-roster","converse-modal","converse-chatboxviews"],initialize(){Qc.settings.extend({autocomplete_add_contact:!0,allow_chat_pending_contacts:!0,allow_contact_removal:!0,hide_offline_users:!1,roster_groups:!0,xhr_user_search_url:null}),Qc.promises.add("rosterViewInitialized");const e={dnd:wd("This contact is busy"),online:wd("This contact is online"),offline:wd("This contact is offline"),unavailable:wd("This contact is unavailable"),xa:wd("This contact is away for an extended period"),away:wd("This contact is away")};function t(){Qc.settings.get("authentication")!==Vc.ANONYMOUS&&(Vc.rosterview=new Vc.RosterView({model:Vc.rostergroups}),Vc.rosterview.render(),Qc.trigger("rosterViewInitialized"))}Vc.AddContactModal=Gd.extend({id:"add-contact-modal",events:{"submit form":"addContactFromForm"},initialize(){Gd.prototype.initialize.apply(this,arguments),this.listenTo(this.model,"change",this.render)},toHTML(){const e=Qc.settings.get("xhr_user_search_url")?wd("Contact name"):wd("Optional nickname");return(e=>{const t=wd("name@example.org"),n=wd("Add"),r=wd("Please enter a valid XMPP address"),i=wd("Add a Contact"),s=wd("XMPP Address"),o=wd("Nickname");return wc`
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addContactModalLabel">${i}</h5>
${qd}
</div>
<form class="converse-form add-xmpp-contact">
<div class="modal-body">
<span class="modal-alert"></span>
<div class="form-group add-xmpp-contact__jid">
<label class="clearfix" for="jid">${s}:</label>
<div class="suggestion-box suggestion-box__jid">
<ul class="suggestion-box__results suggestion-box__results--above" hidden=""></ul>
<input type="text" name="jid" ?required=${!e._converse.xhr_user_search_url}
value="${e.jid||""}"
class="form-control suggestion-box__input"
placeholder="${t}"/>
<span class="suggestion-box__additions visually-hidden" role="status" aria-live="assertive" aria-relevant="additions"></span>
</div>
</div>
<div class="form-group add-xmpp-contact__name">
<label class="clearfix" for="name">${o}:</label>
<div class="suggestion-box suggestion-box__name">
<ul class="suggestion-box__results suggestion-box__results--above" hidden=""></ul>
<input type="text" name="name" value="${e.nickname||""}"
class="form-control suggestion-box__input"
placeholder="${o}"/>
<span class="suggestion-box__additions visually-hidden" role="status" aria-live="assertive" aria-relevant="additions"></span>
</div>
</div>
<div class="form-group">
<div class="invalid-feedback">${r}</div>
</div>
<button type="submit" class="btn btn-primary">${n}</button>
</div>
</form>
</div>
</div>
`})(Object.assign(this.model.toJSON(),{_converse:Vc,label_nickname:e}))},afterRender(){"string"==typeof Qc.settings.get("xhr_user_search_url")?this.initXHRAutoComplete():this.initJIDAutoComplete();const e=this.el.querySelector('input[name="jid"]');this.el.addEventListener("shown.bs.modal",()=>e.focus(),!1)},initJIDAutoComplete(){if(!Qc.settings.get("autocomplete_add_contact"))return;const e=this.el.querySelector(".suggestion-box__jid").parentElement;this.jid_auto_complete=new Vc.AutoComplete(e,{data:(e,t)=>`${t.slice(0,t.indexOf("@"))}@${e}`,filter:Vc.FILTER_STARTSWITH,list:[...new Set(Vc.roster.map(e=>f_.getDomainFromJid(e.get("jid"))))]})},initXHRAutoComplete(){if(!Qc.settings.get("autocomplete_add_contact"))return this.initXHRFetch();const e=this.el.querySelector(".suggestion-box__name").parentElement;this.name_auto_complete=new Vc.AutoComplete(e,{auto_evaluate:!1,filter:Vc.FILTER_STARTSWITH,list:[]});const t=new window.XMLHttpRequest;t.onload=()=>{if(t.responseText){const e=t.responseText;this.name_auto_complete.list=JSON.parse(e).map(e=>({label:e.fullname||e.jid,value:e.jid})),this.name_auto_complete.auto_completing=!0,this.name_auto_complete.evaluate()}};const n=this.el.querySelector('input[name="name"]');n.addEventListener("input",Ma(()=>{t.open("GET",`${Qc.settings.get("xhr_user_search_url")}q=${encodeURIComponent(n.value)}`,!0),t.send()},300)),this.name_auto_complete.on("suggestion-box-selectcomplete",e=>{this.el.querySelector('input[name="name"]').value=e.text.label,this.el.querySelector('input[name="jid"]').value=e.text.value})},initXHRFetch(){this.xhr=new window.XMLHttpRequest,this.xhr.onload=()=>{if(this.xhr.responseText){const e=this.xhr.responseText,t=JSON.parse(e).map(e=>({label:e.fullname||e.jid,value:e.jid}));if(1!==t.length){const e=this.el.querySelector(".invalid-feedback");return e.textContent=wd("Sorry, could not find a contact with that name"),void p_.addClass("d-block",e)}const n=t[0].value;if(this.validateSubmission(n)){const e=this.el.querySelector("form"),r=t[0].label;this.afterSubmission(e,n,r)}}}},validateSubmission(e){const t=this.el.querySelector(".invalid-feedback");return!e||qs(e.split("@")).length<2?(p_.addClass("is-invalid",this.el.querySelector('input[name="jid"]')),p_.addClass("d-block",t),!1):Vc.roster.get(f_.getBareJidFromJid(e))?(t.textContent=wd("This contact has already been added"),p_.addClass("d-block",t),!1):(p_.removeClass("d-block",t),!0)},afterSubmission(e,t,n){Vc.roster.addAndSubscribe(t,n),this.model.clear(),this.modal.hide()},addContactFromForm(e){e.preventDefault();const t=new FormData(e.target),n=(t.get("jid")||"").trim();if(!n&&"string"==typeof Qc.settings.get("xhr_user_search_url")){const e=this.el.querySelector('input[name="name"]');return this.xhr.open("GET",`${Qc.settings.get("xhr_user_search_url")}q=${encodeURIComponent(e.value)}`,!0),void this.xhr.send()}this.validateSubmission(n)&&this.afterSubmission(e.target,n,t.get("name"))}}),Vc.RosterFilter=Bs.extend({initialize(){this.set({filter_text:"",filter_type:"contacts",chat_state:"online"})}}),Vc.RosterFilterView=Md.extend({tagName:"span",initialize(){this.listenTo(this.model,"change:filter_type",this.render),this.listenTo(this.model,"change:filter_text",this.render)},toHTML(){return e=Object.assign(this.model.toJSON(),{visible:this.shouldBeVisible(),placeholder:wd("Filter"),title_contact_filter:wd("Filter by contact name"),title_group_filter:wd("Filter by group name"),title_status_filter:wd("Filter by status"),label_any:wd("Any"),label_unread_messages:wd("Unread"),label_online:wd("Online"),label_chatty:wd("Chatty"),label_busy:wd("Busy"),label_away:wd("Away"),label_xa:wd("Extended Away"),label_offline:wd("Offline"),changeChatStateFilter:e=>this.changeChatStateFilter(e),changeTypeFilter:e=>this.changeTypeFilter(e),clearFilter:e=>this.clearFilter(e),liveFilter:e=>this.liveFilter(e),submitFilter:e=>this.submitFilter(e)}),wc`
<form class="controlbox-padded roster-filter-form input-button-group ${e.visible?"fade-in":"hidden"}"
@submit=${e.submitFilter}>
<div class="form-inline flex-nowrap">
<div class="filter-by d-flex flex-nowrap">
<span @click=${e.changeTypeFilter} class="fa fa-user ${"contacts"===e.filter_type?"selected":""}" data-type="contacts" title="${e.title_contact_filter}"></span>
<span @click=${e.changeTypeFilter} class="fa fa-users ${"groups"===e.filter_type?"selected":""}" data-type="groups" title="${e.title_group_filter}"></span>
<span @click=${e.changeTypeFilter} class="fa fa-circle ${"state"===e.filter_type?"selected":""}" data-type="state" title="${e.title_status_filter}"></span>
</div>
<div class="btn-group">
<input .value="${e.filter_text||""}"
@keydown=${e.liveFilter}
class="roster-filter form-control ${"state"===e.filter_type?"hidden":""}"
placeholder="${e.placeholder}"/>
<span class="clear-input fa fa-times ${e.filter_text&&"state"!==e.filter_type?"":"hidden"}"
@click=${e.clearFilter}>
</span>
</div>
<select class="form-control state-type ${"state"!==e.filter_type?"hidden":""}"
@change=${e.changeChatStateFilter}>
<option value="">${e.label_any}</option>
<option ?selected=${"unread_messages"===e.chat_state} value="unread_messages">${e.label_unread_messages}</option>
<option ?selected=${"online"===e.chat_state} value="online">${e.label_online}</option>
<option ?selected=${"chat"===e.chat_state} value="chat">${e.label_chatty}</option>
<option ?selected=${"dnd"===e.chat_state} value="dnd">${e.label_busy}</option>
<option ?selected=${"away"===e.chat_state} value="away">${e.label_away}</option>
<option ?selected=${"xa"===e.chat_state} value="xa">${e.label_xa}</option>
<option ?selected=${"offline"===e.chat_state} value="offline">${e.label_offline}</option>
</select>
</div>
</form>
`;var e},changeChatStateFilter(e){e&&e.preventDefault(),this.model.save({chat_state:this.el.querySelector(".state-type").value})},changeTypeFilter(e){e&&e.preventDefault();const t=e.target.dataset.type;"state"===t?this.model.save({filter_type:t,chat_state:this.el.querySelector(".state-type").value}):this.model.save({filter_type:t,filter_text:this.el.querySelector(".roster-filter").value})},liveFilter:Ma((function(){this.model.save({filter_text:this.el.querySelector(".roster-filter").value})}),250),submitFilter(e){e&&e.preventDefault(),this.liveFilter()},isActive(){return"state"===this.model.get("filter_type")||this.model.get("filter_text")},shouldBeVisible(){return Vc.roster&&Vc.roster.length>=5||this.isActive()},clearFilter(e){e&&e.preventDefault(),this.model.save({filter_text:""})}}),Vc.RosterContactView=Vc.ViewWithAvatar.extend({tagName:"li",className:"list-item d-flex hidden controlbox-padded",events:{"click .accept-xmpp-request":"acceptRequest","click .decline-xmpp-request":"declineRequest","click .open-chat":"openChat","click .remove-xmpp-contact":"removeContact"},async initialize(){await this.model.initialized,this.debouncedRender=Ma(this.render,50),this.listenTo(this.model,"change",this.debouncedRender),this.listenTo(this.model,"destroy",this.remove),this.listenTo(this.model,"highlight",this.highlight),this.listenTo(this.model,"remove",this.remove),this.listenTo(this.model,"vcard:change",this.debouncedRender),this.listenTo(this.model.presence,"change:show",this.debouncedRender),this.render()},render(){if(!this.mayBeShown())return p_.hideElement(this.el),this;const t=this.model.get("ask"),n=this.model.presence.get("show"),r=this.model.get("requesting"),i=this.model.get("subscription"),s=this.model.get("jid");if(["current-xmpp-contact","pending-xmpp-contact","requesting-xmpp-contact"].concat(Object.keys(e)).forEach(e=>p_.removeClass(e,this.el)),this.el.classList.add(n),this.el.setAttribute("data-status",n),this.highlight(),Vc.isUniView()){const e=Vc.chatboxes.get(this.model.get("jid"));e&&(e.get("hidden")?this.el.classList.remove("open"):this.el.classList.add("open"))}if("subscribe"===t||"from"===i){const e=this.model.getDisplayName();this.el.classList.add("pending-xmpp-contact"),this.el.innerHTML=o_()(Object.assign(this.model.toJSON(),{display_name:e,desc_remove:wd("Click to remove %1$s as a contact",e),allow_chat_pending_contacts:Qc.settings.get("allow_chat_pending_contacts")}))}else if(!0===r){const e=this.model.getDisplayName();this.el.classList.add("requesting-xmpp-contact"),this.el.innerHTML=c_()(Object.assign(this.model.toJSON(),{display_name:e,desc_accept:wd("Click to accept the contact request from %1$s",e),desc_decline:wd("Click to decline the contact request from %1$s",e),allow_chat_pending_contacts:Qc.settings.get("allow_chat_pending_contacts")}))}else("both"===i||"to"===i||Vc.rosterview.isSelf(s))&&(this.el.classList.add("current-xmpp-contact"),this.el.classList.remove(Fp(["both","to"],i)[0]),this.el.classList.add(i),this.renderRosterItem(this.model));return this},highlight(){if(Vc.isUniView()){const e=Vc.chatboxes.get(this.model.get("jid"));e&&e.get("hidden")||!e?this.el.classList.remove("open"):this.el.classList.add("open")}},renderRosterItem(t){const n=t.presence.get("show")||"offline";let r;r="online"===n?"fa fa-circle chat-status chat-status--online":"away"===n?"fa fa-circle chat-status chat-status--away":"xa"===n?"far fa-circle chat-status chat-status-xa":"dnd"===n?"fa fa-minus-circle chat-status chat-status--busy":"fa fa-times-circle chat-status chat-status--offline";const i=t.getDisplayName();return this.el.innerHTML=h_()(Object.assign(t.toJSON(),{show:n,display_name:i,status_icon:r,desc_status:e[n],desc_chat:wd("Click to chat with %1$s (XMPP address: %2$s)",i,t.get("jid")),desc_remove:wd("Click to remove %1$s as a contact",i),allow_contact_removal:Qc.settings.get("allow_contact_removal"),num_unread:t.get("num_unread")||0,classes:""})),this.renderAvatar(),this},mayBeShown(){const e=this.model.presence.get("show");return!Qc.settings.get("hide_offline_users")||"offline"!==e||("subscribe"===this.
2021-01-29 23:34:36 +01:00
/**
* @description Converse.js (A browser based XMPP chat client)
* @copyright 2020, The Converse developers
* @license Mozilla Public License (MPLv2)
2021-03-19 19:26:15 +01:00
*/Vc.CustomElement=Kd;const g_=["converse-autocomplete","converse-bookmark-views","converse-chatboxviews","converse-chatview","converse-controlbox","converse-dragresize","converse-fullscreen","converse-mam-views","converse-minimize","converse-modal","converse-muc-views","converse-headlines-view","converse-notification","converse-omemo","converse-profile","converse-push","converse-register","converse-roomslist","converse-rosterview","converse-singleton"];i.a.templateSettings={escape:/\{\{\{([\s\S]+?)\}\}\}/g,evaluate:/\{\[([\s\S]+?)\]\}/g,interpolate:/\{\{([\s\S]+?)\}\}/g,imports:{_:i.a}},sl.env._=i.a;const m_=sl.initialize;sl.initialize=function(e,t){return Array.isArray(e.whitelisted_plugins)?e.whitelisted_plugins=e.whitelisted_plugins.concat(g_):e.whitelisted_plugins=g_,m_(e,t)};t.default=sl}]);
2021-01-29 23:34:36 +01:00
//# sourceMappingURL=converse.min.js.map