/*!
 * 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={1668:(e,t,o)=>{o.r(t),o.d(t,{default:()=>a});var l=o(232);const a=o.n(l)().div`
    padding: 10px 15px 0px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
`},4215:function(e,t,o){var l=this&&this.__createBinding||(Object.create?function(e,t,o,l){void 0===l&&(l=o);var a=Object.getOwnPropertyDescriptor(t,o);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,l,a)}:function(e,t,o,l){void 0===l&&(l=o),e[l]=t[o]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=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)&&l(t,e,o);return a(t,e),t},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=r(o(9497)),u=n(o(232)),d=n(o(4566)),c=n(o(7020)),s=n(o(1551)),f=n(o(6769)),p=o(3563),b=n(o(1668)),m=n(o(4008)),v=(0,u.default)(b.default)`
    background-color: ${d.default.backgroundColorPopup};
`,g=u.default.span`
    font-weight: 500;
    font-size: 13px;
    margin-bottom: 7px;
    background-color: ${d.default.backgroundColorPopup};
`,h=u.default.ul`
    ${p.mixins.reset("block")};
`,y=u.default.li`
    list-style: none;
`,x=u.default.button`
    background-color: ${({selected:e})=>e?d.default.interactiveColorOverlaySelected:d.default.backgroundColorPopup};
    border: none;
    display: flex;
    padding: 7px 60px 7px 15px;
    position: relative;
    width: 100%;
    &:hover {
        cursor: pointer;
        background-color: ${d.default.interactiveColorOverlayHover};
    }
    &:focus {
        box-shadow: ${d.default.focusShadow};
        outline: none;
        z-index: 3;
    }
`,k=u.default.div`
    margin-right: 10px;
    &:hover {
        cursor: pointer;
    }
`,_=u.default.div`
    align-items: center;
    display: flex;
`,C=u.default.span`
    font-size: 13px;
    font-weight: normal;
`,P=({presetName:e,presetLabel:t,presetValue:o,selectedPreset:l,onPopoverClick:a,open:r})=>{const n=(0,i.useRef)(),u=f.default[e],d=i.default.useCallback((e=>{a(e,t,o)}),[a,t,o]);return(0,i.useEffect)((()=>{var e;r&&t===l&&(null===(e=n.current)||void 0===e||e.focus())}),[r,t,l]),i.default.createElement(y,{key:t},i.default.createElement(x,{"data-test":`flyout-preset-option-${t}`,selected:t===l,onClick:d,ref:n},i.default.createElement(k,null,u&&i.default.createElement(u,{"data-test":`icon-label-${t}`})),i.default.createElement(_,null,i.default.createElement(C,null,t))))};t.default=({animation:e=!0,labelPosition:t="top",onChange:o,label:l,labelWidth:a,presets:r,value:n})=>{const[u,d]=i.default.useState(!1),[f,p]=i.default.useState(n||"Select..."),[b,y]=i.default.useState(),x=i.default.useCallback((e=>y(e)),[]),k=i.default.useCallback((()=>d((e=>!e))),[]),_=i.default.useCallback((({event:e,reason:t})=>{if(e&&"clickAway"===t){let t=e.target;for(;t;){if(t===b||void 0===(null==t?void 0:t.parentNode))return;t=t.parentNode}}d(!1),b.focus()}),[b]),C=i.default.useCallback(((e,t,l)=>{p(t),o(e,l),d(!1),b.focus()}),[b,o]),O=`preset-editor-flyout-${l.replace(" ","-")}`;return i.default.createElement(i.default.Fragment,null,i.default.createElement(m.default,{label:l,labelPosition:t,labelWidth:a},i.default.createElement(c.default,{"data-test":"preset-selector-button",label:f,isMenu:!0,elementRef:x,onClick:k,"aria-label":`${l}, ${f}`,"aria-expanded":u,"aria-controls":O})),i.default.createElement(s.default,{id:O,animation:e,"data-test":"preset-editor-flyout",open:u,anchor:b,appearance:"normal",defaultPlacement:"horizontal",onRequestClose:_,role:"dialog"},i.default.createElement(v,{"data-test":"flyout-header"},i.default.createElement(g,{"data-test":"preset-selector-flyout-label"},l)),i.default.createElement(h,null,r.map((e=>i.default.createElement(P,{key:e.label,presetName:e.name,presetLabel:e.label,presetValue:e.value,selectedPreset:f,onPopoverClick:C,open:u}))))))}},4008:function(e,t,o){var l=this&&this.__createBinding||(Object.create?function(e,t,o,l){void 0===l&&(l=o);var a=Object.getOwnPropertyDescriptor(t,o);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,l,a)}:function(e,t,o,l){void 0===l&&(l=o),e[l]=t[o]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=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)&&l(t,e,o);return a(t,e),t},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AdvancedConfigButton=void 0;const i=r(o(9497)),u=r(o(23)),d=n(o(232)),c=o(6649),s=n(o(6643)),f=o(3563),p=n(o(6379)),b=n(o(7020)),m=n(o(9250)),v=(0,d.default)(m.default)`
    margin-top: 0;
    padding: 0;
    // adjust bottom margin according to theme
    margin-bottom: ${f.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;
    }
`,g=(0,d.default)(p.default)`
    display: flex;
    > span {
        display: flex;
        width: 35px;
    }
`,h=(0,d.default)(b.default)`
    color: ${f.variables.contentColorActive} !important;
    &:hover {
        background-color: ${f.variables.interactiveColorOverlayDrag} !important;
    }
`;t.AdvancedConfigButton=({label:e="",onClick:t})=>i.default.createElement(g,{"data-test":`${e}-advanced-config-button-tooltip`,content:(0,c._)("Advanced configurations")},i.default.createElement(h,{"data-test":`${e}-advanced-config-button`,icon:i.default.createElement(s.default,{"data-test":`${e}-advanced-config-button-icon`}),appearance:"subtle",onClick:t}));const y=({"data-test":e,children:o,isAdvanced:l=!1,label:a,hideLabel:r,labelPosition:n,labelWidth:u,tooltip:d,help:c,style:s,error:f,controlsLayout:p,onClick:b,onAdvancedConfigButtonClick:m})=>i.default.createElement(v,{"data-test":null!=e?e:"control-group",label:a,hideLabel:r,labelPosition:n,labelWidth:u,tooltip:d,help:c,error:f,style:s,onClick:b,controlsLayout:p},l?i.Children.toArray(o).filter(Boolean).map((e=>(0,i.cloneElement)(e,{style:{flex:1}}))):o,l?i.default.createElement(t.AdvancedConfigButton,{label:a,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")},1551:e=>{e.exports=require("@splunk/react-ui/Popover")},6379:e=>{e.exports=require("@splunk/react-ui/Tooltip")},3563:e=>{e.exports=require("@splunk/themes")},4566:e=>{e.exports=require("@splunk/themes/variables")},6649:e=>{e.exports=require("@splunk/ui-utils/i18n")},6769:e=>{e.exports=require("@splunk/visualization-icons/PresetIcons")},23:e=>{e.exports=require("prop-types")},9497:e=>{e.exports=require("react")},232:e=>{e.exports=require("styled-components")}},t={};function o(l){var a=t[l];if(void 0!==a)return a.exports;var r=t[l]={exports:{}};return e[l].call(r.exports,r,r.exports,o),r.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 l in t)o.o(t,l)&&!o.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},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 l=o(4215);module.exports=l})();
//# sourceMappingURL=PresetSelectorEditor.js.map