@player-tools/fluent 0.12.1--canary.241.6077

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/dist/cjs/index.cjs +2396 -0
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/dist/index.legacy-esm.js +2276 -0
  4. package/dist/index.mjs +2276 -0
  5. package/dist/index.mjs.map +1 -0
  6. package/package.json +38 -0
  7. package/src/core/base-builder/__tests__/fluent-builder-base.test.ts +2423 -0
  8. package/src/core/base-builder/__tests__/fluent-partial.test.ts +179 -0
  9. package/src/core/base-builder/__tests__/id-generator.test.ts +658 -0
  10. package/src/core/base-builder/__tests__/registry.test.ts +534 -0
  11. package/src/core/base-builder/__tests__/resolution-mixed-arrays.test.ts +319 -0
  12. package/src/core/base-builder/__tests__/resolution-pipeline.test.ts +416 -0
  13. package/src/core/base-builder/__tests__/resolution-switches.test.ts +468 -0
  14. package/src/core/base-builder/__tests__/resolution-templates.test.ts +255 -0
  15. package/src/core/base-builder/__tests__/switch.test.ts +815 -0
  16. package/src/core/base-builder/__tests__/template.test.ts +596 -0
  17. package/src/core/base-builder/__tests__/value-extraction.test.ts +200 -0
  18. package/src/core/base-builder/__tests__/value-storage.test.ts +459 -0
  19. package/src/core/base-builder/conditional/index.ts +64 -0
  20. package/src/core/base-builder/context.ts +152 -0
  21. package/src/core/base-builder/errors.ts +69 -0
  22. package/src/core/base-builder/fluent-builder-base.ts +308 -0
  23. package/src/core/base-builder/guards.ts +137 -0
  24. package/src/core/base-builder/id/generator.ts +290 -0
  25. package/src/core/base-builder/id/registry.ts +152 -0
  26. package/src/core/base-builder/index.ts +72 -0
  27. package/src/core/base-builder/resolution/path-resolver.ts +116 -0
  28. package/src/core/base-builder/resolution/pipeline.ts +103 -0
  29. package/src/core/base-builder/resolution/steps/__tests__/nested-asset-wrappers.test.ts +206 -0
  30. package/src/core/base-builder/resolution/steps/asset-id.ts +77 -0
  31. package/src/core/base-builder/resolution/steps/asset-wrappers.ts +64 -0
  32. package/src/core/base-builder/resolution/steps/builders.ts +84 -0
  33. package/src/core/base-builder/resolution/steps/mixed-arrays.ts +95 -0
  34. package/src/core/base-builder/resolution/steps/nested-asset-wrappers.ts +124 -0
  35. package/src/core/base-builder/resolution/steps/static-values.ts +35 -0
  36. package/src/core/base-builder/resolution/steps/switches.ts +71 -0
  37. package/src/core/base-builder/resolution/steps/templates.ts +40 -0
  38. package/src/core/base-builder/resolution/value-resolver.ts +333 -0
  39. package/src/core/base-builder/storage/auxiliary-storage.ts +82 -0
  40. package/src/core/base-builder/storage/value-storage.ts +282 -0
  41. package/src/core/base-builder/types.ts +266 -0
  42. package/src/core/base-builder/utils.ts +10 -0
  43. package/src/core/flow/__tests__/index.test.ts +292 -0
  44. package/src/core/flow/index.ts +118 -0
  45. package/src/core/index.ts +8 -0
  46. package/src/core/mocks/generated/action.builder.ts +92 -0
  47. package/src/core/mocks/generated/choice-item.builder.ts +120 -0
  48. package/src/core/mocks/generated/choice.builder.ts +134 -0
  49. package/src/core/mocks/generated/collection.builder.ts +93 -0
  50. package/src/core/mocks/generated/field-collection.builder.ts +86 -0
  51. package/src/core/mocks/generated/index.ts +10 -0
  52. package/src/core/mocks/generated/info.builder.ts +64 -0
  53. package/src/core/mocks/generated/input.builder.ts +63 -0
  54. package/src/core/mocks/generated/overview-collection.builder.ts +65 -0
  55. package/src/core/mocks/generated/splash-collection.builder.ts +93 -0
  56. package/src/core/mocks/generated/text.builder.ts +47 -0
  57. package/src/core/mocks/index.ts +1 -0
  58. package/src/core/mocks/types/action.ts +92 -0
  59. package/src/core/mocks/types/choice.ts +129 -0
  60. package/src/core/mocks/types/collection.ts +140 -0
  61. package/src/core/mocks/types/info.ts +7 -0
  62. package/src/core/mocks/types/input.ts +7 -0
  63. package/src/core/mocks/types/text.ts +5 -0
  64. package/src/core/schema/__tests__/index.test.ts +127 -0
  65. package/src/core/schema/index.ts +195 -0
  66. package/src/core/schema/types.ts +7 -0
  67. package/src/core/switch/__tests__/index.test.ts +156 -0
  68. package/src/core/switch/index.ts +81 -0
  69. package/src/core/tagged-template/README.md +448 -0
  70. package/src/core/tagged-template/__tests__/extract-bindings-from-schema.test.ts +207 -0
  71. package/src/core/tagged-template/__tests__/index.test.ts +190 -0
  72. package/src/core/tagged-template/__tests__/schema-std-integration.test.ts +580 -0
  73. package/src/core/tagged-template/binding.ts +95 -0
  74. package/src/core/tagged-template/expression.ts +92 -0
  75. package/src/core/tagged-template/extract-bindings-from-schema.ts +120 -0
  76. package/src/core/tagged-template/index.ts +5 -0
  77. package/src/core/tagged-template/std.ts +472 -0
  78. package/src/core/tagged-template/types.ts +123 -0
  79. package/src/core/template/__tests__/index.test.ts +380 -0
  80. package/src/core/template/index.ts +196 -0
  81. package/src/core/utils/index.ts +160 -0
  82. package/src/fp/README.md +411 -0
  83. package/src/fp/__tests__/index.test.ts +1178 -0
  84. package/src/fp/index.ts +386 -0
  85. package/src/gen/common.ts +15 -0
  86. package/src/index.ts +5 -0
  87. package/src/types.ts +203 -0
  88. package/types/core/base-builder/conditional/index.d.ts +21 -0
  89. package/types/core/base-builder/context.d.ts +39 -0
  90. package/types/core/base-builder/errors.d.ts +45 -0
  91. package/types/core/base-builder/fluent-builder-base.d.ts +147 -0
  92. package/types/core/base-builder/guards.d.ts +58 -0
  93. package/types/core/base-builder/id/generator.d.ts +69 -0
  94. package/types/core/base-builder/id/registry.d.ts +93 -0
  95. package/types/core/base-builder/index.d.ts +9 -0
  96. package/types/core/base-builder/resolution/path-resolver.d.ts +15 -0
  97. package/types/core/base-builder/resolution/pipeline.d.ts +27 -0
  98. package/types/core/base-builder/resolution/steps/asset-id.d.ts +14 -0
  99. package/types/core/base-builder/resolution/steps/asset-wrappers.d.ts +14 -0
  100. package/types/core/base-builder/resolution/steps/builders.d.ts +14 -0
  101. package/types/core/base-builder/resolution/steps/mixed-arrays.d.ts +14 -0
  102. package/types/core/base-builder/resolution/steps/nested-asset-wrappers.d.ts +14 -0
  103. package/types/core/base-builder/resolution/steps/static-values.d.ts +14 -0
  104. package/types/core/base-builder/resolution/steps/switches.d.ts +15 -0
  105. package/types/core/base-builder/resolution/steps/templates.d.ts +14 -0
  106. package/types/core/base-builder/resolution/value-resolver.d.ts +62 -0
  107. package/types/core/base-builder/storage/auxiliary-storage.d.ts +50 -0
  108. package/types/core/base-builder/storage/value-storage.d.ts +82 -0
  109. package/types/core/base-builder/types.d.ts +183 -0
  110. package/types/core/base-builder/utils.d.ts +2 -0
  111. package/types/core/flow/index.d.ts +23 -0
  112. package/types/core/index.d.ts +8 -0
  113. package/types/core/mocks/index.d.ts +2 -0
  114. package/types/core/mocks/types/action.d.ts +58 -0
  115. package/types/core/mocks/types/choice.d.ts +95 -0
  116. package/types/core/mocks/types/collection.d.ts +102 -0
  117. package/types/core/mocks/types/info.d.ts +7 -0
  118. package/types/core/mocks/types/input.d.ts +7 -0
  119. package/types/core/mocks/types/text.d.ts +5 -0
  120. package/types/core/schema/index.d.ts +34 -0
  121. package/types/core/schema/types.d.ts +5 -0
  122. package/types/core/switch/index.d.ts +21 -0
  123. package/types/core/tagged-template/binding.d.ts +19 -0
  124. package/types/core/tagged-template/expression.d.ts +11 -0
  125. package/types/core/tagged-template/extract-bindings-from-schema.d.ts +7 -0
  126. package/types/core/tagged-template/index.d.ts +6 -0
  127. package/types/core/tagged-template/std.d.ts +174 -0
  128. package/types/core/tagged-template/types.d.ts +69 -0
  129. package/types/core/template/index.d.ts +97 -0
  130. package/types/core/utils/index.d.ts +47 -0
  131. package/types/fp/index.d.ts +149 -0
  132. package/types/gen/common.d.ts +6 -0
  133. package/types/index.d.ts +3 -0
  134. package/types/types.d.ts +163 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/index.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/types.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/guards.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/id/registry.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/id/generator.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/context.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/tagged-template/types.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/tagged-template/binding.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/tagged-template/expression.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/tagged-template/extract-bindings-from-schema.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/tagged-template/std.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/value-resolver.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/storage/value-storage.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/storage/auxiliary-storage.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/steps/static-values.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/steps/asset-id.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/steps/asset-wrappers.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/steps/mixed-arrays.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/steps/builders.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/path-resolver.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/steps/switches.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/steps/templates.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/steps/nested-asset-wrappers.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/resolution/pipeline.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/conditional/index.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/switch/index.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/fluent-builder-base.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/utils.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/base-builder/errors.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/template/index.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/flow/index.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/schema/index.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/fluent/src/core/utils/index.ts"],"sourcesContent":["// Core utilities - building blocks for DSL generation\nexport * from \"./core\";\n\n// All types - safe to export since they don't affect bundle size\nexport * from \"./types\";\n","import { Asset, AssetWrapper } from \"@player-ui/types\";\nimport type { TaggedTemplateValue } from \"../tagged-template/types\";\n\n/**\n * Unique symbol to identify FluentBuilder instances\n * Used for runtime type checking of builder objects\n */\nexport const FLUENT_BUILDER_SYMBOL: unique symbol =\n Symbol.for(\"fluent-builder\");\n\n/**\n * Constants for branch type discriminators\n * Use these instead of string literals to prevent typos\n */\nexport const BranchTypes = {\n SLOT: \"slot\",\n ARRAY_ITEM: \"array-item\",\n TEMPLATE: \"template\",\n SWITCH: \"switch\",\n CUSTOM: \"custom\",\n} as const;\n\n/**\n * Constants for internal storage keys\n * Used by AuxiliaryStorage to store templates and switches\n */\nexport const StorageKeys = {\n TEMPLATES: \"__templates__\",\n SWITCHES: \"__switches__\",\n} as const;\n\n/**\n * Constants for common property keys used in asset building\n */\nexport const PropertyKeys = {\n ID: \"id\",\n TYPE: \"type\",\n VALUE: \"value\",\n BINDING: \"binding\",\n} as const;\n\n/**\n * Core interface for all fluent builders\n * Provides build(), peek(), and has() methods for all builder types\n */\nexport interface FluentBuilder<\n T,\n C extends BaseBuildContext = BaseBuildContext,\n> {\n readonly [FLUENT_BUILDER_SYMBOL]: true;\n build(context?: C): T;\n peek<K extends keyof T>(key: K): T[K] | undefined;\n has<K extends keyof T>(key: K): boolean;\n}\n\n/**\n * Type-erased asset builder interface for generic asset handling\n */\nexport type AnyAssetBuilder<C extends BaseBuildContext = BaseBuildContext> = {\n readonly [FLUENT_BUILDER_SYMBOL]: true;\n build(context?: C): Asset;\n peek(key: string): unknown;\n has(key: string): boolean;\n};\n\n/**\n * Parameters for creating nested build contexts\n * Used by nested context generators to create child contexts\n */\nexport interface NestedContextParams<C extends BaseBuildContext> {\n readonly parentContext: C;\n readonly parameterName: string;\n readonly index?: number;\n}\n\n/**\n * Function type for custom nested context generation\n * Allows users to customize how child contexts are created\n */\nexport type NestedContextGenerator<C extends BaseBuildContext> = (\n params: NestedContextParams<C>,\n) => C;\n\n/**\n * Metadata about an asset used for ID generation and context tracking\n */\nexport interface AssetMetadata {\n readonly type?: string;\n readonly binding?: string;\n readonly value?: string;\n}\n\n/**\n * Base build context interface containing common fields for all builders\n * Extended by specific builder implementations for custom context needs\n */\nexport interface BaseBuildContext {\n readonly parentId?: string;\n readonly parameterName?: string;\n readonly index?: number;\n readonly branch?: IdBranch;\n readonly nestedContextGenerator?: NestedContextGenerator<BaseBuildContext>;\n readonly assetMetadata?: AssetMetadata;\n readonly [key: string]: unknown;\n}\n\n/**\n * Slot branch for named properties (e.g., \"label\", \"action\")\n * Creates IDs like: parent-label, parent-action\n */\nexport interface SlotBranch {\n type: \"slot\";\n name: string;\n}\n\n/**\n * Array item branch for indexed elements\n * Creates IDs like: parent-0, parent-1\n */\nexport interface ArrayItemBranch {\n type: \"array-item\";\n index: number;\n}\n\n/**\n * Template branch for template placeholders\n * Creates IDs like: parent-_index_, parent-_index1_\n */\nexport interface TemplateBranch {\n type: \"template\";\n depth?: number;\n}\n\n/**\n * Switch branch for conditional cases\n * Creates IDs like: parent-staticSwitch-0, parent-dynamicSwitch-1\n */\nexport interface SwitchBranch {\n type: \"switch\";\n index: number;\n kind: \"static\" | \"dynamic\";\n}\n\n/**\n * Custom branch for user-defined ID patterns\n */\nexport interface CustomBranch {\n type: \"custom\";\n}\n\n/**\n * Union of all branch types for type-safe ID generation\n */\nexport type IdBranch =\n | SlotBranch\n | ArrayItemBranch\n | TemplateBranch\n | SwitchBranch\n | CustomBranch;\n\n/**\n * Metadata for arrays containing mixed static values and builders\n * Tracks which indices contain builders for selective resolution\n */\nexport interface MixedArrayMetadata {\n readonly array: readonly unknown[];\n readonly builderIndices: ReadonlySet<number>;\n readonly objectIndices: ReadonlySet<number>;\n}\n\n/**\n * Metadata for template storage in FluentBuilderBase\n */\nexport interface TemplateMetadata {\n readonly data: string;\n readonly output: string;\n readonly dynamic?: boolean;\n}\n\n/**\n * Path type for targeting where to inject values in nested structures\n * Example: [\"actions\", 0, \"label\"] targets actions[0].label\n */\nexport type ValuePath = ReadonlyArray<string | number>;\n\n/**\n * Metadata for switch storage in FluentBuilderBase\n */\nexport interface SwitchMetadata<C extends BaseBuildContext = BaseBuildContext> {\n readonly path: ValuePath;\n readonly switchFn: (context: C, globalCaseIndex?: number) => unknown;\n}\n\n/**\n * Helper type for conditional property values in if/ifElse methods\n * Allows passing unwrapped Asset builders to AssetWrapper properties\n * Enables: .if(() => true, \"label\", text().withValue(\"...\"))\n * Instead of: .if(() => true, \"label\", { asset: text().withValue(\"...\") })\n */\nexport type ConditionalValue<T, C extends BaseBuildContext> =\n // Case 1: Single AssetWrapper<A> property\n T extends AssetWrapper<infer A> | undefined\n ?\n | T\n | FluentBuilder<T, C>\n | FluentBuilder<A, C>\n | A\n | Array<FluentBuilder<A, C> | A>\n | (() =>\n | T\n | FluentBuilder<T, C>\n | FluentBuilder<A, C>\n | A\n | Array<FluentBuilder<A, C> | A>)\n : // Case 2: Array<AssetWrapper<A>> property\n T extends Array<AssetWrapper<infer A>>\n ?\n | T\n | Array<\n | AssetWrapper<A>\n | FluentBuilder<AssetWrapper<A>, C>\n | FluentBuilder<A, C>\n | A\n >\n | (() =>\n | T\n | Array<\n | AssetWrapper<A>\n | FluentBuilder<AssetWrapper<A>, C>\n | FluentBuilder<A, C>\n | A\n >)\n : // Case 3: Other properties\n T | FluentBuilder<T, C> | (() => T | FluentBuilder<T, C>);\n\n/**\n * Transforms property types to allow TaggedTemplateValue for scalars\n * and FluentBuilder for AssetWrapper properties.\n */\nexport type FluentPartialValue<\n T,\n C extends BaseBuildContext = BaseBuildContext,\n> = T extends string\n ? T | TaggedTemplateValue<string>\n : T extends number\n ? T | TaggedTemplateValue<number>\n : T extends boolean\n ? T | TaggedTemplateValue<boolean>\n : T extends bigint\n ? T | TaggedTemplateValue<bigint>\n : T extends AssetWrapper<infer A>\n ? T | FluentBuilder<A, C> | A\n : T extends Array<AssetWrapper<infer A>>\n ? Array<AssetWrapper<A> | FluentBuilder<A, C> | A>\n : T extends Array<infer E>\n ? Array<FluentPartialValue<E, C>>\n : T extends object\n ? { [K in keyof T]: FluentPartialValue<T[K], C> }\n : T;\n\n/**\n * Partial type for builder constructors that allows TaggedTemplateValue for scalars.\n */\nexport type FluentPartial<T, C extends BaseBuildContext = BaseBuildContext> = {\n [K in keyof T]?: FluentPartialValue<T[K], C>;\n};\n","import type { Asset, AssetWrapper } from \"@player-ui/types\";\nimport type { BaseBuildContext, FluentBuilder } from \"./types\";\nimport { FLUENT_BUILDER_SYMBOL } from \"./types\";\n\n/**\n * Type guard to check if a value is a FluentBuilder instance\n * Checks for the builder symbol and build method\n */\nexport function isFluentBuilder<\n T = unknown,\n C extends BaseBuildContext = BaseBuildContext,\n>(value: unknown): value is FluentBuilder<T, C> {\n if (value === null || typeof value !== \"object\") {\n return false;\n }\n\n if (!(FLUENT_BUILDER_SYMBOL in value)) {\n return false;\n }\n\n const obj = value as Record<symbol | string, unknown>;\n\n return obj[FLUENT_BUILDER_SYMBOL] === true && typeof obj.build === \"function\";\n}\n\n/**\n * Type guard to check if a value is an array of FluentBuilders\n */\nexport function isBuilderArray<\n T = unknown,\n C extends BaseBuildContext = BaseBuildContext,\n>(value: unknown): value is Array<FluentBuilder<T, C>> {\n return Array.isArray(value) && value.every(isFluentBuilder);\n}\n\n/**\n * Type guard to check if a value is a plain object (not a class instance)\n * Returns true for objects created with {} or Object.create(null)\n */\nexport function isPlainObject(\n value: unknown,\n): value is Record<string, unknown> {\n if (!value || typeof value !== \"object\") return false;\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n\n/**\n * Type guard to check if a value is an Asset (has required 'type' property)\n * Assets are the core building blocks in Player UI\n */\nexport function isAsset(value: unknown): value is Asset {\n if (!value || typeof value !== \"object\") return false;\n const obj = value as Record<string, unknown>;\n return \"type\" in obj && typeof obj.type === \"string\";\n}\n\n/**\n * Type guard to check if a value is an AssetWrapper\n * AssetWrapper has a single 'asset' property containing the wrapped value\n */\nexport function isAssetWrapper<T extends Asset = Asset>(\n value: unknown,\n): value is AssetWrapper<T> {\n if (!value || typeof value !== \"object\") return false;\n const obj = value as Record<string, unknown>;\n return \"asset\" in obj && typeof obj.asset === \"object\" && obj.asset !== null;\n}\n\n/**\n * Type guard to check if a value is an AssetWrapper containing an Asset\n * More strict than isAssetWrapper - verifies the wrapped value is actually an Asset\n */\nexport function isAssetWrapperWithAsset<T extends Asset = Asset>(\n value: unknown,\n): value is AssetWrapper<T> {\n return isAssetWrapper(value) && isAsset(value.asset);\n}\n\n/**\n * Type guard to check if a value is an AssetWrapper value object\n * This is the internal representation: { asset: unknown }\n * Used to detect values that need special handling during build\n */\nexport function isAssetWrapperValue(\n value: unknown,\n): value is { asset: unknown } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"asset\" in value &&\n Object.keys(value).length === 1\n );\n}\n\n/**\n * Determines if a property value needs to be wrapped in AssetWrapper format\n * Used during value storage to decide wrapping strategy\n */\nexport function needsAssetWrapper(value: unknown): boolean {\n // Don't wrap if already an AssetWrapper\n if (isAssetWrapper(value)) return false;\n\n // Don't wrap if it's a FluentBuilder (will be resolved later)\n if (isFluentBuilder(value)) return false;\n\n // Wrap if it's an Asset\n return isAsset(value);\n}\n\n/**\n * Type guard to check if a value is a switch result object\n * Switch results contain staticSwitch or dynamicSwitch arrays\n */\nexport function isSwitchResult(value: unknown): value is Record<\n string,\n unknown\n> & {\n staticSwitch?: unknown[];\n dynamicSwitch?: unknown[];\n} {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n const obj = value as Record<string, unknown>;\n return \"staticSwitch\" in obj || \"dynamicSwitch\" in obj;\n}\n\n/**\n * Type guard to check if a value is a string or undefined\n * Useful for validating optional string properties\n */\nexport function isStringOrUndefined(\n value: unknown,\n): value is string | undefined {\n return value === undefined || typeof value === \"string\";\n}\n","/**\n * ID Registry for tracking and ensuring unique IDs across asset generation.\n * This registry maintains a set of used IDs and provides collision resolution\n * by appending numeric suffixes when duplicates are detected.\n *\n * Special handling for template placeholders:\n * - IDs ending with template placeholders like `_index_`, `_row_` are allowed to be duplicated\n * - IDs with placeholders followed by additional segments enforce uniqueness normally\n */\nexport class IDRegistry {\n private usedIds: Set<string>;\n private isEnabled: boolean;\n\n constructor(enabled = true) {\n this.usedIds = new Set<string>();\n this.isEnabled = enabled;\n }\n\n /**\n * Ensures the given ID is unique, modifying it if necessary.\n * If the ID already exists, appends a numeric suffix (-1, -2, etc.)\n * until a unique ID is found.\n *\n * Special handling for template placeholders:\n * - IDs ending with `_index_`, `_row_`, etc. are allowed as duplicates\n * - IDs with placeholders followed by segments (e.g., `_index_.field`) enforce uniqueness\n *\n * @param baseId - The desired ID\n * @returns A unique ID (either the original or modified with suffix)\n *\n * @example\n * ```typescript\n * const registry = new IDRegistry();\n * registry.ensureUnique(\"my-id\"); // \"my-id\"\n * registry.ensureUnique(\"my-id\"); // \"my-id-1\"\n * registry.ensureUnique(\"list-_index_\"); // \"list-_index_\" (allowed duplicate)\n * registry.ensureUnique(\"list-_index_\"); // \"list-_index_\" (allowed duplicate)\n * ```\n */\n ensureUnique(baseId: string): string {\n // If registry is disabled, return the ID as-is\n if (!this.isEnabled) {\n return baseId;\n }\n\n // Check if this ID contains template placeholders\n if (this.isTemplatePlaceholderID(baseId)) {\n // For template placeholder IDs, don't enforce uniqueness\n // These will be replaced at runtime, so duplicates are acceptable\n return baseId;\n }\n\n // If the ID hasn't been used, register and return it\n if (!this.usedIds.has(baseId)) {\n this.usedIds.add(baseId);\n return baseId;\n }\n\n // ID collision detected - append counter until unique\n let counter = 1;\n let uniqueId = `${baseId}-${counter}`;\n\n while (this.usedIds.has(uniqueId)) {\n counter++;\n uniqueId = `${baseId}-${counter}`;\n }\n\n this.usedIds.add(uniqueId);\n return uniqueId;\n }\n\n /**\n * Checks if an ID has already been used.\n *\n * @param id - The ID to check\n * @returns true if the ID has been used, false otherwise\n */\n has(id: string): boolean {\n return this.usedIds.has(id);\n }\n\n /**\n * Clears all registered IDs from the registry.\n * Useful for resetting state between test runs or separate flows.\n */\n reset(): void {\n this.usedIds.clear();\n }\n\n /**\n * Enables or disables the uniqueness checking.\n * When disabled, all IDs pass through unchanged.\n *\n * @param enabled - Whether to enable uniqueness checking\n */\n setEnabled(enabled: boolean): void {\n this.isEnabled = enabled;\n }\n\n /**\n * Returns the number of unique IDs currently registered.\n *\n * @returns The count of registered IDs\n */\n size(): number {\n return this.usedIds.size;\n }\n\n /**\n * Returns a snapshot of all registered IDs.\n * Useful for debugging and testing.\n *\n * @returns An array of all registered IDs\n */\n getRegisteredIds(): string[] {\n return Array.from(this.usedIds);\n }\n\n /**\n * Checks if an ID contains template placeholders that should be exempt from uniqueness checks.\n * Template placeholders are patterns like `_index_`, `_index1_`, `_row_` that are replaced at runtime.\n *\n * IDs ending with just a placeholder (e.g., \"parent-_index_\") are allowed as duplicates.\n * IDs with placeholders followed by additional segments (e.g., \"parent-_index_-field\") are not.\n *\n * @param id - The ID to check\n * @returns true if the ID should be exempt from uniqueness checks\n */\n private isTemplatePlaceholderID(id: string): boolean {\n // Pattern to match template placeholder at the end of an ID\n // Matches: _index_, _index1_, _row_, _item_, etc. at the end of the string\n const templatePlaceholderPattern = /_(?:index|row|item)\\d*_$/;\n return templatePlaceholderPattern.test(id);\n }\n}\n\n/**\n * Global singleton instance of the ID registry.\n * This ensures consistent ID tracking across the entire application.\n */\nexport const globalIdRegistry: IDRegistry = new IDRegistry();\n\n/**\n * Creates a new isolated ID registry instance.\n * Useful for testing or when you need separate ID tracking contexts.\n *\n * @param enabled - Whether the registry should be enabled by default\n * @returns A new IDRegistry instance\n */\nexport function createIdRegistry(enabled = true): IDRegistry {\n return new IDRegistry(enabled);\n}\n","import { globalIdRegistry } from \"./registry\";\nimport {\n BranchTypes,\n type AssetMetadata,\n type BaseBuildContext,\n} from \"../types\";\n\nexport { globalIdRegistry, createIdRegistry, IDRegistry } from \"./registry\";\n\n/**\n * Resets the global ID registry, clearing all registered IDs.\n * This is useful for testing scenarios where you need a clean slate.\n */\nexport const resetGlobalIdSet = (): void => {\n globalIdRegistry.reset();\n};\n\n/**\n * Internal function that generates a base ID from context without registry operations.\n * This is the core ID generation logic shared between peekId and genId.\n *\n * @param context - The context containing parent ID and optional branch information\n * @param functionName - The name of the calling function (for error messages)\n * @returns The generated base ID\n */\nconst _generateBaseId = (\n context: BaseBuildContext,\n functionName: string,\n): string => {\n // Validate context\n if (!context) {\n throw new Error(\n `${functionName}: Context is undefined. Please provide a valid BaseBuildContext object.`,\n );\n }\n\n const { parentId, branch } = context;\n\n let baseId: string;\n\n if (!branch) {\n baseId = parentId || \"\";\n } else {\n switch (branch.type) {\n case \"custom\":\n baseId = parentId || \"\";\n break;\n\n case \"slot\":\n if (!branch.name) {\n throw new Error(\n `${functionName}: Slot branch requires a 'name' property. ` +\n `Context: ${JSON.stringify(context)}`,\n );\n }\n baseId = `${parentId ? `${parentId}-` : \"\"}${branch.name}`;\n break;\n\n case \"array-item\":\n if (typeof branch.index !== \"number\") {\n throw new Error(\n `${functionName}: Array-item branch requires a numeric 'index' property. ` +\n `Got: ${typeof branch.index}. Context: ${JSON.stringify(context)}`,\n );\n }\n if (branch.index < 0) {\n throw new Error(\n `${functionName}: Array-item index must be non-negative. ` +\n `Got: ${branch.index}. Context: ${JSON.stringify(context)}`,\n );\n }\n baseId = `${parentId}-${branch.index}`;\n break;\n\n case \"template\":\n if (branch.depth !== undefined && branch.depth < 0) {\n throw new Error(\n `${functionName}: Template depth must be non-negative. ` +\n `Got: ${branch.depth}. Context: ${JSON.stringify(context)}`,\n );\n }\n baseId = `${parentId}-_index${branch.depth || \"\"}_`;\n break;\n\n case \"switch\":\n if (typeof branch.index !== \"number\") {\n throw new Error(\n `${functionName}: Switch branch requires a numeric 'index' property. ` +\n `Got: ${typeof branch.index}. Context: ${JSON.stringify(context)}`,\n );\n }\n if (branch.index < 0) {\n throw new Error(\n `${functionName}: Switch index must be non-negative. ` +\n `Got: ${branch.index}. Context: ${JSON.stringify(context)}`,\n );\n }\n if (!branch.kind || ![\"static\", \"dynamic\"].includes(branch.kind)) {\n throw new Error(\n `${functionName}: Switch branch requires 'kind' to be 'static' or 'dynamic'. ` +\n `Got: ${branch.kind}. Context: ${JSON.stringify(context)}`,\n );\n }\n baseId = `${parentId}-${branch.kind}Switch-${branch.index}`;\n break;\n\n default: {\n const exhaustiveCheck: never = branch;\n throw new Error(\n `${functionName}: Unhandled branch type: ${JSON.stringify(exhaustiveCheck)}`,\n );\n }\n }\n }\n\n return baseId;\n};\n\n/**\n * Generates an ID without registering it in the global registry.\n * This is useful for intermediate ID lookups where you don't want to consume the ID.\n *\n * @param context - The context containing parent ID and optional branch information\n * @returns The generated ID (without collision detection or registration)\n *\n * @example\n * // Use this when you need to generate a parent ID for nested context creation\n * const parentId = peekId({ parentId: 'collection' }); // Doesn't register 'collection'\n * const nestedCtx = { parentId, branch: { type: 'slot', name: 'label' } };\n */\nexport const peekId = (context: BaseBuildContext): string => {\n return _generateBaseId(context, \"peekId\");\n};\n\n/**\n * Generates a unique identifier based on the parent ID and branch information.\n *\n * This function creates hierarchical IDs for various element types in a DSL structure,\n * maintaining relationships between parent and child elements through consistent naming patterns.\n * IDs are automatically checked for uniqueness and modified if collisions are detected.\n *\n * @param {BaseBuildContext} context - The context containing parent ID and optional branch information\n * @param {string} context.parentId - The ID of the parent element\n * @param {IdBranch} [context.branch] - Optional branch information to specify the type of child element\n *\n * @returns {string} A generated ID string representing the element's unique identifier\n *\n * @throws {Error} If context is invalid or incomplete\n *\n * @example\n * // Slot branch\n * genId({ parentId: 'parent', branch: { type: 'slot', name: 'header' } })\n * // Returns: 'parent-header'\n *\n * @example\n * // Array item branch\n * genId({ parentId: 'list', branch: { type: 'array-item', index: 2 } })\n * // Returns: 'list-2'\n *\n * @example\n * // Template branch\n * genId({ parentId: 'template', branch: { type: 'template', depth: 1 } })\n * // Returns: 'template-_index1_'\n *\n * @example\n * // Switch branch\n * genId({ parentId: 'condition', branch: { type: 'switch', index: 0, kind: 'static' } })\n * // Returns: 'condition-staticSwitch-0'\n *\n * @example\n * // Custom ID case (no branch)\n * genId({ parentId: 'custom-id' })\n * // Returns: 'custom-id'\n */\nexport const genId = (context: BaseBuildContext): string => {\n const baseId = _generateBaseId(context, \"genId\");\n\n const { parentId, branch } = context;\n\n if (process.env.NODE_ENV !== \"production\" && !parentId && !branch) {\n console.warn(\n \"genId: Context appears incomplete (no parentId or branch). \" +\n \"This may result in an empty or invalid ID. \" +\n \"Consider using context helper functions from 'fluent/utils/context'.\",\n );\n }\n\n if (process.env.NODE_ENV !== \"production\" && parentId === \"\") {\n console.warn(\n \"genId: parentId is an empty string. \" +\n \"This may indicate a missing or improperly initialized context.\",\n );\n }\n\n // Ensure the generated ID is unique\n const uniqueId = globalIdRegistry.ensureUnique(baseId);\n\n // Warn if collision was detected\n if (process.env.NODE_ENV !== \"production\" && uniqueId !== baseId) {\n console.warn(\n `genId: ID collision detected. Original: \"${baseId}\", Modified to: \"${uniqueId}\". ` +\n `Consider providing more specific IDs to avoid collisions.`,\n );\n }\n\n return uniqueId;\n};\n\nexport function determineSlotName(\n parameterName: string,\n assetMetadata?: AssetMetadata,\n): string {\n if (!assetMetadata) {\n return parameterName;\n }\n\n const { type, binding, value } = assetMetadata;\n\n // Rule 1: If the asset type is `action`, append last segment of `value` if any\n // Note: value can be a binding (TaggedTemplateValue) or plain string\n if (type === \"action\" && value) {\n const cleanValue = value.replace(/^\\{\\{|\\}\\}$/g, \"\");\n const segments = cleanValue.split(\".\");\n const lastSegment = segments[segments.length - 1];\n return lastSegment ? `${type}-${lastSegment}` : type;\n }\n\n // Rule 2: If it's not `action` but has `binding`, append last fragment of binding\n if (type !== \"action\" && binding) {\n const cleanBinding = binding.replace(/^\\{\\{|\\}\\}$/g, \"\");\n const segments = cleanBinding.split(\".\");\n const lastSegment = segments[segments.length - 1];\n if (lastSegment) {\n return `${type || parameterName}-${lastSegment}`;\n }\n }\n\n // Rule 3: Otherwise, just use the type\n return type || parameterName;\n}\n\nexport function generateAssetId<C extends BaseBuildContext>(params: {\n readonly context?: C;\n readonly parameterName?: string;\n readonly assetMetadata?: AssetMetadata;\n readonly explicitId?: string;\n}): string {\n const {\n context,\n parameterName = \"asset\",\n assetMetadata,\n explicitId,\n } = params;\n\n if (explicitId) {\n return explicitId;\n }\n\n if (context && \"parentId\" in context) {\n // Determine the slot name based on asset metadata (action value, binding, or type)\n const slotName = determineSlotName(parameterName, assetMetadata);\n\n if (context.branch) {\n // When there's a branch, generate base ID then append asset type\n // This creates IDs like \"parent-0-questionAnswer\", \"parent-slot-text\", etc.\n const baseId = genId(context);\n\n // Append the asset type as a suffix\n // Use genId again to ensure uniqueness and proper registration\n return genId({\n ...context,\n parentId: baseId,\n branch: { type: BranchTypes.SLOT, name: slotName },\n } as C);\n }\n\n if (context.parentId) {\n // When there's a parentId but no branch, use slotName (determined from metadata)\n // This creates IDs like \"parent-text\", \"parent-action-next\", \"parent-input-firstName\", etc.\n // Generate and register the ID to enable collision detection\n return genId({\n ...context,\n branch: { type: BranchTypes.SLOT, name: slotName },\n } as C);\n }\n }\n\n const slotName = determineSlotName(parameterName, assetMetadata);\n return slotName;\n}\n","import { determineSlotName, genId, peekId } from \"./id/generator\";\nimport {\n BranchTypes,\n type BaseBuildContext,\n type NestedContextParams,\n type AssetMetadata,\n} from \"./types\";\n\nfunction buildContextParams<C extends BaseBuildContext>(\n parentContext: C,\n parameterName: string,\n index?: number,\n): NestedContextParams<C> {\n const params: NestedContextParams<C> = {\n parentContext,\n parameterName,\n };\n if (index !== undefined) {\n return { ...params, index };\n }\n\n return params;\n}\n\n/**\n * Creates a nested context for child builders with automatic ID generation.\n *\n * 1. Determines the appropriate slot name from the parameter name\n * 2. Generates a unique ID using the slot name\n * 3. Creates a new context with the generated ID\n *\n * Use this when you want automatic ID generation for nested builders.\n * For manual context manipulation, use object spreading directly.\n */\nexport function createNestedContext<C extends BaseBuildContext>({\n parentContext,\n parameterName,\n index,\n assetMetadata,\n}: {\n readonly parentContext: C;\n readonly parameterName: string;\n readonly index?: number;\n readonly assetMetadata?: AssetMetadata;\n}): C {\n if (parentContext.nestedContextGenerator) {\n const contextParams = buildContextParams(\n parentContext,\n parameterName,\n index,\n );\n const generated = parentContext.nestedContextGenerator(contextParams);\n // Safe assertion: nestedContextGenerator returns the same context type\n return generated as C;\n }\n\n const slotName = determineSlotName(parameterName, assetMetadata);\n\n let generatedId: string | undefined;\n let branch: BaseBuildContext[\"branch\"];\n\n if (parentContext && \"parentId\" in parentContext) {\n // For array items, use peekId to avoid registering the same slot multiple times\n // For non-array items, use genId to register the slot\n if (index !== undefined) {\n generatedId = peekId({\n parentId: parentContext.parentId,\n branch: { type: BranchTypes.SLOT, name: slotName },\n });\n branch = { type: BranchTypes.ARRAY_ITEM, index };\n } else {\n generatedId = genId({\n parentId: parentContext.parentId,\n branch: { type: BranchTypes.SLOT, name: slotName },\n });\n }\n }\n\n const newContext: BaseBuildContext =\n index !== undefined\n ? {\n ...parentContext,\n parameterName,\n index,\n ...(generatedId ? { parentId: generatedId } : {}),\n ...(assetMetadata ? { assetMetadata } : {}),\n ...(branch ? { branch } : {}),\n }\n : {\n ...parentContext,\n parameterName,\n ...(generatedId ? { parentId: generatedId } : {}),\n ...(assetMetadata ? { assetMetadata } : {}),\n };\n\n // Safe assertion: newContext extends BaseBuildContext with additional properties\n return newContext as C;\n}\n\n/**\n * Creates a template context for template value generation.\n *\n * Template contexts use a special template branch with depth tracking\n * to support nested templates (_index_, _index1_, _index2_, etc.).\n */\nexport function createTemplateContext<C extends BaseBuildContext>({\n parentContext,\n depth = 0,\n}: {\n readonly parentContext: C;\n readonly depth?: number;\n}): C {\n const parentId = genId(parentContext);\n\n const templateContext: BaseBuildContext = {\n ...parentContext,\n parentId,\n branch: {\n type: BranchTypes.TEMPLATE,\n depth,\n },\n };\n\n return templateContext as C;\n}\n\n/**\n * Creates a switch context for switch case asset generation.\n *\n * Switch contexts use a special switch branch with index tracking and kind\n * to support sequential case indexing across all switches.\n */\nexport function createSwitchContext<C extends BaseBuildContext>({\n parentContext,\n index,\n kind,\n}: {\n readonly parentContext: C;\n readonly index: number;\n readonly kind: \"static\" | \"dynamic\";\n}): C {\n const switchContext: BaseBuildContext = {\n ...parentContext,\n branch: {\n type: BranchTypes.SWITCH,\n index,\n kind,\n },\n };\n\n return switchContext as C;\n}\n","import type { Schema } from \"@player-ui/types\";\n\nexport const TaggedTemplateValueSymbol: unique symbol = Symbol(\n \"TaggedTemplateValue\",\n);\n\nexport interface TemplateRefOptions {\n nestedContext?: \"binding\" | \"expression\";\n}\n\nexport interface TaggedTemplateValue<T = unknown> {\n [TaggedTemplateValueSymbol]: true;\n /** Phantom type marker - not available at runtime */\n readonly _phantomType?: T;\n toValue(): string;\n toRefString(options?: TemplateRefOptions): string;\n toString(): string;\n}\n\nexport function isTaggedTemplateValue(\n value: unknown,\n): value is TaggedTemplateValue {\n return (\n typeof value === \"object\" &&\n value !== null &&\n TaggedTemplateValueSymbol in value\n );\n}\n\n/**\n * Type that converts an object type to a bindable proxy type\n * Each property access returns a TaggedTemplateValue with the correct type\n */\nexport type BindableProxy<T> = {\n readonly [K in keyof T]: T[K] extends unknown[]\n ? TaggedTemplateValue<T[K]> // Arrays become bindings directly\n : T[K] extends object\n ? BindableProxy<T[K]> // Objects become nested proxies\n : TaggedTemplateValue<T[K]>; // Primitives become bindings\n};\n\n/**\n * Maps primitive Schema types to their corresponding TypeScript types\n */\ntype PrimitiveTypeMap = {\n StringType: string;\n NumberType: number;\n BooleanType: boolean;\n};\n\n/**\n * Utility to force TypeScript to fully evaluate a type\n */\ntype Evaluate<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;\n\n/**\n * Check if a type name is primitive\n */\ntype IsPrimitiveType<T extends string> = T extends keyof PrimitiveTypeMap\n ? true\n : false;\n\n/**\n * Convert a primitive type name to its TaggedTemplateValue\n */\ntype PrimitiveToBinding<T extends string> = T extends keyof PrimitiveTypeMap\n ? TaggedTemplateValue<PrimitiveTypeMap[T]>\n : TaggedTemplateValue<string>;\n\n/**\n * Process a single field from a node into its binding representation\n */\ntype ProcessField<\n Field extends Schema.DataTypes,\n S extends Schema.Schema,\n CurrentPath extends string,\n> = Field extends { type: infer TypeName extends string }\n ? Field extends { isArray: true }\n ? // Handle array fields\n IsPrimitiveType<TypeName> extends true\n ? TypeName extends \"StringType\"\n ? { name: PrimitiveToBinding<TypeName> }\n : { value: PrimitiveToBinding<TypeName> }\n : TypeName extends keyof S\n ? S[TypeName] extends Schema.Node\n ? ProcessNodeFields<S[TypeName], S, `${CurrentPath}._current_`>\n : TaggedTemplateValue<string>\n : TaggedTemplateValue<string>\n : // Handle non-array fields\n IsPrimitiveType<TypeName> extends true\n ? PrimitiveToBinding<TypeName>\n : TypeName extends keyof S\n ? S[TypeName] extends Schema.Node\n ? ProcessNodeFields<S[TypeName], S, CurrentPath>\n : TaggedTemplateValue<string>\n : TaggedTemplateValue<string>\n : TaggedTemplateValue<string>;\n\n/**\n * Process all fields in a node\n */\ntype ProcessNodeFields<\n Node extends Schema.Node,\n S extends Schema.Schema,\n BasePath extends string,\n> = Evaluate<{\n [K in keyof Node]: ProcessField<\n Node[K],\n S,\n BasePath extends \"\" ? K & string : `${BasePath}.${K & string}`\n >;\n}>;\n\n/**\n * Main type to extract bindings from a schema\n */\nexport type ExtractedBindings<S extends Schema.Schema> = S extends {\n ROOT: infer RootNode;\n}\n ? RootNode extends Schema.Node\n ? ProcessNodeFields<RootNode, S, \"\">\n : never\n : never;\n","import {\n isTaggedTemplateValue,\n TaggedTemplateValueSymbol,\n type TaggedTemplateValue,\n type TemplateRefOptions,\n} from \"./types\";\n\n/**\n * Tagged template for creating binding expressions with optional type information\n * Used to generate template strings with proper binding syntax\n * @param strings - Template string parts\n * @param expressions - Values to interpolate\n * @returns TaggedTemplateValue with optional phantom type T\n *\n * @example\n * ```typescript\n * // Basic usage (backward compatible)\n * const basicBinding = binding`data.count`;\n *\n * // With phantom type for TypeScript type checking\n * const typedBinding = binding<number>`data.count`;\n * ```\n */\nexport function binding<T = unknown>(\n strings: TemplateStringsArray,\n ...expressions: Array<unknown>\n): TaggedTemplateValue<T> {\n // Index counter for replacements\n let indexCounter = 0;\n\n /**\n * Replaces index placeholders with unique identifiers\n */\n const processValue = (val: string): string => {\n if (!val.includes(\"_index_\")) return val;\n\n return val.replace(/_index_/g, () => {\n const suffix = indexCounter > 0 ? indexCounter : \"\";\n indexCounter++;\n return `_index${suffix}_`;\n });\n };\n\n let result = \"\";\n const len = strings.length;\n\n for (let i = 0; i < len; i++) {\n result += processValue(strings[i]);\n\n if (i < expressions.length) {\n const expr = expressions[i];\n\n if (isTaggedTemplateValue(expr)) {\n const refStr = expr.toRefString();\n if (refStr.startsWith(\"@[\")) {\n // Expression template in binding context\n result += expr.toRefString({ nestedContext: \"binding\" });\n } else {\n // Binding template retains braces\n result += expr.toString();\n }\n } else if (typeof expr === \"string\") {\n // Apply index replacements to string expressions\n result += processValue(expr);\n } else {\n // Convert other values to string\n result += String(expr);\n }\n }\n }\n\n const templateValue: TaggedTemplateValue<T> = {\n [TaggedTemplateValueSymbol]: true,\n _phantomType: undefined as T | undefined,\n\n toValue(): string {\n return result;\n },\n\n toRefString(options?: TemplateRefOptions): string {\n // No additional braces needed in binding context\n if (options?.nestedContext === \"binding\") {\n return result;\n }\n // Add braces in other contexts\n return `{{${result}}}`;\n },\n\n toString(): string {\n return `{{${result}}}`;\n },\n };\n\n return templateValue;\n}\n","import {\n isTaggedTemplateValue,\n TaggedTemplateValueSymbol,\n type TaggedTemplateValue,\n type TemplateRefOptions,\n} from \"./types\";\n\n/**\n * Tagged template for creating expression literals\n * Used for generating expressions with proper validation and formatting\n * @param strings - Template string parts\n * @param expressions - Values to interpolate\n * @returns TaggedTemplateValue with expression context\n * @throws Error if expression syntax is invalid\n */\nexport function expression<T = unknown>(\n strings: TemplateStringsArray,\n ...expressions: Array<unknown>\n): TaggedTemplateValue<T> {\n /**\n * Validates expression syntax with balanced parentheses\n * @throws Error if parentheses are unbalanced\n */\n const validateSyntax = (expr: string): void => {\n let openParens = 0;\n // Use position counter to match original behavior exactly\n let position = 0;\n\n // Validation loop using position counter\n for (const char of expr) {\n if (char === \"(\") openParens++;\n if (char === \")\") openParens--;\n position++;\n\n if (openParens < 0) {\n throw new Error(\n `Error: Unexpected ) at character ${position} in expression: \\n ${expr.slice(\n 0,\n position,\n )}█${expr.slice(position)}`,\n );\n }\n }\n\n if (openParens > 0) {\n throw new Error(\n `Error: Expected ) at character ${position} in expression: \\n ${expr}█`,\n );\n }\n };\n\n let result = \"\";\n const len = strings.length;\n\n for (let i = 0; i < len; i++) {\n result += strings[i];\n\n if (i < expressions.length) {\n const expr = expressions[i];\n if (isTaggedTemplateValue(expr)) {\n // Use appropriate reference formatting for nested templates\n result += expr.toRefString({ nestedContext: \"expression\" });\n } else {\n // Convert other values to string\n result += String(expr);\n }\n }\n }\n\n validateSyntax(result);\n\n return {\n [TaggedTemplateValueSymbol]: true,\n\n toValue(): string {\n return result;\n },\n\n toRefString(options?: TemplateRefOptions): string {\n if (options?.nestedContext === \"binding\") {\n return `\\`${result}\\``;\n } else if (options?.nestedContext === \"expression\") {\n return result;\n }\n return `@[${result}]@`;\n },\n\n toString(): string {\n return `@[${result}]@`;\n },\n };\n}\n","import type { Schema } from \"@player-ui/types\";\nimport { binding } from \"./binding\";\nimport type { TaggedTemplateValue, ExtractedBindings } from \"./types\";\n\n/**\n * Runtime implementation that builds the actual object structure\n */\nexport function extractBindingsFromSchema<const S extends Schema.Schema>(\n schema: S,\n): ExtractedBindings<S> {\n const primitiveTypes = new Set([\"StringType\", \"NumberType\", \"BooleanType\"]);\n\n const isPrimitive = (typeName: string): boolean => {\n return primitiveTypes.has(typeName);\n };\n\n const createBinding = (\n typeName: string,\n path: string,\n ): TaggedTemplateValue<unknown> => {\n if (typeName === \"StringType\") {\n return binding<string>`${path}`;\n }\n if (typeName === \"NumberType\") {\n return binding<number>`${path}`;\n }\n if (typeName === \"BooleanType\") {\n return binding<boolean>`${path}`;\n }\n return binding<string>`${path}`;\n };\n\n const processDataType = (\n dataType: Schema.DataTypes,\n schema: Schema.Schema,\n path: string,\n visited: Set<string> = new Set(),\n ): TaggedTemplateValue<unknown> | Record<string, unknown> => {\n const typeName = dataType.type;\n\n // Prevent infinite recursion\n if (visited.has(typeName)) {\n return createBinding(\"StringType\", path);\n }\n\n // Handle arrays\n if (\"isArray\" in dataType && dataType.isArray) {\n const arrayPath = path ? `${path}._current_` : \"_current_\";\n\n if (isPrimitive(typeName)) {\n // Special handling for primitive arrays\n if (typeName === \"StringType\") {\n return { name: createBinding(typeName, arrayPath) };\n } else {\n return { value: createBinding(typeName, arrayPath) };\n }\n } else {\n const typeNode = schema[typeName];\n if (typeNode) {\n const newVisited = new Set(visited);\n newVisited.add(typeName);\n return processNode(\n typeNode as Schema.Node,\n schema,\n arrayPath,\n newVisited,\n );\n }\n return createBinding(\"StringType\", arrayPath);\n }\n }\n\n // Handle records\n if (\"isRecord\" in dataType && dataType.isRecord) {\n const typeNode = schema[typeName];\n if (typeNode) {\n const newVisited = new Set(visited);\n newVisited.add(typeName);\n return processNode(typeNode as Schema.Node, schema, path, newVisited);\n }\n return createBinding(\"StringType\", path);\n }\n\n // Handle primitives\n if (isPrimitive(typeName)) {\n return createBinding(typeName, path);\n }\n\n // Handle complex types\n const typeNode = schema[typeName];\n if (typeNode) {\n const newVisited = new Set(visited);\n newVisited.add(typeName);\n return processNode(typeNode as Schema.Node, schema, path, newVisited);\n }\n\n // Fallback\n return createBinding(\"StringType\", path);\n };\n\n const processNode = (\n node: Schema.Node,\n schema: Schema.Schema,\n basePath: string,\n visited: Set<string> = new Set(),\n ): Record<string, unknown> => {\n const result: Record<string, unknown> = {};\n\n // Process each property in the node\n Object.entries(node).forEach(([key, dataType]) => {\n const path = basePath ? `${basePath}.${key}` : key;\n result[key] = processDataType(dataType, schema, path, visited);\n });\n\n return result;\n };\n\n // Start processing from ROOT\n return processNode(schema.ROOT, schema, \"\") as ExtractedBindings<S>;\n}\n","import { isTaggedTemplateValue, type TaggedTemplateValue } from \"./types\";\nimport { expression } from \"./expression\";\n\n/**\n * Type-safe standard library of expressions for the Player-UI DSL\n * Provides common logical, comparison, and arithmetic operations with full TypeScript type safety\n * using phantom types from TaggedTemplateValue.\n */\n\n// ============================================================================\n// Logical Operations\n// ============================================================================\n\n/**\n * Logical AND operation - returns true if all arguments are truthy\n * @param args - Values or bindings to evaluate with AND logic\n * @returns TaggedTemplateValue<boolean> representing the AND expression\n */\nexport function and(\n ...args: Array<TaggedTemplateValue<unknown> | boolean | string | number>\n): TaggedTemplateValue<boolean> {\n const expressions = args.map((arg) => {\n if (isTaggedTemplateValue(arg)) {\n const expr = arg.toRefString({ nestedContext: \"expression\" });\n // Wrap OR expressions in parentheses to maintain proper precedence\n // (AND has higher precedence than OR)\n if (expr.includes(\" || \") && !expr.startsWith(\"(\")) {\n return `(${expr})`;\n }\n return expr;\n }\n return String(arg);\n });\n\n return expression`${expressions.join(\" && \")}`;\n}\n\n/**\n * Logical OR operation - returns true if any argument is truthy\n * @param args - Values or bindings to evaluate with OR logic\n * @returns TaggedTemplateValue<boolean> representing the OR expression\n */\nexport function or(\n ...args: Array<TaggedTemplateValue<unknown> | boolean | string | number>\n): TaggedTemplateValue<boolean> {\n const expressions = args.map((arg) => {\n if (isTaggedTemplateValue(arg)) {\n return arg.toRefString({ nestedContext: \"expression\" });\n }\n return String(arg);\n });\n\n return expression`${expressions.join(\" || \")}`;\n}\n\n/**\n * Logical NOT operation - returns true if argument is falsy\n * @param value - Value or binding to negate\n * @returns TaggedTemplateValue<boolean> representing the NOT expression\n */\nexport function not(\n value: TaggedTemplateValue<unknown> | boolean | string | number,\n): TaggedTemplateValue<boolean> {\n const expr = isTaggedTemplateValue(value)\n ? value.toRefString({ nestedContext: \"expression\" })\n : String(value);\n\n return expression`!${expr}`;\n}\n\n/**\n * Logical NOR operation - returns true if all arguments are falsy\n * @param args - Values or bindings to evaluate with NOR logic\n * @returns TaggedTemplateValue<boolean> representing the NOR expression\n */\nexport function nor(\n ...args: Array<TaggedTemplateValue<unknown> | boolean | string | number>\n): TaggedTemplateValue<boolean> {\n return not(or(...args));\n}\n\n/**\n * Logical NAND operation - returns false if all arguments are truthy\n * @param args - Values or bindings to evaluate with NAND logic\n * @returns TaggedTemplateValue<boolean> representing the NAND expression\n */\nexport function nand(\n ...args: Array<TaggedTemplateValue<unknown> | boolean | string | number>\n): TaggedTemplateValue<boolean> {\n return not(and(...args));\n}\n\n/**\n * Logical XOR operation - returns true if exactly one argument is truthy\n * @param left - First value to compare\n * @param right - Second value to compare\n * @returns TaggedTemplateValue<boolean> representing the XOR expression\n */\nexport function xor(\n left: TaggedTemplateValue<unknown> | boolean | string | number,\n right: TaggedTemplateValue<unknown> | boolean | string | number,\n): TaggedTemplateValue<boolean> {\n const leftExpr = isTaggedTemplateValue(left)\n ? left.toRefString({ nestedContext: \"expression\" })\n : String(left);\n const rightExpr = isTaggedTemplateValue(right)\n ? right.toRefString({ nestedContext: \"expression\" })\n : String(right);\n\n return expression`(${leftExpr} && !${rightExpr}) || (!${leftExpr} && ${rightExpr})`;\n}\n\n// ============================================================================\n// Comparison Operations\n// ============================================================================\n\n/**\n * Equality comparison (loose equality ==)\n * @param left - First value to compare\n * @param right - Second value to compare\n * @returns TaggedTemplateValue<boolean> representing the equality expression\n */\nexport function equal<T>(\n left: TaggedTemplateValue<T> | T,\n right: TaggedTemplateValue<T> | T,\n): TaggedTemplateValue<boolean> {\n const leftExpr = isTaggedTemplateValue(left)\n ? left.toRefString({ nestedContext: \"expression\" })\n : JSON.stringify(left);\n const rightExpr = isTaggedTemplateValue(right)\n ? right.toRefString({ nestedContext: \"expression\" })\n : JSON.stringify(right);\n\n return expression`${leftExpr} == ${rightExpr}`;\n}\n\n/**\n * Strict equality comparison (===)\n * @param left - First value to compare\n * @param right - Second value to compare\n * @returns TaggedTemplateValue<boolean> representing the strict equality expression\n */\nexport function strictEqual<T>(\n left: TaggedTemplateValue<T> | T,\n right: TaggedTemplateValue<T> | T,\n): TaggedTemplateValue<boolean> {\n const leftExpr = isTaggedTemplateValue(left)\n ? left.toRefString({ nestedContext: \"expression\" })\n : JSON.stringify(left);\n const rightExpr = isTaggedTemplateValue(right)\n ? right.toRefString({ nestedContext: \"expression\" })\n : JSON.stringify(right);\n\n return expression`${leftExpr} === ${rightExpr}`;\n}\n\n/**\n * Inequality comparison (!=)\n * @param left - First value to compare\n * @param right - Second value to compare\n * @returns TaggedTemplateValue<boolean> representing the inequality expression\n */\nexport function notEqual<T>(\n left: TaggedTemplateValue<T> | T,\n right: TaggedTemplateValue<T> | T,\n): TaggedTemplateValue<boolean> {\n const leftExpr = isTaggedTemplateValue(left)\n ? left.toRefString({ nestedContext: \"expression\" })\n : JSON.stringify(left);\n const rightExpr = isTaggedTemplateValue(right)\n ? right.toRefString({ nestedContext: \"expression\" })\n : JSON.stringify(right);\n\n return expression`${leftExpr} != ${rightExpr}`;\n}\n\n/**\n * Strict inequality comparison (!==)\n * @param left - First value to compare\n * @param right - Second value to compare\n * @returns TaggedTemplateValue<boolean> representing the strict inequality expression\n */\nexport function strictNotEqual<T>(\n left: TaggedTemplateValue<T> | T,\n right: TaggedTemplateValue<T> | T,\n): TaggedTemplateValue<boolean> {\n const leftExpr = isTaggedTemplateValue(left)\n ? left.toRefString({ nestedContext: \"expression\" })\n : JSON.stringify(left);\n const rightExpr = isTaggedTemplateValue(right)\n ? right.toRefString({ nestedContext: \"expression\" })\n : JSON.stringify(right);\n\n return expression`${leftExpr} !== ${rightExpr}`;\n}\n\n/**\n * Greater than comparison (>)\n * @param left - First value to compare\n * @param right - Second value to compare\n * @returns TaggedTemplateValue<boolean> representing the greater than expression\n */\nexport function greaterThan<T extends number | string>(\n left: TaggedTemplateValue<T> | T,\n right: TaggedTemplateValue<T> | T,\n): TaggedTemplateValue<boolean> {\n const leftExpr = isTaggedTemplateValue(left)\n ? left.toRefString({ nestedContext: \"expression\" })\n : JSON.stringify(left);\n const rightExpr = isTaggedTemplateValue(right)\n ? right.toRefString({ nestedContext: \"expression\" })\n : JSON.stringify(right);\n\n return expression`${leftExpr} > ${rightExpr}`;\n}\n\n/**\n * Greater than or equal comparison (>=)\n * @param left - First value to compare\n * @param right - Second value to compare\n * @returns TaggedTemplateValue<boolean> representing the greater than or equal expression\n */\nexport function greaterThanOrEqual<T extends number | string>(\n left: TaggedTemplateValue<T> | T,\n right: TaggedTemplateValue<T> | T,\n): TaggedTemplateValue<boolean> {\n const leftExpr = isTaggedTemplateValue(left)\n ? left.toRefString({ nestedContext: \"expression\" })\n : JSON.stringify(left);\n const rightExpr = isTaggedTemplateValue(right)\n ? right.toRefString({ nestedContext: \"expression\" })\n : JSON.stringify(right);\n\n return expression`${leftExpr} >= ${rightExpr}`;\n}\n\n/**\n * Less than comparison (<)\n * @param left - First value to compare\n * @param right - Second value to compare\n * @returns TaggedTemplateValue<boolean> representing the less than expression\n */\nexport function lessThan<T extends number | string>(\n left: TaggedTemplateValue<T> | T,\n right: TaggedTemplateValue<T> | T,\n): TaggedTemplateValue<boolean> {\n const leftExpr = isTaggedTemplateValue(left)\n ? left.toRefString({ nestedContext: \"expression\" })\n : JSON.stringify(left);\n const rightExpr = isTaggedTemplateValue(right)\n ? right.toRefString({ nestedContext: \"expression\" })\n : JSON.stringify(right);\n\n return expression`${leftExpr} < ${rightExpr}`;\n}\n\n/**\n * Less than or equal comparison (<=)\n * @param left - First value to compare\n * @param right - Second value to compare\n * @returns TaggedTemplateValue<boolean> representing the less than or equal expression\n */\nexport function lessThanOrEqual<T extends number | string>(\n left: TaggedTemplateValue<T> | T,\n right: TaggedTemplateValue<T> | T,\n): TaggedTemplateValue<boolean> {\n const leftExpr = isTaggedTemplateValue(left)\n ? left.toRefString({ nestedContext: \"expression\" })\n : JSON.stringify(left);\n const rightExpr = isTaggedTemplateValue(right)\n ? right.toRefString({ nestedContext: \"expression\" })\n : JSON.stringify(right);\n\n return expression`${leftExpr} <= ${rightExpr}`;\n}\n\n// ============================================================================\n// Arithmetic Operations\n// ============================================================================\n\n/**\n * Addition operation (+)\n * @param args - Values or bindings to add together\n * @returns TaggedTemplateValue<number> representing the addition expression\n */\nexport function add(\n ...args: Array<TaggedTemplateValue<number> | number>\n): TaggedTemplateValue<number> {\n const expressions = args.map((arg) => {\n if (isTaggedTemplateValue(arg)) {\n return arg.toRefString({ nestedContext: \"expression\" });\n }\n return String(arg);\n });\n\n return expression`${expressions.join(\" + \")}` as TaggedTemplateValue<number>;\n}\n\n/**\n * Subtraction operation (-)\n * @param left - Value to subtract from\n * @param right - Value to subtract\n * @returns TaggedTemplateValue<number> representing the subtraction expression\n */\nexport function subtract(\n left: TaggedTemplateValue<number> | number,\n right: TaggedTemplateValue<number> | number,\n): TaggedTemplateValue<number> {\n const leftExpr = isTaggedTemplateValue(left)\n ? left.toRefString({ nestedContext: \"expression\" })\n : String(left);\n const rightExpr = isTaggedTemplateValue(right)\n ? right.toRefString({ nestedContext: \"expression\" })\n : String(right);\n\n return expression`${leftExpr} - ${rightExpr}` as TaggedTemplateValue<number>;\n}\n\n/**\n * Multiplication operation (*)\n * @param args - Values or bindings to multiply together\n * @returns TaggedTemplateValue<number> representing the multiplication expression\n */\nexport function multiply(\n ...args: Array<TaggedTemplateValue<number> | number>\n): TaggedTemplateValue<number> {\n const expressions = args.map((arg) => {\n if (isTaggedTemplateValue(arg)) {\n return arg.toRefString({ nestedContext: \"expression\" });\n }\n return String(arg);\n });\n\n return expression`${expressions.join(\" * \")}` as TaggedTemplateValue<number>;\n}\n\n/**\n * Division operation (/)\n * @param left - Dividend\n * @param right - Divisor\n * @returns TaggedTemplateValue<number> representing the division expression\n */\nexport function divide(\n left: TaggedTemplateValue<number> | number,\n right: TaggedTemplateValue<number> | number,\n): TaggedTemplateValue<number> {\n const leftExpr = isTaggedTemplateValue(left)\n ? left.toRefString({ nestedContext: \"expression\" })\n : String(left);\n const rightExpr = isTaggedTemplateValue(right)\n ? right.toRefString({ nestedContext: \"expression\" })\n : String(right);\n\n return expression`${leftExpr} / ${rightExpr}` as TaggedTemplateValue<number>;\n}\n\n/**\n * Modulo operation (%)\n * @param left - Dividend\n * @param right - Divisor\n * @returns TaggedTemplateValue<number> representing the modulo expression\n */\nexport function modulo(\n left: TaggedTemplateValue<number> | number,\n right: TaggedTemplateValue<number> | number,\n): TaggedTemplateValue<number> {\n const leftExpr = isTaggedTemplateValue(left)\n ? left.toRefString({ nestedContext: \"expression\" })\n : String(left);\n const rightExpr = isTaggedTemplateValue(right)\n ? right.toRefString({ nestedContext: \"expression\" })\n : String(right);\n\n return expression`${leftExpr} % ${rightExpr}` as TaggedTemplateValue<number>;\n}\n\n// ============================================================================\n// Control Flow Operations\n// ============================================================================\n\n/**\n * Conditional (ternary) operation - if-then-else logic\n * @param condition - Condition to evaluate\n * @param ifTrue - Value to return if condition is truthy\n * @param ifFalse - Value to return if condition is falsy\n * @returns TaggedTemplateValue<T> representing the conditional expression\n */\nexport function conditional<T>(\n condition: TaggedTemplateValue<boolean> | boolean,\n ifTrue: TaggedTemplateValue<T> | T,\n ifFalse: TaggedTemplateValue<T> | T,\n): TaggedTemplateValue<T> {\n const conditionExpr = isTaggedTemplateValue(condition)\n ? condition.toRefString({ nestedContext: \"expression\" })\n : String(condition);\n\n const trueExpr = isTaggedTemplateValue(ifTrue)\n ? ifTrue.toRefString({ nestedContext: \"expression\" })\n : JSON.stringify(ifTrue);\n\n const falseExpr = isTaggedTemplateValue(ifFalse)\n ? ifFalse.toRefString({ nestedContext: \"expression\" })\n : JSON.stringify(ifFalse);\n\n return expression`${conditionExpr} ? ${trueExpr} : ${falseExpr}` as TaggedTemplateValue<T>;\n}\n\n/**\n * Function call expression\n * @param functionName - Name of the function to call\n * @param args - Arguments to pass to the function\n * @returns TaggedTemplateValue<T> representing the function call expression\n */\nexport function call<T = unknown>(\n functionName: string,\n ...args: Array<TaggedTemplateValue<unknown> | unknown>\n): TaggedTemplateValue<T> {\n const argExpressions = args.map((arg) => {\n if (isTaggedTemplateValue(arg)) {\n return arg.toRefString({\n nestedContext: \"expression\",\n });\n }\n return JSON.stringify(arg);\n });\n\n return expression`${functionName}(${argExpressions.join(\", \")})` as TaggedTemplateValue<T>;\n}\n\n// ============================================================================\n// Type Utilities\n// ============================================================================\n\n/**\n * Creates a literal value expression\n * @param value - Literal value to create expression for\n * @returns TaggedTemplateValue<T> representing the literal\n */\nexport function literal<T>(value: T): TaggedTemplateValue<T> {\n return expression`${JSON.stringify(value)}` as TaggedTemplateValue<T>;\n}\n// ============================================================================\n// Shorthand Aliases\n// ============================================================================\n\n// Logical operations aliases\nexport { and as AND };\nexport { or as OR };\nexport { not as NOT };\nexport { nor as NOR };\nexport { nand as NAND };\nexport { xor as XOR };\n\n// Comparison operations aliases\nexport { equal as eq };\nexport { strictEqual as strictEq };\nexport { notEqual as neq };\nexport { strictNotEqual as strictNeq };\nexport { greaterThan as gt };\nexport { greaterThanOrEqual as gte };\nexport { lessThan as lt };\nexport { lessThanOrEqual as lte };\n\n// Arithmetic operations aliases\nexport { add as plus };\nexport { subtract as minus };\nexport { multiply as times };\nexport { divide as div };\nexport { modulo as mod };\n\n// Control flow aliases\nexport { conditional as ternary, conditional as ifElse };\n","import type { Asset, AssetWrapper } from \"@player-ui/types\";\nimport { BranchTypes, type BaseBuildContext } from \"../types\";\nimport {\n isFluentBuilder,\n isPlainObject,\n isAsset,\n isAssetWrapper,\n} from \"../guards\";\nimport { createNestedContext } from \"../context\";\nimport { genId, peekId } from \"../id/generator\";\nimport { isTaggedTemplateValue } from \"../../tagged-template\";\n\n/**\n * Type-safe value extraction utilities for handling TaggedTemplateValue\n * These functions properly unwrap TaggedTemplateValue while preserving structure\n */\n\ninterface ExtractValueOptions {\n readonly propertyKey?: string;\n readonly visited?: WeakSet<object>;\n}\n\n/**\n * Recursively extracts values from an object, handling nested TaggedTemplateValue instances\n */\nfunction extractObject<T extends Record<string, unknown>>(\n value: T,\n options: ExtractValueOptions,\n): T {\n const visited = options.visited ?? new WeakSet();\n\n if (visited.has(value)) {\n return value;\n }\n visited.add(value);\n\n const result: Record<string, unknown> = {};\n\n for (const [key, val] of Object.entries(value)) {\n result[key] = extractValue(val, { propertyKey: key, visited });\n }\n\n return result as T;\n}\n\n/**\n * Recursively extracts values from a structure, converting TaggedTemplateValue instances\n * to their string representations while preserving arrays and objects.\n *\n * **Return Type Note**: This function returns `unknown` because the input type is unknown\n * and the transformation can change types (TaggedTemplateValue -> string). Callers should\n * validate the returned value using type guards before using it.\n *\n * **Transformation Behavior**:\n * - `TaggedTemplateValue` → `string` (via toString() or toValue())\n * - Arrays → Arrays (elements recursively transformed)\n * - Plain objects → Objects (properties recursively transformed)\n * - FluentBuilder/AssetWrapper → passed through unchanged (resolved later)\n * - Primitives → passed through unchanged\n *\n * @param value - The value to extract (may contain TaggedTemplateValue instances)\n * @param options - Extraction options (propertyKey for special handling, visited for cycle detection)\n * @returns The extracted value with TaggedTemplateValue instances converted to strings\n *\n * @example\n * ```typescript\n * const result = extractValue({ name: taggedTemplate`Hello` });\n * // result is { name: \"Hello\" } but typed as unknown\n *\n * // Caller must validate:\n * if (isPlainObject(result)) {\n * const name = result.name; // Use safely\n * }\n * ```\n */\nexport function extractValue(\n value: unknown,\n options: ExtractValueOptions = {},\n): unknown {\n const { propertyKey, visited = new WeakSet() } = options;\n\n // Handle TaggedTemplateValue\n if (isTaggedTemplateValue(value)) {\n // Special case: 'data' property (in templates) and 'binding' property should use toValue() to get raw string\n if (propertyKey === \"data\" || propertyKey === \"binding\") {\n return value.toValue();\n }\n // Default: use toString() to preserve expression/binding syntax (@[]@ and {{}})\n return value.toString();\n }\n\n // Handle arrays - recursively extract each element\n if (Array.isArray(value)) {\n if (visited.has(value)) {\n return value;\n }\n visited.add(value);\n // Don't pass propertyKey down to array elements\n return value.map((item) => extractValue(item, { visited }));\n }\n\n // Handle plain objects - recursively extract each property\n // But skip FluentBuilders and AssetWrappers (they'll be resolved later)\n if (\n isPlainObject(value) &&\n !isFluentBuilder(value) &&\n !isAssetWrapper(value)\n ) {\n return extractObject(value as Record<string, unknown>, { visited });\n }\n\n // Return primitives and special objects as-is\n return value;\n}\n\n/**\n * Creates an AssetWrapper for a nested asset\n */\nfunction wrapAsset<T extends Asset, C extends BaseBuildContext>(\n asset: T,\n context: C | undefined,\n slotName: string,\n): AssetWrapper<T> {\n if (!context) {\n return { asset };\n }\n\n // If asset already has an ID, preserve it\n // User-provided IDs should be respected\n if (asset.id) {\n return { asset: { ...asset } };\n }\n\n // Generate ID using slot branch for assets without IDs\n const parentId = peekId(context);\n const slotCtx: BaseBuildContext = {\n parentId,\n branch: { type: BranchTypes.SLOT, name: slotName },\n };\n\n return {\n asset: {\n ...asset,\n id: genId(slotCtx),\n },\n };\n}\n\ninterface ResolveValueOptions<C extends BaseBuildContext = BaseBuildContext> {\n readonly context?: C;\n readonly propertyName?: string;\n readonly visited?: WeakSet<object>;\n}\n\n/**\n * Resolves a value, handling FluentBuilders, AssetWrappers, and nested structures\n */\nexport function resolveValue<T, C extends BaseBuildContext>(\n value: unknown,\n options: ResolveValueOptions<C> = {},\n): unknown {\n const { context, propertyName, visited = new WeakSet() } = options;\n\n // Handle TaggedTemplateValue\n if (isTaggedTemplateValue(value)) {\n // Special case: 'data' property (in templates) and 'binding' property should use toValue() to get raw string\n if (propertyName === \"data\" || propertyName === \"binding\") {\n return value.toValue();\n }\n // Default: use toString() to preserve expression/binding syntax (@[]@ and {{}})\n return value.toString();\n }\n\n // Skip null or undefined values\n if (value === null || value === undefined) {\n return value;\n }\n\n // Handle FluentBuilder instances\n if (isFluentBuilder<T, C>(value)) {\n return value.build(context);\n }\n\n // Handle AssetWrapper types - unwrap, resolve inner asset, and re-wrap\n if (isAssetWrapper(value)) {\n if (visited.has(value)) return value;\n visited.add(value);\n\n const innerAsset = value.asset;\n\n // Resolve the inner asset if it's a builder or contains nested structures\n const resolvedAsset = resolveValue(innerAsset, {\n context,\n propertyName,\n visited,\n });\n\n // Return wrapped with the resolved asset\n return { asset: resolvedAsset };\n }\n\n // Handle arrays - recursively resolve each element\n if (Array.isArray(value)) {\n if (visited.has(value)) return value;\n visited.add(value);\n\n // Filter out null/undefined values before processing\n return value\n .filter((item) => item !== null && item !== undefined)\n .map((item, index) => {\n const arrayContext = context\n ? createNestedContext({\n parentContext: context,\n parameterName: propertyName || \"array\",\n index,\n })\n : undefined;\n return resolveValue(item, {\n context: arrayContext,\n propertyName: String(index),\n visited,\n });\n });\n }\n\n // Handle plain objects (but not Assets - they should be terminal)\n if (isPlainObject(value) && !isAsset(value)) {\n if (visited.has(value)) return value;\n visited.add(value);\n\n const resolved: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value)) {\n const nestedContext = context\n ? createNestedContext({ parentContext: context, parameterName: key })\n : undefined;\n resolved[key] = resolveValue(val, {\n context: nestedContext,\n propertyName: key,\n visited,\n });\n }\n\n return resolved;\n }\n\n return value;\n}\n\ninterface ResolveAndWrapAssetOptions<\n C extends BaseBuildContext = BaseBuildContext,\n> {\n readonly context?: C;\n readonly slotName: string;\n readonly visited?: WeakSet<object>;\n}\n\n/**\n * Resolves and wraps a nested asset value\n * This is used when we know a property should contain an AssetWrapper\n */\nexport function resolveAndWrapAsset<C extends BaseBuildContext>(\n value: unknown,\n options: ResolveAndWrapAssetOptions<C>,\n): AssetWrapper<Asset> | unknown {\n const { context, slotName, visited = new WeakSet() } = options;\n\n // Skip null or undefined values\n if (value === null || value === undefined) {\n return value;\n }\n\n // If it's already an AssetWrapper, just resolve its contents\n if (isAssetWrapper(value)) {\n if (visited.has(value)) return value;\n visited.add(value);\n\n const resolvedAsset = resolveValue(value.asset, {\n context,\n propertyName: slotName,\n visited,\n });\n return { asset: resolvedAsset };\n }\n\n // If it's a FluentBuilder, we need to call it with a context that has a slot branch\n // This ensures the built asset gets the correct ID based on the slot name\n if (isFluentBuilder(value)) {\n if (!context) {\n // Without context, just build and wrap\n const built = value.build(undefined);\n if (isAssetWrapper(built)) {\n return built;\n }\n // Only wrap if it's an Asset (has type field)\n if (isAsset(built)) {\n return { asset: built };\n }\n return built;\n }\n\n // Create a context with a slot branch for the builder.\n // We use peekId to get the parent's ID without registering it, then create\n // a slot branch context so the builder generates an ID like \"parent-slotName\".\n const parentId = peekId(context);\n const slotContext: C = {\n ...context,\n parentId,\n branch: { type: BranchTypes.SLOT, name: slotName },\n } as C;\n\n const built = value.build(slotContext);\n\n // If the builder produces an AssetWrapper, return it\n if (isAssetWrapper(built)) {\n return built;\n }\n\n // Only wrap if it's an Asset (has type field)\n if (isAsset(built)) {\n return { asset: built };\n }\n\n // Otherwise return as-is (for non-Asset objects like ChoiceItem)\n return built;\n }\n\n // If it's an Asset, wrap it\n if (isAsset(value)) {\n return wrapAsset(value, context, slotName);\n }\n\n return resolveValue(value, { context, propertyName: slotName, visited });\n}\n","import type {\n BaseBuildContext,\n FluentBuilder,\n MixedArrayMetadata,\n} from \"../types\";\nimport { isFluentBuilder } from \"../guards\";\n\n/**\n * Manages storage for builder property values\n *\n * Values are stored in three different maps based on their type:\n * - values: Static values (strings, numbers, plain objects without builders)\n * - builders: FluentBuilder instances and objects containing builders\n * - mixedArrays: Arrays containing both static values and builders\n *\n * This separation allows efficient resolution during the build process\n */\nexport class ValueStorage<T> {\n private values: Partial<T> = {};\n private builders: Map<\n string,\n FluentBuilder<unknown, BaseBuildContext> | Record<string, unknown>\n > = new Map();\n private mixedArrays: Map<string, MixedArrayMetadata> = new Map();\n\n constructor(initial?: Partial<T>) {\n if (initial) {\n Object.entries(initial).forEach(([key, value]) => {\n this.set(key as keyof T, value);\n });\n }\n }\n\n /**\n * Sets a property value, intelligently routing it to the appropriate storage\n *\n * This method performs runtime type checking to determine how to store the value:\n * - FluentBuilder instances → builders Map\n * - Arrays with builders → mixedArrays Map\n * - Objects with builders → builders Map\n * - Everything else → values (static storage)\n */\n set<K extends keyof T>(key: K, value: unknown): void {\n const keyStr = String(key);\n\n if (isFluentBuilder(value)) {\n this.builders.set(keyStr, value);\n delete this.values[key];\n this.mixedArrays.delete(keyStr);\n } else if (Array.isArray(value)) {\n this.handleArrayValue(key, keyStr, value);\n } else if (\n typeof value === \"object\" &&\n value !== null &&\n this.containsBuilder(value)\n ) {\n this.builders.set(keyStr, value as Record<string, unknown>);\n delete this.values[key];\n this.mixedArrays.delete(keyStr);\n } else {\n this.setStaticValue(key, keyStr, value);\n }\n }\n\n /**\n * Handles array value storage, detecting mixed arrays with builders\n */\n private handleArrayValue<K extends keyof T>(\n key: K,\n keyStr: string,\n value: readonly unknown[],\n ): void {\n const builderIndices = new Set<number>();\n const objectIndices = new Set<number>();\n\n value.forEach((item, index) => {\n if (isFluentBuilder(item)) {\n builderIndices.add(index);\n } else if (\n typeof item === \"object\" &&\n item !== null &&\n this.containsBuilder(item)\n ) {\n objectIndices.add(index);\n }\n });\n\n const hasBuilders = builderIndices.size > 0 || objectIndices.size > 0;\n\n if (hasBuilders) {\n this.mixedArrays.set(keyStr, {\n array: value,\n builderIndices,\n objectIndices,\n });\n delete this.values[key];\n } else {\n this.setStaticValue(key, keyStr, value);\n this.mixedArrays.delete(keyStr);\n }\n\n this.builders.delete(keyStr);\n }\n\n /**\n * Sets a static value with proper type handling\n */\n private setStaticValue<K extends keyof T>(\n key: K,\n keyStr: string,\n value: unknown,\n ): void {\n // For known types in T, TypeScript will validate at compile time\n // At runtime, we trust the caller has provided a compatible type\n this.values[key] = value as T[K];\n this.builders.delete(keyStr);\n this.mixedArrays.delete(keyStr);\n }\n\n /**\n * Checks if an object contains any builders recursively\n * Handles circular references gracefully\n */\n private containsBuilder(\n obj: unknown,\n visited: WeakSet<object> = new WeakSet(),\n ): boolean {\n if (isFluentBuilder(obj)) return true;\n\n if (!obj || typeof obj !== \"object\") return false;\n\n if (visited.has(obj)) return false;\n visited.add(obj);\n\n if (Array.isArray(obj)) {\n return obj.some((item) => this.containsBuilder(item, visited));\n }\n\n const proto = Object.getPrototypeOf(obj);\n if (proto === Object.prototype || proto === null) {\n return Object.values(obj).some((val) =>\n this.containsBuilder(val, visited),\n );\n }\n\n return false;\n }\n\n /**\n * Checks if a property has been set\n */\n has<K extends keyof T>(key: K): boolean {\n const keyStr = String(key);\n return (\n key in this.values ||\n this.builders.has(keyStr) ||\n this.mixedArrays.has(keyStr)\n );\n }\n\n /**\n * Peeks at a property value without resolving builders\n * Returns the raw value if it's static, the array if it's mixed, or undefined if it's a builder\n */\n peek<K extends keyof T>(key: K): T[K] | undefined {\n const keyStr = String(key);\n\n const mixedArray = this.mixedArrays.get(keyStr);\n if (mixedArray) {\n return mixedArray.array as T[K];\n }\n\n if (this.builders.has(keyStr)) {\n return undefined;\n }\n\n return this.values[key];\n }\n\n /**\n * Gets builder for a property if one is set\n */\n peekBuilder<K extends keyof T, C extends BaseBuildContext>(\n key: K,\n ): FluentBuilder<T[K], C> | undefined {\n const keyStr = String(key);\n const entry = this.builders.get(keyStr);\n if (!entry) return undefined;\n\n if (isFluentBuilder<T[K], C>(entry)) {\n return entry;\n }\n\n return undefined;\n }\n\n /**\n * Gets the type of value stored for a property\n */\n getValueType<K extends keyof T>(\n key: K,\n ): \"static\" | \"builder\" | \"mixed-array\" | \"unset\" {\n const keyStr = String(key);\n\n if (this.mixedArrays.has(keyStr)) {\n return \"mixed-array\";\n }\n\n if (this.builders.has(keyStr)) {\n return \"builder\";\n }\n\n if (key in this.values) {\n return \"static\";\n }\n\n return \"unset\";\n }\n\n /**\n * Gets all static values for the build pipeline\n */\n getValues(): Readonly<Partial<T>> {\n return this.values;\n }\n\n /**\n * Gets all builder entries for the build pipeline\n */\n getBuilders(): ReadonlyMap<\n string,\n FluentBuilder<unknown, BaseBuildContext> | Record<string, unknown>\n > {\n return this.builders;\n }\n\n /**\n * Gets all mixed array entries for the build pipeline\n */\n getMixedArrays(): ReadonlyMap<string, MixedArrayMetadata> {\n return this.mixedArrays;\n }\n\n /**\n * Unsets a property, removing it from storage\n */\n unset<K extends keyof T>(key: K): void {\n const keyStr = String(key);\n delete this.values[key];\n this.builders.delete(keyStr);\n this.mixedArrays.delete(keyStr);\n }\n\n /**\n * Clears all properties from storage\n */\n clear(): void {\n this.values = {};\n this.builders.clear();\n this.mixedArrays.clear();\n }\n\n /**\n * Clones the storage, creating an independent copy\n */\n clone(): ValueStorage<T> {\n const cloned = new ValueStorage<T>();\n cloned.values = { ...this.values };\n cloned.builders = new Map(this.builders);\n cloned.mixedArrays = new Map(\n Array.from(this.mixedArrays.entries()).map(([key, metadata]) => [\n key,\n {\n array: metadata.array,\n builderIndices: new Set(metadata.builderIndices),\n objectIndices: new Set(metadata.objectIndices),\n },\n ]),\n );\n return cloned;\n }\n}\n","/**\n * Manages auxiliary data storage for builders\n *\n * Auxiliary data is metadata that doesn't appear in the final built object\n * but is used during the build process. This includes:\n * - Templates (stored under \"__templates__\")\n * - Switches (stored under \"__switches__\")\n * - Custom metadata\n *\n * This separation keeps builder state clean and makes the build process more explicit\n */\nexport class AuxiliaryStorage {\n private data: Map<string, unknown> = new Map();\n\n /**\n * Sets auxiliary data with a given key\n */\n set<T>(key: string, value: T): void {\n this.data.set(key, value);\n }\n\n /**\n * Gets auxiliary data with type assertion\n * The caller is responsible for knowing the correct type\n */\n get<T>(key: string): T | undefined {\n const value = this.data.get(key);\n return value as T | undefined;\n }\n\n /**\n * Pushes an item to an auxiliary data array\n * Creates the array if it doesn't exist\n */\n push<T>(key: string, item: T): void {\n const existing = this.data.get(key);\n if (Array.isArray(existing)) {\n existing.push(item);\n } else {\n this.data.set(key, [item]);\n }\n }\n\n /**\n * Gets an auxiliary data array\n * Returns empty array if doesn't exist or isn't an array\n */\n getArray<T>(key: string): T[] {\n const existing = this.data.get(key);\n return Array.isArray(existing) ? existing : [];\n }\n\n /**\n * Checks if auxiliary data exists for a key\n */\n has(key: string): boolean {\n return this.data.has(key);\n }\n\n /**\n * Deletes auxiliary data for a key\n */\n delete(key: string): boolean {\n return this.data.delete(key);\n }\n\n /**\n * Clears all auxiliary data\n */\n clear(): void {\n this.data.clear();\n }\n\n /**\n * Clones the auxiliary storage, creating an independent copy\n */\n clone(): AuxiliaryStorage {\n const cloned = new AuxiliaryStorage();\n cloned.data = new Map(this.data);\n return cloned;\n }\n}\n","import type { BaseBuildContext } from \"../../types\";\nimport type { ValueStorage } from \"../../storage/value-storage\";\nimport { isAssetWrapperValue } from \"../../guards\";\nimport { extractValue, resolveValue } from \"../value-resolver\";\n\n/**\n * Step 1: Resolves static values\n *\n * Converts TaggedTemplateValue to strings and resolves nested FluentBuilders\n * in static storage. AssetWrapper values are preserved for later processing.\n *\n * @param storage - The value storage containing static values\n * @param result - The result object being built\n * @param context - Optional build context\n */\nexport function resolveStaticValues<T, C extends BaseBuildContext>(\n storage: ValueStorage<T>,\n result: Record<string, unknown>,\n context: C | undefined,\n): void {\n const values = storage.getValues();\n\n for (const [key, value] of Object.entries(values)) {\n if (!isAssetWrapperValue(value)) {\n // First extract any TaggedTemplateValue instances (recursively)\n // Pass the property key to handle special cases like 'binding'\n const extracted = extractValue(value, { propertyKey: key });\n // Then resolve FluentBuilders and nested contexts\n result[key] = resolveValue(extracted, { context, propertyName: key });\n } else {\n // Keep AssetWrapper values for later processing\n result[key] = value;\n }\n }\n}\n","import type { BaseBuildContext, AssetMetadata } from \"../../types\";\nimport type { ValueStorage } from \"../../storage/value-storage\";\nimport { isStringOrUndefined } from \"../../guards\";\nimport { generateAssetId } from \"../../id/generator\";\n\n/**\n * Step 2: Generates ID for this asset if needed\n *\n * Note: This runs AFTER resolveStaticValues, so we use values from result\n * rather than from storage.\n *\n * @param storage - The value storage (used to check if ID was explicitly set)\n * @param result - The result object being built (contains resolved values)\n * @param context - Optional build context\n */\nexport function generateAssetIdForBuilder<T, C extends BaseBuildContext>(\n storage: ValueStorage<T>,\n result: Record<string, unknown>,\n context: C | undefined,\n): void {\n const hasIdSet = storage.has(\"id\" as keyof T);\n const hasType = storage.has(\"type\" as keyof T) || \"type\" in result;\n const hasIdField = \"id\" in result;\n\n // Case 1: Asset with type field (standard case)\n if (!hasIdSet && hasType) {\n // Use values from result since they're already extracted\n const typeValue = result.type;\n const assetValue = result.value;\n const assetBinding = result.binding;\n\n // Validate types with type guards\n if (!isStringOrUndefined(typeValue)) {\n return; // Skip ID generation if type is not a string\n }\n\n if (!isStringOrUndefined(assetValue)) {\n return; // Skip if value is not string/undefined\n }\n\n if (!isStringOrUndefined(assetBinding)) {\n return; // Skip if binding is not string/undefined\n }\n\n const assetMetadata: AssetMetadata = {\n type: typeValue as string,\n ...(assetValue ? { value: assetValue as string } : {}),\n ...(assetBinding ? { binding: assetBinding as string } : {}),\n };\n\n const generatedId = generateAssetId({\n context,\n parameterName: typeValue as string,\n assetMetadata,\n explicitId: undefined,\n });\n\n if (generatedId) {\n result.id = generatedId;\n }\n }\n // Case 2: Object with id field but no type (e.g., ChoiceItem)\n // Generate ID based on context branch if available\n else if (!hasIdSet && hasIdField && !hasType && context && context.branch) {\n // Use genId directly with the context to generate ID based on branch\n const generatedId = generateAssetId({\n context,\n parameterName: \"item\",\n assetMetadata: undefined,\n explicitId: undefined,\n });\n\n if (generatedId) {\n result.id = generatedId;\n }\n }\n}\n","import type { BaseBuildContext } from \"../../types\";\nimport type { ValueStorage } from \"../../storage/value-storage\";\nimport { isAssetWrapperValue } from \"../../guards\";\nimport { resolveAndWrapAsset } from \"../value-resolver\";\n\n/**\n * Step 4: Resolves AssetWrapper values in static storage\n *\n * Processes values that were marked as AssetWrapper during value setting.\n * These values contain assets or builders that need special context handling.\n *\n * @param storage - The value storage\n * @param result - The result object being built\n * @param nestedParentContext - Context for nested assets\n */\nexport function resolveAssetWrappers<T, C extends BaseBuildContext>(\n storage: ValueStorage<T>,\n result: Record<string, unknown>,\n nestedParentContext: C | undefined,\n): void {\n if (!nestedParentContext) {\n return;\n }\n\n const values = storage.getValues();\n\n for (const key of Object.keys(values)) {\n const value = values[key as keyof T];\n\n if (isAssetWrapperValue(value)) {\n const unwrapped = value.asset;\n\n if (Array.isArray(unwrapped)) {\n result[key] = resolveAssetWrapperArray(\n unwrapped,\n nestedParentContext,\n key,\n );\n } else {\n result[key] = resolveAndWrapAsset(unwrapped, {\n context: nestedParentContext,\n slotName: key,\n });\n }\n }\n }\n}\n\n/**\n * Helper: Resolves an array within an AssetWrapper\n */\nfunction resolveAssetWrapperArray<C extends BaseBuildContext>(\n array: readonly unknown[],\n context: C,\n key: string,\n): unknown[] {\n // Filter out null/undefined values before processing\n return array\n .filter((item) => item !== null && item !== undefined)\n .map((item, index) => {\n const slotName = `${key}-${index}`;\n return resolveAndWrapAsset(item, { context, slotName });\n });\n}\n","import type { BaseBuildContext } from \"../../types\";\nimport type { ValueStorage } from \"../../storage/value-storage\";\nimport { isAssetWrapperValue } from \"../../guards\";\nimport { resolveAndWrapAsset } from \"../value-resolver\";\n\n/**\n * Step 5: Resolves mixed arrays\n *\n * Processes arrays containing both builders and static values.\n * Builders are resolved with proper context, static values pass through.\n *\n * @param storage - The value storage\n * @param result - The result object being built\n * @param nestedParentContext - Context for nested builders\n */\nexport function resolveMixedArrays<T, C extends BaseBuildContext>(\n storage: ValueStorage<T>,\n result: Record<string, unknown>,\n nestedParentContext: C | undefined,\n): void {\n const mixedArrays = storage.getMixedArrays();\n\n mixedArrays.forEach((metadata, key) => {\n const { array, builderIndices, objectIndices } = metadata;\n\n // Check if this is an AssetWrapper array\n const currentValue = result[key];\n if (isAssetWrapperValue(currentValue)) {\n resolveMixedArrayAsAssetWrapper(\n result,\n key,\n currentValue,\n nestedParentContext,\n );\n } else {\n resolveMixedArrayNormal(\n result,\n key,\n array,\n builderIndices,\n objectIndices,\n nestedParentContext,\n );\n }\n });\n}\n\n/**\n * Helper: Resolves mixed array that is wrapped in AssetWrapper\n */\nfunction resolveMixedArrayAsAssetWrapper<C extends BaseBuildContext>(\n result: Record<string, unknown>,\n key: string,\n wrapperValue: { asset: unknown },\n nestedParentContext: C | undefined,\n): void {\n const unwrappedArray = wrapperValue.asset;\n\n if (Array.isArray(unwrappedArray)) {\n // Filter out null/undefined values before processing\n result[key] = unwrappedArray\n .filter((item) => item !== null && item !== undefined)\n .map((item, index) => {\n const slotName = `${key}-${index}`;\n return resolveAndWrapAsset(item, {\n context: nestedParentContext,\n slotName,\n });\n });\n }\n}\n\n/**\n * Helper: Resolves mixed array normally (not wrapped)\n * Uses resolveAndWrapAsset to properly wrap Asset builders in { asset: ... } format\n */\nfunction resolveMixedArrayNormal<C extends BaseBuildContext>(\n result: Record<string, unknown>,\n key: string,\n array: readonly unknown[],\n builderIndices: ReadonlySet<number>,\n objectIndices: ReadonlySet<number>,\n nestedParentContext: C | undefined,\n): void {\n // Filter out null/undefined values and resolve each item with proper wrapping\n result[key] = array\n .filter((item) => item !== null && item !== undefined)\n .map((item, index) => {\n const slotName = `${key}-${index}`;\n return resolveAndWrapAsset(item, {\n context: nestedParentContext,\n slotName,\n });\n });\n}\n","import type { BaseBuildContext } from \"../../types\";\nimport type { ValueStorage } from \"../../storage/value-storage\";\nimport { isAssetWrapperValue } from \"../../guards\";\nimport { resolveAndWrapAsset, resolveValue } from \"../value-resolver\";\n\n/**\n * Step 6: Resolves regular builders (non-array)\n *\n * Processes FluentBuilder instances and objects containing builders.\n * Creates nested contexts for proper ID generation.\n *\n * @param storage - The value storage\n * @param result - The result object being built\n * @param nestedParentContext - Context for nested builders\n */\nexport function resolveBuilders<T, C extends BaseBuildContext>(\n storage: ValueStorage<T>,\n result: Record<string, unknown>,\n nestedParentContext: C | undefined,\n): void {\n const builders = storage.getBuilders();\n\n builders.forEach((value, key) => {\n // Check if this is an AssetWrapper\n if (isAssetWrapperValue(value)) {\n resolveBuilderAsAssetWrapper(result, key, value, nestedParentContext);\n } else {\n resolveBuilderNormal(result, key, value, nestedParentContext);\n }\n });\n}\n\n/**\n * Helper: Resolves builder that is wrapped in AssetWrapper\n */\nfunction resolveBuilderAsAssetWrapper<C extends BaseBuildContext>(\n result: Record<string, unknown>,\n key: string,\n wrapperValue: { asset: unknown },\n nestedParentContext: C | undefined,\n): void {\n const unwrapped = wrapperValue.asset;\n\n if (nestedParentContext) {\n if (Array.isArray(unwrapped)) {\n // Filter out null/undefined values before processing\n result[key] = unwrapped\n .filter((item) => item !== null && item !== undefined)\n .map((item, index) => {\n const slotName = `${key}-${index}`;\n return resolveAndWrapAsset(item, {\n context: nestedParentContext,\n slotName,\n });\n });\n } else {\n result[key] = resolveAndWrapAsset(unwrapped, {\n context: nestedParentContext,\n slotName: key,\n });\n }\n } else {\n // No context, just resolve the wrapper\n result[key] = resolveValue(wrapperValue, {});\n }\n}\n\n/**\n * Helper: Resolves builder normally (not wrapped)\n * Uses resolveAndWrapAsset to properly wrap Asset builders in { asset: ... } format\n */\nfunction resolveBuilderNormal<C extends BaseBuildContext>(\n result: Record<string, unknown>,\n key: string,\n value: unknown,\n nestedParentContext: C | undefined,\n): void {\n // Use resolveAndWrapAsset which correctly wraps Asset builders\n // This ensures slot properties like 'label' get wrapped in { asset: ... }\n result[key] = resolveAndWrapAsset(value, {\n context: nestedParentContext,\n slotName: key,\n });\n}\n","import type { ValuePath } from \"../types\";\nimport { isAssetWrapperValue, isPlainObject } from \"../guards\";\n\n/**\n * Safely gets a value as a Record<string, unknown>, returning empty object if not.\n * This avoids unsafe `as` assertions by using the isPlainObject type guard.\n */\nfunction asRecordOrEmpty(value: unknown): Record<string, unknown> {\n return isPlainObject(value) ? value : {};\n}\n\n/**\n * Sets a value at a nested path in an object\n * Handles nested objects, arrays, and AssetWrapper structures\n *\n * @param obj - The target object to modify\n * @param path - Array of keys/indices representing the path\n * @param value - The value to set at the path\n *\n * @example\n * setValueAtPath(obj, [\"actions\", 0, \"label\"], \"Click me\")\n * // Sets obj.actions[0].label = \"Click me\"\n */\nexport function setValueAtPath(\n obj: Record<string, unknown>,\n path: ValuePath,\n value: unknown,\n): void {\n if (path.length === 0) return;\n\n if (path.length === 1) {\n obj[path[0]] = value;\n return;\n }\n\n const [currentKey, ...restPath] = path;\n const nextKey = restPath[0];\n const currentValue = obj[currentKey];\n\n // Check if current value is an AssetWrapper containing an array\n const isAssetWrapperWithArray =\n isAssetWrapperValue(currentValue) && Array.isArray(currentValue.asset);\n\n if (isAssetWrapperWithArray && typeof nextKey === \"number\") {\n setValueInAssetWrapperArray(\n obj,\n currentKey,\n currentValue as { asset: unknown[] },\n nextKey,\n restPath,\n value,\n );\n } else if (Array.isArray(currentValue) && typeof nextKey === \"number\") {\n setValueInArray(obj, currentKey, currentValue, nextKey, restPath, value);\n } else {\n setValueInObject(obj, currentKey, restPath, value);\n }\n}\n\n/**\n * Sets value in an array within an AssetWrapper\n */\nfunction setValueInAssetWrapperArray(\n obj: Record<string, unknown>,\n currentKey: string | number,\n wrappedArray: { asset: unknown[] },\n nextKey: number,\n restPath: ValuePath,\n value: unknown,\n): void {\n const arrayResult = [...wrappedArray.asset];\n if (restPath.length === 1) {\n arrayResult[nextKey] = value;\n } else {\n const nestedObj = asRecordOrEmpty(arrayResult[nextKey]);\n setValueAtPath(nestedObj, restPath.slice(1), value);\n arrayResult[nextKey] = nestedObj;\n }\n obj[currentKey] = { asset: arrayResult };\n}\n\n/**\n * Sets value in a regular array\n */\nfunction setValueInArray(\n obj: Record<string, unknown>,\n currentKey: string | number,\n array: unknown[],\n nextKey: number,\n restPath: ValuePath,\n value: unknown,\n): void {\n const arrayResult = [...array];\n if (restPath.length === 1) {\n arrayResult[nextKey] = value;\n } else {\n const nestedObj = asRecordOrEmpty(arrayResult[nextKey]);\n setValueAtPath(nestedObj, restPath.slice(1), value);\n arrayResult[nextKey] = nestedObj;\n }\n obj[currentKey] = arrayResult;\n}\n\n/**\n * Sets value in a nested object\n */\nfunction setValueInObject(\n obj: Record<string, unknown>,\n currentKey: string | number,\n restPath: ValuePath,\n value: unknown,\n): void {\n const nestedObj = asRecordOrEmpty(obj[currentKey]);\n setValueAtPath(nestedObj, restPath, value);\n obj[currentKey] = nestedObj;\n}\n","import {\n type BaseBuildContext,\n type SwitchMetadata,\n StorageKeys,\n} from \"../../types\";\nimport type { AuxiliaryStorage } from \"../../storage/auxiliary-storage\";\nimport { isSwitchResult } from \"../../guards\";\nimport { setValueAtPath } from \"../path-resolver\";\n\n/**\n * Step 7: Resolves switches\n *\n * Processes switch expressions and injects them at the specified paths.\n * Handles both static and dynamic switches with proper ID generation.\n *\n * @param auxiliaryStorage - Storage containing switch metadata\n * @param result - The result object being built\n * @param nestedParentContext - Context for switch resolution\n * @param arrayProperties - Set of property names that are array types\n */\nexport function resolveSwitches<C extends BaseBuildContext>(\n auxiliaryStorage: AuxiliaryStorage,\n result: Record<string, unknown>,\n nestedParentContext: C | undefined,\n arrayProperties: ReadonlySet<string>,\n): void {\n const switches = auxiliaryStorage.getArray<SwitchMetadata<C>>(\n StorageKeys.SWITCHES,\n );\n if (switches.length === 0 || !nestedParentContext) {\n return;\n }\n\n let globalCaseIndex = 0;\n switches.forEach(({ path, switchFn }) => {\n // Create a context that includes the property/slot name for proper ID generation\n // For path [\"label\"], this creates: parent-label-staticSwitch-0-text\n // We construct the parent ID directly without registering it (no genId call)\n const propertyName = String(path[0]);\n const switchParentId = nestedParentContext.parentId\n ? `${nestedParentContext.parentId}-${propertyName}`\n : propertyName;\n\n const switchContext = {\n ...nestedParentContext,\n parentId: switchParentId,\n branch: undefined,\n } as C;\n\n let switchResult = switchFn(switchContext, globalCaseIndex);\n\n // Count cases for next switch's offset\n if (isSwitchResult(switchResult)) {\n const switchCases =\n switchResult.staticSwitch ?? switchResult.dynamicSwitch;\n if (Array.isArray(switchCases)) {\n globalCaseIndex += switchCases.length;\n }\n }\n\n // If this property is an array type (e.g., actions: Array<AssetWrapper<T>>),\n // wrap the switch result in an array to match the expected schema type.\n // Only wrap if we're replacing the entire property (path.length === 1),\n // not a specific element in the array (path.length > 1)\n if (arrayProperties.has(propertyName) && path.length === 1) {\n switchResult = [switchResult];\n }\n\n setValueAtPath(result, path, switchResult);\n });\n}\n","import { type BaseBuildContext, StorageKeys } from \"../../types\";\nimport type { AuxiliaryStorage } from \"../../storage/auxiliary-storage\";\nimport type { template as easyDslTemplate } from \"../../../index\";\n\n/**\n * Step 8: Resolves templates\n *\n * Processes template functions and adds them to the result.\n * Templates are special constructs that generate dynamic content.\n *\n * @param auxiliaryStorage - Storage containing template functions\n * @param result - The result object being built\n * @param context - Build context for template resolution\n */\nexport function resolveTemplates<C extends BaseBuildContext>(\n auxiliaryStorage: AuxiliaryStorage,\n result: Record<string, unknown>,\n context: C | undefined,\n): void {\n const templateFns = auxiliaryStorage.getArray<\n ReturnType<typeof easyDslTemplate>\n >(StorageKeys.TEMPLATES);\n\n if (templateFns.length === 0) {\n return;\n }\n\n if (!context) {\n if (process.env.NODE_ENV !== \"production\") {\n console.warn(\n `resolveTemplates: ${templateFns.length} template(s) exist but no context provided. ` +\n \"Templates will be ignored. Pass a build context to .build() to enable template resolution.\",\n );\n }\n return;\n }\n\n const templates = templateFns.map((fn) => fn(context));\n result.template = templates;\n}\n","import type { BaseBuildContext } from \"../../types\";\nimport { resolveAndWrapAsset, resolveValue } from \"../value-resolver\";\nimport {\n isAsset,\n isAssetWrapper,\n isFluentBuilder,\n isPlainObject,\n} from \"../../guards\";\n\n/**\n * Step 7: Resolves nested AssetWrapper paths\n *\n * This step handles cases where AssetWrapper properties are nested within\n * interface types. It traverses paths like [\"header\", \"left\"] to find and\n * wrap assets that should be in AssetWrapper format.\n *\n * @param result - The result object being built\n * @param context - Context for nested assets\n * @param assetWrapperPaths - Array of paths to AssetWrapper properties\n */\nexport function resolveNestedAssetWrappers<C extends BaseBuildContext>(\n result: Record<string, unknown>,\n context: C | undefined,\n assetWrapperPaths: ReadonlyArray<ReadonlyArray<string>>,\n): void {\n if (assetWrapperPaths.length === 0) {\n return;\n }\n\n for (const path of assetWrapperPaths) {\n // Skip empty paths (defensive guard against malformed metadata)\n if (path.length === 0) {\n continue;\n }\n\n // Paths with length 1 are handled by direct AssetWrapper resolution (Step 4)\n if (path.length < 2) {\n continue;\n }\n\n resolvePathInResult(result, path, context);\n }\n}\n\n/**\n * Resolves a specific path in the result object.\n * Handles intermediate FluentBuilders by resolving them before continuing traversal.\n */\nfunction resolvePathInResult<C extends BaseBuildContext>(\n result: Record<string, unknown>,\n path: ReadonlyArray<string>,\n context: C | undefined,\n): void {\n // Navigate to the parent object containing the AssetWrapper property\n let current: unknown = result;\n\n for (let i = 0; i < path.length - 1; i++) {\n const key = path[i];\n\n if (!isPlainObject(current)) {\n return;\n }\n\n let next = (current as Record<string, unknown>)[key];\n\n if (next === undefined || next === null) {\n return;\n }\n\n // If intermediate value is a builder, resolve it first\n if (isFluentBuilder(next)) {\n next = resolveValue(next, { context, propertyName: key });\n (current as Record<string, unknown>)[key] = next;\n }\n\n current = next;\n }\n\n // Now `current` is the parent object, and we need to wrap the final property\n const finalKey = path[path.length - 1];\n\n if (!isPlainObject(current)) {\n return;\n }\n\n const parent = current as Record<string, unknown>;\n const value = parent[finalKey];\n\n if (value === undefined || value === null) {\n return;\n }\n\n // If it's already an AssetWrapper, skip\n if (isAssetWrapper(value)) {\n return;\n }\n\n // Generate slot name from the full path\n const slotName = path.join(\"-\");\n\n // Handle arrays of AssetWrappers\n if (Array.isArray(value)) {\n parent[finalKey] = value\n .filter((item) => item !== null && item !== undefined)\n .map((item, index) => {\n if (isAssetWrapper(item)) {\n return item;\n }\n return resolveAndWrapAsset(item, {\n context,\n slotName: `${slotName}-${index}`,\n });\n });\n return;\n }\n\n // Handle single value that needs wrapping\n if (isFluentBuilder(value) || isAsset(value)) {\n parent[finalKey] = resolveAndWrapAsset(value, {\n context,\n slotName,\n });\n }\n}\n","import type { BaseBuildContext } from \"../types\";\nimport type { ValueStorage } from \"../storage/value-storage\";\nimport type { AuxiliaryStorage } from \"../storage/auxiliary-storage\";\nimport { resolveStaticValues } from \"./steps/static-values\";\nimport { generateAssetIdForBuilder } from \"./steps/asset-id\";\nimport { resolveAssetWrappers } from \"./steps/asset-wrappers\";\nimport { resolveMixedArrays } from \"./steps/mixed-arrays\";\nimport { resolveBuilders } from \"./steps/builders\";\nimport { resolveSwitches } from \"./steps/switches\";\nimport { resolveTemplates } from \"./steps/templates\";\nimport { resolveNestedAssetWrappers } from \"./steps/nested-asset-wrappers\";\n\n/**\n * Creates a nested context for child assets\n * This is Step 3 of the build process\n */\nfunction createNestedParentContext<C extends BaseBuildContext>(\n result: Record<string, unknown>,\n context: C | undefined,\n): C | undefined {\n if (!context) {\n return undefined;\n }\n\n // Extract parent ID with type checking\n const parentId =\n \"id\" in result && typeof result.id === \"string\" ? result.id : undefined;\n\n // Create context for nested assets\n // We clear the branch to avoid double-nesting\n return {\n ...context,\n parentId,\n branch: undefined,\n } as C;\n}\n\n/**\n * Executes the complete build pipeline\n *\n * The pipeline consists of 9 steps that transform builder state into a final object:\n * 1. Resolve static values (extract TaggedTemplateValue, resolve simple builders)\n * 2. Generate asset ID if needed\n * 3. Create nested context for child assets\n * 4. Resolve AssetWrapper values\n * 5. Resolve mixed arrays\n * 6. Resolve builders\n * 7. Resolve nested AssetWrapper paths\n * 8. Resolve switches\n * 9. Resolve templates\n *\n * @param valueStorage - Storage containing property values\n * @param auxiliaryStorage - Storage containing metadata (templates, switches)\n * @param defaults - Optional default values to merge into result\n * @param context - Optional build context\n * @param arrayProperties - Set of property names that are array types\n * @param assetWrapperPaths - Paths to nested AssetWrapper properties\n * @returns The fully built object\n */\nexport function executeBuildPipeline<T, C extends BaseBuildContext>(\n valueStorage: ValueStorage<T>,\n auxiliaryStorage: AuxiliaryStorage,\n defaults: Partial<T> | undefined,\n context: C | undefined,\n arrayProperties: ReadonlySet<string>,\n assetWrapperPaths: ReadonlyArray<ReadonlyArray<string>> = [],\n): T {\n const result: Record<string, unknown> = defaults ? { ...defaults } : {};\n\n // Step 1: Resolve static values\n resolveStaticValues(valueStorage, result, context);\n\n // Step 2: Generate asset ID if needed\n generateAssetIdForBuilder(valueStorage, result, context);\n\n // Step 3: Create nested context for child assets\n const nestedParentContext = createNestedParentContext(result, context);\n\n // Step 4: Resolve AssetWrapper values\n resolveAssetWrappers(valueStorage, result, nestedParentContext);\n\n // Step 5: Resolve mixed arrays\n resolveMixedArrays(valueStorage, result, nestedParentContext);\n\n // Step 6: Resolve builders\n resolveBuilders(valueStorage, result, nestedParentContext);\n\n // Step 7: Resolve nested AssetWrapper paths\n resolveNestedAssetWrappers(result, nestedParentContext, assetWrapperPaths);\n\n // Step 8: Resolve switches\n resolveSwitches(\n auxiliaryStorage,\n result,\n nestedParentContext,\n arrayProperties,\n );\n\n // Step 9: Resolve templates\n resolveTemplates(auxiliaryStorage, result, context);\n\n return result as T;\n}\n","import type { Asset } from \"@player-ui/types\";\nimport type { FluentBuilder, BaseBuildContext } from \"../types\";\nimport { isFluentBuilder, isAsset, isAssetWrapperValue } from \"../guards\";\n\n/**\n * Resolves a value or function to its final value\n *\n * Generic helper that unwraps functions to their return values.\n * Handles both simple functions and ConditionalValue types.\n */\nexport function resolveValueOrFunction<V>(value: V | (() => V)): V {\n if (typeof value === \"function\" && !isFluentBuilder(value)) {\n // SAFETY: We've checked it's a function and not a FluentBuilder,\n // so it must be a function returning V\n return (value as () => V)();\n }\n\n return value as V;\n}\n\n/**\n * Type guard to check if a value should be wrapped in AssetWrapper format\n */\nexport function shouldWrapInAssetWrapper(\n value: unknown,\n): value is\n | FluentBuilder<unknown, BaseBuildContext>\n | Asset\n | Array<FluentBuilder<unknown, BaseBuildContext> | Asset> {\n // Don't wrap if already wrapped (has 'asset' property but not 'type')\n if (isAssetWrapperValue(value)) {\n return false;\n }\n\n // Wrap FluentBuilders\n if (isFluentBuilder(value)) {\n return true;\n }\n\n // Wrap Assets (objects with 'type' property)\n if (isAsset(value)) {\n return true;\n }\n\n // Wrap arrays of builders/assets\n if (Array.isArray(value) && value.length > 0) {\n const firstItem = value[0];\n return isFluentBuilder(firstItem) || isAsset(firstItem);\n }\n\n return false;\n}\n\n/**\n * Wraps a value in AssetWrapper format if needed\n * This enables if() and ifElse() to work with unwrapped asset builders\n */\nexport function maybeWrapAsset<V>(value: V): V | { asset: V } {\n if (shouldWrapInAssetWrapper(value)) {\n return { asset: value };\n }\n\n return value;\n}\n","import type { Asset, AssetWrapper } from \"@player-ui/types\";\nimport {\n type BaseBuildContext,\n genId,\n isFluentBuilder,\n BranchTypes,\n} from \"../base-builder\";\nimport {\n isTaggedTemplateValue,\n type TaggedTemplateValue,\n} from \"../tagged-template\";\n\ntype CaseExpression = boolean | string | TaggedTemplateValue;\n\ninterface SwitchCase<\n T extends Asset,\n C extends BaseBuildContext = BaseBuildContext,\n> {\n readonly case: CaseExpression;\n readonly asset: T | { build(context?: C): T };\n}\n\ninterface SwitchArgs<\n T extends Asset,\n C extends BaseBuildContext = BaseBuildContext,\n> {\n readonly cases: ReadonlyArray<SwitchCase<T, C>>;\n readonly isDynamic?: boolean;\n}\n\nfunction processCaseExpression(exp: CaseExpression): string | boolean {\n if (typeof exp === \"boolean\") {\n return exp;\n }\n\n if (isTaggedTemplateValue(exp)) {\n return exp.toString();\n }\n\n return String(exp);\n}\n\n/**\n * Creates a switch configuration for conditionally selecting an asset\n * @see https://player-ui.github.io/next/content/assets-views/#switches\n */\nexport const switch_ =\n <T extends Asset, C extends BaseBuildContext = BaseBuildContext>({\n cases,\n isDynamic = false,\n }: SwitchArgs<T, C>) =>\n (ctx: C, caseOffset: number = 0): AssetWrapper => {\n const switchType = isDynamic ? \"dynamic\" : \"static\";\n\n return {\n [`${switchType}Switch`]: cases.map((c, index) => {\n const caseParentCtx: C = {\n ...ctx,\n parentId: ctx.parentId,\n branch: {\n type: BranchTypes.SWITCH,\n kind: switchType,\n index: caseOffset + index,\n },\n } as C;\n\n const asset: T =\n isFluentBuilder(c.asset) && \"build\" in c.asset\n ? (c.asset.build(caseParentCtx) as T)\n : (c.asset as T);\n\n return {\n case: processCaseExpression(c.case),\n asset: {\n ...asset,\n id: asset.id ?? genId(caseParentCtx),\n },\n };\n }),\n } as AssetWrapper;\n };\n","import type { template as easyDslTemplate } from \"..\";\nimport {\n type BaseBuildContext,\n type ConditionalValue,\n type SwitchMetadata,\n type FluentPartial,\n FLUENT_BUILDER_SYMBOL,\n StorageKeys,\n} from \"./types\";\nimport { ValueStorage } from \"./storage/value-storage\";\nimport { AuxiliaryStorage } from \"./storage/auxiliary-storage\";\nimport { executeBuildPipeline } from \"./resolution/pipeline\";\nimport { resolveValueOrFunction, maybeWrapAsset } from \"./conditional\";\nimport { switch_ } from \"../switch\";\n\n/**\n * Base class for all generated builders\n * Provides core functionality for the builder pattern with Player UI-specific features\n *\n * This class delegates to specialized components:\n * - ValueStorage: Manages property values, builders, and mixed arrays\n * - AuxiliaryStorage: Manages metadata (templates, switches)\n * - Build Pipeline: Orchestrates the 8-step build process\n * - Conditional Logic: Handles if/ifElse with auto-wrapping\n */\nexport abstract class FluentBuilderBase<\n T,\n C extends BaseBuildContext = BaseBuildContext,\n> {\n readonly [FLUENT_BUILDER_SYMBOL]: true = true as const;\n\n protected valueStorage: ValueStorage<T>;\n protected auxiliaryStorage: AuxiliaryStorage;\n protected context?: C;\n\n /**\n * Creates a new builder instance\n * @param initial - Optional initial values (accepts FluentPartial for TaggedTemplateValue support)\n */\n constructor(initial?: FluentPartial<T, C>) {\n this.valueStorage = new ValueStorage(initial as Partial<T>);\n this.auxiliaryStorage = new AuxiliaryStorage();\n }\n\n /**\n * Accessor for generated builders to access values\n * This maintains backward compatibility with generated code\n */\n protected get values(): Partial<T> {\n return this.valueStorage.getValues() as Partial<T>;\n }\n\n /**\n * Setter for generated builders to set values in bulk\n * Used by withAdditionalProperties() in generated builders\n */\n protected set values(newValues: Partial<T>) {\n Object.entries(newValues).forEach(([key, value]) => {\n this.valueStorage.set(key as keyof T, value);\n });\n }\n\n /**\n * Sets additional properties in bulk that may not be defined in the type schema\n * Useful for extensibility and forward compatibility\n */\n public withAdditionalProperties(values: Partial<T>): this {\n this.values = values;\n return this;\n }\n\n /**\n * Sets a property value, intelligently routing it to the appropriate storage\n * @param key - The property key to set\n * @param value - The value to set\n * @returns This builder instance for chaining\n */\n protected set<K extends keyof T>(key: K, value: unknown): this {\n this.valueStorage.set(key, value);\n return this;\n }\n\n /**\n * Builds the final object with defaults and nested builder resolution\n * Executes the complete 8-step build pipeline\n *\n * @param defaults - Optional default values\n * @param context - Optional build context\n */\n protected buildWithDefaults(defaults?: Partial<T>, context?: C): T {\n const arrayProperties = this.getArrayPropertiesMetadata();\n const assetWrapperPaths = this.getAssetWrapperPathsMetadata();\n return executeBuildPipeline(\n this.valueStorage,\n this.auxiliaryStorage,\n defaults,\n context,\n arrayProperties,\n assetWrapperPaths,\n );\n }\n\n /**\n * Gets array property metadata from the builder class\n * Generated builders include a static __arrayProperties__ set\n */\n private getArrayPropertiesMetadata(): ReadonlySet<string> {\n const constructor = this.constructor as typeof FluentBuilderBase & {\n __arrayProperties__?: ReadonlySet<string>;\n };\n\n return constructor.__arrayProperties__ ?? new Set();\n }\n\n /**\n * Gets asset wrapper paths metadata from the builder class.\n * Generated builders include a static __assetWrapperPaths__ array of paths.\n * Each path is an array of property names leading to an AssetWrapper.\n */\n protected getAssetWrapperPathsMetadata(): ReadonlyArray<\n ReadonlyArray<string>\n > {\n const constructor = this.constructor as typeof FluentBuilderBase & {\n __assetWrapperPaths__?: ReadonlyArray<ReadonlyArray<string>>;\n };\n\n return constructor.__assetWrapperPaths__ ?? [];\n }\n\n /**\n * Conditionally sets a property based on a predicate\n *\n * Accepts unwrapped Asset builders and automatically wraps them in AssetWrapper format.\n *\n * @param predicate - Function to determine if the property should be set\n * @param property - The property key\n * @param value - The value, builder, or function returning either\n *\n * @example\n * action()\n * .if(() => showLabel, \"label\", text().withValue(\"Submit\"))\n */\n public if<K extends keyof T>(\n predicate: (builder: this) => boolean,\n property: K,\n value: ConditionalValue<T[K], C>,\n ): this {\n if (predicate(this)) {\n const resolved = resolveValueOrFunction(value);\n const wrapped = maybeWrapAsset(resolved);\n\n // SAFETY: Type assertion is necessary and safe here because:\n // 1. `maybeWrapAsset` uses type guards to check if wrapping is needed\n // 2. For AssetWrapper properties, unwrapped builders are wrapped as { asset: builder }\n // 3. For other properties, values pass through unchanged\n // 4. The runtime behavior ensures type safety that TypeScript can't statically verify\n this.set(property, wrapped as T[K]);\n }\n\n return this;\n }\n\n /**\n * Conditionally sets a property choosing between two values\n *\n * Accepts unwrapped Asset builders and automatically wraps them in AssetWrapper format.\n *\n * @param predicate - Function to determine which value to use\n * @param property - The property key\n * @param trueValue - Value to use if predicate is true\n * @param falseValue - Value to use if predicate is false\n *\n * @example\n * action()\n * .ifElse(\n * () => isActive,\n * \"label\",\n * text().withValue(\"Deactivate\"),\n * text().withValue(\"Activate\")\n * )\n */\n public ifElse<K extends keyof T>(\n predicate: (builder: this) => boolean,\n property: K,\n trueValue: ConditionalValue<T[K], C>,\n falseValue: ConditionalValue<T[K], C>,\n ): this {\n const valueToUse = predicate(this) ? trueValue : falseValue;\n const resolved = resolveValueOrFunction(valueToUse);\n const wrapped = maybeWrapAsset(resolved);\n\n // SAFETY: Type assertion is necessary and safe here because:\n // 1. `maybeWrapAsset` uses type guards to check if wrapping is needed\n // 2. For AssetWrapper properties, unwrapped builders are wrapped as { asset: builder }\n // 3. For other properties, values pass through unchanged\n // 4. The runtime behavior ensures type safety that TypeScript can't statically verify\n this.set(property, wrapped as T[K]);\n return this;\n }\n\n /**\n * Checks if a property has been set\n */\n public has<K extends keyof T>(key: K): boolean {\n return this.valueStorage.has(key);\n }\n\n /**\n * Peeks at a property value without resolving builders\n */\n public peek<K extends keyof T>(key: K): T[K] | undefined {\n return this.valueStorage.peek(key);\n }\n\n /**\n * Gets builder for a property if one is set\n */\n public peekBuilder<K extends keyof T>(\n key: K,\n ): import(\"./types\").FluentBuilder<T[K], C> | undefined {\n return this.valueStorage.peekBuilder<K, C>(key);\n }\n\n /**\n * Gets the type of value stored for a property\n */\n public getValueType<K extends keyof T>(\n key: K,\n ): \"static\" | \"builder\" | \"mixed-array\" | \"unset\" {\n return this.valueStorage.getValueType(key);\n }\n\n /**\n * Clones the builder, creating an independent copy with the same state.\n *\n * Note: This method requires that the builder class has a constructor that\n * accepts an optional `initial` parameter (like all generated builders do).\n * If your custom builder has required constructor parameters, you must\n * override this method.\n */\n public clone(): this {\n // Generated builders have constructor signature: constructor(initial?: Partial<T>)\n // We create a new instance and copy the internal state\n const BuilderClass = this.constructor as new (initial?: unknown) => this;\n\n // Create new instance (passing undefined is safe for generated builders)\n let cloned: this;\n try {\n cloned = new BuilderClass();\n } catch (error) {\n throw new Error(\n `clone() failed: Builder class \"${this.constructor.name}\" requires constructor arguments. ` +\n `Override clone() in your subclass to handle this case.`,\n );\n }\n\n cloned.valueStorage = this.valueStorage.clone();\n cloned.auxiliaryStorage = this.auxiliaryStorage.clone();\n if (this.context) {\n cloned.context = this.context;\n }\n\n return cloned;\n }\n\n /**\n * Unsets a property, removing it from the builder\n */\n public unset<K extends keyof T>(key: K): this {\n this.valueStorage.unset(key);\n return this;\n }\n\n /**\n * Clears all properties from the builder, resetting it to initial state\n */\n public clear(): this {\n this.valueStorage.clear();\n return this;\n }\n\n /**\n * Adds a template to this builder\n */\n public template(templateFn: ReturnType<typeof easyDslTemplate>): this {\n this.auxiliaryStorage.push(StorageKeys.TEMPLATES, templateFn);\n return this;\n }\n\n /**\n * Adds a switch to this builder at a specific path\n */\n public switch(\n path: ReadonlyArray<string | number>,\n switchFnArgs: Parameters<typeof switch_>[0],\n ): this {\n this.auxiliaryStorage.push<SwitchMetadata<C>>(StorageKeys.SWITCHES, {\n path,\n switchFn: switch_(switchFnArgs),\n });\n return this;\n }\n\n /**\n * Abstract build method to be implemented by generated builders\n */\n abstract build(context?: C): T;\n}\n","export function createInspectMethod(\n builderName: string,\n properties: Record<string, unknown>,\n): string {\n return `${builderName} { properties: ${JSON.stringify(\n properties,\n null,\n 2,\n )} }`;\n}\n","/**\n * Error codes for fluent builder errors.\n * Use these codes for programmatic error handling.\n */\nexport const ErrorCodes = {\n /** Context is missing when required */\n MISSING_CONTEXT: \"FLUENT_MISSING_CONTEXT\",\n /** Invalid branch type in ID generation */\n INVALID_BRANCH: \"FLUENT_INVALID_BRANCH\",\n /** Template produced no output */\n TEMPLATE_NO_OUTPUT: \"FLUENT_TEMPLATE_NO_OUTPUT\",\n /** Invalid path in value resolution */\n INVALID_PATH: \"FLUENT_INVALID_PATH\",\n} as const;\n\n/**\n * Type for error codes\n */\nexport type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];\n\n/**\n * Custom error class for fluent builder errors.\n * Provides structured error information with error codes.\n */\nexport class FluentError extends Error {\n readonly code: ErrorCode;\n readonly context?: Record<string, unknown>;\n\n constructor(\n code: ErrorCode,\n message: string,\n context?: Record<string, unknown>,\n ) {\n const contextStr = context ? ` Context: ${JSON.stringify(context)}` : \"\";\n super(`[${code}] ${message}${contextStr}`);\n this.name = \"FluentError\";\n this.code = code;\n this.context = context;\n\n // Maintains proper stack trace in V8 environments\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, FluentError);\n }\n }\n}\n\n/**\n * Creates a FluentError with the given code and message.\n * This is a convenience function for creating errors.\n *\n * @param code - The error code from ErrorCodes\n * @param message - Human-readable error message\n * @param context - Optional context object with additional details\n * @returns A FluentError instance\n *\n * @example\n * throw createFluentError(\n * ErrorCodes.MISSING_CONTEXT,\n * \"Context is required for template resolution\",\n * { templateCount: 3 }\n * );\n */\nexport function createFluentError(\n code: ErrorCode,\n message: string,\n context?: Record<string, unknown>,\n): FluentError {\n return new FluentError(code, message, context);\n}\n","import type { Asset, Template } from \"@player-ui/types\";\nimport {\n type BaseBuildContext,\n genId,\n isFluentBuilder,\n BranchTypes,\n} from \"../base-builder\";\nimport {\n isTaggedTemplateValue,\n type TaggedTemplateValue,\n} from \"../tagged-template\";\n\n/**\n * Symbol marker to identify template functions\n */\nexport const TEMPLATE_MARKER = Symbol.for(\"fluent-builder-template\");\n\n/**\n * Type guard to check if a function is a template function\n */\nexport function isTemplate(fn: unknown): fn is ReturnType<typeof template> {\n return (\n typeof fn === \"function\" &&\n TEMPLATE_MARKER in (fn as { [TEMPLATE_MARKER]?: unknown })\n );\n}\n\n/**\n * Arguments for creating a template configuration\n * @template T - The type of asset that will be created for each item in the array\n */\ninterface TemplateArgs<T extends Asset<string>> {\n /** A binding that points to an array in the model */\n readonly data: string | TaggedTemplateValue;\n /** A property to put the mapped objects. If not provided, will be inferred from context */\n readonly output?: string;\n /** The asset creator - can be a static asset, a FluentBuilder, or a builder function that returns an asset */\n readonly value:\n | T\n | { build(context?: BaseBuildContext): T }\n | (<K extends BaseBuildContext>(ctx: K) => T);\n /** Whether template should be recomputed when data changes */\n readonly dynamic?: boolean;\n}\n\n/**\n * Creates a template configuration for dynamically creating a list of assets based on array data.\n * Templates provide a way to dynamically create a list of assets, or any object, based on data from the model.\n * All of the templating semantics are removed by the time it reaches an asset's transform or UI layer.\n *\n * Within a template, the `_index_` string can be used to substitute the array-index of the item being mapped.\n *\n * Multiple templates:\n * - Templates can be nested. Use `_index_` for the outer loop, `_index1_` for the inner loop, and so on.\n * - Multiple templates can output to the same property using the same output name. Items will be appended.\n * - Templates can append to existing arrays by using the same output property name.\n *\n * Dynamic vs Static Templates:\n * - If dynamic is false (default), the template will be parsed when a view first renders and won't update as data changes.\n * - If dynamic is true, template will be updated whenever data changes while a view is still showing.\n *\n * @param args - The template configuration arguments\n * @returns A function that takes parent context and returns a Template configuration\n * @see https://player-ui.github.io/next/content/assets-views/#templates\n * @example\n * ```ts\n * // Using a static asset\n * template({\n * data: binding`users`,\n * output: \"items\",\n * value: text({ value: binding`users._index_.name` })\n * })(parentCtx)\n * ```\n *\n * @example\n * ```ts\n * // Using a builder function\n * template({\n * data: binding`users`,\n * output: \"items\",\n * value: (ctx) => text({ value: binding`users._index_.name` }).withId(genId(ctx))\n * })(parentCtx)\n * ```\n *\n * @example Multiple templates with the same output\n * ```ts\n * [\n * template({\n * data: binding`names`,\n * output: \"values\",\n * value: text({ id: `name-_index_`, value: binding`names._index_` })\n * })(parentCtx),\n * template({\n * data: binding`otherNames`,\n * output: \"values\",\n * value: text({ id: `other-name-_index_`, value: binding`otherNames._index_` })\n * })(parentCtx)\n * ]\n * ```\n *\n * @example Dynamic template that updates when data changes\n * ```ts\n * template({\n * data: binding`users`,\n * output: \"items\",\n * dynamic: true,\n * value: text({ value: binding`users._index_.name` })\n * })(parentCtx)\n * ```\n */\nexport const template = <T extends Asset<string>>({\n data,\n output,\n value,\n dynamic = false,\n}: TemplateArgs<T>) => {\n const templateFn = (parentCtx: BaseBuildContext): Template<{ asset: T }> => {\n // If output is not provided, try to infer from context\n const resolvedOutput = output || inferOutputFromContext(parentCtx);\n\n if (!resolvedOutput) {\n throw new Error(\n \"Template output must be provided or inferrable from context. \" +\n \"When using template in asset arrays, ensure the array property can be inferred \" +\n \"(e.g., collection().withValues([template(...)]) infers 'values' as output).\",\n );\n }\n\n // Create template context for the value - use the generated parent ID to include slot context\n const templateValueCtx: BaseBuildContext = {\n parentId: genId(parentCtx),\n branch: {\n type: BranchTypes.TEMPLATE,\n depth: 0,\n },\n };\n\n let resolvedAsset: T;\n if (isFluentBuilder(value)) {\n resolvedAsset = value.build(templateValueCtx) as T;\n } else if (typeof value === \"function\") {\n const builderResult = value(templateValueCtx);\n if (typeof builderResult === \"function\") {\n resolvedAsset = (builderResult as (ctx: BaseBuildContext) => T)(\n templateValueCtx,\n );\n } else {\n resolvedAsset = builderResult;\n }\n } else {\n if (typeof value === \"object\" && value !== null) {\n resolvedAsset = { ...value } as T;\n } else {\n resolvedAsset = value;\n }\n }\n\n return {\n data: isTaggedTemplateValue(data) ? data.toString() : data,\n output: resolvedOutput,\n value: {\n asset: resolvedAsset,\n },\n ...(dynamic && { dynamic }),\n };\n };\n\n // Add the marker symbol to the function\n (templateFn as typeof templateFn & { [TEMPLATE_MARKER]: true })[\n TEMPLATE_MARKER\n ] = true;\n\n return templateFn;\n};\n\n/**\n * Helper function to infer output property name from BaseBuildContext\n */\nfunction inferOutputFromContext(\n parentCtx: BaseBuildContext,\n): string | undefined {\n // Check if we're in a slot context that can give us the property name\n if (parentCtx.branch?.type === \"slot\") {\n const slotName = parentCtx.branch.name;\n // Extract property name from slot names like \"values-0\", \"items-2\", etc.\n const match = slotName.match(/^([a-zA-Z_][a-zA-Z0-9_]*)-\\d+$/);\n if (match) {\n return match[1];\n }\n // If it's just a property name without index, use it directly\n if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(slotName)) {\n return slotName;\n }\n }\n return undefined;\n}\n","import { Asset, Flow, DataModel, Navigation, Schema } from \"@player-ui/types\";\nimport { BaseBuildContext, BranchTypes } from \"../base-builder\";\n\n/**\n * Core options for creating a Player-UI Flow\n */\ninterface CoreFlowOptions<\n T extends Asset = Asset,\n C extends BaseBuildContext = BaseBuildContext,\n> {\n id?: string;\n views: Array<T | { build(context?: C): T } | ((ctx: C) => T)>;\n data?: DataModel;\n schema?: Schema.Schema;\n navigation: Navigation;\n context?: C;\n}\n\n/**\n * Options for creating a Player-UI Flow\n * Allows additional properties to be passed through to the final Flow\n */\nexport type FlowOptions<\n T extends Asset = Asset,\n C extends BaseBuildContext = BaseBuildContext,\n> = CoreFlowOptions<T, C> &\n Omit<Flow<T>, keyof CoreFlowOptions<T, C> | \"views\">;\n\n/**\n * Creates a Player-UI Flow from the given options\n *\n * @example\n * ```ts\n * import { flow } from './flow';\n * import { text } from './assets';\n *\n * const myFlow = flow({\n * id: 'example-flow',\n * views: [text().withValue('Some Text').withId('view-1')],\n * navigation: {\n * BEGIN: 'FLOW_1',\n * FLOW_1: {\n * startState: 'VIEW_1',\n * VIEW_1: { state_type: 'VIEW', ref: 'view-1', transitions: { '*': 'END_Done' } },\n * END_Done: { state_type: 'END', outcome: 'done' }\n * }\n * }\n * });\n * ```\n */\nfunction isBuilder<T>(\n value: T | { build(context?: BaseBuildContext): T },\n): value is { build(context?: BaseBuildContext): T } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"build\" in value &&\n typeof value.build === \"function\"\n );\n}\n\nfunction isBuilderFunction<T>(\n value: T | ((ctx: BaseBuildContext) => T),\n): value is (ctx: BaseBuildContext) => T {\n return typeof value === \"function\";\n}\n\nexport function flow<T extends Asset = Asset>(\n options: FlowOptions<T>,\n): Flow<T> {\n const flowId = options.id || \"root\";\n\n const viewsNamespace = `${flowId}-views`;\n\n const processedViews = (() => {\n const processViews = (): T[] => {\n const results: T[] = [];\n\n for (let index = 0; index < options.views.length; index++) {\n const viewOrFn = options.views[index];\n const ctx: BaseBuildContext = {\n parentId: viewsNamespace,\n branch: {\n type: BranchTypes.ARRAY_ITEM,\n index,\n },\n ...(options.context ?? {}),\n };\n\n if (isBuilder(viewOrFn)) {\n results.push(viewOrFn.build(ctx));\n } else if (isBuilderFunction(viewOrFn)) {\n results.push(viewOrFn(ctx));\n } else {\n results.push(viewOrFn);\n }\n }\n\n return results;\n };\n\n return processViews();\n })();\n\n // Extract core properties that need special handling (views and context are handled separately)\n const { views: _views, context: _context, ...restOptions } = options;\n void _views; // Handled via processedViews\n void _context; // Used to construct view build context\n\n return {\n ...restOptions,\n id: flowId,\n views: processedViews,\n ...(options.data && { data: options.data }),\n ...(options.schema && { schema: options.schema }),\n navigation: options.navigation,\n };\n}\n","import type { Schema, Language } from \"@player-ui/types\";\nimport { SyncWaterfallHook } from \"tapable-ts\";\nimport { dequal } from \"dequal\";\nimport { SchemaGeneratorInput } from \"./types\";\n\n/** Symbol to indicate that a schema node should be generated with a different name */\nexport const SchemaTypeName = Symbol.for(\"Schema Rename\");\n\nexport type LoggingInterface = Pick<Console, \"warn\" | \"error\" | \"log\">;\n\ninterface SchemaChildren {\n /** Object property that will be used to create the intermediate type */\n name: string;\n\n /** Object properties children that will be parsed */\n child: Record<string, unknown>;\n}\n\ntype SchemaNode = (Schema.DataType | Language.DataTypeRef) & {\n /** Overwrite the name of the generated type */\n [SchemaTypeName]?: string;\n};\n\ninterface GeneratedDataType {\n /** The SchemaNode that was generated */\n node: SchemaNode;\n /** How many times it has been generated */\n count: number;\n}\n\n/**\n * Type Guard for the `Schema.DataType` and `Language.DataTypeRef` type\n * A bit hacky but since `Schema.Schema` must have a `Schema.DataType` as\n * the final product we have to call it that even if it is a `Language.DataTypeRef`\n */\nconst isTypeDef = (property: SchemaNode): property is Schema.DataType => {\n return (property as Schema.DataType).type !== undefined;\n};\n\n/**\n * Generator for `Schema.Schema` Objects\n */\nexport class SchemaGenerator {\n private children: SchemaChildren[] = [];\n private generatedDataTypes: Map<string, GeneratedDataType> = new Map();\n private typeNameCache: Map<string, string> = new Map();\n private logger: LoggingInterface;\n\n public hooks = {\n createSchemaNode: new SyncWaterfallHook<\n [\n node: Schema.DataType,\n originalProperty: Record<string | symbol, unknown>,\n ]\n >(),\n };\n\n constructor(logger?: LoggingInterface) {\n this.logger = logger ?? console;\n }\n\n /**\n * Converts an object to a `Schema.Schema` representation\n * Optimized to minimize object operations and memory allocations\n */\n public toSchema = (schema: SchemaGeneratorInput): Schema.Schema => {\n // Clear state efficiently\n this.children.length = 0;\n this.generatedDataTypes.clear();\n this.typeNameCache.clear();\n\n const newSchema: Schema.Schema = {\n ROOT: {},\n };\n\n // Pre-allocate arrays and use for...in for better performance\n const rootKeys = Object.keys(schema);\n for (let i = 0; i < rootKeys.length; i++) {\n const property = rootKeys[i];\n const subType = schema[property] as SchemaNode;\n newSchema.ROOT[property] = this.hooks.createSchemaNode.call(\n this.processChild(property, subType),\n subType as unknown as Record<string | symbol, unknown>,\n );\n }\n\n // Process children using optimized iteration\n while (this.children.length > 0) {\n const { name, child } = this.children.pop()!;\n const typeDef: Record<string, Schema.DataType> = {};\n\n const childKeys = Object.keys(child);\n for (let i = 0; i < childKeys.length; i++) {\n const property = childKeys[i];\n const subType = child[property] as SchemaNode;\n typeDef[property] = this.hooks.createSchemaNode.call(\n this.processChild(property, subType),\n subType as unknown as Record<string | symbol, unknown>,\n );\n }\n newSchema[name] = typeDef;\n }\n\n return newSchema;\n };\n\n private processChild(property: string, subType: SchemaNode): Schema.DataType {\n if (isTypeDef(subType)) {\n return subType;\n }\n\n let intermediateType: Schema.DataType;\n let child: Record<string, unknown>;\n\n if (Array.isArray(subType)) {\n if (subType.length > 1) {\n this.logger.warn(\n `Type ${property} has multiple types in array, should only contain one top level object type. Only taking first defined type`,\n );\n }\n\n const subTypeName = subType[0][SchemaTypeName] ?? property;\n intermediateType = this.makePlaceholderArrayType(subTypeName);\n child = subType[0] as Record<string, unknown>;\n } else {\n const subTypeName = subType[SchemaTypeName] ?? property;\n intermediateType = this.makePlaceholderType(subTypeName);\n child = subType as unknown as Record<string, unknown>;\n }\n\n const typeName = intermediateType.type;\n\n if (this.generatedDataTypes.has(typeName)) {\n const generatedType = this.generatedDataTypes.get(typeName)!;\n\n // Use deep equality check to ensure types are actually different\n if (\n !dequal(child, this.generatedDataTypes.get(typeName)?.node as object)\n ) {\n generatedType.count += 1;\n const newTypeName = `${typeName}${generatedType.count}`;\n intermediateType = {\n ...intermediateType,\n type: newTypeName,\n };\n this.logger.warn(\n `WARNING: Generated two intermediate types with the name: ${typeName} that are of different shapes, using artificial type ${newTypeName}`,\n );\n\n // Add new type mapping for the new artificial type\n this.generatedDataTypes.set(newTypeName, {\n node: subType,\n count: 1,\n });\n this.children.push({ name: newTypeName, child });\n return intermediateType;\n }\n } else {\n this.generatedDataTypes.set(typeName, {\n node: subType,\n count: 1,\n });\n }\n\n this.children.push({ name: intermediateType.type, child });\n return intermediateType;\n }\n\n /**\n * Cached type name generation\n */\n private makePlaceholderType = (typeName: string): Schema.DataType => {\n let cachedName = this.typeNameCache.get(typeName);\n if (!cachedName) {\n cachedName = `${typeName}Type`;\n this.typeNameCache.set(typeName, cachedName);\n }\n return { type: cachedName };\n };\n\n /**\n * Cached array type name generation\n */\n private makePlaceholderArrayType(typeName: string): Schema.DataType {\n let cachedName = this.typeNameCache.get(typeName);\n if (!cachedName) {\n cachedName = `${typeName}Type`;\n this.typeNameCache.set(typeName, cachedName);\n }\n return {\n type: cachedName,\n isArray: true,\n };\n }\n}\n","import { isTaggedTemplateValue, TaggedTemplateValue } from \"../tagged-template\";\n\n/**\n * Type that can be either a direct value T or a TaggedTemplateValue\n */\nexport type TaggedOr<T> = T | TaggedTemplateValue;\n\n/**\n * Safely extract a string if TaggedTemplateValue is present\n */\nexport function safeToString<T extends TaggedOr<string | unknown>>(\n value: T,\n): string {\n if (isTaggedTemplateValue(value)) {\n return value.toString();\n }\n return String(value);\n}\n\n/**\n * Safely extract a boolean if TaggedTemplateValue is present\n */\nexport function safeToBoolean<T extends TaggedOr<boolean | unknown>>(\n value: T,\n): boolean {\n if (isTaggedTemplateValue(value)) {\n return value.toString() === \"true\";\n }\n return Boolean(value);\n}\n\n/**\n * Safely extract a number if TaggedTemplateValue is present\n */\nexport function safeToNumber<T extends TaggedOr<number | unknown>>(\n value: T,\n): number {\n if (isTaggedTemplateValue(value)) {\n return Number(value.toString());\n }\n return Number(value);\n}\n\n/**\n * Type for an item that could be in an array with TaggedTemplate values\n */\nexport type ArrayItem<T> = T extends (infer U)[] ? U : T;\n\n/**\n * Safely extract an array of values if TaggedTemplateValue is present\n * Preserves element types when possible and handles nested arrays recursively\n */\nexport function safeToArray<T extends unknown[] | unknown>(\n value: TaggedOr<T>,\n): Array<DeepUnwrapTagged<ArrayItem<T>>> {\n if (isTaggedTemplateValue(value)) {\n return [value.toString()] as Array<DeepUnwrapTagged<ArrayItem<T>>>;\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => {\n if (isTaggedTemplateValue(item)) {\n return item.toString();\n } else if (Array.isArray(item)) {\n return safeToArray(item);\n } else if (\n item &&\n typeof item === \"object\" &&\n !isTaggedTemplateValue(item)\n ) {\n return safeToObject(item as Record<string, unknown>);\n }\n return item;\n }) as Array<DeepUnwrapTagged<ArrayItem<T>>>;\n }\n\n return [value] as Array<DeepUnwrapTagged<ArrayItem<T>>>;\n}\n\n/**\n * Recursively transforms a type by replacing TaggedTemplateValue with string\n * and handling unions that contain TaggedTemplateValue\n */\nexport type DeepUnwrapTagged<T> =\n // If T is exactly TaggedTemplateValue, convert to string\n T extends TaggedTemplateValue\n ? T extends string // Check if TaggedTemplateValue also extends string to avoid conflicts\n ? string\n : string\n : // If T is a union that includes TaggedTemplateValue, remove TaggedTemplateValue from the union\n TaggedTemplateValue extends T\n ? T extends TaggedTemplateValue\n ? string // T is exactly TaggedTemplateValue\n : Exclude<T, TaggedTemplateValue> // T is a union containing TaggedTemplateValue - remove it\n : // Handle arrays\n T extends Array<infer U>\n ? Array<DeepUnwrapTagged<U>>\n : // Handle records/objects\n T extends Record<string, unknown>\n ? { [K in keyof T]: DeepUnwrapTagged<T[K]> }\n : // Default case - return as is\n T;\n\n/**\n * Safely extract an object if TaggedTemplateValue is present\n * Recursively handles nested TaggedTemplateValues\n */\nexport function safeToObject<T extends Record<string, unknown>>(\n value: T,\n): DeepUnwrapTagged<T> {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return value as DeepUnwrapTagged<T>;\n }\n\n return Object.fromEntries(\n Object.entries(value).map(([key, val]) => {\n if (isTaggedTemplateValue(val)) {\n return [key, val.toString()];\n } else if (Array.isArray(val)) {\n return [key, safeToArray(val)];\n } else if (\n val &&\n typeof val === \"object\" &&\n !isTaggedTemplateValue(val)\n ) {\n return [key, safeToObject(val as Record<string, unknown>)];\n }\n return [key, val];\n }),\n ) as DeepUnwrapTagged<T>;\n}\n\n/**\n * Processes a value that could be a string, TaggedTemplateValue, or\n * a complex object with nested TaggedTemplateValue instances\n *\n * This is useful for handling complex union types like:\n * string | TaggedTemplateValue | Record<string, string | TaggedTemplateValue>\n */\nexport function safeFromMixedType<T>(value: unknown): DeepUnwrapTagged<T> {\n // Handle TaggedTemplateValue directly\n if (isTaggedTemplateValue(value)) {\n return value.toString() as DeepUnwrapTagged<T>;\n }\n\n // Handle objects (including records)\n if (value && typeof value === \"object\" && !Array.isArray(value)) {\n return safeToObject(\n value as Record<string, unknown>,\n ) as DeepUnwrapTagged<T>;\n }\n\n // Handle arrays\n if (Array.isArray(value)) {\n return safeToArray(value) as unknown as DeepUnwrapTagged<T>;\n }\n\n // Handle primitives\n return value as DeepUnwrapTagged<T>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;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