import { s as stringify } from './index2-BpEbpEAf.js';
import 'js-yaml';
import { P as Panel } from './edit-workspace-context-BQXwYkgE.js';
import { o as onDestroy } from './index-server-BI-Ep7Rw.js';

function ContextEditor($$renderer, $$props) {
  $$renderer.component(($$renderer2) => {
    let editor = null;
    let model = null;
    let editorDisposables = [];
    let {
      context,
      onContextChanged,
      class: className,
      suppressErrors = false,
      defaultFormat = "yaml",
      hideHeader = false
    } = $$props;
    onDestroy(() => {
      for (const d of editorDisposables) {
        try {
          d.dispose();
        } catch {
        }
      }
      editorDisposables = [];
      const toDisposeModel = model;
      model = null;
      try {
        if (editor) {
          try {
            editor.setModel(null);
          } catch {
          }
          editor.dispose();
        }
      } finally {
        editor = null;
      }
      try {
        toDisposeModel?.dispose();
      } catch {
      }
    });
    Panel($$renderer2, {
      class: `min-h-0 overflow-hidden ${stringify(
        // Keep model language in sync without recreating the editor
        // Update value only when actual text differs to avoid caret jumps
        // If the next canonical text equals the last user-emitted serialization,
        // skip setting the value to preserve caret/selection.
        className
      )}`,
      children: ($$renderer3) => {
        $$renderer3.push(`<div class="h-full min-h-0 w-full"></div>`);
      }});
  });
}

export { ContextEditor as C };
//# sourceMappingURL=ContextEditor-DwSmZH0Y.js.map
