/*! Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one or more contributor license agreements. * Licensed under the Elastic License 2.0; you may not use this file except in compliance with the Elastic License 2.0. */ (window.cloudChat_bundle_jsonpfunction=window.cloudChat_bundle_jsonpfunction||[]).push([[1],{15:function(e,t,i){"use strict";i.r(t),i.d(t,"Chat",(function(){return d}));var n=i(1),s=i(0),a=i(13),o=i(4),r=i(14),c=i(3);const d=({onHide:e=(()=>{}),onReady:t,onResize:i})=>{const d=(({onReady:e=(()=>{}),onResize:t=(()=>{})})=>{const i=Object(n.useRef)(null),s=Object(c.b)(),[a,o]=Object(n.useState)({height:0,width:0}),[r,d]=Object(n.useState)(!1),[u,l]=Object(n.useState)(!1);return Object(n.useEffect)((()=>{const n=n=>{const{current:r}=i;if(!s||null==r||!r.contentWindow||n.source!==(null==r?void 0:r.contentWindow))return;const c=(()=>{const{location:e,navigator:t,innerHeight:i,innerWidth:n}=window,{hash:s,host:a,hostname:o,href:r,origin:c,pathname:d,port:u,protocol:l,search:h}=e,{language:b,userAgent:f}=t,{title:m,referrer:j}=document;return{window:{location:{hash:s,host:a,hostname:o,href:r,origin:c,pathname:d,port:u,protocol:l,search:h},navigator:{language:b,userAgent:f},innerHeight:i,innerWidth:n},document:{title:m,referrer:j}}})(),{data:h}=n,{user:b}=s,{id:f,email:m,jwt:j,trialEndDate:g,kbnVersion:w,kbnBuildNum:p}=b;switch(h.type){case"driftIframeReady":{const e={id:f,attributes:{email:m,trial_end_date:g,kbn_version:w,kbn_build_num:p},jwt:j};r.contentWindow.postMessage({type:"driftSetContext",data:{context:c,user:e}},"*");break}case"driftIframeResize":{const e=h.data.styles||{};o({...a,...e}),u||l(!0),t();break}case"driftWidgetReady":d(!0),e()}};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)}),[s,a,e,t,r,u]),s?{enabled:!0,src:s.chatURL,ref:i,style:a,isReady:r,isResized:u}:{enabled:!1}})({onReady:t,onResize:i}),u=Object(n.useRef)(null),[l,h]=Object(n.useState)(!1);if(!d.enabled||l)return null;const{isReady:b,isResized:f,style:m}=d,{right:j}=m,g=Object(s.css)("bottom:",r.euiThemeVars.euiSizeXS,";position:fixed;right:calc(",j," + ",r.euiThemeVars.euiSizeXS,");visibility:",b&&f?"visible":"hidden",";",""),w=Object(s.jsx)(o.EuiButtonEmpty,{css:g,"data-test-subj":"cloud-chat-hide",name:"cloudChatHide",onClick:()=>{e(),h(!0)},size:"xs"},a.i18n.translate("xpack.cloudChat.hideChatButtonLabel",{defaultMessage:"Hide chat"})),p=Object(s.css)("bottom:",r.euiThemeVars.euiSizeXL,";position:fixed;right:",r.euiThemeVars.euiSizeXL,";z-index:",r.euiThemeVars.euiZMaskBelowHeader-1,";&:focus [name='cloudChatHide'],&:hover [name='cloudChatHide']{visibility:visible;}","");return Object(s.jsx)("div",{css:p,ref:u,"data-test-subj":"cloud-chat"},w,Object(s.jsx)("iframe",{"data-test-subj":"cloud-chat-frame",title:a.i18n.translate("xpack.cloudChat.chatFrameTitle",{defaultMessage:"Chat"}),src:d.src,ref:d.ref,style:d.style}))}}}]);