"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[2462],{89852:(Wt,ae,C)=>{C.r(ae),C.d(ae,{ReactMonacoEditor:()=>qt});function Ce(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ue(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function se(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ue(Object(n),!0).forEach(function(r){Ce(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ue(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Pe(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,c;for(c=0;c<r.length;c++)i=r[c],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function Re(e,t){if(e==null)return{};var n=Pe(e,t),r,i;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(i=0;i<c.length;i++)r=c[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Se(e,t){return Te(e)||Ie(e,t)||ke(e,t)||De()}function Te(e){if(Array.isArray(e))return e}function Ie(e,t){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(e)))){var n=[],r=!0,i=!1,c=void 0;try{for(var s=e[Symbol.iterator](),v;!(r=(v=s.next()).done)&&(n.push(v.value),!(t&&n.length===t));r=!0);}catch(p){i=!0,c=p}finally{try{!r&&s.return!=null&&s.return()}finally{if(i)throw c}}return n}}function ke(e,t){if(e){if(typeof e=="string")return le(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return le(e,t)}}function le(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function De(){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 Ae(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function fe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function de(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?fe(Object(n),!0).forEach(function(r){Ae(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function ze(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(r){return t.reduceRight(function(i,c){return c(i)},r)}}function I(e){return function t(){for(var n=this,r=arguments.length,i=new Array(r),c=0;c<r;c++)i[c]=arguments[c];return i.length>=e.length?e.apply(this,i):function(){for(var s=arguments.length,v=new Array(s),p=0;p<s;p++)v[p]=arguments[p];return t.apply(n,[].concat(i,v))}}}function U(e){return{}.toString.call(e).includes("Object")}function xe(e){return!Object.keys(e).length}function k(e){return typeof e=="function"}function Ne(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Le(e,t){return U(t)||E("changeType"),Object.keys(t).some(function(n){return!Ne(e,n)})&&E("changeField"),t}function Ue(e){k(e)||E("selectorType")}function _e(e){k(e)||U(e)||E("handlerType"),U(e)&&Object.values(e).some(function(t){return!k(t)})&&E("handlersType")}function Be(e){e||E("initialIsRequired"),U(e)||E("initialType"),xe(e)&&E("initialContent")}function Fe(e,t){throw new Error(e[t]||e.default)}var He={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"},E=I(Fe)(He),_={changes:Le,selector:Ue,handler:_e,initial:Be};function qe(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};_.initial(e),_.handler(t);var n={current:e},r=I(Ge)(n,t),i=I(We)(n),c=I(_.changes)(e),s=I(Ve)(n);function v(){var m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(T){return T};return _.selector(m),m(n.current)}function p(m){ze(r,i,c,s)(m)}return[v,p]}function Ve(e,t){return k(t)?t(e.current):t}function We(e,t){return e.current=de(de({},e.current),t),t}function Ge(e,t,n){return k(t)?t(e.current):Object.keys(n).forEach(function(r){var i;return(i=t[r])===null||i===void 0?void 0:i.call(t,e.current[r])}),n}var Ke={create:qe};const Ye=Ke;var Ze={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.33.0/min/vs"}};const Je=Ze;function Qe(e){return function t(){for(var n=this,r=arguments.length,i=new Array(r),c=0;c<r;c++)i[c]=arguments[c];return i.length>=e.length?e.apply(this,i):function(){for(var s=arguments.length,v=new Array(s),p=0;p<s;p++)v[p]=arguments[p];return t.apply(n,[].concat(i,v))}}}const Xe=Qe;function $e(e){return{}.toString.call(e).includes("Object")}const et=$e;function tt(e){return e||ge("configIsRequired"),et(e)||ge("configType"),e.urls?(nt(),{paths:{vs:e.urls.monacoBase}}):e}function nt(){console.warn(pe.deprecation)}function rt(e,t){throw new Error(e[t]||e.default)}var pe={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
  `},ge=Xe(rt)(pe),ot={config:tt};const it=ot;var ct=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return function(i){return n.reduceRight(function(c,s){return s(c)},i)}};const at=ct;function ve(e,t){return Object.keys(t).forEach(function(n){t[n]instanceof Object&&e[n]&&Object.assign(t[n],ve(e[n],t[n]))}),se(se({},e),t)}const ut=ve;var st={type:"cancelation",msg:"operation is manually canceled"};function lt(e){var t=!1,n=new Promise(function(r,i){e.then(function(c){return t?i(st):r(c)}),e.catch(i)});return n.cancel=function(){return t=!0},n}const W=lt;var ft=Ye.create({config:Je,isInitialized:!1,resolve:null,reject:null,monaco:null}),he=Se(ft,2),D=he[0],B=he[1];function dt(e){var t=it.config(e),n=t.monaco,r=Re(t,["monaco"]);B(function(i){return{config:ut(i.config,r),monaco:n}})}function pt(){var e=D(function(t){var n=t.monaco,r=t.isInitialized,i=t.resolve;return{monaco:n,isInitialized:r,resolve:i}});if(!e.isInitialized){if(B({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),W(G);if(window.monaco&&window.monaco.editor)return me(window.monaco),e.resolve(window.monaco),W(G);at(gt,ht)(mt)}return W(G)}function gt(e){return document.body.appendChild(e)}function vt(e){var t=document.createElement("script");return e&&(t.src=e),t}function ht(e){var t=D(function(r){var i=r.config,c=r.reject;return{config:i,reject:c}}),n=vt("".concat(t.config.paths.vs,"/loader.js"));return n.onload=function(){return e()},n.onerror=t.reject,n}function mt(){var e=D(function(n){var r=n.config,i=n.resolve,c=n.reject;return{config:r,resolve:i,reject:c}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(n){me(n),e.resolve(n)},function(n){e.reject(n)})}function me(e){D().monaco||B({monaco:e})}function bt(){return D(function(e){var t=e.monaco;return t})}var G=new Promise(function(e,t){return B({resolve:e,reject:t})}),yt={config:dt,init:pt,__getMonacoInstance:bt};const S=yt;var a=C(66111),Mt=C(59160),o=C.n(Mt);function K(){return K=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},K.apply(this,arguments)}const Ot={display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"};function wt({content:e}){return a.createElement("div",{style:Ot},e)}const jt=wt,Y={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}};function be({width:e,height:t,isEditorReady:n,loading:r,_ref:i,className:c,wrapperProps:s}){return a.createElement("section",K({style:{...Y.wrapper,width:e,height:t}},s),!n&&a.createElement(jt,{content:r}),a.createElement("div",{ref:i,style:{...Y.fullWidth,...!n&&Y.hide},className:c}))}be.propTypes={width:o().oneOfType([o().number,o().string]).isRequired,height:o().oneOfType([o().number,o().string]).isRequired,loading:o().oneOfType([o().element,o().string]).isRequired,isEditorReady:o().bool.isRequired,className:o().string,wrapperProps:o().object};const Et=be;var Ct=(0,a.memo)(Et);const ye=Ct;function Pt(e){(0,a.useEffect)(e,[])}const Z=Pt;function Rt(e,t,n=!0){const r=(0,a.useRef)(!0);(0,a.useEffect)(r.current||!n?()=>{r.current=!1}:e,t)}const w=Rt;function A(){}function F(e,t,n,r){return St(e,r)||Tt(e,t,n,r)}function St(e,t){return e.editor.getModel(Me(e,t))}function Tt(e,t,n,r){return e.editor.createModel(t,n,r&&Me(e,r))}function Me(e,t){return e.Uri.parse(t)}function It(e){return e===void 0}function J({original:e,modified:t,language:n,originalLanguage:r,modifiedLanguage:i,originalModelPath:c,modifiedModelPath:s,keepCurrentOriginalModel:v,keepCurrentModifiedModel:p,theme:m,loading:T,options:j,height:X,width:$,className:ee,wrapperProps:te,beforeMount:ne,onMount:re}){const[M,z]=(0,a.useState)(!1),[R,g]=(0,a.useState)(!0),O=(0,a.useRef)(null),b=(0,a.useRef)(null),q=(0,a.useRef)(null),y=(0,a.useRef)(re),u=(0,a.useRef)(ne);Z(()=>{const l=S.init();return l.then(h=>(b.current=h)&&g(!1)).catch(h=>h?.type!=="cancelation"&&console.error("Monaco initialization: error:",h)),()=>O.current?oe():l.cancel()}),w(()=>{const l=O.current.getModifiedEditor();l.getOption(b.current.editor.EditorOption.readOnly)?l.setValue(t):t!==l.getValue()&&(l.executeEdits("",[{range:l.getModel().getFullModelRange(),text:t,forceMoveMarkers:!0}]),l.pushUndoStop())},[t],M),w(()=>{O.current.getModel().original.setValue(e)},[e],M),w(()=>{const{original:l,modified:h}=O.current.getModel();b.current.editor.setModelLanguage(l,r||n),b.current.editor.setModelLanguage(h,i||n)},[n,r,i],M),w(()=>{b.current.editor.setTheme(m)},[m],M),w(()=>{O.current.updateOptions(j)},[j],M);const x=(0,a.useCallback)(()=>{u.current(b.current);const l=F(b.current,e,r||n,c),h=F(b.current,t,i||n,s);O.current.setModel({original:l,modified:h})},[n,t,i,e,r,c,s]),V=(0,a.useCallback)(()=>{O.current=b.current.editor.createDiffEditor(q.current,{automaticLayout:!0,...j}),x(),b.current.editor.setTheme(m),z(!0)},[j,m,x]);(0,a.useEffect)(()=>{M&&y.current(O.current,b.current)},[M]),(0,a.useEffect)(()=>{!R&&!M&&V()},[R,M,V]);function oe(){const l=O.current.getModel();if(!v){var h;(h=l.original)===null||h===void 0||h.dispose()}if(!p){var N;(N=l.modified)===null||N===void 0||N.dispose()}O.current.dispose()}return a.createElement(ye,{width:$,height:X,isEditorReady:M,loading:T,_ref:q,className:ee,wrapperProps:te})}J.propTypes={original:o().string,modified:o().string,language:o().string,originalLanguage:o().string,modifiedLanguage:o().string,originalModelPath:o().string,modifiedModelPath:o().string,keepCurrentOriginalModel:o().bool,keepCurrentModifiedModel:o().bool,theme:o().string,loading:o().oneOfType([o().element,o().string]),options:o().object,width:o().oneOfType([o().number,o().string]),height:o().oneOfType([o().number,o().string]),className:o().string,wrapperProps:o().object,beforeMount:o().func,onMount:o().func},J.defaultProps={theme:"light",loading:"Loading...",options:{},keepCurrentOriginalModel:!1,keepCurrentModifiedModel:!1,width:"100%",height:"100%",wrapperProps:{},beforeMount:A,onMount:A};const kt=J;var Kt=(0,a.memo)(kt);const Yt=null;function Dt(){const[e,t]=(0,a.useState)(S.__getMonacoInstance());return Z(()=>{let n;return e||(n=S.init(),n.then(r=>{t(r)})),()=>{var r;return(r=n)===null||r===void 0?void 0:r.cancel()}}),e}const At=Dt;function zt(e){const t=(0,a.useRef)();return(0,a.useEffect)(()=>{t.current=e},[e]),t.current}const xt=zt,H=new Map;function Q({defaultValue:e,defaultLanguage:t,defaultPath:n,value:r,language:i,path:c,theme:s,line:v,loading:p,options:m,overrideServices:T,saveViewState:j,keepCurrentModel:X,width:$,height:ee,className:te,wrapperProps:ne,beforeMount:re,onMount:M,onChange:z,onValidate:R}){const[g,O]=(0,a.useState)(!1),[b,q]=(0,a.useState)(!0),y=(0,a.useRef)(null),u=(0,a.useRef)(null),x=(0,a.useRef)(null),V=(0,a.useRef)(M),oe=(0,a.useRef)(re),l=(0,a.useRef)(null),h=(0,a.useRef)(r),N=xt(c),je=(0,a.useRef)(!1);Z(()=>{const f=S.init();return f.then(d=>(y.current=d)&&q(!1)).catch(d=>d?.type!=="cancelation"&&console.error("Monaco initialization: error:",d)),()=>u.current?Vt():f.cancel()}),w(()=>{const f=F(y.current,e||r,t||i,c);f!==u.current.getModel()&&(j&&H.set(N,u.current.saveViewState()),u.current.setModel(f),j&&u.current.restoreViewState(H.get(c)))},[c],g),w(()=>{u.current.updateOptions(m)},[m],g),w(()=>{u.current.getOption(y.current.editor.EditorOption.readOnly)?u.current.setValue(r):r!==u.current.getValue()&&(u.current.executeEdits("",[{range:u.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),u.current.pushUndoStop())},[r],g),w(()=>{y.current.editor.setModelLanguage(u.current.getModel(),i)},[i],g),w(()=>{It(v)||u.current.revealLine(v)},[v],g),w(()=>{y.current.editor.setTheme(s)},[s],g);const Ee=(0,a.useCallback)(()=>{if(!je.current){oe.current(y.current);const f=c||n,d=F(y.current,r||e,t||i,f);u.current=y.current.editor.create(x.current,{model:d,automaticLayout:!0,...m},T),j&&u.current.restoreViewState(H.get(f)),y.current.editor.setTheme(s),O(!0),je.current=!0}},[e,t,n,r,i,c,m,T,j,s]);(0,a.useEffect)(()=>{g&&V.current(u.current,y.current)},[g]),(0,a.useEffect)(()=>{!b&&!g&&Ee()},[b,g,Ee]),h.current=r,(0,a.useEffect)(()=>{if(g&&z){var f,d;(f=l.current)===null||f===void 0||f.dispose(),l.current=(d=u.current)===null||d===void 0?void 0:d.onDidChangeModelContent(L=>{z(u.current.getValue(),L)})}},[g,z]),(0,a.useEffect)(()=>{if(g){const f=y.current.editor.onDidChangeMarkers(d=>{var L;const ie=(L=u.current.getModel())===null||L===void 0?void 0:L.uri;if(ie&&d.find(ce=>ce.path===ie.path)){const ce=y.current.editor.getModelMarkers({resource:ie});R?.(ce)}});return()=>{f?.dispose()}}},[g,R]);function Vt(){var f;if((f=l.current)===null||f===void 0||f.dispose(),X)j&&H.set(c,u.current.saveViewState());else{var d;(d=u.current.getModel())===null||d===void 0||d.dispose()}u.current.dispose()}return a.createElement(ye,{width:$,height:ee,isEditorReady:g,loading:p,_ref:x,className:te,wrapperProps:ne})}Q.propTypes={defaultValue:o().string,defaultPath:o().string,defaultLanguage:o().string,value:o().string,language:o().string,path:o().string,theme:o().string,line:o().number,loading:o().oneOfType([o().element,o().string]),options:o().object,overrideServices:o().object,saveViewState:o().bool,keepCurrentModel:o().bool,width:o().oneOfType([o().number,o().string]),height:o().oneOfType([o().number,o().string]),className:o().string,wrapperProps:o().object,beforeMount:o().func,onMount:o().func,onChange:o().func,onValidate:o().func},Q.defaultProps={theme:"light",loading:"Loading...",options:{},overrideServices:{},saveViewState:!0,keepCurrentModel:!1,width:"100%",height:"100%",wrapperProps:{},beforeMount:A,onMount:A,onValidate:A};const Nt=Q;var Lt=(0,a.memo)(Nt);const Ut=Lt;var _t=C(72648),Bt=C(28550);function Ft(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(n=>{t[n]=P(t[n])}),t}}function P(e){return(0,Bt.Z)(e).toHexString()}function Oe(e,t){const n=Ft(t);e.editor.defineTheme("grafana-dark",{base:"vs-dark",inherit:!0,colors:n,rules:[{token:"predefined",foreground:P(t?.visualization.getColorByName("purple"))},{token:"operator",foreground:P(t?.visualization.getColorByName("orange"))},{token:"tag",foreground:P(t?.visualization.getColorByName("green"))}]}),e.editor.defineTheme("grafana-light",{base:"vs",inherit:!0,colors:n,rules:[{token:"predefined",foreground:P(t?.visualization.getColorByName("purple"))},{token:"operator",foreground:P(t?.visualization.getColorByName("orange"))},{token:"tag",foreground:P(t?.visualization.getColorByName("green"))}]})}let we=!1;function Ht(){we||(S.config({paths:{vs:(window.__grafana_public_path__??"public/")+"lib/monaco/min/vs"}}),we=!0,S.init().then(e=>{Oe(e)}))}const qt=e=>{const t=(0,_t.l4)(),n=At();(0,a.useEffect)(()=>{n!=null&&Oe(n,t)},[n,t]),Ht();const r=t.isDark?"grafana-dark":"grafana-light";return a.createElement(Ut,{theme:r,...e})}}}]);

//# sourceMappingURL=react-monaco-editor.dc1b00eee71b209ab45d.js.map