/*! 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([[16,37,58],{112:function(t,n,e){"use strict";function r(t){return t}function u(t){throw new Error("Called `absurd` function which should be uncallable")}Object.defineProperty(n,"__esModule",{value:!0}),n.bindTo_=n.bind_=n.hole=n.pipe=n.untupled=n.tupled=n.absurd=n.decrement=n.increment=n.tuple=n.flow=n.flip=n.constVoid=n.constUndefined=n.constNull=n.constFalse=n.constTrue=n.constant=n.not=n.unsafeCoerce=n.identity=void 0,n.identity=r,n.unsafeCoerce=r,n.not=function(t){return function(n){return!t(n)}},n.constant=function(t){return function(){return t}},n.constTrue=function(){return!0},n.constFalse=function(){return!1},n.constNull=function(){return null},n.constUndefined=function(){},n.constVoid=function(){},n.flip=function(t){return function(n,e){return t(e,n)}},n.flow=function(t,n,e,r,u,i,o,c,a){switch(arguments.length){case 1:return t;case 2:return function(){return n(t.apply(this,arguments))};case 3:return function(){return e(n(t.apply(this,arguments)))};case 4:return function(){return r(e(n(t.apply(this,arguments))))};case 5:return function(){return u(r(e(n(t.apply(this,arguments)))))};case 6:return function(){return i(u(r(e(n(t.apply(this,arguments))))))};case 7:return function(){return o(i(u(r(e(n(t.apply(this,arguments)))))))};case 8:return function(){return c(o(i(u(r(e(n(t.apply(this,arguments))))))))};case 9:return function(){return a(c(o(i(u(r(e(n(t.apply(this,arguments)))))))))}}},n.tuple=function(){for(var t=[],n=0;n{var n;return null==t||null===(n=t.actions)||void 0===n?void 0:n.show},u=t=>{var n;return null==t||null===(n=t.actions)||void 0===n?void 0:n.save},i=t=>{var n;return null==t||null===(n=t.actions)||void 0===n?void 0:n.execute},o=t=>{var n;return null==t||null===(n=t.actions)||void 0===n?void 0:n.delete};function c(t,n){var e,r;return null!==(e=null==n||null===(r=n.authorizedConsumers[t])||void 0===r?void 0:r.all)&&void 0!==e&&e}const a=t=>{var n,e;return null==t||null===(n=t.management)||void 0===n||null===(e=n.security)||void 0===e?void 0:e.api_keys}},115:function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.pipeable=n.pipe=void 0;var r=e(112);n.pipe=r.pipe;n.pipeable=function(t){var n={};return function(t){return"function"==typeof t.map}(t)&&(n.map=function(n){return function(e){return t.map(e,n)}}),function(t){return"function"==typeof t.contramap}(t)&&(n.contramap=function(n){return function(e){return t.contramap(e,n)}}),function(t){return"function"==typeof t.mapWithIndex}(t)&&(n.mapWithIndex=function(n){return function(e){return t.mapWithIndex(e,n)}}),function(t){return"function"==typeof t.ap}(t)&&(n.ap=function(n){return function(e){return t.ap(e,n)}},n.apFirst=function(n){return function(e){return t.ap(t.map(e,(function(t){return function(){return t}})),n)}},n.apSecond=function(n){return function(e){return t.ap(t.map(e,(function(){return function(t){return t}})),n)}}),function(t){return"function"==typeof t.chain}(t)&&(n.chain=function(n){return function(e){return t.chain(e,n)}},n.chainFirst=function(n){return function(e){return t.chain(e,(function(e){return t.map(n(e),(function(){return e}))}))}},n.flatten=function(n){return t.chain(n,r.identity)}),function(t){return"function"==typeof t.bimap}(t)&&(n.bimap=function(n,e){return function(r){return t.bimap(r,n,e)}},n.mapLeft=function(n){return function(e){return t.mapLeft(e,n)}}),function(t){return"function"==typeof t.extend}(t)&&(n.extend=function(n){return function(e){return t.extend(e,n)}},n.duplicate=function(n){return t.extend(n,r.identity)}),function(t){return"function"==typeof t.reduce}(t)&&(n.reduce=function(n,e){return function(r){return t.reduce(r,n,e)}},n.foldMap=function(n){var e=t.foldMap(n);return function(t){return function(n){return e(n,t)}}},n.reduceRight=function(n,e){return function(r){return t.reduceRight(r,n,e)}}),function(t){return"function"==typeof t.reduceWithIndex}(t)&&(n.reduceWithIndex=function(n,e){return function(r){return t.reduceWithIndex(r,n,e)}},n.foldMapWithIndex=function(n){var e=t.foldMapWithIndex(n);return function(t){return function(n){return e(n,t)}}},n.reduceRightWithIndex=function(n,e){return function(r){return t.reduceRightWithIndex(r,n,e)}}),function(t){return"function"==typeof t.alt}(t)&&(n.alt=function(n){return function(e){return t.alt(e,n)}}),function(t){return"function"==typeof t.compact}(t)&&(n.compact=t.compact,n.separate=t.separate),function(t){return"function"==typeof t.filter}(t)&&(n.filter=function(n){return function(e){return t.filter(e,n)}},n.filterMap=function(n){return function(e){return t.filterMap(e,n)}},n.partition=function(n){return function(e){return t.partition(e,n)}},n.partitionMap=function(n){return function(e){return t.partitionMap(e,n)}}),function(t){return"function"==typeof t.filterWithIndex}(t)&&(n.filterWithIndex=function(n){return function(e){return t.filterWithIndex(e,n)}},n.filterMapWithIndex=function(n){return function(e){return t.filterMapWithIndex(e,n)}},n.partitionWithIndex=function(n){return function(e){return t.partitionWithIndex(e,n)}},n.partitionMapWithIndex=function(n){return function(e){return t.partitionMapWithIndex(e,n)}}),function(t){return"function"==typeof t.promap}(t)&&(n.promap=function(n,e){return function(r){return t.promap(r,n,e)}}),function(t){return"function"==typeof t.compose}(t)&&(n.compose=function(n){return function(e){return t.compose(e,n)}}),function(t){return"function"==typeof t.throwError}(t)&&(n.fromOption=function(n){return function(e){return"None"===e._tag?t.throwError(n()):t.of(e.value)}},n.fromEither=function(n){return"Left"===n._tag?t.throwError(n.left):t.of(n.right)},n.fromPredicate=function(n,e){return function(r){return n(r)?t.of(r):t.throwError(e(r))}},n.filterOrElse=function(n,e){return function(r){return t.chain(r,(function(r){return n(r)?t.of(r):t.throwError(e(r))}))}}),n}},122:function(t,n,e){"use strict";e.d(n,"a",(function(){return o}));var r=e(5);const u=({decryption_health:t,execution_health:n,read_health:e,...r})=>({decryptionHealth:t,executionHealth:n,readHealth:e,...r}),i=({is_sufficiently_secure:t,has_permanent_encryption_key:n,alerting_framework_health:e,...r})=>({isSufficientlySecure:t,hasPermanentEncryptionKey:n,alertingFrameworkHealth:e,...r});async function o({http:t}){const n=await t.get(`${r.b}/_health`),e=u(n.alerting_framework_health);return{...i(n),alertingFrameworkHealth:e}}},127:function(t,n,e){"use strict";e.d(n,"a",(function(){return u}));var r=e(26);async function u({http:t}){return await t.get(`${r.a}/_config`)}},156:function(t,n,e){"use strict";e.d(n,"a",(function(){return o}));var r=e(9),u=e(3);const i=t=>({isEnabled:!1,message:u.i18n.translate("xpack.triggersActionsUI.checkRuleTypeEnabled.ruleTypeDisabledByLicenseMessage",{defaultMessage:"This rule type requires a {minimumLicenseRequired} license.",values:{minimumLicenseRequired:Object(r.upperFirst)(t.minimumLicenseRequired)}})});function o(t){return!1===(null==t?void 0:t.enabledInLicense)?i(t):{isEnabled:!0}}},75:function(t,n,e){"use strict";e.r(n),e.d(n,"RuleEdit",(function(){return W})),e.d(n,"default",(function(){return W}));var r=e(1),u=e.n(r),i=e(25),o=e(11),c=e(2),a=e(9),s=e(3),l=e(17),f=e(164),d=e(157),p=e(136),h=e(5),y=e(32);const b=({actions:t,...n})=>({...n,actions:t.map((({group:t,id:n,params:e,frequency:r,uuid:u,alertsFilter:i})=>({group:t,id:n,params:e,frequency:{notify_when:r.notifyWhen,throttle:r.throttle,summary:r.summary},alerts_filter:i,...u&&{uuid:u}})))});var m=e(51),j=e(140),g=e(124),x=e(29),O=e(158),v=e(159),E=e(54),I=e(127),w=e(0);const T=t=>{const n=Object(a.cloneDeep)(Object(a.omit)(t,"notifyWhen","throttle")),e=Boolean(t.notifyWhen),r=Boolean(t.throttle);if(e||r){const r=e?{summary:!1,notifyWhen:t.notifyWhen,throttle:t.notifyWhen===o.RuleNotifyWhen.THROTTLE?t.throttle:null}:{summary:!1,notifyWhen:o.RuleNotifyWhen.THROTTLE,throttle:t.throttle};n.actions=n.actions.map((t=>({...t,frequency:r})))}return n},W=({initialRule:t,onClose:n,reloadRules:e,onSave:o,hideInterval:W,ruleTypeRegistry:_,actionTypeRegistry:F,metadata:M,...R})=>{const S=null!=o?o:e,[{rule:k},C]=Object(r.useReducer)(p.a,{rule:T(t)}),[A,L]=Object(r.useState)(!1),[U,B]=Object(r.useState)(!1),[N,H]=Object(r.useState)(!1),[D,P]=Object(r.useState)(!1),[q,z]=Object(r.useState)([]),[$,V]=Object(r.useState)(!1),[G,J]=Object(r.useState)(R.ruleType),[K,Q]=Object(r.useState)({isUsingSecurity:!1}),[X,Y]=Object(r.useState)(M),Z=Object(r.useCallback)((t=>Y(t)),[]),{http:tt,notifications:{toasts:nt}}=Object(x.b)().services,et=t=>{C({command:{type:"setRule"},payload:{key:"rule",value:t}})},rt=_.get(k.ruleTypeId);Object(r.useEffect)((()=>{(async()=>{Q(await Object(I.a)({http:tt}))})()}),[tt]),Object(r.useEffect)((()=>{(async()=>{V(!0);const t=await Object(d.a)(k.actions,F);z([...t]),V(!1)})()}),[k.actions,F]),Object(r.useEffect)((()=>{R.ruleType||G||(async()=>{const t=await Object(m.a)({http:tt});for(const n of t)rt.id===n.id&&J(n)})()}),[R.ruleType,rt.id,G,tt]);const{ruleBaseErrors:ut,ruleErrors:it,ruleParamsErrors:ot}=Object(d.b)(k,rt,K),ct=()=>{Object(v.a)(k,t,!0)?P(!0):n(l.m.CANCELED,X)};return Object(w.jsx)(c.EuiPortal,null,Object(w.jsx)(c.EuiFlyout,{onClose:ct,"aria-labelledby":"flyoutRuleEditTitle",size:"m",maxWidth:620,ownFocus:!1},Object(w.jsx)(c.EuiFlyoutHeader,{hasBorder:!0},Object(w.jsx)(c.EuiTitle,{size:"s","data-test-subj":"editRuleFlyoutTitle"},Object(w.jsx)("h3",{id:"flyoutTitle"},Object(w.jsx)(i.FormattedMessage,{defaultMessage:"Edit rule",id:"xpack.triggersActionsUI.sections.ruleEdit.flyoutTitle"})))),Object(w.jsx)(g.a,null,Object(w.jsx)(j.a,{inFlyout:!0,waitForCheck:!0},Object(w.jsx)(c.EuiFlyoutBody,null,U&&Object(w.jsx)(u.a.Fragment,null,Object(w.jsx)(c.EuiCallOut,{size:"s",color:"danger",iconType:"rule","data-test-subj":"hasActionsDisabled",title:s.i18n.translate("xpack.triggersActionsUI.sections.ruleEdit.disabledActionsWarningTitle",{defaultMessage:"This rule has actions that are disabled"})}),Object(w.jsx)(c.EuiSpacer,null)),Object(w.jsx)(f.a,{rule:k,config:K,dispatch:C,errors:it,actionTypeRegistry:F,hideInterval:W,ruleTypeRegistry:_,canChangeTrigger:!1,setHasActionsDisabled:B,setHasActionsWithBrokenConnector:H,operation:s.i18n.translate("xpack.triggersActionsUI.sections.ruleEdit.operationName",{defaultMessage:"edit"}),metadata:X,onChangeMetaData:Z})),Object(w.jsx)(c.EuiFlyoutFooter,null,Object(w.jsx)(c.EuiFlexGroup,{justifyContent:"spaceBetween"},Object(w.jsx)(c.EuiFlexItem,{grow:!1},Object(w.jsx)(c.EuiButtonEmpty,{"data-test-subj":"cancelSaveEditedRuleButton",onClick:()=>ct()},s.i18n.translate("xpack.triggersActionsUI.sections.ruleEdit.cancelButtonLabel",{defaultMessage:"Cancel"}))),$?Object(w.jsx)(c.EuiFlexItem,{grow:!1},Object(w.jsx)(c.EuiSpacer,{size:"s"}),Object(w.jsx)(c.EuiLoadingSpinner,{size:"l"})):Object(w.jsx)(u.a.Fragment,null),Object(w.jsx)(c.EuiFlexItem,{grow:!1},Object(w.jsx)(c.EuiFlexGroup,{alignItems:"center"},K.isUsingSecurity&&Object(w.jsx)(c.EuiFlexItem,{grow:!1},Object(w.jsx)(c.EuiIconTip,{type:"warning",position:"top","data-test-subj":"changeInPrivilegesTip",content:s.i18n.translate("xpack.triggersActionsUI.sections.ruleEdit.changeInPrivilegesLabel",{defaultMessage:"Saving this rule will change its privileges and might change its behavior."})})),Object(w.jsx)(c.EuiFlexItem,{grow:!1},Object(w.jsx)(c.EuiButton,{fill:!0,color:"success","data-test-subj":"saveEditedRuleButton",type:"submit",iconType:"check",isLoading:A,onClick:async()=>await async function(){L(!0);try{if($||!Object(d.c)(k,it,q)||N)et(Object(E.a)(k,ot,ut,q));else{const t=await async function({http:t,rule:n,id:e}){const r=await t.put(`${h.b}/rule/${encodeURIComponent(e)}`,{body:JSON.stringify(b(Object(a.pick)(n,["name","tags","schedule","params","actions"])))});return Object(y.b)(r)}({http:tt,rule:k,id:k.id});nt.addSuccess(s.i18n.translate("xpack.triggersActionsUI.sections.ruleEdit.saveSuccessNotificationText",{defaultMessage:"Updated '{ruleName}'",values:{ruleName:t.name}})),n(l.m.SAVED,X),S&&S(X)}}catch(n){var t,e;nt.addDanger(null!==(t=null===(e=n.body)||void 0===e?void 0:e.message)&&void 0!==t?t:s.i18n.translate("xpack.triggersActionsUI.sections.ruleEdit.saveErrorNotificationText",{defaultMessage:"Cannot update rule."}))}L(!1)}()},Object(w.jsx)(i.FormattedMessage,{id:"xpack.triggersActionsUI.sections.ruleEdit.saveButtonLabel",defaultMessage:"Save"}))))))))),D&&Object(w.jsx)(O.a,{onConfirm:()=>{P(!1),n(l.m.CANCELED,X)},onCancel:()=>{P(!1)}})))}}}]);