/**
 * Monaco worker wiring (docs/architecture/08 §1).
 *
 * Self-hosting raw `monaco-editor` means we must point `MonacoEnvironment` at the
 * web workers ourselves — the CDN loader is deliberately not used (offline,
 * privacy, determinism). Vite's `?worker` imports become hashed bundles that the
 * PWA precaches. The `json` worker is what powers JSON validation + completion;
 * everything else uses the base editor worker.
 *
 * Side-effect module: import it once, before creating any editor.
 */

import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
import JsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';

self.MonacoEnvironment = {
  getWorker: (_workerId, label) => (label === 'json' ? new JsonWorker() : new EditorWorker()),
};
