function initIframeDraggable(){let e=0;const o=setInterval(()=>{var t=document.getElementById("zopim-widget");e++,t?(clearInterval(o),makeIframeDraggable(t)):20<e&&clearInterval(o)},500)}function makeIframeDraggable(i){let s=!1,a=!1,l,d,r,c;const u=5,m=document.createElement("div");m.id="zopim-drag-handle",m.style.cssText="position:fixed;inset:auto auto 60px 0px;width:100px;height:100px;background:transparent;cursor:move;z-index:1000000;pointer-events:auto;",document.body.appendChild(m);let e=null;m.addEventListener("click",function(t){if(a)return t.preventDefault(),void t.stopPropagation();if(e)return clearTimeout(e),void(e=null);e=setTimeout(()=>{e=null,function(o){if(i.contentWindow)try{var t=i.src;let e="*";if(t)try{var n=new URL(t);e=n.origin}catch(t){e="*"}i.contentWindow.postMessage(o,e)}catch(t){i.contentWindow.postMessage(o,"*")}}({type:"openChat"})},250)}),m.addEventListener("mousedown",t),m.addEventListener("touchstart",t,{passive:!1});function t(t){s=!0,a=!1;t="touchstart"===t.type?t.touches[0]:t;l=t.clientX,d=t.clientY;t=i.getBoundingClientRect();r=t.left,c=t.top,document.addEventListener("mousemove",o),document.addEventListener("touchmove",o,{passive:!1}),document.addEventListener("mouseup",n),document.addEventListener("touchend",n)}function o(t){var e,o,n;s&&(o=(e="touchmove"===t.type?t.touches[0]:t).clientX-l,n=e.clientY-d,e=Math.sqrt(o*o+n*n),!a&&e>u&&(a=!0,m.style.cursor="grabbing"),a&&(t.preventDefault(),t.stopPropagation(),e=r+o,t=c+n,o=window.innerWidth-i.offsetWidth,n=window.innerHeight-i.offsetHeight,o=Math.max(0,Math.min(e,o)),n=Math.max(0,Math.min(t,n)),i.style.left=o+"px",i.style.top=n+"px",i.style.right="auto",i.style.bottom="auto",m.style.left=o+"px",m.style.top=n+"px",m.style.right="auto",m.style.bottom="auto"))}function n(t){s&&(document.removeEventListener("mousemove",o),document.removeEventListener("touchmove",o),document.removeEventListener("mouseup",n),document.removeEventListener("touchend",n),a?t&&(t.preventDefault(),t.stopPropagation()):(i.style.left="0",i.style.top="auto",i.style.right="auto",i.style.bottom="60px",m.style.left="0",m.style.top="auto",m.style.right="auto",m.style.bottom="60px",i.contentWindow.postMessage({type:"openChat"},"*")),s=!1,setTimeout(()=>{a=!1},50),m.style.cursor="move")}i.addEventListener("load",function(){})}!function(){const t=window.location.href;var e=(e=t.includes("?")?t.split("?")[1]:"")?"?"+e:"";const o=document.getElementById("zopim-widget");o&&(o.src=e?"https://secure.cwgmx.com/mobile/zopim.html"+e:"./zopim.html")}(),window.addEventListener("message",function(t){const e=document.getElementById("zopim-widget");if(e&&t.data&&"object"==typeof t.data){var{type:o,isHidden:t}=t.data;if("chatWidgetStatus"===o){const n=document.getElementById("zopim-drag-handle");t?(e.style.width="100px",e.style.height="100px",e.style.bottom="60px",e.style.right="auto",e.style.left="0",n&&(n.style.display="block")):(e.style.width="100%",e.style.height="100vh",e.style.bottom="0",e.style.left="0",e.style.right="auto",e.style.top="auto",n&&(n.style.display="none"))}}}),document.addEventListener("DOMContentLoaded",initIframeDraggable);