/*! 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([[22,37,38],{112:function(e,t,n){"use strict";function r(e){return e}function i(e){throw new Error("Called `absurd` function which should be uncallable")}Object.defineProperty(t,"__esModule",{value:!0}),t.bindTo_=t.bind_=t.hole=t.pipe=t.untupled=t.tupled=t.absurd=t.decrement=t.increment=t.tuple=t.flow=t.flip=t.constVoid=t.constUndefined=t.constNull=t.constFalse=t.constTrue=t.constant=t.not=t.unsafeCoerce=t.identity=void 0,t.identity=r,t.unsafeCoerce=r,t.not=function(e){return function(t){return!e(t)}},t.constant=function(e){return function(){return e}},t.constTrue=function(){return!0},t.constFalse=function(){return!1},t.constNull=function(){return null},t.constUndefined=function(){},t.constVoid=function(){},t.flip=function(e){return function(t,n){return e(n,t)}},t.flow=function(e,t,n,r,i,s,o,u,a){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return o(s(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return u(o(s(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return a(u(o(s(i(r(n(t(e.apply(this,arguments)))))))))}}},t.tuple=function(){for(var e=[],t=0;t{const r=[];if(e){const t=e.replace(/([\)\(\<\>\}\{\"\:\\])/gm,"\\$&");r.push(`(message: "${t}" OR error.message: "${t}")`)}if(t&&t.length){const e=function(e){const t={failure:"event.outcome: failure",warning:"kibana.alerting.outcome: warning",success:"kibana.alerting.outcome:success OR (event.outcome: success AND NOT kibana.alerting.outcome:*)",unknown:"event.outcome: unknown"};return`${e.map((e=>t[e])).join(" OR ")}`}(t);e&&r.push(`(${e})`)}return n&&r.push(`kibana.alert.rule.execution.uuid: ${n}`),r}},115:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.pipeable=t.pipe=void 0;var r=n(112);t.pipe=r.pipe;t.pipeable=function(e){var t={};return function(e){return"function"==typeof e.map}(e)&&(t.map=function(t){return function(n){return e.map(n,t)}}),function(e){return"function"==typeof e.contramap}(e)&&(t.contramap=function(t){return function(n){return e.contramap(n,t)}}),function(e){return"function"==typeof e.mapWithIndex}(e)&&(t.mapWithIndex=function(t){return function(n){return e.mapWithIndex(n,t)}}),function(e){return"function"==typeof e.ap}(e)&&(t.ap=function(t){return function(n){return e.ap(n,t)}},t.apFirst=function(t){return function(n){return e.ap(e.map(n,(function(e){return function(){return e}})),t)}},t.apSecond=function(t){return function(n){return e.ap(e.map(n,(function(){return function(e){return e}})),t)}}),function(e){return"function"==typeof e.chain}(e)&&(t.chain=function(t){return function(n){return e.chain(n,t)}},t.chainFirst=function(t){return function(n){return e.chain(n,(function(n){return e.map(t(n),(function(){return n}))}))}},t.flatten=function(t){return e.chain(t,r.identity)}),function(e){return"function"==typeof e.bimap}(e)&&(t.bimap=function(t,n){return function(r){return e.bimap(r,t,n)}},t.mapLeft=function(t){return function(n){return e.mapLeft(n,t)}}),function(e){return"function"==typeof e.extend}(e)&&(t.extend=function(t){return function(n){return e.extend(n,t)}},t.duplicate=function(t){return e.extend(t,r.identity)}),function(e){return"function"==typeof e.reduce}(e)&&(t.reduce=function(t,n){return function(r){return e.reduce(r,t,n)}},t.foldMap=function(t){var n=e.foldMap(t);return function(e){return function(t){return n(t,e)}}},t.reduceRight=function(t,n){return function(r){return e.reduceRight(r,t,n)}}),function(e){return"function"==typeof e.reduceWithIndex}(e)&&(t.reduceWithIndex=function(t,n){return function(r){return e.reduceWithIndex(r,t,n)}},t.foldMapWithIndex=function(t){var n=e.foldMapWithIndex(t);return function(e){return function(t){return n(t,e)}}},t.reduceRightWithIndex=function(t,n){return function(r){return e.reduceRightWithIndex(r,t,n)}}),function(e){return"function"==typeof e.alt}(e)&&(t.alt=function(t){return function(n){return e.alt(n,t)}}),function(e){return"function"==typeof e.compact}(e)&&(t.compact=e.compact,t.separate=e.separate),function(e){return"function"==typeof e.filter}(e)&&(t.filter=function(t){return function(n){return e.filter(n,t)}},t.filterMap=function(t){return function(n){return e.filterMap(n,t)}},t.partition=function(t){return function(n){return e.partition(n,t)}},t.partitionMap=function(t){return function(n){return e.partitionMap(n,t)}}),function(e){return"function"==typeof e.filterWithIndex}(e)&&(t.filterWithIndex=function(t){return function(n){return e.filterWithIndex(n,t)}},t.filterMapWithIndex=function(t){return function(n){return e.filterMapWithIndex(n,t)}},t.partitionWithIndex=function(t){return function(n){return e.partitionWithIndex(n,t)}},t.partitionMapWithIndex=function(t){return function(n){return e.partitionMapWithIndex(n,t)}}),function(e){return"function"==typeof e.promap}(e)&&(t.promap=function(t,n){return function(r){return e.promap(r,t,n)}}),function(e){return"function"==typeof e.compose}(e)&&(t.compose=function(t){return function(n){return e.compose(n,t)}}),function(e){return"function"==typeof e.throwError}(e)&&(t.fromOption=function(t){return function(n){return"None"===n._tag?e.throwError(t()):e.of(n.value)}},t.fromEither=function(t){return"Left"===t._tag?e.throwError(t.left):e.of(t.right)},t.fromPredicate=function(t,n){return function(r){return t(r)?e.of(r):e.throwError(n(r))}},t.filterOrElse=function(t,n){return function(r){return e.chain(r,(function(r){return t(r)?e.of(r):e.throwError(n(r))}))}}),t}},117:function(e,t,n){"use strict";n.d(t,"a",(function(){return $}));var r=n(13),i=n.n(r),s=(n(1),n(122)),o=n(128),u=n(60),a=n(59),c=n(5),l=n(51),d=n(114);const f=({data:e,...t})=>({data:e.map((e=>(e=>{const{duration_ms:t,total_search_duration_ms:n,es_search_duration_ms:r,schedule_delay_ms:i,...s}=e;return{execution_duration:e.duration_ms,total_search_duration:e.total_search_duration_ms,es_search_duration:e.es_search_duration_ms,schedule_delay:e.schedule_delay_ms,...s}})(e))),...t}),p=async({id:e,http:t,dateStart:n,dateEnd:r,outcomeFilter:i,message:s,perPage:o=10,page:u=0,sort:a=[]})=>{const l=a,p=Object(d.a)({outcomeFilter:i,message:s}),h=await t.get(`${c.j}/rule/${e}/_execution_log`,{query:{date_start:n,date_end:r,filter:p.length?p.join(" and "):void 0,per_page:o,page:u+1,sort:l.length?JSON.stringify(l):void 0}});return f(h)},h=async({http:e,dateStart:t,dateEnd:n,outcomeFilter:r,message:i,perPage:s=10,page:o=0,sort:u=[],namespaces:a})=>{const l=u,p=Object(d.a)({outcomeFilter:r,message:i}),h=await e.get(`${c.j}/_global_execution_logs`,{query:{date_start:t,date_end:n,filter:p.length?p.join(" and "):void 0,per_page:s,page:o+1,sort:l.length?JSON.stringify(l):void 0,namespaces:a?JSON.stringify(a):void 0}});return f(h)};async function g({id:e,http:t}){await t.post(`${c.b}/rule/${encodeURIComponent(e)}/_mute_all`)}async function b({id:e,http:t}){await t.post(`${c.b}/rule/${encodeURIComponent(e)}/_unmute_all`)}var m=n(115),j=n(126),y=n(87),x=n(11);const O=({rule_type_state:e,alerts:t,previous_started_at:n,...r})=>({...r,alertTypeState:e,alertInstances:t,previousStartedAt:n}),S=({id:e,http:t,outcomeFilter:n,message:r,dateStart:i,dateEnd:s})=>{const o=Object(d.a)({outcomeFilter:n,message:r});return t.get(`${c.j}/rule/${e}/_execution_kpi`,{query:{filter:o.length?o.join(" and "):void 0,date_start:i,date_end:s}})},_=({id:e,http:t,outcomeFilter:n,message:r,dateStart:i,dateEnd:s,namespaces:o})=>{const u=Object(d.a)({outcomeFilter:n,message:r});return t.get(`${c.j}/_global_execution_kpi`,{query:{filter:u.length?u.join(" and "):void 0,date_start:i,date_end:s,namespaces:o?JSON.stringify(o):o}})},v={timestamp:"@timestamp"},I=({id:e,http:t,dateStart:n,dateEnd:r,runId:i,message:s,perPage:o=10,page:u=0,sort:a,namespace:l,withAuth:f=!1})=>{const p=(e=>e?e.map((e=>{const t=Object.keys(e)[0],n=e[Object.keys(e)[0]];return{[v[t]||t]:{...n}}})):[])(a),h=Object(d.a)({runId:i,message:s});return t.get(`${c.j}/rule/${e}/_action_error_log`,{query:{date_start:n,date_end:r,filter:h.length?h.join(" and "):void 0,per_page:o,page:u+1,sort:p.length?JSON.stringify(p):void 0,namespace:l,with_auth:f}})};var w=n(32),E=n(118),z=n(119),R=n(56),k=n(129),L=n(130),M=n(29),N=n(0);function $(e){return t=>{const{http:n}=Object(M.b)().services;return Object(N.jsx)(e,i()({},t,{muteRules:async e=>async function({ids:e,http:t}){await Promise.all(e.map((e=>g({http:t,id:e}))))}({http:n,ids:e.filter((e=>!U(e))).map((e=>e.id))}),unmuteRules:async e=>async function({ids:e,http:t}){await Promise.all(e.map((e=>b({id:e,http:t}))))}({http:n,ids:e.filter(U).map((e=>e.id))}),muteRule:async e=>{if(!U(e))return await g({http:n,id:e.id})},unmuteRule:async e=>{if(U(e))return await b({http:n,id:e.id})},muteAlertInstance:async(e,t)=>{if(!A(e,t))return async function({id:e,instanceId:t,http:n}){await n.post(`${c.b}/rule/${encodeURIComponent(e)}/alert/${encodeURIComponent(t)}/_mute`)}({http:n,id:e.id,instanceId:t})},unmuteAlertInstance:async(e,t)=>{if(A(e,t))return async function({id:e,instanceId:t,http:n}){await n.post(`${c.b}/rule/${encodeURIComponent(e)}/alert/${encodeURIComponent(t)}/_unmute`)}({http:n,id:e.id,instanceId:t})},loadRule:async e=>Object(u.a)({http:n,ruleId:e}),loadRuleState:async e=>async function({http:e,ruleId:t}){return await e.get(`${c.j}/rule/${t}/state`).then((e=>e?O(e):{})).then((e=>Object(m.pipe)(x.ruleStateSchema.decode(e),Object(j.fold)((e=>{throw new Error(`Rule "${t}" has invalid state`)}),y.identity))))}({http:n,ruleId:e}),loadRuleSummary:async(e,t)=>Object(a.a)({http:n,ruleId:e,numberOfExecutions:t}),loadRuleTypes:async()=>Object(l.a)({http:n}),loadExecutionLogAggregations:async e=>p({...e,http:n}),loadGlobalExecutionLogAggregations:async e=>h({...e,http:n}),loadActionErrorLog:async e=>I({...e,http:n}),loadExecutionKPIAggregations:async e=>S({...e,http:n}),loadGlobalExecutionKPIAggregations:async e=>_({...e,http:n}),resolveRule:async e=>async function({http:e,ruleId:t}){const n=await e.get(`${c.j}/rule/${encodeURIComponent(t)}/_resolve`);return Object(w.a)(n)}({http:n,ruleId:e}),getHealth:async()=>Object(s.a)({http:n}),snoozeRule:async(e,t)=>await Object(E.b)({http:n,id:e.id,snoozeSchedule:t}),bulkSnoozeRules:async e=>await Object(E.a)({http:n,...e}),unsnoozeRule:async(e,t)=>await Object(z.b)({http:n,id:e.id,scheduleIds:t}),bulkUnsnoozeRules:async e=>await Object(z.a)({http:n,...e}),cloneRule:async e=>await Object(o.a)({http:n,ruleId:e}),bulkDeleteRules:async e=>await Object(R.a)({http:n,...e}),bulkEnableRules:async e=>await Object(k.a)({http:n,...e}),bulkDisableRules:async e=>await Object(L.a)({http:n,...e})}))}}function U(e){return!0===e.muteAll}function A(e,t){return e.mutedInstanceIds.findIndex((e=>e===t))>=0}},118:function(e,t,n){"use strict";n.d(t,"b",(function(){return s})),n.d(t,"a",(function(){return o}));var r=n(5);function i({id:e,duration:t,rRule:n}){return{...e?{id:e}:{},duration:t,rRule:{...n,...n.until?{until:n.until.toISOString()}:{}}}}async function s({id:e,snoozeSchedule:t,http:n}){await n.post(`${r.j}/rule/${encodeURIComponent(e)}/_snooze`,{body:JSON.stringify({snooze_schedule:i(t)})})}function o({ids:e,filter:t,snoozeSchedule:n,http:s}){let o;try{o=JSON.stringify({ids:null!=e&&e.length?e:void 0,...t?{filter:JSON.stringify(t)}:{},operations:[{operation:"set",field:"snoozeSchedule",value:i(n)}]})}catch(e){throw new Error(`Unable to parse bulk snooze params: ${e}`)}return s.post(`${r.j}/rules/_bulk_edit`,{body:o})}},119:function(e,t,n){"use strict";n.d(t,"b",(function(){return i})),n.d(t,"a",(function(){return s}));var r=n(5);async function i({id:e,http:t,scheduleIds:n}){await t.post(`${r.j}/rule/${encodeURIComponent(e)}/_unsnooze`,{body:JSON.stringify({schedule_ids:n})})}function s({ids:e,filter:t,scheduleIds:n,http:i}){let s;try{s=JSON.stringify({ids:null!=e&&e.length?e:void 0,...t?{filter:JSON.stringify(t)}:{},operations:[{operation:"delete",field:"snoozeSchedule",value:n}]})}catch(e){throw new Error(`Unable to parse bulk unsnooze params: ${e}`)}return i.post(`${r.j}/rules/_bulk_edit`,{body:s})}},122:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(5);const i=({decryption_health:e,execution_health:t,read_health:n,...r})=>({decryptionHealth:e,executionHealth:t,readHealth:n,...r}),s=({is_sufficiently_secure:e,has_permanent_encryption_key:t,alerting_framework_health:n,...r})=>({isSufficientlySecure:e,hasPermanentEncryptionKey:t,alertingFrameworkHealth:n,...r});async function o({http:e}){const t=await e.get(`${r.b}/_health`),n=i(t.alerting_framework_health);return{...s(t),alertingFrameworkHealth:n}}},128:function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(5),i=n(32);async function s({http:e,ruleId:t}){const n=await e.post(`${r.j}/rule/${encodeURIComponent(t)}/_clone`);return Object(i.b)(n)}},129:function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(5);const i=async({filter:e,ids:t,http:n})=>{try{const i=JSON.stringify({ids:null!=t&&t.length?t:void 0,...e?{filter:JSON.stringify(e)}:{}});return n.patch(`${r.j}/rules/_bulk_enable`,{body:i})}catch(e){throw new Error(`Unable to parse bulk enable params: ${e}`)}}},130:function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(5);const i=async({filter:e,ids:t,http:n})=>{try{const i=JSON.stringify({ids:null!=t&&t.length?t:void 0,...e?{filter:JSON.stringify(e)}:{}});return n.patch(`${r.j}/rules/_bulk_disable`,{body:i})}catch(e){throw new Error(`Unable to parse bulk disable params: ${e}`)}}},85:function(e,t,n){"use strict";n.r(t),n.d(t,"RulesListNotifyBadge",(function(){return I})),n.d(t,"SNOOZE_SUCCESS_MESSAGE",(function(){return p})),n.d(t,"UNSNOOZE_SUCCESS_MESSAGE",(function(){return h})),n.d(t,"SNOOZE_FAILED_MESSAGE",(function(){return g})),n.d(t,"default",(function(){return w}));var r=n(1),i=n(29),s=n(119),o=n(118),u=n(31),a=n.n(u),c=n(2),l=n(3),d=n(137),f=n(125);const p=l.i18n.translate("xpack.triggersActionsUI.sections.rulesList.rulesListSnoozePanel.snoozeSuccess",{defaultMessage:"Rule successfully snoozed"}),h=l.i18n.translate("xpack.triggersActionsUI.sections.rulesList.rulesListSnoozePanel.unsnoozeSuccess",{defaultMessage:"Rule successfully unsnoozed"}),g=l.i18n.translate("xpack.triggersActionsUI.sections.rulesList.rulesListSnoozePanel.snoozeFailed",{defaultMessage:"Unable to change rule snooze settings"}),b=l.i18n.translate("xpack.triggersActionsUI.sections.rulesList.rulesListNotifyBadge.openSnoozePanel",{defaultMessage:"Open snooze panel"}),m=e=>l.i18n.translate("xpack.triggersActionsUI.sections.rulesList.rulesListNotifyBadge.seconds",{defaultMessage:"{value, plural, one {# second} other {# seconds}}",values:{value:e}}),j=e=>l.i18n.translate("xpack.triggersActionsUI.sections.rulesList.rulesListNotifyBadge.minutes",{defaultMessage:"{value, plural, one {# minute} other {# minutes}}",values:{value:e}}),y=e=>l.i18n.translate("xpack.triggersActionsUI.sections.rulesList.rulesListNotifyBadge.hours",{defaultMessage:"{value, plural, one {# hour} other {# hours}}",values:{value:e}}),x=e=>l.i18n.translate("xpack.triggersActionsUI.sections.rulesList.rulesListNotifyBadge.days",{defaultMessage:"{value, plural, one {# day} other {# days}}",values:{value:e}}),O=e=>l.i18n.translate("xpack.triggersActionsUI.sections.rulesList.rulesListNotifyBadge.weeks",{defaultMessage:"{value, plural, one {# week} other {# weeks}}",values:{value:e}}),S=e=>l.i18n.translate("xpack.triggersActionsUI.sections.rulesList.rulesListNotifyBadge.months",{defaultMessage:"{value, plural, one {# month} other {# months}}",values:{value:e}}),_=e=>l.i18n.translate("xpack.triggersActionsUI.sections.rulesList.rulesListNotifyBadge.years",{defaultMessage:"{value, plural, one {# year} other {# years}}",values:{value:e}});var v=n(0);const I=({snoozeSettings:e,loading:t=!1,disabled:n=!1,onRuleChanged:s,snoozeRule:o,unsnoozeRule:u,showOnHover:I=!1,showTooltipInline:w=!1})=>{var E,z,R;const[k,L]=Object(r.useState)(!1),M=t||k,N=Boolean(n)||!e,[$,U]=Object(r.useState)(!1),A=Object(r.useCallback)((()=>U(!0)),[U]),C=Object(r.useCallback)((()=>U(!1)),[U]),T=null==e?void 0:e.isSnoozedUntil,B=null!==(E=null==e?void 0:e.muteAll)&&void 0!==E&&E,F=Object(r.useMemo)((()=>{return!!e&&(t=e,Boolean(t.isSnoozedUntil&&new Date(t.isSnoozedUntil).getTime()>Date.now()||t.muteAll));var t}),[e]),P=Object(r.useMemo)((()=>e?(e=>{if(!e.snoozeSchedule)return null;const t=e.snoozeSchedule.filter((e=>Boolean(e.id)));return 0===t.length?null:t.reduce(((e,t)=>a()(t.rRule.dtstart).isBefore(a()(e.rRule.dtstart))?t:e))})(e):null),[e]),W=Object(r.useMemo)((()=>T?function(e){const t=a.a.duration(a()(e).diff(a()())),n={years:_(t.years()),months:S(t.months()),weeks:O(t.weeks()),days:x(t.days()),hours:y(t.hours()),minutes:j(t.minutes()),seconds:m(t.seconds())},r=Object.entries(n).filter((([e,t])=>""!==t&&t!==`0 ${e}`)).map((([e,t])=>`${t}`)).join(", "),i=r.lastIndexOf(", ");return-1===i?r:r.slice(0,i)+" and"+r.slice(i+1)}(T):void 0),[T]),{notifications:{toasts:D}}=Object(i.b)().services,J=Object(r.useMemo)((()=>!F&&Boolean(P)),[P,F]),H=Object(r.useMemo)((()=>T?Object(d.a)(a()(T)):P?Object(d.a)(a()(P.rRule.dtstart)):""),[T,P]),G=Object(r.useMemo)((()=>B?l.i18n.translate("xpack.triggersActionsUI.sections.rulesList.rulesListNotifyBadge.snoozedIndefinitelyTooltip",{defaultMessage:"Notifications snoozed indefinitely"}):J?l.i18n.translate("xpack.triggersActionsUI.sections.rulesList.rulesListNotifyBadge.snoozeScheduledTooltip",{defaultMessage:"Notifications scheduled to snooze starting {schedStart}",values:{schedStart:Object(d.b)(a()(P.rRule.dtstart))}}):F&&W?Object(v.jsx)(c.EuiToolTip,{title:l.i18n.translate("xpack.triggersActionsUI.sections.rulesList.rulesListNotifyBadge.timeRemaining",{defaultMessage:"Time remaining"}),content:Object(v.jsx)(c.EuiFlexGroup,{direction:"column",gutterSize:"none"},Object(v.jsx)(c.EuiFlexItem,{grow:!1},Object(v.jsx)("span",null,W)),Object(v.jsx)(c.EuiSpacer,null),Object(v.jsx)(c.EuiFlexItem,{grow:!1},Object(v.jsx)("span",null,null==T?void 0:T.toString())))},Object(v.jsx)(c.EuiTextAlign,null,l.i18n.translate("xpack.triggersActionsUI.sections.rulesList.rulesListNotifyBadge.snoozedTooltip",{defaultMessage:"Notifications snoozing for {snoozeTime}",values:{snoozeTime:a()(T).fromNow(!0)}}))):w?l.i18n.translate("xpack.triggersActionsUI.sections.rulesList.rulesListNotifyBadge.noSnoozeAppliedTooltip",{defaultMessage:"Notify when alerts generated"}):""),[B,J,F,w,P,W,T]),q=Object(r.useMemo)((()=>Object(v.jsx)(c.EuiButton,{size:"s",isLoading:M,disabled:M||N,"data-test-subj":"rulesListNotifyBadge-snoozed","aria-label":b,minWidth:85,iconType:"bellSlash",color:"accent",onClick:A},Object(v.jsx)(c.EuiText,{size:"xs"},H))),[H,M,N,A]),K=Object(r.useMemo)((()=>Object(v.jsx)(c.EuiButton,{size:"s",isLoading:M,disabled:M||N,"data-test-subj":"rulesListNotifyBadge-scheduled",minWidth:85,iconType:"calendar",color:"text","aria-label":b,onClick:A},Object(v.jsx)(c.EuiText,{size:"xs"},H))),[H,M,N,A]),Z=Object(r.useMemo)((()=>{const e=I?"ruleSidebarItem__action":"";return Object(v.jsx)(c.EuiButtonIcon,{size:"s",isLoading:M,disabled:M||N,display:M?"base":"empty","data-test-subj":"rulesListNotifyBadge-unsnoozed","aria-label":b,className:$||M?"":e,iconType:"bell",onClick:A})}),[$,M,N,I,A]),V=Object(r.useMemo)((()=>Object(v.jsx)(c.EuiButtonIcon,{size:"s",isLoading:M,disabled:M||N,display:"base","data-test-subj":"rulesListNotifyBadge-snoozedIndefinitely","aria-label":b,iconType:"bellSlash",color:"accent",onClick:A})),[M,N,A]),Y=Object(r.useMemo)((()=>J?K:B?V:F?q:Z),[F,J,B,K,q,V,Z]),Q=Object(r.useMemo)((()=>{const e="string"==typeof n?n:$||w?void 0:W;return Object(v.jsx)(c.EuiToolTip,{title:e?l.i18n.translate("xpack.triggersActionsUI.sections.rulesList.rulesListNotifyBadge.timeRemaining",{defaultMessage:"Time remaining"}):void 0,content:e},Y)}),[n,$,Y,w,W]),X=Object(r.useCallback)((async e=>{try{L(!0),C(),await o(e),await s(),D.addSuccess(p)}catch(e){D.addDanger(g)}finally{L(!1)}}),[L,o,s,D,C]),ee=Object(r.useCallback)((async e=>{try{L(!0),C(),await u(e),await s(),D.addSuccess(h)}catch(e){D.addDanger(g)}finally{L(!1)}}),[L,u,s,D,C]),te=Object(v.jsx)(c.EuiPopover,{"data-test-subj":"rulesListNotifyBadge",isOpen:$&&!N,closePopover:C,button:Q,anchorPosition:"rightCenter",panelStyle:{maxHeight:"100vh",overflowY:"auto"}},Object(v.jsx)(f.a,{snoozeRule:X,unsnoozeRule:ee,interval:Object(f.b)(T),showCancel:F,scheduledSnoozes:null!==(z=null==e?void 0:e.snoozeSchedule)&&void 0!==z?z:[],activeSnoozes:null!==(R=null==e?void 0:e.activeSnoozes)&&void 0!==R?R:[],inPopover:!0}));return w?Object(v.jsx)(c.EuiFlexGroup,{alignItems:"center"},Object(v.jsx)(c.EuiFlexItem,{grow:!1},te),Object(v.jsx)(c.EuiFlexItem,null,Object(v.jsx)(c.EuiText,{color:"subdued",size:"xs"},G))):te},w=({ruleId:e,snoozeSettings:t,loading:n,disabled:u,showTooltipInline:a,showOnHover:c,onRuleChanged:l})=>{const{http:d}=Object(i.b)().services,f=Object(r.useCallback)((t=>e?Object(o.b)({http:d,id:e,snoozeSchedule:t}):Promise.resolve()),[d,e]),p=Object(r.useCallback)((t=>e?Object(s.b)({http:d,id:e,scheduleIds:t}):Promise.resolve()),[d,e]);return Object(v.jsx)(I,{snoozeSettings:t,loading:n,disabled:u,onRuleChanged:l,snoozeRule:f,unsnoozeRule:p,showTooltipInline:a,showOnHover:c})}},96:function(e,t,n){"use strict";n.r(t),n.d(t,"RuleStatusPanel",(function(){return g})),n.d(t,"default",(function(){return b}));var r=n(3),i=n(53),s=n.n(i),o=n(1),u=n(31),a=n.n(u),c=n(25),l=n(2),d=n(7),f=n(117),p=n(85),h=n(0);const g=({rule:e,bulkEnableRules:t,bulkDisableRules:n,snoozeRule:i,unsnoozeRule:u,requestRefresh:f,isEditable:g,healthColor:b,statusMessage:m,loadExecutionLogAggregations:j})=>{const[y,x]=Object(o.useState)(null),O=Object(o.useCallback)((t=>i(e,t)),[e,i]),S=Object(o.useCallback)((t=>u(e,t)),[e,u]),_=Object(o.useMemo)((()=>{var t;return m||Object(h.jsx)(l.EuiStat,{titleSize:"xs",title:"--",description:"",isLoading:!(null!==(t=e.lastRun)&&void 0!==t&&t.outcome||e.nextRun)})}),[e,m]),v=Object(o.useCallback)((async()=>{try{const t=await j({id:e.id,dateStart:s.a.parse("now-24h").format(),dateEnd:s.a.parse("now").format(),page:0,perPage:10});x(t.total)}catch(e){}}),[j,x,e]);return Object(o.useEffect)((()=>{v()}),[v]),Object(h.jsx)(l.EuiPanel,{"data-test-subj":"ruleStatusPanel",hasBorder:!0,paddingSize:"none"},Object(h.jsx)(l.EuiPanel,{hasShadow:!1},Object(h.jsx)(l.EuiFlexGroup,{justifyContent:"flexStart"},Object(h.jsx)(l.EuiFlexItem,{grow:!1},Object(h.jsx)(l.EuiTitle,{size:"xxs"},Object(h.jsx)("h5",null,Object(h.jsx)(c.FormattedMessage,{id:"xpack.triggersActionsUI.sections.ruleDetails.rule.statusPanel.ruleIsEnabledDisabledTitle",defaultMessage:"Rule is"})))),Object(h.jsx)(l.EuiFlexItem,null,Object(h.jsx)(d.g,{disableRule:async()=>{await n({ids:[e.id]})},enableRule:async()=>{await t({ids:[e.id]})},snoozeRule:async()=>{},unsnoozeRule:async()=>{},rule:e,onRuleChanged:f,direction:"row",isEditable:g,hideSnoozeOption:!0}))),Object(h.jsx)(l.EuiSpacer,{size:"s"}),Object(h.jsx)(l.EuiText,{size:"s",color:"subdued","data-test-subj":"ruleStatus-numberOfExecutions"},null!==y&&Object(h.jsx)(c.FormattedMessage,{id:"xpack.triggersActionsUI.sections.ruleDetails.rule.statusPanel.totalExecutions",defaultMessage:"{executions, plural, one {# execution} other {# executions}} in the last 24 hr",values:{executions:y}}))),Object(h.jsx)(l.EuiHorizontalRule,{margin:"none"}),Object(h.jsx)(l.EuiPanel,{hasShadow:!1},Object(h.jsx)(l.EuiFlexGroup,{gutterSize:"none",direction:"row",responsive:!1},Object(h.jsx)(l.EuiFlexItem,null,Object(h.jsx)(l.EuiStat,{"data-test-subj":`ruleStatus-${e.executionStatus.status}`,titleSize:"m",descriptionElement:"strong",titleElement:"h5",title:Object(h.jsx)(l.EuiHealth,{"data-test-subj":`ruleStatus-${e.executionStatus.status}`,textSize:"m",color:b,style:{fontWeight:400}},_),description:r.i18n.translate("xpack.triggersActionsUI.sections.ruleDetails.rulesList.ruleLastExecutionDescription",{defaultMessage:"Last response"})})),Object(h.jsx)(l.EuiFlexItem,{grow:!1},Object(h.jsx)(l.EuiSpacer,{size:"xs"}),Object(h.jsx)(l.EuiText,{color:"subdued",size:"xs"},a()(e.executionStatus.lastExecutionDate).fromNow())))),Object(h.jsx)(l.EuiHorizontalRule,{margin:"none"}),Object(h.jsx)(l.EuiPanel,{hasShadow:!1},Object(h.jsx)(p.RulesListNotifyBadge,{snoozeSettings:e,loading:!e,disabled:!g,onRuleChanged:f,snoozeRule:O,unsnoozeRule:S,showTooltipInline:!0})))},b=Object(f.a)(g)}}]);