import { onBeforeUnmount, onMounted, ref, toValue, watch } from "vue";
import * as monaco from "monaco-editor/esm/vs/editor/editor.api.js";
//#region src/v2/features/editor/hooks/use-editor-markers.ts
var useEditorMarkers = (editorRef) => {
	const markers = ref([]);
	let dispose = null;
	const retryTimeouts = [];
	const updateMarkers = () => {
		const resource = toValue(editorRef)?.getModel()?.uri;
		if (!resource) {
			markers.value = [];
			return;
		}
		markers.value = monaco.editor.getModelMarkers({}).filter((marker) => marker.resource.toString() === resource.toString());
	};
	const scheduleMarkerReads = () => {
		retryTimeouts.push(setTimeout(updateMarkers, 0), setTimeout(updateMarkers, 80), setTimeout(updateMarkers, 220));
	};
	onMounted(() => {
		dispose = monaco.editor.onDidChangeMarkers(() => {
			scheduleMarkerReads();
		});
		scheduleMarkerReads();
	});
	onBeforeUnmount(() => {
		dispose?.dispose();
		retryTimeouts.forEach((timeout) => clearTimeout(timeout));
	});
	watch(() => toValue(editorRef)?.getModel()?.uri?.toString(), () => {
		scheduleMarkerReads();
	}, { immediate: true });
	return { markers };
};
//#endregion
export { useEditorMarkers };

//# sourceMappingURL=use-editor-markers.js.map