(()=>{var t=null,e=null,n=null,l="chatling-chat-iframe",i=null,o=null,r=null,a=null,c="chatling-open-chat-icon",u="chatling-close-chat-icon",s=null;null==s&&(s="1.2.8");var d=null,p=640,h=null,y=365,f=!1,v=!1,m=null,g=0,x=null,b=null;function w(){return null!=t&&("1"==t||"1.0"==t)}function _(){return null!=t&&("2"==t||"2.0"==t)}function C(){return S("chtl_cus")}function k(){return S("chtl_chats")}function A(){return S("chtl_opened")}function E(){return S("chtl_aghmc")}function S(t){return null==t||0==t.length||0==(t=t.trim()).length?null:(null==e&&(e=J()),null!=e?"".concat(t,"_").concat(e):null)}function I(t){if(null!=t)try{var e=C();if(null==e)return;for(var n in t)null===t[n]&&delete t[n];var l=JSON.stringify(t);O(e,btoa(l),y)}catch(t){}}function N(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"*";try{null!=n&&n.contentWindow.postMessage(t,e)}catch(t){}}function T(){try{return window.innerWidth}catch(t){return null}}function B(){var t=T();return null!==t&&t
3&&void 0!==arguments[3]?arguments[3]:"Strict",i="";if(n){var o=new Date;o.setTime(o.getTime()+24*n*60*60*1e3),i=";expires="+o.toUTCString()}var r=null;try{null!=(r=window.location.hostname)&&0!=r.length||(r=location.hostname)}catch(t){}null!=r&&r.length>0&&(document.cookie=t+"="+(e||"")+i+";path=/;domain=.".concat(r,";SameSite=").concat(l))}function R(t){if(null==t||0==t.length)return null;if(0==(t=t.trim()).length)return null;for(var e=t+"=",n=decodeURIComponent(document.cookie).split(";"),l=0;l0&&N({event_id:"chtl_conversation_history",lcg:b,messages:x}),_()){var p,y=null;if(null!=h)y=null===(p=h)||void 0===p?void 0:p.uuid;N({event_id:"chtl_chatbot_init",lcg:b,cuid:y})}}}else"chtl_chat_cleared"==i?function(){var t=k();if(null==t)return;e=t,document.cookie=e+"=; Max-Age=-99999999;";var e}():"chtl_chatbot_loaded"==i&&H()}}catch(t){}})),function(){if(!(e=J()))return;try{var s=function(){try{var t=M();return null==t||0==t.length?null:t[t.length-1]}catch(t){return null}}();null!=s&&(b=s.chat_gid)}catch(t){}var d=null;null==h&&(h=function(){try{var t=C();if(null==t)return;var e=R(t);if(null==e)return;var n=atob(e);return JSON.parse(n)}catch(t){return null}}());try{var p;if(null!=h)d=null===(p=h)||void 0===p?void 0:p.uuid}catch(t){}var y={widget_id:e,lcg:b,cuid:d};fetch("https://api.chatling.ai/public/embed/chatbot/setup",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(y)}).then((function(s){try{s.json().then((function(s){if(null!=s&&null!=(null==s?void 0:s.success)&&0!=s.success){var p=null==s?void 0:s.data;if(null!=p){try{var y=null==p?void 0:p.chat;if(null!=y){var b=null==y?void 0:y.messages;null!=b&&b.length>0&&(x=b)}}catch(t){}if(p,null==d){var C=null==p?void 0:p.cuid;null!=C&&C.length>0&&(null==h?h={uuid:C}:h.uuid=C,I(h))}t=null==p?void 0:p.version,(w()||_())&&(function(t){var e=t.chat_icon.url,n=t.position.value,l=t.position.x,s=t.position.y;if(null!=l)try{l=parseInt(l)}catch(t){}if(null!=s)try{s=parseInt(s)}catch(t){}var d=t.primary_color,p=t.chat_icon.border_radius,h=t.chat_icon.size,y=t.chat_icon.color;(i=document.createElement("div")).style.position="fixed",i.style.zIndex="9999999","bl"==n?(i.style.bottom="".concat(s,"px"),i.style.left="".concat(l,"px")):"tl"==n?(i.style.top="".concat(s,"px"),i.style.left="".concat(l,"px")):"tr"==n?(i.style.top="".concat(s,"px"),i.style.right="".concat(l,"px")):(i.style.bottom="".concat(s,"px"),i.style.right="".concat(l,"px"));(o=document.createElement("div")).setAttribute("id",c),o.style.display="flex",o.style.justifyContent="center",o.style.alignItems="center",o.style.cursor="pointer",o.style.borderRadius="".concat(p);var f=document.createElement("div");f.style.height="".concat(h,"px"),f.style.width="".concat(h,"px"),f.style.cursor="pointer",f.style.borderRadius="".concat(p);var v=f.cloneNode(!0);if(null==e){o.style.backgroundColor="".concat(d),f.style.display="flex",f.style.justifyContent="center",f.style.alignItems="center",f.style.backgroundColor="".concat(d);var m=document.documentElement;(m=document.createElementNS("http://www.w3.org/2000/svg","svg")).setAttribute("style","transition: width ease-in-out 0.05s; width: ".concat(h/2,"px; height: ").concat(h/2,"px;")),m.setAttribute("viewBox","0 0 820 760"),m.setAttribute("fill","none");var g=document.createElementNS("http://www.w3.org/2000/svg","path");g.setAttribute("d","M400 0C179.44 0 9.84565e-05 161.493 9.84565e-05 360C9.84565e-05 429.4 21.9601 496.613 63.5734 554.72C55.6934 641.88 34.5734 706.587 3.90677 737.24C-0.146568 741.293 -1.1599 747.493 1.4001 752.613C3.6801 757.187 8.33343 760 13.3334 760C13.9468 760 14.5734 759.96 15.2001 759.867C20.6001 759.107 146.04 741.04 236.76 688.693C288.293 709.48 343.173 720 400 720C620.56 720 800 558.507 800 360C800 161.493 620.56 0 400 0Z"),g.setAttribute("fill",y),m.appendChild(g),f.appendChild(m)}else f.style.backgroundImage="url(".concat(e,")"),f.style.backgroundSize="cover",f.style.backgroundRepeat="no-repeat",f.style.backgroundPosition="center";(r=o.cloneNode(!0)).setAttribute("id",u),v.style.display="flex",v.style.justifyContent="center",v.style.alignItems="center",v.style.backgroundColor="".concat(d);var x=document.documentElement;(x=document.createElementNS("http://www.w3.org/2000/svg","svg")).setAttribute("style","width: ".concat(.33*h,"px; height: ").concat(.33*h,"px;")),x.setAttribute("viewBox","0 0 537 537"),x.setAttribute("fill","none");var b=document.createElementNS("http://www.w3.org/2000/svg","path");b.setAttribute("d","M41.1666 495.834L496.167 40.8335"),b.setAttribute("stroke",y),b.setAttribute("stroke-width","81.6667"),b.setAttribute("stroke-linecap","round"),b.setAttribute("stroke-linejoin","round"),x.appendChild(b);var w=document.createElementNS("http://www.w3.org/2000/svg","path");w.setAttribute("d","M496.167 495.834L41.1666 40.8335"),w.setAttribute("stroke",y),w.setAttribute("stroke-width","81.6667"),w.setAttribute("stroke-linecap","round"),w.setAttribute("stroke-linejoin","round"),x.appendChild(w),v.appendChild(x),r.appendChild(v),o.style.display="flex",r.style.display="none",o.appendChild(f),i.appendChild(o),i.appendChild(r),document.body.appendChild(i),function(t){try{var e=null==t?void 0:t.attention_grabber;if(null==e)return;var n,l,o=null==e?void 0:e.delay,r=!1;if(B())r=null==e||null===(n=e.mobile)||void 0===n?void 0:n.enabled;else r=null==e||null===(l=e.desktop)||void 0===l?void 0:l.enabled;if(!0!==r)return;var c=null==e?void 0:e.messages;if(null==c||0==c.length)return;if(0==(c=c.filter((function(t){return null!=t&&(null!=(t=t.trim())&&0!=t.length)}))).length)return;var u=350,s=T();(a=document.createElement("div")).style.position="absolute";var d=0,p=10,h=t.position.x,y=t.position.y;if(null!=h)try{h=parseInt(h)}catch(t){}if(null!=y)try{y=parseInt(y)}catch(t){}var f=t.chat_icon.size;null!=y&&(d=f);var v=t.position.value,m=d+p,g=0,x=document.createElement("div");x.style.position="absolute",x.style.top="-25px",x.style.zIndex="1",x.style.cursor="pointer",x.style.background="#ffffff",x.style.borderRadius="999px",x.style.padding="5px",x.style.border="1px solid #e7ebf0",x.style.display="flex",x.style.alignItems="center",x.style.justifyContent="center",x.setAttribute("id","cthl-hovering-message-close-btn");var b=document.createElementNS("http://www.w3.org/2000/svg","svg");b.setAttribute("style","width: 8px; height: 8px;"),b.setAttribute("viewBox","0 0 16 16"),b.setAttribute("fill","none");var w=document.createElementNS("http://www.w3.org/2000/svg","path");w.setAttribute("d","M2 14L14 2M2 2L14 14"),w.setAttribute("stroke","#aeaeae"),w.setAttribute("stroke-width","3"),w.setAttribute("stroke-linecap","round"),w.setAttribute("stroke-linejoin","round"),b.appendChild(w),x.appendChild(b),"bl"==v?(a.style.bottom="".concat(m,"px"),a.style.left="".concat(g,"px"),x.style.left="0px"):"tl"==v?(a.style.top="".concat(m,"px"),a.style.left="".concat(g,"px"),x.style.left="0px"):"tr"==v?(a.style.top="".concat(m,"px"),a.style.right="".concat(g,"px"),x.style.right="0px"):(a.style.bottom="".concat(m,"px"),a.style.right="".concat(g,"px"),x.style.right="0px"),a.style.display="none",null!=s&&B()?(u>s&&(u=s-25),a.style.width="".concat(u,"px")):a.style.width="".concat(u,"px"),a.appendChild(x);var _=document.createElement("div");_.style.cursor="pointer";var C=0;c.forEach((function(t){var e=document.createElement("div");e.style.padding="10px 15px",e.style.position="relative",e.style.borderRadius="5px",e.style.marginTop=0==C?"0px":"7px",e.style.backgroundColor="#ffffff",e.style.fontSize="14.5px",e.style.color="#000000",e.style.border="1px solid #e6e9ee",e.style.boxShadow="-2px 0px 10px rgba(0, 0, 0, 0.05)",e.style.mozBoxShadow="-2px 0px 10px rgba(0, 0, 0, 0.05)",e.innerHTML=t,C++,_.appendChild(e)})),_.addEventListener("click",(function(){j()})),i.appendChild(a),a.appendChild(_),x.addEventListener("click",(function(){z("hide")})),(null==o||o<0)&&(o=0),setTimeout((function(){z("show")}),1e3*o)}catch(t){}}(t),f.addEventListener("click",(function(){j()})),v.addEventListener("click",(function(){L()}))}(p),function(t){var i=t.position.value,o=t.position.x,r=t.position.y;if(null!=o)try{o=parseInt(o)}catch(t){}if(null!=r)try{r=parseInt(r)}catch(t){}var a=t.chat_icon.size,c=20,u=t.chat_interface.width,s=u,d=700,p=d,h=r+a+c;null!=r&&(p=window.innerHeight-h-50)>d&&(p=d);if(n=document.createElement("iframe"),w())n.src="https://embed.chatling.ai/widgets/".concat(e);else{if(!_())return;n.src="https://embed.chatling.ai/w2/".concat(e)}n.style.display="none",n.style.border="none",n.style.position="fixed","bl"==i?(n.style.bottom="".concat(h,"px"),n.style.left="".concat(o,"px")):"tl"==i?(n.style.top="".concat(h,"px"),n.style.left="".concat(o,"px")):"tr"==i?(n.style.top="".concat(h,"px"),n.style.right="".concat(o,"px")):(n.style.bottom="".concat(h,"px"),n.style.right="".concat(o,"px"));n.style.height="80vh",n.style.minHeight="80px",n.style.maxHeight="".concat(p,"px"),n.style.zIndex="9999999",n.style.overflow="hidden",n.style.width="100%",n.style.maxWidth="".concat(s,"px"),n.style.borderRadius="15px",n.setAttribute("id",l),n.addEventListener("load",(function(){n.style.boxShadow="rgba(0, 0, 0, 0.01) 0px 5px 10px 0px, rgba(0, 0, 0, 0.1) 0px 7px 12px 0px"})),document.body.appendChild(n)}(p),function(t){var e="@media all and (max-width: 640px) {\n #chatling-chat-iframe { \n width: 100% !important;\n max-width: initial !important;\n right: 0px !important;\n top: 0px !important;\n left: 0 !important;\n bottom: 0px !important;\n max-height: initial !important;\n height: 100% !important;\n border-radius: 0px !important;\n }\n }",n=document.createElement("style");n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e));document.head.appendChild(n)}(),function(t){try{var e=null==t?void 0:t.auto_open;if(null!=e){v=null==e?void 0:e.enable_on_desktop,f=null==e?void 0:e.enable_on_mobile;var n=null==e?void 0:e.delay;m=null==e?void 0:e.behavior,(null==n||n<0)&&(n=0),g=n,w()&&H()}}catch(t){}}(p))}}}))}catch(t){}})).catch((function(t){}))}()})();