(window.unifiedSearch_bundle_jsonpfunction=window.unifiedSearch_bundle_jsonpfunction||[]).push([[9],{133:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var s=n(42),o=n(0),i=s.__importDefault(n(134));t.default=function(e){var t=o.useRef(0),n=o.useState(e),s=n[0],r=n[1],a=o.useCallback((function(e){cancelAnimationFrame(t.current),t.current=requestAnimationFrame((function(){r(e)}))}),[]);return i.default((function(){cancelAnimationFrame(t.current)})),[s,a]}},134:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var s=n(42),o=n(0),i=s.__importDefault(n(65));t.default=function(e){var t=o.useRef(e);t.current=e,i.default((function(){return function(){return t.current()}}))}},143:function(e,t,n){"use strict";n.r(t),n.d(t,"default",(function(){return suggestions_component_SuggestionsComponent}));var s=n(3),o=n.n(s),i=n(0),r=n.n(i),a=n(4),u=n(39),c=n.n(u),l=n(1),d=n(133),p=n.n(d),g=n(11);function f(e){switch(e){case"field":return"kqlField";case"value":return"kqlValue";case"recentSearch":return"search";case"conjunction":return"kqlSelector";case"operator":return"kqlOperand";default:throw new Error(`Unknown type: ${e}`)}}const h=r.a.memo((function(e){const{index:t,innerRef:n,onClick:s,onMouseEnter:o,suggestion:r}=e,a=Object(i.useCallback)((e=>{n(t,e)}),[t,n]),u=Object(i.useCallback)((()=>{s(r,t)}),[t,s,r]),d=Object(i.useCallback)((()=>{o(r,t)}),[t,o,r]);return Object(l.jsx)("div",{className:c()({kbnTypeahead__item:!0,active:e.selected}),role:"option",onMouseEnter:d,onClick:u,ref:a,id:e.ariaId,"aria-selected":e.selected,"data-test-subj":`autocompleteSuggestion-${e.suggestion.type}-${e.suggestion.text.replace(/\s/g,"-")}`},Object(l.jsx)("div",{className:c()({kbnSuggestionItem:!0,["kbnSuggestionItem--"+e.suggestion.type]:!0})},Object(l.jsx)("div",{className:"kbnSuggestionItem__type"},Object(l.jsx)(g.EuiIcon,{type:f(e.suggestion.type)})),Object(l.jsx)("div",{className:"kbnSuggestionItem__text","data-test-subj":"autoCompleteSuggestionText"},e.suggestion.text),e.shouldDisplayDescription&&Object(l.jsx)("div",{className:"kbnSuggestionItem__description","data-test-subj":"autoCompleteSuggestionDescription"},e.suggestion.description)))}));var b=n(60);class suggestions_component_SuggestionsComponent extends i.PureComponent{constructor(e){super(e),o()(this,"childNodes",[]),o()(this,"parentNode",null),o()(this,"scrollIntoView",Object(b.b)((()=>{if(null===this.props.index)return;const e=this.parentNode,t=this.childNodes[this.props.index];if(null==this.props.index||!e||!t)return;const n=Math.max(Math.min(e.scrollTop,t.offsetTop),t.offsetTop+t.offsetHeight-e.offsetHeight);e.scrollTop=n}))),o()(this,"handleScroll",Object(b.b)((()=>{if(!this.props.loadMore||!this.parentNode)return;const e=this.parentNode.scrollTop+this.parentNode.offsetHeight,t=this.parentNode.scrollHeight;t&&e&&t-e<=50&&this.props.loadMore()}))),this.assignParentNode=this.assignParentNode.bind(this),this.assignChildNode=this.assignChildNode.bind(this)}assignParentNode(e){this.parentNode=e}assignChildNode(e,t){this.childNodes[e]=t}render(){if(!this.props.inputContainer||!this.props.show||Object(a.isEmpty)(this.props.suggestions))return null;const e=e=>{const t=e>=600;return this.props.suggestions.map(((e,n)=>Object(l.jsx)(h,{innerRef:this.assignChildNode,selected:n===this.props.index,index:n,suggestion:e,onClick:this.props.onClick,onMouseEnter:this.props.onMouseEnter,ariaId:"suggestion-"+n,key:`${e.type} - ${e.text}`,shouldDisplayDescription:t})))};return Object(l.jsx)(m,{inputContainer:this.props.inputContainer,suggestionsSize:this.props.size},(t=>Object(l.jsx)("div",{id:"kbnTypeahead__items",role:"listbox",ref:this.assignParentNode,onScroll:this.handleScroll},e(t.width))))}componentDidUpdate(e){e.index!==this.props.index&&this.scrollIntoView()}}const m=r.a.memo((e=>{const t=e.inputContainer,[{documentHeight:n},{pageYOffset:s},o]=function(e){const[t,n]=p()((()=>document.documentElement.clientHeight||window.innerHeight)),[s,o]=p()((()=>({pageXOffset:window.pageXOffset,pageYOffset:window.pageYOffset}))),[i,a]=p()((()=>{var t;return null!==(t=null==e?void 0:e.getBoundingClientRect())&&void 0!==t?t:null})),u=r.a.useCallback((()=>{a((t=>{var n;const s=null!==(n=null==e?void 0:e.getBoundingClientRect())&&void 0!==n?n:null;return Object(b.c)(null==t?void 0:t.toJSON(),null==s?void 0:s.toJSON())?t:s}))}),[e,a]);return r.a.useEffect((()=>{const e=()=>{n(document.documentElement.clientHeight||window.innerHeight)};return window.addEventListener("resize",e,{passive:!0}),()=>{window.removeEventListener("resize",e)}}),[n]),r.a.useEffect((()=>{const t=()=>{o((e=>{const{pageXOffset:t,pageYOffset:n}=window;return e.pageXOffset!==t||e.pageYOffset!==n?{pageXOffset:t,pageYOffset:n}:e})),u()};window.addEventListener("scroll",t,{passive:!0,capture:!0});const n=void 0!==window.ResizeObserver&&new ResizeObserver((()=>{u()}));return e&&n&&n.observe(e),()=>{window.removeEventListener("scroll",t,{capture:!0}),n&&n.disconnect()}}),[o,e,u]),[{documentHeight:t},s,i]}(t);if(!o)return null;const i=n-(o.top+o.height)>250,a=i?`top: ${s+o.bottom-0}px;`:`bottom: ${n-(s+o.top)}px;`,u=Object(l.css)("position:absolute;z-index:4001;left:",o.left,"px;width:",o.width,"px;",a,";","");return Object(l.jsx)("div",{css:u},Object(l.jsx)("div",{className:c()("kbnTypeahead",{"kbnTypeahead--small":"s"===e.suggestionsSize})},Object(l.jsx)("div",{className:c()("kbnTypeahead__popover",{"kbnTypeahead__popover--bottom":i,"kbnTypeahead__popover--top":!i})},e.children(o))))}))},65:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var s=n(0);t.default=function(e){s.useEffect(e,[])}}}]);