(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[404],{49880:(y,w,n)=>{"use client";const{createElement:M,useEffect:r,useRef:l}=n(96540);function v({html:m,dangerouslySetInnerHTML:p,allowRerender:x,...S}){const d=l(null),u=l(!0);return r(()=>{if(!m||!d.current)throw new Error("html prop can't be null");if(!u.current)return;u.current=!!x;const g=document.createRange().createContextualFragment(m);d.current.innerHTML="",d.current.appendChild(g)},[m,d]),M("div",{...S,ref:d})}y.exports=v},37683:(y,w,n)=>{"use strict";n.r(w),n.d(w,{plugin:()=>O});var M=n(68256),r=n(74848),l=n(22803),v=n(49880),m=n.n(v),p=n(96540),x=n(40996),S=n(84099),d=n(60997),u=n(29675),g=n(3886),T=n(99134),C=n(88023),s=(e=>(e.Code="code",e.HTML="html",e.Markdown="markdown",e))(s||{}),H=(e=>(e.Go="go",e.Html="html",e.Json="json",e.Markdown="markdown",e.Plaintext="plaintext",e.Sql="sql",e.Typescript="typescript",e.Xml="xml",e.Yaml="yaml",e))(H||{});const R="plaintext",h={language:"plaintext",showLineNumbers:!1,showMiniMap:!1},P={content:`# Title

For markdown syntax help: [commonmark.org/help](https://commonmark.org/help/)`,mode:"markdown"};function j(e){const o=(0,u.of)(k),[a,c]=(0,p.useState)({mode:e.options.mode,content:b(e.options,e.replaceVariables,C.Ay.disableSanitizeHtml)});if((0,x.A)(()=>{const{options:t,replaceVariables:f}=e,i=b(t,f,C.Ay.disableSanitizeHtml);(i!==a.content||t.mode!==a.mode)&&c({mode:t.mode,content:i})},100,[e]),a.mode===s.Code){const t=e.options.code??h;return(0,r.jsx)(g.B,{value:a.content,language:t.language??h.language,width:e.width,height:e.height,containerStyles:o.codeEditorContainer,showMiniMap:t.showMiniMap,showLineNumbers:t.showLineNumbers,readOnly:!0},`${t.showLineNumbers}/${t.showMiniMap}`)}return(0,r.jsx)("div",{className:o.containStrict,children:(0,r.jsx)(T.P,{minHeight:"100%",children:(0,r.jsx)(m(),{allowRerender:!0,html:a.content,className:(0,l.cx)("markdown-html",o.markdownHtml),"data-testid":"TextPanel-converted-content"})})})}function b(e,o,a){let{mode:c,content:t}=e;if(t=o(t,{},e.code?.language==="json"?"json":"html"),!t)return" ";switch(c){case s.Code:break;case s.HTML:a||(t=S.sQ.sanitizeTextPanelContent(t));break;case s.Markdown:default:t=(0,d.P)(t,{noSanitize:a})}return t}const k=e=>({codeEditorContainer:(0,l.css)({".monaco-editor .margin, .monaco-editor-background":{backgroundColor:e.colors.background.primary}}),containStrict:(0,l.css)({contain:"strict",height:"100%",display:"flex"}),markdownHtml:(0,l.css)({height:"100%"})});var N=n(70713),B=n(86266);const E=({value:e,onChange:o,context:a})=>{const c=(0,p.useMemo)(()=>a.options?.mode??s.Markdown,[a]),t=(0,u.of)(V),f=()=>a.getSuggestions?a.getSuggestions().map(i=>(0,B.O)(i)):[];return(0,r.jsx)("div",{className:(0,l.cx)(t.editorBox),children:(0,r.jsx)(N.default,{disableHeight:!0,children:({width:i})=>i===0?null:(0,r.jsx)(g.B,{value:e,onBlur:o,onSave:o,language:c,width:i,showMiniMap:!1,showLineNumbers:!1,height:"500px",getSuggestions:f})})})},V=e=>({editorBox:(0,l.css)({label:"editorBox",border:`1px solid ${e.colors.border.medium}`,borderRadius:e.shape.radius.default,margin:e.spacing(.5,0),width:"100%"})}),L=e=>{const o=parseFloat(e.pluginVersion||"6.1");let a=e.options;if(e.hasOwnProperty("content")&&e.hasOwnProperty("mode")){const t=e,f=t.content,i=t.mode;delete t.content,delete t.mode,o<7.1&&(a={content:f,mode:i})}return[s.Code,s.HTML,s.Markdown].find(t=>t===a.mode)||(a={...a,mode:s.Markdown}),a},O=new M.m(j).setPanelOptions(e=>{e.addRadio({path:"mode",name:"Mode",settings:{options:[{value:s.Markdown,label:"Markdown"},{value:s.HTML,label:"HTML"},{value:s.Code,label:"Code"}]},defaultValue:P.mode}).addSelect({path:"code.language",name:"Language",settings:{options:Object.values(H).map(o=>({value:o,label:o}))},defaultValue:h.language,showIf:o=>o.mode===s.Code}).addBooleanSwitch({path:"code.showLineNumbers",name:"Show line numbers",defaultValue:h.showLineNumbers,showIf:o=>o.mode===s.Code}).addBooleanSwitch({path:"code.showMiniMap",name:"Show mini map",defaultValue:h.showMiniMap,showIf:o=>o.mode===s.Code}).addCustomEditor({id:"content",path:"content",name:"Content",editor:E,defaultValue:P.content})}).setMigrationHandler(L)}}]);

//# sourceMappingURL=textPanel.2e0c590c6df274d71296.js.map