import { i as RESERVED_BYLINE_FIELD_SLUGS } from "./types-tM44hEcf.mjs";
import { Ln as roleLevel, Nn as httpUrl } from "./redirects-DXEXBAII.mjs";
import { z } from "zod";

//#region src/api/schemas/auth.ts
const authenticatorTransport$1 = z.enum([
	"usb",
	"nfc",
	"ble",
	"internal",
	"hybrid"
]);
/** RegistrationResponse — sent by the browser after navigator.credentials.create() */
const registrationCredential$1 = z.object({
	id: z.string(),
	rawId: z.string(),
	type: z.literal("public-key"),
	response: z.object({
		clientDataJSON: z.string(),
		attestationObject: z.string(),
		transports: z.array(authenticatorTransport$1).optional()
	}),
	authenticatorAttachment: z.enum(["platform", "cross-platform"]).optional()
});
/** AuthenticationResponse — sent by the browser after navigator.credentials.get() */
const authenticationCredential = z.object({
	id: z.string(),
	rawId: z.string(),
	type: z.literal("public-key"),
	response: z.object({
		clientDataJSON: z.string(),
		authenticatorData: z.string(),
		signature: z.string(),
		userHandle: z.string().optional()
	}),
	authenticatorAttachment: z.enum(["platform", "cross-platform"]).optional()
});
const signupRequestBody = z.object({ email: z.string().email() }).meta({ id: "SignupRequestBody" });
const signupCompleteBody = z.object({
	token: z.string().min(1),
	credential: registrationCredential$1,
	name: z.string().optional()
}).meta({ id: "SignupCompleteBody" });
const inviteCreateBody = z.object({
	email: z.string().email(),
	role: roleLevel.optional()
}).meta({ id: "InviteCreateBody" });
const inviteRegisterOptionsBody = z.object({
	token: z.string().min(1),
	name: z.string().optional()
}).meta({ id: "InviteRegisterOptionsBody" });
const inviteCompleteBody = z.object({
	token: z.string().min(1),
	credential: registrationCredential$1,
	name: z.string().optional()
}).meta({ id: "InviteCompleteBody" });
const magicLinkSendBody = z.object({ email: z.string().email() }).meta({ id: "MagicLinkSendBody" });
const passkeyOptionsBody = z.object({ email: z.string().email().optional() }).meta({ id: "PasskeyOptionsBody" });
const passkeyVerifyBody = z.object({ credential: authenticationCredential }).meta({ id: "PasskeyVerifyBody" });
const passkeyRegisterOptionsBody = z.object({ name: z.string().optional() }).meta({ id: "PasskeyRegisterOptionsBody" });
const passkeyRegisterVerifyBody = z.object({
	credential: registrationCredential$1,
	name: z.string().optional()
}).meta({ id: "PasskeyRegisterVerifyBody" });
const passkeyRenameBody = z.object({ name: z.string().min(1) }).meta({ id: "PasskeyRenameBody" });
const authMeActionBody = z.object({ action: z.string().min(1) }).meta({ id: "AuthMeActionBody" });

//#endregion
//#region src/api/schemas/import.ts
const importProbeBody = z.object({ url: httpUrl });
const wpPluginAnalyzeBody = z.object({
	url: httpUrl,
	token: z.string().min(1)
});
const wpPluginExecuteBody = z.object({
	url: httpUrl,
	token: z.string().min(1),
	config: z.record(z.string(), z.unknown()),
	phase: z.enum([
		"content",
		"comments",
		"finalize"
	]).optional(),
	cursor: z.object({
		postTypeIndex: z.number().int().min(0).default(0),
		page: z.number().int().min(1).default(1)
	}).optional(),
	idMap: z.record(z.string(), z.object({
		id: z.string().min(1),
		collection: z.string().min(1)
	})).optional(),
	translationGroups: z.record(z.string(), z.string().min(1)).optional(),
	commentRoots: z.record(z.string(), z.string().min(1)).optional()
});
const wpPrepareBody = z.object({ postTypes: z.array(z.object({
	name: z.string().min(1),
	collection: z.string().min(1),
	fields: z.array(z.object({
		slug: z.string().min(1),
		label: z.string().min(1),
		type: z.string().min(1),
		required: z.boolean(),
		searchable: z.boolean().optional()
	})).optional()
})) });
const wpMediaImportBody = z.object({
	attachments: z.array(z.record(z.string(), z.unknown())),
	stream: z.boolean().optional()
});
const wpRewriteUrlsBody = z.object({
	urlMap: z.record(z.string(), z.string()),
	collections: z.array(z.string()).optional()
});

//#endregion
//#region src/api/schemas/setup.ts
/** Registration credential — duplicated reference for setup flow.
*  The canonical definition lives in auth.ts but setup needs it independently
*  because setup runs before auth is configured. */
const authenticatorTransport = z.enum([
	"usb",
	"nfc",
	"ble",
	"internal",
	"hybrid"
]);
const registrationCredential = z.object({
	id: z.string(),
	rawId: z.string(),
	type: z.literal("public-key"),
	response: z.object({
		clientDataJSON: z.string(),
		attestationObject: z.string(),
		transports: z.array(authenticatorTransport).optional()
	}),
	authenticatorAttachment: z.enum(["platform", "cross-platform"]).optional()
});
const setupBody = z.object({
	title: z.string().min(1),
	tagline: z.string().optional(),
	includeContent: z.boolean()
});
const setupAdminBody = z.object({
	email: z.string().email(),
	name: z.string().optional()
});
const setupAdminVerifyBody = z.object({ credential: registrationCredential });
const atprotoLoginBody = z.object({ handle: z.string().trim().min(1) });
const setupAtprotoAdminBody = z.object({ handle: z.string().trim().min(1) });

//#endregion
//#region src/api/schemas/byline-fields.ts
/**
* Zod schemas for the byline-fields admin API (Discussion #1174, Phase 4).
*
* Reserved-slug + identifier validation runs at the zod layer so the
* route returns a clean 400 (`VALIDATION_ERROR` from `parseBody`) rather
* than bubbling a registry-level `BylineSchemaError` ("RESERVED_SLUG" /
* "INVALID_SLUG"). The registry repeats the same checks for non-HTTP
* callers (seeds, scripts) — see `BylineSchemaRegistry.validateSlug`.
*
* Field types are constrained to the v1 subset declared in
* `BYLINE_FIELD_TYPES`. Adding a type to the union there will require a
* corresponding update to this enum.
*/
/**
* Slug pattern for byline field definitions — matches the identifier rule
* used by `validateIdentifier` (and `slugPattern` in `common.ts`).
* Lowercase letters, digits, and underscores; must start with a letter.
*/
const bylineFieldSlugPattern = /^[a-z][a-z0-9_]*$/;
/** Hard cap on a slug — mirrors `BylineSchemaRegistry.MAX_SLUG_LENGTH`. */
const MAX_SLUG_LENGTH = 63;
/** Hard cap on a label — mirrors `BylineSchemaRegistry.MAX_LABEL_LENGTH`. */
const MAX_LABEL_LENGTH = 200;
/** Hard cap on a select field's `options` list. */
const MAX_SELECT_OPTIONS = 200;
const RESERVED_SET = new Set(RESERVED_BYLINE_FIELD_SLUGS);
const bylineFieldTypeValues = z.enum([
	"string",
	"text",
	"url",
	"boolean",
	"select"
]);
/**
* Validation payload for a byline custom field. v1 only exposes
* `options` (used by `select`-type fields). Empty/duplicate options are
* rejected at the registry layer; the zod layer only enforces shape and
* caps. Future field types may add keys here.
*/
const bylineFieldValidationSchema = z.object({ options: z.array(z.string().min(1)).min(1, "select options must contain at least one entry").max(MAX_SELECT_OPTIONS, `select options cannot exceed ${MAX_SELECT_OPTIONS} entries`).optional() }).strict().nullable();
/**
* Slug validation chain shared by create + reorder bodies. Centralised so
* the reserved-slug message and pattern are identical everywhere.
*/
const bylineFieldSlug = z.string().min(1, "Byline field slug is required").max(MAX_SLUG_LENGTH, `Byline field slug must be ${MAX_SLUG_LENGTH} characters or less`).regex(bylineFieldSlugPattern, "Byline field slug must contain only lowercase letters, digits, and underscores, and start with a letter").refine((slug) => !RESERVED_SET.has(slug), { message: "Byline field slug is reserved" });
const bylineFieldLabel = z.string().min(1, "Byline field label is required").max(MAX_LABEL_LENGTH, `Byline field label must be ${MAX_LABEL_LENGTH} characters or less`);
const bylineFieldCreateBody = z.object({
	slug: bylineFieldSlug,
	label: bylineFieldLabel,
	type: bylineFieldTypeValues,
	required: z.boolean().optional(),
	translatable: z.boolean().optional(),
	validation: bylineFieldValidationSchema.optional(),
	sortOrder: z.number().int().min(0).optional()
}).strict().meta({ id: "BylineFieldCreateBody" });
/**
* Update body. `slug` and `type` are intentionally absent — both are
* immutable post-create (changing them would invalidate stored values).
* `translatable` flips are gated at the registry layer when value rows
* exist (`TRANSLATABLE_LOCKED`).
*/
const bylineFieldUpdateBody = z.object({
	label: bylineFieldLabel.optional(),
	required: z.boolean().optional(),
	translatable: z.boolean().optional(),
	validation: bylineFieldValidationSchema.optional(),
	sortOrder: z.number().int().min(0).optional()
}).strict().meta({ id: "BylineFieldUpdateBody" });
const bylineFieldReorderBody = z.object({ slugs: z.array(bylineFieldSlug) }).strict().meta({ id: "BylineFieldReorderBody" });
const bylineFieldDefinitionSchema = z.object({
	id: z.string(),
	slug: z.string(),
	label: z.string(),
	type: bylineFieldTypeValues,
	required: z.boolean(),
	translatable: z.boolean(),
	validation: z.object({ options: z.array(z.string()).optional() }).nullable(),
	sortOrder: z.number().int(),
	createdAt: z.string(),
	updatedAt: z.string()
}).meta({ id: "BylineFieldDefinition" });
const bylineFieldListResponseSchema = z.object({ items: z.array(bylineFieldDefinitionSchema) }).meta({ id: "BylineFieldListResponse" });
/**
* Response shape for `GET /api/admin/byline-fields/[slug]/usage`.
*
* `translatableValueCount` counts rows in `_emdash_byline_field_values`.
* `groupValueCount` counts rows in `_emdash_byline_field_group_values`.
* `totalAffectedRows` is the sum — what the destructive-delete confirm
* dialog surfaces. Both individual counts are exposed for diagnostic
* value (e.g. inconsistency with the field's current `translatable`
* flag would show non-zero on the "wrong" side).
*/
const bylineFieldUsageResponseSchema = z.object({
	translatableValueCount: z.number().int().nonnegative(),
	groupValueCount: z.number().int().nonnegative(),
	totalAffectedRows: z.number().int().nonnegative()
}).meta({ id: "BylineFieldUsageResponse" });

//#endregion
export { passkeyOptionsBody as C, passkeyVerifyBody as D, passkeyRenameBody as E, signupCompleteBody as O, magicLinkSendBody as S, passkeyRegisterVerifyBody as T, wpRewriteUrlsBody as _, bylineFieldUpdateBody as a, inviteCreateBody as b, setupAdminBody as c, setupBody as d, importProbeBody as f, wpPrepareBody as g, wpPluginExecuteBody as h, bylineFieldReorderBody as i, signupRequestBody as k, setupAdminVerifyBody as l, wpPluginAnalyzeBody as m, bylineFieldDefinitionSchema as n, bylineFieldUsageResponseSchema as o, wpMediaImportBody as p, bylineFieldListResponseSchema as r, atprotoLoginBody as s, bylineFieldCreateBody as t, setupAtprotoAdminBody as u, authMeActionBody as v, passkeyRegisterOptionsBody as w, inviteRegisterOptionsBody as x, inviteCompleteBody as y };
//# sourceMappingURL=byline-fields-2Lp5Hbgf.mjs.map