//#region src/constants/allowed-file-formats.ts
const ALLOWED_IMAGE_MIME_TYPES_LIST = [
	"image/png",
	"image/jpeg",
	"image/webp"
];
const ALLOWED_IMAGE_MIME_TYPES = new Set(ALLOWED_IMAGE_MIME_TYPES_LIST);
const TEXT_DOCUMENT_MIME_TYPE_TO_EXTENSION = {
	"text/plain": "txt",
	"text/markdown": "md",
	"text/html": "html",
	"text/csv": "csv",
	"text/x-log": "log",
	"application/json": "json",
	"application/javascript": "js",
	"application/typescript": "ts",
	"text/xml": "xml",
	"text/x-shellscript": "sh",
	"text/x-rst": "rst",
	"text/x-makefile": "makefile",
	"text/x-lisp": "lisp",
	"text/x-asm": "asm",
	"text/vbscript": "vbs",
	"text/css": "css",
	"message/rfc822": "eml",
	"application/x-powershell": "ps1",
	"text/x-diff": "diff",
	"text/x-patch": "patch",
	"text/x-java": "java",
	"text/x-python": "py",
	"text/x-c": "c",
	"text/x-c++": "cpp",
	"text/x-php": "php",
	"text/x-ruby": "rb",
	"text/x-sh": "sh",
	"text/x-bash": "bash",
	"text/x-zsh": "zsh",
	"text/x-tex": "tex",
	"text/x-csharp": "cs",
	"text/x-go": "go",
	"text/x-rust": "rs",
	"text/x-scala": "scala",
	"text/x-kotlin": "kt",
	"text/x-swift": "swift",
	"text/x-lua": "lua",
	"text/x-r": "r",
	"text/x-julia": "jl",
	"text/x-perl": "pl",
	"text/x-objectivec": "m",
	"text/x-objectivec++": "mm",
	"text/x-erlang": "erl",
	"text/x-elixir": "ex",
	"text/x-haskell": "hs",
	"text/x-clojure": "clj",
	"text/x-groovy": "groovy",
	"text/x-dart": "dart",
	"text/x-awk": "awk",
	"text/jsx": "jsx",
	"text/tsx": "tsx",
	"text/x-handlebars": "hbs",
	"text/x-mustache": "mustache",
	"text/x-ejs": "ejs",
	"text/x-jinja2": "jinja2",
	"text/x-liquid": "liquid",
	"text/x-erb": "erb",
	"text/x-twig": "twig",
	"text/x-pug": "pug",
	"text/x-jade": "jade",
	"text/x-tmpl": "tmpl",
	"text/x-cmake": "cmake",
	"text/x-dockerfile": "dockerfile",
	"text/x-gradle": "gradle",
	"text/x-ini": "ini",
	"text/x-properties": "properties",
	"text/x-protobuf": "proto",
	"text/x-sql": "sql",
	"text/x-sass": "sass",
	"text/x-scss": "scss",
	"text/x-less": "less",
	"text/x-hcl": "hcl",
	"text/x-terraform": "tf",
	"application/graphql": "graphql",
	"application/x-ndjson": "ndjson",
	"application/json5": "json5",
	"application/toml": "toml",
	"application/yaml": "yaml",
	"text/x-astro": "astro",
	"text/srt": "srt",
	"text/vtt": "vtt",
	"text/x-vcard": "vcf",
	"text/calendar": "ics"
};
const TEXT_DOCUMENT_EXTENSION_TO_MIME_TYPE = {
	txt: "text/plain",
	text: "text/plain",
	bat: "text/plain",
	cfg: "text/plain",
	conf: "text/plain",
	def: "text/plain",
	dic: "text/plain",
	in: "text/plain",
	list: "text/plain",
	md: "text/markdown",
	markdown: "text/markdown",
	html: "text/html",
	htm: "text/html",
	csv: "text/csv",
	log: "text/x-log",
	json: "application/json",
	js: "application/javascript",
	mjs: "application/javascript",
	ts: "application/typescript",
	jsx: "text/jsx",
	tsx: "text/tsx",
	xml: "text/xml",
	sh: "text/x-sh",
	bash: "text/x-bash",
	zsh: "text/x-zsh",
	ksh: "text/x-shellscript",
	rst: "text/x-rst",
	makefile: "text/x-makefile",
	mk: "text/x-makefile",
	lisp: "text/x-lisp",
	asm: "text/x-asm",
	s: "text/x-asm",
	vbs: "text/vbscript",
	css: "text/css",
	eml: "message/rfc822",
	mht: "message/rfc822",
	mhtml: "message/rfc822",
	mime: "message/rfc822",
	nws: "message/rfc822",
	sql: "text/x-sql",
	scala: "text/x-scala",
	rs: "text/x-rust",
	ps1: "application/x-powershell",
	diff: "text/x-diff",
	patch: "text/x-patch",
	java: "text/x-java",
	py: "text/x-python",
	c: "text/x-c",
	h: "text/x-c",
	cpp: "text/x-c++",
	cc: "text/x-c++",
	cxx: "text/x-c++",
	hh: "text/x-c++",
	go: "text/x-go",
	php: "text/x-php",
	rb: "text/x-ruby",
	tex: "text/x-tex",
	cs: "text/x-csharp",
	kt: "text/x-kotlin",
	swift: "text/x-swift",
	lua: "text/x-lua",
	r: "text/x-r",
	jl: "text/x-julia",
	pl: "text/x-perl",
	m: "text/x-objectivec",
	mm: "text/x-objectivec++",
	erl: "text/x-erlang",
	ex: "text/x-elixir",
	hs: "text/x-haskell",
	clj: "text/x-clojure",
	groovy: "text/x-groovy",
	dart: "text/x-dart",
	awk: "text/x-awk",
	hbs: "text/x-handlebars",
	mustache: "text/x-mustache",
	ejs: "text/x-ejs",
	jinja: "text/x-jinja2",
	jinja2: "text/x-jinja2",
	liquid: "text/x-liquid",
	erb: "text/x-erb",
	twig: "text/x-twig",
	pug: "text/x-pug",
	jade: "text/x-jade",
	tmpl: "text/x-tmpl",
	cmake: "text/x-cmake",
	dockerfile: "text/x-dockerfile",
	gradle: "text/x-gradle",
	ini: "text/x-ini",
	properties: "text/x-properties",
	proto: "text/x-protobuf",
	sass: "text/x-sass",
	scss: "text/x-scss",
	less: "text/x-less",
	hcl: "text/x-hcl",
	tf: "text/x-terraform",
	toml: "application/toml",
	graphql: "application/graphql",
	gql: "application/graphql",
	ndjson: "application/x-ndjson",
	json5: "application/json5",
	yaml: "application/yaml",
	yml: "application/yaml",
	astro: "text/x-astro",
	srt: "text/srt",
	vtt: "text/vtt",
	vcf: "text/x-vcard",
	ics: "text/calendar",
	ifb: "text/calendar"
};
const ALLOWED_TEXT_DOCUMENT_MIME_TYPES = new Set(Object.keys(TEXT_DOCUMENT_MIME_TYPE_TO_EXTENSION));
const ZIP_DOCUMENT_MIME_TYPE_TO_EXTENSION = {
	"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
	"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
	"application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
	"application/vnd.oasis.opendocument.text": "odt",
	"application/vnd.oasis.opendocument.spreadsheet": "ods",
	"application/vnd.oasis.opendocument.presentation": "odp",
	"application/vnd.apple.pages": "pages",
	"application/vnd.apple.numbers": "numbers",
	"application/vnd.apple.keynote": "key"
};
const ZIP_DOCUMENT_EXTENSIONS = Object.values(ZIP_DOCUMENT_MIME_TYPE_TO_EXTENSION);
const ZIP_DOCUMENT_EXTENSIONS_LABEL = ZIP_DOCUMENT_EXTENSIONS.map((ext) => `.${ext}`).join(", ");
const ALLOWED_OFFICE_DOCUMENT_MIME_TYPES = new Set(Object.keys(ZIP_DOCUMENT_MIME_TYPE_TO_EXTENSION));
const FILE_MIME_TYPE_TO_EXTENSION = {
	"image/png": "png",
	"image/jpeg": "jpg",
	"image/jpg": "jpg",
	"image/webp": "webp",
	"application/pdf": "pdf",
	...TEXT_DOCUMENT_MIME_TYPE_TO_EXTENSION,
	...ZIP_DOCUMENT_MIME_TYPE_TO_EXTENSION
};
const FILE_EXTENSION_TO_MIME_TYPE = {
	png: "image/png",
	jpg: "image/jpeg",
	jpeg: "image/jpeg",
	webp: "image/webp",
	pdf: "application/pdf",
	...TEXT_DOCUMENT_EXTENSION_TO_MIME_TYPE,
	docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
	xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
	pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
	odt: "application/vnd.oasis.opendocument.text",
	ods: "application/vnd.oasis.opendocument.spreadsheet",
	odp: "application/vnd.oasis.opendocument.presentation",
	pages: "application/vnd.apple.pages",
	numbers: "application/vnd.apple.numbers",
	key: "application/vnd.apple.keynote"
};
const MIME_ALIAS_TO_CANONICAL_MIME_TYPE = {
	"application/x-sql": "text/x-sql",
	"application/x-scala": "text/x-scala",
	"application/x-rust": "text/x-rust",
	"application/x-patch": "text/x-patch",
	"text/x-script.python": "text/x-python",
	"text/x-golang": "text/x-go",
	"application/x-php": "text/x-php",
	"application/x-httpd-php": "text/x-php",
	"application/x-httpd-php-source": "text/x-php",
	"application/x-bash": "text/x-bash",
	"text/x-typescript": "application/typescript",
	"text/javascript": "application/javascript",
	"application/x-awk": "text/x-awk",
	"application/x-protobuf": "text/x-protobuf",
	"application/x-terraform": "text/x-terraform",
	"text/x-toml": "application/toml",
	"application/x-toml": "application/toml",
	"application/x-graphql": "application/graphql",
	"text/x-graphql": "application/graphql",
	"application/x-json5": "application/json5",
	"text/x-yaml": "application/yaml",
	"application/x-yaml": "application/yaml",
	"application/x-subrip": "text/srt",
	"text/x-subrip": "text/srt"
};
const dataUriSubtypes = Array.from(ALLOWED_IMAGE_MIME_TYPES).flatMap((mime) => {
	const subtype = mime.replace("image/", "");
	return subtype === "jpeg" ? ["jpeg", "jpg"] : [subtype];
});
const escapeForRegex = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const officeDataUriMimePattern = Object.keys(ZIP_DOCUMENT_MIME_TYPE_TO_EXTENSION).map(escapeForRegex).join("|");
const textDocumentDataUriMimePattern = Array.from(ALLOWED_TEXT_DOCUMENT_MIME_TYPES).map(escapeForRegex).join("|");
const DATA_URI_IMAGE_BASE64_REGEX = /* @__PURE__ */ new RegExp(`^data:image/(${dataUriSubtypes.join("|")});base64,`);
const DATA_URI_PDF_BASE64_REGEX = /^data:application\/pdf;base64,/;
const DATA_URI_TEXT_BASE64_REGEX = /* @__PURE__ */ new RegExp(`^data:(?:${textDocumentDataUriMimePattern});base64,`);
const DATA_URI_OFFICE_BASE64_REGEX = /* @__PURE__ */ new RegExp(`^data:(?:${officeDataUriMimePattern});base64,`);
function normalizeMimeType(mimeType) {
	return mimeType.split(";")[0]?.trim().toLowerCase() || "";
}
function canonicalizeMimeType(mimeType, filename) {
	if (filename) {
		const dotIndex = filename.lastIndexOf(".");
		if (dotIndex !== -1) {
			const canonical = FILE_EXTENSION_TO_MIME_TYPE[filename.slice(dotIndex + 1).toLowerCase()];
			if (canonical) return canonical;
		}
	}
	const normalizedMimeType = normalizeMimeType(mimeType);
	return MIME_ALIAS_TO_CANONICAL_MIME_TYPE[normalizedMimeType] ?? normalizedMimeType;
}
function getExtensionFromMimeType(mimeType) {
	if (!mimeType) return "bin";
	const normalizedMimeType = normalizeMimeType(mimeType);
	return FILE_MIME_TYPE_TO_EXTENSION[normalizedMimeType] || normalizedMimeType.split("/")[1] || "bin";
}
function isOfficeDocumentMimeType(mimeType) {
	if (!mimeType) return false;
	return ALLOWED_OFFICE_DOCUMENT_MIME_TYPES.has(normalizeMimeType(mimeType));
}
function getMimeTypeFromExtension(extension) {
	if (!extension) return "application/octet-stream";
	return FILE_EXTENSION_TO_MIME_TYPE[extension.replace(/^\./, "").trim().toLowerCase()] || "application/octet-stream";
}

//#endregion
export { ALLOWED_IMAGE_MIME_TYPES, ALLOWED_OFFICE_DOCUMENT_MIME_TYPES, ALLOWED_TEXT_DOCUMENT_MIME_TYPES, DATA_URI_IMAGE_BASE64_REGEX, DATA_URI_OFFICE_BASE64_REGEX, DATA_URI_PDF_BASE64_REGEX, DATA_URI_TEXT_BASE64_REGEX, MIME_ALIAS_TO_CANONICAL_MIME_TYPE, ZIP_DOCUMENT_EXTENSIONS, ZIP_DOCUMENT_EXTENSIONS_LABEL, canonicalizeMimeType, getExtensionFromMimeType, getMimeTypeFromExtension, isOfficeDocumentMimeType, normalizeMimeType };