"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8926],{16556:(Ft,ne,R)=>{R.r(ne),R.d(ne,{ReactMonacoEditor:()=>Bt});function ye(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function oe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function ie(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?oe(Object(r),!0).forEach(function(n){ye(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):oe(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function we(e,t){if(e==null)return{};var r={},n=Object.keys(e),o,i;for(i=0;i<n.length;i++)o=n[i],!(t.indexOf(o)>=0)&&(r[o]=e[o]);return r}function Oe(e,t){if(e==null)return{};var r=we(e,t),n,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)n=i[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function je(e,t){return Me(e)||Ee(e,t)||Se(e,t)||Pe()}function Me(e){if(Array.isArray(e))return e}function Ee(e,t){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(e)))){var r=[],n=!0,o=!1,i=void 0;try{for(var u=e[Symbol.iterator](),s;!(n=(s=u.next()).done)&&(r.push(s.value),!(t&&r.length===t));n=!0);}catch(d){o=!0,i=d}finally{try{!n&&u.return!=null&&u.return()}finally{if(o)throw i}}return r}}function Se(e,t){if(e){if(typeof e=="string")return ae(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ae(e,t)}}function ae(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Pe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ce(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ue(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function le(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ue(Object(r),!0).forEach(function(n){Ce(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ue(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Re(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(n){return t.reduceRight(function(o,i){return i(o)},n)}}function I(e){return function t(){for(var r=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=e.length?e.apply(this,o):function(){for(var u=arguments.length,s=new Array(u),d=0;d<u;d++)s[d]=arguments[d];return t.apply(r,[].concat(o,s))}}}function V(e){return{}.toString.call(e).includes("Object")}function Te(e){return!Object.keys(e).length}function T(e){return typeof e=="function"}function Ae(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Le(e,t){return V(t)||j("changeType"),Object.keys(t).some(function(r){return!Ae(e,r)})&&j("changeField"),t}function ke(e){T(e)||j("selectorType")}function De(e){T(e)||V(e)||j("handlerType"),V(e)&&Object.values(e).some(function(t){return!T(t)})&&j("handlersType")}function ze(e){e||j("initialIsRequired"),V(e)||j("initialType"),Te(e)&&j("initialContent")}function Ne(e,t){throw new Error(e[t]||e.default)}var Ve={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},j=I(Ne)(Ve),x={changes:Le,selector:ke,handler:De,initial:ze};function xe(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};x.initial(e),x.handler(t);var r={current:e},n=I(Fe)(r,t),o=I(_e)(r),i=I(x.changes)(e),u=I(Be)(r);function s(){var b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(P){return P};return x.selector(b),b(r.current)}function d(b){Re(n,o,i,u)(b)}return[s,d]}function Be(e,t){return T(t)?t(e.current):t}function _e(e,t){return e.current=le(le({},e.current),t),t}function Fe(e,t,r){return T(t)?t(e.current):Object.keys(r).forEach(function(n){var o;return(o=t[n])===null||o===void 0?void 0:o.call(t,e.current[n])}),r}var Ue={create:xe};const He=Ue;var $e={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs"}};const We=$e;function qe(e){return function t(){for(var r=this,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return o.length>=e.length?e.apply(this,o):function(){for(var u=arguments.length,s=new Array(u),d=0;d<u;d++)s[d]=arguments[d];return t.apply(r,[].concat(o,s))}}}const Ge=qe;function Ye(e){return{}.toString.call(e).includes("Object")}const Je=Ye;function Ke(e){return e||fe("configIsRequired"),Je(e)||fe("configType"),e.urls?(Qe(),{paths:{vs:e.urls.monacoBase}}):e}function Qe(){console.warn(se.deprecation)}function Xe(e,t){throw new Error(e[t]||e.default)}var se={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
    You are using deprecated way of configuration.

    Instead of using
      monaco.config({ urls: { monacoBase: '...' } })
    use
      monaco.config({ paths: { vs: '...' } })

    For more please check the link https://github.com/suren-atoyan/monaco-loader#config
  `},fe=Ge(Xe)(se),Ze={config:Ke};const et=Ze;var tt=function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return function(o){return r.reduceRight(function(i,u){return u(i)},o)}};const rt=tt;function de(e,t){return Object.keys(t).forEach(function(r){t[r]instanceof Object&&e[r]&&Object.assign(t[r],de(e[r],t[r]))}),ie(ie({},e),t)}const nt=de;var ot={type:"cancelation",msg:"operation is manually canceled"};function it(e){var t=!1,r=new Promise(function(n,o){e.then(function(i){return t?o(ot):n(i)}),e.catch(o)});return r.cancel=function(){return t=!0},r}const H=it;var at=He.create({config:We,isInitialized:!1,resolve:null,reject:null,monaco:null}),ge=je(at,2),A=ge[0],B=ge[1];function ct(e){var t=et.config(e),r=t.monaco,n=Oe(t,["monaco"]);B(function(o){return{config:nt(o.config,n),monaco:r}})}function ut(){var e=A(function(t){var r=t.monaco,n=t.isInitialized,o=t.resolve;return{monaco:r,isInitialized:n,resolve:o}});if(!e.isInitialized){if(B({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),H($);if(window.monaco&&window.monaco.editor)return pe(window.monaco),e.resolve(window.monaco),H($);rt(lt,ft)(dt)}return H($)}function lt(e){return document.body.appendChild(e)}function st(e){var t=document.createElement("script");return e&&(t.src=e),t}function ft(e){var t=A(function(n){var o=n.config,i=n.reject;return{config:o,reject:i}}),r=st("".concat(t.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=t.reject,r}function dt(){var e=A(function(r){var n=r.config,o=r.resolve,i=r.reject;return{config:n,resolve:o,reject:i}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(r){pe(r),e.resolve(r)},function(r){e.reject(r)})}function pe(e){A().monaco||B({monaco:e})}function gt(){return A(function(e){var t=e.monaco;return t})}var $=new Promise(function(e,t){return B({resolve:e,reject:t})}),pt={config:ct,init:ut,__getMonacoInstance:gt};const W=pt;var a=R(96540),vt={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},q=vt,ht={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},mt=ht;function bt({children:e}){return a.createElement("div",{style:mt.container},e)}var yt=bt,wt=yt;function Ot({width:e,height:t,isEditorReady:r,loading:n,_ref:o,className:i,wrapperProps:u}){return a.createElement("section",{style:{...q.wrapper,width:e,height:t},...u},!r&&a.createElement(wt,null,n),a.createElement("div",{ref:o,style:{...q.fullWidth,...!r&&q.hide},className:i}))}var jt=Ot,ve=(0,a.memo)(jt);function Mt(e){(0,a.useEffect)(e,[])}var G=Mt;function Et(e,t,r=!0){let n=(0,a.useRef)(!0);(0,a.useEffect)(n.current||!r?()=>{n.current=!1}:e,t)}var w=Et;function L(){}function S(e,t,r,n){return St(e,n)||Pt(e,t,r,n)}function St(e,t){return e.editor.getModel(he(e,t))}function Pt(e,t,r,n){return e.editor.createModel(t,r,n?he(e,n):void 0)}function he(e,t){return e.Uri.parse(t)}function Ct({original:e,modified:t,language:r,originalLanguage:n,modifiedLanguage:o,originalModelPath:i,modifiedModelPath:u,keepCurrentOriginalModel:s=!1,keepCurrentModifiedModel:d=!1,theme:b="light",loading:P="Loading...",options:O={},height:Y="100%",width:J="100%",className:K,wrapperProps:Q={},beforeMount:X=L,onMount:Z=L}){let[y,k]=(0,a.useState)(!1),[D,g]=(0,a.useState)(!0),p=(0,a.useRef)(null),f=(0,a.useRef)(null),z=(0,a.useRef)(null),h=(0,a.useRef)(Z),c=(0,a.useRef)(X),C=(0,a.useRef)(!1);G(()=>{let l=W.init();return l.then(v=>(f.current=v)&&g(!1)).catch(v=>v?.type!=="cancelation"&&console.error("Monaco initialization: error:",v)),()=>p.current?N():l.cancel()}),w(()=>{if(p.current&&f.current){let l=p.current.getOriginalEditor(),v=S(f.current,e||"",n||r||"text",i||"");v!==l.getModel()&&l.setModel(v)}},[i],y),w(()=>{if(p.current&&f.current){let l=p.current.getModifiedEditor(),v=S(f.current,t||"",o||r||"text",u||"");v!==l.getModel()&&l.setModel(v)}},[u],y),w(()=>{let l=p.current.getModifiedEditor();l.getOption(f.current.editor.EditorOption.readOnly)?l.setValue(t||""):t!==l.getValue()&&(l.executeEdits("",[{range:l.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),l.pushUndoStop())},[t],y),w(()=>{p.current?.getModel()?.original.setValue(e||"")},[e],y),w(()=>{let{original:l,modified:v}=p.current.getModel();f.current.editor.setModelLanguage(l,n||r||"text"),f.current.editor.setModelLanguage(v,o||r||"text")},[r,n,o],y),w(()=>{f.current?.editor.setTheme(b)},[b],y),w(()=>{p.current?.updateOptions(O)},[O],y);let F=(0,a.useCallback)(()=>{if(!f.current)return;c.current(f.current);let l=S(f.current,e||"",n||r||"text",i||""),v=S(f.current,t||"",o||r||"text",u||"");p.current?.setModel({original:l,modified:v})},[r,t,o,e,n,i,u]),U=(0,a.useCallback)(()=>{!C.current&&z.current&&(p.current=f.current.editor.createDiffEditor(z.current,{automaticLayout:!0,...O}),F(),f.current?.editor.setTheme(b),k(!0),C.current=!0)},[O,b,F]);(0,a.useEffect)(()=>{y&&h.current(p.current,f.current)},[y]),(0,a.useEffect)(()=>{!D&&!y&&U()},[D,y,U]);function N(){let l=p.current?.getModel();s||l?.original?.dispose(),d||l?.modified?.dispose(),p.current?.dispose()}return a.createElement(ve,{width:J,height:Y,isEditorReady:y,loading:P,_ref:z,className:K,wrapperProps:Q})}var Rt=Ct,Ut=(0,a.memo)(Rt);function Ht(){let[e,t]=Ie(ce.__getMonacoInstance());return G(()=>{let r;return e||(r=ce.init(),r.then(n=>{t(n)})),()=>r?.cancel()}),e}var $t=null;function It(e){let t=(0,a.useRef)();return(0,a.useEffect)(()=>{t.current=e},[e]),t.current}var Tt=It,_=new Map;function At({defaultValue:e,defaultLanguage:t,defaultPath:r,value:n,language:o,path:i,theme:u="light",line:s,loading:d="Loading...",options:b={},overrideServices:P={},saveViewState:O=!0,keepCurrentModel:Y=!1,width:J="100%",height:K="100%",className:Q,wrapperProps:X={},beforeMount:Z=L,onMount:y=L,onChange:k,onValidate:D=L}){let[g,p]=(0,a.useState)(!1),[f,z]=(0,a.useState)(!0),h=(0,a.useRef)(null),c=(0,a.useRef)(null),C=(0,a.useRef)(null),F=(0,a.useRef)(y),U=(0,a.useRef)(Z),N=(0,a.useRef)(),l=(0,a.useRef)(n),v=Tt(i),me=(0,a.useRef)(!1),ee=(0,a.useRef)(!1);G(()=>{let m=W.init();return m.then(M=>(h.current=M)&&z(!1)).catch(M=>M?.type!=="cancelation"&&console.error("Monaco initialization: error:",M)),()=>c.current?_t():m.cancel()}),w(()=>{let m=S(h.current,e||n||"",t||o||"",i||r||"");m!==c.current?.getModel()&&(O&&_.set(v,c.current?.saveViewState()),c.current?.setModel(m),O&&c.current?.restoreViewState(_.get(i)))},[i],g),w(()=>{c.current?.updateOptions(b)},[b],g),w(()=>{!c.current||n===void 0||(c.current.getOption(h.current.editor.EditorOption.readOnly)?c.current.setValue(n):n!==c.current.getValue()&&(ee.current=!0,c.current.executeEdits("",[{range:c.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),c.current.pushUndoStop(),ee.current=!1))},[n],g),w(()=>{let m=c.current?.getModel();m&&o&&h.current?.editor.setModelLanguage(m,o)},[o],g),w(()=>{s!==void 0&&c.current?.revealLine(s)},[s],g),w(()=>{h.current?.editor.setTheme(u)},[u],g);let be=(0,a.useCallback)(()=>{if(!(!C.current||!h.current)&&!me.current){U.current(h.current);let m=i||r,M=S(h.current,n||e||"",t||o||"",m||"");c.current=h.current?.editor.create(C.current,{model:M,automaticLayout:!0,...b},P),O&&c.current.restoreViewState(_.get(m)),h.current.editor.setTheme(u),s!==void 0&&c.current.revealLine(s),p(!0),me.current=!0}},[e,t,r,n,o,i,b,P,O,u,s]);(0,a.useEffect)(()=>{g&&F.current(c.current,h.current)},[g]),(0,a.useEffect)(()=>{!f&&!g&&be()},[f,g,be]),l.current=n,(0,a.useEffect)(()=>{g&&k&&(N.current?.dispose(),N.current=c.current?.onDidChangeModelContent(m=>{ee.current||k(c.current.getValue(),m)}))},[g,k]),(0,a.useEffect)(()=>{if(g){let m=h.current.editor.onDidChangeMarkers(M=>{let te=c.current.getModel()?.uri;if(te&&M.find(re=>re.path===te.path)){let re=h.current.editor.getModelMarkers({resource:te});D?.(re)}});return()=>{m?.dispose()}}return()=>{}},[g,D]);function _t(){N.current?.dispose(),Y?O&&_.set(i,c.current.saveViewState()):c.current.getModel()?.dispose(),c.current.dispose()}return a.createElement(ve,{width:J,height:K,isEditorReady:g,loading:d,_ref:C,className:Q,wrapperProps:X})}var Lt=At,kt=(0,a.memo)(Lt),Dt=kt,zt=R(40845),Nt=R(84140);function Vt(e){if(e===void 0)return{};{const t={"editor.background":e.components.input.background,"minimap.background":e.colors.background.secondary};return Object.keys(t).forEach(r=>{t[r]=E(t[r])}),t}}function E(e){return(0,Nt.A)(e).toHexString()}function xt(e,t){const r=Vt(t);e.editor.defineTheme("grafana-dark",{base:"vs-dark",inherit:!0,colors:r,rules:[{token:"predefined",foreground:E(t?.visualization.getColorByName("purple"))},{token:"operator",foreground:E(t?.visualization.getColorByName("orange"))},{token:"tag",foreground:E(t?.visualization.getColorByName("green"))}]}),e.editor.defineTheme("grafana-light",{base:"vs",inherit:!0,colors:r,rules:[{token:"predefined",foreground:E(t?.visualization.getColorByName("purple"))},{token:"operator",foreground:E(t?.visualization.getColorByName("orange"))},{token:"tag",foreground:E(t?.visualization.getColorByName("green"))}]})}W.config({paths:{vs:(window.__grafana_public_path__??"public/")+"lib/monaco/min/vs"}});const Bt=e=>{const{beforeMount:t}=e,r=(0,zt.$j)(),n=(0,a.useCallback)(o=>{xt(o,r),t?.(o)},[t,r]);return a.createElement(Dt,{...e,theme:r.isDark?"grafana-dark":"grafana-light",beforeMount:n})}}}]);

//# sourceMappingURL=react-monaco-editor.988b1aa5e90b11f9941a.js.map