import { Q as QuestionType, d as FormField, b as FormPolicy, c as FormSchema, J as JsonValue, f as FieldOption } from '../analytics-B1eUnjBp.cjs'; import { z } from 'zod'; import '../lifecycle.cjs'; import '../i18n/keys.cjs'; type AuthoringIntent = "generate_form" | "add_questions" | "improve_text" | "generate_options" | "rewrite_field"; type AuthoringTarget = { readonly kind: "form"; } | { readonly kind: "field"; readonly fieldId: string; } | { readonly kind: "option"; readonly fieldId: string; readonly optionId: string; }; interface AuthoringRequest { readonly intent: AuthoringIntent; readonly prompt?: string; readonly target?: AuthoringTarget; readonly context?: Readonly>; } interface AuthoringAssistantAdapter { generate: (request: AuthoringRequest, signal?: AbortSignal) => Promise; } interface AuthoringOptionInput { readonly label: string; readonly textInput?: boolean; readonly pinned?: boolean; } /** A field proposed by AI. IDs are deliberately absent and are assigned on apply. */ interface AuthoringFieldInput { readonly type: QuestionType; readonly title: string; readonly description?: string; readonly required?: boolean; readonly translationKey?: string; readonly messages?: FormField["messages"]; readonly placeholderKey?: string; readonly minLength?: number; readonly maxLength?: number; readonly pattern?: string; readonly minDate?: string; readonly maxDate?: string; readonly minTime?: string; readonly maxTime?: string; readonly min?: number; readonly max?: number; readonly step?: number; readonly shuffleOptions?: boolean; readonly minSelections?: number; readonly maxSelections?: number; readonly options?: readonly AuthoringOptionInput[]; } interface AddFieldOperation { readonly operationId: string; readonly type: "addField"; readonly field: AuthoringFieldInput; readonly pageId?: string; } type AuthoringFieldPatch = Readonly<{ readonly title?: string; readonly description?: string; readonly required?: boolean; readonly placeholderKey?: string; readonly minLength?: number; readonly maxLength?: number; readonly pattern?: string; readonly minDate?: string; readonly maxDate?: string; readonly minTime?: string; readonly maxTime?: string; readonly min?: number; readonly max?: number; readonly step?: number; readonly shuffleOptions?: boolean; readonly minSelections?: number; readonly maxSelections?: number; readonly messages?: FormField["messages"]; }>; interface UpdateFieldOperation { readonly operationId: string; readonly type: "updateField"; readonly fieldId: string; readonly patch: AuthoringFieldPatch; } interface UpdateFormOperation { readonly operationId: string; readonly type: "updateForm"; readonly patch: Readonly>>; } interface AddOptionOperation { readonly operationId: string; readonly type: "addOption"; readonly fieldId: string; readonly option: AuthoringOptionInput; } interface UpdateOptionOperation { readonly operationId: string; readonly type: "updateOption"; readonly fieldId: string; readonly optionId: string; readonly patch: Readonly>>; } type AuthoringOperation = AddFieldOperation | UpdateFieldOperation | UpdateFormOperation | AddOptionOperation | UpdateOptionOperation; interface AuthoringSuggestion { readonly id: string; readonly summary: string; readonly operations: readonly AuthoringOperation[]; readonly rationale?: string; readonly baseSchemaHash: string; } type AuthoringValidationCode = "invalid_suggestion" | "duplicate_operation_id" | "unsupported_operation" | "stale_schema" | "field_not_found" | "option_not_found" | "page_not_found" | "disallowed_field_type" | "max_fields_exceeded" | "max_options_exceeded" | "max_text_length_exceeded" | "schema_invalid" | "policy_violation"; interface AuthoringValidationIssue { readonly code: AuthoringValidationCode; readonly operationId?: string; readonly path?: string; readonly message: string; } interface AuthoringValidationResult { readonly valid: boolean; readonly issues: readonly AuthoringValidationIssue[]; } type AuthoringPreviewValue = { readonly kind: "form"; readonly title?: string; readonly description?: string; readonly completionMessage?: string; readonly submitLabelKey?: string; } | { readonly kind: "field"; readonly field?: FormField | AuthoringFieldInput; } | { readonly kind: "option"; readonly option?: FieldOption | AuthoringOptionInput; }; interface AuthoringOperationPreview { readonly operationId: string; readonly operation: AuthoringOperation; readonly valid: boolean; readonly before?: AuthoringPreviewValue; readonly after?: AuthoringPreviewValue; readonly issues: readonly AuthoringValidationIssue[]; } interface AuthoringPreview { readonly valid: boolean; readonly baseSchemaHash: string; readonly schema: FormSchema; readonly operations: readonly AuthoringOperation[]; readonly operationPreviews: readonly AuthoringOperationPreview[]; readonly issues: readonly AuthoringValidationIssue[]; } interface AuthoringPreviewOptions { readonly operationIds?: readonly string[]; readonly policy?: FormPolicy; readonly idFactory?: AuthoringApplyOptions["idFactory"]; } type AuthoringApplyError = { readonly code: "stale_schema"; readonly issues: readonly AuthoringValidationIssue[]; } | { readonly code: "validation_failed"; readonly issues: readonly AuthoringValidationIssue[]; } | { readonly code: "apply_failed"; readonly issues: readonly AuthoringValidationIssue[]; }; type AuthoringApplyResult = { readonly success: true; readonly schema: FormSchema; readonly appliedOperationIds: readonly string[]; } | { readonly success: false; readonly error: AuthoringApplyError; }; interface AuthoringApplyOptions { readonly policy?: FormPolicy; readonly idFactory?: (kind: "field" | "option", existingIds: ReadonlySet) => string; } declare function applyAuthoringSuggestion(schema: FormSchema, suggestion: AuthoringSuggestion, selectedOperationIds?: readonly string[], options?: AuthoringApplyOptions): AuthoringApplyResult; interface BuildAuthoringContextOptions { readonly schema: FormSchema; readonly request: AuthoringRequest; readonly policy?: FormPolicy; } interface AuthoringContext extends Readonly> { readonly fields: readonly JsonValue[]; } declare function buildAuthoringContext({ schema, request, policy }: BuildAuthoringContextOptions): AuthoringContext; /** Deterministic, local fingerprint for stale-suggestion protection. */ declare function computeAuthoringSchemaHash(schema: FormSchema): string; declare const AuthoringSuggestionSchema: z.ZodObject<{ id: z.ZodString; summary: z.ZodString; operations: z.ZodArray; field: z.ZodObject<{ type: z.ZodEnum<{ number: "number"; text: "text"; textarea: "textarea"; date: "date"; time: "time"; email: "email"; tel: "tel"; url: "url"; rating: "rating"; select: "select"; radio: "radio"; "multi-select": "multi-select"; checkbox: "checkbox"; }>; title: z.ZodString; description: z.ZodOptional; required: z.ZodOptional; translationKey: z.ZodOptional; messages: z.ZodOptional>; placeholderKey: z.ZodOptional; minLength: z.ZodOptional; maxLength: z.ZodOptional; pattern: z.ZodOptional; minDate: z.ZodOptional; maxDate: z.ZodOptional; minTime: z.ZodOptional; maxTime: z.ZodOptional; min: z.ZodOptional; max: z.ZodOptional; step: z.ZodOptional; shuffleOptions: z.ZodOptional; minSelections: z.ZodOptional; maxSelections: z.ZodOptional; options: z.ZodOptional; pinned: z.ZodOptional; }, z.core.$strict>>>; }, z.core.$strict>; pageId: z.ZodOptional; }, z.core.$strict>, z.ZodObject<{ operationId: z.ZodString; type: z.ZodLiteral<"updateField">; fieldId: z.ZodString; patch: z.ZodObject<{ title: z.ZodOptional; description: z.ZodOptional; required: z.ZodOptional; placeholderKey: z.ZodOptional; minLength: z.ZodOptional; maxLength: z.ZodOptional; pattern: z.ZodOptional; minDate: z.ZodOptional; maxDate: z.ZodOptional; minTime: z.ZodOptional; maxTime: z.ZodOptional; min: z.ZodOptional; max: z.ZodOptional; step: z.ZodOptional; shuffleOptions: z.ZodOptional; minSelections: z.ZodOptional; maxSelections: z.ZodOptional; messages: z.ZodOptional>; }, z.core.$strict>; }, z.core.$strict>, z.ZodObject<{ operationId: z.ZodString; type: z.ZodLiteral<"updateForm">; patch: z.ZodObject<{ title: z.ZodOptional; description: z.ZodOptional; completionMessage: z.ZodOptional; submitLabelKey: z.ZodOptional; }, z.core.$strict>; }, z.core.$strict>, z.ZodObject<{ operationId: z.ZodString; type: z.ZodLiteral<"addOption">; fieldId: z.ZodString; option: z.ZodObject<{ label: z.ZodString; textInput: z.ZodOptional; pinned: z.ZodOptional; }, z.core.$strict>; }, z.core.$strict>, z.ZodObject<{ operationId: z.ZodString; type: z.ZodLiteral<"updateOption">; fieldId: z.ZodString; optionId: z.ZodString; patch: z.ZodObject<{ label: z.ZodOptional; textInput: z.ZodOptional; pinned: z.ZodOptional; }, z.core.$strict>; }, z.core.$strict>], "type">>; rationale: z.ZodOptional; baseSchemaHash: z.ZodString; }, z.core.$strict>; declare const AUTHORING_SUGGESTION_JSON_SCHEMA: z.core.ZodStandardJSONSchemaPayload; field: z.ZodObject<{ type: z.ZodEnum<{ number: "number"; text: "text"; textarea: "textarea"; date: "date"; time: "time"; email: "email"; tel: "tel"; url: "url"; rating: "rating"; select: "select"; radio: "radio"; "multi-select": "multi-select"; checkbox: "checkbox"; }>; title: z.ZodString; description: z.ZodOptional; required: z.ZodOptional; translationKey: z.ZodOptional; messages: z.ZodOptional>; placeholderKey: z.ZodOptional; minLength: z.ZodOptional; maxLength: z.ZodOptional; pattern: z.ZodOptional; minDate: z.ZodOptional; maxDate: z.ZodOptional; minTime: z.ZodOptional; maxTime: z.ZodOptional; min: z.ZodOptional; max: z.ZodOptional; step: z.ZodOptional; shuffleOptions: z.ZodOptional; minSelections: z.ZodOptional; maxSelections: z.ZodOptional; options: z.ZodOptional; pinned: z.ZodOptional; }, z.core.$strict>>>; }, z.core.$strict>; pageId: z.ZodOptional; }, z.core.$strict>, z.ZodObject<{ operationId: z.ZodString; type: z.ZodLiteral<"updateField">; fieldId: z.ZodString; patch: z.ZodObject<{ title: z.ZodOptional; description: z.ZodOptional; required: z.ZodOptional; placeholderKey: z.ZodOptional; minLength: z.ZodOptional; maxLength: z.ZodOptional; pattern: z.ZodOptional; minDate: z.ZodOptional; maxDate: z.ZodOptional; minTime: z.ZodOptional; maxTime: z.ZodOptional; min: z.ZodOptional; max: z.ZodOptional; step: z.ZodOptional; shuffleOptions: z.ZodOptional; minSelections: z.ZodOptional; maxSelections: z.ZodOptional; messages: z.ZodOptional>; }, z.core.$strict>; }, z.core.$strict>, z.ZodObject<{ operationId: z.ZodString; type: z.ZodLiteral<"updateForm">; patch: z.ZodObject<{ title: z.ZodOptional; description: z.ZodOptional; completionMessage: z.ZodOptional; submitLabelKey: z.ZodOptional; }, z.core.$strict>; }, z.core.$strict>, z.ZodObject<{ operationId: z.ZodString; type: z.ZodLiteral<"addOption">; fieldId: z.ZodString; option: z.ZodObject<{ label: z.ZodString; textInput: z.ZodOptional; pinned: z.ZodOptional; }, z.core.$strict>; }, z.core.$strict>, z.ZodObject<{ operationId: z.ZodString; type: z.ZodLiteral<"updateOption">; fieldId: z.ZodString; optionId: z.ZodString; patch: z.ZodObject<{ label: z.ZodOptional; textInput: z.ZodOptional; pinned: z.ZodOptional; }, z.core.$strict>; }, z.core.$strict>], "type">>; rationale: z.ZodOptional; baseSchemaHash: z.ZodString; }, z.core.$strict>>; declare function parseAuthoringSuggestion(value: unknown): AuthoringSuggestion; declare function validateAuthoringSuggestion(suggestion: AuthoringSuggestion, schema: FormSchema, policy?: FormPolicy): AuthoringValidationResult; declare function previewAuthoringSuggestion(schema: FormSchema, suggestion: AuthoringSuggestion, options?: AuthoringPreviewOptions): AuthoringPreview; export { AUTHORING_SUGGESTION_JSON_SCHEMA, type AddFieldOperation, type AddOptionOperation, type AuthoringApplyError, type AuthoringApplyOptions, type AuthoringApplyResult, type AuthoringAssistantAdapter, type AuthoringContext, type AuthoringFieldInput, type AuthoringFieldPatch, type AuthoringIntent, type AuthoringOperation, type AuthoringOperationPreview, type AuthoringOptionInput, type AuthoringPreview, type AuthoringPreviewOptions, type AuthoringPreviewValue, type AuthoringRequest, type AuthoringSuggestion, AuthoringSuggestionSchema, type AuthoringTarget, type AuthoringValidationCode, type AuthoringValidationIssue, type AuthoringValidationResult, type BuildAuthoringContextOptions, type UpdateFieldOperation, type UpdateFormOperation, type UpdateOptionOperation, applyAuthoringSuggestion, buildAuthoringContext, computeAuthoringSchemaHash, parseAuthoringSuggestion, previewAuthoringSuggestion, validateAuthoringSuggestion };