<\/div>/g,"
")),console.log("p",o,h),"html"===o&&(u=DOMPurify.sanitize(h),m.log.debug("sanitized HTML clipboard",u),e=E("
"+u+"
"),l=!1,s=h,c=new RegExp("<(/w|w):[A-Za-z]"),s.match(c)&&(l=!0,s=s.replace(c,"")),c=new RegExp("<(/o|o):[A-Za-z]"),s.match(c)&&(l=!0,s=s.replace(c,"")),l&&(e=m.wordFilter(e)),(e=E(e)).contents().each(function(){if(8===this.nodeType)return E(this).remove()}),e.find("a, font, small, time, form, label").replaceWith(function(){return E(this).contents()}),e.find("textarea").each(function(){var e,t;return t=this.outerHTML,c=new RegExp("<"+this.tagName,"i"),e=t.replace(c,"
')).get(0),document.caretPositionFromPoint?(s=document.caretPositionFromPoint(l,d),(i=document.createRange()).setStart(s.offsetNode,s.offset),i.collapse(),i.insertNode(a)):document.caretRangeFromPoint?(i=document.caretRangeFromPoint(l,d)).insertNode(a):console.log("could not find carat")},c.resizeImage(a.src,460,"auto",2,"image/jpeg","auto",t)},o.readAsDataURL(n)})),E(_).on("beforeunload",(e=this,function(){return e.onLeaveTemporary()})),E(_).on("hashchange",(t=this,function(){if(!t.isOpen)return t.idleTimeout.start();t.sessionId&&t.send("chat_session_notice",{session_id:t.sessionId,message:_.location.href})})),this.isFullscreen)return this.input.on({focus:this.onFocus,focusout:this.onFocusOut})},t.prototype.stopPropagation=function(e){return e.stopPropagation()},t.prototype.checkForEnter=function(e){if(!this.inputDisabled&&!e.shiftKey&&13===e.keyCode)return e.preventDefault(),this.sendMessage()},t.prototype.send=function(e,t){return null==t&&(t={}),t.chat_id=this.options.chatId,this.io.send(e,t)},t.prototype.onWebSocketMessage=function(e){var t,n,o;for(t=0,n=e.length;t
new Date((new Date).getTime()-1500)))return this.isTyping=new Date,this.send("chat_session_typing",{session_id:this.sessionId}),this.inactiveTimeout.start()},t.prototype.onSubmit=function(e){return e.preventDefault(),this.sendMessage()},t.prototype.sendMessage=function(){var e,t;if(e=this.input.html())return this.inactiveTimeout.start(),sessionStorage.removeItem("unfinished_message"),t=this.view("message")({message:e,from:"customer",id:this._messageCount++,unreadClass:""}),this.maybeAddTimestamp(),this.el.find(".zammad-chat-message--typing").get(0)?(this.lastAddedType="typing-placeholder",this.el.find(".zammad-chat-message--typing").before(t)):(this.lastAddedType="message--customer",this.el.find(".zammad-chat-body").append(t)),this.input.html(""),this.scrollToBottom(),this.send("chat_session_message",{content:e,id:this._messageCount,session_id:this.sessionId})},t.prototype.receiveMessage=function(e){return this.inactiveTimeout.start(),this.onAgentTypingEnd(),this.maybeAddTimestamp(),this.renderMessage({message:e.message.content,id:e.id,from:"agent"}),this.scrollToBottom({showHint:!0})},t.prototype.renderMessage=function(e){return this.lastAddedType="message--"+e.from,e.unreadClass=document.hidden?" zammad-chat-message--unread":"",this.el.find(".zammad-chat-body").append(this.view("message")(e))},t.prototype.open=function(){var e;if(!this.isOpen)return this.isOpen=!0,this.log.debug("open widget"),this.show(),this.sessionId||this.showLoader(),this.el.addClass("zammad-chat-is-open"),e=this.el.height()-this.el.find(".zammad-chat-header").outerHeight(),this.el.css("bottom",-e),this.sessionId?(this.el.css("bottom",0),this.onOpenAnimationEnd()):(this.el.animate({bottom:0},500,this.onOpenAnimationEnd),this.send("chat_session_init",{url:_.location.href}));this.log.debug("widget already open, block")},t.prototype.onOpenAnimationEnd=function(){var e;return this.idleTimeout.stop(),this.isFullscreen&&this.disableScrollOnRoot(),"function"==typeof(e=this.options).onOpenAnimationEnd?e.onOpenAnimationEnd():void 0},t.prototype.sessionClose=function(){return this.send("chat_session_close",{session_id:this.sessionId}),this.inactiveTimeout.stop(),this.waitingListTimeout.stop(),sessionStorage.removeItem("unfinished_message"),this.onInitialQueueDelayId&&clearTimeout(this.onInitialQueueDelayId),this.setSessionId(void 0)},t.prototype.toggle=function(e){return this.isOpen?this.close(e):this.open(e)},t.prototype.close=function(e){var t;if(this.isOpen)return this.initDelayId&&clearTimeout(this.initDelayId),this.sessionId&&(this.log.debug("session close before widget close"),this.sessionClose()),this.log.debug("close widget"),e&&e.stopPropagation(),this.isFullscreen&&this.enableScrollOnRoot(),t=this.el.height()-this.el.find(".zammad-chat-header").outerHeight(),this.el.animate({bottom:-t},500,this.onCloseAnimationEnd);this.log.debug("can't close widget, it's not open")},t.prototype.onCloseAnimationEnd=function(){var e;return this.el.css("bottom",""),this.el.removeClass("zammad-chat-is-open"),this.showLoader(),this.el.find(".zammad-chat-welcome").removeClass("zammad-chat-is-hidden"),this.el.find(".zammad-chat-agent").addClass("zammad-chat-is-hidden"),this.el.find(".zammad-chat-agent-status").addClass("zammad-chat-is-hidden"),this.isOpen=!1,"function"==typeof(e=this.options).onCloseAnimationEnd&&e.onCloseAnimationEnd(),this.io.reconnect()},t.prototype.onWebSocketClose=function(){if(!this.isOpen)return this.el?(this.el.removeClass("zammad-chat-is-shown"),this.el.removeClass("zammad-chat-is-loaded")):void 0},t.prototype.show=function(){if("offline"!==this.state)return this.el.addClass("zammad-chat-is-loaded"),this.el.addClass("zammad-chat-is-shown")},t.prototype.disableInput=function(){return this.inputDisabled=!0,this.input.prop("contenteditable",!1),this.el.find(".zammad-chat-send").prop("disabled",!0),this.io.close()},t.prototype.enableInput=function(){return this.inputDisabled=!1,this.input.prop("contenteditable",!0),this.el.find(".zammad-chat-send").prop("disabled",!1)},t.prototype.hideModal=function(){return this.el.find(".zammad-chat-modal").html("")},t.prototype.onQueueScreen=function(e){var t,n;if(this.setSessionId(e.session_id),t=function(){return n.onQueue(e),n.waitingListTimeout.start()},!(n=this).initialQueueDelay||this.onInitialQueueDelayId)return this.onInitialQueueDelayId&&clearTimeout(this.onInitialQueueDelayId),t();this.onInitialQueueDelayId=setTimeout(t,this.initialQueueDelay)},t.prototype.onQueue=function(e){return this.log.notice("onQueue",e.position),this.inQueue=!0,this.el.find(".zammad-chat-modal").html(this.view("waiting")({position:e.position}))},t.prototype.onAgentTypingStart=function(){if(this.stopTypingId&&clearTimeout(this.stopTypingId),this.stopTypingId=setTimeout(this.onAgentTypingEnd,3e3),!this.el.find(".zammad-chat-message--typing").get(0)&&(this.maybeAddTimestamp(),this.el.find(".zammad-chat-body").append(this.view("typingIndicator")()),this.isVisible(this.el.find(".zammad-chat-message--typing"),!0)))return this.scrollToBottom()},t.prototype.onAgentTypingEnd=function(){return this.el.find(".zammad-chat-message--typing").remove()},t.prototype.onLeaveTemporary=function(){if(this.sessionId)return this.send("chat_session_leave_temporary",{session_id:this.sessionId})},t.prototype.maybeAddTimestamp=function(){var e,t,n;if(n=Date.now(),!this.lastTimestamp||n-this.lastTimestamp>6e4*this.showTimeEveryXMinutes)return e=this.T("Today"),t=(new Date).toTimeString().substr(0,5),"timestamp"===this.lastAddedType?(this.updateLastTimestamp(e,t),this.lastTimestamp=n):(this.el.find(".zammad-chat-body").append(this.view("timestamp")({label:e,time:t})),this.lastTimestamp=n,this.lastAddedType="timestamp",this.scrollToBottom())},t.prototype.updateLastTimestamp=function(e,t){if(this.el)return this.el.find(".zammad-chat-body").find(".zammad-chat-timestamp").last().replaceWith(this.view("timestamp")({label:e,time:t}))},t.prototype.addStatus=function(e){if(this.el)return this.maybeAddTimestamp(),this.el.find(".zammad-chat-body").append(this.view("status")({status:e})),this.scrollToBottom()},t.prototype.detectScrolledtoBottom=function(){var e;if(e=this.el.find(".zammad-chat-body").scrollTop()+this.el.find(".zammad-chat-body").outerHeight(),this.scrolledToBottom=Math.abs(e-this.el.find(".zammad-chat-body").prop("scrollHeight"))<=this.scrollSnapTolerance,this.scrolledToBottom)return this.el.find(".zammad-scroll-hint").addClass("is-hidden")},t.prototype.showScrollHint=function(){return this.el.find(".zammad-scroll-hint").removeClass("is-hidden"),this.el.find(".zammad-chat-body").scrollTop(this.el.find(".zammad-chat-body").scrollTop()+this.el.find(".zammad-scroll-hint").outerHeight())},t.prototype.onScrollHintClick=function(){return this.el.find(".zammad-chat-body").animate({scrollTop:this.el.find(".zammad-chat-body").prop("scrollHeight")},300)},t.prototype.scrollToBottom=function(e){var t;return t=(null!=e?e:{showHint:!1}).showHint,this.scrolledToBottom?this.el.find(".zammad-chat-body").scrollTop(E(".zammad-chat-body").prop("scrollHeight")):t?this.showScrollHint():void 0},t.prototype.destroy=function(e){return null==e&&(e={}),this.log.debug("destroy widget",e),this.setAgentOnlineState("offline"),e.remove&&this.el&&(this.el.remove(),E("."+this.options.buttonClass).hide()),this.waitingListTimeout&&this.waitingListTimeout.stop(),this.inactiveTimeout&&this.inactiveTimeout.stop(),this.idleTimeout&&this.idleTimeout.stop(),this.io.close()},t.prototype.reconnect=function(){return this.log.notice("reconnecting"),this.disableInput(),this.lastAddedType="status",this.setAgentOnlineState("connecting"),this.addStatus(this.T("Connection lost"))},t.prototype.onConnectionReestablished=function(){var e;return this.lastAddedType="status",this.setAgentOnlineState("online"),this.addStatus(this.T("Connection re-established")),"function"==typeof(e=this.options).onConnectionReestablished?e.onConnectionReestablished():void 0},t.prototype.onSessionClosed=function(e){var t;return this.addStatus(this.T("Chat closed by %s",e.realname)),this.disableInput(),this.setAgentOnlineState("offline"),this.inactiveTimeout.stop(),"function"==typeof(t=this.options).onSessionClosed?t.onSessionClosed(e):void 0},t.prototype.setSessionId=function(e){return void 0===(this.sessionId=e)?sessionStorage.removeItem("sessionId"):sessionStorage.setItem("sessionId",e)},t.prototype.onConnectionEstablished=function(e){var t;return this.onInitialQueueDelayId&&clearTimeout(this.onInitialQueueDelayId),this.inQueue=!1,e.agent&&(this.agent=e.agent),e.session_id&&this.setSessionId(e.session_id),this.el.find(".zammad-chat-body").html(""),this.el.find(".zammad-chat-agent").html(this.view("agent")({agent:this.agent})),this.enableInput(),this.hideModal(),this.el.find(".zammad-chat-welcome").addClass("zammad-chat-is-hidden"),this.el.find(".zammad-chat-agent").removeClass("zammad-chat-is-hidden"),this.el.find(".zammad-chat-agent-status").removeClass("zammad-chat-is-hidden"),this.isFullscreen||this.input.trigger("focus"),this.setAgentOnlineState("online"),this.waitingListTimeout.stop(),this.idleTimeout.stop(),this.inactiveTimeout.start(),"function"==typeof(t=this.options).onConnectionEstablished?t.onConnectionEstablished(e):void 0},t.prototype.showCustomerTimeout=function(){var e;return this.el.find(".zammad-chat-modal").html(this.view("customer_timeout")({agent:this.agent.name,delay:this.options.inactiveTimeout})),e=function(){return location.reload()},this.el.find(".js-restart").on("click",e),this.sessionClose()},t.prototype.showWaitingListTimeout=function(){var e;return this.el.find(".zammad-chat-modal").html(this.view("waiting_list_timeout")({delay:this.options.watingListTimeout})),e=function(){return location.reload()},this.el.find(".js-restart").on("click",e),this.sessionClose()},t.prototype.showLoader=function(){return this.el.find(".zammad-chat-modal").html(this.view("loader")())},t.prototype.setAgentOnlineState=function(e){var t;if(this.state=e,this.el)return t=e.charAt(0).toUpperCase()+e.slice(1),this.el.find(".zammad-chat-agent-status").attr("data-status",e).text(this.T(t))},t.prototype.detectHost=function(){var e;return e="ws://","https"===r&&(e="wss://"),this.options.host=""+e+a+"/ws"},t.prototype.loadCss=function(){var e,t,n;if(this.options.cssAutoload)return(n=this.options.cssUrl)||(n=this.options.host.replace(/^wss/i,"https").replace(/^ws/i,"http").replace(/\/ws$/i,""),n+="/assets/chat/chat.css"),this.log.debug("load css from '"+n+"'"),t="@import url('"+n+"');",(e=document.createElement("link")).onload=this.onCssLoaded,e.rel="stylesheet",e.href="data:text/css,"+escape(t),document.getElementsByTagName("head")[0].appendChild(e)},t.prototype.onCssLoaded=function(){var e;return this.cssLoaded=!0,this.socketReady&&this.onReady(),"function"==typeof(e=this.options).onCssLoaded?e.onCssLoaded():void 0},t.prototype.startTimeoutObservers=function(){var e,t,n;return this.idleTimeout=new s({logPrefix:"idleTimeout",debug:this.options.debug,timeout:this.options.idleTimeout,timeoutIntervallCheck:this.options.idleTimeoutIntervallCheck,callback:(e=this,function(){return e.log.debug("Idle timeout reached, hide widget",new Date),e.destroy({remove:!0})})}),this.inactiveTimeout=new s({logPrefix:"inactiveTimeout",debug:this.options.debug,timeout:this.options.inactiveTimeout,timeoutIntervallCheck:this.options.inactiveTimeoutIntervallCheck,callback:(t=this,function(){return t.log.debug("Inactive timeout reached, show timeout screen.",new Date),t.showCustomerTimeout(),t.destroy({remove:!1})})}),this.waitingListTimeout=new s({logPrefix:"waitingListTimeout",debug:this.options.debug,timeout:this.options.waitingListTimeout,timeoutIntervallCheck:this.options.waitingListTimeoutIntervallCheck,callback:(n=this,function(){return n.log.debug("Waiting list timeout reached, show timeout screen.",new Date),n.showWaitingListTimeout(),n.destroy({remove:!1})})})},t.prototype.disableScrollOnRoot=function(){return this.rootScrollOffset=this.scrollRoot.scrollTop(),this.scrollRoot.css({overflow:"hidden",position:"fixed"})},t.prototype.enableScrollOnRoot=function(){return this.scrollRoot.scrollTop(this.rootScrollOffset),this.scrollRoot.css({overflow:"",position:""})},t.prototype.isVisible=function(e,t,n,o){var s,i,a,r,l,d,c,u,h,m,p,g,f,y,v,b,w,T,C,S,k,z,A,x,O,I;if(!(e.length<1))if(i=E(_),T=(s=1/gi,"")).replace(/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,"")).replace(/<(\/?)s>/gi,"<$1strike>")).replace(/ /gi," "),e.html(t),E("p",e).each(function(){var e,t;if(t=E(this).attr("style"),e=/mso-list:\w+ \w+([0-9]+)/.exec(t))return E(this).data("_listLevel",parseInt(e[1],10))}),c=0,u=null,E("p",e).each(function(){var e,t,n,o,s,i,a,r,l,d;if(void 0!==(e=E(this).data("_listLevel"))){if(d=E(this).text(),o="",/^\s*\w+\./.test(d)&&(o=(s=/([0-9])\./.exec(d))?null!=(i=1<(l=parseInt(s[1],10)))?i:'
':"
"}:"
"),c"+E(this).html()+""),E(this).remove(),c=e}return c=0}),E("[style]",e).removeAttr("style"),E("[align]",e).removeAttr("align"),E("span",e).replaceWith(function(){return E(this).contents()}),E("span:empty",e).remove(),E("[class^='Mso']",e).removeAttr("class"),E("p:empty",e).remove(),e},t.prototype.removeAttribute=function(e){var t,n,o,s,i;if(e){for(t=E(e),o=0,s=(i=e.attributes).length;o/g,">").replace(/"/g,""")}),function(){(function(){t.push('")}).call(this)}.call(e),e.safe=o,e.escape=s,t.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.customer_timeout=function(e){e||(e={});var t=[],n=e.safe,o=e.escape;return e.safe=function(e){if(e&&e.ecoSafe)return e;void 0!==e&&null!=e||(e="");var t=new String(e);return t.ecoSafe=!0,t},o||(o=e.escape=function(e){return(""+e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){var e;t.push('\n '),this.agent?(t.push("\n "),t.push(this.T("Since you didn't respond in the last %s minutes your conversation with
%s got closed.",this.delay,this.agent))):(t.push("\n "),t.push(this.T("Since you didn't respond in the last %s minutes your conversation got closed.",this.delay))),t.push("\n "),t.push('\n
\n
"),t.push(this.T("Start new conversation")),t.push("
\n
")}).call(this)}.call(e),e.safe=n,e.escape=o,t.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.loader=function(e){e||(e={});var t=[],n=e.safe,o=e.escape;return e.safe=function(e){if(e&&e.ecoSafe)return e;void 0!==e&&null!=e||(e="");var t=new String(e);return t.ecoSafe=!0,t},o||(o=e.escape=function(e){return(""+e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){t.push('\n \n \n \n\n'),t.push(this.T("Connecting")),t.push("")}).call(this)}.call(e),e.safe=n,e.escape=o,t.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.message=function(e){e||(e={});var t=[],n=function(e){return e&&e.ecoSafe?e:void 0!==e&&null!=e?s(e):""},o=e.safe,s=e.escape;return e.safe=function(e){if(e&&e.ecoSafe)return e;void 0!==e&&null!=e||(e="");var t=new String(e);return t.ecoSafe=!0,t},s||(s=e.escape=function(e){return(""+e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){t.push('\n "),t.push(this.message),t.push("\n
")}).call(this)}.call(e),e.safe=o,e.escape=s,t.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.status=function(e){e||(e={});var t=[],n=e.safe,o=e.escape;return e.safe=function(e){if(e&&e.ecoSafe)return e;void 0!==e&&null!=e||(e="");var t=new String(e);return t.ecoSafe=!0,t},o||(o=e.escape=function(e){return(""+e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){t.push('\n
\n '),t.push(this.status),t.push("\n
\n
")}).call(this)}.call(e),e.safe=n,e.escape=o,t.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.timestamp=function(e){e||(e={});var t=[],n=function(e){return e&&e.ecoSafe?e:void 0!==e&&null!=e?s(e):""},o=e.safe,s=e.escape;return e.safe=function(e){if(e&&e.ecoSafe)return e;void 0!==e&&null!=e||(e="");var t=new String(e);return t.ecoSafe=!0,t},s||(s=e.escape=function(e){return(""+e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){t.push(''),t.push(n(this.label)),t.push(" "),t.push(n(this.time)),t.push("
")}).call(this)}.call(e),e.safe=o,e.escape=s,t.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.typingIndicator=function(e){e||(e={});var t=[],n=e.safe,o=e.escape;return e.safe=function(e){if(e&&e.ecoSafe)return e;void 0!==e&&null!=e||(e="");var t=new String(e);return t.ecoSafe=!0,t},o||(o=e.escape=function(e){return(""+e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){t.push('\n \n \n \n \n \n \n \n
')}).call(this)}.call(e),e.safe=n,e.escape=o,t.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.waiting=function(e){e||(e={});var t=[],n=e.safe,o=e.escape;return e.safe=function(e){if(e&&e.ecoSafe)return e;void 0!==e&&null!=e||(e="");var t=new String(e);return t.ecoSafe=!0,t},o||(o=e.escape=function(e){return(""+e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){t.push('\n \n \n \n \n \n '),t.push(this.T("All colleagues are busy.")),t.push("
\n "),t.push(this.T("You are on waiting list position %s.",this.position)),t.push("\n
")}).call(this)}.call(e),e.safe=n,e.escape=o,t.join("")},window.zammadChatTemplates||(window.zammadChatTemplates={}),window.zammadChatTemplates.waiting_list_timeout=function(e){e||(e={});var t=[],n=e.safe,o=e.escape;return e.safe=function(e){if(e&&e.ecoSafe)return e;void 0!==e&&null!=e||(e="");var t=new String(e);return t.ecoSafe=!0,t},o||(o=e.escape=function(e){return(""+e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}),function(){(function(){var e;t.push('\n '),t.push(this.T("We are sorry, it takes longer as expected to get an empty slot. Please try again later or send us an email. Thank you!")),t.push('\n
\n
"),t.push(this.T("Start new conversation")),t.push("
\n
")}).call(this)}.call(e),e.safe=n,e.escape=o,t.join("")};