(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[404],{49880(S,p,o){"use client";const{createElement:M,useEffect:l,useRef:i}=o(96540);function r({html:u,dangerouslySetInnerHTML:y,allowRerender:f,...v}){const d=i(null),w=i(!0);return l(()=>{if(!u||!d.current)throw new Error("html prop can't be null");if(!w.current)return;w.current=!!f;const x=document.createRange().createContextualFragment(u);d.current.innerHTML="",d.current.appendChild(x)},[u,d]),M("div",{...v,ref:d})}S.exports=r},3801(S,p,o){"use strict";o.r(p),o.d(p,{plugin:()=>O});var M=o(45468),l=o(52358),i=o(74848),r=o(22803),u=o(49880),y=o.n(u),f=o(96540),v=o(40996),d=o(55407),w=o(3617),x=o(49439),C=o(23172),k=o(56646),H=o(63075),a=(t=>(t.Code="code",t.HTML="html",t.Markdown="markdown",t))(a||{}),P=(t=>(t.Go="go",t.Html="html",t.Json="json",t.Markdown="markdown",t.Plaintext="plaintext",t.Sql="sql",t.Typescript="typescript",t.Xml="xml",t.Yaml="yaml",t))(P||{});const R="plaintext",h={language:"plaintext",showLineNumbers:!1,showMiniMap:!1},b={content:`# Title

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

//# sourceMappingURL=textPanel.32c255b39fcc2f0a49bb.js.map