import "./dist-DZj99xX4.js";
import "./dist-DAY54QOk.js";
import { t as DocumentToolbar } from "./connect-DwcZHh7Q.js";
import { g as actions } from "./module-Dmginl-e.js";
import { t as useSelectedVaultConfigDocument } from "./vault-config-BoWoMmWN.js";
import { t as TOOLBAR_CLASS } from "./theme-context-DsfdY07T.js";
import { useState } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
//#region editors/vault-config-editor/editor.tsx
function ts() {
	return (/* @__PURE__ */ new Date()).toISOString();
}
const DIMENSIONS = [
	"granularity",
	"organization",
	"linking",
	"processing",
	"navigation",
	"maintenance",
	"schema",
	"automation"
];
const DIM_LABELS = {
	granularity: ["Atomic", "Coarse"],
	organization: ["Flat", "Hierarchical"],
	linking: ["Implicit", "Explicit"],
	processing: ["Minimal", "Intense"],
	navigation: ["Linear", "3-Tier"],
	maintenance: ["Manual", "Condition-based"],
	schema: ["Convention", "Dense"],
	automation: ["Manual", "Full"]
};
function Editor() {
	const [document, dispatch] = useSelectedVaultConfigDocument();
	const state = document.state.global;
	if (!!!state.name) return /* @__PURE__ */ jsx(InitForm, { dispatch });
	const dims = state.dimensions;
	const vocab = state.vocabulary;
	const maint = state.maintenance;
	const pipeline = state.pipeline;
	return /* @__PURE__ */ jsx("div", {
		className: "min-h-screen",
		style: {
			backgroundColor: "var(--bai-bg)",
			color: "var(--bai-text)"
		},
		children: /* @__PURE__ */ jsxs("div", {
			className: "mx-auto max-w-5xl",
			children: [/* @__PURE__ */ jsx(DocumentToolbar, { toolbarClassName: TOOLBAR_CLASS }), /* @__PURE__ */ jsxs("div", {
				className: "p-6 space-y-6",
				children: [
					/* @__PURE__ */ jsxs("div", {
						className: "rounded-xl p-6",
						style: {
							backgroundColor: "var(--bai-surface)",
							border: "1px solid var(--bai-border)"
						},
						children: [
							/* @__PURE__ */ jsx("input", {
								type: "text",
								defaultValue: state.name ?? "",
								placeholder: "Vault name",
								onBlur: (e) => {
									const val = e.target.value.trim();
									if (val && val !== state.name) dispatch(actions.initializeConfig({
										name: val,
										domain: state.domain ?? "",
										updatedAt: ts()
									}));
								},
								className: "w-full border-0 bg-transparent text-xl font-bold outline-none",
								style: { color: "var(--bai-text)" }
							}),
							/* @__PURE__ */ jsx("input", {
								type: "text",
								defaultValue: state.domain ?? "",
								placeholder: "Domain description",
								onBlur: (e) => {
									const val = e.target.value.trim();
									if (val && val !== state.domain) dispatch(actions.initializeConfig({
										name: state.name ?? "",
										domain: val,
										updatedAt: ts()
									}));
								},
								className: "mt-1 w-full border-0 bg-transparent text-sm outline-none",
								style: { color: "var(--bai-text-muted)" }
							}),
							state.updatedAt && /* @__PURE__ */ jsxs("p", {
								className: "text-[10px] mt-1",
								style: { color: "var(--bai-text-faint)" },
								children: ["Updated: ", new Date(state.updatedAt).toLocaleString()]
							})
						]
					}),
					dims && /* @__PURE__ */ jsxs("div", {
						className: "rounded-xl p-6",
						style: {
							backgroundColor: "var(--bai-surface)",
							border: "1px solid var(--bai-border)"
						},
						children: [/* @__PURE__ */ jsx("h3", {
							className: "mb-4 text-xs font-semibold uppercase tracking-wider",
							style: { color: "var(--bai-text-muted)" },
							children: "8-Dimension Parameter Space"
						}), /* @__PURE__ */ jsx("div", {
							className: "space-y-4",
							children: DIMENSIONS.map((dim) => {
								const d = dims[dim];
								if (!d) return null;
								const [leftLabel, rightLabel] = DIM_LABELS[dim] ?? ["Low", "High"];
								return /* @__PURE__ */ jsxs("div", {
									className: "space-y-1",
									children: [
										/* @__PURE__ */ jsxs("div", {
											className: "flex items-center justify-between",
											children: [/* @__PURE__ */ jsx("span", {
												className: "text-xs font-medium capitalize",
												style: { color: "var(--bai-text-secondary)" },
												children: dim
											}), /* @__PURE__ */ jsxs("span", {
												className: "text-[10px]",
												style: { color: "var(--bai-text-faint)" },
												children: [
													"confidence: ",
													((d.confidence ?? 0) * 100).toFixed(0),
													"%"
												]
											})]
										}),
										/* @__PURE__ */ jsxs("div", {
											className: "flex items-center gap-2",
											children: [
												/* @__PURE__ */ jsx("span", {
													className: "w-16 text-right text-[10px]",
													style: { color: "var(--bai-text-faint)" },
													children: leftLabel
												}),
												/* @__PURE__ */ jsx("input", {
													type: "range",
													min: "1",
													max: "5",
													value: d.value ?? 3,
													onChange: (e) => dispatch(actions.updateDimension({
														dimension: dim,
														value: parseInt(e.target.value),
														confidence: d.confidence ?? .5,
														rationale: d.rationale ?? void 0,
														updatedAt: ts()
													})),
													className: "flex-1 accent-[#cba6f7]"
												}),
												/* @__PURE__ */ jsx("span", {
													className: "w-16 text-[10px]",
													style: { color: "var(--bai-text-faint)" },
													children: rightLabel
												}),
												/* @__PURE__ */ jsx("span", {
													className: "w-6 text-center text-xs font-bold",
													style: { color: "var(--bai-accent)" },
													children: d.value ?? 3
												})
											]
										}),
										d.rationale && /* @__PURE__ */ jsx("p", {
											className: "text-[10px] italic pl-18",
											style: { color: "var(--bai-text-faint)" },
											children: d.rationale
										})
									]
								}, dim);
							})
						})]
					}),
					/* @__PURE__ */ jsxs("div", {
						className: "grid grid-cols-2 gap-6",
						children: [vocab && /* @__PURE__ */ jsxs("div", {
							className: "rounded-xl p-6",
							style: {
								backgroundColor: "var(--bai-surface)",
								border: "1px solid var(--bai-border)"
							},
							children: [/* @__PURE__ */ jsx("h3", {
								className: "mb-3 text-xs font-semibold uppercase tracking-wider",
								style: { color: "var(--bai-text-muted)" },
								children: "Vocabulary"
							}), /* @__PURE__ */ jsx("div", {
								className: "space-y-2",
								children: Object.entries(vocab).map(([key, value]) => /* @__PURE__ */ jsxs("label", {
									className: "block text-xs",
									children: [/* @__PURE__ */ jsx("span", {
										className: "capitalize",
										style: { color: "var(--bai-text-faint)" },
										children: key
									}), /* @__PURE__ */ jsx("input", {
										type: "text",
										defaultValue: value ?? "",
										placeholder: key,
										onBlur: (e) => dispatch(actions.updateVocabulary({
											key,
											value: e.target.value,
											updatedAt: ts()
										})),
										className: "mt-0.5 w-full rounded px-2 py-1 text-xs outline-none focus:border-[#cba6f7]/50",
										style: {
											backgroundColor: "var(--bai-deep)",
											color: "var(--bai-text-secondary)",
											border: "1px solid var(--bai-border)"
										}
									})]
								}, key))
							})]
						}), /* @__PURE__ */ jsxs("div", {
							className: "space-y-6",
							children: [
								pipeline && /* @__PURE__ */ jsxs("div", {
									className: "rounded-xl p-6",
									style: {
										backgroundColor: "var(--bai-surface)",
										border: "1px solid var(--bai-border)"
									},
									children: [/* @__PURE__ */ jsx("h3", {
										className: "mb-3 text-xs font-semibold uppercase tracking-wider",
										style: { color: "var(--bai-text-muted)" },
										children: "Pipeline"
									}), /* @__PURE__ */ jsxs("div", {
										className: "space-y-2 text-xs",
										children: [
											/* @__PURE__ */ jsxs("div", {
												className: "flex justify-between",
												children: [/* @__PURE__ */ jsx("span", {
													style: { color: "var(--bai-text-faint)" },
													children: "Depth"
												}), /* @__PURE__ */ jsx("span", {
													style: { color: "var(--bai-text-secondary)" },
													children: pipeline.depth
												})]
											}),
											/* @__PURE__ */ jsxs("div", {
												className: "flex justify-between",
												children: [/* @__PURE__ */ jsx("span", {
													style: { color: "var(--bai-text-faint)" },
													children: "Auto-chain"
												}), /* @__PURE__ */ jsx("span", {
													className: pipeline.autoChain ? "text-emerald-400" : "",
													style: pipeline.autoChain ? void 0 : { color: "var(--bai-text-muted)" },
													children: pipeline.autoChain ? "Yes" : "No"
												})]
											}),
											/* @__PURE__ */ jsxs("div", {
												className: "flex justify-between",
												children: [/* @__PURE__ */ jsx("span", {
													style: { color: "var(--bai-text-faint)" },
													children: "Selectivity"
												}), /* @__PURE__ */ jsx("span", {
													style: { color: "var(--bai-text-secondary)" },
													children: pipeline.extractionSelectivity
												})]
											})
										]
									})]
								}),
								maint && /* @__PURE__ */ jsxs("div", {
									className: "rounded-xl p-6",
									style: {
										backgroundColor: "var(--bai-surface)",
										border: "1px solid var(--bai-border)"
									},
									children: [/* @__PURE__ */ jsx("h3", {
										className: "mb-3 text-xs font-semibold uppercase tracking-wider",
										style: { color: "var(--bai-text-muted)" },
										children: "Maintenance Thresholds"
									}), /* @__PURE__ */ jsx("div", {
										className: "space-y-2 text-xs",
										children: Object.entries(maint).map(([key, value]) => /* @__PURE__ */ jsxs("div", {
											className: "flex justify-between",
											children: [/* @__PURE__ */ jsx("span", {
												className: "capitalize",
												style: { color: "var(--bai-text-faint)" },
												children: key.replace(/([A-Z])/g, " $1").trim()
											}), /* @__PURE__ */ jsx("span", {
												style: { color: "var(--bai-text-secondary)" },
												children: value
											})]
										}, key))
									})]
								}),
								/* @__PURE__ */ jsxs("div", {
									className: "rounded-xl p-6",
									style: {
										backgroundColor: "var(--bai-surface)",
										border: "1px solid var(--bai-border)"
									},
									children: [/* @__PURE__ */ jsxs("h3", {
										className: "mb-3 text-xs font-semibold uppercase tracking-wider",
										style: { color: "var(--bai-text-muted)" },
										children: [
											"Features (",
											(state.features ?? []).length,
											")"
										]
									}), /* @__PURE__ */ jsx("div", {
										className: "flex flex-wrap gap-1",
										children: (state.features ?? []).map((f) => /* @__PURE__ */ jsxs("span", {
											className: "group inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px]",
											style: {
												backgroundColor: "var(--bai-accent-soft)",
												color: "var(--bai-accent)"
											},
											children: [f, /* @__PURE__ */ jsx("button", {
												type: "button",
												onClick: () => dispatch(actions.toggleFeature({
													feature: f,
													enabled: false
												})),
												className: "opacity-0 hover:text-red-400 group-hover:opacity-100",
												children: "×"
											})]
										}, f))
									})]
								})
							]
						})]
					})
				]
			})]
		})
	});
}
function InitForm({ dispatch }) {
	const [name, setName] = useState("");
	const [domain, setDomain] = useState("");
	return /* @__PURE__ */ jsx("div", {
		className: "min-h-screen",
		style: {
			backgroundColor: "var(--bai-bg)",
			color: "var(--bai-text)"
		},
		children: /* @__PURE__ */ jsxs("div", {
			className: "mx-auto max-w-2xl",
			children: [/* @__PURE__ */ jsx(DocumentToolbar, { toolbarClassName: TOOLBAR_CLASS }), /* @__PURE__ */ jsx("div", {
				className: "p-6",
				children: /* @__PURE__ */ jsxs("div", {
					className: "rounded-xl p-8 space-y-4",
					style: {
						backgroundColor: "var(--bai-surface)",
						border: "1px solid var(--bai-border)"
					},
					children: [
						/* @__PURE__ */ jsx("h2", {
							className: "text-lg font-bold",
							style: { color: "var(--bai-text)" },
							children: "Initialize Vault Configuration"
						}),
						/* @__PURE__ */ jsx("input", {
							type: "text",
							value: name,
							onChange: (e) => setName(e.target.value),
							placeholder: "Vault name",
							className: "w-full rounded-lg px-3 py-2 text-sm outline-none focus:border-[#cba6f7]/50",
							style: {
								backgroundColor: "var(--bai-bg)",
								color: "var(--bai-text-secondary)",
								border: "1px solid var(--bai-border)"
							}
						}),
						/* @__PURE__ */ jsx("input", {
							type: "text",
							value: domain,
							onChange: (e) => setDomain(e.target.value),
							placeholder: "Domain description",
							className: "w-full rounded-lg px-3 py-2 text-sm outline-none focus:border-[#cba6f7]/50",
							style: {
								backgroundColor: "var(--bai-bg)",
								color: "var(--bai-text-secondary)",
								border: "1px solid var(--bai-border)"
							}
						}),
						/* @__PURE__ */ jsx("button", {
							type: "button",
							disabled: !name.trim() || !domain.trim(),
							onClick: () => dispatch(actions.initializeConfig({
								name,
								domain,
								updatedAt: ts()
							})),
							className: "rounded-lg px-4 py-2 text-sm font-medium hover:opacity-80 disabled:opacity-40",
							style: {
								backgroundColor: "var(--bai-accent)",
								color: "var(--bai-accent-text)"
							},
							children: "Initialize"
						})
					]
				})
			})]
		})
	});
}
//#endregion
export { Editor as default };

//# sourceMappingURL=editor-CGb0Iz_d.js.map