/*! 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.stackConnectors_bundle_jsonpfunction=window.stackConnectors_bundle_jsonpfunction||[]).push([[56],{99:function(e,s,n){"use strict";n.r(s),n.d(s,"default",(function(){return r}));var a=n(1),t=n.n(a),o=n(0),l=n(2),c=n(25),i=n(9);const r=({actionConnector:e,actionParams:s,editAction:n,index:r,errors:u,messageVariables:b,defaultMessage:d,useDefaultMessage:m})=>{var g,p;const{subAction:h,subActionParams:x}=s,{channels:j=[],text:f}=null!=x?x:{},{toasts:C}=Object(l.useKibana)().notifications;Object(a.useEffect)((()=>{!m&&f||n("subActionParams",{channels:j,text:d},r)}),[d,m]),h||n("subAction","postMessage",r),x||n("subActionParams",{channels:j,text:f},r);const{response:{channels:k}={},isLoading:A,error:O}=Object(l.useSubAction)({connectorId:null==e?void 0:e.id,subAction:"getChannels"});Object(a.useEffect)((()=>{O&&C.danger({title:o.i18n.translate("xpack.stackConnectors.slack.params.componentError.getChannelsRequestFailed",{defaultMessage:"Failed to retrieve Slack channels list"}),body:O.message})}),[C,O]);const[v,M]=Object(a.useState)((null!=j?j:[]).map((e=>({label:e})))),P=Object(a.useMemo)((()=>{var e;return null!==(e=null==k?void 0:k.filter((e=>e.is_channel)).map((e=>({label:e.name}))))&&void 0!==e?e:[]}),[k]),w=Object(a.useCallback)((e=>{const s=e.map((e=>e.label));M(e),n("subActionParams",{channels:s,text:f},r)}),[n,r,f]);return Object(i.jsx)(t.a.Fragment,null,Object(i.jsx)(c.EuiFormRow,{label:o.i18n.translate("xpack.stackConnectors.slack.params.channelsComboBoxLabel",{defaultMessage:"Channels"}),fullWidth:!0,error:u.channels,isInvalid:(null===(g=u.channels)||void 0===g?void 0:g.length)>0&&0===j.length},Object(i.jsx)(c.EuiComboBox,{noSuggestions:!1,"data-test-subj":"slackChannelsComboBox",isLoading:A,options:P,selectedOptions:v,onChange:w,singleSelection:!0})),Object(i.jsx)(c.EuiSpacer,{size:"m"}),Object(i.jsx)(l.TextAreaWithMessageVariables,{index:r,editAction:(e,s)=>n("subActionParams",{channels:j,text:s},r),messageVariables:b,paramsProperty:"webApi",inputTargetValue:f,label:o.i18n.translate("xpack.stackConnectors.components.slack.messageTextAreaFieldLabel",{defaultMessage:"Message"}),errors:null!==(p=u.text)&&void 0!==p?p:[]}))}}}]);