"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[2462],{28099:(Gt,ae,E)=>{E.r(ae),E.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)||C("changeType"),Object.keys(t).some(function(n){return!Ne(e,n)})&&C("changeField"),t}function Ue(e){k(e)||C("selectorType")}function Be(e){k(e)||U(e)||C("handlerType"),U(e)&&Object.values(e).some(function(t){return!k(t)})&&C("handlersType")}function Fe(e){e||C("initialIsRequired"),U(e)||C("initialType"),xe(e)&&C("initialContent")}function He(e,t){throw new Error(e[t]||e.default)}var _e={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"},C=I(He)(_e),B={changes:Le,selector:Ue,handler:Be,initial:Fe};function Ve(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};B.initial(e),B.handler(t);var n={current:e},r=I(Ge)(n,t),i=I(We)(n),c=I(B.changes)(e),s=I(qe)(n);function v(){var m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(T){return T};return B.selector(m),m(n.current)}function p(m){ze(r,i,c,s)(m)}return[v,p]}function qe(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:Ve};const Ye=Ke;var Je={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.33.0/min/vs"}};const Qe=Je;function Xe(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 Ze=Xe;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=Ze(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:Qe,isInitialized:!1,resolve:null,reject:null,monaco:null}),he=Se(ft,2),D=he[0],F=he[1];function dt(e){var t=it.config(e),n=t.monaco,r=Re(t,["monaco"]);F(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(F({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||F({monaco:e})}function bt(){return D(function(e){var t=e.monaco;return t})}var G=new Promise(function(e,t){return F({resolve:e,reject:t})}),yt={config:dt,init:pt,__getMonacoInstance:bt};const S=yt;var a=E(68404),Mt=E(59160),o=E.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 J=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 H(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 Q({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:Z,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),V=(0,a.useRef)(null),y=(0,a.useRef)(re),u=(0,a.useRef)(ne);J(()=>{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=H(b.current,e,r||n,c),h=H(b.current,t,i||n,s);O.current.setModel({original:l,modified:h})},[n,t,i,e,r,c,s]),q=(0,a.useCallback)(()=>{O.current=b.current.editor.createDiffEditor(V.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&&q()},[R,M,q]);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:Z,isEditorReady:M,loading:T,_ref:V,className:ee,wrapperProps:te})}Q.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},Q.defaultProps={theme:"light",loading:"Loading...",options:{},keepCurrentOriginalModel:!1,keepCurrentModifiedModel:!1,width:"100%",height:"100%",wrapperProps:{},beforeMount:A,onMount:A};const kt=Q;var Yt=(0,a.memo)(kt);const Jt=null;function Dt(){const[e,t]=(0,a.useState)(S.__getMonacoInstance());return J(()=>{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,_=new Map;function X({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:Z,width:$,height:ee,className:te,wrapperProps:ne,beforeMount:re,onMount:M,onChange:z,onValidate:R}){const[g,O]=(0,a.useState)(!1),[b,V]=(0,a.useState)(!0),y=(0,a.useRef)(null),u=(0,a.useRef)(null),x=(0,a.useRef)(null),q=(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);J(()=>{const f=S.init();return f.then(d=>(y.current=d)&&V(!1)).catch(d=>d?.type!=="cancelation"&&console.error("Monaco initialization: error:",d)),()=>u.current?Wt():f.cancel()}),w(()=>{const f=H(y.current,e||r,t||i,c);f!==u.current.getModel()&&(j&&_.set(N,u.current.saveViewState()),u.current.setModel(f),j&&u.current.restoreViewState(_.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=H(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(_.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&&q.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 Wt(){var f;if((f=l.current)===null||f===void 0||f.dispose(),Z)j&&_.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})}X.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},X.defaultProps={theme:"light",loading:"Loading...",options:{},overrideServices:{},saveViewState:!0,keepCurrentModel:!1,width:"100%",height:"100%",wrapperProps:{},beforeMount:A,onMount:A,onValidate:A};const Nt=X;var Lt=(0,a.memo)(Nt);const Ut=Lt;var Bt=E(72648),Ft=E(35008),Ht=E.n(Ft);function _t(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 Ht()(e).toHexString()}function Oe(e,t){const n=_t(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 Vt(){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,Bt.l4)(),n=At();(0,a.useEffect)(()=>{n!=null&&Oe(n,t)},[n,t]),Vt();const r=t.isDark?"grafana-dark":"grafana-light";return a.createElement(Ut,{theme:r,...e})}}}]);

//# sourceMappingURL=react-monaco-editor.6a65055e4f6b44b19395.js.map