/*! 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([[26,67],{127:function(e,t,n){"use strict";n.r(t),n.d(t,"default",(function(){return x}));var o=n(1),a=n.n(o),s=n(29),i=n(25),c=n(26),l=n(27),r=n(28);let u,d;!function(e){e.Basic="webhook-authentication-basic",e.SSL="webhook-authentication-ssl"}(u||(u={})),function(e){e.CRT="ssl-crt-key",e.PFX="ssl-pfx"}(d||(d={}));var p=n(68),b=n(9);const E=["post","put"],{emptyField:f,urlField:j}=r.fieldValidators,x=({readOnly:e})=>{var t,n;const{setFieldValue:r,getFieldDefaultValue:x}=Object(c.useFormContext)(),[{config:h,__internal__:k}]=Object(c.useFormData)({watch:["config.hasAuth","config.authType","config.certType","config.verificationMode","__internal__.hasHeaders","__internal__.hasCA"]}),m=!!x("config.headers"),F=!1===x("config.hasAuth")?null:null!==(t=x("config.authType"))&&void 0!==t?t:u.Basic,O=null!==(n=x("config.certType"))&&void 0!==n?n:d.CRT,_=!!x("config.ca")||"none"===x("config.verificationMode"),A=null!=k&&k.hasHeaders,T=null!=k&&k.hasCA,C=null==h?u.Basic:h.authType,L=null==h?d.CRT:h.certType,g=!!x("config.ca");Object(o.useEffect)((()=>r("config.hasAuth",Boolean(C))),[C,r]);const R=Object(b.jsx)(i.EuiFlexGroup,{justifyContent:"spaceBetween"},Object(b.jsx)(i.EuiFlexItem,null,Object(b.jsx)(c.UseField,{path:"secrets.user",config:{label:p.USERNAME_LABEL,validations:[{validator:f(p.USERNAME_REQUIRED)}]},component:l.Field,componentProps:{euiFieldProps:{readOnly:e,"data-test-subj":"webhookUserInput",fullWidth:!0}}})),Object(b.jsx)(i.EuiFlexItem,null,Object(b.jsx)(c.UseField,{path:"secrets.password",config:{label:p.PASSWORD_LABEL,validations:[{validator:f(p.PASSWORD_REQUIRED)}]},component:l.PasswordField,componentProps:{euiFieldProps:{"data-test-subj":"webhookPasswordInput",readOnly:e}}}))),w=Object(b.jsx)(i.EuiFlexGroup,{justifyContent:"spaceBetween"},Object(b.jsx)(i.EuiFlexItem,null,Object(b.jsx)(c.UseField,{path:"secrets.password",config:{label:p.PASSPHRASE_LABEL},component:l.PasswordField,componentProps:{euiFieldProps:{"data-test-subj":"webhookSSLPassphraseInput",readOnly:e}}}),Object(b.jsx)(i.EuiSpacer,{size:"s"}),Object(b.jsx)(c.UseField,{path:"config.certType",defaultValue:O,component:({field:e})=>Object(b.jsx)(i.EuiTabs,{size:"s"},Object(b.jsx)(i.EuiTab,{onClick:()=>e.setValue(d.CRT),isSelected:e.value===d.CRT},p.CERT_TYPE_CRT_KEY),Object(b.jsx)(i.EuiTab,{onClick:()=>e.setValue(d.PFX),isSelected:e.value===d.PFX},p.CERT_TYPE_PFX))}),Object(b.jsx)(i.EuiSpacer,{size:"s"}),L===d.CRT&&Object(b.jsx)(i.EuiFlexGroup,null,Object(b.jsx)(i.EuiFlexItem,null,Object(b.jsx)(c.UseField,{path:"secrets.crt",config:{label:"CRT file",validations:[{validator:f(p.CRT_REQUIRED)}]},component:l.FilePickerField,componentProps:{euiFieldProps:{"data-test-subj":"webhookSSLCRTInput",display:"default",accept:".crt,.cert,.cer,.pem"}}})),Object(b.jsx)(i.EuiFlexItem,null,Object(b.jsx)(c.UseField,{path:"secrets.key",config:{label:"KEY file",validations:[{validator:f(p.KEY_REQUIRED)}]},component:l.FilePickerField,componentProps:{euiFieldProps:{"data-test-subj":"webhookSSLKEYInput",display:"default",accept:".key,.pem"}}}))),L===d.PFX&&Object(b.jsx)(c.UseField,{path:"secrets.pfx",config:{label:"PFX file",validations:[{validator:f(p.PFX_REQUIRED)}]},component:l.FilePickerField,componentProps:{euiFieldProps:{"data-test-subj":"webhookSSLPFXInput",display:"default",accept:".pfx,.p12"}}})));return Object(b.jsx)(a.a.Fragment,null,Object(b.jsx)(c.UseField,{path:"config.hasAuth",component:l.HiddenField}),Object(b.jsx)(i.EuiFlexGroup,{justifyContent:"spaceBetween"},Object(b.jsx)(i.EuiFlexItem,{grow:!1},Object(b.jsx)(c.UseField,{path:"config.method",component:l.SelectField,config:{label:p.METHOD_LABEL,defaultValue:"post",validations:[{validator:f(p.METHOD_REQUIRED)}]},componentProps:{euiFieldProps:{"data-test-subj":"webhookMethodSelect",options:E.map((e=>({text:e.toUpperCase(),value:e}))),fullWidth:!0,readOnly:e}}})),Object(b.jsx)(i.EuiFlexItem,null,Object(b.jsx)(c.UseField,{path:"config.url",config:{label:p.URL_LABEL,validations:[{validator:j(p.URL_INVALID)}]},component:l.Field,componentProps:{euiFieldProps:{readOnly:e,"data-test-subj":"webhookUrlText",fullWidth:!0}}}))),Object(b.jsx)(i.EuiFlexGroup,null,Object(b.jsx)(i.EuiFlexItem,null,Object(b.jsx)(i.EuiSpacer,{size:"m"}),Object(b.jsx)(i.EuiTitle,{size:"xxs"},Object(b.jsx)("h4",null,Object(b.jsx)(s.FormattedMessage,{id:"xpack.stackConnectors.components.webhook.authenticationLabel",defaultMessage:"Authentication"}))),Object(b.jsx)(i.EuiSpacer,{size:"s"}),Object(b.jsx)(c.UseField,{path:"config.authType",defaultValue:F,component:l.CardRadioGroupField,componentProps:{options:[{value:null,label:p.AUTHENTICATION_NONE},{value:u.Basic,label:p.AUTHENTICATION_BASIC,children:C===u.Basic&&R},{value:u.SSL,label:p.AUTHENTICATION_SSL,children:C===u.SSL&&w}]}}))),Object(b.jsx)(i.EuiSpacer,{size:"m"}),Object(b.jsx)(c.UseField,{path:"__internal__.hasHeaders",component:l.ToggleField,config:{defaultValue:m,label:p.ADD_HEADERS_LABEL},componentProps:{euiFieldProps:{disabled:e,"data-test-subj":"webhookViewHeadersSwitch"}}}),A?Object(b.jsx)(a.a.Fragment,null,Object(b.jsx)(i.EuiSpacer,{size:"m"}),Object(b.jsx)(c.UseArray,{path:"config.headers",initialNumberOfItems:1},(({items:t,addItem:n,removeItem:o})=>Object(b.jsx)(a.a.Fragment,null,t.map((t=>Object(b.jsx)(i.EuiFlexGroup,{key:t.id},Object(b.jsx)(i.EuiFlexItem,null,Object(b.jsx)(c.UseField,{path:`${t.path}.key`,config:{label:p.HEADER_KEY_LABEL},component:l.TextField,readDefaultValueOnForm:!t.isNew,componentProps:{euiFieldProps:{readOnly:e}}})),Object(b.jsx)(i.EuiFlexItem,null,Object(b.jsx)(c.UseField,{path:`${t.path}.value`,config:{label:p.HEADER_VALUE_LABEL},component:l.TextField,readDefaultValueOnForm:!t.isNew,componentProps:{euiFieldProps:{readOnly:e}}})),Object(b.jsx)(i.EuiFlexItem,{grow:!1},Object(b.jsx)(i.EuiButtonIcon,{color:"danger",onClick:()=>o(t.id),iconType:"minusInCircle","aria-label":p.REMOVE_ITEM_LABEL,style:{marginTop:"28px"}}))))),Object(b.jsx)(i.EuiSpacer,{size:"m"}),Object(b.jsx)(i.EuiButtonEmpty,{iconType:"plusInCircle",onClick:n},p.ADD_HEADER_BTN),Object(b.jsx)(i.EuiSpacer,null))))):null,Object(b.jsx)(i.EuiSpacer,{size:"m"}),Object(b.jsx)(c.UseField,{path:"__internal__.hasCA",component:l.ToggleField,config:{defaultValue:_,label:p.ADD_CA_LABEL},componentProps:{euiFieldProps:{disabled:e,"data-test-subj":"webhookViewCASwitch"}}}),Object(b.jsx)(i.EuiSpacer,{size:"m"}),T&&Object(b.jsx)(a.a.Fragment,null,Object(b.jsx)(i.EuiFlexGroup,{justifyContent:"spaceBetween"},Object(b.jsx)(i.EuiFlexItem,null,Object(b.jsx)(c.UseField,{path:"config.ca",config:{label:"CA file",validations:[{validator:"none"!==(null==h?void 0:h.verificationMode)?f(p.CA_REQUIRED):()=>{}}]},component:l.FilePickerField,componentProps:{euiFieldProps:{display:"default","data-test-subj":"webhookCAInput",accept:".ca,.pem"}}})),Object(b.jsx)(i.EuiFlexItem,null,Object(b.jsx)(c.UseField,{path:"config.verificationMode",component:l.SelectField,config:{label:p.VERIFICATION_MODE_LABEL,defaultValue:"full",validations:[{validator:f(p.VERIFICATION_MODE_LABEL)}]},componentProps:{euiFieldProps:{"data-test-subj":"webhookVerificationModeSelect",options:[{text:"None",value:"none"},{text:"Certificate",value:"certificate"},{text:"Full",value:"full"}],fullWidth:!0,readOnly:e}}}))),g&&Object(b.jsx)(a.a.Fragment,null,Object(b.jsx)(i.EuiSpacer,{size:"s"}),Object(b.jsx)(i.EuiCallOut,{size:"s",iconType:"document",title:p.EDIT_CA_CALLOUT}))))}},68:function(e,t,n){"use strict";n.r(t),n.d(t,"METHOD_LABEL",(function(){return a})),n.d(t,"HAS_AUTH_LABEL",(function(){return s})),n.d(t,"URL_LABEL",(function(){return i})),n.d(t,"USERNAME_LABEL",(function(){return c})),n.d(t,"PASSWORD_LABEL",(function(){return l})),n.d(t,"PASSPHRASE_LABEL",(function(){return r})),n.d(t,"ADD_HEADERS_LABEL",(function(){return u})),n.d(t,"HEADER_KEY_LABEL",(function(){return d})),n.d(t,"REMOVE_ITEM_LABEL",(function(){return p})),n.d(t,"ADD_HEADER_BTN",(function(){return b})),n.d(t,"HEADER_VALUE_LABEL",(function(){return E})),n.d(t,"URL_INVALID",(function(){return f})),n.d(t,"METHOD_REQUIRED",(function(){return j})),n.d(t,"USERNAME_REQUIRED",(function(){return x})),n.d(t,"BODY_REQUIRED",(function(){return h})),n.d(t,"PASSWORD_REQUIRED",(function(){return k})),n.d(t,"AUTHENTICATION_NONE",(function(){return m})),n.d(t,"AUTHENTICATION_BASIC",(function(){return F})),n.d(t,"AUTHENTICATION_SSL",(function(){return O})),n.d(t,"CERT_TYPE_CRT_KEY",(function(){return _})),n.d(t,"CERT_TYPE_PFX",(function(){return A})),n.d(t,"CRT_REQUIRED",(function(){return T})),n.d(t,"KEY_REQUIRED",(function(){return C})),n.d(t,"PFX_REQUIRED",(function(){return L})),n.d(t,"CA_REQUIRED",(function(){return g})),n.d(t,"ADD_CA_LABEL",(function(){return R})),n.d(t,"VERIFICATION_MODE_LABEL",(function(){return w})),n.d(t,"EDIT_CA_CALLOUT",(function(){return I}));var o=n(0);const a=o.i18n.translate("xpack.stackConnectors.components.webhook.methodTextFieldLabel",{defaultMessage:"Method"}),s=o.i18n.translate("xpack.stackConnectors.components.webhook.hasAuthSwitchLabel",{defaultMessage:"Require authentication for this webhook"}),i=o.i18n.translate("xpack.stackConnectors.components.webhook.urlTextFieldLabel",{defaultMessage:"URL"}),c=o.i18n.translate("xpack.stackConnectors.components.webhook.userTextFieldLabel",{defaultMessage:"Username"}),l=o.i18n.translate("xpack.stackConnectors.components.webhook.passwordTextFieldLabel",{defaultMessage:"Password"}),r=o.i18n.translate("xpack.stackConnectors.components.webhook.passphraseTextFieldLabel",{defaultMessage:"Passphrase"}),u=o.i18n.translate("xpack.stackConnectors.components.webhook.viewHeadersSwitch",{defaultMessage:"Add HTTP header"}),d=o.i18n.translate("xpack.stackConnectors.components.webhook.headerKeyTextFieldLabel",{defaultMessage:"Key"}),p=o.i18n.translate("xpack.stackConnectors.components.webhook.removeHeaderIconLabel",{defaultMessage:"Key"}),b=o.i18n.translate("xpack.stackConnectors.components.webhook.addHeaderButtonLabel",{defaultMessage:"Add header"}),E=o.i18n.translate("xpack.stackConnectors.components.webhook.headerValueTextFieldLabel",{defaultMessage:"Value"}),f=o.i18n.translate("xpack.stackConnectors.components.webhook.error.invalidUrlTextField",{defaultMessage:"URL is invalid."}),j=o.i18n.translate("xpack.stackConnectors.components.webhook.error.requiredMethodText",{defaultMessage:"Method is required."}),x=o.i18n.translate("xpack.stackConnectors.components.webhook.error.requiredAuthUserNameText",{defaultMessage:"Username is required."}),h=o.i18n.translate("xpack.stackConnectors.components.webhook.error.requiredWebhookBodyText",{defaultMessage:"Body is required."}),k=o.i18n.translate("xpack.stackConnectors.components.webhook.error.requiredWebhookPasswordText",{defaultMessage:"Password is required."}),m=o.i18n.translate("xpack.stackConnectors.components.webhook.authenticationMethodNoneLabel",{defaultMessage:"None"}),F=o.i18n.translate("xpack.stackConnectors.components.webhook.authenticationMethodBasicLabel",{defaultMessage:"Basic authentication"}),O=o.i18n.translate("xpack.stackConnectors.components.webhook.authenticationMethodSSLLabel",{defaultMessage:"SSL authentication"}),_=o.i18n.translate("xpack.stackConnectors.components.webhook.certTypeCrtKeyLabel",{defaultMessage:"CRT and KEY file"}),A=o.i18n.translate("xpack.stackConnectors.components.webhook.certTypePfxLabel",{defaultMessage:"PFX file"}),T=o.i18n.translate("xpack.stackConnectors.components.webhook.error.requiredWebhookCRTText",{defaultMessage:"CRT file is required."}),C=o.i18n.translate("xpack.stackConnectors.components.webhook.error.requiredWebhookKEYText",{defaultMessage:"KEY file is required."}),L=o.i18n.translate("xpack.stackConnectors.components.webhook.error.requiredWebhookPFXText",{defaultMessage:"PFX file is required."}),g=o.i18n.translate("xpack.stackConnectors.components.webhook.error.requiredWebhookCAText",{defaultMessage:"CA file is required."}),R=o.i18n.translate("xpack.stackConnectors.components.webhook.viewCertificateAuthoritySwitch",{defaultMessage:"Add certificate authority"}),w=o.i18n.translate("xpack.stackConnectors.components.webhook.verificationModeFieldLabel",{defaultMessage:"Verification mode"}),I=o.i18n.translate("xpack.stackConnectors.components.webhook.editCACallout",{defaultMessage:"This webhook has an existing certificate authority file. Upload a new one to replace it."})}}]);