/*!
 * Copyright © 2018 Splunk Inc.
 * SPLUNK CONFIDENTIAL – Use or disclosure of this material in whole or
 * in part without a valid written license from Splunk Inc. is PROHIBITED.
 */(()=>{"use strict";var e={4008:function(e,t,o){var r=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o);var l=Object.getOwnPropertyDescriptor(t,o);l&&!("get"in l?!t.__esModule:l.writable||l.configurable)||(l={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,r,l)}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),l=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&r(t,e,o);return l(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AdvancedConfigButton=void 0;const i=n(o(9497)),u=n(o(23)),s=a(o(232)),c=o(6649),d=a(o(6643)),p=o(3563),b=a(o(6379)),f=a(o(7020)),v=a(o(9250)),g=(0,s.default)(v.default)`
    margin-top: 0;
    padding: 0;
    // adjust bottom margin according to theme
    margin-bottom: ${p.variables.spacingMedium};
    width: 100%;

    // remove top margin of the first component in control group
    &:first-child {
        margin-top: 0;
    }

    // remove bottom margin of the last component in control group
    &:last-child {
        margin-bottom: 0;
    }
    // remove top padding on label of the first control group
    [data-test='label']:first-of-type {
        padding-top: 0;
    }
`,h=(0,s.default)(b.default)`
    display: flex;
    > span {
        display: flex;
        width: 35px;
    }
`,m=(0,s.default)(f.default)`
    color: ${p.variables.contentColorActive} !important;
    &:hover {
        background-color: ${p.variables.interactiveColorOverlayDrag} !important;
    }
`;t.AdvancedConfigButton=({label:e="",onClick:t})=>i.default.createElement(h,{"data-test":`${e}-advanced-config-button-tooltip`,content:(0,c._)("Advanced configurations")},i.default.createElement(m,{"data-test":`${e}-advanced-config-button`,icon:i.default.createElement(d.default,{"data-test":`${e}-advanced-config-button-icon`}),appearance:"subtle",onClick:t}));const y=({"data-test":e,children:o,isAdvanced:r=!1,label:l,hideLabel:n,labelPosition:a,labelWidth:u,tooltip:s,help:c,style:d,error:p,controlsLayout:b,onClick:f,onAdvancedConfigButtonClick:v})=>i.default.createElement(g,{"data-test":null!=e?e:"control-group",label:l,hideLabel:n,labelPosition:a,labelWidth:u,tooltip:s,help:c,error:p,style:d,onClick:f,controlsLayout:b},r?i.Children.toArray(o).filter(Boolean).map((e=>(0,i.cloneElement)(e,{style:{flex:1}}))):o,r?i.default.createElement(t.AdvancedConfigButton,{label:l,onClick:v}):null);y.propTypes={style:u.object,isAdvanced:u.bool,onClick:u.func,onAdvancedConfigButtonClick:u.func},t.default=y},5862:(e,t)=>{t.editorStyle=void 0,t.editorStyle={width:"100%"}},6195:e=>{e.exports=require("@babel/runtime/helpers/defineProperty")},2649:e=>{e.exports=require("@babel/runtime/helpers/extends")},6643:e=>{e.exports=require("@splunk/react-icons/SlidersDoubleHorizontal")},7020:e=>{e.exports=require("@splunk/react-ui/Button")},9250:e=>{e.exports=require("@splunk/react-ui/ControlGroup")},4082:e=>{e.exports=require("@splunk/react-ui/Text")},6379:e=>{e.exports=require("@splunk/react-ui/Tooltip")},3563:e=>{e.exports=require("@splunk/themes")},6649:e=>{e.exports=require("@splunk/ui-utils/i18n")},4793:e=>{e.exports=require("lodash")},23:e=>{e.exports=require("prop-types")},9497:e=>{e.exports=require("react")},232:e=>{e.exports=require("styled-components")}},t={};function o(r){var l=t[r];if(void 0!==l)return l.exports;var n=t[r]={exports:{}};return e[r].call(n.exports,n,n.exports,o),n.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{o.r(r),o.d(r,{default:()=>C});var e=o(2649),t=o.n(e),l=o(6195),n=o.n(l);const a=require("@babel/runtime/helpers/objectWithoutProperties");var i=o.n(a),u=o(9497),s=o.n(u),c=o(23),d=o.n(c),p=o(4793),b=o(4082),f=o.n(b),v=o(4008),g=o.n(v),h=o(5862);const m=["onChange","name","value","label","labelPosition","labelWidth","labelStyle","hideLabel","isAdvanced","isDisabled","help","tooltip","validate","error"];function y(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,r)}return o}const O={},j=e=>{let{onChange:o,name:r,value:l="",label:a,labelPosition:c="top",labelWidth:d,labelStyle:b=O,hideLabel:v=!1,isAdvanced:j,isDisabled:C=!1,help:x,tooltip:P,validate:k,error:_}=e,q=i()(e,m);const[S,w]=(0,u.useState)(l),A=(0,u.useCallback)((e=>"function"==typeof k?k({value:e}):null),[k]),[D,E]=(0,u.useState)(A(l)),M=(0,u.useMemo)((()=>(0,p.debounce)((e=>{E(A(e))}),250)),[A]);(0,u.useEffect)((()=>()=>{M.cancel()}),[M]),(0,u.useEffect)((()=>{w(l),E(A(l))}),[A,l]);const B=(0,u.useCallback)(((e,{value:t})=>{w(t),M(t)}),[M]),L=(0,u.useCallback)((e=>{const t=S.trim();if(t===l)return;const n=A(t);E(n),n||o(e,r,t)}),[S,l,A,o,r]),W=(0,u.useCallback)((e=>{"Enter"===e.key&&L(e)}),[L]),T=(0,u.useMemo)((()=>a&&""!==a?b:function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?y(Object(o),!0).forEach((function(t){n()(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):y(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}({},b)),[a,b]);return s().createElement(g(),{label:a,labelPosition:c,labelWidth:d,style:T,hideLabel:v,help:x,tooltip:P,error:(null==D?void 0:D.message)||_,isAdvanced:j},s().createElement(f(),t()({key:l,"data-test":r,style:h.editorStyle,onChange:B,onKeyDown:W,onBlur:L,value:S,disabled:C,canClear:!0},q,{error:!!D||_})))};j.propTypes={onChange:d().func.isRequired,name:d().string.isRequired,label:d().string.isRequired,value:d().string,labelPosition:d().oneOf(["top","left"]),labelWidth:d().number,labelStyle:d().object,hideLabel:d().bool,isAdvanced:d().bool,isDisabled:d().bool,validate:d().func,error:d().bool,help:d().string,tooltip:d().string};const C=j})(),module.exports=r})();
//# sourceMappingURL=TextEditor.js.map