/*! 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.triggersActionsUi_bundle_jsonpfunction=window.triggersActionsUi_bundle_jsonpfunction||[]).push([[54],{312:function(e,t,s){"use strict";s.r(t);var n=s(2),l=s(33),o=s.n(l),i=s(1),a=s.n(i),c=s(21),u=s(20),r=s(17),d=s(194),b=s(133),j=s(0);const p={display:"inline-block",position:"relative"},O=(e,t)=>Array.from(t.keys()).map((t=>{var s,n;const l=e[t];return{_id:l._id,_index:l._index,data:[{field:u.A,value:l[u.A]},{field:u.O,value:l[u.O]},{field:u.b,value:null!==(s=l[u.b])&&void 0!==s?s:[]},{field:u.gb,value:null!==(n=l[u.gb])&&void 0!==n?n:[]}],ecs:{_id:l._id,_index:l._index}}})),m=({totalItems:e,panels:t,alerts:s,setIsBulkActionsLoading:l,clearSelection:a,refresh:u})=>{const[{rowSelection:m,isAllSelected:f},k]=Object(i.useContext)(b.a),[A,v]=Object(i.useState)(!1),[S]=Object(c.useUiSetting$)("format:number:defaultPattern"),[g,x]=Object(i.useState)(!1);Object(i.useEffect)((()=>{x(f)}),[f]);const C=m.size,y=Object(i.useMemo)((()=>o()(e).format(S)),[S,e]),_=Object(i.useMemo)((()=>o()(C).format(S)),[S,C]),h=Object(i.useCallback)((()=>{v((e=>!e))}),[v]),w=Object(i.useCallback)((()=>{v(!1)}),[v]),B=((e,t,s,n,l,o)=>{const[{isAllSelected:a,rowSelection:c}]=Object(i.useContext)(b.a);return Object(i.useMemo)((()=>{const i=[];for(const u of e){const e=O(l,c);if(u.items){const l=u.items.map((l=>{const i=a&&l.disableOnQuery;return{key:l.key,"data-test-subj":l["data-test-subj"],disabled:i,onClick:l.onClick?()=>{var i;o(),null===(i=l.onClick)||void 0===i||i.call(l,e,a,t,s,n)}:void 0,name:i&&l.disabledLabel?l.disabledLabel:l.label,panel:l.panel}}));i.push({...u,items:l})}else{const l=u.renderContent({alertItems:e,isAllSelected:a,setIsBulkActionsLoading:t,clearSelection:s,refresh:n,closePopoverMenu:o});i.push({...u,content:l})}}return i}),[l,s,a,e,n,c,t,o])})(t,l,a,u,s,Object(i.useCallback)((()=>{A&&v(!1)}),[A])),E=Object(i.useCallback)((()=>{k(g?{action:r.g.clear}:{action:r.g.selectAll})}),[g,k]),M=Object(i.useMemo)((()=>g?d.c(y,e):d.c(_,C)),[g,y,_,e,C]),P=Object(i.useMemo)((()=>g?d.a:d.d(y,e)),[g,y,e]);return Object(j.jsx)("div",{style:p,"data-test-subj":"bulk-actions-button-container","aria-hidden":!0},Object(j.jsx)(n.EuiPopover,{isOpen:A,anchorPosition:"upCenter",panelPaddingSize:"none",button:Object(j.jsx)(n.EuiButtonEmpty,{"aria-label":"selectedShowBulkActions","data-test-subj":"selectedShowBulkActionsButton",size:"xs",iconType:"arrowDown",iconSide:"right",color:"primary",onClick:h},M),closePopover:w},Object(j.jsx)(n.EuiContextMenu,{size:"s",initialPanelId:0,panels:B})),Object(j.jsx)(n.EuiButtonEmpty,{size:"xs","aria-label":"selectAllAlerts","data-test-subj":"selectAllAlertsButton",iconType:g?"cross":"pagesSelect",onClick:E},P))};t.default=a.a.memo(m)}}]);