/*!
 * 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={527:function(e,t,a){var l=this&&this.__createBinding||(Object.create?function(e,t,a,l){void 0===l&&(l=a);var o=Object.getOwnPropertyDescriptor(t,a);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,l,o)}:function(e,t,a,l){void 0===l&&(l=a),e[l]=t[a]}),o=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 a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&l(t,e,a);return o(t,e),t},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_TEXT_DISPLAY=t.DEFAULT_TEXT_CONFIG=void 0;const i=r(a(9497)),d=n(a(23)),u=n(a(232)),c=a(6649),s=n(a(1551)),f=n(a(1227)),p=n(a(7020)),g=n(a(3625)),m=a(3563),b=a(4008);t.DEFAULT_TEXT_CONFIG=(0,c._)("Select below to override default"),t.DEFAULT_TEXT_DISPLAY=(0,c._)("Config to override default");const v={borderRadius:"4px"},h=Object.assign(Object.assign({},v),{width:"165px",height:"40px",display:"flex",alignItems:"center",justifyContent:"right"}),C={height:"170px"},E={padding:"20px",width:"420px"},x=m.variables.backgroundColorSection,_=m.variables.borderColorWeak,y=u.default.div`
    background-color: ${x};
    padding: 12px 16px;
    border: solid;
    border-width: 1px;
    border-radius: 4px;
    border-color: ${e=>e.hasError?m.variables.accentColorNegative:_};
`,k=u.default.div`
    color: ${m.variables.accentColorNegative};
    font-size: ${m.variables.fontSize};
`,O=u.default.hr`
    width: 100%;
    height: 1px;
    border: 0;
    background-color: ${_};
`,D=u.default.div`
    padding: 0 24px 24px 24px;
    text-align: right;
`,T=u.default.div`
    height: 40px;
    width: calc(100% - 165px);
`,A=u.default.div`
    display: flex;
    width: 100%;
`,P=u.default.div`
    width: 100%;
    height: 40px;
    margin-top: 10px;
    display: flex;
`,$=(0,u.default)(f.default)`
    color: ${e=>e.enableMutedContentColor?m.variables.contentColorMuted:m.variables.contentColorActive};
    margin-bottom: 0;
`,M=(0,u.default)($)`
    width: calc(100% - 40px);
    display: flex;
    align-items: center;
`,q=(0,u.default)(p.default)`
    color: ${e=>e.disabled?m.variables.contentColorDisabled:m.variables.contentColorLink} !important;
    &:hover {
        background-color: ${m.variables.interactiveColorOverlayDrag} !important;
    }
`,j=({optionName:e,text:a,dsl:l,defaultDsl:o,isTextAvailable:r,isDefaultDsl:n,errorMessage:d,isPopoverOpen:u,handleRequestPopoverOpen:f,handleRequestPopoverClose:m,handleRequestReset:b,anchorRef:x,anchor:_,hasError:A})=>{let M=i.default.createElement(i.default.Fragment,null,i.default.createElement($,null,a),i.default.createElement(O,null),i.default.createElement($,{enableMutedContentColor:r},l));return n?M=""===o?i.default.createElement($,null,t.DEFAULT_TEXT_CONFIG):i.default.createElement(i.default.Fragment,null,i.default.createElement($,null,t.DEFAULT_TEXT_CONFIG),i.default.createElement(O,null),i.default.createElement($,{enableMutedContentColor:r},l)):r||(M=i.default.createElement($,null,l)),i.default.createElement(i.default.Fragment,null,i.default.createElement(y,{"data-test":`${e}-advConfig-card-config-mode`,key:`${e}-advConfig-card-config-mode`,hasError:A},M),A&&i.default.createElement(k,{"data-test":`${e}-advConfig-card-config-mode-error`},d),i.default.createElement(P,null,i.default.createElement(T,null),i.default.createElement(q,{"data-test":`${e}-advConfig-card-reset-button`,appearance:"subtle",inline:!1,icon:i.default.createElement(g.default,null),style:h,onClick:f,elementRef:x,disabled:n,label:(0,c._)("Reset to default")}),i.default.createElement(s.default,{"data-test":`${e}-advConfig-card-popover`,style:C,open:u,anchor:_},i.default.createElement("div",{style:E},(0,c._)("You may lose your current configurations to reset to the default configuration.")),i.default.createElement(D,null,i.default.createElement(p.default,{"data-test":`${e}-advConfig-card-popover-cancel-button`,style:v,appearance:"default",onClick:m},(0,c._)("Cancel")),i.default.createElement(p.default,{"data-test":`${e}-advConfig-card-popover-reset-button`,style:v,icon:i.default.createElement(g.default,null),appearance:"destructive",onClick:b},(0,c._)("Reset"))))))},R=({optionName:e,text:a,dsl:l,hasError:o,errorMessage:r,onConfigButtonClick:n})=>i.default.createElement(i.default.Fragment,null,i.default.createElement(y,{"data-test":`${e}-advConfig-card-display-mode`,key:`${e}-advConfig-card-display-mode`,hasError:o},i.default.createElement(A,null,i.default.createElement(M,null,a||l||t.DEFAULT_TEXT_DISPLAY),i.default.createElement(b.AdvancedConfigButton,{label:e,onClick:n}))),o&&i.default.createElement(k,null,r)),w=({optionName:e,mode:t,text:a,dsl:l="",defaultDsl:o="",onResetButtonClick:r,onConfigButtonClick:n,errorMessage:d=""})=>{const[u,c]=(0,i.useState)(!1),[s,f]=(0,i.useState)(),p="config"===t,g=a&&a.length>0,m=o===l,b=d&&d.length>0,v=(0,i.useCallback)((e=>f(e)),[]),h=(0,i.useCallback)((()=>c(!0)),[]),C=(0,i.useCallback)((()=>c(!1)),[]),E=(0,i.useCallback)(((e,t)=>{r(e,t),c(!1)}),[r]);return p?i.default.createElement(j,{optionName:e,text:a,dsl:l,defaultDsl:o,isTextAvailable:g,isDefaultDsl:m,errorMessage:d,isPopoverOpen:u,handleRequestPopoverOpen:h,handleRequestPopoverClose:C,handleRequestReset:E,anchorRef:v,anchor:s,hasError:b}):i.default.createElement(R,{optionName:e,text:a,dsl:l,hasError:b,errorMessage:d,onConfigButtonClick:n})};w.propTypes={optionName:d.default.string.isRequired,mode:d.default.string.isRequired,onResetButtonClick:d.default.func,onConfigButtonClick:d.default.func,text:d.default.string,dsl:d.default.string,defaultDsl:d.default.string,errorMessage:d.default.string},t.default=w},4008:function(e,t,a){var l=this&&this.__createBinding||(Object.create?function(e,t,a,l){void 0===l&&(l=a);var o=Object.getOwnPropertyDescriptor(t,a);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,l,o)}:function(e,t,a,l){void 0===l&&(l=a),e[l]=t[a]}),o=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 a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&l(t,e,a);return o(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(a(9497)),d=r(a(23)),u=n(a(232)),c=a(6649),s=n(a(6643)),f=a(3563),p=n(a(6379)),g=n(a(7020)),m=n(a(9250)),b=(0,u.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;
    }
`,v=(0,u.default)(p.default)`
    display: flex;
    > span {
        display: flex;
        width: 35px;
    }
`,h=(0,u.default)(g.default)`
    color: ${f.variables.contentColorActive} !important;
    &:hover {
        background-color: ${f.variables.interactiveColorOverlayDrag} !important;
    }
`;t.AdvancedConfigButton=({label:e="",onClick:t})=>i.default.createElement(v,{"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 C=({"data-test":e,children:a,isAdvanced:l=!1,label:o,hideLabel:r,labelPosition:n,labelWidth:d,tooltip:u,help:c,style:s,error:f,controlsLayout:p,onClick:g,onAdvancedConfigButtonClick:m})=>i.default.createElement(b,{"data-test":null!=e?e:"control-group",label:o,hideLabel:r,labelPosition:n,labelWidth:d,tooltip:u,help:c,error:f,style:s,onClick:g,controlsLayout:p},l?i.Children.toArray(a).filter(Boolean).map((e=>(0,i.cloneElement)(e,{style:{flex:1}}))):a,l?i.default.createElement(t.AdvancedConfigButton,{label:o,onClick:m}):null);C.propTypes={style:d.object,isAdvanced:d.bool,onClick:d.func,onAdvancedConfigButtonClick:d.func},t.default=C},6643:e=>{e.exports=require("@splunk/react-icons/SlidersDoubleHorizontal")},3625:e=>{e.exports=require("@splunk/react-icons/TrashCanCross")},7020:e=>{e.exports=require("@splunk/react-ui/Button")},9250:e=>{e.exports=require("@splunk/react-ui/ControlGroup")},1227:e=>{e.exports=require("@splunk/react-ui/Paragraph")},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")},6649:e=>{e.exports=require("@splunk/ui-utils/i18n")},23:e=>{e.exports=require("prop-types")},9497:e=>{e.exports=require("react")},232:e=>{e.exports=require("styled-components")}},t={};var a=function a(l){var o=t[l];if(void 0!==o)return o.exports;var r=t[l]={exports:{}};return e[l].call(r.exports,r,r.exports,a),r.exports}(527);module.exports=a})();
//# sourceMappingURL=AdvancedConfigCard.js.map