/*!
 * 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={7970:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return a(t,e),t},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=o(r(9497)),u=o(r(23)),l=i(r(232)),c=i(r(348));r(6265);const d=i(r(1018)),p=r(6649),f=i(r(6447)),m=r(3563),v=r(5135),b=r(962),g=r(137),h=l.default.div`
    font-family: ${m.variables.sansFontFamily};
    .react-mde * {
        font-family: inherit;
    }
    .mde-header,
    .mde-preview,
    .mde-textarea-wrapper textarea.mde-text {
        background-color: ${m.variables.backgroundColorPopup};
    }
    .mde-header .mde-tabs button,
    .mde-header ul.mde-header-group li.mde-header-item button,
    .mde-textarea-wrapper textarea.mde-text {
        color: ${m.variables.contentColorActive};
    }
`,_=l.default.div`
    display: none;
`,y={error:1,warning:2,other:3},x=({onChange:e,defaultErrors:t={},name:r,value:n=""})=>{const[a,o]=s.useState("write"),[i,u]=s.useState(n),[l,m]=s.useState(t),x=s.useCallback((e=>u(e)),[u]),O=s.useCallback((a=>{i!==n&&(e(a,r,i),m(t))}),[i,n,e,r,t]),M=s.useMemo((()=>{let e=null;return Object.values(l).includes("error")?e=s.createElement(b.CSPMessage,{type:"error"}):Object.values(l).includes("warning")&&(e=s.createElement(b.CSPMessage,{type:"warning"})),Object.values(l).includes("other")&&(e=s.createElement(s.Fragment,null,e,s.createElement(f.default,{appearance:"fill",type:"error","data-test":"image-error"},(0,p._)("We can't find an image with this URL. Please enter a new URL")))),e}),[Object.values(l).join("")]),j=s.useMemo((()=>{return s.createElement(_,null,s.createElement(d.default,{text:n,imageRenderer:(e=(e,t)=>{var r,n;(null!==(r=y[l[e]])&&void 0!==r?r:1/0)>(null!==(n=y[t])&&void 0!==n?n:0)&&m(Object.assign(Object.assign({},l),{[e]:t}))},function({src:t,alt:r}){const n=(0,v.useCSPViolationObserver)(t);return s.useEffect((()=>{"none"!==n&&e(t,n)}),[n,t]),s.createElement("img",{src:t,alt:r,onError:()=>{"none"===n&&e(t,"other")}})})}));var e}),[n,l]);return s.createElement(h,{"data-test":r},s.createElement(c.default,{value:i,toolbarCommands:[["header","bold","italic","link","quote","code","image","unordered-list","ordered-list"]],onChange:x,selectedTab:a,onTabChange:o,disablePreview:!0,childProps:{textArea:{onBlur:O}}}),j,M&&s.createElement(g.MessageContainer,null,M))};x.propTypes={onChange:u.func.isRequired,name:u.string.isRequired,value:u.string,defaultErrors:u.string},t.default=x},5135:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.useCSPViolationObserver=void 0;const n=r(9497);t.useCSPViolationObserver=(e,t="none")=>{const[r,a]=(0,n.useState)(t);return(0,n.useEffect)((()=>{const r=t=>{t.blockedURI!==e&&t.blockedURI!==`${e}/`||"enforce"!==t.disposition?t.blockedURI!==e&&t.blockedURI!==`${e}/`||"report"!==t.disposition||a("warning"):a("error")};return document.addEventListener("securitypolicyviolation",r),a(t),()=>{document.removeEventListener("securitypolicyviolation",r)}}),[e]),r}},962:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,a)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return a(t,e),t},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CSPMessage=void 0;const s=o(r(9497)),u=r(6649),l=i(r(6447)),c=i(r(451)),d=i(r(5711));t.CSPMessage=({type:e})=>{const{cspMessageLink:t}=s.useContext(d.default);return s.createElement(l.default,{appearance:"fill",type:e,"data-test":`csp-message-${e}`},(0,u._)("External image URLs must now have their domains listed in the Dashboards Trusted Domains List by working with your administrator. Alternatively, you can upload the image directly into the dashboard. "),t&&s.createElement(c.default,{to:t,openInNewContext:!0},(0,u._)("Learn more")))}},137:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.MessageContainer=void 0;const a=n(r(232));t.MessageContainer=a.default.div`
    margin-top: 10px;
`},451:e=>{e.exports=require("@splunk/react-ui/Link")},1018:e=>{e.exports=require("@splunk/react-ui/Markdown")},6447:e=>{e.exports=require("@splunk/react-ui/Message")},3563:e=>{e.exports=require("@splunk/themes")},6649:e=>{e.exports=require("@splunk/ui-utils/i18n")},5711:e=>{e.exports=require("@splunk/visualization-context/MessageContext")},23:e=>{e.exports=require("prop-types")},9497:e=>{e.exports=require("react")},348:e=>{e.exports=require("react-mde")},6265:e=>{e.exports=require("react-mde/lib/styles/css/react-mde-all.css")},232:e=>{e.exports=require("styled-components")}},t={};var r=function r(n){var a=t[n];if(void 0!==a)return a.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,r),o.exports}(7970);module.exports=r})();
//# sourceMappingURL=MarkdownEditor.js.map