import dayjs from 'dayjs';
import isToday from 'dayjs/plugin/isToday';
import isYesterday from 'dayjs/plugin/isYesterday';
import relativeTime from 'dayjs/plugin/relativeTime';
import utc from 'dayjs/plugin/utc';
import { enableMapSet, enablePatches } from 'immer';
import { isChunkLoadError, notifyChunkError } from '@/utils/chunkError';
enablePatches();
enableMapSet();
dayjs.extend(relativeTime);
dayjs.extend(utc);
dayjs.extend(isToday);
dayjs.extend(isYesterday);
if (typeof window !== 'undefined') {
window.addEventListener('vite:preloadError', (event) => {
if (isChunkLoadError((event as any).payload)) {
event.preventDefault();
notifyChunkError();
}
});
window.addEventListener('unhandledrejection', (event) => {
if (isChunkLoadError(event.reason)) {
event.preventDefault();
notifyChunkError();
}
});
}
if (__DEV__) {
void import('react-scan').then(({ scan }) => {
scan({ enabled: true });
});
}