(window.console_bundle_jsonpfunction=window.console_bundle_jsonpfunction||[]).push([[3],{67:function(e,a,t){"use strict";t.r(a),t.d(a,"DevToolsVariablesFlyout",(function(){return v})),t.d(a,"editVariable",(function(){return o})),t.d(a,"deleteVariable",(function(){return u})),t.d(a,"generateEmptyVariableField",(function(){return b})),t.d(a,"isValidVariableName",(function(){return c}));var l=t(23),s=t(3),n=t(26),i=t(25),r=t(9);const o=(e,a,t,l)=>{const s=l.findIndex((e=>e.id===t));return-1===s?l:[...l.slice(0,s),{...l[s],[e]:a},...l.slice(s+1)]},u=(e,a)=>e.filter((e=>e.id!==a)),b=()=>({id:Object(r.v4)(),name:"",value:""}),c=e=>"string"==typeof e&&null!==e.match(/^[a-zA-Z0-9_]+$/g);var d=t(24),j={name:"1ff36h2",styles:"flex-grow:1"};const v=e=>{const[a,t]=Object(l.useState)(e.variables),r=Object(i.useGeneratedHtmlId)({prefix:"__console"}),v=Object(l.useCallback)((()=>{t((e=>[...e,b()]))}),[]),m=Object(l.useCallback)((e=>{const l=u(a,e);t(l)}),[a]),x=Object(l.useCallback)((t=>{t.preventDefault(),e.onSaveVariables(a.filter((({name:e,value:a})=>e.trim()&&a)))}),[e,a]),f=Object(l.useCallback)(((e,l)=>{const{name:s,value:n}=e.target,i=o(s,n,l,a);t(i)}),[a]),g=[{field:"name",name:s.i18n.translate("console.variablesPage.variablesTable.columns.variableHeader",{defaultMessage:"Variable name"}),render:(e,{id:a})=>{const t=!c(e);return Object(d.jsx)(i.EuiFormRow,{isInvalid:t,error:[Object(d.jsx)(n.FormattedMessage,{id:"console.variablesPage.variablesTable.variableInputError.validCharactersText",defaultMessage:"Only letters, numbers and underscores are allowed"})],fullWidth:!0,css:j},Object(d.jsx)(i.EuiFieldText,{"data-test-subj":"variablesNameInput",name:"name",value:e,onChange:e=>f(e,a),isInvalid:t,fullWidth:!0,"aria-label":s.i18n.translate("console.variablesPage.variablesTable.variableInput.ariaLabel",{defaultMessage:"Variable name"})}))}},{field:"value",name:s.i18n.translate("console.variablesPage.variablesTable.columns.valueHeader",{defaultMessage:"Value"}),render:(e,{id:a})=>Object(d.jsx)(i.EuiFieldText,{"data-test-subj":"variablesValueInput",name:"value",onChange:e=>f(e,a),value:e,"aria-label":s.i18n.translate("console.variablesPage.variablesTable.valueInput.ariaLabel",{defaultMessage:"Variable value"})})},{field:"id",name:"",width:"5%",render:e=>Object(d.jsx)(i.EuiButtonIcon,{iconType:"trash","aria-label":"Delete",color:"danger",onClick:()=>m(e),"data-test-subj":"variablesRemoveButton"})}];return Object(d.jsx)(i.EuiFlyout,{onClose:e.onClose},Object(d.jsx)(i.EuiFlyoutHeader,{hasBorder:!0},Object(d.jsx)(i.EuiTitle,null,Object(d.jsx)("h2",null,Object(d.jsx)(n.FormattedMessage,{id:"console.variablesPage.pageTitle",defaultMessage:"Variables"}))),Object(d.jsx)(i.EuiSpacer,{size:"s"}),Object(d.jsx)(i.EuiText,{color:"subdued"},Object(d.jsx)("p",null,Object(d.jsx)(n.FormattedMessage,{id:"console.variablesPage.descriptionText",defaultMessage:"Define variables and use them in your requests in the form of {variable}.",values:{variable:Object(d.jsx)("code",null,Object(d.jsx)(n.FormattedMessage,{id:"console.variablesPage.descriptionText.variableNameText",defaultMessage:"{variableName}",values:{variableName:"${variableName}"}}))}})))),Object(d.jsx)(i.EuiFlyoutBody,null,Object(d.jsx)(i.EuiForm,{id:r,component:"form",onSubmit:x},Object(d.jsx)(i.EuiBasicTable,{items:a,columns:g}),Object(d.jsx)(i.EuiButtonEmpty,{"data-test-subj":"variablesAddButton",iconType:"plus",onClick:v},Object(d.jsx)(n.FormattedMessage,{id:"console.variablesPage.addButtonLabel",defaultMessage:"Add"})))),Object(d.jsx)(i.EuiFlyoutFooter,null,Object(d.jsx)(i.EuiFlexGroup,{justifyContent:"flexEnd"},Object(d.jsx)(i.EuiFlexItem,{grow:!1},Object(d.jsx)(i.EuiButtonEmpty,{"data-test-subj":"variablesCancelButton",onClick:e.onClose},Object(d.jsx)(n.FormattedMessage,{id:"console.variablesPage.cancelButtonLabel",defaultMessage:"Cancel"}))),Object(d.jsx)(i.EuiFlexItem,{grow:!1},Object(d.jsx)(i.EuiButton,{fill:!0,"data-test-subj":"variablesSaveButton",type:"submit",form:r},Object(d.jsx)(n.FormattedMessage,{id:"console.variablesPage.saveButtonLabel",defaultMessage:"Save"}))))))}}}]);