/*!
 * 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={3797:(e,t,l)=>{l.d(t,{default:()=>b});var o=l(9497),n=l.n(o),a=l(23),r=l.n(a),i=l(2782),u=l.n(i),s=l(4008),d=l.n(s),c=l(5592);const p=({onChange:e,name:t,value:l=null,labelPosition:a="top",labelWidth:r,label:i,min:s,max:p,step:b,isDisabled:f,help:m,helpFormat:h="under",defaultValue:v})=>{const g=(0,o.useCallback)(((l,o)=>{if(void 0===v&&null==o)return void e(l,t,o);const n=parseFloat(null!=o?o:v);Number.isFinite(n)&&e(l,t,n)}),[v,e,t]),{currentValue:y,handleChange:C,handleBlur:x,handleFocus:k,handleKeyPress:_}=(0,c.useNumberInput)({value:l,min:s,max:p,defaultValue:v,onValueChange:g});return n().createElement(d(),{label:i,labelPosition:a,labelWidth:r,help:"under"===h?m:void 0,tooltip:"tooltip"===h?m:void 0,tooltipDefaultPlacement:"top"},n().createElement(u(),{"data-test":t,min:s,max:p,step:b,onChange:C,onBlur:x,onFocus:k,onKeyDown:_,value:y,disabled:f}))};p.propTypes={onChange:r().func.isRequired,name:r().string.isRequired,label:r().string.isRequired,value:r().number,defaultValue:r().number,labelPosition:r().oneOf(["top","left"]),labelWidth:r().number,min:r().number,max:r().number,step:r().number,isDisabled:r().bool,help:r().string,helpFormat:r().oneOf(["text","under"])};const b=p},5592:(e,t,l)=>{t.useNumberInput=void 0;const o=l(9497),n=l(4793);t.useNumberInput=({min:e=Number.NEGATIVE_INFINITY,max:t=Number.POSITIVE_INFINITY,value:l,defaultValue:a,onValueChange:r=n.noop})=>{const[i,u]=(0,o.useState)(l),s=(0,o.useRef)(!1),d=(0,o.useCallback)(((e,t)=>{null==t&&u(null!=a?a:l),r(e,t)}),[a,r,l]),c=(0,o.useMemo)((()=>(0,n.debounce)(((e,t)=>d(e,t.value)),250)),[d]);(0,o.useLayoutEffect)((()=>{u(l)}),[l]);return{handleChange:(0,o.useCallback)(((e,t)=>{u(t.value),s.current||c(e,t)}),[c]),handleBlur:(0,o.useCallback)((e=>{s.current=!1,l!==i&&d(e,i)}),[i,d,l]),handleFocus:(0,o.useCallback)((()=>{s.current=!0}),[]),handleKeyPress:(0,o.useCallback)((o=>{var a;if("string"==typeof o.key&&"enter"===o.key.toLowerCase()){const r=null===(a=o.target)||void 0===a?void 0:a.value,i=r?Number(r):void 0,u="number"==typeof i?(0,n.clamp)(i,e,t):void 0;l!==u&&d(o,u)}"string"==typeof o.key&&"escape"===o.key.toLowerCase()&&u(l)}),[d,l,e,t]),currentValue:i}}},4008:function(e,t,l){var o=this&&this.__createBinding||(Object.create?function(e,t,l,o){void 0===o&&(o=l);var n=Object.getOwnPropertyDescriptor(t,l);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[l]}}),Object.defineProperty(e,o,n)}:function(e,t,l,o){void 0===o&&(o=l),e[o]=t[l]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var l in e)"default"!==l&&Object.prototype.hasOwnProperty.call(e,l)&&o(t,e,l);return n(t,e),t},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AdvancedConfigButton=void 0;const i=a(l(9497)),u=a(l(23)),s=r(l(232)),d=l(6649),c=r(l(6643)),p=l(3563),b=r(l(6379)),f=r(l(7020)),m=r(l(9250)),h=(0,s.default)(m.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;
    }
`,v=(0,s.default)(b.default)`
    display: flex;
    > span {
        display: flex;
        width: 35px;
    }
`,g=(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(v,{"data-test":`${e}-advanced-config-button-tooltip`,content:(0,d._)("Advanced configurations")},i.default.createElement(g,{"data-test":`${e}-advanced-config-button`,icon:i.default.createElement(c.default,{"data-test":`${e}-advanced-config-button-icon`}),appearance:"subtle",onClick:t}));const y=({"data-test":e,children:l,isAdvanced:o=!1,label:n,hideLabel:a,labelPosition:r,labelWidth:u,tooltip:s,help:d,style:c,error:p,controlsLayout:b,onClick:f,onAdvancedConfigButtonClick:m})=>i.default.createElement(h,{"data-test":null!=e?e:"control-group",label:n,hideLabel:a,labelPosition:r,labelWidth:u,tooltip:s,help:d,error:p,style:c,onClick:f,controlsLayout:b},o?i.Children.toArray(l).filter(Boolean).map((e=>(0,i.cloneElement)(e,{style:{flex:1}}))):l,o?i.default.createElement(t.AdvancedConfigButton,{label:n,onClick:m}):null);y.propTypes={style:u.object,isAdvanced:u.bool,onClick:u.func,onAdvancedConfigButtonClick:u.func},t.default=y},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")},2782:e=>{e.exports=require("@splunk/react-ui/Number")},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 l(o){var n=t[o];if(void 0!==n)return n.exports;var a=t[o]={exports:{}};return e[o].call(a.exports,a,a.exports,l),a.exports}l.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return l.d(t,{a:t}),t},l.d=(e,t)=>{for(var o in t)l.o(t,o)&&!l.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(()=>{l.r(o),l.d(o,{default:()=>u});var e=l(9497),t=l.n(e),n=l(23),a=l.n(n),r=l(3797);const i=({name:l,value:o=0,labelPosition:n="top",labelWidth:a,label:i,onChange:u,isDisabled:s=!1,help:d})=>{const c=(0,e.useCallback)(((e,t,l)=>{u(e,t,null==l?l:l/100)}),[u]);return t().createElement(r.default,{name:l,value:Math.round(100*o),label:i,labelPosition:n,labelWidth:a,onChange:c,min:0,max:100,step:1,disabled:s,help:d})};i.propTypes={onChange:a().func.isRequired,name:a().string.isRequired,label:a().string.isRequired,labelWidth:a().number,value:a().number,labelPosition:a().oneOf(["top","left"]),isDisabled:a().bool,help:a().string};const u=i})(),module.exports=o})();
//# sourceMappingURL=PercentEditor.js.map