import { $ as e, F as t, H as n, N as r, P as i, S as a, _ as o, at as s, b as c, ct as l, d as u, g as d, h as f, j as ee, lt as p, m, n as h, p as g, r as _, st as v, u as te, w as y, y as b } from "./draggable-Bcb86AsV.js";
import { Dt as ne, O as x, w as S, xt as re } from "./features-BnG-dhzy.js";
import { L as ie, U as ae, k as oe, y as se, z as ce } from "./icons-B_185qj_.js";
import { a as le, c as ue, d as C, f as w, h as T, i as E, l as D, n as O, o as k, p as A, r as j, s as M, t as N, u as P } from "./media-library-DxpFw4Tt.js";
//#region ../media-library/src/standalone/MediaLibrary.vue?vue&type=script&setup=true&lang.ts
var F = {
	class: "tpl tpl:flex tpl:flex-col tpl:overflow-hidden tpl:rounded-[var(--tpl-radius-lg)]",
	style: {
		width: "100%",
		height: "100%",
		"background-color": "var(--tpl-bg-elevated)",
		border: "1px solid var(--tpl-border)"
	}
}, I = {
	class: "tpl:flex tpl:shrink-0 tpl:items-center tpl:justify-between tpl:border-b tpl:px-5 tpl:py-3.5",
	style: { "border-color": "var(--tpl-border)" }
}, L = {
	class: "tpl:text-sm tpl:font-semibold",
	style: { color: "var(--tpl-text)" }
}, R = { class: "tpl:flex tpl:items-center tpl:gap-3" }, z = { class: "tpl:relative" }, B = ["value", "placeholder"], V = { class: "tpl:flex tpl:min-h-0 tpl:flex-1 tpl:overflow-hidden" }, H = {
	key: 0,
	class: "tpl:flex tpl:w-48 tpl:shrink-0 tpl:flex-col tpl:border-r",
	style: {
		"border-color": "var(--tpl-border)",
		"background-color": "var(--tpl-bg)"
	}
}, U = { class: "tpl:flex tpl:min-w-0 tpl:flex-1 tpl:flex-col" }, de = {
	class: "tpl:flex tpl:shrink-0 tpl:items-center tpl:justify-between tpl:border-b tpl:px-4 tpl:py-2.5",
	style: { "border-color": "var(--tpl-border)" }
}, fe = { class: "tpl:flex tpl:items-center tpl:gap-2" }, pe = ["title"], me = {
	key: 1,
	class: "tpl:text-xs tpl:font-medium",
	style: { color: "var(--tpl-text)" }
}, he = {
	class: "tpl:flex tpl:rounded-md tpl:p-0.5",
	style: {
		border: "1px solid var(--tpl-border)",
		"background-color": "var(--tpl-bg)"
	}
}, ge = ["title"], _e = ["title"], ve = { class: "tpl:flex tpl:items-center tpl:gap-2" }, ye = ["value"], be = { value: "" }, xe = ["value"], Se = ["value"], Ce = { value: "newest" }, we = { value: "oldest" }, Te = { value: "name_asc" }, Ee = { value: "name_desc" }, De = { value: "size_asc" }, Oe = { value: "size_desc" }, ke = { class: "tpl:min-h-0 tpl:flex-1 tpl:overflow-y-auto" }, Ae = {
	key: 0,
	class: "tpl:px-4 tpl:pt-3"
}, je = {
	class: "tpl-scale-in tpl:mx-4 tpl:w-full tpl:max-w-sm tpl:rounded-[var(--tpl-radius-lg)] tpl:p-5",
	style: {
		"background-color": "var(--tpl-bg-elevated)",
		"box-shadow": "var(--tpl-shadow-xl)"
	}
}, Me = {
	class: "tpl:mb-2 tpl:text-sm tpl:font-semibold",
	style: { color: "var(--tpl-text)" }
}, Ne = {
	key: 0,
	class: "tpl:mb-4 tpl:text-xs",
	style: { color: "var(--tpl-text-muted)" }
}, Pe = {
	key: 1,
	class: "tpl:mb-4 tpl:max-h-32 tpl:overflow-y-auto tpl:rounded tpl:border tpl:p-2",
	style: { "border-color": "var(--tpl-border)" }
}, Fe = { class: "tpl:font-medium" }, Ie = { style: { color: "var(--tpl-text-muted)" } }, Le = { class: "tpl:flex tpl:justify-end tpl:gap-2" }, Re = {
	class: "tpl:flex tpl:shrink-0 tpl:items-center tpl:justify-between tpl:border-t tpl:px-5 tpl:py-3",
	style: { "border-color": "var(--tpl-border)" }
}, ze = { class: "tpl:flex tpl:min-w-0 tpl:flex-1 tpl:items-center tpl:gap-3" }, Be = { class: "tpl:flex tpl:items-center tpl:gap-5" }, Ve = {
	key: 0,
	class: "tpl:flex tpl:items-center tpl:gap-2"
}, He = {
	key: 1,
	class: "tpl:relative"
}, Ue = { class: "tpl:flex tpl:items-center tpl:gap-2" }, W = ["disabled"], G = /* @__PURE__ */ a({
	__name: "MediaLibrary",
	props: {
		authManager: {},
		projectId: {},
		planConfig: {},
		translations: {},
		onSelect: { type: Function },
		onError: { type: Function }
	},
	emits: ["ready"],
	setup(a, { emit: _ }) {
		let y = a, x = _, S = g(() => y.translations);
		i("translations", y.translations), i("authManager", y.authManager), i("projectId", g(() => y.projectId)), i("planConfig", {
			config: e(y.planConfig),
			isLoading: e(!1),
			hasFeature: (e) => y.planConfig.features[e] ?? !1,
			features: g(() => y.planConfig.features),
			fetchConfig: async () => {}
		});
		let N = g(() => y.planConfig.features.media_folders ?? !1), G = g(() => y.planConfig.features.import_from_url ?? !1), K = g(() => y.planConfig.storage.used_bytes ?? 0), q = g(() => y.planConfig.storage.limit_bytes ?? 0), { availableCategories: J } = w(), Y = T({
			projectId: y.projectId,
			authManager: y.authManager,
			onError: y.onError
		}), X = O({
			library: Y,
			canUseMediaFolders: N,
			translations: S
		});
		function Z() {
			if (!Y.previewItem.value) return;
			let e = Y.previewItem.value;
			y.onSelect?.({
				...e,
				url: X.selectedUrl.value || e.url
			});
		}
		return ee(() => {
			Y.loadItems(), Y.loadFrequentlyUsed(), x("ready");
		}), (e, i) => (r(), o("div", F, [
			m("div", I, [m("h2", L, p(S.value.mediaLibrary.title), 1), m("div", R, [c(j, {
				"used-bytes": K.value,
				"limit-bytes": q.value,
				size: 22
			}, null, 8, ["used-bytes", "limit-bytes"]), m("div", z, [m("input", {
				value: s(X).searchInput.value,
				type: "text",
				class: "tpl:w-52 tpl:rounded-md tpl:border tpl:py-1.5 tpl:pr-3 tpl:pl-8 tpl:text-xs tpl:shadow-xs tpl:transition-all tpl:duration-150 tpl:outline-none tpl:focus:shadow-[var(--tpl-ring)]",
				style: {
					"border-color": "var(--tpl-border)",
					"background-color": "var(--tpl-bg)",
					color: "var(--tpl-text)"
				},
				placeholder: S.value.mediaLibrary.searchPlaceholder,
				onInput: i[0] ||= (e) => s(X).handleSearchInput(e.target.value)
			}, null, 40, B), c(s(se), {
				class: "tpl:absolute tpl:top-1/2 tpl:left-2.5 tpl:-translate-y-1/2",
				size: 13,
				"stroke-width": 2,
				style: { color: "var(--tpl-text-dim)" }
			})])])]),
			m("div", V, [c(h, {
				"enter-active-class": "tpl:transition-all tpl:duration-200 tpl:ease-out",
				"enter-from-class": "tpl:-ml-48 tpl:opacity-0",
				"enter-to-class": "tpl:ml-0 tpl:opacity-100",
				"leave-active-class": "tpl:transition-all tpl:duration-150 tpl:ease-in",
				"leave-from-class": "tpl:ml-0 tpl:opacity-100",
				"leave-to-class": "tpl:-ml-48 tpl:opacity-0"
			}, {
				default: n(() => [N.value && s(X).showSidebar.value ? (r(), o("div", H, [c(P, {
					folders: s(Y).folders.value,
					"current-folder-id": s(Y).currentFolderId.value,
					"view-mode": s(Y).viewMode.value,
					"has-frequently-used": s(X).hasFrequentlyUsed.value,
					onNavigate: s(Y).navigateToFolder,
					onCreateFolder: s(X).handleCreateFolder,
					onRenameFolder: s(X).handleRenameFolder,
					onDeleteFolder: s(X).handleDeleteFolder,
					onShowFrequentlyUsed: s(Y).showFrequentlyUsed
				}, null, 8, [
					"folders",
					"current-folder-id",
					"view-mode",
					"has-frequently-used",
					"onNavigate",
					"onCreateFolder",
					"onRenameFolder",
					"onDeleteFolder",
					"onShowFrequentlyUsed"
				])])) : d("", !0)]),
				_: 1
			}), m("div", U, [m("div", de, [m("div", fe, [
				N.value ? (r(), o("button", {
					key: 0,
					class: "tpl:flex tpl:size-7 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:rounded-md tpl:transition-all tpl:duration-150",
					style: l({
						color: s(X).showSidebar.value ? "var(--tpl-primary)" : "var(--tpl-text-muted)",
						backgroundColor: s(X).showSidebar.value ? "var(--tpl-bg)" : "transparent",
						border: s(X).showSidebar.value ? "1px solid var(--tpl-border)" : "1px solid transparent"
					}),
					title: s(X).showSidebar.value ? S.value.mediaLibrary.hideFolders : S.value.mediaLibrary.showFolders,
					onClick: i[1] ||= (e) => s(X).showSidebar.value = !s(X).showSidebar.value
				}, [c(s(oe), {
					size: 16,
					"stroke-width": 2
				})], 12, pe)) : d("", !0),
				s(Y).viewMode.value === "frequently-used" ? (r(), o("span", me, p(S.value.mediaLibrary.frequentlyUsed), 1)) : (r(), f(A, {
					key: 2,
					folders: s(Y).folders.value,
					"current-folder-id": s(Y).currentFolderId.value,
					onNavigate: s(Y).navigateToFolder
				}, null, 8, [
					"folders",
					"current-folder-id",
					"onNavigate"
				])),
				m("div", he, [m("button", {
					class: "tpl:flex tpl:size-6 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:rounded tpl:transition-all tpl:duration-150",
					style: l({
						color: s(X).layoutMode.value === "grid" ? "var(--tpl-primary)" : "var(--tpl-text-muted)",
						backgroundColor: s(X).layoutMode.value === "grid" ? "var(--tpl-bg-elevated)" : "transparent"
					}),
					title: S.value.mediaLibrary.viewGrid,
					onClick: i[2] ||= (e) => s(X).layoutMode.value = "grid"
				}, [c(s(ae), {
					size: 14,
					"stroke-width": 2
				})], 12, ge), m("button", {
					class: "tpl:flex tpl:size-6 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:rounded tpl:transition-all tpl:duration-150",
					style: l({
						color: s(X).layoutMode.value === "list" ? "var(--tpl-primary)" : "var(--tpl-text-muted)",
						backgroundColor: s(X).layoutMode.value === "list" ? "var(--tpl-bg-elevated)" : "transparent"
					}),
					title: S.value.mediaLibrary.viewList,
					onClick: i[3] ||= (e) => s(X).layoutMode.value = "list"
				}, [c(s(ie), {
					size: 14,
					"stroke-width": 2
				})], 12, _e)])
			]), m("div", ve, [s(J).length > 1 ? (r(), o("select", {
				key: 0,
				class: "tpl:rounded-md tpl:border tpl:py-1.5 tpl:pr-7 tpl:pl-2.5 tpl:text-xs tpl:transition-all tpl:duration-150 tpl:outline-none",
				style: {
					"border-color": "var(--tpl-border)",
					"background-color": "var(--tpl-bg)",
					color: "var(--tpl-text)"
				},
				value: s(Y).categoryFilter.value ?? "",
				onChange: i[4] ||= (e) => s(Y).filterByCategory(e.target.value || null)
			}, [m("option", be, p(S.value.mediaLibrary.filterAll), 1), (r(!0), o(u, null, t(s(J), (e) => (r(), o("option", {
				key: e,
				value: e
			}, p(s(X).getCategoryLabel(e)), 9, xe))), 128))], 40, ye)) : d("", !0), m("select", {
				class: "tpl:rounded-md tpl:border tpl:py-1.5 tpl:pr-7 tpl:pl-2.5 tpl:text-xs tpl:transition-all tpl:duration-150 tpl:outline-none",
				style: {
					"border-color": "var(--tpl-border)",
					"background-color": "var(--tpl-bg)",
					color: "var(--tpl-text)"
				},
				value: s(Y).sortOption.value,
				onChange: i[5] ||= (e) => s(Y).sortBy(e.target.value)
			}, [
				m("option", Ce, p(S.value.mediaLibrary.sortNewest), 1),
				m("option", we, p(S.value.mediaLibrary.sortOldest), 1),
				m("option", Te, p(S.value.mediaLibrary.sortNameAsc), 1),
				m("option", Ee, p(S.value.mediaLibrary.sortNameDesc), 1),
				m("option", De, p(S.value.mediaLibrary.sortSizeAsc), 1),
				m("option", Oe, p(S.value.mediaLibrary.sortSizeDesc), 1)
			], 40, Se)])]), m("div", ke, [s(Y).viewMode.value === "files" ? (r(), o("div", Ae, [c(E, {
				"is-uploading": s(Y).isUploading.value,
				"upload-progress": s(Y).uploadProgress.value,
				onUpload: s(X).handleUpload
			}, null, 8, [
				"is-uploading",
				"upload-progress",
				"onUpload"
			]), G.value ? (r(), o("button", {
				key: 0,
				class: "tpl:mt-2 tpl:flex tpl:w-full tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:gap-1.5 tpl:rounded-md tpl:border tpl:border-dashed tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150",
				style: {
					"border-color": "var(--tpl-border)",
					color: "var(--tpl-text-muted)",
					"background-color": "var(--tpl-bg)"
				},
				onClick: i[6] ||= (e) => s(X).showImportUrlModal.value = !0
			}, [c(s(ce), {
				size: 14,
				"stroke-width": 2
			}), b(" " + p(S.value.mediaLibrary.importFromUrl), 1)])) : d("", !0)])) : d("", !0), c(D, {
				items: s(X).displayItems.value,
				"selected-ids": s(Y).selectedItems.value,
				"is-loading": s(Y).isLoading.value,
				"has-more": s(Y).viewMode.value === "files" && s(Y).hasMore.value,
				layout: s(X).layoutMode.value,
				onSelect: s(X).handleSelect,
				onToggle: s(Y).toggleSelection,
				onLoadMore: s(Y).loadMore,
				onEdit: s(X).handleEditItem,
				onReplace: s(X).handleReplaceItem
			}, null, 8, [
				"items",
				"selected-ids",
				"is-loading",
				"has-more",
				"layout",
				"onSelect",
				"onToggle",
				"onLoadMore",
				"onEdit",
				"onReplace"
			])])])]),
			c(ue, {
				visible: s(X).showImportUrlModal.value,
				"is-importing": s(Y).isImportingFromUrl.value,
				error: s(Y).importFromUrlError.value,
				onImport: s(X).handleImportFromUrl,
				onClose: i[7] ||= (e) => s(X).showImportUrlModal.value = !1
			}, null, 8, [
				"visible",
				"is-importing",
				"error",
				"onImport"
			]),
			c(C, {
				visible: !!s(X).editingItem.value,
				item: s(X).editingItem.value,
				onSave: s(X).handleEditSave,
				onClose: i[8] ||= (e) => s(X).editingItem.value = null
			}, null, 8, [
				"visible",
				"item",
				"onSave"
			]),
			c(le, {
				visible: s(Y).showReplaceWarning.value,
				item: s(Y).pendingReplaceItem.value,
				"usage-info": s(Y).replaceUsageInfo.value,
				"is-replacing": s(Y).isReplacing.value,
				error: s(Y).replaceError.value,
				onReplace: s(X).handleReplaceFile,
				onClose: s(Y).cancelReplace
			}, null, 8, [
				"visible",
				"item",
				"usage-info",
				"is-replacing",
				"error",
				"onReplace",
				"onClose"
			]),
			c(h, {
				"enter-active-class": "tpl:transition tpl:ease-out tpl:duration-150",
				"enter-from-class": "tpl:opacity-0",
				"enter-to-class": "tpl:opacity-100",
				"leave-active-class": "tpl:transition tpl:ease-in tpl:duration-100",
				"leave-from-class": "tpl:opacity-100",
				"leave-to-class": "tpl:opacity-0"
			}, {
				default: n(() => [s(Y).showDeleteWarning.value ? (r(), o("div", {
					key: 0,
					class: "tpl:absolute tpl:inset-0 tpl:z-10 tpl:flex tpl:items-center tpl:justify-center tpl:rounded-[var(--tpl-radius-lg)]",
					style: {
						"background-color": "rgba(0, 0, 0, 0.5)",
						"backdrop-filter": "blur(8px)",
						"-webkit-backdrop-filter": "blur(8px)"
					},
					onClick: i[11] ||= te((...e) => s(Y).cancelDelete && s(Y).cancelDelete(...e), ["self"])
				}, [m("div", je, [
					m("h3", Me, p(S.value.mediaLibrary.deleteWarningTitle), 1),
					m("p", {
						class: v(["tpl:text-xs", s(X).hasUsedFiles.value ? "tpl:mb-2" : "tpl:mb-4"]),
						style: { color: "var(--tpl-text-muted)" }
					}, p(S.value.mediaLibrary.deleteWarningMessage), 3),
					s(X).hasUsedFiles.value ? (r(), o("p", Ne, p(S.value.mediaLibrary.deleteWarningUsageNote), 1)) : d("", !0),
					s(X).hasUsedFiles.value ? (r(), o("div", Pe, [(r(!0), o(u, null, t(s(Y).deleteUsageInfo.value, (e, t) => (r(), o("div", {
						key: t,
						class: "tpl:text-xs",
						style: { color: "var(--tpl-text)" }
					}, [e.template_count > 0 ? (r(), o(u, { key: 0 }, [m("span", Fe, p(s(X).displayItems.value.find((e) => e.id === t)?.filename || t), 1), m("span", Ie, " - " + p(S.value.mediaLibrary.usedInTemplates.replace("{count}", e.template_count.toString())), 1)], 64)) : d("", !0)]))), 128))])) : d("", !0),
					m("div", Le, [m("button", {
						class: "tpl:cursor-pointer tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150",
						style: {
							"border-color": "var(--tpl-border)",
							color: "var(--tpl-text)",
							"background-color": "var(--tpl-bg)"
						},
						onClick: i[9] ||= (...e) => s(Y).cancelDelete && s(Y).cancelDelete(...e)
					}, p(S.value.mediaLibrary.cancel), 1), m("button", {
						class: "tpl:cursor-pointer tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150",
						style: {
							"border-color": "var(--tpl-danger)",
							color: "var(--tpl-danger)",
							"background-color": "var(--tpl-danger-light)"
						},
						onClick: i[10] ||= (...e) => s(Y).confirmDelete && s(Y).confirmDelete(...e)
					}, p(s(X).hasUsedFiles.value ? S.value.mediaLibrary.deleteAnyway : S.value.mediaLibrary.confirmDelete), 1)])
				])])) : d("", !0)]),
				_: 1
			}),
			m("div", Re, [m("div", ze, [s(Y).previewItem.value ? (r(), f(k, {
				key: 0,
				"selected-conversion": s(X).selectedConversion.value,
				"onUpdate:selectedConversion": i[12] ||= (e) => s(X).selectedConversion.value = e,
				item: s(Y).previewItem.value,
				folders: s(Y).folders.value
			}, null, 8, [
				"selected-conversion",
				"item",
				"folders"
			])) : d("", !0)]), m("div", Be, [s(Y).selectedItems.value.size > 0 ? (r(), o("div", Ve, [s(Y).previewItem.value ? (r(), o("button", {
				key: 0,
				class: "tpl:flex tpl:cursor-pointer tpl:items-center tpl:gap-1 tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150",
				style: l({
					borderColor: s(X).copied.value ? "var(--tpl-success)" : "var(--tpl-border)",
					color: s(X).copied.value ? "var(--tpl-success)" : "var(--tpl-text)",
					backgroundColor: "var(--tpl-bg)"
				}),
				onClick: i[13] ||= (e) => s(X).copy(s(X).selectedUrl.value)
			}, [s(X).copied.value ? (r(), f(s(ne), {
				key: 1,
				size: 12,
				"stroke-width": 2
			})) : (r(), f(s(re), {
				key: 0,
				size: 12,
				"stroke-width": 2
			})), b(" " + p(s(X).copied.value ? S.value.mediaLibrary.copied : S.value.mediaLibrary.copyUrl), 1)], 4)) : d("", !0), N.value ? (r(), o("div", He, [m("button", {
				class: "tpl:cursor-pointer tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150",
				style: {
					"border-color": "var(--tpl-border)",
					color: "var(--tpl-text)",
					"background-color": "var(--tpl-bg)"
				},
				onClick: i[14] ||= (e) => s(X).showMovePicker.value = !s(X).showMovePicker.value
			}, p(S.value.mediaLibrary.moveSelected), 1), s(X).showMovePicker.value ? (r(), f(M, {
				key: 0,
				folders: s(Y).folders.value,
				"current-folder-id": s(Y).currentFolderId.value,
				onSelect: s(X).handleMoveToFolder,
				onClose: i[15] ||= (e) => s(X).showMovePicker.value = !1
			}, null, 8, [
				"folders",
				"current-folder-id",
				"onSelect"
			])) : d("", !0)])) : d("", !0)])) : d("", !0), m("div", Ue, [s(Y).selectedItems.value.size > 0 ? (r(), o("button", {
				key: 0,
				class: "tpl:cursor-pointer tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150",
				style: {
					"border-color": "var(--tpl-danger)",
					color: "var(--tpl-danger)",
					"background-color": "var(--tpl-danger-light)"
				},
				onClick: i[16] ||= (...e) => s(X).handleDeleteClick && s(X).handleDeleteClick(...e)
			}, p(S.value.mediaLibrary.deleteSelected), 1)) : d("", !0), a.onSelect ? (r(), o("button", {
				key: 1,
				class: "tpl:cursor-pointer tpl:rounded-md tpl:px-4 tpl:py-1.5 tpl:text-sm tpl:font-medium tpl:shadow-xs tpl:transition-all tpl:duration-150 tpl:hover:opacity-90 tpl:disabled:cursor-not-allowed tpl:disabled:opacity-50",
				style: {
					"background-color": "var(--tpl-primary)",
					color: "var(--tpl-bg)"
				},
				disabled: !s(Y).previewItem.value,
				onClick: Z
			}, p(S.value.mediaLibrary.selectFile), 9, W)) : d("", !0)])])])
		]));
	}
}), K = (e, t, n) => {
	let r = t.lastIndexOf("?"), i = e[r === -1 || r < t.lastIndexOf("/") ? t : t.slice(0, r)];
	return i ? typeof i == "function" ? i() : Promise.resolve(i) : new Promise((e, r) => {
		(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(r.bind(null, /* @__PURE__ */ Error("Unknown variable dynamic import: " + t + (t.split("/").length === n ? "" : ". Note that variables only represent file names one level deep."))));
	});
}, q = ["en", "de"];
function J(e) {
	return e.split("-")[0].toLowerCase();
}
async function Y(e) {
	let t = J(e), n = q.includes(t) ? t : "en";
	return (await K(/* @__PURE__ */ Object.assign({
		"./locales/de.ts": () => import("./de-CGu9U1iv.js"),
		"./locales/en.ts": () => import("./en-C3WMCISl.js")
	}), `./locales/${n}.ts`, 3)).default;
}
//#endregion
//#region ../media-library/src/standalone/visual.ts
var X = null, Z = e(null);
async function We(e) {
	let t = typeof e.container == "string" ? document.querySelector(e.container) : e.container;
	if (!t) throw Error(`Container element not found: ${e.container}`);
	let n = x(e.auth, e.onError);
	await n.initialize();
	let r = await new S(n).fetchConfig(), i = await Y(e.locale ?? "en");
	return $(t, e.theme), X && Q(), new Promise((a, o) => {
		try {
			X = _({ setup() {
				let o = () => {
					a({
						setTheme: (e) => $(t, e),
						unmount: Q
					});
				};
				return () => y(G, {
					authManager: n,
					projectId: n.projectId,
					planConfig: r,
					translations: i,
					onSelect: e.onSelect,
					onError: e.onError,
					ref: Z,
					onReady: o
				});
			} }), X.mount(t);
		} catch (e) {
			o(e);
		}
	});
}
function Q() {
	X && (X.unmount(), X = null, Z.value = null);
}
function $(e, t) {
	t && (t.primaryColor && e.style.setProperty("--tpl-primary", t.primaryColor), t.borderRadius !== void 0 && (e.style.setProperty("--tpl-radius", `${t.borderRadius}px`), e.style.setProperty("--tpl-radius-sm", `${Math.max(0, t.borderRadius - 3)}px`), e.style.setProperty("--tpl-radius-lg", `${t.borderRadius + 4}px`)));
}
typeof window < "u" && (window.TemplaticalMedia = {
	init: We,
	unmount: Q
});
//#endregion
export { N as MediaLibraryModal };

//# sourceMappingURL=src-Cw7KAyui.js.map