import { Text as e } from "../text/index.js";
import { r as t } from "../chunks/flex-DYZ0IbU6.js";
import { Component as n, useEffect as r, useState as i } from "react";
import { useQueryClient as a } from "@tanstack/react-query";
import { logError as o } from "@ryuzaki13/react-foundation-lib/utils";
import { jsx as s, jsxs as c } from "react/jsx-runtime";
import { captureRuntimeErrorReport as l } from "@ryuzaki13/react-foundation-lib/error-report";
//#region src/errors/PageError.tsx
var u = ({ code: e, title: n, description: r }) => /* @__PURE__ */ c(t.Predefined, {
	variant: "columnCenter",
	className: "paddingXl",
	children: [
		/* @__PURE__ */ s("div", {
			"aria-hidden": "true",
			className: "content2 fontBolded",
			style: { fontSize: "5em" },
			children: e
		}),
		/* @__PURE__ */ s("h2", { children: n }),
		/* @__PURE__ */ s("p", { children: r })
	]
}), d = () => /* @__PURE__ */ s(u, {
	code: 400,
	title: "Некорректный запрос",
	description: "Похоже, что запрос был сформирован неверно. Попробуйте обновить страницу или вернуться на главную."
});
//#endregion
//#region src/errors/BoomExplosion.tsx
function f() {
	let [e] = i(() => `scale(${.7 + Math.random() * .3}) rotateZ(${Math.random() * 45 - 15}deg)`);
	return /* @__PURE__ */ s("svg", {
		viewBox: "0 0 300 300",
		width: "300",
		height: "300",
		style: {
			position: "absolute",
			top: "50%",
			left: "50%",
			transform: `translate(-50%, -50%) ${e}`,
			zIndex: 0,
			opacity: .5
		},
		children: /* @__PURE__ */ s("polygon", {
			points: "\n150,10 170,60 230,40 200,100 270,110 210,150 270,190 200,200 230,260 170,240 150,290 130,240\n70,260 100,200 30,190 90,150 30,110 100,100 70,40 130,60",
			fill: "var(--status-error-on-fill)",
			stroke: "var(--status-error-fill)",
			strokeWidth: "5",
			strokeLinejoin: "round"
		})
	});
}
//#endregion
//#region src/errors/constants.ts
var p = [
	"Упс!",
	"Ой!",
	"Эх!",
	"Ай-ай-ай!",
	"Бах!",
	"Бум!",
	"Ого!",
	"Облом!",
	"Ёлки-палки!",
	"Хлоп!"
], m = () => /* @__PURE__ */ s(u, {
	code: 403,
	title: "Доступ запрещён",
	description: "У вас нет прав для просмотра этой страницы."
}), h = () => /* @__PURE__ */ s(u, {
	code: 404,
	title: "Страница не найдена",
	description: "Извините, запрашиваемая страница не существует"
});
//#endregion
//#region src/errors/ErrorDisplay.tsx
function g(e) {
	if (!(!("status" in e) || typeof e.status != "number")) return e.status;
}
var _ = ({ error: e, componentStack: t, draftId: n }) => {
	let [u] = i(() => Math.random()), _ = a();
	r(() => {
		n === void 0 && l(e, {
			category: "react",
			componentStack: t
		}, _);
	}, [
		t,
		n,
		e,
		_
	]);
	let v = g(e);
	if (v) switch (v) {
		case 400: return /* @__PURE__ */ s(d, {});
		case 403: return /* @__PURE__ */ s(m, {});
		case 404: return /* @__PURE__ */ s(h, {});
	}
	return o(e.stack), /* @__PURE__ */ c("section", {
		className: "w100 h100 flexColumn justifyContentCenter paddingMd",
		children: [/* @__PURE__ */ c("div", {
			"aria-hidden": "true",
			className: "textCenter relative fontBolded statusError",
			style: {
				fontSize: "4em",
				marginBlock: "2em"
			},
			children: [/* @__PURE__ */ s(f, {}), /* @__PURE__ */ s("div", {
				style: {
					zIndex: 1,
					position: "relative",
					textShadow: "1px -1px 1px var(--status-warning-border-focus), -1px 1px 1px var(--status-info-border-focus)"
				},
				children: p[Math.floor(u * p.length)]
			})]
		}), /* @__PURE__ */ c("div", {
			className: "textCenter",
			children: [
				/* @__PURE__ */ s("h2", {
					className: "statusError",
					children: "Критическая ошибка"
				}),
				/* @__PURE__ */ s("p", {
					className: "statusError fontSizeLg",
					children: /* @__PURE__ */ s("code", { children: e.message })
				}),
				/* @__PURE__ */ s("p", { children: "Попробуйте перезагрузить страницу или вернуться позже." })
			]
		})]
	});
}, v = class extends n {
	constructor(e) {
		super(e), this.state = { error: null };
	}
	static getDerivedStateFromError(e) {
		return { error: e };
	}
	componentDidUpdate(e) {
		this.state.error && e.children !== this.props.children && this.setState({
			error: null,
			componentStack: void 0,
			draftId: void 0
		});
	}
	componentDidCatch(e, t) {
		this.setState({
			componentStack: t.componentStack ?? void 0,
			draftId: null
		}), l(e, {
			category: "react",
			componentStack: t.componentStack ?? void 0
		}).then((t) => {
			t && this.state.error === e && this.setState({ draftId: t.reportId });
		});
	}
	render() {
		if (this.state.error) {
			let e = this.props.customComponent;
			return e ? /* @__PURE__ */ s(e, { error: this.state.error }) : /* @__PURE__ */ s(_, {
				error: this.state.error,
				componentStack: this.state.componentStack,
				draftId: this.state.draftId
			});
		}
		return this.props.children;
	}
}, y = ({ header: e, description: t }) => {
	let [n] = i(() => Math.random());
	return /* @__PURE__ */ c("div", {
		className: "container marginBlockLg",
		children: [/* @__PURE__ */ c("div", {
			"aria-hidden": "true",
			className: "textCenter relative fontBolded statusWarning marginBlockMd",
			style: { fontSize: "6em" },
			children: [/* @__PURE__ */ s(f, {}), /* @__PURE__ */ s("div", {
				style: {
					zIndex: 1,
					position: "relative",
					textShadow: "1px 0 1px var(--status-error-fill), -1px 0 1px var(--status-info-fill)"
				},
				children: p[Math.floor(n * p.length)]
			})]
		}), /* @__PURE__ */ c("div", {
			className: "flexColumn alignItemsCenter textCenter marginBlockMd",
			children: [e && /* @__PURE__ */ s("h2", {
				className: "statusWarning",
				children: e
			}), t && /* @__PURE__ */ s("p", { children: t })]
		})]
	});
};
//#endregion
//#region src/errors/SimpleErrorDisplay.tsx
function b({ error: t }) {
	return o(t.stack), /* @__PURE__ */ s(e, {
		color: "error",
		children: /* @__PURE__ */ s("code", { children: t.message })
	});
}
//#endregion
//#region src/errors/UnauthorizedPage.tsx
var x = () => /* @__PURE__ */ s(u, {
	code: 401,
	title: "Необходима авторизация",
	description: "Для доступа к этой странице нужно войти в систему. Пожалуйста, авторизуйтесь и попробуйте снова."
}), S = () => /* @__PURE__ */ s(t.Predefined, {
	variant: "columnCenter",
	className: "paddingXl",
	children: /* @__PURE__ */ s("h2", {
		className: "content2",
		children: "Выберите ракурс"
	})
});
//#endregion
export { d as BadRequestPage, f as BoomExplosion, v as ErrorBoundary, _ as ErrorDisplay, y as ErrorExplosion, m as ForbiddenPage, h as NotFoundPage, u as PageError, b as SimpleErrorDisplay, x as UnauthorizedPage, S as ViewNotChanged };

//# sourceMappingURL=index.js.map