import { A as e, C as t, M as n, N as r, P as i, V as a, Z as o, ct as s, f as c, g as l, h as u, it as d, l as ee, m as f, n as p, ot as te, p as m, r as h, st as g, u as _, v, x as y, y as b } from "./draggable-P6QWzy4g.js";
import { At as x, T as S, k as C, wt as ne } from "./features-CgTy87Ni.js";
import { A as re, G as ie, R as ae, V as oe, b as se } from "./icons-DxJ--AJb.js";
import { a as ce, c as le, d as ue, f as de, h as fe, i as w, l as T, n as E, o as D, p as O, r as k, s as A, t as j, u as M } from "./media-library-Byh_BbTm.js";
//#region ../media-library/src/standalone/MediaLibrary.vue?vue&type=script&setup=true&lang.ts
var N = {
	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)"
	}
}, P = {
	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)" }
}, F = {
	class: "tpl:text-sm tpl:font-semibold",
	style: { color: "var(--tpl-text)" }
}, I = { class: "tpl:flex tpl:items-center tpl:gap-3" }, L = { class: "tpl:relative" }, R = ["value", "placeholder"], z = { class: "tpl:flex tpl:min-h-0 tpl:flex-1 tpl:overflow-hidden" }, B = {
	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)"
	}
}, V = { class: "tpl:flex tpl:min-w-0 tpl:flex-1 tpl:flex-col" }, pe = {
	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)" }
}, me = { class: "tpl:flex tpl:items-center tpl:gap-2" }, he = ["title"], ge = {
	key: 1,
	class: "tpl:text-xs tpl:font-medium",
	style: { color: "var(--tpl-text)" }
}, _e = {
	class: "tpl:flex tpl:rounded-md tpl:p-0.5",
	style: {
		border: "1px solid var(--tpl-border)",
		"background-color": "var(--tpl-bg)"
	}
}, ve = ["title"], ye = ["title"], be = { class: "tpl:flex tpl:items-center tpl:gap-2" }, xe = ["value"], Se = { value: "" }, Ce = ["value"], we = ["value"], Te = { value: "newest" }, Ee = { value: "oldest" }, De = { value: "name_asc" }, Oe = { value: "name_desc" }, ke = { value: "size_asc" }, Ae = { value: "size_desc" }, je = { class: "tpl:min-h-0 tpl:flex-1 tpl:overflow-y-auto" }, Me = {
	key: 0,
	class: "tpl:px-4 tpl:pt-3"
}, Ne = {
	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)"
	}
}, Pe = {
	class: "tpl:mb-2 tpl:text-sm tpl:font-semibold",
	style: { color: "var(--tpl-text)" }
}, Fe = {
	key: 0,
	class: "tpl:mb-4 tpl:text-xs",
	style: { color: "var(--tpl-text-muted)" }
}, Ie = {
	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)" }
}, Le = { class: "tpl:font-medium" }, Re = { style: { color: "var(--tpl-text-muted)" } }, ze = { class: "tpl:flex tpl:justify-end tpl:gap-2" }, Be = {
	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)" }
}, Ve = { class: "tpl:flex tpl:min-w-0 tpl:flex-1 tpl:items-center tpl:gap-3" }, He = { class: "tpl:flex tpl:items-center tpl:gap-5" }, Ue = {
	key: 0,
	class: "tpl:flex tpl:items-center tpl:gap-2"
}, We = {
	key: 1,
	class: "tpl:relative"
}, Ge = { class: "tpl:flex tpl:items-center tpl:gap-2" }, H = ["disabled"], U = /* @__PURE__ */ y({
	__name: "MediaLibrary",
	props: {
		authManager: {},
		projectId: {},
		planConfig: {},
		translations: {},
		onSelect: { type: Function },
		onError: { type: Function }
	},
	emits: ["ready"],
	setup(t, { emit: h }) {
		let y = t, S = h, C = c(() => y.translations);
		r("translations", y.translations), r("authManager", y.authManager), r("projectId", c(() => y.projectId)), r("planConfig", {
			config: o(y.planConfig),
			isLoading: o(!1),
			hasFeature: (e) => y.planConfig.features[e] ?? !1,
			features: c(() => y.planConfig.features),
			fetchConfig: async () => {}
		});
		let j = c(() => y.planConfig.features.media_folders ?? !1), U = c(() => y.planConfig.features.import_from_url ?? !1), W = c(() => y.planConfig.storage.used_bytes ?? 0), G = c(() => y.planConfig.storage.limit_bytes ?? 0), { availableCategories: K } = de(), q = fe({
			projectId: y.projectId,
			authManager: y.authManager,
			onError: y.onError
		}), J = E({
			library: q,
			canUseMediaFolders: j,
			translations: C
		});
		function Y() {
			if (!q.previewItem.value) return;
			let e = q.previewItem.value;
			y.onSelect?.({
				...e,
				url: J.selectedUrl.value || e.url
			});
		}
		return e(() => {
			q.loadItems(), q.loadFrequentlyUsed(), S("ready");
		}), (e, r) => (n(), l("div", N, [
			m("div", P, [m("h2", F, s(C.value.mediaLibrary.title), 1), m("div", I, [b(k, {
				"used-bytes": W.value,
				"limit-bytes": G.value,
				size: 22
			}, null, 8, ["used-bytes", "limit-bytes"]), m("div", L, [m("input", {
				value: d(J).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: C.value.mediaLibrary.searchPlaceholder,
				onInput: r[0] ||= (e) => d(J).handleSearchInput(e.target.value)
			}, null, 40, R), b(d(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", z, [b(p, {
				"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: a(() => [j.value && d(J).showSidebar.value ? (n(), l("div", B, [b(M, {
					folders: d(q).folders.value,
					"current-folder-id": d(q).currentFolderId.value,
					"view-mode": d(q).viewMode.value,
					"has-frequently-used": d(J).hasFrequentlyUsed.value,
					onNavigate: d(q).navigateToFolder,
					onCreateFolder: d(J).handleCreateFolder,
					onRenameFolder: d(J).handleRenameFolder,
					onDeleteFolder: d(J).handleDeleteFolder,
					onShowFrequentlyUsed: d(q).showFrequentlyUsed
				}, null, 8, [
					"folders",
					"current-folder-id",
					"view-mode",
					"has-frequently-used",
					"onNavigate",
					"onCreateFolder",
					"onRenameFolder",
					"onDeleteFolder",
					"onShowFrequentlyUsed"
				])])) : u("", !0)]),
				_: 1
			}), m("div", V, [m("div", pe, [m("div", me, [
				j.value ? (n(), l("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: g({
						color: d(J).showSidebar.value ? "var(--tpl-primary)" : "var(--tpl-text-muted)",
						backgroundColor: d(J).showSidebar.value ? "var(--tpl-bg)" : "transparent",
						border: d(J).showSidebar.value ? "1px solid var(--tpl-border)" : "1px solid transparent"
					}),
					title: d(J).showSidebar.value ? C.value.mediaLibrary.hideFolders : C.value.mediaLibrary.showFolders,
					onClick: r[1] ||= (e) => d(J).showSidebar.value = !d(J).showSidebar.value
				}, [b(d(re), {
					size: 16,
					"stroke-width": 2
				})], 12, he)) : u("", !0),
				d(q).viewMode.value === "frequently-used" ? (n(), l("span", ge, s(C.value.mediaLibrary.frequentlyUsed), 1)) : (n(), f(O, {
					key: 2,
					folders: d(q).folders.value,
					"current-folder-id": d(q).currentFolderId.value,
					onNavigate: d(q).navigateToFolder
				}, null, 8, [
					"folders",
					"current-folder-id",
					"onNavigate"
				])),
				m("div", _e, [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: g({
						color: d(J).layoutMode.value === "grid" ? "var(--tpl-primary)" : "var(--tpl-text-muted)",
						backgroundColor: d(J).layoutMode.value === "grid" ? "var(--tpl-bg-elevated)" : "transparent"
					}),
					title: C.value.mediaLibrary.viewGrid,
					onClick: r[2] ||= (e) => d(J).layoutMode.value = "grid"
				}, [b(d(ie), {
					size: 14,
					"stroke-width": 2
				})], 12, ve), 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: g({
						color: d(J).layoutMode.value === "list" ? "var(--tpl-primary)" : "var(--tpl-text-muted)",
						backgroundColor: d(J).layoutMode.value === "list" ? "var(--tpl-bg-elevated)" : "transparent"
					}),
					title: C.value.mediaLibrary.viewList,
					onClick: r[3] ||= (e) => d(J).layoutMode.value = "list"
				}, [b(d(ae), {
					size: 14,
					"stroke-width": 2
				})], 12, ye)])
			]), m("div", be, [d(K).length > 1 ? (n(), l("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: d(q).categoryFilter.value ?? "",
				onChange: r[4] ||= (e) => d(q).filterByCategory(e.target.value || null)
			}, [m("option", Se, s(C.value.mediaLibrary.filterAll), 1), (n(!0), l(_, null, i(d(K), (e) => (n(), l("option", {
				key: e,
				value: e
			}, s(d(J).getCategoryLabel(e)), 9, Ce))), 128))], 40, xe)) : u("", !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: d(q).sortOption.value,
				onChange: r[5] ||= (e) => d(q).sortBy(e.target.value)
			}, [
				m("option", Te, s(C.value.mediaLibrary.sortNewest), 1),
				m("option", Ee, s(C.value.mediaLibrary.sortOldest), 1),
				m("option", De, s(C.value.mediaLibrary.sortNameAsc), 1),
				m("option", Oe, s(C.value.mediaLibrary.sortNameDesc), 1),
				m("option", ke, s(C.value.mediaLibrary.sortSizeAsc), 1),
				m("option", Ae, s(C.value.mediaLibrary.sortSizeDesc), 1)
			], 40, we)])]), m("div", je, [d(q).viewMode.value === "files" ? (n(), l("div", Me, [b(w, {
				"is-uploading": d(q).isUploading.value,
				"upload-progress": d(q).uploadProgress.value,
				onUpload: d(J).handleUpload
			}, null, 8, [
				"is-uploading",
				"upload-progress",
				"onUpload"
			]), U.value ? (n(), l("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: r[6] ||= (e) => d(J).showImportUrlModal.value = !0
			}, [b(d(oe), {
				size: 14,
				"stroke-width": 2
			}), v(" " + s(C.value.mediaLibrary.importFromUrl), 1)])) : u("", !0)])) : u("", !0), b(T, {
				items: d(J).displayItems.value,
				"selected-ids": d(q).selectedItems.value,
				"is-loading": d(q).isLoading.value,
				"has-more": d(q).viewMode.value === "files" && d(q).hasMore.value,
				layout: d(J).layoutMode.value,
				onSelect: d(J).handleSelect,
				onToggle: d(q).toggleSelection,
				onLoadMore: d(q).loadMore,
				onEdit: d(J).handleEditItem,
				onReplace: d(J).handleReplaceItem
			}, null, 8, [
				"items",
				"selected-ids",
				"is-loading",
				"has-more",
				"layout",
				"onSelect",
				"onToggle",
				"onLoadMore",
				"onEdit",
				"onReplace"
			])])])]),
			b(le, {
				visible: d(J).showImportUrlModal.value,
				"is-importing": d(q).isImportingFromUrl.value,
				error: d(q).importFromUrlError.value,
				onImport: d(J).handleImportFromUrl,
				onClose: r[7] ||= (e) => d(J).showImportUrlModal.value = !1
			}, null, 8, [
				"visible",
				"is-importing",
				"error",
				"onImport"
			]),
			b(ue, {
				visible: !!d(J).editingItem.value,
				item: d(J).editingItem.value,
				onSave: d(J).handleEditSave,
				onClose: r[8] ||= (e) => d(J).editingItem.value = null
			}, null, 8, [
				"visible",
				"item",
				"onSave"
			]),
			b(ce, {
				visible: d(q).showReplaceWarning.value,
				item: d(q).pendingReplaceItem.value,
				"usage-info": d(q).replaceUsageInfo.value,
				"is-replacing": d(q).isReplacing.value,
				error: d(q).replaceError.value,
				onReplace: d(J).handleReplaceFile,
				onClose: d(q).cancelReplace
			}, null, 8, [
				"visible",
				"item",
				"usage-info",
				"is-replacing",
				"error",
				"onReplace",
				"onClose"
			]),
			b(p, {
				"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: a(() => [d(q).showDeleteWarning.value ? (n(), l("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: r[11] ||= ee((...e) => d(q).cancelDelete && d(q).cancelDelete(...e), ["self"])
				}, [m("div", Ne, [
					m("h3", Pe, s(C.value.mediaLibrary.deleteWarningTitle), 1),
					m("p", {
						class: te(["tpl:text-xs", d(J).hasUsedFiles.value ? "tpl:mb-2" : "tpl:mb-4"]),
						style: { color: "var(--tpl-text-muted)" }
					}, s(C.value.mediaLibrary.deleteWarningMessage), 3),
					d(J).hasUsedFiles.value ? (n(), l("p", Fe, s(C.value.mediaLibrary.deleteWarningUsageNote), 1)) : u("", !0),
					d(J).hasUsedFiles.value ? (n(), l("div", Ie, [(n(!0), l(_, null, i(d(q).deleteUsageInfo.value, (e, t) => (n(), l("div", {
						key: t,
						class: "tpl:text-xs",
						style: { color: "var(--tpl-text)" }
					}, [e.template_count > 0 ? (n(), l(_, { key: 0 }, [m("span", Le, s(d(J).displayItems.value.find((e) => e.id === t)?.filename || t), 1), m("span", Re, " - " + s(C.value.mediaLibrary.usedInTemplates.replace("{count}", e.template_count.toString())), 1)], 64)) : u("", !0)]))), 128))])) : u("", !0),
					m("div", ze, [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: r[9] ||= (...e) => d(q).cancelDelete && d(q).cancelDelete(...e)
					}, s(C.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: r[10] ||= (...e) => d(q).confirmDelete && d(q).confirmDelete(...e)
					}, s(d(J).hasUsedFiles.value ? C.value.mediaLibrary.deleteAnyway : C.value.mediaLibrary.confirmDelete), 1)])
				])])) : u("", !0)]),
				_: 1
			}),
			m("div", Be, [m("div", Ve, [d(q).previewItem.value ? (n(), f(D, {
				key: 0,
				"selected-conversion": d(J).selectedConversion.value,
				"onUpdate:selectedConversion": r[12] ||= (e) => d(J).selectedConversion.value = e,
				item: d(q).previewItem.value,
				folders: d(q).folders.value
			}, null, 8, [
				"selected-conversion",
				"item",
				"folders"
			])) : u("", !0)]), m("div", He, [d(q).selectedItems.value.size > 0 ? (n(), l("div", Ue, [d(q).previewItem.value ? (n(), l("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: g({
					borderColor: d(J).copied.value ? "var(--tpl-success)" : "var(--tpl-border)",
					color: d(J).copied.value ? "var(--tpl-success)" : "var(--tpl-text)",
					backgroundColor: "var(--tpl-bg)"
				}),
				onClick: r[13] ||= (e) => d(J).copy(d(J).selectedUrl.value)
			}, [d(J).copied.value ? (n(), f(d(x), {
				key: 1,
				size: 12,
				"stroke-width": 2
			})) : (n(), f(d(ne), {
				key: 0,
				size: 12,
				"stroke-width": 2
			})), v(" " + s(d(J).copied.value ? C.value.mediaLibrary.copied : C.value.mediaLibrary.copyUrl), 1)], 4)) : u("", !0), j.value ? (n(), l("div", We, [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: r[14] ||= (e) => d(J).showMovePicker.value = !d(J).showMovePicker.value
			}, s(C.value.mediaLibrary.moveSelected), 1), d(J).showMovePicker.value ? (n(), f(A, {
				key: 0,
				folders: d(q).folders.value,
				"current-folder-id": d(q).currentFolderId.value,
				onSelect: d(J).handleMoveToFolder,
				onClose: r[15] ||= (e) => d(J).showMovePicker.value = !1
			}, null, 8, [
				"folders",
				"current-folder-id",
				"onSelect"
			])) : u("", !0)])) : u("", !0)])) : u("", !0), m("div", Ge, [d(q).selectedItems.value.size > 0 ? (n(), l("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: r[16] ||= (...e) => d(J).handleDeleteClick && d(J).handleDeleteClick(...e)
			}, s(C.value.mediaLibrary.deleteSelected), 1)) : u("", !0), t.onSelect ? (n(), l("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: !d(q).previewItem.value,
				onClick: Y
			}, s(C.value.mediaLibrary.selectFile), 9, H)) : u("", !0)])])])
		]));
	}
}), W = (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."))));
	});
}, G = [
	"en",
	"de",
	"pt-BR"
];
function K(e) {
	return e.trim().replace(/_/g, "-").toLowerCase();
}
function q(e) {
	let t = K(e);
	return G.find((e) => K(e) === t);
}
function J(e) {
	return K(e).split("-")[0];
}
function Y(e) {
	return q(e) ?? q(J(e)) ?? "en";
}
async function Ke(e) {
	let t = Y(e);
	return (await W(/* @__PURE__ */ Object.assign({
		"./locales/de.ts": () => import("./de-DG1WWVXM.js"),
		"./locales/en.ts": () => import("./en-BE6OV83-.js"),
		"./locales/pt-BR.ts": () => import("./pt-BR-BYRTP5Ww.js")
	}), `./locales/${t}.ts`, 3)).default;
}
//#endregion
//#region ../media-library/src/standalone/visual.ts
var X = null, Z = o(null);
async function qe(e) {
	let n = typeof e.container == "string" ? document.querySelector(e.container) : e.container;
	if (!n) throw Error(`Container element not found: ${e.container}`);
	let r = C(e.auth, e.onError);
	await r.initialize();
	let i = await new S(r).fetchConfig(), a = await Ke(e.locale ?? "en");
	return $(n, e.theme), X && Q(), new Promise((o, s) => {
		try {
			X = h({ setup() {
				let s = () => {
					o({
						setTheme: (e) => $(n, e),
						unmount: Q
					});
				};
				return () => t(U, {
					authManager: r,
					projectId: r.projectId,
					planConfig: i,
					translations: a,
					onSelect: e.onSelect,
					onError: e.onError,
					ref: Z,
					onReady: s
				});
			} }), X.mount(n);
		} catch (e) {
			s(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: qe,
	unmount: Q
});
//#endregion
export { j as MediaLibraryModal };

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