//#region src/lib/server/coercion.ts
/**
* Shared `unknown` -> typed coercion helpers used by API routes and
* server-side logic that consumes opaque JSON (e.g. OpenCode config blobs).
*
* Each helper returns `undefined` when the value does not match the expected
* shape. Object helpers shallow-clone so callers can mutate without leaking
* back into shared state.
*/
/** Narrow `unknown` to a plain-object record. Returns a shallow clone. */
function asRecord(value) {
	return value && typeof value === "object" && !Array.isArray(value) ? { ...value } : void 0;
}
/** Narrow `unknown` to a string. */
function asString(value) {
	return typeof value === "string" ? value : void 0;
}
/** Narrow `unknown` to a number. */
function asNumber(value) {
	return typeof value === "number" ? value : void 0;
}
/** Narrow `unknown` to an array of strings. Drops non-string entries. */
function asStringArray(value) {
	return Array.isArray(value) ? value.filter((e) => typeof e === "string") : void 0;
}
/** Narrow `unknown` to a `Record<string, string>`. Returns `undefined` when empty. */
function asStringRecord(value) {
	if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
	const entries = Object.entries(value).filter((e) => typeof e[1] === "string");
	return entries.length > 0 ? Object.fromEntries(entries) : void 0;
}

export { asNumber as a, asRecord as b, asString as c, asStringArray as d, asStringRecord as e };
//# sourceMappingURL=coercion-TNFJisCC.js.map
