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