import { A as e, F as t, L as n, M as r, X as i, _ as a, at as ee, b as o, f as s, h as c, l, m as u, ot as d, p as f, rt as p, st as m, t as h, v as g, w as te, z as ne } from "./vue.runtime.esm-bundler-Bxqkjqhc.js";
import { A as _, E as re, m as ie, y as v } from "./keys-B5SJtPWf.js";
import { t as y } from "./createLucideIcon-Di4mqmGn.js";
import { t as ae } from "./chevron-down-tee-ghFi.js";
import { t as b } from "./circle-alert-C0L9pUQ4.js";
import { n as x, t as S } from "./refresh-cw-BNAhAmtL.js";
import { t as oe } from "./info-DTGrc0Bx.js";
import { t as C } from "./loader-circle-_9bP23op.js";
import { t as w } from "./shield-check-C5Gv2cM1.js";
import { t as T } from "./sparkles-D1IGi_cC.js";
import { t as se } from "./triangle-alert-DWQySIE2.js";
import { t as ce } from "./x-Dlaenqta.js";
import { t as le } from "./LoadingTrack-CFkDkjBb.js";
import { t as E } from "./_plugin-vue_export-helper-B0hnzhyu.js";
import { n as D } from "./useCloudI18n-ByEMykjO.js";
var O = y("shield-x", [
	["path", {
		d: "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",
		key: "oel41y"
	}],
	["path", {
		d: "m14.5 9.5-5 5",
		key: "17q4r4"
	}],
	["path", {
		d: "m9.5 9.5 5 5",
		key: "18nt4w"
	}]
]), k = y("zap", [["path", {
	d: "M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",
	key: "1xq2db"
}]]);
//#endregion
//#region src/cloud/utils/scoringStyles.ts
function A(e) {
	return e >= 80 ? "var(--tpl-success)" : e >= 60 ? "var(--tpl-warning)" : "var(--tpl-danger)";
}
function j(e) {
	return e >= 80 ? "var(--tpl-success-light)" : e >= 60 ? "var(--tpl-warning-light)" : "var(--tpl-danger-light)";
}
function M(e) {
	return e === "high" ? "var(--tpl-danger)" : e === "medium" ? "var(--tpl-warning)" : "var(--tpl-text-muted)";
}
function N(e) {
	return e === "high" ? "var(--tpl-danger-light)" : e === "medium" ? "var(--tpl-warning-light)" : "var(--tpl-bg-hover)";
}
//#endregion
//#region src/cloud/components/TemplateScoringPanel.vue?vue&type=script&setup=true&lang.ts
var P = {
	key: 0,
	class: "tpl-scoring-panel 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)]"
}, F = { class: "tpl:flex tpl:items-center tpl:justify-between tpl:border-b tpl:border-[var(--tpl-border)] tpl:px-4 tpl:py-3" }, I = { class: "tpl:flex tpl:items-center tpl:gap-1.5 tpl:text-sm tpl:font-medium tpl:text-[var(--tpl-primary)]" }, L = { class: "tpl:flex tpl:items-center tpl:gap-1" }, R = ["title"], z = { class: "tpl:flex-1 tpl:overflow-y-auto tpl:p-4" }, B = {
	key: 0,
	class: "tpl:flex tpl:h-full tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-3 tpl:text-center"
}, V = { class: "tpl:text-sm tpl:text-[var(--tpl-text-muted)]" }, H = {
	key: 1,
	class: "tpl:flex tpl:h-full tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-3 tpl:text-center"
}, U = { class: "tpl:max-w-[240px] tpl:text-sm tpl:text-[var(--tpl-text-muted)]" }, W = {
	key: 2,
	class: "tpl:flex tpl:flex-col tpl:gap-4"
}, ue = { class: "tpl:text-xs tpl:font-medium tpl:uppercase tpl:tracking-wider tpl:text-[var(--tpl-text-muted)]" }, de = {
	key: 0,
	class: "tpl:text-xs tpl:text-[var(--tpl-text-dim)]"
}, fe = {
	key: 0,
	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)]"
}, pe = ["onClick"], me = { class: "tpl:flex-1 tpl:text-xs tpl:font-medium tpl:text-[var(--tpl-text)]" }, he = {
	key: 0,
	class: "tpl:text-[10px] tpl:text-[var(--tpl-text-dim)]"
}, ge = {
	key: 0,
	class: "tpl:border-t tpl:border-[var(--tpl-border)]"
}, _e = {
	key: 0,
	class: "tpl:px-3 tpl:py-3 tpl:text-center tpl:text-xs tpl:text-[var(--tpl-text-dim)]"
}, ve = { class: "tpl:flex tpl:items-start tpl:gap-2" }, ye = { class: "tpl:flex-1 tpl:min-w-0" }, be = { class: "tpl:flex tpl:items-start tpl:gap-1.5" }, xe = { class: "tpl:text-xs tpl:leading-snug tpl:text-[var(--tpl-text)]" }, Se = {
	key: 0,
	class: "tpl:mt-1 tpl:text-[11px] tpl:leading-snug tpl:text-[var(--tpl-text-dim)]"
}, Ce = {
	key: 1,
	class: "tpl:mt-2 tpl:flex tpl:justify-center"
}, we = ["disabled", "onClick"], Te = {
	key: 0,
	class: "tpl:mt-1.5 tpl:text-[11px] tpl:text-[var(--tpl-danger)]"
}, Ee = {
	key: 3,
	class: "tpl:flex tpl:h-full tpl:flex-col tpl:items-center tpl:justify-center tpl:gap-3 tpl:text-center"
}, De = { class: "tpl:max-w-[240px] tpl:text-sm tpl:text-[var(--tpl-text-muted)]" }, Oe = { class: "tpl:m-0 tpl:px-4 tpl:pb-2 tpl:pt-2 tpl:text-center tpl:text-[11px] tpl:text-[var(--tpl-text-dim)]" }, G = /* @__PURE__ */ E(/* @__PURE__ */ o({
	__name: "TemplateScoringPanel",
	props: { visible: { type: Boolean } },
	emits: ["close"],
	setup(o, { emit: y }) {
		let E = o, G = y, { t: K } = D(), q = _(ie, "TemplateScoringPanel"), J = _(re, "TemplateScoringPanel"), Y = te(v, []), X = i({
			spam: !0,
			readability: !0,
			accessibility: !0,
			bestPractices: !0
		});
		function ke(e) {
			X.value[e] = !X.value[e];
		}
		let Z = [
			"spam",
			"readability",
			"accessibility",
			"bestPractices"
		], Ae = {
			spam: O,
			readability: x,
			accessibility: T,
			bestPractices: k
		};
		function Q() {
			J.score(q.content.value, Y);
		}
		n(() => E.visible, (e) => {
			e && !J.scoringResult.value && !J.isScoring.value && Q();
		});
		async function je(e) {
			if (!e.blockId) return;
			let t = q.content.value.blocks.find((t) => t.id === e.blockId);
			if (!t) return;
			let n = t.content;
			if (!n) return;
			let r = await J.fixFinding(n, e, Y);
			r && (q.updateBlock(e.blockId, { content: r }), J.removeFinding(e.category, e.id));
		}
		function $() {
			return J.scoringResult.value ? Z.reduce((e, t) => e + (J.scoringResult.value?.categories[t]?.findings.length ?? 0), 0) : 0;
		}
		return (n, i) => (e(), f(h, {
			"enter-active-class": "tpl-scoring-slide-enter-active",
			"enter-from-class": "tpl:translate-x-full",
			"enter-to-class": "tpl:translate-x-0",
			"leave-active-class": "tpl-scoring-slide-leave-active",
			"leave-from-class": "tpl:translate-x-0",
			"leave-to-class": "tpl:translate-x-full"
		}, {
			default: ne(() => [o.visible ? (e(), c("div", P, [s("div", F, [s("div", I, [g(p(w), {
				size: 13,
				"stroke-width": 2
			}), s("span", null, m(p(K).scoring.title), 1)]), s("div", L, [p(J).scoringResult.value && !p(J).isScoring.value ? (e(), c("button", {
				key: 0,
				class: "tpl:rounded-md tpl:p-0.5 tpl:transition-colors tpl:duration-150 tpl:text-[var(--tpl-text-muted)]",
				title: p(K).scoring.rescore,
				onClick: i[0] ||= (e) => Q()
			}, [g(p(S), {
				size: 14,
				"stroke-width": 2
			})], 8, R)) : u("", !0), s("button", {
				class: "tpl:rounded-md tpl:p-0.5 tpl:transition-colors tpl:duration-150 tpl:text-[var(--tpl-text-muted)]",
				onClick: i[1] ||= (e) => G("close")
			}, [g(p(ce), {
				size: 14,
				"stroke-width": 2
			})])])]), s("div", z, [p(J).isScoring.value ? (e(), c("div", B, [s("p", V, m(p(K).scoring.scoring), 1), g(le, { class: "tpl:w-3/4" })])) : p(J).error.value && !p(J).scoringResult.value ? (e(), c("div", H, [
				g(p(b), {
					size: 32,
					"stroke-width": 1.5,
					class: "tpl:text-[var(--tpl-danger)]"
				}),
				s("p", U, m(p(K).scoring.error), 1),
				s("button", {
					class: "tpl:mt-2 tpl:inline-flex tpl:items-center tpl:gap-1.5 tpl:rounded-md tpl:border tpl:px-3 tpl:py-1.5 tpl:text-xs tpl:font-medium tpl:transition-all tpl:duration-150 tpl:border-[var(--tpl-border)] tpl:text-[var(--tpl-text-muted)]",
					onClick: i[2] ||= (e) => Q()
				}, [g(p(S), {
					size: 12,
					"stroke-width": 2
				}), a(" " + m(p(K).scoring.rescore), 1)])
			])) : p(J).scoringResult.value ? (e(), c("div", W, [
				s("div", {
					class: "tpl:flex tpl:flex-col tpl:items-center tpl:gap-2 tpl:rounded-[var(--tpl-radius)] tpl:p-5",
					style: d({ backgroundColor: p(j)(p(J).scoringResult.value.score) })
				}, [
					s("span", {
						class: "tpl:text-4xl tpl:font-bold tpl:tabular-nums",
						style: d({ color: p(A)(p(J).scoringResult.value.score) })
					}, m(p(J).scoringResult.value.score), 5),
					s("span", ue, m(p(K).scoring.overallScore), 1),
					$() > 0 ? (e(), c("span", de, m($()) + " " + m(p(K).scoring.findings), 1)) : u("", !0)
				], 4),
				p(J).fixError.value ? (e(), c("div", fe, [g(p(b), {
					size: 14,
					"stroke-width": 2,
					class: "tpl:mt-0.5 tpl:shrink-0"
				}), s("span", null, m(p(K).scoring.fixError), 1)])) : u("", !0),
				(e(), c(l, null, r(Z, (n) => s("div", {
					key: n,
					class: "tpl:overflow-hidden tpl:rounded-[var(--tpl-radius)] tpl:border tpl:border-[var(--tpl-border)]"
				}, [s("button", {
					class: "tpl:flex tpl:w-full tpl:cursor-pointer tpl:items-center tpl:gap-2.5 tpl:px-3 tpl:py-2.5 tpl:text-left tpl:transition-colors tpl:duration-100 tpl:bg-[var(--tpl-bg)]",
					onClick: (e) => ke(n)
				}, [
					(e(), f(t(Ae[n]), {
						size: 14,
						"stroke-width": 2,
						style: d({ color: p(A)(p(J).scoringResult.value.categories[n].score) })
					}, null, 8, ["style"])),
					s("span", me, m(p(K).scoring.categories[n]), 1),
					s("span", {
						class: "tpl:rounded-full tpl:px-2 tpl:py-0.5 tpl:text-xs tpl:font-semibold tpl:tabular-nums",
						style: d({
							color: p(A)(p(J).scoringResult.value.categories[n].score),
							backgroundColor: p(j)(p(J).scoringResult.value.categories[n].score)
						})
					}, m(p(J).scoringResult.value.categories[n].score), 5),
					p(J).scoringResult.value.categories[n].findings.length > 0 ? (e(), c("span", he, m(p(J).scoringResult.value.categories[n].findings.length), 1)) : u("", !0),
					g(p(ae), {
						size: 12,
						"stroke-width": 2,
						class: ee(["tpl:transition-transform tpl:duration-200 tpl:text-[var(--tpl-text-dim)]", X.value[n] ? "tpl:rotate-0" : "tpl:-rotate-90"])
					}, null, 8, ["class"])
				], 8, pe), X.value[n] ? (e(), c("div", ge, [p(J).scoringResult.value.categories[n].findings.length === 0 ? (e(), c("div", _e, m(p(K).scoring.noFindings), 1)) : u("", !0), (e(!0), c(l, null, r(p(J).scoringResult.value.categories[n].findings, (n) => (e(), c("div", {
					key: n.id,
					class: "tpl:border-t tpl:px-3 tpl:py-2.5 first:tpl:border-t-0 tpl:border-[var(--tpl-border-light)]"
				}, [s("div", ve, [(e(), f(t(n.severity === "high" ? p(b) : n.severity === "medium" ? p(se) : p(oe)), {
					size: 13,
					"stroke-width": 2,
					class: "tpl:mt-0.5 tpl:shrink-0",
					style: d({ color: p(M)(n.severity) })
				}, null, 8, ["style"])), s("div", ye, [
					s("div", be, [s("span", {
						class: "tpl:mt-0.5 tpl:shrink-0 tpl:rounded tpl:px-1 tpl:py-px tpl:text-[10px] tpl:font-medium tpl:leading-tight",
						style: d({
							color: p(M)(n.severity),
							backgroundColor: p(N)(n.severity)
						})
					}, m(p(K).scoring.severity[n.severity]), 5), s("span", xe, m(n.message), 1)]),
					n.suggestion ? (e(), c("p", Se, m(n.suggestion), 1)) : u("", !0),
					n.blockId ? (e(), c("div", Ce, [s("button", {
						class: "tpl-scoring-fix-btn tpl:inline-flex tpl:items-center tpl:gap-1.5 tpl:rounded tpl:border tpl:px-3 tpl:py-1.5 tpl:text-[11px] tpl:font-medium tpl:transition-all tpl:duration-150 tpl:disabled:opacity-50 tpl:border-[var(--tpl-border)] tpl:text-[var(--tpl-primary)]",
						style: { "background-color": "transparent" },
						disabled: p(J).fixingFindingId.value !== null,
						onClick: (e) => je(n)
					}, [p(J).fixingFindingId.value === n.id ? (e(), f(p(C), {
						key: 0,
						class: "tpl-spinner",
						size: 11,
						"stroke-width": 2
					})) : (e(), f(p(T), {
						key: 1,
						size: 11,
						"stroke-width": 2
					})), a(" " + m(p(J).fixingFindingId.value === n.id ? p(K).scoring.fixing : p(K).scoring.fix), 1)], 8, we), p(J).fixError.value ? (e(), c("p", Te, m(p(J).fixError.value), 1)) : u("", !0)])) : u("", !0)
				])])]))), 128))])) : u("", !0)])), 64))
			])) : (e(), c("div", Ee, [g(p(w), {
				size: 32,
				"stroke-width": 1.5,
				class: "tpl:text-[var(--tpl-text-dim)]"
			}), s("p", De, m(p(K).scoring.emptyState), 1)])), s("p", Oe, m(p(K).aiMenu.disclaimer), 1)])])) : u("", !0)]),
			_: 1
		}));
	}
}), [["__scopeId", "data-v-3a059e8d"]]);
//#endregion
export { G as default };
