!function(){"use strict";const t=window?.bit_assist_?.api?.base||"http://bit-assist.click/wp-json/bit-assist/v1",i=window?.bit_assist_?.api?.base?`${bit_assist_.api.base}/iframe`:"http://localhost:5000",e=new URL(i).origin,o=window?.bit_assist_?.api?.separator||"?",n="http:"===window.location.protocol?"i":"s",a="localhost"===window.location.hostname?window.location.host:window.location.hostname,s=window.location.href,d=document.documentElement.offsetWidth,r=window.innerHeight;let c="100px",h="100px",l=0;const w=`\n\t#bit-assist-widget-container{--ba-top:auto;--ba-left:auto;--ba-bottom:10;--ba-right:10;position:fixed;z-index:2147483646;bottom:0;right:0;width:${h};height:${c};max-width:100%}\n\t#bit-assist-widget-container.bottom-right{left:var(--ba-left);right:var(--ba-right);top:var(--ba-top);bottom:var(--ba-bottom)}\n\t#bit-assist-widget-container.bottom-left{left:var(--ba-left);right:var(--ba-right);top:var(--ba-top);bottom:var(--ba-bottom)}\n\t#bit-assist-widget-container.top-right{left:var(--ba-left);right:var(--ba-right);top:var(--ba-top);bottom:var(--ba-bottom)}\n\t#bit-assist-widget-container.top-left{left:var(--ba-left);right:var(--ba-right);top:var(--ba-top);bottom:var(--ba-bottom)}\n\t#bit-assist-widget-iframe{width:100%;height:100%;border:none;}\n\t.bit-assist-hide{visibility:hidden;pointer-events:none}\n\t`,p=document.createElement("style");p.appendChild(document.createTextNode(w));const f=document.createElement("div");f.id="bit-assist-widget-container",L();const b=document.createElement("iframe");function u(t,i=!1){const e=window.scrollY,o=document.body.offsetHeight,n=window.innerHeight,a=Math.round(e/(o-n)*100);if(!i)return a;!l&&a>=i?(l=1,m(a)):l&&a<i&&(l=0,m(a))}function m(t){b.contentWindow.postMessage({action:"scrollPercent",scrollPercent:t},e)}function g(t,i){h=t+"px",c=i+"px",Object.assign(f.style,{width:h,height:c})}b.title="wp-bit-assist",b.src=`${i}${o}clientDomain=${n}-protocol-bit-assist-${a}`,b.id="bit-assist-widget-iframe",b.setAttribute("allowfullscreen",""),b.setAttribute("scrolling","no"),f.appendChild(b),document.body.append(p,f),document.addEventListener("click",(t=>{f.classList.contains("bit-assist-open")&&!t.target.closest("#bit-assist-widget-container")&&b.contentWindow.postMessage({action:"clickOutside"},e)})),window.addEventListener("message",(i=>{if(i.origin!==e)return;const{action:o}=i.data;if("getClientInfo"===o){const i=u();b.contentWindow.postMessage({action:"windowLoaded",url:s,winWidth:d,winHeight:r,scrollPercent:i,apiEndPoint:t},e)}else if("widgetLoaded"===o){const{height:t,width:e,position:o,top:n,bottom:a,left:s,right:d,pageScroll:r}=i.data;!function(t,i,e,o,n){t.indexOf("top")>-1&&f.style.setProperty("--ba-top",i+"px");t.indexOf("bottom")>-1&&f.style.setProperty("--ba-bottom",e+"px");t.indexOf("left")>-1&&f.style.setProperty("--ba-left",o+"px");t.indexOf("right")>-1&&f.style.setProperty("--ba-right",n+"px")}(o,n,a,s,d),f.classList.remove("bit-assist-hide"),f.classList.add(o),g(e,t),r>0&&window.addEventListener("scroll",(t=>u(0,r)))}else if("widgetOpen"===o){C()&&1==Tawk_API?.isChatMaximized()&&Tawk_API?.minimize();const{isWidgetOpen:t}=i.data;f.classList.toggle("bit-assist-open",t)}else if("removeWidget"===o)f.remove(),p.remove();else if("resetWidgetSize"===o){const{height:t,width:e}=i.data;g(e,t)}else if("chatWidgetClick"===o){const{chatWidgetName:t}=i.data;!function(t){x(),"tawk"===t&&function(){if(!v)return W("Tawk"),null;try{Tawk_API=Tawk_API||{},Tawk_API.showWidget(),Tawk_API.toggle(),L()}catch(t){W("Tawk"),T()}}();"crisp"===t&&function(){if(!y)return W("Crisp"),null;try{const t=window.$crisp||{};t.push(["do","chat:show"]),t.push(["do","chat:toggle"]),L()}catch{W("Crisp"),T()}}();"intercom"===t&&function(){if(!I)return W("Intercom"),null;try{Intercom=Intercom||{},Intercom("show"),L()}catch(t){W("Intercom"),T()}}();"tidio"===t&&function(){if(!A)return W("Tidio"),null;try{tidioChatApi=tidioChatApi||{},tidioChatApi.open(),tidioChatApi.show(),L()}catch(t){W("Tawk"),T()}}()}(t)}else if("bitAssistChannelClick"===o){const{channelInfo:t}=i.data;window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"bitAssistChannel",...t})}})),window.addEventListener("load",(()=>{C()&&(Tawk_API=Tawk_API||{},Tawk_API.onLoad=function(){v=!0,Tawk_API.hideWidget()},Tawk_API.onChatMinimized=function(){Tawk_API.hideWidget(),T()}),_()&&function(){const t=window.$crisp||{};y=!0,t.push(["do","chat:hide"]),t.push(["on","chat:closed",function(){t.push(["do","chat:hide"]),T()}])}(),k()&&(I=!0,Intercom("update",{hide_default_launcher:!0}),Intercom("onShow",(function(){L()})),Intercom("onHide",(function(){T()}))),P()&&(tidioChatApi.hide(),tidioChatApi.on("ready",(function(){A=!0,tidioChatApi.hide()})),tidioChatApi.on("close",(function(){T(),tidioChatApi.hide()})))}));var v=!1,A=!1,y=!1,I=!1;function C(){return"undefined"!=typeof Tawk_API}function _(){return"undefined"!=typeof $crisp}function k(){return"undefined"!=typeof Intercom}function P(){return"undefined"!=typeof tidioChatApi}function T(){f.classList.remove("bit-assist-hide"),x()}function x(){C()&&Tawk_API?.minimize(),void 0!==window.FB&&FB?.CustomerChat?.hide(),_()&&$crisp?.push(["do","chat:hide"]),k()&&Intercom("hide"),P()&&tidioChatApi.hide()}function L(){f.classList.add("bit-assist-hide")}function W(t){return alert(`Sorry, ${t} is not loaded yet!`)}}();
