import { Badge } from "../../../components/ui/badge.js";
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "../../../components/ui/dialog.js";
import DocumentDetails_default from "./document-details/DocumentDetails.js";
import PromptDetails_default from "./document-details/PromptDetails.js";
import { c } from "react/compiler-runtime";
import { useState } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
var DefaultMetadataRenderer = (e) => {
	let s = c(4), { data: l } = e, u;
	s[0] === l ? u = s[1] : (u = JSON.stringify(l, null, 2), s[0] = l, s[1] = u);
	let d;
	return s[2] === u ? d = s[3] : (d = /* @__PURE__ */ jsx("div", {
		className: "bg-muted max-h-96 overflow-auto rounded-md p-4 font-mono whitespace-pre-wrap",
		children: u
	}), s[2] = u, s[3] = d), d;
}, metadataRenderers = {
	prompt: (e) => /* @__PURE__ */ jsx(PromptDetails_default, { promptData: e }),
	document: (e) => /* @__PURE__ */ jsx(DocumentDetails_default, { data: e })
}, DocumentMetadataPills_default = (f) => {
	let p = c(13), { metaData: m } = f, [h, g] = useState(null), [_, v] = useState(null), [y, b] = useState(!1), x;
	p[0] === Symbol.for("react.memo_cache_sentinel") ? (x = (e, s) => {
		g(e), v(s), b(!0);
	}, p[0] = x) : x = p[0];
	let S = x, C;
	p[1] === h ? C = p[2] : (C = (e) => e && metadataRenderers[e] ? metadataRenderers[e](h) : /* @__PURE__ */ jsx(DefaultMetadataRenderer, { data: h }), p[1] = h, p[2] = C);
	let w = C, T;
	p[3] === m ? T = p[4] : (T = /* @__PURE__ */ jsx("div", {
		className: "mb-8 flex flex-wrap gap-2",
		children: Object.entries(m).map((s) => {
			let [l, u] = s;
			return /* @__PURE__ */ jsx(Badge, {
				variant: "outline",
				className: "hover:bg-accent hover:text-accent-foreground cursor-pointer rounded-full px-3 py-1 transition-colors",
				onClick: () => S(u, l),
				children: l
			}, l);
		})
	}), p[3] = m, p[4] = T);
	let E;
	p[5] !== w || p[6] !== y || p[7] !== h || p[8] !== _ ? (E = h && /* @__PURE__ */ jsx(Dialog, {
		open: y,
		onOpenChange: b,
		children: /* @__PURE__ */ jsxs(DialogContent, {
			className: "max-h-3/4 max-w-2xl overflow-auto",
			children: [/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, {
				className: "flex items-center gap-2",
				children: [_, /* @__PURE__ */ jsx("span", {
					className: "text-muted-foreground text-xs font-normal",
					children: "Metadata"
				})]
			}) }), /* @__PURE__ */ jsx("div", {
				className: "mt-4",
				children: w(_)
			})]
		})
	}), p[5] = w, p[6] = y, p[7] = h, p[8] = _, p[9] = E) : E = p[9];
	let D;
	return p[10] !== T || p[11] !== E ? (D = /* @__PURE__ */ jsxs("div", {
		className: "px-6",
		children: [T, E]
	}), p[10] = T, p[11] = E, p[12] = D) : D = p[12], D;
};
export { DocumentMetadataPills_default as default };
