/*!
 * 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={437:(e,t,o)=>{o.r(t),o.d(t,{default:()=>T});var l=o(9497),r=o.n(l),a=o(23),n=o.n(a),i=o(232),u=o.n(i),d=o(4793),s=o(3563),c=o(7408),p=o.n(c),f=o(4082),b=o.n(f),h=o(8987),m=o(6649);const g=require("@splunk/react-ui/ScreenReaderContent");var C=o.n(g);const v=require("@splunk/visualizations-shared/colorConstants");var y=o(3283),x=o(4008),_=o.n(x);const k=u().div`
    max-height: ${s.variables.inputHeight};
    width: 100%;
    min-width: 0;
`,O=u()(b())`
    max-height: ${s.variables.inputHeight};
`,E=({color:e,defaultColor:t,prevColor:o})=>{const l="string"==typeof e?e.trim():e;return(0,y.isColor)(l)||null===l?l:(0,y.isColor)(t)?t:(0,y.isColor)(o)||null===o?o:"transparent"},P=({id:e,showTextInput:t,color:o,palette:a,handleColorChange:n,labelledBy:i,textWidth:u,value:d,name:s,handleTextColorChange:c,handleKeyPress:f,handleBlur:b,isDisabled:g})=>{const v=(0,l.useMemo)((()=>(0,h.createDOMID)("color-code")),[]);return r().createElement(r().Fragment,null,r().createElement("div",null,r().createElement(p(),{key:"color-editor",append:t,value:E({color:o}),palette:a,onChange:n,"data-test":`color-picker-${s}`,disabled:g,hideInput:!0,labelledBy:i})),t&&r().createElement(k,{"data-test":"text-container",textWidth:u},r().createElement(C(),{id:v},(0,m._)("Color code input")),r().createElement(O,{key:d,"data-test":s,prepend:!0,value:null===o?"N/A":o,onChange:c,onKeyDown:f,onBlur:b,disabled:g,style:{height:"32px"},labelledBy:`${i} ${v}`,inputId:e})))};P.propTypes={id:n().string,showTextInput:n().bool,color:n().string,palette:n().arrayOf(n().string),handleColorChange:n().func,labelledBy:n().string,textWidth:n().oneOfType([n().string,n().number]),value:n().string,name:n().string.isRequired,handleTextColorChange:n().func,handleKeyPress:n().func,handleBlur:n().func,isDisabled:n().bool};const M={default:"transparent"},j={},w=({name:e="color",value:t="transparent",label:o="",labelPosition:a="top",labelWidth:n,palette:i=v.COLOR_EDITOR_PALETTE,onChange:u=d.noop,itemSchema:s=M,isDisabled:c=!1,textWidth:p="auto",hideLabel:f=!1,showTextInput:b=!0,style:h=j})=>{const[m,g]=(0,l.useState)(t);(0,l.useEffect)((()=>{g(t)}),[t]);const C=(0,l.useMemo)((()=>(0,d.debounce)(u,250)),[u]),y=(0,l.useCallback)((({value:o})=>{const l=E({color:o,defaultColor:s.default,prevColor:t});g(l),t!==l&&C(null,e,l)}),[C,s.default,e,t]),x=(0,l.useCallback)(((e,{value:t})=>{const o="n/a"===(0,d.toLower)(t).trim()?null:t;g(o)}),[]),k=(0,l.useCallback)((o=>{if("Escape"!==o.key){if("Enter"===o.key&&t!==m){const l=E({color:m,defaultColor:s.default,prevColor:t});g(l),l!==t&&u(o,e,l)}}else g(t)}),[e,m,t,u,s.default]),O=(0,l.useCallback)((o=>{if(m!==t){const l=E({color:m,defaultColor:s.default,prevColor:t});g(l),l!==t&&u(o,e,l)}}),[e,m,t,u,s.default]);return r().createElement(_(),{label:o,labelPosition:a,labelWidth:n,style:h,hideLabel:f,controlsLayout:"fillJoin"},r().createElement(P,{showTextInput:b,color:m,palette:i,handleColorChange:y,name:e,isDisabled:c,textWidth:p,value:t,handleTextColorChange:x,handleKeyPress:k,handleBlur:O}))};w.propTypes={name:n().string.isRequired,value:n().string,itemSchema:n().object,label:n().string.isRequired,hideLabel:n().bool,showTextInput:n().bool,style:n().object,labelPosition:n().oneOf(["top","left"]),labelWidth:n().number,palette:n().arrayOf(n().string),onChange:n().func.isRequired,isDisabled:n().bool,textWidth:n().oneOfType([n().string,n().number])};const T=w},2965:function(e,t,o){var l=this&&this.__createBinding||(Object.create?function(e,t,o,l){void 0===l&&(l=o);var r=Object.getOwnPropertyDescriptor(t,o);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,l,r)}:function(e,t,o,l){void 0===l&&(l=o),e[l]=t[o]}),r=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 o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&l(t,e,o);return r(t,e),t},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ColorFlyoutEditor=void 0;const i=a(o(9497)),u=a(o(23)),d=n(o(232)),s=o(4793),c=n(o(4566)),p=o(6649),f=n(o(8965)),b=o(8987),h=n(o(7020)),m=n(o(1551)),g=o(3850),C=o(6801),v=n(o(4008)),y=n(o(437)),x={padding:"10px"},_={width:"314px"},k=(0,d.default)(h.default)`
    padding: 8px;
    width: 100%;
    min-height: 40px;
    & > span {
        display: grid;
        grid-template-columns: repeat(auto-fill, 26px);
        justify-content: space-evenly;
        grid-gap: 4px;
    }
    background-color: ${c.default.interactiveColorBackground};
`,O=d.default.div`
    width: 26px;
    height: 24px;
    background-color: ${e=>e.color};
    border-radius: 2px;
`,E=d.default.div`
    box-sizing: border-box;
    padding: 8px;
    width: 312px;
    max-height: 484px;
    background-color: ${c.default.backgroundColorPopup};
`,P=d.default.div`
    font-weight: 500;
    font-size: 14px;
    line-height: 20px;
    padding: 8px 8px 0 8px;
    font-family: ${c.default.fontFamily};
    color: ${c.default.contentColorActive};
`,M=d.default.div`
    height: 412px;
    overflow-y: auto;
    padding: 8px 10px;
`;t.ColorFlyoutEditor=({colors:e,CustomColorMatchEditor:t,handleColorRemove:o,handleColorChange:l,flyoutTitle:r,addColorButtonLabel:a,handleColorAdd:n,handleColorMove:u})=>{const d=(0,i.useMemo)((()=>e.map(((e,r)=>{const a=null==t;return i.default.createElement(f.default.Row,{index:r,key:(0,b.createDOMID)(),"data-color":e,onRequestRemove:o},i.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},i.default.createElement(y.default,{value:e,key:(0,b.createDOMID)(),onChange:l(r),hideLabel:!0,label:" ",name:"color",style:{marginBottom:0,marginTop:0,width:a?"100%":32},showTextInput:a}),"function"==typeof t&&i.default.createElement(t,{index:r})))}))),[e,t,o,l]);return i.default.createElement(E,{"data-test":"MultiColorPickerFlyoutContent"},i.default.createElement(P,{"data-test":"MultiColorPickerFlyoutTitle"},r),i.default.createElement(M,null,i.default.createElement(f.default,{addLabel:a,onRequestAdd:n,onRequestMove:u,"data-test":"ColorListEditor"},d)))};const j=({CustomColorMatchEditor:e,onChange:o=s.noop,canReorderColors:l=!0,value:r=g.VIZ_CATEGORICAL,flyoutTitle:a=(0,p._)("Customize colors"),addColorButtonLabel:n=(0,p._)("Add color"),name:u="seriesColors",label:d="",labelPosition:c="top",labelWidth:f,isDisabled:h=!1,hideLabel:C=!0,canAddNewColors:y=!0})=>{const[E,P]=(0,i.useState)(!1),[M,j]=(0,i.useState)(r),w=(0,i.useRef)(null);(0,i.useEffect)((()=>{j(r)}),[r]);const T=(0,i.useCallback)((()=>{const e=new Set(M);let t=g.VIZ_CATEGORICAL.find((t=>!e.has(t)));if(!t){const e=new Map;g.VIZ_CATEGORICAL.forEach((t=>e.set(t,0))),M.forEach((t=>{e.set(t,(e.get(t)||0)+1)}));let o=1/0;g.VIZ_CATEGORICAL.forEach((l=>{const r=e.get(l)||0;r<o&&(o=r,t=l)}))}o(null,u,[...M,t])}),[u,o,M]),q=(0,i.useCallback)((e=>(t,l,r)=>{const a=[...M];a.splice(e,1,r),o(null,u,a)}),[u,o,M]),B=(0,i.useCallback)(((e,{index:t})=>{const l=[...M];l.splice(t,1),o(null,u,l)}),[u,o,M]),A=(0,i.useCallback)((({fromIndex:e,toIndex:t})=>{const l=[...M],r=l[e];l.splice(e,1),l.splice(t,0,r),o(null,u,l)}),[u,o,M]),D=(0,i.useCallback)((({event:e,reason:t})=>{var o;(null===(o=null==e?void 0:e.srcElement)||void 0===o?void 0:o.sortableHandle)||P(!1),"escapeKey"===t&&w.current.focus()}),[]),L=(0,i.useMemo)((()=>M.map((e=>i.default.createElement(O,{color:e,key:(0,b.createDOMID)()})))),[M]),R=(0,i.useCallback)((()=>{P((e=>!e))}),[]);return i.default.createElement(v.default,{label:d,labelPosition:c,labelWidth:f,hideLabel:C,"data-test":"MultiColorPickerEditor"},i.default.createElement(k,{inline:!1,"data-test":"MultiColorPickerButton",appearance:"default",ref:w,onClick:R,disabled:h,style:_},L),i.default.createElement(m.default,{"data-test":"MultiColorPickerFlyout",open:E,anchor:w.current,defaultPlacement:"horizontal",style:x,onRequestClose:D,takeFocus:!0},i.default.createElement(t.ColorFlyoutEditor,{colors:M,CustomColorMatchEditor:e,handleColorRemove:B,handleColorChange:q,handleColorAdd:y?T:void 0,handleColorMove:l?A:void 0,flyoutTitle:a,addColorButtonLabel:n})))};j.propTypes=Object.assign(Object.assign({},C.BaseEditorPropTypes),{canReorderColors:u.bool,canAddNewColors:u.bool,value:u.arrayOf(u.string),flyoutTitle:u.string,addColorButtonLabel:u.string,CustomColorMatchEditor:u.func,hideLabel:u.bool}),t.default=j},6801:function(e,t,o){var l=this&&this.__createBinding||(Object.create?function(e,t,o,l){void 0===l&&(l=o);var r=Object.getOwnPropertyDescriptor(t,o);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,l,r)}:function(e,t,o,l){void 0===l&&(l=o),e[l]=t[o]}),r=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 o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&l(t,e,o);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.BaseEditorPropTypes=void 0;const n=a(o(23));t.BaseEditorPropTypes={name:n.string.isRequired,value:n.oneOfType([n.string,n.object,n.arrayOf(n.string)]),context:n.object,label:n.string,labelPosition:n.oneOf(["top","left"]),labelWidth:n.number,onChange:n.func,isAdvanced:n.bool,isDisabled:n.bool,dataSourceBindings:n.object,options:n.object,optionsSchema:n.object}},4008:function(e,t,o){var l=this&&this.__createBinding||(Object.create?function(e,t,o,l){void 0===l&&(l=o);var r=Object.getOwnPropertyDescriptor(t,o);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[o]}}),Object.defineProperty(e,l,r)}:function(e,t,o,l){void 0===l&&(l=o),e[l]=t[o]}),r=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 o in e)"default"!==o&&Object.prototype.hasOwnProperty.call(e,o)&&l(t,e,o);return r(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=a(o(9497)),u=a(o(23)),d=n(o(232)),s=o(6649),c=n(o(6643)),p=o(3563),f=n(o(6379)),b=n(o(7020)),h=n(o(9250)),m=(0,d.default)(h.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;
    }
`,g=(0,d.default)(f.default)`
    display: flex;
    > span {
        display: flex;
        width: 35px;
    }
`,C=(0,d.default)(b.default)`
    color: ${p.variables.contentColorActive} !important;
    &:hover {
        background-color: ${p.variables.interactiveColorOverlayDrag} !important;
    }
`;t.AdvancedConfigButton=({label:e="",onClick:t})=>i.default.createElement(g,{"data-test":`${e}-advanced-config-button-tooltip`,content:(0,s._)("Advanced configurations")},i.default.createElement(C,{"data-test":`${e}-advanced-config-button`,icon:i.default.createElement(c.default,{"data-test":`${e}-advanced-config-button-icon`}),appearance:"subtle",onClick:t}));const v=({"data-test":e,children:o,isAdvanced:l=!1,label:r,hideLabel:a,labelPosition:n,labelWidth:u,tooltip:d,help:s,style:c,error:p,controlsLayout:f,onClick:b,onAdvancedConfigButtonClick:h})=>i.default.createElement(m,{"data-test":null!=e?e:"control-group",label:r,hideLabel:a,labelPosition:n,labelWidth:u,tooltip:d,help:s,error:p,style:c,onClick:b,controlsLayout:f},l?i.Children.toArray(o).filter(Boolean).map((e=>(0,i.cloneElement)(e,{style:{flex:1}}))):o,l?i.default.createElement(t.AdvancedConfigButton,{label:r,onClick:h}):null);v.propTypes={style:u.object,isAdvanced:u.bool,onClick:u.func,onAdvancedConfigButtonClick:u.func},t.default=v},6643:e=>{e.exports=require("@splunk/react-icons/SlidersDoubleHorizontal")},7020:e=>{e.exports=require("@splunk/react-ui/Button")},7408:e=>{e.exports=require("@splunk/react-ui/Color")},9250:e=>{e.exports=require("@splunk/react-ui/ControlGroup")},8965:e=>{e.exports=require("@splunk/react-ui/FormRows")},1551:e=>{e.exports=require("@splunk/react-ui/Popover")},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")},4566:e=>{e.exports=require("@splunk/themes/variables")},6649:e=>{e.exports=require("@splunk/ui-utils/i18n")},8987:e=>{e.exports=require("@splunk/ui-utils/id")},3850:e=>{e.exports=require("@splunk/visualization-color-palettes")},3283:e=>{e.exports=require("@splunk/visualizations-shared/colorUtils")},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(l){var r=t[l];if(void 0!==r)return r.exports;var a=t[l]={exports:{}};return e[l].call(a.exports,a,a.exports,o),a.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(2965);module.exports=l})();
//# sourceMappingURL=MultiColorPickerEditor.js.map