/*! 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.cases_bundle_jsonpfunction=window.cases_bundle_jsonpfunction||[]).push([[13],{145:function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));const i={jira:["jira"],resilient:["resilient"],servicenow:["servicenow"],jiraGetFieldsByIssueType:(e,t)=>[...i.jira,e,"getFields",t],jiraGetIssueTypes:e=>[...i.jira,e,"getIssueType"],jiraGetIssues:(e,t)=>[...i.jira,e,"getIssues",t],resilientGetIncidentTypes:e=>[...i.resilient,e,"getIncidentTypes"],resilientGetSeverity:e=>[...i.resilient,e,"getSeverity"],servicenowGetChoices:(e,t)=>[...i.servicenow,e,"getChoices",t]}},147:function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));const i=({connector_id:e,service_message:t,...n})=>({...n,actionId:e,...t&&{serviceMessage:t}})},152:function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var i=n(2),a=n.n(i),s=n(15),l=n(1);const c=l.i18n.translate("xpack.cases.connectors.serviceNow.deprecatedConnectorWarningTitle",{defaultMessage:"This connector type is deprecated"}),o=l.i18n.translate("xpack.cases.connectors.serviceNow.deprecatedConnectorWarningDesc",{defaultMessage:"Update this connector, or create a new one."}),r=({type:e="warning"})=>a.a.createElement(s.EuiCallOut,{title:c,color:e,iconType:"warning","data-test-subj":"deprecated-connector-warning-callout"},o);r.displayName="DeprecatedCallout";const u=a.a.memo(r)},162:function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));const i=e=>e.map((e=>({value:e.value,text:e.label})))},164:function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(43),a=n(44),s=n(145),l=n(78),c=n(147),o=n(151);const r=({http:e,connector:t,fields:n})=>{var r;const{showErrorToast:u}=Object(a.a)();return Object(i.useQuery)(s.a.servicenowGetChoices(null!==(r=null==t?void 0:t.id)&&void 0!==r?r:"",n),(({signal:i})=>{var a;return async function({http:e,connectorId:t,fields:n,signal:i}){const a=await e.post(Object(l.b)(t),{body:JSON.stringify({params:{subAction:"getChoices",subActionParams:{fields:n}}}),signal:i});return Object(c.a)(a)}({http:e,signal:i,connectorId:null!==(a=null==t?void 0:t.id)&&void 0!==a?a:"",fields:n})}),{enabled:Boolean(t),staleTime:6e4,onSuccess:e=>{var t;e.status&&"error"===e.status&&u(new Error(o.d),{title:o.d,toastMessage:`${null!==(t=e.serviceMessage)&&void 0!==t?t:e.message}`})},onError:e=>{u(e,{title:o.d})}})}},327:function(e,t,n){"use strict";n.r(t),n.d(t,"default",(function(){return b}));var i=n(2),a=n.n(i),s=n(15),l=n(129),c=n(131),o=n(151),r=n(5),u=n(164),d=n(162),p=n(152);const m=["urgency","severity","impact","category","subcategory"],g={urgency:[],severity:[],impact:[],category:[],subcategory:[]},b=({connector:e})=>{var t;const n=Object(l.useFormContext)(),[{fields:b}]=Object(l.useFormData)(),{category:f=null}=null!=b?b:{},{http:y}=Object(r.g)().services,v=e.isDeprecated,{isLoading:j,isFetching:E,data:F}=Object(u.a)({http:y,connector:e,fields:m}),h=j||E,I=(null!==(t=null==F?void 0:F.data)&&void 0!==t?t:[]).reduce(((e,t)=>({...e,[t.element]:[...null!=e[t.element]?e[t.element]:[],t]})),g),S=Object(i.useMemo)((()=>Object(d.a)(I.category)),[I.category]),O=Object(i.useMemo)((()=>Object(d.a)(I.urgency)),[I.urgency]),w=Object(i.useMemo)((()=>Object(d.a)(I.severity)),[I.severity]),x=Object(i.useMemo)((()=>Object(d.a)(I.impact)),[I.impact]),G=Object(i.useMemo)((()=>Object(d.a)(I.subcategory.filter((e=>e.dependent_value===f)))),[I.subcategory,f]);return a.a.createElement(a.a.Fragment,null,v&&a.a.createElement(s.EuiFlexGroup,null,a.a.createElement(s.EuiFlexItem,null,a.a.createElement(p.a,null))),a.a.createElement(s.EuiFlexGroup,{"data-test-subj":"connector-fields-sn-itsm",direction:"column",gutterSize:"s"},a.a.createElement(s.EuiFlexGroup,null,a.a.createElement(s.EuiFlexItem,null,a.a.createElement(l.UseField,{path:"fields.urgency",component:c.SelectField,config:{label:o.m},componentProps:{euiFieldProps:{"data-test-subj":"urgencySelect",options:O,hasNoInitialSelection:!0,fullWidth:!0,disabled:h,isLoading:h}}}))),a.a.createElement(s.EuiFlexGroup,null,a.a.createElement(s.EuiFlexItem,null,a.a.createElement(l.UseField,{path:"fields.severity",component:c.SelectField,config:{label:o.j},componentProps:{euiFieldProps:{"data-test-subj":"severitySelect",options:w,hasNoInitialSelection:!0,fullWidth:!0,disabled:h,isLoading:h}}})),a.a.createElement(s.EuiFlexItem,null,a.a.createElement(l.UseField,{path:"fields.impact",component:c.SelectField,config:{label:o.f},componentProps:{euiFieldProps:{"data-test-subj":"impactSelect",options:x,hasNoInitialSelection:!0,fullWidth:!0,disabled:h,isLoading:h}}}))),a.a.createElement(s.EuiFlexGroup,null,a.a.createElement(s.EuiFlexItem,null,a.a.createElement(l.UseField,{path:"fields.category",component:c.SelectField,config:{label:o.c},onChange:()=>{n.setFieldValue("fields.subcategory",null)},componentProps:{euiFieldProps:{"data-test-subj":"categorySelect",options:S,hasNoInitialSelection:!0,fullWidth:!0,disabled:h,isLoading:h}}})),a.a.createElement(s.EuiFlexItem,null,a.a.createElement(l.UseField,{path:"fields.subcategory",component:c.SelectField,config:{label:o.l},componentProps:{euiFieldProps:{"data-test-subj":"subcategorySelect",options:G,hasNoInitialSelection:!0,fullWidth:!0,disabled:h,isLoading:h}}})))))};b.displayName="ServiceNowITSMFields"}}]);