import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{a as t}from"./vendor-datadog-Bq_0f1ke.js";function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var i=arguments[t]==null?{}:arguments[t];t%2?r(Object(i),!0).forEach(function(t){n(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function a(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function o(e,t){if(e==null)return{};var n=a(e,t),r,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)r=o[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function s(e,t){return c(e)||l(e,t)||u(e,t)||f()}function c(e){if(Array.isArray(e))return e}function l(e,t){if(!(typeof Symbol>`u`||!(Symbol.iterator in Object(e)))){var n=[],r=!0,i=!1,a=void 0;try{for(var o=e[Symbol.iterator](),s;!(r=(s=o.next()).done)&&(n.push(s.value),!(t&&n.length===t));r=!0);}catch(e){i=!0,a=e}finally{try{!r&&o.return!=null&&o.return()}finally{if(i)throw a}}return n}}function u(e,t){if(e){if(typeof e==`string`)return d(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 d(e,t)}}function d(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function f(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function h(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?m(Object(n),!0).forEach(function(t){p(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):m(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function g(){var e=[...arguments];return function(t){return e.reduceRight(function(e,t){return t(e)},t)}}function _(e){return function t(){var n=this,r=[...arguments];return r.length>=e.length?e.apply(this,r):function(){var e=[...arguments];return t.apply(n,[].concat(r,e))}}}function v(e){return{}.toString.call(e).includes(`Object`)}function y(e){return!Object.keys(e).length}function b(e){return typeof e==`function`}function x(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function S(e,t){return v(t)||D(`changeType`),Object.keys(t).some(function(t){return!x(e,t)})&&D(`changeField`),t}function C(e){b(e)||D(`selectorType`)}function w(e){b(e)||v(e)||D(`handlerType`),v(e)&&Object.values(e).some(function(e){return!b(e)})&&D(`handlersType`)}function T(e){e||D(`initialIsRequired`),v(e)||D(`initialType`),y(e)&&D(`initialContent`)}function E(e,t){throw Error(e[t]||e.default)}var D=_(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"}),O={changes:S,selector:C,handler:w,initial:T};function k(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};O.initial(e),O.handler(t);var n={current:e},r=_(j)(n,t),i=_(ee)(n),a=_(O.changes)(e),o=_(A)(n);function s(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(e){return e};return O.selector(e),e(n.current)}function c(e){g(r,i,a,o)(e)}return[s,c]}function A(e,t){return b(t)?t(e.current):t}function ee(e,t){return e.current=h(h({},e.current),t),t}function j(e,t,n){return b(t)?t(e.current):Object.keys(n).forEach(function(n){return t[n]?.call(t,e.current[n])}),n}var M={create:k},N={paths:{vs:`https://cdn.jsdelivr.net/npm/monaco-editor@0.52.2/min/vs`}};function P(e){return function t(){var n=this,r=[...arguments];return r.length>=e.length?e.apply(this,r):function(){var e=[...arguments];return t.apply(n,[].concat(r,e))}}}function F(e){return{}.toString.call(e).includes(`Object`)}function te(e){return e||L(`configIsRequired`),F(e)||L(`configType`),e.urls?(ne(),{paths:{vs:e.urls.monacoBase}}):e}function ne(){console.warn(I.deprecation)}function re(e,t){throw Error(e[t]||e.default)}var I={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
  `},L=P(re)(I),ie={config:te},ae=function(){var e=[...arguments];return function(t){return e.reduceRight(function(e,t){return t(e)},t)}};function R(e,t){return Object.keys(t).forEach(function(n){t[n]instanceof Object&&e[n]&&Object.assign(t[n],R(e[n],t[n]))}),i(i({},e),t)}var oe={type:`cancelation`,msg:`operation is manually canceled`};function z(e){var t=!1,n=new Promise(function(n,r){e.then(function(e){return t?r(oe):n(e)}),e.catch(r)});return n.cancel=function(){return t=!0},n}var se=s(M.create({config:N,isInitialized:!1,resolve:null,reject:null,monaco:null}),2),B=se[0],V=se[1];function ce(e){var t=ie.config(e),n=t.monaco,r=o(t,[`monaco`]);V(function(e){return{config:R(e.config,r),monaco:n}})}function le(){var e=B(function(e){return{monaco:e.monaco,isInitialized:e.isInitialized,resolve:e.resolve}});if(!e.isInitialized){if(V({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),z(U);if(window.monaco&&window.monaco.editor)return H(window.monaco),e.resolve(window.monaco),z(U);ae(ue,fe)(pe)}return z(U)}function ue(e){return document.body.appendChild(e)}function de(e){var t=document.createElement(`script`);return e&&(t.src=e),t}function fe(e){var t=B(function(e){return{config:e.config,reject:e.reject}}),n=de(`${t.config.paths.vs}/loader.js`);return n.onload=function(){return e()},n.onerror=t.reject,n}function pe(){var e=B(function(e){return{config:e.config,resolve:e.resolve,reject:e.reject}}),t=window.require;t.config(e.config),t([`vs/editor/editor.main`],function(t){H(t),e.resolve(t)},function(t){e.reject(t)})}function H(e){B().monaco||V({monaco:e})}function me(){return B(function(e){return e.monaco})}var U=new Promise(function(e,t){return V({resolve:e,reject:t})}),W={config:ce,init:le,__getMonacoInstance:me},G=e(t(),1),K={wrapper:{display:`flex`,position:`relative`,textAlign:`initial`},fullWidth:{width:`100%`},hide:{display:`none`}},he={container:{display:`flex`,height:`100%`,width:`100%`,justifyContent:`center`,alignItems:`center`}};function ge({children:e}){return G.createElement(`div`,{style:he.container},e)}var _e=ge;function ve({width:e,height:t,isEditorReady:n,loading:r,_ref:i,className:a,wrapperProps:o}){return G.createElement(`section`,{style:{...K.wrapper,width:e,height:t},...o},!n&&G.createElement(_e,null,r),G.createElement(`div`,{ref:i,style:{...K.fullWidth,...!n&&K.hide},className:a}))}var q=(0,G.memo)(ve);function ye(e){(0,G.useEffect)(e,[])}var J=ye;function be(e,t,n=!0){let r=(0,G.useRef)(!0);(0,G.useEffect)(r.current||!n?()=>{r.current=!1}:e,t)}var Y=be;function X(){}function Z(e,t,n,r){return xe(e,r)||Se(e,t,n,r)}function xe(e,t){return e.editor.getModel(Q(e,t))}function Se(e,t,n,r){return e.editor.createModel(t,n,r?Q(e,r):void 0)}function Q(e,t){return e.Uri.parse(t)}function Ce({original:e,modified:t,language:n,originalLanguage:r,modifiedLanguage:i,originalModelPath:a,modifiedModelPath:o,keepCurrentOriginalModel:s=!1,keepCurrentModifiedModel:c=!1,theme:l=`light`,loading:u=`Loading...`,options:d={},height:f=`100%`,width:p=`100%`,className:m,wrapperProps:h={},beforeMount:g=X,onMount:_=X}){let[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(!0),S=(0,G.useRef)(null),C=(0,G.useRef)(null),w=(0,G.useRef)(null),T=(0,G.useRef)(_),E=(0,G.useRef)(g),D=(0,G.useRef)(!1);J(()=>{let e=W.init();return e.then(e=>(C.current=e)&&x(!1)).catch(e=>e?.type!==`cancelation`&&console.error(`Monaco initialization: error:`,e)),()=>S.current?A():e.cancel()}),Y(()=>{if(S.current&&C.current){let t=S.current.getOriginalEditor(),i=Z(C.current,e||``,r||n||`text`,a||``);i!==t.getModel()&&t.setModel(i)}},[a],v),Y(()=>{if(S.current&&C.current){let e=S.current.getModifiedEditor(),r=Z(C.current,t||``,i||n||`text`,o||``);r!==e.getModel()&&e.setModel(r)}},[o],v),Y(()=>{let e=S.current.getModifiedEditor();e.getOption(C.current.editor.EditorOption.readOnly)?e.setValue(t||``):t!==e.getValue()&&(e.executeEdits(``,[{range:e.getModel().getFullModelRange(),text:t||``,forceMoveMarkers:!0}]),e.pushUndoStop())},[t],v),Y(()=>{S.current?.getModel()?.original.setValue(e||``)},[e],v),Y(()=>{let{original:e,modified:t}=S.current.getModel();C.current.editor.setModelLanguage(e,r||n||`text`),C.current.editor.setModelLanguage(t,i||n||`text`)},[n,r,i],v),Y(()=>{C.current?.editor.setTheme(l)},[l],v),Y(()=>{S.current?.updateOptions(d)},[d],v);let O=(0,G.useCallback)(()=>{if(!C.current)return;E.current(C.current);let s=Z(C.current,e||``,r||n||`text`,a||``),c=Z(C.current,t||``,i||n||`text`,o||``);S.current?.setModel({original:s,modified:c})},[n,t,i,e,r,a,o]),k=(0,G.useCallback)(()=>{!D.current&&w.current&&(S.current=C.current.editor.createDiffEditor(w.current,{automaticLayout:!0,...d}),O(),C.current?.editor.setTheme(l),y(!0),D.current=!0)},[d,l,O]);(0,G.useEffect)(()=>{v&&T.current(S.current,C.current)},[v]),(0,G.useEffect)(()=>{!b&&!v&&k()},[b,v,k]);function A(){let e=S.current?.getModel();s||e?.original?.dispose(),c||e?.modified?.dispose(),S.current?.dispose()}return G.createElement(q,{width:p,height:f,isEditorReady:v,loading:u,_ref:w,className:m,wrapperProps:h})}var we=(0,G.memo)(Ce);function Te(){let[e,t]=(0,G.useState)(W.__getMonacoInstance());return J(()=>{let n;return e||(n=W.init(),n.then(e=>{t(e)})),()=>n?.cancel()}),e}var Ee=Te;function De(e){let t=(0,G.useRef)();return(0,G.useEffect)(()=>{t.current=e},[e]),t.current}var Oe=De,$=new Map;function ke({defaultValue:e,defaultLanguage:t,defaultPath:n,value:r,language:i,path:a,theme:o=`light`,line:s,loading:c=`Loading...`,options:l={},overrideServices:u={},saveViewState:d=!0,keepCurrentModel:f=!1,width:p=`100%`,height:m=`100%`,className:h,wrapperProps:g={},beforeMount:_=X,onMount:v=X,onChange:y,onValidate:b=X}){let[x,S]=(0,G.useState)(!1),[C,w]=(0,G.useState)(!0),T=(0,G.useRef)(null),E=(0,G.useRef)(null),D=(0,G.useRef)(null),O=(0,G.useRef)(v),k=(0,G.useRef)(_),A=(0,G.useRef)(),ee=(0,G.useRef)(r),j=Oe(a),M=(0,G.useRef)(!1),N=(0,G.useRef)(!1);J(()=>{let e=W.init();return e.then(e=>(T.current=e)&&w(!1)).catch(e=>e?.type!==`cancelation`&&console.error(`Monaco initialization: error:`,e)),()=>E.current?F():e.cancel()}),Y(()=>{let o=Z(T.current,e||r||``,t||i||``,a||n||``);o!==E.current?.getModel()&&(d&&$.set(j,E.current?.saveViewState()),E.current?.setModel(o),d&&E.current?.restoreViewState($.get(a)))},[a],x),Y(()=>{E.current?.updateOptions(l)},[l],x),Y(()=>{!E.current||r===void 0||(E.current.getOption(T.current.editor.EditorOption.readOnly)?E.current.setValue(r):r!==E.current.getValue()&&(N.current=!0,E.current.executeEdits(``,[{range:E.current.getModel().getFullModelRange(),text:r,forceMoveMarkers:!0}]),E.current.pushUndoStop(),N.current=!1))},[r],x),Y(()=>{let e=E.current?.getModel();e&&i&&T.current?.editor.setModelLanguage(e,i)},[i],x),Y(()=>{s!==void 0&&E.current?.revealLine(s)},[s],x),Y(()=>{T.current?.editor.setTheme(o)},[o],x);let P=(0,G.useCallback)(()=>{if(!(!D.current||!T.current)&&!M.current){k.current(T.current);let c=a||n,f=Z(T.current,r||e||``,t||i||``,c||``);E.current=T.current?.editor.create(D.current,{model:f,automaticLayout:!0,...l},u),d&&E.current.restoreViewState($.get(c)),T.current.editor.setTheme(o),s!==void 0&&E.current.revealLine(s),S(!0),M.current=!0}},[e,t,n,r,i,a,l,u,d,o,s]);(0,G.useEffect)(()=>{x&&O.current(E.current,T.current)},[x]),(0,G.useEffect)(()=>{!C&&!x&&P()},[C,x,P]),ee.current=r,(0,G.useEffect)(()=>{x&&y&&(A.current?.dispose(),A.current=E.current?.onDidChangeModelContent(e=>{N.current||y(E.current.getValue(),e)}))},[x,y]),(0,G.useEffect)(()=>{if(x){let e=T.current.editor.onDidChangeMarkers(e=>{let t=E.current.getModel()?.uri;if(t&&e.find(e=>e.path===t.path)){let e=T.current.editor.getModelMarkers({resource:t});b?.(e)}});return()=>{e?.dispose()}}return()=>{}},[x,b]);function F(){A.current?.dispose(),f?d&&$.set(a,E.current.saveViewState()):E.current.getModel()?.dispose(),E.current.dispose()}return G.createElement(q,{width:p,height:m,isEditorReady:x,loading:c,_ref:D,className:h,wrapperProps:g})}var Ae=(0,G.memo)(ke),je=Ae;export{we as DiffEditor,Ae as Editor,je as default,W as loader,Ee as useMonaco};
//# sourceMappingURL=dist-Cjh2xdPt.js.map