{"version":3,"file":"index.cjs","names":["z","z","field","buildField","buildBlock"],"sources":["../../../forge-core/src/components/utils/buildComponent.ts","../../../forge-core/src/authoring/types/enums.ts","../../../forge-core/src/components/typeguards.ts","../../../forge-core/src/authoring/builders/utils/captureCallsite.ts","../../../forge-core/src/authoring/builders/utils/splitKey.ts","../../../forge-core/src/authoring/builders/IterableBuilder.ts","../../../forge-core/src/authoring/builders/ExpressionBuilder.ts","../../../forge-core/src/authoring/builders/ReferenceBuilder.ts","../../../forge-core/src/authoring/builders/LoopReferenceBuilder.ts","../../../forge-core/src/authoring/builders/references.ts","../../../forge-core/src/shared/diagnostics/formatCallsite.ts","../../../forge-core/src/engine/errors/DiagnosticErrorFormatter.ts","../../../forge-core/src/engine/errors/ForgeBaseError.ts","../../../forge-core/src/engine/errors/ForgeAuthoringError.ts","../../../forge-core/src/shared/diagnostics/DSLPathFormatter.ts","../../../forge-core/src/shared/diagnostics/DSLSourceLocator.ts","../../../forge-core/src/authoring/builders/utils/finaliseBuilders.ts","../../../forge-core/src/authoring/builders/structures.ts","../../../forge-core/src/engine/errors/ForgeRegistryDuplicateError.ts","../../../forge-core/src/authoring/builders/GeneratorBuilder.ts","../../../forge-core/src/authoring/registries/BaseFunctionRegistry.ts","../../../forge-core/src/authoring/registries/GeneratorRegistry.ts","../../../forge-core/src/built-ins/functions/generators/formatGenerators.ts","../../../forge-core/src/authoring/builders/values.ts","../../../forge-core/src/authoring/builders/combinators.ts","../../../forge-core/src/components/component.ts","../../../forge-core/src/built-ins/sanitize.ts","../../../forge-core/src/built-ins/components/html.ts","../../../forge-core/src/built-ins/components/collectionBlock.ts","../../../forge-core/src/built-ins/components/templateWrapper.ts","../../../forge-core/src/built-ins/components/fragment.ts","../../../forge-core/src/built-ins/components/index.ts"],"sourcesContent":["import type { ZodType } from 'zod'\nimport { ComponentRegistryEntry, ComponentRenderer } from '../types/components.type'\nimport type { BlockDefinition } from '../types/structures.type'\n\nexport interface BuildComponentOptions {\n  inputSchema?: ZodType\n  multiple?: boolean\n}\n\n/**\n * Creates a component for the registry.\n *\n * Use this for simple components that render HTML directly, such as\n * HTML passthrough or collection blocks.\n *\n *\n * @param variant - The block variant identifier (e.g., 'html', 'collection-block')\n * @param renderer - Function that takes a block and returns HTML string\n * @param options - Optional input schema and fixed-shape `multiple` flag for the entry\n * @returns A registerable component\n *\n * @example\n * ```typescript\n * export const html = buildComponent<HtmlBlock>('html', block => {\n *   return block.content\n * })\n * ```\n */\nexport const buildComponent = <T extends BlockDefinition, TRenderOutput = string>(\n  variant: string,\n  renderer: ComponentRenderer<T, TRenderOutput>,\n  options: BuildComponentOptions = {},\n): ComponentRegistryEntry<T, TRenderOutput> => ({\n  variant,\n  render: renderer,\n  ...(options.inputSchema !== undefined && { inputSchema: options.inputSchema }),\n  ...(options.multiple !== undefined && { multiple: options.multiple }),\n})\n","/**\n * Discriminates the four kinds of registered function a call expression can\n * target: conditions test values, transformers reshape them, generators\n * produce them, and effects perform side effects in hooks.\n */\nexport enum FunctionType {\n  CONDITION = 'FunctionType.Condition',\n  TRANSFORMER = 'FunctionType.Transformer',\n  GENERATOR = 'FunctionType.Generator',\n  EFFECT = 'FunctionType.Effect',\n}\n\n/**\n * Discriminates the structural nodes a form is built from: journeys contain\n * steps, steps contain blocks.\n */\nexport enum StructureType {\n  BLOCK = 'StructureType.Block',\n  JOURNEY = 'StructureType.Journey',\n  STEP = 'StructureType.Step',\n}\n\n/**\n * Distinguishes field blocks, which collect answers, from basic blocks,\n * which only display content.\n */\nexport enum BlockType {\n  FIELD = 'BlockType.field',\n  BASIC = 'BlockType.basic',\n}\n\n/**\n * Discriminates expression nodes: value expressions such as references,\n * pipelines, conditionals, and iterations, plus rule nodes such as\n * validations and tie-breakers.\n */\nexport enum ExpressionType {\n  REFERENCE = 'ExpressionType.Reference',\n  PIPELINE = 'ExpressionType.Pipeline',\n  NULLISH = 'ExpressionType.Nullish',\n  NEXT = 'ExpressionType.Next',\n  VALIDATION = 'ExpressionType.Validation',\n  ITERATE = 'ExpressionType.Iterate',\n  CONDITIONAL = 'ExpressionType.Conditional',\n  MATCH = 'ExpressionType.Match',\n  TIE_BREAKER = 'ExpressionType.TieBreaker',\n}\n\n/**\n * Discriminates the per-item operations an iterate expression can apply to\n * a collection.\n */\nexport enum IteratorType {\n  MAP = 'IteratorType.Map',\n  FILTER = 'IteratorType.Filter',\n  FIND = 'IteratorType.Find',\n  SOME = 'IteratorType.Some',\n  EVERY = 'IteratorType.Every',\n  COUNT = 'IteratorType.Count',\n}\n\n/**\n * Discriminates predicate nodes: a single condition test, or a logical\n * combination of other predicates.\n */\nexport enum PredicateType {\n  TEST = 'PredicateType.Test',\n  AND = 'PredicateType.And',\n  OR = 'PredicateType.Or',\n  XOR = 'PredicateType.Xor',\n  NOT = 'PredicateType.Not',\n}\n\n/**\n * Discriminates the logical combinations of a subject-less condition\n * combinator tree, as used by match branches. Unlike PredicateType, whose\n * TEST leaves carry their own subject, these trees combine bare conditions\n * and take their subject from the surrounding match expression.\n */\nexport enum ConditionCombinatorType {\n  AND = 'ConditionCombinatorType.And',\n  OR = 'ConditionCombinatorType.Or',\n  XOR = 'ConditionCombinatorType.Xor',\n  NOT = 'ConditionCombinatorType.Not',\n}\n\n/**\n * Discriminates lifecycle hooks: access hooks run on every request, submit\n * hooks run on form submission.\n */\nexport enum HookType {\n  ACCESS = 'HookType.Access',\n  SUBMIT = 'HookType.Submit',\n}\n\n/**\n * Discriminates the outcomes a hook can halt with: a redirect or a thrown\n * error.\n */\nexport enum OutcomeType {\n  REDIRECT = 'Outcome.Redirect',\n  THROW_ERROR = 'Outcome.ThrowError',\n}\n","import { BlockDefinition, FieldBlockDefinition, RenderedBlock } from './types/structures.type'\nimport { BlockType, StructureType } from '../authoring/types/enums'\n\nfunction isBlockDefinition(obj: any): obj is BlockDefinition {\n  return obj != null && obj.type === StructureType.BLOCK\n}\n\nexport function isFieldBlockDefinition(obj: any): obj is FieldBlockDefinition {\n  return isBlockDefinition(obj) && obj.blockType === BlockType.FIELD\n}\n\nexport function isRenderedBlock(obj: unknown): obj is RenderedBlock {\n  return obj != null &&\n    typeof obj === 'object' &&\n    'html' in obj &&\n    typeof obj.html === 'string' &&\n    'block' in obj &&\n    isBlockDefinition(obj.block)\n}\n","export interface Callsite {\n  readonly stack?: string\n}\n\n/**\n * Captures the caller's stack without formatting it: V8 defines `.stack` as a\n * lazy accessor, so the (expensive) trace formatting only happens if something\n * actually reads it. Do not read `.stack` here.\n *\n * @param skip - Frames above this function are kept; it and everything below are dropped\n */\nexport const captureCallsite = (skip: (...args: any[]) => unknown): Callsite => {\n  if (typeof Error.captureStackTrace !== 'function') {\n    return {}\n  }\n\n  const site: Callsite = {}\n  const previousLimit = Error.stackTraceLimit\n\n  // Deep enough that wrapper DSL layers (curried builders, native Array.map\n  // frames) cannot eat the whole budget before the author's own frame lands.\n  Error.stackTraceLimit = 15\n  try {\n    Error.captureStackTrace(site, skip)\n  } finally {\n    Error.stackTraceLimit = previousLimit\n  }\n\n  return site\n}\n\n/**\n * Attaches a captured callsite to an object as a non-enumerable `__callsite`.\n * configurable + writable so finalisation walks can re-stamp copies.\n */\nexport const stampCallsite = (target: unknown, callsite: Callsite): void => {\n  if (target === null || typeof target !== 'object' || !('stack' in callsite)) {\n    return\n  }\n\n  Object.defineProperty(target, '__callsite', {\n    value: callsite,\n    enumerable: false,\n    configurable: true,\n    writable: true,\n  })\n}\n","/**\n * Split a key string into path segments.\n * 'user.name' -> ['user', 'name']\n * 'simple' -> ['simple']\n */\nexport const splitKey = (key: string): string[] => (key.includes('.') ? key.split('.') : [key])\n","import {\n  ConditionFunctionExpr,\n  FilterIteratorConfig,\n  FindIteratorConfig,\n  IterateExpr,\n  IteratorConfig,\n  SomeIteratorConfig,\n  EveryIteratorConfig,\n  CountIteratorConfig,\n  CollectionPredicateExpr,\n  NullishExpr,\n  MapIteratorConfig,\n  PipelineExpr,\n  PredicateTestExpr,\n  ReferenceExpr,\n  TransformerFunctionExpr,\n  ResolvableValue,\n} from '../types/expressions.type'\nimport { ExpressionType, IteratorType, PredicateType } from '../types/enums'\nimport { ExpressionBuilder } from './ExpressionBuilder'\nimport { captureCallsite, stampCallsite } from './utils/captureCallsite'\nimport { splitKey } from './utils/splitKey'\n\n/**\n * Immutable builder for chainable iterate expressions.\n *\n * Created by .each() on ReferenceBuilder or ExpressionBuilder.\n * Supports chaining: .each().each().pipe()\n *\n * Enables fluent API patterns like:\n * - Data('items').each(Iterator.Map({ ... }))\n * - Data('items').each(Iterator.Filter(...)).each(Iterator.Map(...))\n * - Data('items').each(Iterator.Map({ ... })).pipe(Transformer.Array.Slice(0, 10))\n *\n * Key design decisions:\n * - Immutable: Each method returns a NEW instance\n * - Chainable: Multiple .each() calls compose iterators\n * - Escapable: .pipe() exits iteration mode to operate on the result array\n *\n * @internal Exposed to authors via the ChainableIterable interface.\n */\nexport class IterableBuilder {\n  readonly nodeKind = 'forge-builder' as const\n\n  private readonly expression: IterateExpr\n\n  private readonly negated: boolean\n\n  private constructor(expr: IterateExpr, negate: boolean) {\n    this.expression = expr\n    this.negated = negate\n  }\n\n  /**\n   * Create an iterable builder from a source and iterator.\n   */\n  static create(input: ResolvableValue, iterator: IteratorConfig): IterableBuilder {\n    return new IterableBuilder(\n      {\n        type: ExpressionType.ITERATE,\n        input,\n        iterator,\n      },\n      false,\n    )\n  }\n\n  /**\n   * Get the underlying expression.\n   */\n  get expr(): IterateExpr {\n    return this.expression\n  }\n\n  /**\n   * Build the final expression.\n   * Called automatically by finaliseBuilders().\n   */\n  build(): IterateExpr {\n    return this.expression\n  }\n\n  /**\n   * Chain a Find iterator.\n   * Returns an ExpressionBuilder since Find returns a single item, not an array.\n   *\n   * @example\n   * Data('items')\n   *   .each(Iterator.Filter(...))\n   *   .each(Iterator.Find(...))\n   *   .path('name')  // Navigate into the found item\n   */\n  each(iterator: FindIteratorConfig): ExpressionBuilder<ReferenceExpr>\n\n  /** Test the collection directly as a predicate. */\n  each(iterator: SomeIteratorConfig | EveryIteratorConfig): CollectionPredicateExpr\n\n  /** Count matching items and continue with the resulting number. */\n  each(iterator: CountIteratorConfig): ExpressionBuilder<IterateExpr>\n\n  /**\n   * Chain a Map or Filter iterator.\n   * Returns an IterableBuilder that can chain more .each() calls.\n   *\n   * @example\n   * Data('items')\n   *   .each(Iterator.Filter(Item().path('active').match(Condition.IsTrue())))\n   *   .each(Iterator.Map({ label: Item().path('name') }))\n   */\n  each(iterator: MapIteratorConfig | FilterIteratorConfig): IterableBuilder\n\n  /**\n   * Chain another iterator operation.\n   */\n  each(\n    iterator: IteratorConfig,\n  ): IterableBuilder | ExpressionBuilder<ReferenceExpr> | ExpressionBuilder<IterateExpr> | CollectionPredicateExpr {\n    if (iterator.type === IteratorType.COUNT) {\n      const expression: IterateExpr = { type: ExpressionType.ITERATE, input: this.expression, iterator }\n      const builder = ExpressionBuilder.from(expression)\n\n      stampCallsite(builder, captureCallsite(this.each))\n\n      return builder\n    }\n\n    if (iterator.type === IteratorType.SOME || iterator.type === IteratorType.EVERY) {\n      const predicate: CollectionPredicateExpr = { type: ExpressionType.ITERATE, input: this.expression, iterator }\n\n      stampCallsite(predicate, captureCallsite(this.each))\n\n      return predicate\n    }\n\n    if (iterator.type === IteratorType.FIND) {\n      // Find returns a single item - wrap in a reference with empty path\n      // so .path() works naturally\n      const iterateExpr: IterateExpr = {\n        type: ExpressionType.ITERATE,\n        input: this.expression,\n        iterator,\n      }\n      const referenceExpr: ReferenceExpr = {\n        type: ExpressionType.REFERENCE,\n        base: iterateExpr,\n        path: [],\n      }\n\n      return ExpressionBuilder.from(referenceExpr)\n    }\n\n    return IterableBuilder.create(this.expression, iterator)\n  }\n\n  /**\n   * Transform the output array through a pipeline.\n   * Exits iteration mode - operates on the whole result array.\n   *\n   * @example\n   * Data('items')\n   *   .each(Iterator.Map(Item().path('name')))\n   *   .pipe(Transformer.Array.Slice(0, 10))\n   */\n  pipe(...steps: TransformerFunctionExpr[]): ExpressionBuilder<PipelineExpr> {\n    return ExpressionBuilder.pipeline(this.expression, steps)\n  }\n\n  /** Uses the fallback only when the value is null or undefined, like `??`. */\n  nullish(fallback: ResolvableValue | undefined): ExpressionBuilder<NullishExpr> {\n    const expression: NullishExpr = {\n      type: ExpressionType.NULLISH,\n      input: this.expression,\n      ...(fallback !== undefined && { fallback }),\n    }\n    const builder = ExpressionBuilder.from(expression)\n\n    stampCallsite(builder, captureCallsite(this.nullish))\n\n    return builder\n  }\n\n  /**\n   * Navigate into a property of the iteration result.\n   * Useful after Iterator.Find() to extract a specific property from the found item.\n   *\n   * Creates a ReferenceExpr with the iterate expression as its base,\n   * which evaluates the iteration first and then navigates into the result.\n   *\n   * @param key - Property path to navigate into (supports dot notation)\n   * @returns ExpressionBuilder wrapping a ReferenceExpr\n   *\n   * @example\n   * // Find an item and get its 'goals' property\n   * Literal(areasOfNeed)\n   *   .each(Iterator.Find(Item().path('slug').match(Condition.Equals(Params('area')))))\n   *   .path('goals')\n   *\n   * @example\n   * // Nested path navigation\n   * Data('users')\n   *   .each(Iterator.Find(...))\n   *   .path('profile.settings')\n   */\n  path(key: string): ExpressionBuilder<ReferenceExpr> {\n    const referenceExpr: ReferenceExpr = {\n      type: ExpressionType.REFERENCE,\n      base: this.expression,\n      path: splitKey(key),\n    }\n\n    return ExpressionBuilder.from(referenceExpr)\n  }\n\n  /**\n   * Test the output array against a condition.\n   * Terminal operation - returns a plain PredicateTestExpr.\n   *\n   * @example\n   * Data('items')\n   *   .each(Iterator.Filter(...))\n   *   .match(Condition.Array.IsEmpty())\n   */\n  match(condition: ConditionFunctionExpr<any>): PredicateTestExpr {\n    const predicate: PredicateTestExpr = {\n      type: PredicateType.TEST,\n      subject: this.expression,\n      negate: this.negated,\n      condition,\n    }\n\n    stampCallsite(predicate, captureCallsite(this.match))\n\n    return predicate\n  }\n\n  /**\n   * Negate the next condition test.\n   * Returns a new builder with toggled negation.\n   *\n   * @example\n   * Data('items')\n   *   .each(Iterator.Filter(...))\n   *   .not.match(Condition.Array.IsEmpty())\n   */\n  get not(): IterableBuilder {\n    return new IterableBuilder(this.expression, !this.negated)\n  }\n}\n","import {\n  ConditionFunctionExpr,\n  FilterIteratorConfig,\n  FindIteratorConfig,\n  IteratorConfig,\n  SomeIteratorConfig,\n  EveryIteratorConfig,\n  CountIteratorConfig,\n  CollectionPredicateExpr,\n  NullishExpr,\n  IterateExpr,\n  MapIteratorConfig,\n  PipelineExpr,\n  PredicateTestExpr,\n  ReferenceExpr,\n  TransformerFunctionExpr,\n  ResolvableValue,\n} from '../types/expressions.type'\nimport { ExpressionType, IteratorType, PredicateType } from '../types/enums'\nimport { IterableBuilder } from './IterableBuilder'\nimport { captureCallsite, stampCallsite } from './utils/captureCallsite'\nimport { splitKey } from './utils/splitKey'\n\n/**\n * Immutable builder for creating chainable value expressions.\n *\n * Enables fluent API patterns like:\n * - Answer('email').pipe(Transformer.String.Trim).match(Condition.IsRequired())\n * - Self().not.match(Condition.String.IsEmpty())\n * - Answer('quantity').pipe(Transformer.Number.Parse).not.match(Condition.Number.LessThan(0))\n *\n * Key design decisions:\n * - Immutable: Each method returns a NEW instance\n * - Type-safe: Full TypeScript inference throughout chains\n * - Buildable: Implements build() for automatic finalization via finaliseBuilders()\n *\n * @internal Exposed to authors via the ChainableExpr interface.\n */\nexport class ExpressionBuilder<T extends ResolvableValue> {\n  readonly nodeKind = 'forge-builder' as const\n\n  private readonly expression: T\n\n  private readonly negate: boolean\n\n  private constructor(expr: T, negate: boolean) {\n    this.expression = expr\n    this.negate = negate\n  }\n\n  /**\n   * Create a builder from any value expression.\n   */\n  static from<E extends ResolvableValue>(expr: E): ExpressionBuilder<E> {\n    return new ExpressionBuilder(expr, false)\n  }\n\n  /**\n   * Create a builder wrapping a pipeline expression.\n   */\n  static pipeline(input: ResolvableValue, steps: TransformerFunctionExpr[]): ExpressionBuilder<PipelineExpr> {\n    return new ExpressionBuilder(\n      {\n        type: ExpressionType.PIPELINE,\n        input,\n        steps,\n      },\n      false,\n    )\n  }\n\n  /**\n   * Get the underlying expression.\n   */\n  get expr(): T {\n    return this.expression\n  }\n\n  /**\n   * Build the final expression.\n   * Called automatically by finaliseBuilders().\n   */\n  build(): T {\n    return this.expression\n  }\n\n  /**\n   * Transform the value through a pipeline of transformers.\n   * Each call creates a nested pipeline (input is the current expression).\n   *\n   * @example\n   * Answer('email').pipe(\n   *   Transformer.String.Trim,\n   *   Transformer.String.ToLowerCase,\n   * )\n   */\n  pipe(...steps: TransformerFunctionExpr[]): ExpressionBuilder<PipelineExpr> {\n    return ExpressionBuilder.pipeline(this.expression, steps)\n  }\n\n  /** Uses the fallback only when the value is null or undefined, like `??`. */\n  nullish(fallback: ResolvableValue | undefined): ExpressionBuilder<NullishExpr> {\n    const expression: NullishExpr = {\n      type: ExpressionType.NULLISH,\n      input: this.expression,\n      ...(fallback !== undefined && { fallback }),\n    }\n    const builder = ExpressionBuilder.from(expression)\n\n    stampCallsite(builder, captureCallsite(this.nullish))\n\n    return builder\n  }\n\n  /**\n   * Navigate into a property of the expression result.\n   * Creates a ReferenceExpr with this expression as its base.\n   *\n   * @param key - Property path to navigate into (supports dot notation)\n   * @returns ExpressionBuilder wrapping a ReferenceExpr\n   *\n   * @example\n   * // After a Find, navigate into the result\n   * Data('users').each(Iterator.Find(...)).path('profile.name')\n   */\n  path(key: string): ExpressionBuilder<ReferenceExpr> {\n    const referenceExpr: ReferenceExpr = {\n      type: ExpressionType.REFERENCE,\n      base: this.expression,\n      path: splitKey(key),\n    }\n\n    return ExpressionBuilder.from(referenceExpr)\n  }\n\n  /**\n   * Enter per-item iteration mode with a Find iterator.\n   * Returns an ExpressionBuilder since Find returns a single item, not an array.\n   *\n   * @example\n   * Data('users').each(Iterator.Find(Item().path('id').match(Condition.Equals(Params('userId')))))\n   *   .path('name')  // Navigate into the found item\n   */\n  each(iterator: FindIteratorConfig): ExpressionBuilder<ReferenceExpr>\n\n  /** Test the collection directly as a predicate. */\n  each(iterator: SomeIteratorConfig | EveryIteratorConfig): CollectionPredicateExpr\n\n  /** Count matching items and continue with the resulting number. */\n  each(iterator: CountIteratorConfig): ExpressionBuilder<IterateExpr>\n\n  /**\n   * Enter per-item iteration mode with a Map or Filter iterator.\n   * Returns an IterableBuilder that can chain more .each() calls or exit via .pipe().\n   *\n   * @example\n   * Literal(someArray).each(Iterator.Map(Item().path('name')))\n   */\n  each(iterator: MapIteratorConfig | FilterIteratorConfig): IterableBuilder\n\n  /**\n   * Enter per-item iteration mode with an iterator.\n   */\n  each(\n    iterator: IteratorConfig,\n  ): IterableBuilder | ExpressionBuilder<ReferenceExpr> | ExpressionBuilder<IterateExpr> | CollectionPredicateExpr {\n    if (iterator.type === IteratorType.COUNT) {\n      const expression: IterateExpr = { type: ExpressionType.ITERATE, input: this.expression, iterator }\n      const builder = ExpressionBuilder.from(expression)\n\n      stampCallsite(builder, captureCallsite(this.each))\n\n      return builder\n    }\n\n    if (iterator.type === IteratorType.SOME || iterator.type === IteratorType.EVERY) {\n      const predicate: CollectionPredicateExpr = { type: ExpressionType.ITERATE, input: this.expression, iterator }\n\n      stampCallsite(predicate, captureCallsite(this.each))\n\n      return predicate\n    }\n\n    if (iterator.type === IteratorType.FIND) {\n      // Find returns a single item - wrap in a reference with empty path\n      // so .path() works naturally\n      const iterateExpr = {\n        type: ExpressionType.ITERATE as const,\n        input: this.expression,\n        iterator,\n      }\n      const referenceExpr: ReferenceExpr = {\n        type: ExpressionType.REFERENCE,\n        base: iterateExpr,\n        path: [],\n      }\n\n      return ExpressionBuilder.from(referenceExpr)\n    }\n\n    return IterableBuilder.create(this.expression, iterator)\n  }\n\n  /**\n   * Test the value against a condition.\n   * Terminal operation - returns a plain PredicateTestExpr.\n   *\n   * @example\n   * Answer('age').match(Condition.Number.GreaterThan(18))\n   * Self().not.match(Condition.IsRequired())\n   */\n  match(condition: ConditionFunctionExpr<any>): PredicateTestExpr {\n    const predicate: PredicateTestExpr = {\n      type: PredicateType.TEST,\n      subject: this.expression,\n      negate: this.negate,\n      condition,\n    }\n\n    stampCallsite(predicate, captureCallsite(this.match))\n\n    return predicate\n  }\n\n  /**\n   * Negate the next condition test.\n   * Returns a new builder with toggled negation.\n   *\n   * @example\n   * Self().not.match(Condition.IsRequired())  // negate: true\n   * Self().not.not.match(Condition.IsRequired())  // negate: false (double negation)\n   */\n  get not(): ExpressionBuilder<T> {\n    return new ExpressionBuilder(this.expression, !this.negate)\n  }\n}\n","import {\n  ConditionFunctionExpr,\n  FilterIteratorConfig,\n  FindIteratorConfig,\n  IteratorConfig,\n  SomeIteratorConfig,\n  EveryIteratorConfig,\n  CountIteratorConfig,\n  CollectionPredicateExpr,\n  NullishExpr,\n  IterateExpr,\n  ResolvableValue,\n  MapIteratorConfig,\n  PipelineExpr,\n  PredicateTestExpr,\n  ReferenceExpr,\n  TransformerFunctionExpr,\n} from '../types/expressions.type'\nimport { ExpressionType, IteratorType, PredicateType } from '../types/enums'\nimport { ExpressionBuilder } from './ExpressionBuilder'\nimport { IterableBuilder } from './IterableBuilder'\nimport { captureCallsite, stampCallsite } from './utils/captureCallsite'\nimport { splitKey } from './utils/splitKey'\n\n/**\n * Immutable builder for ReferenceExpr with path navigation support.\n *\n * Extends the base expression builder pattern with:\n * - .path(key) for nested property access\n *\n * @example\n * Data('user').path('address.city')  // path: ['data', 'user', 'address', 'city']\n * Answer('email').pipe(Transformer.String.Trim).match(Condition.IsRequired())\n *\n * @internal Exposed to authors via the ChainableRef interface.\n */\nexport class ReferenceBuilder {\n  readonly nodeKind = 'forge-builder' as const\n\n  private readonly reference: ReferenceExpr\n\n  private readonly negated: boolean\n\n  private constructor(ref: ReferenceExpr, negate: boolean) {\n    this.reference = ref\n    this.negated = negate\n  }\n\n  /**\n   * Create a builder from path segments.\n   */\n  static create(path: string[]): ReferenceBuilder {\n    return new ReferenceBuilder(\n      {\n        type: ExpressionType.REFERENCE,\n        path,\n      },\n      false,\n    )\n  }\n\n  /**\n   * Get the underlying reference expression.\n   */\n  get expr(): ReferenceExpr {\n    return this.reference\n  }\n\n  /**\n   * Build the final reference expression.\n   * Called automatically by finaliseBuilders().\n   */\n  build(): ReferenceExpr {\n    return this.reference\n  }\n\n  /**\n   * Navigate to a nested property.\n   * Supports dot notation: .path('user.address.city')\n   *\n   * @example\n   * Data('response').path('data.items')\n   * Answer('user').path('address').path('postcode')\n   */\n  path(key: string): ReferenceBuilder {\n    const newRef: ReferenceExpr = {\n      type: ExpressionType.REFERENCE,\n      path: [...this.reference.path, ...splitKey(key)],\n    }\n\n    return new ReferenceBuilder(newRef, false)\n  }\n\n  /**\n   * Transform through a pipeline of transformers.\n   * Returns an ExpressionBuilder wrapping the PipelineExpr.\n   *\n   * @example\n   * Answer('email').pipe(Transformer.String.Trim, Transformer.String.ToLowerCase)\n   */\n  pipe(...steps: TransformerFunctionExpr[]): ExpressionBuilder<PipelineExpr> {\n    return ExpressionBuilder.pipeline(this.reference, steps)\n  }\n\n  /** Uses the fallback only when the value is null or undefined, like `??`. */\n  nullish(fallback: ResolvableValue | undefined): ExpressionBuilder<NullishExpr> {\n    const expression: NullishExpr = {\n      type: ExpressionType.NULLISH,\n      input: this.reference,\n      ...(fallback !== undefined && { fallback }),\n    }\n    const builder = ExpressionBuilder.from(expression)\n\n    stampCallsite(builder, captureCallsite(this.nullish))\n\n    return builder\n  }\n\n  /**\n   * Enter per-item iteration mode with a Find iterator.\n   * Returns an ExpressionBuilder since Find returns a single item, not an array.\n   *\n   * @example\n   * Data('users').each(Iterator.Find(Item().path('id').match(Condition.Equals(Params('userId')))))\n   *   .path('name')  // Navigate into the found item\n   */\n  each(iterator: FindIteratorConfig): ExpressionBuilder<ReferenceExpr>\n\n  /** Test the collection directly as a predicate. */\n  each(iterator: SomeIteratorConfig | EveryIteratorConfig): CollectionPredicateExpr\n\n  /** Count matching items and continue with the resulting number. */\n  each(iterator: CountIteratorConfig): ExpressionBuilder<IterateExpr>\n\n  /**\n   * Enter per-item iteration mode with a Map or Filter iterator.\n   * Returns an IterableBuilder that can chain more .each() calls or exit via .pipe().\n   *\n   * @example\n   * Data('items').each(Iterator.Map({ label: Item().path('name') }))\n   * Data('items').each(Iterator.Filter(...)).each(Iterator.Map(...))\n   */\n  each(iterator: MapIteratorConfig | FilterIteratorConfig): IterableBuilder\n\n  /**\n   * Enter per-item iteration mode with an iterator.\n   */\n  each(\n    iterator: IteratorConfig,\n  ): IterableBuilder | ExpressionBuilder<ReferenceExpr> | ExpressionBuilder<IterateExpr> | CollectionPredicateExpr {\n    if (iterator.type === IteratorType.COUNT) {\n      const expression: IterateExpr = { type: ExpressionType.ITERATE, input: this.reference, iterator }\n      const builder = ExpressionBuilder.from(expression)\n\n      stampCallsite(builder, captureCallsite(this.each))\n\n      return builder\n    }\n\n    if (iterator.type === IteratorType.SOME || iterator.type === IteratorType.EVERY) {\n      const predicate: CollectionPredicateExpr = { type: ExpressionType.ITERATE, input: this.reference, iterator }\n\n      stampCallsite(predicate, captureCallsite(this.each))\n\n      return predicate\n    }\n\n    if (iterator.type === IteratorType.FIND) {\n      // Find returns a single item - wrap in a reference with empty path\n      // so .path() works naturally\n      const iterateExpr = {\n        type: ExpressionType.ITERATE as const,\n        input: this.reference,\n        iterator,\n      }\n      const referenceExpr: ReferenceExpr = {\n        type: ExpressionType.REFERENCE,\n        base: iterateExpr,\n        path: [],\n      }\n\n      return ExpressionBuilder.from(referenceExpr)\n    }\n\n    return IterableBuilder.create(this.reference, iterator)\n  }\n\n  /**\n   * Test against a condition.\n   * Terminal operation - returns a plain PredicateTestExpr.\n   *\n   * @example\n   * Answer('email').match(Condition.Email.IsValid())\n   * Self().not.match(Condition.IsRequired())\n   */\n  match(condition: ConditionFunctionExpr<any>): PredicateTestExpr {\n    const predicate: PredicateTestExpr = {\n      type: PredicateType.TEST,\n      subject: this.reference,\n      negate: this.negated,\n      condition,\n    }\n\n    stampCallsite(predicate, captureCallsite(this.match))\n\n    return predicate\n  }\n\n  /**\n   * Negate the next condition test.\n   * Returns a new builder with toggled negation.\n   *\n   * @example\n   * Self().not.match(Condition.IsRequired())  // negate: true\n   * Answer('x').not.not.match(...)  // negate: false (double negation)\n   */\n  get not(): ReferenceBuilder {\n    return new ReferenceBuilder(this.reference, !this.negated)\n  }\n}\n","import { ReferenceBuilder } from './ReferenceBuilder'\n\n/**\n * Immutable builder for creating references to iterator loop metadata.\n *\n * This mirrors Nunjucks' loop object: Item() references the current item, while\n * Loop references metadata about the current iteration.\n *\n * @internal Exposed to authors via the ChainableLoopRef interface.\n */\nexport class LoopReferenceBuilder {\n  readonly nodeKind = 'forge-builder' as const\n\n  private readonly level: number\n\n  private constructor(level: number) {\n    this.level = level\n  }\n\n  /**\n   * Create a loop reference builder at the specified nesting level.\n   * Level 0 is the current loop, level 1 is the parent loop, etc.\n   */\n  static create(level: number): LoopReferenceBuilder {\n    return new LoopReferenceBuilder(level)\n  }\n\n  /**\n   * Navigate to the parent loop in nested collections.\n   *\n   * @example\n   * Loop.Parent.Index()\n   * Loop.Parent.Parent.Index0()\n   */\n  get Parent(): LoopReferenceBuilder {\n    return new LoopReferenceBuilder(this.level + 1)\n  }\n\n  /**\n   * Get the current iteration position (1-based).\n   *\n   * @example\n   * Loop.Index()  // Returns 1, 2, 3, etc.\n   */\n  Index(): ReferenceBuilder {\n    return ReferenceBuilder.create(['@loop', this.level.toString(), 'index'])\n  }\n\n  /**\n   * Get the current iteration index (0-based).\n   *\n   * @example\n   * Loop.Index0()  // Returns 0, 1, 2, etc.\n   */\n  Index0(): ReferenceBuilder {\n    return ReferenceBuilder.create(['@loop', this.level.toString(), 'index0'])\n  }\n\n  /**\n   * Get the reverse iteration position (1-based).\n   *\n   * @example\n   * Loop.RevIndex()  // Returns length, length - 1, etc.\n   */\n  RevIndex(): ReferenceBuilder {\n    return ReferenceBuilder.create(['@loop', this.level.toString(), 'revindex'])\n  }\n\n  /**\n   * Get the reverse iteration index (0-based).\n   *\n   * @example\n   * Loop.RevIndex0()  // Returns length - 1, length - 2, etc.\n   */\n  RevIndex0(): ReferenceBuilder {\n    return ReferenceBuilder.create(['@loop', this.level.toString(), 'revindex0'])\n  }\n\n  /**\n   * Check whether the current item is the first item in the iteration.\n   *\n   * @example\n   * Loop.First()  // true for the first item\n   */\n  First(): ReferenceBuilder {\n    return ReferenceBuilder.create(['@loop', this.level.toString(), 'first'])\n  }\n\n  /**\n   * Check whether the current item is the last item in the iteration.\n   *\n   * @example\n   * Loop.Last()  // true for the last item\n   */\n  Last(): ReferenceBuilder {\n    return ReferenceBuilder.create(['@loop', this.level.toString(), 'last'])\n  }\n\n  /**\n   * Get the number of items in the iteration.\n   *\n   * @example\n   * Loop.Length()  // Returns the total item count\n   */\n  Length(): ReferenceBuilder {\n    return ReferenceBuilder.create(['@loop', this.level.toString(), 'length'])\n  }\n}\n","import { isFieldBlockDefinition } from '../../components/typeguards'\nimport { ReferenceBuilder } from './ReferenceBuilder'\nimport { ScopedReferenceBuilder } from './ScopedReferenceBuilder'\nimport { LoopReferenceBuilder } from './LoopReferenceBuilder'\nimport { ChainableLoopRef, ChainableRef, ChainableScopedRef } from './types'\nimport { splitKey } from './utils/splitKey'\nimport { captureCallsite, stampCallsite } from './utils/captureCallsite'\nimport { FieldBlockDefinition, ResolvableString } from '../../components/types/structures.type'\n\n/**\n * References POST body data from form submission.\n */\nexport function Post(key: string): ChainableRef {\n  const ref = ReferenceBuilder.create(['post', ...splitKey(key)])\n  stampCallsite(ref, captureCallsite(Post))\n  return ref\n}\n\n/**\n * References URL parameters (e.g., /users/:id).\n */\nexport function Params(key: string): ChainableRef {\n  const ref = ReferenceBuilder.create(['params', ...splitKey(key)])\n  stampCallsite(ref, captureCallsite(Params))\n  return ref\n}\n\n/**\n * References query string parameters (e.g., ?search=test).\n */\nexport function Query(key: string): ChainableRef {\n  const ref = ReferenceBuilder.create(['query', ...splitKey(key)])\n  stampCallsite(ref, captureCallsite(Query))\n  return ref\n}\n\n/**\n * References request metadata from the current request context.\n */\nexport const Request = {\n  Url(): ChainableRef {\n    const ref = ReferenceBuilder.create(['request', 'url'])\n    stampCallsite(ref, captureCallsite(Request.Url))\n    return ref\n  },\n\n  Path(): ChainableRef {\n    const ref = ReferenceBuilder.create(['request', 'path'])\n    stampCallsite(ref, captureCallsite(Request.Path))\n    return ref\n  },\n\n  Method(): ChainableRef {\n    const ref = ReferenceBuilder.create(['request', 'method'])\n    stampCallsite(ref, captureCallsite(Request.Method))\n    return ref\n  },\n\n  Headers(name: string): ChainableRef {\n    const ref = ReferenceBuilder.create(['request', 'headers', name])\n    stampCallsite(ref, captureCallsite(Request.Headers))\n    return ref\n  },\n\n  Cookies(name: string): ChainableRef {\n    const ref = ReferenceBuilder.create(['request', 'cookies', name])\n    stampCallsite(ref, captureCallsite(Request.Cookies))\n    return ref\n  },\n\n  State(key: string): ChainableRef {\n    const ref = ReferenceBuilder.create(['request', 'state', ...splitKey(key)])\n    stampCallsite(ref, captureCallsite(Request.State))\n    return ref\n  },\n}\n\n/**\n * References data defined for the step.\n */\nexport function Data(key: string): ChainableRef {\n  const ref = ReferenceBuilder.create(['data', ...splitKey(key)])\n  stampCallsite(ref, captureCallsite(Data))\n  return ref\n}\n\n/**\n * References server-side session data from the current request context.\n */\nexport function Session(key: string): ChainableRef {\n  const ref = ReferenceBuilder.create(['session', ...splitKey(key)])\n  stampCallsite(ref, captureCallsite(Session))\n  return ref\n}\n\n/**\n * References an answer using its target field or a string code.\n *\n * @example\n * Answer('email')  // Reference by code string\n * Answer(emailField)  // Reference by field definition\n * Answer('user.address.postcode')  // Nested path\n */\nexport function Answer(target: FieldBlockDefinition | ResolvableString): ChainableRef {\n  const callsite = captureCallsite(Answer)\n\n  const create = (ref: ChainableRef): ChainableRef => {\n    stampCallsite(ref, callsite)\n    return ref\n  }\n\n  // If it's a field block definition, use its code property\n  if (isFieldBlockDefinition(target)) {\n    const { code } = target\n\n    // String code - split dot notation\n    if (typeof code === 'string') {\n      return create(ReferenceBuilder.create(['answers', ...splitKey(code)]))\n    }\n\n    // Dynamic code (expression) - pass through\n    return create(ReferenceBuilder.create(['answers', code as any]))\n  }\n\n  // String target - split dot notation\n  if (typeof target === 'string') {\n    return create(ReferenceBuilder.create(['answers', ...splitKey(target)]))\n  }\n\n  // Otherwise, use the target directly (expression types like Format)\n  return create(ReferenceBuilder.create(['answers', target as any]))\n}\n\n/**\n * References the current collection item when inside a collection scope.\n *\n * @example\n * Item().path('name')  // Access item.name\n * Item().value()  // Access the whole item\n * Item().parent.path('groupId')  // Access parent item's property\n */\nexport function Item(): ChainableScopedRef {\n  const ref = ScopedReferenceBuilder.create(0)\n  stampCallsite(ref, captureCallsite(Item))\n  return ref\n}\n\nconst createLoop = (): ChainableLoopRef => {\n  return LoopReferenceBuilder.create(0)\n}\n\n/**\n * References metadata for the current collection loop.\n *\n * @example\n * Loop.Index()  // 1-based iteration position\n * Loop.Index0()  // 0-based iteration index\n * Loop.Parent.Index()  // Parent loop position in nested iterations\n */\nexport const Loop: ChainableLoopRef = createLoop()\n\n/**\n * References the block/field it's in scope of.\n *\n * @example\n * Self().match(Condition.IsRequired())\n * Self().not.match(Condition.String.IsEmpty())\n * Self().pipe(Transformer.String.Trim).match(Condition.IsRequired())\n */\nexport function Self(): ChainableRef {\n  const ref = ReferenceBuilder.create(['answers', '@self'])\n  stampCallsite(ref, captureCallsite(Self))\n  return ref\n}\n","const FRAME_PATTERN = /^\\s+at /\n\nconst MAX_CHAIN_LENGTH = 3\n\nexport const isInternalFrame = (frame: string): boolean =>\n  frame.includes('node:') ||\n  frame.includes('node_modules') ||\n  frame.includes('forge-core/src') ||\n  frame.includes('forge-core/dist') ||\n  frame.includes('forge:compiled/') ||\n  frame.includes('(<anonymous>)')\n\n// Bundler module-wiring helpers (esbuild's __init/__require, webpack's require) —\n// shared by every definition in a module, so they never distinguish one.\nconst BUNDLER_HELPER_PATTERN = /^(?:__init|__require|__commonJS|__esm|__toESM|__webpack_require__) /\n\n/**\n * Formats a captured callsite into the chain of author-facing \"defined at\"\n * frames, innermost first. Frames inside forge-core, node internals, and\n * node_modules are skipped because registry handles are often invoked by\n * forge-internal callers. The chain keeps walking past frames in the capture\n * site's file (wrapper DSL utilities produce several), stops once it has the\n * first frame from a different file, and caps at three entries — enough to\n * read past a wrapper layer to the author's own file without printing the\n * whole capture. Reading `.stack` here triggers V8's lazy trace formatting,\n * so call this only at display time.\n */\nexport const formatCallsiteChain = (callsite: { readonly stack?: string } | undefined): string[] => {\n  const stack = callsite?.stack\n  if (!stack) {\n    return []\n  }\n\n  const frames = extractFrames(stack)\n\n  if (frames.length === 0) {\n    return []\n  }\n\n  const chainFrames = selectAuthorChainFrames(frames)\n\n  if (chainFrames.length === 0) {\n    return [frames[0]]\n  }\n\n  return chainFrames.map(collapseModuleNamedFrame)\n}\n\nconst extractFrames = (stack: string): string[] =>\n  stack\n    .split('\\n')\n    .filter(line => FRAME_PATTERN.test(line))\n    .map(line => line.replace(FRAME_PATTERN, ''))\n\n/**\n * The author-facing chain frames, innermost first: walks past frames in the\n * capture site's file, stops after the first frame from a different file,\n * caps at `MAX_CHAIN_LENGTH`.\n */\nconst selectAuthorChainFrames = (frames: string[]): string[] => {\n  const authorFrames = frames.filter(frame => !isInternalFrame(frame) && !BUNDLER_HELPER_PATTERN.test(frame))\n\n  if (authorFrames.length === 0) {\n    return []\n  }\n\n  const captureSiteFile = frameFile(authorFrames[0])\n  const chain: string[] = []\n\n  authorFrames.some(frame => {\n    chain.push(frame)\n\n    return chain.length >= MAX_CHAIN_LENGTH || frameFile(frame) !== captureSiteFile\n  })\n\n  return chain\n}\n\n// V8 names top-level module frames by module id — `server/forms/index.ts\n// (/app/server/forms/index.ts:40:40)` — so the name restates the path. Collapse\n// those to the bare location, matching the anonymous-frame grammar.\nconst collapseModuleNamedFrame = (frame: string): string => {\n  const match = /^(.+) \\((.+):(\\d+:\\d+)\\)$/.exec(frame)\n\n  if (match === null) {\n    return frame\n  }\n\n  const [, name, file, position] = match\n\n  return file.endsWith(name) ? `${file}:${position}` : frame\n}\n\n/**\n * Formats a captured callsite into the single innermost author-facing frame —\n * the first entry of `formatCallsiteChain`.\n */\nexport const formatCallsite = (callsite: { readonly stack?: string } | undefined): string | undefined => {\n  const chain = formatCallsiteChain(callsite)\n\n  return chain.length > 0 ? chain[0] : undefined\n}\n\nexport interface CallsitePosition {\n  readonly file: string\n  readonly line: number\n  readonly column: number\n}\n\n/**\n * Resolves a captured callsite to the structured positions (1-based line and\n * column) of the author chain frames `formatCallsiteChain` renders, innermost\n * first. Every chain frame is a legitimate breakpoint home: a node built\n * inside a shared wiring helper is \"defined at\" both the helper's line and\n * the line that called the helper. Unlike the display formatters there is no\n * fallback to an internal frame when every frame is filtered — a source-map\n * entry pointing into forge internals is worse than none. Reading `.stack`\n * triggers V8's lazy trace formatting, so call this at codegen time only.\n */\nexport const resolveCallsitePositionChain = (callsite: { readonly stack?: string } | undefined): CallsitePosition[] => {\n  const stack = callsite?.stack\n  if (!stack) {\n    return []\n  }\n\n  return selectAuthorChainFrames(extractFrames(stack))\n    .map(parseFramePosition)\n    .filter(position => position !== undefined)\n}\n\nconst parseFramePosition = (frame: string): CallsitePosition | undefined => {\n  const location = /\\((.+)\\)$/.exec(frame)?.[1] ?? frame\n  const match = /^(.+):(\\d+):(\\d+)$/.exec(location)\n\n  if (match === null) {\n    return undefined\n  }\n\n  return { file: match[1], line: Number(match[2]), column: Number(match[3]) }\n}\n\nconst frameFile = (frame: string): string => {\n  const location = /\\((.+)\\)$/.exec(frame)?.[1] ?? frame\n\n  return location.replace(/:\\d+:\\d+$/, '')\n}\n","import { isInternalFrame } from '../../shared/diagnostics/formatCallsite'\n\nexport interface RuntimeDiagnosticFields {\n  readonly phase: string\n  readonly formattedPath?: string\n  readonly functionName?: string\n  readonly functionType?: string\n}\n\nconst FRAME_PATTERN = /^\\s+at /\n\n/**\n * Renders the author-facing sections of a forge error's `stack`: the\n * diagnostics block and the folded frame list. Indentation is deliberate —\n * the block header sits at frame depth (4 spaces) with fields nested at 6, so\n * Node's `[cause]:` (fixed at 2 spaces in `util.inspect`) visibly outdents as\n * a sibling of the whole error instead of reading as another diagnostics\n * field.\n */\nexport default class DiagnosticErrorFormatter {\n  static formatRuntimeDiagnostics(diagnostics: RuntimeDiagnosticFields): string {\n    const formattedFields = [\n      { label: 'Phase', value: diagnostics.phase },\n      { label: 'Path', value: diagnostics.formattedPath },\n      { label: 'Function', value: diagnostics.functionName },\n      { label: 'Type', value: diagnostics.functionType },\n    ]\n      .filter(field => field.value !== undefined)\n      .map(field => `      ${field.label}: ${field.value}`)\n\n    return ['    Forge diagnostics:', ...formattedFields].join('\\n')\n  }\n\n  static extractStackFrames(stack: string | undefined): string[] {\n    if (stack === undefined) {\n      return []\n    }\n\n    return stack\n      .split('\\n')\n      .filter(line => FRAME_PATTERN.test(line))\n      .map(line => line.replace(FRAME_PATTERN, ''))\n  }\n\n  /**\n   * Collapses each consecutive run of forge-internal frames into one summary\n   * line naming the run's first and last frame. Author frames always render.\n   * The summary line deliberately does not match the `at ...` frame grammar so\n   * error trackers never ingest it as an execution frame.\n   */\n  static foldStackFrames(frames: string[]): string[] {\n    const folded: string[] = []\n    let internalRun: string[] = []\n\n    const flushRun = (): void => {\n      if (internalRun.length === 0) {\n        return\n      }\n\n      folded.push(DiagnosticErrorFormatter.formatFoldedRun(internalRun))\n      internalRun = []\n    }\n\n    frames.forEach(frame => {\n      if (isInternalFrame(frame)) {\n        internalRun.push(frame)\n\n        return\n      }\n\n      flushRun()\n      folded.push(`    at ${frame}`)\n    })\n    flushRun()\n\n    return folded\n  }\n\n  private static formatFoldedRun(run: string[]): string {\n    if (run.length === 1) {\n      return `    ... 1 forge frame (${frameName(run[0])}) — FORGE_FULL_STACK=1 to expand`\n    }\n\n    const summary = `${frameName(run[0])} → ${frameName(run[run.length - 1])}`\n\n    return `    ... ${run.length} forge frames (${summary}) — FORGE_FULL_STACK=1 to expand`\n  }\n}\n\nconst frameName = (frame: string): string => {\n  const parenIndex = frame.indexOf(' (')\n\n  return parenIndex === -1 ? frame : frame.slice(0, parenIndex)\n}\n","import DiagnosticErrorFormatter from './DiagnosticErrorFormatter'\n\nexport interface ForgeErrorDiagnostics {\n  /** Human-readable path through the journey DSL */\n  readonly formattedPath?: string\n  /** Author callsite captured where the offending node was defined */\n  readonly callsite?: { readonly stack?: string }\n}\n\n/**\n * Base class for every error the engine throws. Owns the diagnostic fields\n * shared across the family (`formattedPath`, `callsite`), stamps `name` from\n * the concrete class, and owns `stack` rendering: raw frames are captured once\n * at construction (with constructor frames trimmed) and the display string —\n * folded forge-internal frames, defined-at frames, diagnostics block — is\n * assembled lazily on first read, so errors that get caught and handled never\n * pay for formatting. The unfolded original stays reachable via the\n * non-enumerable `rawStack`, and `FORGE_FULL_STACK=1` renders every frame.\n */\nexport default abstract class ForgeBaseError extends Error {\n  readonly formattedPath?: string\n\n  readonly callsite?: { readonly stack?: string }\n\n  declare readonly rawStack: string | undefined\n\n  private readonly rawStackHolder: { stack?: string }\n\n  protected constructor(message: string, diagnostics?: ForgeErrorDiagnostics) {\n    super(message)\n    this.name = new.target.name\n    this.formattedPath = diagnostics?.formattedPath\n    this.callsite = diagnostics?.callsite\n    const canCapture = typeof Error.captureStackTrace === 'function'\n\n    this.rawStackHolder = canCapture ? {} : { stack: this.stack }\n\n    if (canCapture) {\n      Error.captureStackTrace(this.rawStackHolder, new.target)\n    }\n\n    Object.defineProperty(this, 'stack', {\n      get: () => this.renderStack(),\n      set: (value: string | undefined) => {\n        Object.defineProperty(this, 'stack', { value, writable: true, configurable: true, enumerable: false })\n      },\n      configurable: true,\n      enumerable: false,\n    })\n    Object.defineProperty(this, 'rawStack', {\n      get: () => this.renderRawStack(),\n      configurable: true,\n      enumerable: false,\n    })\n  }\n\n  /** ForgeInternalError opts out: when the engine itself is broken, the internals are the story. */\n  protected get foldsInternalStackFrames(): boolean {\n    return true\n  }\n\n  /** The stack string whose frames form the rendered body — subclasses may substitute a cause's stack. */\n  protected stackBodySource(): string | undefined {\n    return this.rawStackHolder.stack\n  }\n\n  /** Definition-site frames rendered after the execution frames as `at [defined] ...` lines. */\n  protected definedAtStackFrames(): string[] {\n    return []\n  }\n\n  /** The `Forge diagnostics:` block appended after the frames, if the subclass carries one. */\n  protected formatDiagnosticsBlock(): string | undefined {\n    return undefined\n  }\n\n  private renderStack(): string {\n    const frames = DiagnosticErrorFormatter.extractStackFrames(this.stackBodySource())\n    const foldDisabled = process.env.FORGE_FULL_STACK === '1' || !this.foldsInternalStackFrames\n    const frameLines = foldDisabled\n      ? frames.map(frame => `    at ${frame}`)\n      : DiagnosticErrorFormatter.foldStackFrames(frames)\n    const definedLines = this.definedAtStackFrames().map(frame => `    at [defined] ${frame}`)\n    const diagnosticsBlock = this.formatDiagnosticsBlock()\n\n    const sections = [\n      [`${this.name}: ${this.message}`, ...frameLines].join('\\n'),\n      definedLines.length > 0 ? definedLines.join('\\n') : undefined,\n      diagnosticsBlock,\n    ].filter(section => section !== undefined)\n\n    return sections.join('\\n\\n')\n  }\n\n  private renderRawStack(): string | undefined {\n    const rawFrames = DiagnosticErrorFormatter.extractStackFrames(this.rawStackHolder.stack)\n\n    return [`${this.name}: ${this.message}`, ...rawFrames.map(frame => `    at ${frame}`)].join('\\n')\n  }\n}\n","import ForgeBaseError from './ForgeBaseError'\n\ninterface ForgeAuthoringErrorOptions {\n  /** Human-readable error message */\n  message: string\n  /** Human-readable path through the journey DSL */\n  formattedPath?: string\n  /** Author callsite captured where the offending definition was written */\n  callsite?: { readonly stack?: string }\n}\n\n/**\n * The authoring API was misused in a way the schema never gets to see -\n * thrown while builders and DSL helpers are still assembling the definition.\n */\nexport default class ForgeAuthoringError extends ForgeBaseError {\n  constructor(options: ForgeAuthoringErrorOptions) {\n    super(options.message, options)\n  }\n}\n","import {\n  BlockType,\n  ExpressionType,\n  FunctionType,\n  IteratorType,\n  PredicateType,\n  StructureType,\n} from '../../authoring/types/enums'\nimport type { DSLPathSegment } from './sourceLocation.type'\n\ntype DSLRecord = Record<string, unknown>\n\nconst FUNCTION_TYPE_VALUES: ReadonlySet<string> = new Set(Object.values(FunctionType))\n\ninterface PathFormatState {\n  readonly current: unknown\n  readonly index: number\n  readonly segments: readonly string[]\n}\n\nexport default class DSLPathFormatter {\n  format(root: unknown, path: readonly DSLPathSegment[]): string {\n    const rootSegment = this.formatJourneySegment(root) ?? 'root'\n    const segments = this.formatPathSegments(path, { current: root, index: 0, segments: [rootSegment] })\n\n    return segments.join(' > ')\n  }\n\n  private formatPathSegments(path: readonly DSLPathSegment[], state: PathFormatState): readonly string[] {\n    if (state.index >= path.length) {\n      return state.segments\n    }\n\n    const pathPart = path[state.index]\n\n    if (this.isArrayIndex(pathPart)) {\n      const nextValue = Array.isArray(state.current) ? state.current[pathPart] : undefined\n      const nextSegments = [...state.segments, `[${pathPart}]`]\n\n      return this.formatPathSegments(path, { current: nextValue, index: state.index + 1, segments: nextSegments })\n    }\n\n    const nextPathPart = path[state.index + 1]\n    const propertyValue = this.getNextValue(state.current, pathPart)\n\n    if (this.isArrayIndex(nextPathPart)) {\n      const arrayValue = Array.isArray(propertyValue) ? propertyValue[nextPathPart] : undefined\n      const nextSegments = [...state.segments, this.formatArraySegment(pathPart, nextPathPart, arrayValue)]\n\n      return this.formatPathSegments(path, { current: arrayValue, index: state.index + 2, segments: nextSegments })\n    }\n\n    const propertySegments = this.formatPropertySegments(pathPart, state.current, propertyValue)\n    const nextSegments = [...state.segments, ...propertySegments]\n\n    return this.formatPathSegments(path, { current: propertyValue, index: state.index + 1, segments: nextSegments })\n  }\n\n  private formatArraySegment(key: string, index: number, value: unknown): string {\n    if (key === 'steps') {\n      return this.formatStepSegment(value) ?? `${key}[${index}]`\n    }\n\n    if (key === 'children') {\n      return this.formatJourneySegment(value) ?? `${key}[${index}]`\n    }\n\n    const base = `${key}[${index}]`\n    const context = key === 'blocks' ? this.formatBlockContext(value) : this.formatFunctionContext(value)\n\n    return context ? `${base} (${context})` : base\n  }\n\n  private formatPropertySegments(key: string, current: unknown, value: unknown): readonly string[] {\n    if (key === 'condition' && this.isPredicateTest(current) && this.formatFunctionContext(value)) {\n      return []\n    }\n\n    if (this.isRecord(current) && current.type === ExpressionType.ITERATE && key === 'input') {\n      return ['source']\n    }\n\n    if (this.isRecord(current) && current.type === ExpressionType.ITERATE && key === 'iterator') {\n      return ['source', 'iterator']\n    }\n\n    if (this.isRecord(current) && current.type === IteratorType.MAP && key === 'yield') {\n      return ['template']\n    }\n\n    return [key]\n  }\n\n  private formatJourneySegment(value: unknown): string | undefined {\n    const code = this.getStringProperty(value, 'code')\n    const path = this.getStringProperty(value, 'path')\n    const title = this.getStringProperty(value, 'title')\n\n    return code ?? (path ? this.trimPath(path) : undefined) ?? title\n  }\n\n  private formatStepSegment(value: unknown): string | undefined {\n    const code = this.getStringProperty(value, 'code')\n    const path = this.getStringProperty(value, 'path')\n    const title = this.getStringProperty(value, 'title')\n\n    return code ?? (path ? this.trimPath(path) : undefined) ?? title\n  }\n\n  private formatFunctionContext(value: unknown): string | undefined {\n    if (!this.isRecord(value)) {\n      return undefined\n    }\n\n    const type = this.getStringProperty(value, 'type')\n    const name = this.getStringProperty(value, 'name')\n\n    if (!type || !name || !FUNCTION_TYPE_VALUES.has(type)) {\n      return undefined\n    }\n\n    return `${this.formatFunctionType(type)} - ${name}`\n  }\n\n  private isPredicateTest(value: unknown): boolean {\n    return this.isRecord(value) && value.type === PredicateType.TEST\n  }\n\n  private formatBlockContext(value: unknown): string | undefined {\n    if (!this.isRecord(value) || value.type !== StructureType.BLOCK) {\n      return undefined\n    }\n\n    const variant = this.getStringProperty(value, 'variant')\n\n    if (!variant) {\n      return undefined\n    }\n\n    const code = value.blockType === BlockType.FIELD ? this.getStringProperty(value, 'code') : undefined\n\n    return code ? `${variant} - ${code}` : variant\n  }\n\n  private formatFunctionType(functionType: string): string {\n    const suffix = functionType.split('.').at(-1)\n\n    return suffix?.toLowerCase() ?? functionType\n  }\n\n  private getNextValue(current: unknown, key: string): unknown {\n    if (!this.isRecord(current)) {\n      return undefined\n    }\n\n    return current[key]\n  }\n\n  private getStringProperty(value: unknown, property: string): string | undefined {\n    if (!this.isRecord(value)) {\n      return undefined\n    }\n\n    const propertyValue = value[property]\n\n    return typeof propertyValue === 'string' && propertyValue.trim() !== '' ? propertyValue : undefined\n  }\n\n  private trimPath(path: string): string {\n    const trimmed = path.replace(/^\\/+|\\/+$/g, '')\n\n    return trimmed === '' ? path : trimmed\n  }\n\n  private isRecord(value: unknown): value is DSLRecord {\n    return typeof value === 'object' && value !== undefined && value !== null && !Array.isArray(value)\n  }\n\n  private isArrayIndex(value: unknown): value is number {\n    return typeof value === 'number'\n  }\n}\n","import DSLPathFormatter from './DSLPathFormatter'\nimport type { DSLPathSegment, DSLSourceLocation } from './sourceLocation.type'\n\nconst isValidCallsite = (value: unknown): value is { readonly stack?: string } =>\n  typeof value === 'object' &&\n  value !== null &&\n  (!('stack' in value) || typeof (value as { stack?: unknown }).stack === 'string')\n\nexport default class DSLSourceLocator {\n  constructor(\n    private readonly root: unknown,\n    private readonly pathFormatter = new DSLPathFormatter(),\n  ) {}\n\n  fromPath(path: readonly DSLPathSegment[]): DSLSourceLocation {\n    return {\n      path,\n      formattedPath: this.pathFormatter.format(this.root, path),\n    }\n  }\n\n  /**\n   * Resolves the captured author callsite for the node at the given path by\n   * reading the nearest `__callsite` stamp, walking from the node itself up\n   * through its ancestors to the root.\n   */\n  callsiteFromPath(path: readonly DSLPathSegment[]): { readonly stack?: string } | undefined {\n    const objects: object[] = []\n    let current: unknown = this.root\n\n    for (let i = 0; i < path.length && current !== null && typeof current === 'object'; i += 1) {\n      objects.push(current)\n      current = (current as Record<DSLPathSegment, unknown>)[path[i]]\n    }\n\n    if (current !== null && typeof current === 'object') {\n      objects.push(current)\n    }\n\n    for (let i = objects.length - 1; i >= 0; i -= 1) {\n      const callsite = Object.getOwnPropertyDescriptor(objects[i], '__callsite')?.value\n\n      if (isValidCallsite(callsite)) {\n        return callsite\n      }\n    }\n\n    return undefined\n  }\n}\n","import ForgeAuthoringError from '../../../engine/errors/ForgeAuthoringError'\nimport DSLSourceLocator from '../../../shared/diagnostics/DSLSourceLocator'\nimport type { DSLPathSegment } from '../../../shared/diagnostics/sourceLocation.type'\nimport { stampCallsite } from './captureCallsite'\n\nconst carryCallsite = (from: object, to: unknown): void => {\n  const callsite = Object.getOwnPropertyDescriptor(from, '__callsite')?.value\n\n  if (callsite) {\n    stampCallsite(to, callsite)\n  }\n}\n\ninterface Buildable {\n  build(): unknown\n}\n\nconst isBuildable = (value: unknown): value is Buildable => {\n  return value !== null &&\n    typeof value === 'object' &&\n    (value as any).nodeKind === 'forge-builder' &&\n    'build' in value &&\n    typeof (value as any).build === 'function'\n}\n\nconst describePath = (path: readonly DSLPathSegment[]): string => (path.length === 0 ? '<root>' : path.join('.'))\n\nconst finalise = (value: unknown, path: DSLPathSegment[], ancestors: Set<object>): unknown => {\n  if (value === null || typeof value !== 'object') {\n    return value\n  }\n\n  if (ancestors.has(value)) {\n    throw new ForgeAuthoringError({\n      message:\n        `Circular reference detected in form configuration at \"${describePath(path)}\". ` +\n        'Configuration objects must form a tree; an object cannot contain itself.',\n    })\n  }\n\n  ancestors.add(value)\n  try {\n    if (Array.isArray(value)) {\n      return value.map((item, index) => finalise(item, [...path, index], ancestors))\n    }\n\n    if (isBuildable(value)) {\n      // Recurse into the built output at the same path so shared builder\n      // instances produce a fresh copy per tree position.\n      const built = value.build()\n      carryCallsite(value, built)\n      return finalise(built, path, ancestors)\n    }\n\n    const prototype = Object.getPrototypeOf(value)\n\n    if (prototype !== Object.prototype && prototype !== null) {\n      return value\n    }\n\n    const result: Record<string, unknown> = {}\n    Object.entries(value).forEach(([key, entry]) => {\n      result[key] = finalise(entry, [...path, key], ancestors)\n    })\n    carryCallsite(value, result)\n    return result\n  } finally {\n    ancestors.delete(value)\n  }\n}\n\nconst stampSource = (node: unknown, path: DSLPathSegment[], locator: DSLSourceLocator): void => {\n  if (node === null || typeof node !== 'object') {\n    return\n  }\n\n  if (Array.isArray(node)) {\n    node.forEach((item, index) => stampSource(item, [...path, index], locator))\n    return\n  }\n\n  // configurable + writable so an outer finaliseBuilders() walk can re-stamp\n  // nodes that were already stamped by an earlier, narrower walk.\n  Object.defineProperty(node, '__source', {\n    value: locator.fromPath(path),\n    enumerable: false,\n    configurable: true,\n    writable: true,\n  })\n\n  Object.entries(node).forEach(([key, entry]) => {\n    stampSource(entry, [...path, key], locator)\n  })\n}\n\n/**\n * Convert form configuration from builders into JSON.\n * Recursively processes objects and arrays, calling build() on any Buildable instances.\n *\n * Every object node in the output is stamped with a non-enumerable `__source`\n * ({ path, formattedPath }) describing its position in the finalised tree.\n * Stamping happens in a second pass over the fully finalised tree so that\n * formatted paths resolve context (step codes, block variants) against final\n * values rather than un-built builders.\n *\n * Shared builder instances are finalised once per tree position: each position\n * gets its own built copy so per-position `__source` stamps are possible.\n * Circular references in the input throw.\n *\n * @param input - Objects, arrays that contain builders\n */\nexport const finaliseBuilders = <T>(input: T): unknown => {\n  const result = finalise(input, [], new Set())\n  stampSource(result, [], new DSLSourceLocator(result))\n  return result\n}\n","import { finaliseBuilders } from './utils/finaliseBuilders'\nimport { captureCallsite, stampCallsite } from './utils/captureCallsite'\nimport { BlockDefinition, FieldBlockDefinition } from '../../components/types/structures.type'\nimport { JourneyDefinition, StepDefinition } from '../types/structures.type'\nimport { ForgePackage, RegisteredForgePackage } from '../types/package.type'\nimport { BlockType, StructureType } from '../types/enums'\n\n/**\n * Creates a presentational (non-field) block for a step.\n * Use for headings, paragraphs, inset text, and other non-interactive content.\n */\nexport function block<D extends BlockDefinition>(definition: Omit<D, 'type' | 'blockType'>): D {\n  const result = finaliseBuilders({\n    ...definition,\n    type: StructureType.BLOCK,\n    blockType: BlockType.BASIC,\n  }) as D\n  stampCallsite(result, captureCallsite(block))\n  return result\n}\n\n/**\n * Creates a field block that captures user input.\n * Fields have a `code` for storing answers and support `validWhen`, `dependentWhen`,\n * `defaultValue`, and `formatters`.\n */\nexport function field<D extends FieldBlockDefinition>(definition: Omit<D, 'type' | 'blockType'>): D {\n  const result = finaliseBuilders({\n    ...definition,\n    type: StructureType.BLOCK,\n    blockType: BlockType.FIELD,\n  }) as D\n  stampCallsite(result, captureCallsite(field))\n  return result\n}\n\n/**\n * Creates a step (page) within a journey.\n * Steps contain blocks and define lifecycle hooks for access, submission, and actions.\n */\nexport function step<D extends StepDefinition>(definition: Omit<D, 'type'>): D {\n  const result = finaliseBuilders({\n    ...definition,\n    type: StructureType.STEP,\n  }) as D\n  stampCallsite(result, captureCallsite(step))\n  return result\n}\n\n/**\n * Creates a journey definition - a complete form flow containing steps.\n */\nexport function journey<D extends JourneyDefinition>(definition: Omit<D, 'type'>): D {\n  const result = finaliseBuilders({\n    ...definition,\n    type: StructureType.JOURNEY,\n  }) as D\n  stampCallsite(result, captureCallsite(journey))\n  return result\n}\n\n/**\n * Create a forge package that bundles a journey with its custom functions and components.\n *\n * This is the mandatory gate into Forge: it parses string journeys, finalises\n * any builders in the journey tree (stamping source locations for diagnostics),\n * and brands the result so `Forge.registerPackage()` accepts it.\n *\n * @param pkg - The forge package configuration\n * @returns The package with a finalised journey, branded for registration\n *\n * @example\n * ```typescript\n * // Package with custom functions (deps injected via registerPackage)\n * export default createForgePackage<MyDeps>({\n *   journey: myJourney,\n *   functions: {\n *     ...myEffectsImplementations,\n *     ...myTransformersImplementations,\n *   },\n * })\n *\n * // Journey only (no custom functions)\n * export default createForgePackage({\n *   journey: simpleJourney,\n * })\n * ```\n */\nexport function createForgePackage<TDeps = Record<string, never>>(\n  pkg: ForgePackage<TDeps>,\n): RegisteredForgePackage<TDeps> {\n  const parsed: unknown = typeof pkg.journey === 'string' ? JSON.parse(pkg.journey) : pkg.journey\n\n  const result: RegisteredForgePackage<TDeps> = {\n    ...pkg,\n    journey: finaliseBuilders(parsed) as JourneyDefinition,\n    forgePackage: true,\n  }\n  stampCallsite(result, captureCallsite(createForgePackage))\n  return result\n}\n","import ForgeBaseError from './ForgeBaseError'\n\ninterface ForgeRegistryDuplicateErrorOptions {\n  /** Type of registry (function or component) */\n  registryType: 'function' | 'component'\n  /** Name or variant of the item being registered */\n  itemName: string\n  /** Optional additional message */\n  message?: string\n}\n\nexport default class ForgeRegistryDuplicateError extends ForgeBaseError {\n  readonly registryType: 'function' | 'component'\n\n  readonly itemName: string\n\n  constructor(options: ForgeRegistryDuplicateErrorOptions) {\n    super(options.message ?? `Duplicate ${options.registryType} registration: \"${options.itemName}\"`)\n    this.registryType = options.registryType\n    this.itemName = options.itemName\n  }\n}\n","import { FunctionType, PredicateType, ExpressionType } from '../types/enums'\nimport {\n  ConditionFunctionExpr,\n  GeneratorFunctionExpr,\n  PipelineExpr,\n  NullishExpr,\n  PredicateTestExpr,\n  TransformerFunctionExpr,\n  ResolvableValue,\n} from '../types/expressions.type'\nimport { ExpressionBuilder } from './ExpressionBuilder'\nimport { captureCallsite, stampCallsite } from './utils/captureCallsite'\nimport { ChainableGenerator, ChainableNegation } from './types'\n\n/**\n * Immutable builder for creating generator function expressions.\n *\n * Generators produce values without requiring input, unlike conditions and transformers.\n * They can be used standalone, chained with transformers via pipelines, or tested with conditions.\n *\n * @example\n * // Standalone generator\n * Generator.Date.Now()\n *\n * @example\n * // Generator with pipeline\n * Generator.Date.Now().pipe(Transformer.Date.AddDays(7))\n *\n * @example\n * // Generator with condition\n * Generator.Date.Now().match(Condition.Date.IsFutureDate())\n *\n * @template A - The argument types for the generator function\n *\n * @internal Exposed to authors via the ChainableGenerator interface.\n */\nexport class GeneratorBuilder<A extends ResolvableValue[]> implements ChainableGenerator {\n  readonly nodeKind = 'forge-builder' as const\n\n  // The marker must exist on the class type so builders pass the weak-type\n  // check on Resolvable<T> argument slots; it is type-only and never set.\n  declare readonly __resolves?: any\n\n  private readonly expression: GeneratorFunctionExpr<A>\n\n  private readonly negated: boolean\n\n  private constructor(expr: GeneratorFunctionExpr<A>, negate: boolean = false) {\n    this.expression = expr\n    this.negated = negate\n  }\n\n  /**\n   * Create a new GeneratorBuilder with the given function name and arguments.\n   *\n   * @param name - The name of the generator function (must be registered)\n   * @param args - Arguments to pass to the generator function\n   */\n  static create<A extends ResolvableValue[]>(name: string, args: A): GeneratorBuilder<A> {\n    return new GeneratorBuilder(\n      {\n        type: FunctionType.GENERATOR,\n        name,\n        arguments: args,\n      },\n      false,\n    )\n  }\n\n  /**\n   * Get the underlying generator expression.\n   */\n  get expr(): GeneratorFunctionExpr<A> {\n    return this.expression\n  }\n\n  /**\n   * Build the final generator function expression.\n   * Called automatically by finaliseBuilders().\n   */\n  build(): GeneratorFunctionExpr<A> {\n    return this.expression\n  }\n\n  /**\n   * Transform the generated value through a pipeline of transformers.\n   * Creates a PipelineExpr with this generator as the input.\n   *\n   * @param steps - Transformer functions to apply sequentially\n   * @returns An ExpressionBuilder wrapping the pipeline\n   *\n   * @example\n   * Generator.Date.Now().pipe(\n   *   Transformer.Date.AddDays(7),\n   *   Transformer.Date.Format('YYYY-MM-DD')\n   * )\n   */\n  pipe(...steps: TransformerFunctionExpr[]): ExpressionBuilder<PipelineExpr> {\n    return ExpressionBuilder.pipeline(this.expression, steps)\n  }\n\n  /** Uses the fallback only when the value is null or undefined, like `??`. */\n  nullish(fallback: ResolvableValue | undefined): ExpressionBuilder<NullishExpr> {\n    const expression: NullishExpr = {\n      type: ExpressionType.NULLISH,\n      input: this.expression,\n      ...(fallback !== undefined && { fallback }),\n    }\n    const builder = ExpressionBuilder.from(expression)\n\n    stampCallsite(builder, captureCallsite(this.nullish))\n\n    return builder\n  }\n\n  /**\n   * Test the generated value against a condition.\n   * Terminal operation - returns a plain PredicateTestExpr.\n   *\n   * @example\n   * Generator.Date.Now().match(Condition.Date.IsFutureDate())\n   */\n  match(condition: ConditionFunctionExpr<any>): PredicateTestExpr {\n    const predicate: PredicateTestExpr = {\n      type: PredicateType.TEST,\n      subject: this.expression,\n      negate: this.negated,\n      condition,\n    }\n\n    stampCallsite(predicate, captureCallsite(this.match))\n\n    return predicate\n  }\n\n  /**\n   * Negate the next condition test.\n   * Returns a new builder with toggled negation.\n   *\n   * @example\n   * Generator.Date.Now().not.match(Condition.Date.IsPast())\n   */\n  get not(): ChainableNegation {\n    return new GeneratorBuilder(this.expression, !this.negated)\n  }\n}\n","import { z, type ZodType } from 'zod'\nimport { FunctionType } from '../types/enums'\nimport ForgeAuthoringError from '../../engine/errors/ForgeAuthoringError'\nimport ForgeRegistryDuplicateError from '../../engine/errors/ForgeRegistryDuplicateError'\nimport { GeneratorBuilder } from '../builders/GeneratorBuilder'\nimport { captureCallsite, stampCallsite } from '../builders/utils/captureCallsite'\nimport type { FunctionRegistryObject } from '../types/functions.type'\n\nexport interface RegistrationOptions {\n  inputSchema?: ZodType\n  argumentsSchema?: ZodType\n  outputSchema?: ZodType\n  prepare?: (...args: any[]) => any[]\n}\n\ninterface RegistrationWithFactory<TDeps = any> extends RegistrationOptions {\n  factory: (deps: TDeps) => (...args: any[]) => any\n}\n\ninterface StoredRegistration {\n  name: string\n  inputSchema?: ZodType\n  argumentsSchema?: ZodType\n  outputSchema?: ZodType\n  prepare?: (...args: any[]) => any[]\n  factory: (deps: any) => (...args: any[]) => any\n}\n\nexport const CONDITION_OUTPUT_SCHEMA = z.compile(z.boolean())\n\n// Each rolldown entry point (core, core/authoring) inlines its own copy of this class, so\n// `instanceof` fails when an instance from one bundle reaches a check in another. The\n// Symbol.for brand is process-global, so it survives the duplication.\n//\n// TODO: Probably should delete the brand/symbol machinery once the deprecated\n// implementations-map form of `functions` is removed — at that point the engine only needs\n// Array.isArray before calling .build(), and never needs to identify a registry.\nconst REGISTRY_BRAND = Symbol.for('forge:BaseFunctionRegistry')\n\nexport function isFunctionRegistry<T = any>(value: unknown): value is BaseFunctionRegistry<T> {\n  return typeof value === 'object' && value !== null && (value as Record<symbol, unknown>)[REGISTRY_BRAND] === true\n}\n\nexport abstract class BaseFunctionRegistry<TDeps = Record<string, never>> {\n  readonly [REGISTRY_BRAND] = true\n\n  private readonly registrations = new Map<string, StoredRegistration>()\n\n  private anonymousCounter = 0\n\n  constructor(\n    private readonly functionType: FunctionType,\n    private readonly defaultOutputSchema?: ZodType,\n  ) {}\n\n  protected nextAnonymousName(): string {\n    return `__anon_${this.anonymousCounter++}`\n  }\n\n  protected parseArgs(\n    first: string | RegistrationOptions | ((deps: TDeps) => (...args: any[]) => any),\n    second?: RegistrationOptions | ((deps: TDeps) => (...args: any[]) => any),\n    third?: (deps: TDeps) => (...args: any[]) => any,\n  ): { name: string; options: RegistrationOptions; factory: (deps: TDeps) => (...args: any[]) => any } {\n    if (typeof first === 'function') {\n      return { name: first.name || this.nextAnonymousName(), options: {}, factory: first }\n    }\n\n    if (typeof first !== 'string') {\n      const factory = second as (deps: TDeps) => (...args: any[]) => any\n\n      return { name: factory.name || this.nextAnonymousName(), options: first, factory }\n    }\n\n    if (typeof second === 'function') {\n      return { name: first, options: {}, factory: second }\n    }\n\n    const options = second ?? {}\n\n    return { name: first, options, factory: third ?? this.requireEmbeddedFactory(first, options) }\n  }\n\n  private requireEmbeddedFactory(name: string, options: RegistrationOptions): (deps: TDeps) => (...args: any[]) => any {\n    const { factory } = options as RegistrationWithFactory<TDeps>\n\n    if (!factory) {\n      throw new ForgeAuthoringError({\n        message: `The ${this.functionType} registration \"${name}\" has no factory - pass one positionally or as options.factory`,\n      })\n    }\n\n    return factory\n  }\n\n  protected store(name: string, options: RegistrationOptions, factory: (deps: TDeps) => (...args: any[]) => any): void {\n    if (this.registrations.has(name)) {\n      throw new ForgeRegistryDuplicateError({\n        registryType: 'function',\n        itemName: name,\n        message: `A ${this.functionType} is already registered under the name \"${name}\"`,\n      })\n    }\n\n    const inputSchema = this.compileSchema(options.inputSchema)\n    const argumentsSchema = this.compileSchema(options.argumentsSchema)\n    const outputSchema = this.compileOutputSchema(options.outputSchema)\n\n    this.registrations.set(name, {\n      name,\n      inputSchema,\n      argumentsSchema,\n      outputSchema,\n      prepare: options.prepare,\n      factory,\n    })\n  }\n\n  protected buildExpressionHandle(name: string, prepare?: (...args: any[]) => any[]): (...args: any[]) => any {\n    const type = this.functionType\n\n    if (type === FunctionType.GENERATOR) {\n      const generatorHandle = (...args: any[]) => {\n        const prepared = prepare ? prepare(...args) : args\n        const builder = GeneratorBuilder.create(name, prepared)\n\n        stampCallsite(builder, captureCallsite(generatorHandle))\n        return builder\n      }\n\n      return generatorHandle\n    }\n\n    const expressionHandle = (...args: any[]) => {\n      const prepared = prepare ? prepare(...args) : args\n      const expr = { type, name, arguments: prepared }\n\n      stampCallsite(expr, captureCallsite(expressionHandle))\n      return expr\n    }\n\n    return expressionHandle\n  }\n\n  build(deps?: TDeps): FunctionRegistryObject {\n    const resolvedDeps = (deps ?? {}) as TDeps\n    const registry = {} as FunctionRegistryObject\n\n    this.registrations.forEach((registration, name) => {\n      const evaluate = registration.factory(resolvedDeps)\n\n      registry[name] = {\n        name,\n        evaluate,\n        inputSchema: registration.inputSchema,\n        argumentsSchema: registration.argumentsSchema,\n        outputSchema: registration.outputSchema,\n        functionType: this.functionType,\n      }\n    })\n\n    return registry\n  }\n\n  private compileSchema(schema: ZodType | undefined): ZodType | undefined {\n    if (schema === undefined) {\n      return undefined\n    }\n\n    return z.compile(schema)\n  }\n\n  private compileOutputSchema(schema: ZodType | undefined): ZodType | undefined {\n    if (schema === undefined) {\n      return this.defaultOutputSchema\n    }\n\n    return z.compile(schema)\n  }\n}\n","import type { Resolvable } from '../types/expressions.type'\nimport type { ChainableGenerator } from '../builders/types'\nimport { FunctionType } from '../types/enums'\nimport { BaseFunctionRegistry, type RegistrationOptions } from './BaseFunctionRegistry'\n\nexport default class GeneratorRegistry<TDeps = Record<string, never>> extends BaseFunctionRegistry<TDeps> {\n  constructor() {\n    super(FunctionType.GENERATOR)\n  }\n\n  register<TArgs extends any[]>(\n    name: string,\n    options: RegistrationOptions & { factory: (deps: TDeps) => (...args: TArgs) => any },\n  ): (...args: { [K in keyof TArgs]: Resolvable<TArgs[K]> }) => ChainableGenerator\n\n  register<TArgs extends any[]>(\n    name: string,\n    options: RegistrationOptions,\n    factory: (deps: TDeps) => (...args: TArgs) => any,\n  ): (...args: { [K in keyof TArgs]: Resolvable<TArgs[K]> }) => ChainableGenerator\n\n  register<TArgs extends any[]>(\n    name: string,\n    factory: (deps: TDeps) => (...args: TArgs) => any,\n  ): (...args: { [K in keyof TArgs]: Resolvable<TArgs[K]> }) => ChainableGenerator\n\n  register<TArgs extends any[]>(\n    options: RegistrationOptions,\n    factory: (deps: TDeps) => (...args: TArgs) => any,\n  ): (...args: { [K in keyof TArgs]: Resolvable<TArgs[K]> }) => ChainableGenerator\n\n  register<TArgs extends any[]>(\n    factory: (deps: TDeps) => (...args: TArgs) => any,\n  ): (...args: { [K in keyof TArgs]: Resolvable<TArgs[K]> }) => ChainableGenerator\n\n  register(\n    first: string | RegistrationOptions | ((deps: TDeps) => (...args: any[]) => any),\n    second?: RegistrationOptions | ((deps: TDeps) => (...args: any[]) => any),\n    third?: (deps: TDeps) => (...args: any[]) => any,\n  ): (...args: any[]) => ChainableGenerator {\n    const { name, options, factory } = this.parseArgs(first, second, third)\n\n    this.store(name, options, factory)\n\n    return this.buildExpressionHandle(name, options.prepare) as any\n  }\n}\n","import { z } from 'zod'\nimport GeneratorRegistry from '../../../authoring/registries/GeneratorRegistry'\n\nexport const FORMAT_STRING_GENERATOR_NAME = 'FormatString'\n\nconst formatGenerators = new GeneratorRegistry()\n\nexport const FormatGenerators = {\n  /** Generates a string from a template with %1-style positional placeholders */\n  FormatString: formatGenerators.register(FORMAT_STRING_GENERATOR_NAME, {\n    argumentsSchema: z.tuple([z.string()], z.unknown()),\n    factory:\n      () =>\n      (template: string, ...replacements: unknown[]) =>\n        formatString(template, replacements),\n  }),\n}\n\nexport { formatGenerators as formatGeneratorsRegistry }\n\nfunction formatString(template: string, replacements: readonly unknown[]): string {\n  return template.replace(/%([1-9]\\d*)(?!\\d)/g, (placeholder, indexValue) =>\n    replaceFormatPlaceholder(placeholder, indexValue, replacements),\n  )\n}\n\nfunction replaceFormatPlaceholder(placeholder: string, indexValue: string, replacements: readonly unknown[]): string {\n  const index = Number(indexValue) - 1\n\n  if (!Number.isInteger(index) || index < 0 || index >= replacements.length) {\n    return placeholder\n  }\n\n  return String(replacements[index] ?? '')\n}\n","import { ExpressionBuilder } from './ExpressionBuilder'\nimport { captureCallsite, stampCallsite } from './utils/captureCallsite'\nimport { ChainableExpr, ChainableGenerator } from './types'\nimport { ResolvableValue } from '../types/expressions.type'\nimport { ResolvableString } from '../../components/types/structures.type'\nimport { FormatGenerators } from '../../built-ins/functions/generators/formatGenerators'\n\n/**\n * Creates a string formatting expression with placeholder substitution.\n * Placeholders are %1, %2, etc.\n *\n * @example\n * Format('Hello %1!', Answer('name'))\n * Format('%1 %2', Answer('firstName'), Answer('lastName'))\n */\nexport const Format = FormatGenerators.FormatString as (\n  template: ResolvableString,\n  ...args: ResolvableString[]\n) => ChainableGenerator\n\n/**\n * Wraps a static/literal value to make it chainable with .pipe() and .match().\n *\n * Use this when you have static data that you want to transform or test\n * using the fluent expression API.\n *\n * @param value - Any static value (array, object, primitive)\n * @returns A chainable expression (only exposes .pipe(), .match(), .not)\n *\n * @example\n * // Static array with transformations\n * Literal(['apple', 'banana', 'cherry']).pipe(Transformer.Array.Filter(...))\n *\n * // Static value with condition\n * Literal(42).match(Condition.Number.GreaterThan(0))\n *\n * // Use with .each() for iteration\n * Literal([1, 2, 3]).each(Iterator.Map(Item().value()))\n */\nexport function Literal(value: ResolvableValue): ChainableExpr {\n  const expr = ExpressionBuilder.from(value)\n  stampCallsite(expr, captureCallsite(Literal))\n  return expr\n}\n","import {\n  ConditionBranchExpr,\n  ConditionAndExpr,\n  ConditionOrExpr,\n  ConditionXorExpr,\n  ConditionNotExpr,\n  PredicateExpr,\n  PredicateAndExpr,\n  PredicateOrExpr,\n  PredicateXorExpr,\n  PredicateNotExpr,\n} from '../types/expressions.type'\nimport { ConditionCombinatorType, FunctionType, PredicateType } from '../types/enums'\nimport { captureCallsite, stampCallsite } from './utils/captureCallsite'\nimport ForgeAuthoringError from '../../engine/errors/ForgeAuthoringError'\n\n/** A single operand of a combinator: a bare condition branch, or a predicate. */\ntype CombinatorOperand = ConditionBranchExpr | PredicateExpr\n\n/** Both call forms the AND, OR and XOR combinators accept: one array, or two or more operands. */\ntype CombinatorArgs = [CombinatorOperand[]] | [CombinatorOperand, CombinatorOperand, ...CombinatorOperand[]]\n\n/** The kind of operand a combinator was called with, which decides the node it builds. */\nenum OperandKind {\n  CONDITION = 'OperandKind.Condition',\n  PREDICATE = 'OperandKind.Predicate',\n}\n\ntype ClassifiedOperands =\n  | { kind: OperandKind.CONDITION; operands: ConditionBranchExpr[] }\n  | { kind: OperandKind.PREDICATE; operands: PredicateExpr[] }\n\nconst conditionCombinatorTypes = new Set<string>(Object.values(ConditionCombinatorType))\n\n/**\n * Identifies a bare condition branch - a condition function call, or a nested\n * condition combinator over them - as opposed to a predicate, which carries its own subject.\n */\nfunction isConditionBranch(operand: CombinatorOperand): operand is ConditionBranchExpr {\n  return operand.type === FunctionType.CONDITION || conditionCombinatorTypes.has(operand.type)\n}\n\n/**\n * Flattens the array and variadic call forms into a single operand list, and\n * classifies that list as bare conditions or as predicates.\n * @param fnName - The combinator's name, used in the mixed operand error\n * @param args - The arguments the combinator was called with, in either form\n * @returns The flattened operands, tagged with the kind they all share\n * @throws When conditions and predicates are mixed in one call, which the overloads\n * already rule out for TypeScript callers\n */\nfunction classifyOperands(fnName: string, args: CombinatorArgs): ClassifiedOperands {\n  const operands = Array.isArray(args[0]) && args.length === 1 ? args[0] : (args as CombinatorOperand[])\n  const conditions = operands.filter(isConditionBranch)\n  const predicates = operands.filter((operand): operand is PredicateExpr => !isConditionBranch(operand))\n\n  if (conditions.length === 0) {\n    return { kind: OperandKind.PREDICATE, operands: predicates }\n  }\n\n  if (predicates.length > 0) {\n    throw new ForgeAuthoringError({\n      message: `${fnName}() cannot mix bare conditions with predicates — conditions take their subject from the surrounding match`,\n    })\n  }\n\n  return { kind: OperandKind.CONDITION, operands: conditions }\n}\n\n/**\n * Creates an AND combination where all operands must be true.\n * Given predicates, returns an AND logic predicate.\n * Given bare conditions, or combinators over them, returns a subject-less AND\n * condition combinator, whose conditions take their subject from the surrounding match.\n * @param p - Two or more operands to combine, as one array or as separate arguments\n * @returns A logic predicate, or a condition combinator, that is true if all operands are true\n */\nexport function and(p: PredicateExpr[]): PredicateAndExpr\nexport function and(...p: [PredicateExpr, PredicateExpr, ...PredicateExpr[]]): PredicateAndExpr\nexport function and(c: ConditionBranchExpr[]): ConditionAndExpr\nexport function and(...c: [ConditionBranchExpr, ConditionBranchExpr, ...ConditionBranchExpr[]]): ConditionAndExpr\nexport function and(...args: CombinatorArgs): PredicateAndExpr | ConditionAndExpr {\n  const classified = classifyOperands('and', args)\n\n  const expr: PredicateAndExpr | ConditionAndExpr =\n    classified.kind === OperandKind.CONDITION\n      ? {\n          type: ConditionCombinatorType.AND,\n          operands: classified.operands as [ConditionBranchExpr, ConditionBranchExpr, ...ConditionBranchExpr[]],\n        }\n      : {\n          type: PredicateType.AND,\n          operands: classified.operands as [PredicateExpr, PredicateExpr, ...PredicateExpr[]],\n        }\n  stampCallsite(expr, captureCallsite(and))\n  return expr\n}\n\n/**\n * Creates an OR combination where at least one operand must be true.\n * Given predicates, returns an OR logic predicate.\n * Given bare conditions, or combinators over them, returns a subject-less OR\n * condition combinator, whose conditions take their subject from the surrounding match.\n * @param p - Two or more operands to combine, as one array or as separate arguments\n * @returns A logic predicate, or a condition combinator, that is true if any operand is true\n */\nexport function or(p: PredicateExpr[]): PredicateOrExpr\nexport function or(...p: [PredicateExpr, PredicateExpr, ...PredicateExpr[]]): PredicateOrExpr\nexport function or(c: ConditionBranchExpr[]): ConditionOrExpr\nexport function or(...c: [ConditionBranchExpr, ConditionBranchExpr, ...ConditionBranchExpr[]]): ConditionOrExpr\nexport function or(...args: CombinatorArgs): PredicateOrExpr | ConditionOrExpr {\n  const classified = classifyOperands('or', args)\n\n  const expr: PredicateOrExpr | ConditionOrExpr =\n    classified.kind === OperandKind.CONDITION\n      ? {\n          type: ConditionCombinatorType.OR,\n          operands: classified.operands as [ConditionBranchExpr, ConditionBranchExpr, ...ConditionBranchExpr[]],\n        }\n      : {\n          type: PredicateType.OR,\n          operands: classified.operands as [PredicateExpr, PredicateExpr, ...PredicateExpr[]],\n        }\n  stampCallsite(expr, captureCallsite(or))\n  return expr\n}\n\n/**\n * Creates an XOR combination where exactly one operand must be true.\n * Given predicates, returns an XOR logic predicate.\n * Given bare conditions, or combinators over them, returns a subject-less XOR\n * condition combinator, whose conditions take their subject from the surrounding match.\n * @param p - Two or more operands to combine, as one array or as separate arguments\n * @returns A logic predicate, or a condition combinator, that is true if exactly one operand is true\n */\nexport function xor(p: PredicateExpr[]): PredicateXorExpr\nexport function xor(...p: [PredicateExpr, PredicateExpr, ...PredicateExpr[]]): PredicateXorExpr\nexport function xor(c: ConditionBranchExpr[]): ConditionXorExpr\nexport function xor(...c: [ConditionBranchExpr, ConditionBranchExpr, ...ConditionBranchExpr[]]): ConditionXorExpr\nexport function xor(...args: CombinatorArgs): PredicateXorExpr | ConditionXorExpr {\n  const classified = classifyOperands('xor', args)\n\n  const expr: PredicateXorExpr | ConditionXorExpr =\n    classified.kind === OperandKind.CONDITION\n      ? {\n          type: ConditionCombinatorType.XOR,\n          operands: classified.operands as [ConditionBranchExpr, ConditionBranchExpr, ...ConditionBranchExpr[]],\n        }\n      : {\n          type: PredicateType.XOR,\n          operands: classified.operands as [PredicateExpr, PredicateExpr, ...PredicateExpr[]],\n        }\n  stampCallsite(expr, captureCallsite(xor))\n  return expr\n}\n\n/**\n * Creates a NOT combination that inverts the operand's result.\n * Given a predicate, returns a NOT logic predicate.\n * Given a bare condition, or a combinator over them, returns a subject-less NOT\n * condition combinator, whose conditions take their subject from the surrounding match.\n * @param p - The operand to negate\n * @returns A logic predicate, or a condition combinator, that is the opposite of the operand\n */\nexport function not(p: PredicateExpr): PredicateNotExpr\nexport function not(c: ConditionBranchExpr): ConditionNotExpr\nexport function not(operand: CombinatorOperand): PredicateNotExpr | ConditionNotExpr {\n  const expr: PredicateNotExpr | ConditionNotExpr = isConditionBranch(operand)\n    ? {\n        type: ConditionCombinatorType.NOT,\n        operand,\n      }\n    : {\n        type: PredicateType.NOT,\n        operand,\n      }\n  stampCallsite(expr, captureCallsite(not))\n  return expr\n}\n","import { block as buildBlock, field as buildField } from '../authoring/builders'\nimport type {\n  BaseComponentOptions,\n  ComponentOptions,\n  FieldComponentOptions,\n  ForgeComponent,\n  PropsOf,\n} from './types/components.type'\nimport type { BlockDefinition, EvaluatedBlock, FieldBlockDefinition } from './types/structures.type'\n\n/**\n * Defines a component from a single block interface.\n *\n * The returned value is both the authoring builder and the registry entry, so one\n * declaration covers both roles:\n *\n * ```typescript\n * export interface MyCard extends BlockDefinition { title: string }\n * export const MyCard = component<MyCard>('myCard', {\n *   render: (props, renderer) => {\n *     const nunjucksEnv = renderer as nunjucks.Environment\n *\n *     return nunjucksEnv.render('components/card.njk', { params: { text: props.title } })\n *   },\n * })\n * ```\n *\n * A component that captures user input declares `field: true` - see\n * {@link FieldComponentOptions.field}.\n *\n * @param variant - The component's variant identifier\n * @param options - How the component renders, plus the field options where it is one\n * @returns A callable block builder that doubles as the component registry entry\n */\nexport function component<TBlock extends BlockDefinition, TOutput = string, TRenderer = unknown>(\n  variant: string,\n  options: ComponentOptions<TBlock, TOutput, TRenderer>,\n): ForgeComponent<TBlock, TOutput> {\n  // TBlock is still generic here, so the conditional options type is unresolved - read it\n  // through a shape carrying every member either arm can contribute.\n  const { render, prepare, field, inputSchema, multiple, errorAnchor } = options as BaseComponentOptions<\n    TBlock,\n    TOutput,\n    TRenderer\n  > &\n    Partial<FieldComponentOptions<TBlock, TOutput, TRenderer>>\n\n  const buildDefinition = (props?: PropsOf<TBlock>): TBlock => {\n    const authored = props ?? ({} as PropsOf<TBlock>)\n    const prepared = prepare ? prepare(authored) : authored\n\n    // The field props are only present on a field component; the cast lets both builders\n    // share one definition, and the declared `field` option picks the right one.\n    const definition = { ...prepared, variant } as unknown as Omit<TBlock & FieldBlockDefinition, 'type' | 'blockType'>\n\n    return field\n      ? buildField<TBlock & FieldBlockDefinition>(definition)\n      : buildBlock<TBlock & FieldBlockDefinition>(definition)\n  }\n\n  return Object.assign(buildDefinition, {\n    variant,\n    render: (block: EvaluatedBlock<TBlock>, renderer?: unknown) => render(block, renderer as TRenderer),\n    ...(inputSchema !== undefined && { inputSchema }),\n    ...(multiple !== undefined && { multiple }),\n    ...(errorAnchor !== undefined && { errorAnchor }),\n  })\n}\n","/**\n * HTML entity encoding map for XSS prevention\n */\nconst HTML_ENTITY_MAP: Record<string, string> = {\n  '<': '&lt;',\n  '>': '&gt;',\n  '&': '&amp;',\n  '\"': '&quot;',\n  \"'\": '&#39;',\n}\n\n/**\n * Escape HTML entities in a string value to prevent XSS attacks.\n *\n * Converts dangerous characters to their HTML entity equivalents:\n * - < becomes &lt;\n * - > becomes &gt;\n * - & becomes &amp;\n * - \" becomes &quot;\n * - ' becomes &#39;\n *\n * @param value - The string value to sanitize\n * @returns The sanitized string with HTML entities escaped\n */\nexport function escapeHtmlEntities(value: string): string {\n  return value.replace(/[<>&\"']/g, char => HTML_ENTITY_MAP[char])\n}\n","import { component } from '../../components/component'\nimport { escapeHtmlEntities } from '../sanitize'\nimport { isRenderedBlock } from '../../components/typeguards'\nimport type { BlockDefinition, ResolvableString } from '../../components/types/structures.type'\n\n/**\n * HTML Block component.\n *\n * Use this to render raw HTML content within forms.\n *\n * When `tag` is set, content is wrapped in that element with `classes` and `attributes`\n * applied directly. When `tag` is not set but `classes`/`attributes` are present, falls\n * back to a wrapper `<div>`. Content can be a string or an array of rendered blocks\n * (e.g. from a collection expression), which are concatenated into a single string.\n *\n * **WARNING: XSS Risk — Content is rendered as raw HTML without any sanitization.**\n *\n * Any dynamic data interpolated into the content (e.g. via `Format()`, `Data()`, `Item()`)\n * will be rendered as-is. If that data comes from user input or external sources, it **must**\n * be escaped using `Transformer.String.EscapeHtml()` to prevent injection attacks.\n *\n * @example Safe — static developer HTML:\n * ```typescript\n * HtmlBlock({\n *   content: '<p class=\"govuk-body\">Terms of Service</p>',\n * })\n * ```\n *\n * @example Safe — dynamic data escaped before interpolation:\n * ```typescript\n * HtmlBlock({\n *   content: Format(\n *     '<p class=\"govuk-body\">%1</p>',\n *     Data('goalTitle').pipe(Transformer.String.EscapeHtml()),\n *   ),\n * })\n * ```\n *\n * @example UNSAFE — dynamic data interpolated without escaping:\n * ```typescript\n * // DO NOT do this — vulnerable to XSS if goalTitle contains malicious HTML\n * HtmlBlock({\n *   content: Format('<p class=\"govuk-body\">%1</p>', Data('goalTitle')),\n * })\n * ```\n */\nexport interface HtmlBlock extends BlockDefinition {\n  /**\n   * HTML tag to render content within. When set, `classes` and `attributes`\n   * are applied directly to this element instead of a wrapper `<div>`.\n   */\n  tag?: string\n\n  /**\n   * Content to render. Accepts a string, a dynamic expression, or an array of child blocks.\n   * When `tag` is a void element (e.g. `hr`), content is ignored.\n   *\n   * **WARNING: Not sanitized.** Escape any untrusted data with `Transformer.String.EscapeHtml()`.\n   */\n  content?: ResolvableString | BlockDefinition | BlockDefinition[]\n\n  /** Additional CSS classes to apply to the element (optional) */\n  classes?: ResolvableString\n\n  /** Custom HTML attributes for the element (optional) */\n  attributes?: Record<string, any>\n}\n\nconst VOID_ELEMENTS = new Set([\n  'area',\n  'base',\n  'br',\n  'col',\n  'embed',\n  'hr',\n  'img',\n  'input',\n  'link',\n  'meta',\n  'source',\n  'track',\n  'wbr',\n])\n\nconst resolveContent = (content: unknown): string => {\n  if (Array.isArray(content)) {\n    return content.map(item => resolveContent(item)).join('')\n  }\n\n  if (isRenderedBlock(content)) {\n    return content.html\n  }\n\n  return (content as string) ?? ''\n}\n\n/**\n * HTML Block component.\n *\n * Use this to render raw HTML content within forms.\n *\n * When `tag` is set, content is wrapped in that element with `classes` and `attributes`\n * applied directly. When `tag` is not set but `classes`/`attributes` are present, falls\n * back to a wrapper `<div>`. Content can be a string or an array of rendered blocks\n * (e.g. from a collection expression), which are concatenated into a single string.\n *\n * **WARNING: XSS Risk — Content is rendered as raw HTML without any sanitization.**\n *\n * Any dynamic data interpolated into the content (e.g. via `Format()`, `Data()`, `Item()`)\n * will be rendered as-is. If that data comes from user input or external sources, it **must**\n * be escaped using `Transformer.String.EscapeHtml()` to prevent injection attacks.\n *\n * @example Safe — static developer HTML:\n * ```typescript\n * HtmlBlock({\n *   content: '<p class=\"govuk-body\">Terms of Service</p>',\n * })\n * ```\n *\n * @example Safe — dynamic data escaped before interpolation:\n * ```typescript\n * HtmlBlock({\n *   content: Format(\n *     '<p class=\"govuk-body\">%1</p>',\n *     Data('goalTitle').pipe(Transformer.String.EscapeHtml()),\n *   ),\n * })\n * ```\n *\n * @example UNSAFE — dynamic data interpolated without escaping:\n * ```typescript\n * // DO NOT do this — vulnerable to XSS if goalTitle contains malicious HTML\n * HtmlBlock({\n *   content: Format('<p class=\"govuk-body\">%1</p>', Data('goalTitle')),\n * })\n * ```\n */\nexport const HtmlBlock = component<HtmlBlock>('html', {\n  render: props => {\n    const hasAttrs = props.classes || props.attributes\n\n    if (!props.tag && !hasAttrs) {\n      return resolveContent(props.content)\n    }\n\n    const element = props.tag ?? 'div'\n    const classAttr = props.classes ? ` class=\"${escapeHtmlEntities(props.classes)}\"` : ''\n    const customAttrs = props.attributes\n      ? Object.entries(props.attributes)\n          .map(([key, value]) => ` ${escapeHtmlEntities(key)}=\"${escapeHtmlEntities(String(value))}\"`)\n          .join('')\n      : ''\n\n    if (VOID_ELEMENTS.has(element)) {\n      return `<${element}${classAttr}${customAttrs}>`\n    }\n\n    return `<${element}${classAttr}${customAttrs}>${resolveContent(props.content)}</${element}>`\n  },\n})\n","import { component } from '../../components/component'\nimport { StructureType } from '../../authoring/types/enums'\nimport { isRenderedBlock } from '../../components/typeguards'\nimport { escapeHtmlEntities } from '../sanitize'\nimport type {\n  BlockDefinition,\n  ResolvableArray,\n  ResolvableString,\n  RenderedBlock,\n} from '../../components/types/structures.type'\n\n/**\n * Collection Block component.\n * Renders repeated blocks based on a collection expression.\n *\n * The `collection` property accepts any chainable expression that evaluates to an array of blocks.\n * This works with the Iterator pattern (e.g., `Data('items').each(Iterator.Map(...))`)\n *\n * @template T - Type of blocks in the collection array\n * @template F - Type of blocks in the fallback array (defaults to T)\n *\n * @example\n * ```typescript\n * CollectionBlock({\n *   collection: Data('tasks').each(Iterator.Map({\n *     template: MojCard({\n *       heading: Item().path('title'),\n *       content: Item().path('description'),\n *     }),\n *   })),\n *   fallback: [GovUKInsetText({ html: 'No tasks available' })],\n *   classes: 'govuk-!-margin-bottom-6',\n * })\n * ```\n */\nexport interface CollectionBlock<T = BlockDefinition, F = T> extends BlockDefinition {\n  /**\n   * The blocks to render: an expression that evaluates to an array of blocks,\n   * or a static array of block definitions.\n   * @example Data('items').each(Iterator.Map({ template: GovUKInsetText({ ... }) }))\n   * @example [GovUKInsetText({ html: 'First' }), GovUKInsetText({ html: 'Second' })]\n   */\n  collection: ResolvableArray<T>\n\n  /**\n   * Fallback blocks to render when the collection is empty.\n   * @example [GovUKInsetText({ html: 'No items found' })]\n   */\n  fallback?: F[]\n\n  /**\n   * HTML tag to render content within. When set, `classes` and `attributes`\n   * are applied directly to this element instead of a wrapper `<div>`.\n   * @example 'ul'\n   */\n  tag?: string\n\n  /**\n   * Additional CSS classes to apply to the wrapper element.\n   * @example 'govuk-!-margin-bottom-6'\n   */\n  classes?: ResolvableString\n\n  /**\n   * Custom HTML attributes for the wrapper element.\n   * @example { 'data-module': 'collection-list' }\n   */\n  attributes?: Record<string, any>\n}\n\n/**\n * Runtime representation of a collection block after evaluation.\n * The `collection` property contains the rendered blocks from applying the template.\n *\n * Note: This doesn't extend EvaluatedBlock<CollectionBlock> because the\n * `collection` property transforms from an expression to RenderedBlock[]\n * during evaluation - a transformation the generic type can't express.\n */\nexport interface EvaluatedCollectionBlock {\n  type: typeof StructureType.BLOCK\n  variant: 'collection-block'\n\n  /** The rendered blocks from applying the template to each collection item */\n  collection?: RenderedBlock[]\n\n  /** Fallback blocks rendered when the collection is empty */\n  fallback?: RenderedBlock[]\n\n  /** HTML tag for the wrapper element (defaults to div when classes/attributes are present) */\n  tag?: string\n\n  /** Additional CSS classes applied to the wrapper element */\n  classes?: string\n\n  /** Custom HTML attributes for the wrapper element */\n  attributes?: Record<string, string>\n}\n\n/**\n * Extracts a string value from a collection item that could be:\n * - A rendered block (with .html and .block properties)\n * - A plain string\n * - An array of either\n */\nconst extractItemValue = (item: unknown): string => {\n  if (Array.isArray(item)) {\n    return item.map(i => extractItemValue(i)).join('')\n  }\n\n  if (isRenderedBlock(item)) {\n    return item.html\n  }\n\n  return (item as string) ?? ''\n}\n\n/**\n * Render function for collection-block.\n */\nconst renderCollectionBlock = (block: EvaluatedCollectionBlock): string => {\n  let content = ''\n\n  const hasItems = block.collection && block.collection.length > 0\n\n  if (hasItems) {\n    content = block.collection!.map(item => extractItemValue(item)).join('')\n  } else if (block.fallback && block.fallback.length > 0) {\n    content = block.fallback.map(item => extractItemValue(item)).join('')\n  }\n\n  const hasWrapper = block.tag || block.classes || block.attributes\n\n  if (hasWrapper) {\n    const element = block.tag ?? 'div'\n    const classAttr = block.classes ? ` class=\"${escapeHtmlEntities(block.classes)}\"` : ''\n    const customAttrs = block.attributes\n      ? Object.entries(block.attributes)\n          .map(([key, value]) => ` ${escapeHtmlEntities(key)}=\"${escapeHtmlEntities(String(value))}\"`)\n          .join('')\n      : ''\n\n    return `<${element}${classAttr}${customAttrs}>${content}</${element}>`\n  }\n\n  return content\n}\n\n/**\n * Collection Block component.\n * Renders repeated blocks based on a collection expression.\n *\n * The `collection` property accepts any chainable expression that evaluates to an array of blocks.\n * This works with the Iterator pattern (e.g., `Data('items').each(Iterator.Map(...))`)\n *\n * @example\n * ```typescript\n * CollectionBlock({\n *   collection: Data('tasks').each(Iterator.Map({\n *     template: MojCard({\n *       heading: Item().path('title'),\n *       content: Item().path('description'),\n *     }),\n *   })),\n *   fallback: [GovUKInsetText({ html: 'No tasks available' })],\n *   classes: 'govuk-!-margin-bottom-6',\n * })\n * ```\n */\nexport const CollectionBlock = component<CollectionBlock>('collection-block', {\n  // Cast to the evaluated shape because the generic EvaluatedBlock<CollectionBlock> type\n  // cannot express that `collection` transforms from an expression to RenderedBlock[].\n  render: props => renderCollectionBlock(props as unknown as EvaluatedCollectionBlock),\n})\n","import { component } from '../../components/component'\nimport { isRenderedBlock } from '../../components/typeguards'\nimport { escapeHtmlEntities } from '../sanitize'\nimport type { BlockDefinition, ResolvableString } from '../../components/types/structures.type'\n\n/**\n * TemplateWrapper component.\n *\n * Template wrapper allows wrapping child blocks in an HTML template.\n * Slots in the template use the syntax `{{slot:slotName}}` and will be replaced\n * with the rendered HTML of the corresponding blocks in the `slots` property.\n *\n * Values in the template use the syntax `{{valueName}}` and will be replaced\n * with the corresponding string value from the `values` property.\n *\n * @example\n * ```typescript\n * TemplateWrapper({\n *   template: `\n *     <section class=\"govuk-section\">\n *       <h2 class=\"govuk-heading-m\">{{title}}</h2>\n *       {{slot:content}}\n *       <p class=\"govuk-body-s\">{{footer}}</p>\n *     </section>\n *   `,\n *   values: {\n *     title: 'Journey Configuration',\n *     footer: 'See the next page for step configuration.'\n *   },\n *   slots: {\n *     content: [\n *       HtmlBlock({ content: '<p>Explanation...</p>' }),\n *       GovUKCodeBlock({ code: '...' }),\n *     ]\n *   }\n * })\n * ```\n */\nexport interface TemplateWrapper extends BlockDefinition {\n  /**\n   * HTML template with slot markers ({{slot:name}}) and value markers ({{name}}).\n   *\n   * @example '<div class=\"wrapper\">{{slot:content}}</div>'\n   * @example '<h2>{{title}}</h2>{{slot:body}}'\n   */\n  template: ResolvableString\n\n  /**\n   * String values to inject into the template at {{name}} markers.\n   *\n   * **WARNING: Not sanitized.** Values are injected directly into the HTML template.\n   * Escape any untrusted data with `Transformer.String.EscapeHtml()`.\n   *\n   * @example { title: 'Section Title', footer: 'Footer text' }\n   */\n  values?: Record<string, ResolvableString>\n\n  /**\n   * Named slots containing blocks to render at {{slot:name}} markers.\n   *\n   * @example { content: [HtmlBlock({ content: '<p>Hello</p>' })] }\n   */\n  slots?: Record<string, BlockDefinition[]>\n\n  /**\n   * HTML tag to render content within. When set, `classes` and `attributes`\n   * are applied directly to this element instead of a wrapper `<div>`.\n   *\n   * @example 'section'\n   */\n  tag?: string\n\n  /**\n   * Additional CSS classes to apply to the wrapper element (optional).\n   * Only applies when a wrapper element is rendered.\n   *\n   * @example 'govuk-!-margin-bottom-6'\n   */\n  classes?: ResolvableString\n\n  /**\n   * Custom HTML attributes for the wrapper element (optional).\n   * Only applies when a wrapper element is rendered.\n   *\n   * @example { 'data-module': 'template-section' }\n   */\n  attributes?: Record<string, any>\n}\n\n/**\n * Extracts a string value from a value that could be:\n * - A plain string\n * - A rendered block (with .html and .block properties)\n * - An array of strings or rendered blocks\n */\nconst extractStringValue = (value: unknown): string => {\n  if (Array.isArray(value)) {\n    return value.map(v => extractStringValue(v)).join('')\n  }\n\n  if (isRenderedBlock(value)) {\n    return value.html\n  }\n\n  return (value as string) ?? ''\n}\n\n/**\n * TemplateWrapper component.\n *\n * Template wrapper allows wrapping child blocks in an HTML template.\n * Slots in the template use the syntax `{{slot:slotName}}` and will be replaced\n * with the rendered HTML of the corresponding blocks in the `slots` property.\n *\n * Values in the template use the syntax `{{valueName}}` and will be replaced\n * with the corresponding string value from the `values` property.\n *\n * @example\n * ```typescript\n * TemplateWrapper({\n *   template: `\n *     <section class=\"govuk-section\">\n *       <h2 class=\"govuk-heading-m\">{{title}}</h2>\n *       {{slot:content}}\n *       <p class=\"govuk-body-s\">{{footer}}</p>\n *     </section>\n *   `,\n *   values: {\n *     title: 'Journey Configuration',\n *     footer: 'See the next page for step configuration.'\n *   },\n *   slots: {\n *     content: [\n *       HtmlBlock({ content: '<p>Explanation...</p>' }),\n *       GovUKCodeBlock({ code: '...' }),\n *     ]\n *   }\n * })\n * ```\n */\nexport const TemplateWrapper = component<TemplateWrapper>('templateWrapper', {\n  render: props => {\n    let content = props.template\n\n    // Replace value markers: {{valueName}}\n    // Values are developer-controlled (not user input), so no escaping needed.\n    // User input flows through form fields and is escaped by Nunjucks at render time.\n    if (props.values) {\n      Object.entries(props.values).forEach(([key, value]) => {\n        const marker = `{{${key}}}`\n        const stringValue = extractStringValue(value)\n        content = content.split(marker).join(stringValue)\n      })\n    }\n\n    // Replace slot markers: {{slot:slotName}}\n    if (props.slots) {\n      Object.entries(props.slots).forEach(([slotName, renderedBlocks]) => {\n        const marker = `{{slot:${slotName}}}`\n        const slotHtml = renderedBlocks.map(b => b.html).join('')\n        content = content.split(marker).join(slotHtml)\n      })\n    }\n\n    // Clean up any unreplaced markers (slots/values that weren't provided)\n    content = content.replace(/\\{\\{slot:[^}]+}}/g, '')\n    content = content.replace(/\\{\\{[^}]+}}/g, '')\n\n    const hasWrapper = props.tag || props.classes || props.attributes\n\n    if (hasWrapper) {\n      const element = props.tag ?? 'div'\n      const classAttr = props.classes ? ` class=\"${escapeHtmlEntities(props.classes)}\"` : ''\n      const customAttrs = props.attributes\n        ? Object.entries(props.attributes)\n            .map(([key, value]) => ` ${escapeHtmlEntities(key)}=\"${escapeHtmlEntities(String(value))}\"`)\n            .join('')\n        : ''\n\n      return `<${element}${classAttr}${customAttrs}>${content}</${element}>`\n    }\n\n    return content\n  },\n})\n","import { component } from '../../components/component'\nimport { isRenderedBlock } from '../../components/typeguards'\nimport type { BlockDefinition, ResolvableArray } from '../../components/types/structures.type'\n\n/**\n * Fragment component.\n *\n * Groups child blocks without adding a wrapper element - the blocks render\n * back-to-back exactly as they would as siblings.\n *\n * Useful anywhere a single block is expected but you want to output several,\n * such as the template of an `Iterator.Map()`.\n *\n * @example\n * ```typescript\n * Data('tasks').each(Iterator.Map(\n *   Fragment({\n *     blocks: [\n *       GovUKHeading({ text: Item().path('title'), level: 3 }),\n *       GovUKBody({ text: Item().path('description') }),\n *     ],\n *   }),\n * ))\n * ```\n */\nexport interface Fragment extends BlockDefinition {\n  /**\n   * The child blocks to render, in order.\n   *\n   * @example [GovUKHeading({ text: 'Title' }), GovUKBody({ text: 'Body' })]\n   */\n  blocks: ResolvableArray<BlockDefinition>\n}\n\n/**\n * Renders a fragment child to its HTML string:\n * - Rendered blocks contribute their HTML as-is\n * - Arrays are flattened in order\n * - Anything else (e.g. a dynamic expression resolving to non-blocks) is skipped\n */\nconst renderChild = (child: unknown): string => {\n  if (Array.isArray(child)) {\n    return child.map(c => renderChild(c)).join('')\n  }\n\n  if (isRenderedBlock(child)) {\n    return child.html\n  }\n\n  return ''\n}\n\n/**\n * Fragment component.\n *\n * Groups child blocks without adding a wrapper element - the blocks render\n * back-to-back exactly as they would as siblings.\n *\n * @example\n * ```typescript\n * Fragment({\n *   blocks: [\n *     GovUKHeading({ text: 'Title', level: 3 }),\n *     GovUKBody({ text: 'Body' }),\n *   ],\n * })\n * ```\n */\nexport const Fragment = component<Fragment>('fragment', {\n  render: props => props.blocks.map(child => renderChild(child)).join(''),\n})\n","import { HtmlBlock } from './html'\nimport { CollectionBlock } from './collectionBlock'\nimport { TemplateWrapper } from './templateWrapper'\nimport { Fragment } from './fragment'\n\nexport const coreComponents = [HtmlBlock, CollectionBlock, TemplateWrapper, Fragment]\n\n// Re-export supporting types\nexport type { EvaluatedCollectionBlock } from './collectionBlock'\n\n// Re-export the components (each const is both the block builder and the registry entry)\nexport { HtmlBlock } from './html'\nexport { CollectionBlock } from './collectionBlock'\nexport { TemplateWrapper } from './templateWrapper'\nexport { Fragment } from './fragment'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,kBACX,SACA,UACA,UAAiC,CAAC,OACY;CAC9C;CACA,QAAQ;CACR,GAAI,QAAQ,gBAAgB,KAAA,KAAa,EAAE,aAAa,QAAQ,YAAY;CAC5E,GAAI,QAAQ,aAAa,KAAA,KAAa,EAAE,UAAU,QAAQ,SAAS;AACrE;;;;;;;;AChCA,IAAY,eAAL,yBAAA,cAAA;CACL,aAAA,eAAA;CACA,aAAA,iBAAA;CACA,aAAA,eAAA;CACA,aAAA,YAAA;;AACF,EAAA,CAAA,CAAA;;;;;;;AAqEA,IAAY,0BAAL,yBAAA,yBAAA;CACL,wBAAA,SAAA;CACA,wBAAA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