import { Dt as e, H as t, M as n, Mt as r, Ot as i, Q as a, S as o, V as ee, _ as s, b as c, g as l, h as te, it as u, m as d, p as f, s as p, t as ne, y as m, z as re } from "./vue.runtime.esm-bundler-DpvJL-nX.js";
import "./timeouts-BSGxjuUF.js";
import { D as h, p as ie, r as ae } from "./keys-BeW4IrXP.js";
import { n as g, t as _ } from "./_plugin-vue_export-helper-GRmvIR5A.js";
import { t as oe } from "./circle-alert-De74azaX.js";
import { t as v } from "./image-up-10kxuulB.js";
import { t as y } from "./x-BNc1bVzp.js";
import { t as se } from "./LoadingTrack-DhxulLPM.js";
import { n as ce } from "./useCloudI18n-D0Fi0hBU.js";
import { u as le } from "./cloud-B1NAFg44.js";
var ue = g("file-image", [
	["path", {
		d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
		key: "1oefj6"
	}],
	["path", {
		d: "M14 2v5a1 1 0 0 0 1 1h5",
		key: "wfsgrz"
	}],
	["circle", {
		cx: "10",
		cy: "12",
		r: "2",
		key: "737tya"
	}],
	["path", {
		d: "m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",
		key: "wt3hpn"
	}]
]), b = g("file-text", [
	["path", {
		d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
		key: "1oefj6"
	}],
	["path", {
		d: "M14 2v5a1 1 0 0 0 1 1h5",
		key: "wfsgrz"
	}],
	["path", {
		d: "M10 9H8",
		key: "b1mrlr"
	}],
	["path", {
		d: "M16 13H8",
		key: "t4e002"
	}],
	["path", {
		d: "M16 17H8",
		key: "z1uh3a"
	}]
]), de = g("upload", [
	["path", {
		d: "M12 3v12",
		key: "1x0j5s"
	}],
	["path", {
		d: "m17 8-5-5-5 5",
		key: "7q97r8"
	}],
	["path", {
		d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",
		key: "ih7n3h"
	}]
]), fe = {
	key: 0,
	class: "tpl-design-sidebar tpl:absolute tpl:top-14 tpl:right-0 tpl:bottom-0 tpl:z-panel tpl:flex tpl:w-[360px] tpl:flex-col tpl:border-l tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg-elevated)]"
}, pe = { class: "tpl:flex tpl:items-center tpl:justify-between tpl:border-b tpl:border-[var(--tpl-border)] tpl:px-4 tpl:py-3" }, me = { class: "tpl:flex tpl:items-center tpl:gap-1.5 tpl:text-sm tpl:font-medium tpl:text-[var(--tpl-primary)]" }, he = { class: "tpl:flex-1 tpl:overflow-y-auto tpl:p-4" }, x = {
	key: 0,
	class: "tpl:flex tpl:h-full tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-3 tpl:text-center"
}, S = { class: "tpl:flex tpl:w-full tpl:flex-col tpl:items-center tpl:gap-3" }, C = { class: "tpl:text-sm tpl:text-[var(--tpl-text-muted)]" }, w = {
	key: 1,
	class: "tpl:flex tpl:flex-col tpl:gap-4"
}, T = { class: "tpl:flex tpl:gap-1 tpl:rounded-[var(--tpl-radius-sm)] tpl:p-1 tpl:bg-[var(--tpl-bg-hover)]" }, E = {
	key: 0,
	class: "tpl:flex tpl:flex-col tpl:gap-2"
}, D = { class: "tpl:relative tpl:overflow-hidden tpl:rounded-[var(--tpl-radius)] tpl:border tpl:border-[var(--tpl-border)] tpl:bg-[var(--tpl-bg)]" }, O = ["src", "alt"], k = {
	key: 1,
	class: "tpl:flex tpl:h-32 tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-2"
}, A = { class: "tpl:text-xs tpl:text-[var(--tpl-text-muted)]" }, j = { class: "tpl:text-center tpl:text-xs tpl:text-[var(--tpl-text-muted)]" }, M = { class: "tpl:text-center tpl:text-[11px] tpl:text-[var(--tpl-text-dim)]" }, N = ["accept"], P = { class: "tpl:flex tpl:flex-col tpl:gap-1.5" }, F = { class: "tpl:text-xs tpl:font-medium tpl:text-[var(--tpl-text-muted)]" }, I = ["placeholder"], L = {
	key: 0,
	class: "tpl:flex tpl:flex-col tpl:gap-2 tpl:rounded-[var(--tpl-radius)] tpl:px-3 tpl:py-3 tpl:bg-[var(--tpl-warning-light)] tpl:border tpl:border-[var(--tpl-warning)]"
}, R = { class: "tpl:text-xs tpl:leading-snug tpl:text-[var(--tpl-text)]" }, ge = { class: "tpl:flex tpl:gap-2" }, _e = {
	key: 1,
	class: "tpl:flex tpl:items-start tpl:gap-2 tpl:rounded-lg tpl:px-3 tpl:py-2 tpl:text-xs tpl:bg-[var(--tpl-danger-light)] tpl:text-[var(--tpl-danger)]"
}, ve = ["disabled"], ye = { class: "tpl:m-0 tpl:pt-1 tpl:text-center tpl:text-[11px] tpl:text-[var(--tpl-text-dim)]" }, z = /* @__PURE__ */ _(/* @__PURE__ */ o({
	__name: "DesignReferenceSidebar",
	props: {
		visible: { type: Boolean },
		hasExistingBlocks: { type: Boolean }
	},
	emits: ["close", "apply"],
	setup(o, { emit: g }) {
		let _ = o, z = g, { t: B } = ce(), be = h(ie, "DesignReferenceSidebar"), V = le({
			authManager: h(ae, "DesignReferenceSidebar"),
			getTemplateId: () => be.state.template?.id ?? null,
			onApply: (e) => z("apply", e)
		}), H = a(null), U = a("image"), W = a(null), G = a(""), K = a(null), q = a(!1), J = a(!1), Y = f(() => V.isGenerating.value ? !1 : W.value !== null);
		function X(e) {
			U.value = e, Q();
		}
		function xe(e) {
			let t = e.target, n = t.files?.[0];
			n && Z(n), t.value = "";
		}
		function Z(e) {
			if (e.size > 10485760) {
				V.error.value = B.designReference.fileTooLarge;
				return;
			}
			if (U.value === "image") {
				if (![
					"image/png",
					"image/jpeg",
					"image/jpg",
					"image/webp"
				].includes(e.type)) {
					V.error.value = B.designReference.invalidFileType;
					return;
				}
			} else if (U.value === "pdf" && e.type !== "application/pdf") {
				V.error.value = B.designReference.invalidFileType;
				return;
			}
			W.value = e, V.error.value = null, K.value && URL.revokeObjectURL(K.value), e.type.startsWith("image/") ? K.value = URL.createObjectURL(e) : K.value = null;
		}
		function Q() {
			K.value &&= (URL.revokeObjectURL(K.value), null), W.value = null;
		}
		function Se(e) {
			e.preventDefault(), J.value = !0;
		}
		function Ce() {
			J.value = !1;
		}
		function we(e) {
			e.preventDefault(), J.value = !1;
			let t = e.dataTransfer?.files?.[0];
			t && Z(t);
		}
		function $() {
			if (!Y.value) return;
			if (_.hasExistingBlocks && !q.value) {
				q.value = !0;
				return;
			}
			q.value = !1;
			let e = {};
			G.value.trim() && (e.prompt = G.value.trim()), U.value === "image" && W.value ? e.imageUpload = W.value : U.value === "pdf" && W.value && (e.pdfUpload = W.value), V.generate(e);
		}
		function Te() {
			q.value = !1;
		}
		return re(() => _.visible, (e) => {
			e || (q.value = !1);
		}), (a, f) => (n(), te(ne, {
			"enter-active-class": "tpl-design-slide-enter-active",
			"enter-from-class": "tpl:translate-x-full",
			"enter-to-class": "tpl:translate-x-0",
			"leave-active-class": "tpl-design-slide-leave-active",
			"leave-from-class": "tpl:translate-x-0",
			"leave-to-class": "tpl:translate-x-full"
		}, {
			default: ee(() => [o.visible ? (n(), s("div", fe, [d("div", pe, [d("div", me, [c(u(v), {
				size: 13,
				"stroke-width": 2
			}), d("span", null, r(u(B).designReference.title), 1)]), d("button", {
				class: "tpl:rounded-md tpl:p-0.5 tpl:transition-colors tpl:duration-150 tpl:text-[var(--tpl-text-muted)]",
				onClick: f[0] ||= (e) => z("close")
			}, [c(u(y), {
				size: 14,
				"stroke-width": 2
			})])]), d("div", he, [u(V).isGenerating.value ? (n(), s("div", x, [d("div", S, [c(se), d("p", C, r(u(B).designReference.generating), 1)])])) : (n(), s("div", w, [
				d("div", T, [d("button", {
					class: "tpl:flex tpl:flex-1 tpl:items-center tpl:justify-center tpl:gap-1.5 tpl:rounded-[var(--tpl-radius-sm)] tpl:px-2 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150",
					style: i({
						backgroundColor: U.value === "image" ? "var(--tpl-bg)" : "transparent",
						color: U.value === "image" ? "var(--tpl-primary)" : "var(--tpl-text-muted)",
						boxShadow: U.value === "image" ? "var(--tpl-shadow)" : "none"
					}),
					onClick: f[1] ||= (e) => X("image")
				}, [c(u(ue), {
					size: 12,
					"stroke-width": 2
				}), m(" " + r(u(B).designReference.uploadImage), 1)], 4), d("button", {
					class: "tpl:flex tpl:flex-1 tpl:items-center tpl:justify-center tpl:gap-1.5 tpl:rounded-[var(--tpl-radius-sm)] tpl:px-2 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150",
					style: i({
						backgroundColor: U.value === "pdf" ? "var(--tpl-bg)" : "transparent",
						color: U.value === "pdf" ? "var(--tpl-primary)" : "var(--tpl-text-muted)",
						boxShadow: U.value === "pdf" ? "var(--tpl-shadow)" : "none"
					}),
					onClick: f[2] ||= (e) => X("pdf")
				}, [c(u(b), {
					size: 12,
					"stroke-width": 2
				}), m(" " + r(u(B).designReference.uploadPdf), 1)], 4)]),
				d("div", null, [W.value ? (n(), s("div", E, [d("div", D, [K.value ? (n(), s("img", {
					key: 0,
					src: K.value,
					alt: W.value.name,
					class: "tpl:h-auto tpl:max-h-48 tpl:w-full tpl:object-contain"
				}, null, 8, O)) : (n(), s("div", k, [c(u(b), {
					size: 32,
					"stroke-width": 1.5,
					class: "tpl:text-[var(--tpl-text-dim)]"
				}), d("span", A, r(W.value.name), 1)])), d("button", {
					class: "tpl:absolute tpl:top-2 tpl:right-2 tpl:rounded-full tpl:p-1 tpl:transition-colors tpl:duration-150 tpl:bg-[var(--tpl-bg)] tpl:text-[var(--tpl-text-muted)] tpl:shadow-[var(--tpl-shadow)]",
					onClick: Q
				}, [c(u(y), {
					size: 12,
					"stroke-width": 2
				})])])])) : (n(), s("div", {
					key: 1,
					class: "tpl-design-dropzone tpl:flex tpl:cursor-pointer tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-2 tpl:rounded-[var(--tpl-radius)] tpl:border-2 tpl:border-dashed tpl:px-4 tpl:py-8 tpl:transition-colors tpl:duration-150",
					style: i({
						borderColor: J.value ? "var(--tpl-primary)" : "var(--tpl-border-light)",
						backgroundColor: J.value ? "var(--tpl-primary-light)" : "var(--tpl-bg)"
					}),
					onClick: f[3] ||= (e) => H.value?.click(),
					onDragover: Se,
					onDragleave: Ce,
					onDrop: we
				}, [
					c(u(de), {
						size: 24,
						"stroke-width": 1.5,
						class: "tpl:text-[var(--tpl-text-dim)]"
					}),
					d("span", j, r(u(B).designReference.dropHint), 1),
					d("span", M, r(U.value === "image" ? u(B).designReference.acceptedImages : u(B).designReference.acceptedPdf), 1)
				], 36)), d("input", {
					ref_key: "fileInput",
					ref: H,
					type: "file",
					class: "tpl:hidden",
					accept: U.value === "image" ? "image/png,image/jpeg,image/webp" : "application/pdf",
					onChange: xe
				}, null, 40, N)]),
				d("div", P, [d("label", F, r(u(B).designReference.promptLabel), 1), t(d("textarea", {
					"onUpdate:modelValue": f[4] ||= (e) => G.value = e,
					class: e(["tpl:min-h-[72px] tpl:w-full tpl:resize-none tpl:rounded-[var(--tpl-radius-sm)] tpl:border tpl:px-3 tpl:py-2 tpl:font-sans tpl:text-sm tpl:outline-none tpl:transition-colors tpl:duration-150 tpl:border-[var(--tpl-border)] tpl:text-[var(--tpl-text)] tpl:bg-[var(--tpl-bg)]", ["tpl-design-prompt-input"]]),
					placeholder: u(B).designReference.promptPlaceholder,
					rows: "3"
				}, null, 8, I), [[p, G.value]])]),
				q.value ? (n(), s("div", L, [d("p", R, r(u(B).designReference.replaceWarning), 1), d("div", ge, [d("button", {
					class: "tpl:flex-1 tpl:rounded-[var(--tpl-radius-sm)] tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150 tpl:text-[var(--tpl-text-muted)] tpl:border tpl:border-[var(--tpl-border)]",
					style: { "background-color": "transparent" },
					onClick: Te
				}, r(u(B).designReference.replaceCancel), 1), d("button", {
					class: "tpl:flex-1 tpl:rounded-[var(--tpl-radius-sm)] tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150 tpl:hover:opacity-90 tpl:bg-[var(--tpl-primary)] tpl:text-[var(--tpl-bg)]",
					onClick: $
				}, r(u(B).designReference.replaceConfirm), 1)])])) : l("", !0),
				u(V).error.value ? (n(), s("div", _e, [c(u(oe), {
					size: 14,
					"stroke-width": 2,
					class: "tpl:mt-0.5 tpl:shrink-0"
				}), d("span", null, r(u(B).designReference.error), 1)])) : l("", !0),
				q.value ? l("", !0) : (n(), s("button", {
					key: 2,
					class: "tpl:flex tpl:w-full tpl:items-center tpl:justify-center tpl:gap-2 tpl:rounded-[var(--tpl-radius-sm)] tpl:px-4 tpl:py-2.5 tpl:text-sm tpl:font-medium tpl:transition-all tpl:duration-150 tpl:hover:opacity-90 tpl:disabled:cursor-not-allowed tpl:disabled:opacity-50 tpl:bg-[var(--tpl-primary)] tpl:text-[var(--tpl-bg)]",
					disabled: !Y.value,
					onClick: $
				}, [c(u(v), {
					size: 16,
					"stroke-width": 2
				}), m(" " + r(u(B).designReference.generate), 1)], 8, ve)),
				d("p", ye, r(u(B).aiMenu.disclaimer), 1)
			]))])])) : l("", !0)]),
			_: 1
		}));
	}
}), [["__scopeId", "data-v-7e3f1324"]]);
//#endregion
export { z as default };
