if(!document.querySelector("#bitgetChatFrame")){let w=!1;const y={lang:"en",domain:""},C={ar:"ar",de:"de",en:"en","en-GB":"en",es:"es","es-ES":"es",es:"es",fr:"fr",in:"id",id:"id",it:"it",ja:"ja",ko:"ko",ko_KR:"ko",nl:"nl",pl:"pl",pt:"pt","pt-PT":"pt",pt:"pt",ru:"ru",sv:"sv",th:"th",tr:"tr",uk:"uk",uz:"uz",vi:"vi","zh-CN":"zh","zh-TW":"zh-tw","zh-TC":"zh-tw"},v=()=>{if(!window)return!1;if(window.control)return!0;if(!window.control&&!window.webkit)return!1;try{return window.webkit.messageHandlers.transDomainConfig.postMessage(null),!0}catch(t){console.log("error===>",t)}return!1},x=()=>{let t=navigator.userAgent,e=["Android","iPhone","SymbianOS","Windows Phone","rv:1.2.3.4","windows mobile","midp"],o=!0;for(let i=0;i<e.length;i++)if(t.indexOf(e[i])>=0){o=!1;break}return o},E=()=>{const t=document.createElement("style"),e=document.head||document.getElementsByTagName("head")[0];t.type="text/css",t.rel="stylesheet";const o="#ada-button-frame{display:none !important;}";try{t.appendChild(document.createTextNode(o))}catch{t.styleSheet.cssText=o}window.requestAnimationFrame(()=>{e.appendChild(t)})},p=()=>C[a.lang]||y.lang,f=()=>{var t;if(w||a.lang&&a.lang.toLowerCase()==="en-gb"){(t=window==null?void 0:window.adaEmbed)==null||t.getInfo().then(e=>{var o;if(!e.isDrawerOpen){(o=window==null?void 0:window.adaEmbed)==null||o.toggle(!0),n.style.zIndex="-1",n.style.visibility="hidden";try{window.adaEmbed.setLanguage(p())}catch{}}}).catch(e=>{var o,i;console.error("getInfo error: ",e),(o=window.adaEmbed)==null||o.stop(),(i=window.adaEmbed)==null||i.start({handle:I,language:p()})});return}n.style.zIndex="999998",n.style.visibility="visible",n.contentWindow.postMessage({source:"customerChat",action:"openChat",data:a},"*")},L=(t=1e3)=>new Promise(e=>setTimeout(e,t));let I="bitget";const k=()=>{const t=document.createElement("img"),e=document.createElement("div");e.id="bitget-chat-button",e.style.width="44px",e.style.height="44px",e.style.borderRadius="44px",e.style.position="fixed",e.style.right="24px",e.style.bottom="24px",e.style.border="0",e.style.outline="none",e.style.cursor="pointer",e.style.zIndex="10001",e.style.backgroundColor="rgb(0, 240, 255)",e.style.display="flex",e.style.alignItems="center",e.style.justifyContent="center",t.alt="Ada Logo",t.src="https://img.bgstatic.com/image/third/ada.svg",e.appendChild(t),u.append(e);let o=!1,i=0,l=0;const s=function(d){d=d||window.event,d.preventDefault(),o=!1,i=d.clientX-e.offsetLeft,l=d.clientY-e.offsetTop,document.addEventListener("mousemove",h),document.addEventListener("mouseup",g)},h=function(d){o=!0,d=d||window.event,d.preventDefault();let r=d.clientX-i,c=d.clientY-l;e.style.left=r+"px",e.style.top=c+"px",r<0?r=0:r>window.innerWidth-e.offsetWidth&&(r=window.innerWidth-e.offsetWidth),c<0?c=0:c>window.innerHeight-e.offsetHeight&&(c=window.innerHeight-e.offsetHeight),e.style.left=r+"px",e.style.top=c+"px"},g=function(){document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",g)},m=function(){o||f()};e.addEventListener("click",m),a.needDrag&&e.addEventListener("mousedown",s)},a=Object.assign({},y),u=document.createElement("div");u.id="bitgetChatEntry";const n=document.createElement("iframe");n.id="bitgetChatFrame",n.style="position: fixed; right: 0; bottom:0; width: 375px; height: 90%; visibility: hidden; margin-right: 24px; margin-bottom:24px; max-height: 725px; border: none; outline: none; box-shadow: 0px 10px 32px 0px rgba(31, 31, 31, 0.15); border-radius: 16px; background: transparent; z-index: -1;",n.onload=()=>{var t=new Event("bitgetChatReady");window.dispatchEvent(t)};const b=t=>{const[e,o]=t;if(e==="config")return Object.assign(a,o),!0};for(;window.customerChatChip&&window.customerChatChip.length;)b(window.customerChatChip.shift());window.customerChatChip._nativePush=window.customerChatChip.push,window.customerChatChip.push=(...t)=>{const[e,o]=t[0];if(o.open){f();return}if(o.close){n.contentWindow.postMessage({source:"customerChat",action:"closeChat",data:a},"*"),n.style.zIndex="-1",n.style.visibility="hidden";return}if(o.hidden){try{const i=document.getElementById("bitgetChatEntry");i.style.display="none"}catch{}return}if(o.show){n.src||(n.src=a.domain+"/#/ada/?time="+Date.now());try{const i=document.getElementById("bitgetChatEntry");i.style.display="block"}catch{}return}b(...t)?o.position||n.contentWindow.postMessage({source:"customerChat",action:"updateConfig",data:a},"*"):window.customerChatChip._nativePush(...t)},v()||(n.src=a.domain+"/#/ada/?time="+Date.now()),window.customerChatAction=(t,e)=>{n.contentWindow.postMessage({source:"customerChat",action:t,data:e}),t==="showAllService"&&document.getElementById("bitget-chat-button")&&f()};const z=async(t=()=>{},e=1e3,o=3)=>{for(let i=0;i<o;++i){await L(e);try{t()}catch{}}};window.addEventListener("message",t=>{var e;if(typeof t.data=="object"){const{source:o}=t.data;if(o==="customerChat"){const{action:i,data:l}=t.data;if(i==="openAda"&&(n.style.zIndex="-1",n.style.visibility="hidden",(e=window==null?void 0:window.adaEmbed)==null||e.getInfo().then(s=>{var m;if(s.isDrawerOpen)return;(m=window==null?void 0:window.adaEmbed)==null||m.toggle(!0),w=!0;const h=p();z(()=>window.adaEmbed.setLanguage(h),2e3,4)})),i==="close"&&(n.style.zIndex="-1",n.style.visibility="hidden"),i==="toLogin"){const s=l;location.href=`${s}/login?from=${encodeURIComponent(location.pathname)}&source=events`}if(i==="init"){k();const s=x();n.style.width=s?"375px":"100%",n.style.height=s?"90%":"100%",n.style.marginBottom=s?"24px":"0",n.style.marginRight=s?"24px":"0",n.style.maxHeight=s?"725px":"unset",n.style.borderRadius=s?"16px":"0",n.contentWindow.postMessage({source:"customerChat",action:"updateConfig",data:a},"*")}}}},!1),E(),u.append(n),document.body.append(u)}
