(window.controls_bundle_jsonpfunction=window.controls_bundle_jsonpfunction||[]).push([[5],{103:function(t,e,i){switch(window.__kbnThemeTag__){case"v8dark":return i(104);case"v8light":return i(106)}},104:function(t,e,i){var s=i(50),o=i(105);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[t.i,o,""]]);s(o,{insert:"head",singleton:!1}),t.exports=o.locals||{}},105:function(t,e,i){(e=i(51)(!1)).push([t.i,".optionsList__anchorOverride{display:block}.optionsList__popoverOverride{height:100%;width:100%}.optionsList__actions{border-bottom:1px solid;border-color:#202128;padding:8px 8px 0}.optionsList__actions .optionsList__actionsRow{margin:4px 0!important}.optionsList__actions .optionsList__actionsRow .optionsList__actionBarDivider{border-right:1px solid #343741;height:16px}.optionsList__popoverTitle{align-items:center;display:flex;justify-content:space-between}.optionsList__filterInvalid{color:#7a7f89;font-weight:400;margin-left:8px;text-decoration:line-through}.optionsList__existsFilter,.optionsList__loadMore{font-style:italic}.optionsList__negateLabel{color:#f86b63;font-size:12px;font-weight:700}.optionsList__actionBarFirstBadge{margin-left:8px}.optionsList-control-ignored-selection-title{padding-left:8px}.optionsList__selectionInvalid{color:#7a7f89;text-decoration:line-through}.optionsList--filterBtnWrapper{height:100%}.optionsList--filterBtn .euiFilterButton__text-hasNotification{flex-grow:1;justify-content:space-between;width:0}.optionsList--filterBtn.optionsList--filterBtnPlaceholder .euiFilterButton__textShift{color:#7a7f89}.optionsList--filterGroupSingle{border-bottom-left-radius:0;border-bottom-right-radius:5px;border-top-left-radius:0;border-top-right-radius:5px;box-shadow:none;height:100%}.optionsList--filterGroup{width:100%}.optionsList--hiddenEditorForm{margin-left:52px}.optionsList--sortPopover{width:224px}.optionslist--loadingMoreGroupLabel{font-style:italic;height:40px!important;padding:12px;text-align:center}.optionslist--endOfOptionsGroupLabel{color:#7a7f89;font-size:12px;height:auto!important;padding:12px;text-align:center}",""]),t.exports=e},106:function(t,e,i){var s=i(50),o=i(107);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[t.i,o,""]]);s(o,{insert:"head",singleton:!1}),t.exports=o.locals||{}},107:function(t,e,i){(e=i(51)(!1)).push([t.i,".optionsList__anchorOverride{display:block}.optionsList__popoverOverride{height:100%;width:100%}.optionsList__actions{border-bottom:1px solid;border-color:#eef2f7;padding:8px 8px 0}.optionsList__actions .optionsList__actionsRow{margin:4px 0!important}.optionsList__actions .optionsList__actionsRow .optionsList__actionBarDivider{border-right:1px solid #d3dae6;height:16px}.optionsList__popoverTitle{align-items:center;display:flex;justify-content:space-between}.optionsList__filterInvalid{color:#69707d;font-weight:400;margin-left:8px;text-decoration:line-through}.optionsList__existsFilter,.optionsList__loadMore{font-style:italic}.optionsList__negateLabel{color:#bd271e;font-size:12px;font-weight:700}.optionsList__actionBarFirstBadge{margin-left:8px}.optionsList-control-ignored-selection-title{padding-left:8px}.optionsList__selectionInvalid{color:#69707d;text-decoration:line-through}.optionsList--filterBtnWrapper{height:100%}.optionsList--filterBtn .euiFilterButton__text-hasNotification{flex-grow:1;justify-content:space-between;width:0}.optionsList--filterBtn.optionsList--filterBtnPlaceholder .euiFilterButton__textShift{color:#69707d}.optionsList--filterGroupSingle{border-bottom-left-radius:0;border-bottom-right-radius:5px;border-top-left-radius:0;border-top-right-radius:5px;box-shadow:none;height:100%}.optionsList--filterGroup{width:100%}.optionsList--hiddenEditorForm{margin-left:52px}.optionsList--sortPopover{width:224px}.optionslist--loadingMoreGroupLabel{font-style:italic;height:40px!important;padding:12px;text-align:center}.optionslist--endOfOptionsGroupLabel{color:#69707d;font-size:12px;height:auto!important;padding:12px;text-align:center}",""]),t.exports=e},108:function(t,e,i){!function(e){"use strict";const i="(0?\\d+|0x[a-f0-9]+)",s={fourOctet:new RegExp(`^${i}\\.${i}\\.${i}\\.${i}$`,"i"),threeOctet:new RegExp(`^${i}\\.${i}\\.${i}$`,"i"),twoOctet:new RegExp(`^${i}\\.${i}$`,"i"),longValue:new RegExp(`^${i}$`,"i")},o=new RegExp("^0[0-7]+$","i"),n=new RegExp("^0x[a-f0-9]+$","i"),r="%[0-9a-z]{1,}",a="(?:[0-9a-f]+::?)+",l={zoneIndex:new RegExp(r,"i"),native:new RegExp(`^(::)?(${a})?([0-9a-f]+)?(::)?(${r})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${i}\\.${i}\\.${i}\\.${i}(${r})?)$`,"i"),transitional:new RegExp(`^((?:${a})|(?:::)(?:${a})?)${i}\\.${i}\\.${i}\\.${i}(${r})?$`,"i")};function c(t,e){if(t.indexOf("::")!==t.lastIndexOf("::"))return null;let i,s,o=0,n=-1,r=(t.match(l.zoneIndex)||[])[0];for(r&&(r=r.substring(1),t=t.replace(/%.+$/,""));(n=t.indexOf(":",n+1))>=0;)o++;if("::"===t.substr(0,2)&&o--,"::"===t.substr(-2,2)&&o--,o>e)return null;for(s=e-o,i=":";s--;)i+="0:";return":"===(t=t.replace("::",i))[0]&&(t=t.slice(1)),":"===t[t.length-1]&&(t=t.slice(0,-1)),{parts:e=function(){const e=t.split(":"),i=[];for(let t=0;t0;){if(o=i-s,o<0&&(o=0),t[n]>>o!=e[n]>>o)return!1;s-=i,n+=1}return!0}function d(t){if(n.test(t))return parseInt(t,16);if("0"===t[0]&&!isNaN(parseInt(t[1],10))){if(o.test(t))return parseInt(t,8);throw new Error(`ipaddr: cannot parse ${t} as octal`)}return parseInt(t,10)}function u(t,e){for(;t.length=0;s-=1){if(o=this.octets[s],!(o in i))return null;if(n=i[o],e&&0!==n)return null;8!==n&&(e=!0),t+=n}return 32-t},t.prototype.range=function(){return h.subnetMatch(this,this.SpecialRanges)},t.prototype.toByteArray=function(){return this.octets.slice(0)},t.prototype.toIPv4MappedAddress=function(){return h.IPv6.parse(`::ffff:${this.toString()}`)},t.prototype.toNormalizedString=function(){return this.toString()},t.prototype.toString=function(){return this.octets.join(".")},t}(),h.IPv4.broadcastAddressFromCIDR=function(t){try{const e=this.parseCIDR(t),i=e[0].toByteArray(),s=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),o=[];let n=0;for(;n<4;)o.push(parseInt(i[n],10)|255^parseInt(s[n],10)),n++;return new this(o)}catch(t){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},h.IPv4.isIPv4=function(t){return null!==this.parser(t)},h.IPv4.isValid=function(t){try{return new this(this.parser(t)),!0}catch(t){return!1}},h.IPv4.isValidFourPartDecimal=function(t){return!(!h.IPv4.isValid(t)||!t.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},h.IPv4.networkAddressFromCIDR=function(t){let e,i,s,o,n;try{for(e=this.parseCIDR(t),s=e[0].toByteArray(),n=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),o=[],i=0;i<4;)o.push(parseInt(s[i],10)&parseInt(n[i],10)),i++;return new this(o)}catch(t){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},h.IPv4.parse=function(t){const e=this.parser(t);if(null===e)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(e)},h.IPv4.parseCIDR=function(t){let e;if(e=t.match(/^(.+)\/(\d+)$/)){const t=parseInt(e[2]);if(t>=0&&t<=32){const i=[this.parse(e[1]),t];return Object.defineProperty(i,"toString",{value:function(){return this.join("/")}}),i}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},h.IPv4.parser=function(t){let e,i,o;if(e=t.match(s.fourOctet))return function(){const t=e.slice(1,6),s=[];for(let e=0;e4294967295||o<0)throw new Error("ipaddr: address outside defined range");return function(){const t=[];let e;for(e=0;e<=24;e+=8)t.push(o>>e&255);return t}().reverse()}return(e=t.match(s.twoOctet))?function(){const t=e.slice(1,4),i=[];if(o=d(t[1]),o>16777215||o<0)throw new Error("ipaddr: address outside defined range");return i.push(d(t[0])),i.push(o>>16&255),i.push(o>>8&255),i.push(255&o),i}():(e=t.match(s.threeOctet))?function(){const t=e.slice(1,5),i=[];if(o=d(t[2]),o>65535||o<0)throw new Error("ipaddr: address outside defined range");return i.push(d(t[0])),i.push(d(t[1])),i.push(o>>8&255),i.push(255&o),i}():null},h.IPv4.subnetMaskFromPrefixLength=function(t){if((t=parseInt(t))<0||t>32)throw new Error("ipaddr: invalid IPv4 prefix length");const e=[0,0,0,0];let i=0;const s=Math.floor(t/8);for(;i=0;n-=1){if(s=this.parts[n],!(s in i))return null;if(o=i[s],e&&0!==o)return null;16!==o&&(e=!0),t+=o}return 128-t},t.prototype.range=function(){return h.subnetMatch(this,this.SpecialRanges)},t.prototype.toByteArray=function(){let t;const e=[],i=this.parts;for(let s=0;s>8),e.push(255&t);return e},t.prototype.toFixedLengthString=function(){const t=function(){const t=[];for(let e=0;e>8,255&e,i>>8,255&i])},t.prototype.toNormalizedString=function(){const t=function(){const t=[];for(let e=0;eo&&(s=i.index,o=i[0].length);return o<0?e:`${e.substring(0,s)}::${e.substring(s+o)}`},t.prototype.toString=function(){return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/,"::")},t}(),h.IPv6.isIPv6=function(t){return null!==this.parser(t)},h.IPv6.isValid=function(t){if("string"==typeof t&&-1===t.indexOf(":"))return!1;try{const e=this.parser(t);return new this(e.parts,e.zoneId),!0}catch(t){return!1}},h.IPv6.parse=function(t){const e=this.parser(t);if(null===e.parts)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(e.parts,e.zoneId)},h.IPv6.parseCIDR=function(t){let e,i,s;if((i=t.match(/^(.+)\/(\d+)$/))&&(e=parseInt(i[2]),e>=0&&e<=128))return s=[this.parse(i[1]),e],Object.defineProperty(s,"toString",{value:function(){return this.join("/")}}),s;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},h.IPv6.parser=function(t){let e,i,s,o,n,r;if(s=t.match(l.deprecatedTransitional))return this.parser(`::ffff:${s[1]}`);if(l.native.test(t))return c(t,8);if((s=t.match(l.transitional))&&(r=s[6]||"",e=c(s[1].slice(0,-1)+r,6),e.parts)){for(n=[parseInt(s[2]),parseInt(s[3]),parseInt(s[4]),parseInt(s[5])],i=0;i{const t=K(),e=t.select((t=>t.componentState.allowExpensiveQueries)),i=t.select((t=>t.explicitInput.title));return Object(L.jsx)(w.EuiPopoverTitle,{paddingSize:"s"},Object(L.jsx)(w.EuiFlexGroup,{gutterSize:"xs",alignItems:"center"},Object(L.jsx)(w.EuiFlexItem,{grow:!1},i),!e&&Object(L.jsx)(w.EuiFlexItem,{"data-test-subj":"optionsList-allow-expensive-queries-warning",grow:!1},Object(L.jsx)(w.EuiIconTip,{"aria-label":"Warning",type:"warning",color:"warning",content:y.a.popover.getAllowExpensiveQueriesWarning()}))))},_=[{id:"optionsList__includeResults",label:y.a.popover.getIncludeLabel()},{id:"optionsList__excludeResults",label:y.a.popover.getExcludeLabel()}],P=({isLoading:t})=>{const e=K(),i=e.select((t=>t.explicitInput.exclude));return Object(L.jsx)(h.a.Fragment,null,Object(L.jsx)(w.EuiPopoverFooter,{paddingSize:"none",css:Object(L.css)("background-color:",Object(w.useEuiBackgroundColor)("subdued"),";","")},t&&Object(L.jsx)("div",{style:{position:"absolute",width:"100%"}},Object(L.jsx)(w.EuiProgress,{"data-test-subj":"optionsList-control-popover-loading",size:"xs",color:"accent"})),Object(L.jsx)("div",{css:Object(L.css)("padding:",Object(w.useEuiPaddingSize)("s"),";","")},Object(L.jsx)(w.EuiButtonGroup,{legend:y.a.popover.getIncludeExcludeLegend(),options:_,idSelected:i?"optionsList__excludeResults":"optionsList__includeResults",onChange:t=>e.dispatch.setExclude("optionsList__excludeResults"===t),buttonSize:"compressed","data-test-subj":"optionsList__includeExcludeButtonGroup"}))))};var F=i(13);const C=[{id:"asc",iconType:"sortAscending","data-test-subj":"optionsList__sortOrder_asc",label:y.a.editorAndPopover.sortOrder.asc.getSortOrderLabel()},{id:"desc",iconType:"sortDescending","data-test-subj":"optionsList__sortOrder_desc",label:y.a.editorAndPopover.sortOrder.desc.getSortOrderLabel()}],R=({showOnlySelected:t})=>{const e=K(),i=e.select((t=>t.componentState.field)),s=e.select((t=>{var e;return null!==(e=t.explicitInput.sort)&&void 0!==e?e:F.a})),[o,n]=Object(u.useState)(!1),[r,a]=Object(u.useState)((()=>Object(F.b)(null==i?void 0:i.type).map((t=>({onFocusBadge:!1,data:{sortBy:t},checked:t===s.by?"on":void 0,"data-test-subj":`optionsList__sortBy_${t}`,label:y.a.editorAndPopover.sortBy[t].getSortByLabel()}))))),l=Object(u.useCallback)((t=>{a(t);const i=t.find((({checked:t})=>"on"===t));i&&e.dispatch.setSort({by:i.data.sortBy})}),[e.dispatch]),c=()=>Object(L.jsx)(w.EuiButtonEmpty,{size:"s",color:"text",iconSide:"right",iconType:"arrowDown",disabled:t,"data-test-subj":"optionsListControl__sortingOptionsButton",onClick:()=>n(!o),className:"euiFilterGroup","aria-label":y.a.popover.getSortPopoverDescription()},y.a.popover.getSortPopoverTitle());return Object(L.jsx)(w.EuiPopover,{button:t?Object(L.jsx)(w.EuiToolTip,{position:"top",content:y.a.popover.getSortDisabledTooltip()},Object(L.jsx)(c,null)):Object(L.jsx)(c,null),panelPaddingSize:"none",isOpen:o,"aria-labelledby":"optionsList_sortingOptions",closePopover:()=>n(!1),panelClassName:"optionsList--sortPopover"},Object(L.jsx)("span",{"data-test-subj":"optionsListControl__sortingOptionsPopover"},Object(L.jsx)(w.EuiPopoverTitle,{paddingSize:"s"},Object(L.jsx)(w.EuiFlexGroup,{alignItems:"center",responsive:!1},Object(L.jsx)(w.EuiFlexItem,null,y.a.popover.getSortPopoverTitle()),Object(L.jsx)(w.EuiFlexItem,{grow:!1},Object(L.jsx)(w.EuiButtonGroup,{isIconOnly:!0,buttonSize:"compressed",options:C,idSelected:s.direction,legend:y.a.editorAndPopover.getSortDirectionLegend(),onChange:t=>e.dispatch.setSort({direction:t})})))),Object(L.jsx)(w.EuiSelectable,{options:r,singleSelection:"always",onChange:l,id:"optionsList_sortingOptions",listProps:{bordered:!1},"data-test-subj":"optionsListControl__sortingOptions","aria-label":y.a.popover.getSortPopoverDescription()},(t=>t))))};var T=i(10);const B=({showOnlySelected:t,updateSearchString:e,setShowOnlySelected:i})=>{var s;const o=K(),n=null!==(s=o.select((t=>t.componentState.totalCardinality)))&&void 0!==s?s:0,r=o.select((t=>t.componentState.searchString)),a=o.select((t=>t.componentState.invalidSelections)),l=o.select((t=>t.explicitInput.searchTechnique)),c=o.select((t=>t.componentState.allowExpensiveQueries)),p=o.select((t=>t.explicitInput.hideSort));return Object(L.jsx)("div",{className:"optionsList__actions"},Object(L.jsx)(w.EuiFormRow,{fullWidth:!0},Object(L.jsx)(w.EuiFlexGroup,{gutterSize:"xs",alignItems:"center",responsive:!1},Object(L.jsx)(w.EuiFlexItem,{grow:!0},Object(L.jsx)(w.EuiFieldSearch,{isInvalid:!r.valid,compressed:!0,disabled:t,fullWidth:!0,onChange:t=>e(t.target.value),value:r.value,"data-test-subj":"optionsList-control-search-input",placeholder:y.a.popover.searchPlaceholder[null!=l?l:T.b].getPlaceholderText()})),!p&&Object(L.jsx)(w.EuiFlexItem,{grow:!1},Object(L.jsx)(R,{showOnlySelected:t})))),Object(L.jsx)(w.EuiFormRow,{className:"optionsList__actionsRow",fullWidth:!0},Object(L.jsx)(w.EuiFlexGroup,{justifyContent:"spaceBetween",alignItems:"center",gutterSize:"s",responsive:!1},c&&Object(L.jsx)(w.EuiFlexItem,{grow:!1},Object(L.jsx)(w.EuiText,{size:"xs",color:"subdued","data-test-subj":"optionsList-cardinality-label"},y.a.popover.getCardinalityLabel(n))),a&&a.length>0&&Object(L.jsx)(h.a.Fragment,null,c&&Object(L.jsx)(w.EuiFlexItem,{grow:!1},Object(L.jsx)("div",{className:"optionsList__actionBarDivider"})),Object(L.jsx)(w.EuiFlexItem,{grow:!1},Object(L.jsx)(w.EuiText,{size:"xs",color:"subdued"},y.a.popover.getInvalidSelectionsLabel(a.length)))),Object(L.jsx)(w.EuiFlexItem,{grow:!0},Object(L.jsx)(w.EuiFlexGroup,{gutterSize:"xs",alignItems:"center",justifyContent:"flexEnd",responsive:!1},Object(L.jsx)(w.EuiFlexItem,{grow:!1},Object(L.jsx)(w.EuiToolTip,{position:"top",content:t?y.a.popover.getAllOptionsButtonTitle():y.a.popover.getSelectedOptionsButtonTitle()},Object(L.jsx)(w.EuiButtonIcon,{size:"xs",iconType:"list","aria-pressed":t,color:t?"primary":"text",display:t?"base":"empty",onClick:()=>i(!t),"data-test-subj":"optionsList-control-show-only-selected","aria-label":t?y.a.popover.getAllOptionsButtonTitle():y.a.popover.getSelectedOptionsButtonTitle()}))))))))};var M=i(47);const $=({showOnlySelected:t})=>Object(L.jsx)(w.EuiSelectableMessage,{"data-test-subj":"optionsList-control-"+(t?"selectionsEmptyMessage":"noSelectionsMessage")},Object(L.jsx)(w.EuiIcon,{type:"minusInCircle"}),Object(L.jsx)(w.EuiSpacer,{size:"xs"}),t?y.a.popover.getSelectionsEmptyMessage():y.a.popover.getEmptyMessage()),k=({documentCount:t})=>{const{euiTheme:e}=Object(w.useEuiTheme)();return Object(L.jsx)(h.a.Fragment,null,Object(L.jsx)(w.EuiToolTip,{content:y.a.popover.getDocumentCountTooltip(t),position:"right"},Object(L.jsx)(w.EuiText,{size:"xs","aria-hidden":!0,className:"eui-textNumber",color:e.colors.subduedText,"data-test-subj":"optionsList-document-count-badge",css:Object(L.css)("font-weight:",e.font.weight.medium,"!important;","")},`${t.toLocaleString()}`)),Object(L.jsx)(w.EuiScreenReaderOnly,null,Object(L.jsx)("div",null,'" "'," ",y.a.popover.getDocumentCountScreenReaderText(t))))},A=({showOnlySelected:t,loadMoreSuggestions:e})=>{var i;const s=K(),o=s.select((t=>t.componentState.searchString)),n=s.select((t=>t.componentState.availableOptions)),r=s.select((t=>t.componentState.totalCardinality)),a=s.select((t=>t.componentState.invalidSelections)),l=s.select((t=>t.explicitInput.sort)),c=s.select((t=>t.explicitInput.fieldName)),p=s.select((t=>t.explicitInput.hideExists)),d=s.select((t=>t.explicitInput.singleSelect)),b=s.select((t=>t.explicitInput.existsSelected)),g=s.select((t=>t.explicitInput.selectedOptions)),v=null!==(i=s.select((t=>t.output.loading)))&&void 0!==i&&i,f=Object(u.useRef)(null),x=Object(u.useMemo)((()=>!!r&&(null!=n?n:[]).lengthnew Set(g)),[g]),S=Object(u.useMemo)((()=>new Set(a)),[a]),O=Object(u.useMemo)((()=>t?g:null!=n?n:[]),[n,g,t]),m=Object(u.useMemo)((()=>{if(!p&&(b||!t&&0!==(null==O?void 0:O.length)))return{key:"exists-option",checked:b?"on":void 0,label:y.a.controlAndPopover.getExists(),className:"optionsList__existsFilter","data-test-subj":"optionsList-control-selection-exists"}}),[O,b,t,p]),[E,_]=Object(u.useState)([]);Object(u.useEffect)((()=>{const e=(null!=O?O:[]).map((e=>{var i;return"string"==typeof e&&(e={value:e}),{key:e.value,label:e.value,checked:null!=j&&j.has(e.value)?"on":void 0,"data-test-subj":`optionsList-control-selection-${e.value}`,className:t&&S.has(e.value)?"optionsList__selectionInvalid":"optionsList__validSuggestion",append:!t&&null!==(i=e)&&void 0!==i&&i.docCount?Object(L.jsx)(k,{documentCount:e.docCount}):void 0}}));x?e.push({key:"loading-option",className:"optionslist--loadingMoreGroupLabel",label:y.a.popover.getLoadingMoreMessage(),isGroupLabel:!0}):e.length===I&&e.push({key:"no-more-option",className:"optionslist--endOfOptionsGroupLabel",label:y.a.popover.getAtEndOfOptionsMessage(),isGroupLabel:!0}),_(m?[m,...e]:e)}),[O,n,t,j,S,m,x]);const P=Object(u.useCallback)((()=>{var t;const i=null===(t=f.current)||void 0===t?void 0:t.querySelector(".euiSelectableList__list");if(!i)return;const{scrollTop:s,scrollHeight:o,clientHeight:n}=i;s+n>=o-parseInt(M.euiThemeVars.euiSizeXXL,10)&&e(null!=r?r:I)}),[e,r]);return Object(u.useEffect)((()=>{const t=f.current;if(!v&&x)return null==t||t.addEventListener("scroll",P,!0),()=>{null==t||t.removeEventListener("scroll",P,!0)}}),[P,v,x]),Object(u.useEffect)((()=>{var t;const e=null===(t=f.current)||void 0===t?void 0:t.querySelector(".euiSelectableList__list");null==e||e.scrollTo({top:0})}),[l,o]),Object(L.jsx)(h.a.Fragment,null,Object(L.jsx)("div",{ref:f},Object(L.jsx)(w.EuiSelectable,{options:E,renderOption:t=>Object(L.jsx)(w.EuiHighlight,{search:"exists-option"===t.key?"":o.value},t.label),listProps:{onFocusBadge:!1},"aria-label":y.a.popover.getSuggestionsAriaLabel(c,E.length),emptyMessage:Object(L.jsx)($,{showOnlySelected:t}),onChange:(e,i,o)=>{var n;const r=null!==(n=o.key)&&void 0!==n?n:o.label;_(e),"exists-option"===r?s.dispatch.selectExists(!Boolean(b)):t||j.has(r)?s.dispatch.deselectOption(r):d?s.dispatch.replaceSelection(r):s.dispatch.selectOption(r)}},(t=>t))))},V=()=>{var t,e;const i=K(),s=i.select((t=>t.componentState.invalidSelections)),o=i.select((t=>t.explicitInput.fieldName)),[n,r]=Object(u.useState)([]);return Object(u.useEffect)((()=>{const t=(null!=s?s:[]).map((t=>({key:t,label:t,checked:"on",className:"optionsList__selectionInvalid","data-test-subj":`optionsList-control-ignored-selection-${t}`,prepend:Object(L.jsx)(w.EuiScreenReaderOnly,null,Object(L.jsx)("div",null,y.a.popover.getInvalidSelectionScreenReaderText(),'" "'," "))})));r(t)}),[s]),Object(L.jsx)(h.a.Fragment,null,Object(L.jsx)(w.EuiSpacer,{size:"s"}),Object(L.jsx)(w.EuiTitle,{size:"xxs",className:"optionsList-control-ignored-selection-title","data-test-subj":"optionList__ignoredSelectionLabel"},Object(L.jsx)("label",null,y.a.popover.getInvalidSelectionsSectionTitle(null!==(t=null==s?void 0:s.length)&&void 0!==t?t:0))),Object(L.jsx)(w.EuiSelectable,{"aria-label":y.a.popover.getInvalidSelectionsSectionAriaLabel(o,null!==(e=null==s?void 0:s.length)&&void 0!==e?e:0),options:n,listProps:{onFocusBadge:!1,isVirtualized:!1},onChange:(t,e,s)=>{r(t),i.dispatch.deselectOption(s.label)}},(t=>t)))},z=({width:t,isLoading:e,updateSearchString:i,loadMoreSuggestions:s})=>{const o=K(),n=o.select((t=>t.componentState.field)),r=o.select((t=>t.componentState.availableOptions)),a=o.select((t=>t.componentState.invalidSelections)),l=o.select((t=>t.explicitInput.id)),c=o.select((t=>t.explicitInput.fieldName)),d=o.select((t=>t.explicitInput.hideExclude)),b=o.select((t=>t.explicitInput.hideActionBar)),[g,v]=Object(u.useState)(!1);return Object(L.jsx)(h.a.Fragment,null,Object(L.jsx)("div",{id:`control-popover-${l}`,style:{width:t,minWidth:300},"data-test-subj":"optionsList-control-popover","aria-label":y.a.popover.getAriaLabel(c)},Object(L.jsx)(E,null),"boolean"!==(null==n?void 0:n.type)&&!b&&Object(L.jsx)(B,{showOnlySelected:g,updateSearchString:i,setShowOnlySelected:v}),Object(L.jsx)("div",{"data-test-subj":"optionsList-control-available-options","data-option-count":e?0:Object.keys(null!=r?r:{}).length,style:{width:"100%",height:"100%"}},Object(L.jsx)(A,{loadMoreSuggestions:s,showOnlySelected:g}),!g&&a&&!Object(p.isEmpty)(a)&&Object(L.jsx)(V,null)),!d&&Object(L.jsx)(P,{isLoading:e})))};i(103);var N=i(59);const D=({typeaheadSubject:t,loadMoreSubject:e})=>{const i=Object(u.useRef)(null),s=K(),o=Object(w.useResizeObserver)(i.current),n=s.select((t=>t.componentState.error)),r=s.select((t=>t.componentState.popoverOpen)),a=s.select((t=>t.componentState.validSelections)),l=s.select((t=>t.componentState.invalidSelections)),c=s.select((t=>t.explicitInput.id)),d=s.select((t=>t.explicitInput.exclude)),b=s.select((t=>t.explicitInput.fieldName)),g=s.select((t=>t.explicitInput.placeholder)),v=s.select((t=>t.explicitInput.controlStyle)),f=s.select((t=>t.explicitInput.singleSelect)),x=s.select((t=>t.explicitInput.existsSelected)),j=s.select((t=>t.explicitInput.selectedOptions)),S=s.select((t=>t.output.loading));Object(u.useEffect)((()=>()=>{s.dispatch.setPopoverOpen(!1)}),[s]);const[O,E]=Object(u.useState)(!0),_=Object(u.useMemo)((()=>Object(p.debounce)((t=>{E(t)}),100)),[]);Object(u.useEffect)((()=>_(null!=S&&S)),[S,_]),Object(u.useEffect)((()=>{f&&j&&(null==j?void 0:j.length)>1&&s.dispatch.replaceSelection(j[0])}),[j,f,s.dispatch]);const P=Object(u.useCallback)((e=>{t.next(e),s.dispatch.setSearchString(e)}),[t,s.dispatch]),F=Object(u.useCallback)((t=>{e.next(Math.min(t,I))}),[e]),{hasSelections:C,selectionDisplayNode:R,validSelectionsCount:T}=Object(u.useMemo)((()=>({hasSelections:!Object(p.isEmpty)(a)||!Object(p.isEmpty)(l),validSelectionsCount:null==a?void 0:a.length,selectionDisplayNode:Object(L.jsx)(h.a.Fragment,null,d&&Object(L.jsx)(h.a.Fragment,null,Object(L.jsx)("span",{className:"optionsList__negateLabel"},x?y.a.control.getExcludeExists():y.a.control.getNegate())," "),x?Object(L.jsx)("span",{className:"optionsList__existsFilter"},y.a.controlAndPopover.getExists(+Boolean(d))):Object(L.jsx)(h.a.Fragment,null,a&&Object(L.jsx)("span",null,a.join(y.a.control.getSeparator())),l&&Object(L.jsx)("span",{className:"optionsList__filterInvalid"},l.join(y.a.control.getSeparator()))))})),[d,x,a,l]),B=Object(L.jsx)("div",{className:"optionsList--filterBtnWrapper",ref:i},Object(L.jsx)(w.EuiFilterButton,{badgeColor:"success",iconType:"arrowDown",isLoading:O,className:m()("optionsList--filterBtn",{"optionsList--filterBtnSingle":"twoLine"!==v,"optionsList--filterBtnPlaceholder":!C}),"data-test-subj":`optionsList-control-${c}`,onClick:()=>s.dispatch.setPopoverOpen(!r),isSelected:r,numActiveFilters:T,hasActiveFilters:Boolean(T)},C||x?R:null!=g?g:y.a.control.getPlaceholder()));return n?Object(L.jsx)(N.a,{error:n}):Object(L.jsx)(w.EuiFilterGroup,{className:m()("optionsList--filterGroup",{"optionsList--filterGroupSingle":"twoLine"!==v})},Object(L.jsx)(w.EuiPopover,{ownFocus:!0,button:B,repositionOnScroll:!0,isOpen:r,panelPaddingSize:"none",anchorPosition:"downCenter",initialFocus:"[data-test-subj=optionsList-control-search-input]",className:"optionsList__popoverOverride",closePopover:()=>s.dispatch.setPopoverOpen(!1),anchorClassName:"optionsList__anchorOverride","aria-label":y.a.popover.getAriaLabel(b)},Object(L.jsx)(z,{width:o.width,isLoading:O,updateSearchString:P,loadMoreSuggestions:F})))};var G=i(108),Q=i.n(G);const q=(t,e)=>{const i="ipv4"===t;return{min:i?e.concat(Array(4-e.length).fill("0")).join("."):e.join(":")+"::",max:i?e.concat(Array(4-e.length).fill("255")).join("."):e.concat(Array(8-e.length).fill("ffff")).join(":")}},W=t=>{const{type:e,segments:i}=t,s="ipv4"===e,o=i.join(s?".":":");if(Q.a.isValid(o))return[{key:e,mask:s?o+"/32":o+"/128"}]},H={deselectOption:(t,e)=>{if(!t.explicitInput.selectedOptions)return;const i=t.explicitInput.selectedOptions.indexOf(e.payload);if(-1!==i){const e=[...t.explicitInput.selectedOptions];e.splice(i,1),t.explicitInput.selectedOptions=e}},setSearchString:(t,e)=>{var i;t.componentState.searchString.value=e.payload,""!==e.payload&&"ip"===(null===(i=t.componentState.field)||void 0===i?void 0:i.type)&&(t.componentState.searchString.valid=(t=>{if(null===t.match(/^[A-Fa-f0-9.:]*$/))return{validSearch:!1};const e=(t=>-1!==t.indexOf(".")?{segments:t.split(".").filter((t=>""!==t)),type:"ipv4"}:-1!==t.indexOf(":")?{segments:t.split(":").filter((t=>""!==t)),type:"ipv6"}:{segments:[t],type:"unknown"})(t);if("ipv4"===e.type&&4===e.segments.length){const t=W(e);return{validSearch:Boolean(t),rangeQuery:t}}if("ipv6"===e.type&&8===e.segments.length){const t=W(e);return{validSearch:Boolean(t),rangeQuery:t}}const i=(t=>{const{type:e,segments:i}=t,s=[];if("unknown"===e||"ipv4"===e){const{min:t,max:e}=q("ipv4",i);Q.a.isValid(t)&&Q.a.isValid(e)&&s.push({key:"ipv4",from:t,to:e})}if("unknown"===e||"ipv6"===e){const{min:t,max:e}=q("ipv6",i);Q.a.isValid(t)&&Q.a.isValid(e)&&s.push({key:"ipv6",from:t,to:e})}return s})(e);return{validSearch:!(0===(null==i?void 0:i.length)),rangeQuery:i}})(e.payload).validSearch)},setAllowExpensiveQueries:(t,e)=>{t.componentState.allowExpensiveQueries=e.payload},setPopoverOpen:(t,e)=>{t.componentState.popoverOpen=e.payload},setSort:(t,e)=>{var i;t.explicitInput.sort={...null!==(i=t.explicitInput.sort)&&void 0!==i?i:F.a,...e.payload}},selectExists:(t,e)=>{e.payload?(t.explicitInput.existsSelected=!0,t.explicitInput.selectedOptions=[]):t.explicitInput.existsSelected=!1},selectOption:(t,e)=>{var i;t.explicitInput.selectedOptions||(t.explicitInput.selectedOptions=[]),t.explicitInput.existsSelected&&(t.explicitInput.existsSelected=!1),null===(i=t.explicitInput.selectedOptions)||void 0===i||i.push(e.payload)},replaceSelection:(t,e)=>{t.explicitInput.selectedOptions=[e.payload],t.explicitInput.existsSelected&&(t.explicitInput.existsSelected=!1)},clearSelections:t=>{t.explicitInput.existsSelected&&(t.explicitInput.existsSelected=!1),t.explicitInput.selectedOptions&&(t.explicitInput.selectedOptions=[])},setExclude:(t,e)=>{t.explicitInput.exclude=e.payload},clearValidAndInvalidSelections:t=>{t.componentState.invalidSelections=[],t.componentState.validSelections=[]},setValidAndInvalidSelections:(t,e)=>{const{invalidSelections:i,validSelections:s}=e.payload;t.componentState.invalidSelections=i,t.componentState.validSelections=s},setErrorMessage:(t,e)=>{t.componentState.error=e.payload},setLoading:(t,e)=>{t.output.loading=e.payload},setField:(t,e)=>{t.componentState.field=e.payload},updateQueryResults:(t,e)=>{var i;t.componentState={...null!==(i=t.componentState)&&void 0!==i?i:{},...e.payload}},publishFilters:(t,e)=>{t.output.filters=e.payload},setDataViewId:(t,e)=>{t.output.dataViewId=e.payload},setExplicitInputDataViewId:(t,e)=>{t.explicitInput.dataViewId=e.payload}},U=(t,e)=>{if(!e||!t)return!1;const{filters:i,...s}=e,{filters:o,...n}=t;return!!c()(s,n)&&!!Object(g.compareFilters)(null!=o?o:[],null!=i?i:[],g.COMPARE_ALL_OPTIONS)},X=Object(u.createContext)(null),K=()=>{const t=Object(u.useContext)(X);if(null==t)throw new Error("useOptionsList must be used inside OptionsListEmbeddableContext.");return t};class options_list_embeddable_OptionsListEmbeddable extends f.Embeddable{constructor(t,e,i,s){super(e,i,s),o()(this,"type",j.OPTIONS_LIST_CONTROL),o()(this,"deferEmbeddableLoad",!0),o()(this,"subscriptions",new d.Subscription),o()(this,"node",void 0),o()(this,"dataViewsService",void 0),o()(this,"optionsListService",void 0),o()(this,"typeaheadSubject",new d.Subject),o()(this,"loadMoreSubject",new d.Subject),o()(this,"abortController",void 0),o()(this,"dataView",void 0),o()(this,"field",void 0),o()(this,"select",void 0),o()(this,"getState",void 0),o()(this,"dispatch",void 0),o()(this,"onStateChange",void 0),o()(this,"cleanupStateTools",void 0),o()(this,"initialize",(async()=>{const{selectedOptions:t}=this.getInput();t||this.setInitializationFinished(),this.dispatch.setAllowExpensiveQueries(await this.optionsListService.getAllowExpensiveQueries()),this.runOptionsListQuery().then((async()=>{t&&(await this.buildFilter(),this.setInitializationFinished()),this.setupSubscriptions()}))})),o()(this,"setupSubscriptions",(()=>{const t=this.getInput$().pipe(Object(b.map)((t=>{var e;return{validate:!Boolean(null===(e=t.ignoreParentSettings)||void 0===e?void 0:e.ignoreValidations),lastReloadRequestTime:t.lastReloadRequestTime,existsSelected:t.existsSelected,searchTechnique:t.searchTechnique,dataViewId:t.dataViewId,fieldName:t.fieldName,timeRange:t.timeRange,timeslice:t.timeslice,exclude:t.exclude,filters:t.filters,query:t.query,sort:t.sort}})),Object(b.distinctUntilChanged)(U)),e=this.typeaheadSubject.pipe(Object(b.debounceTime)(100)),i=this.loadMoreSubject.pipe(Object(b.debounceTime)(100));this.subscriptions.add(Object(d.merge)(t,e).pipe(Object(b.skip)(1)).subscribe((()=>{this.runOptionsListQuery()}))),this.subscriptions.add(i.subscribe((t=>{this.runOptionsListQuery(t)}))),this.subscriptions.add(this.getInput$().pipe(Object(b.distinctUntilChanged)(((t,e)=>t.exclude===e.exclude&&t.existsSelected===e.existsSelected&&Object(p.isEqual)(t.selectedOptions,e.selectedOptions)))).subscribe((async({selectedOptions:t})=>{if(!t||Object(p.isEmpty)(t))this.dispatch.clearValidAndInvalidSelections({});else{var e;const{invalidSelections:i}=null!==(e=this.getState().componentState)&&void 0!==e?e:{},s=[],o=[];for(const e of t)null!=i&&i.includes(e)?o.push(e):s.push(e);this.dispatch.setValidAndInvalidSelections({validSelections:s,invalidSelections:o})}const i=await this.buildFilter();this.dispatch.publishFilters(i)})))})),o()(this,"getCurrentDataViewAndField",(async()=>{const{explicitInput:{dataViewId:t,fieldName:e}}=this.getState();if(!this.dataView||this.dataView.id!==t){var i;try{this.dataView=await this.dataViewsService.get(t)}catch(t){this.dispatch.setErrorMessage(t.message)}this.dispatch.setDataViewId(null===(i=this.dataView)||void 0===i?void 0:i.id)}if(this.dataView&&(!this.field||this.field.name!==e)){const t=this.dataView.getFieldByName(e);t?(this.field=t.toSpec(),this.dispatch.setField(this.field)):this.dispatch.setErrorMessage(v.i18n.translate("controls.optionsList.errors.fieldNotFound",{defaultMessage:"Could not locate field: {fieldName}",values:{fieldName:e}}))}return{dataView:this.dataView,field:this.field}})),o()(this,"runOptionsListQuery",(async(t=10)=>{var e;const i=null===(e=this.field)||void 0===e?void 0:e.name,{dataView:s,field:o}=await this.getCurrentDataViewAndField();if(!s||!o)return;i&&o.name!==i&&this.dispatch.setSearchString("");const{componentState:{searchString:n,allowExpensiveQueries:r},explicitInput:{selectedOptions:l,runPastTimeout:c,existsSelected:d,sort:u,searchTechnique:h}}=this.getState();if(this.dispatch.setLoading(!0),n.valid){const{ignoreParentSettings:e,filters:i,query:b,timeRange:g,timeslice:v}=this.getInput();this.abortController&&this.abortController.abort(),this.abortController=new AbortController;const f=void 0!==v?{from:new Date(v[0]).toISOString(),to:new Date(v[1]).toISOString(),mode:"absolute"}:g,x=await this.optionsListService.runOptionsListRequest({sort:u,size:t,field:o,query:b,filters:i,dataView:s,timeRange:f,searchTechnique:h,runPastTimeout:c,selectedOptions:l,allowExpensiveQueries:r,searchString:n.value},this.abortController.signal);if(this.optionsListService.optionsListResponseWasFailure(x)){if("aborted"===x.error)return;return void this.dispatch.setErrorMessage(x.error.message)}const{suggestions:j,invalidSelections:S,totalCardinality:O}=x;if(!l&&!d||Object(p.isEmpty)(S)||null!=e&&e.ignoreValidations)this.dispatch.updateQueryResults({availableOptions:j,invalidSelections:void 0,validSelections:l,totalCardinality:O});else{const t=[],e=[];for(const i of null!=l?l:[])null!=S&&S.includes(i)?e.push(i):t.push(i);this.dispatch.updateQueryResults({availableOptions:j,invalidSelections:e,validSelections:t,totalCardinality:O})}const m=await this.buildFilter();Object(a.batch)((()=>{this.dispatch.setErrorMessage(void 0),this.dispatch.setLoading(!1),this.dispatch.publishFilters(m)}))}else Object(a.batch)((()=>{this.dispatch.setErrorMessage(void 0),this.dispatch.updateQueryResults({availableOptions:[]}),this.dispatch.setLoading(!1)}))})),o()(this,"buildFilter",(async()=>{var t,e;const{validSelections:i}=null!==(t=this.getState().componentState)&&void 0!==t?t:{},{existsSelected:s}=null!==(e=this.getState().explicitInput)&&void 0!==e?e:{},{exclude:o}=this.getInput();if((!i||Object(p.isEmpty)(i))&&!s)return[];const{dataView:n,field:r}=await this.getCurrentDataViewAndField();if(!n||!r)return;let a;return s?a=Object(g.buildExistsFilter)(r,n):i&&(a=1===i.length?Object(g.buildPhraseFilter)(r,i[0],n):Object(g.buildPhrasesFilter)(r,i,n)),a?(a.meta.key=null==r?void 0:r.name,o&&(a.meta.negate=!0),[a]):[]})),o()(this,"reload",(()=>{this.optionsListService.clearOptionsListCache(),this.runOptionsListQuery()})),o()(this,"destroy",(()=>{var t;super.destroy(),this.cleanupStateTools(),null===(t=this.abortController)||void 0===t||t.abort(),this.subscriptions.unsubscribe(),this.node&&r.a.unmountComponentAtNode(this.node)})),o()(this,"render",(t=>{this.node&&r.a.unmountComponentAtNode(this.node),this.node=t,r.a.render(Object(L.jsx)(x.KibanaThemeProvider,{theme$:S.a.getServices().theme.theme$},Object(L.jsx)(X.Provider,{value:this},Object(L.jsx)(D,{typeaheadSubject:this.typeaheadSubject,loadMoreSubject:this.loadMoreSubject}))),t)})),({dataViews:this.dataViewsService,optionsList:this.optionsListService}=S.a.getServices()),this.typeaheadSubject=new d.Subject,this.loadMoreSubject=new d.Subject;const n=t.createReduxEmbeddableTools({embeddable:this,reducers:H,initialComponentState:{popoverOpen:!1,allowExpensiveQueries:!0,searchString:{value:"",valid:!0}}});this.select=n.select,this.getState=n.getState,this.dispatch=n.dispatch,this.cleanupStateTools=n.cleanup,this.onStateChange=n.onStateChange,this.initialize()}clearSelections(){this.dispatch.clearSelections({})}isChained(){return!0}}}}]);