@cratis/screenplay-language 5.3.0 → 5.3.1

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 (395) hide show
  1. package/dist/bundles/TypeReferenceSymbol.js.map +1 -1
  2. package/dist/bundles/action-subject-authoring.js.map +1 -1
  3. package/dist/bundles/bmp-word-characters.js.map +1 -1
  4. package/dist/bundles/case-authoring.js +1 -1
  5. package/dist/bundles/case-authoring.js.map +1 -1
  6. package/dist/bundles/code-actions.js.map +1 -1
  7. package/dist/bundles/command-read-completions.js.map +1 -1
  8. package/dist/bundles/compiler/Authoring/ActionSubjectQuickFixes.js +3 -3
  9. package/dist/bundles/compiler/Authoring/ActionSubjectQuickFixes.js.map +1 -1
  10. package/dist/bundles/compiler/Authoring/QuickFixes.js +4 -4
  11. package/dist/bundles/compiler/Authoring/QuickFixes.js.map +1 -1
  12. package/dist/bundles/compiler/Authoring/StructuredValueQuickFix.js +1 -1
  13. package/dist/bundles/compiler/Authoring/StructuredValueQuickFix.js.map +1 -1
  14. package/dist/bundles/compiler/Authoring/TimelineQuickFixContext.js +4 -4
  15. package/dist/bundles/compiler/Authoring/TimelineQuickFixContext.js.map +1 -1
  16. package/dist/bundles/compiler/Authoring/TimelineQuickFixImports.js +2 -2
  17. package/dist/bundles/compiler/Authoring/TimelineQuickFixImports.js.map +1 -1
  18. package/dist/bundles/compiler/Authoring/TimelineQuickFixes.js +1 -1
  19. package/dist/bundles/compiler/Authoring/TimelineQuickFixes.js.map +1 -1
  20. package/dist/bundles/compiler/Dependencies/DeclaredDependencies.js.map +1 -1
  21. package/dist/bundles/compiler/Dependencies/DeclaredDependencyTargets.js.map +1 -1
  22. package/dist/bundles/compiler/Dependencies/DependencyGraph.js +1 -1
  23. package/dist/bundles/compiler/Dependencies/DependencyGraph.js.map +1 -1
  24. package/dist/bundles/compiler/Dependencies/DependencyKind.js.map +1 -1
  25. package/dist/bundles/compiler/Dependencies/InvalidDependencyQuery.js.map +1 -1
  26. package/dist/bundles/compiler/Dependencies/SliceReferences.js.map +1 -1
  27. package/dist/bundles/compiler/Dependencies/StronglyConnectedGroups.js.map +1 -1
  28. package/dist/bundles/compiler/Diagnostics/DiagnosticArgument.js.map +1 -1
  29. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js +1 -1
  30. package/dist/bundles/compiler/Diagnostics/DiagnosticCodes.js.map +1 -1
  31. package/dist/bundles/compiler/Diagnostics/ProductionDestinationDiagnostics.js +1 -1
  32. package/dist/bundles/compiler/Diagnostics/ProductionDestinationDiagnostics.js.map +1 -1
  33. package/dist/bundles/compiler/Diagnostics/SourceLocation.js.map +1 -1
  34. package/dist/bundles/compiler/Files/AuthoredOrder.js +1 -1
  35. package/dist/bundles/compiler/Files/AuthoredOrder.js.map +1 -1
  36. package/dist/bundles/compiler/Files/OrderingRoot.js +1 -1
  37. package/dist/bundles/compiler/Files/OrderingRoot.js.map +1 -1
  38. package/dist/bundles/compiler/Files/PlayApplicationAssembly.js +1 -1
  39. package/dist/bundles/compiler/Files/PlayApplicationAssembly.js.map +1 -1
  40. package/dist/bundles/compiler/Files/PlayDocumentSource.js.map +1 -1
  41. package/dist/bundles/compiler/Files/PlayFolderMerge.js +1 -1
  42. package/dist/bundles/compiler/Files/PlayFolderMerge.js.map +1 -1
  43. package/dist/bundles/compiler/Files/PlayGlob.js +2 -1
  44. package/dist/bundles/compiler/Files/PlayGlob.js.map +1 -1
  45. package/dist/bundles/compiler/Files/PlayImports.js +1 -1
  46. package/dist/bundles/compiler/Files/PlayImports.js.map +1 -1
  47. package/dist/bundles/compiler/Files/PlayPlacement.js.map +1 -1
  48. package/dist/bundles/compiler/Files/TimelineOrder.js +1 -1
  49. package/dist/bundles/compiler/Files/TimelineOrder.js.map +1 -1
  50. package/dist/bundles/compiler/Generation/FiniteGenerationRules.js +1 -1
  51. package/dist/bundles/compiler/Generation/GenerationAssessmentCache.js.map +1 -1
  52. package/dist/bundles/compiler/Generation/GenerationChecksum.js.map +1 -1
  53. package/dist/bundles/compiler/Generation/GenerationPattern.js +1 -1
  54. package/dist/bundles/compiler/Generation/GenerationPattern.js.map +1 -1
  55. package/dist/bundles/compiler/Generation/GenerationPatternAssessment.js.map +1 -1
  56. package/dist/bundles/compiler/Generation/GenerationPatternParser.js.map +1 -1
  57. package/dist/bundles/compiler/Generation/GenerationPatternToken.js.map +1 -1
  58. package/dist/bundles/compiler/Generation/GenerationRuleProof.js +1 -1
  59. package/dist/bundles/compiler/Generation/InvalidGenerationPattern.js.map +1 -1
  60. package/dist/bundles/compiler/Generation/RegexCharacters.js.map +1 -1
  61. package/dist/bundles/compiler/Generation/RegexExpression.js.map +1 -1
  62. package/dist/bundles/compiler/Generation/RuleConsistency.js +1 -1
  63. package/dist/bundles/compiler/Parsing/ActionSubjectClause.js.map +1 -1
  64. package/dist/bundles/compiler/Parsing/ActionSubjectInputs.js.map +1 -1
  65. package/dist/bundles/compiler/Parsing/ActionSubjectResolution.js.map +1 -1
  66. package/dist/bundles/compiler/Parsing/ApplicationContextParser.js +1 -1
  67. package/dist/bundles/compiler/Parsing/ApplicationContextParser.js.map +1 -1
  68. package/dist/bundles/compiler/Parsing/AuthorizeParser.js +1 -1
  69. package/dist/bundles/compiler/Parsing/AuthorizeParser.js.map +1 -1
  70. package/dist/bundles/compiler/Parsing/CanvasPlacement.js.map +1 -1
  71. package/dist/bundles/compiler/Parsing/CaptureEventFixturesValidator.js.map +1 -1
  72. package/dist/bundles/compiler/Parsing/CaptureParser.js +1 -1
  73. package/dist/bundles/compiler/Parsing/CaptureParser.js.map +1 -1
  74. package/dist/bundles/compiler/Parsing/ClockOperandParser.js.map +1 -1
  75. package/dist/bundles/compiler/Parsing/CodeBlockParser.js.map +1 -1
  76. package/dist/bundles/compiler/Parsing/CommandDestinationTypes.js.map +1 -1
  77. package/dist/bundles/compiler/Parsing/CommandHandlerValidator.js.map +1 -1
  78. package/dist/bundles/compiler/Parsing/CommandParser.js +1 -1
  79. package/dist/bundles/compiler/Parsing/CommandParser.js.map +1 -1
  80. package/dist/bundles/compiler/Parsing/CommandReadSources.js.map +1 -1
  81. package/dist/bundles/compiler/Parsing/CommandResponseParser.js +1 -1
  82. package/dist/bundles/compiler/Parsing/CommandResponseParser.js.map +1 -1
  83. package/dist/bundles/compiler/Parsing/CommandStreamCandidates.js.map +1 -1
  84. package/dist/bundles/compiler/Parsing/CompositeStreamIdValidator.js.map +1 -1
  85. package/dist/bundles/compiler/Parsing/CompositionParser.js +1 -1
  86. package/dist/bundles/compiler/Parsing/CompositionParser.js.map +1 -1
  87. package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js +1 -1
  88. package/dist/bundles/compiler/Parsing/ConceptComplianceParser.js.map +1 -1
  89. package/dist/bundles/compiler/Parsing/ConditionDepthBudget.js +2 -0
  90. package/dist/bundles/compiler/Parsing/ConditionDepthBudget.js.map +1 -0
  91. package/dist/bundles/compiler/Parsing/ConditionParser.js +1 -1
  92. package/dist/bundles/compiler/Parsing/ConditionParser.js.map +1 -1
  93. package/dist/bundles/compiler/Parsing/ConstraintParser.js +1 -1
  94. package/dist/bundles/compiler/Parsing/ConstraintParser.js.map +1 -1
  95. package/dist/bundles/compiler/Parsing/ConstraintPropertyValidator.js +1 -1
  96. package/dist/bundles/compiler/Parsing/ConstraintPropertyValidator.js.map +1 -1
  97. package/dist/bundles/compiler/Parsing/ContinuationValues.js.map +1 -1
  98. package/dist/bundles/compiler/Parsing/DeclarationParsers.js +1 -1
  99. package/dist/bundles/compiler/Parsing/DeclarationParsers.js.map +1 -1
  100. package/dist/bundles/compiler/Parsing/DependencySourceParser.js +1 -1
  101. package/dist/bundles/compiler/Parsing/DependencySourceParser.js.map +1 -1
  102. package/dist/bundles/compiler/Parsing/DependsOnParser.js.map +1 -1
  103. package/dist/bundles/compiler/Parsing/DescriptionParser.js +1 -1
  104. package/dist/bundles/compiler/Parsing/DescriptionParser.js.map +1 -1
  105. package/dist/bundles/compiler/Parsing/DocumentationParser.js +1 -1
  106. package/dist/bundles/compiler/Parsing/DocumentationParser.js.map +1 -1
  107. package/dist/bundles/compiler/Parsing/EnumerationMembers.js +1 -1
  108. package/dist/bundles/compiler/Parsing/EnumerationMembers.js.map +1 -1
  109. package/dist/bundles/compiler/Parsing/EventMetadataParser.js +1 -1
  110. package/dist/bundles/compiler/Parsing/EventMetadataParser.js.map +1 -1
  111. package/dist/bundles/compiler/Parsing/EventSourceParser.js +1 -1
  112. package/dist/bundles/compiler/Parsing/EventSourceParser.js.map +1 -1
  113. package/dist/bundles/compiler/Parsing/EventSourceValidator.js +1 -1
  114. package/dist/bundles/compiler/Parsing/EventSourceValidator.js.map +1 -1
  115. package/dist/bundles/compiler/Parsing/EventSubjectValidator.js +1 -1
  116. package/dist/bundles/compiler/Parsing/EventSubjectValidator.js.map +1 -1
  117. package/dist/bundles/compiler/Parsing/ExpressionParser.js +1 -1
  118. package/dist/bundles/compiler/Parsing/ExpressionParser.js.map +1 -1
  119. package/dist/bundles/compiler/Parsing/FeatureBody.js +1 -1
  120. package/dist/bundles/compiler/Parsing/FeatureBody.js.map +1 -1
  121. package/dist/bundles/compiler/Parsing/FileImportParser.js.map +1 -1
  122. package/dist/bundles/compiler/Parsing/FileReferences.js.map +1 -1
  123. package/dist/bundles/compiler/Parsing/FoldedEventSources.js.map +1 -1
  124. package/dist/bundles/compiler/Parsing/GenerationBodyParser.js +1 -1
  125. package/dist/bundles/compiler/Parsing/GenerationBodyParser.js.map +1 -1
  126. package/dist/bundles/compiler/Parsing/GenerationParser.js +1 -1
  127. package/dist/bundles/compiler/Parsing/GenerationParser.js.map +1 -1
  128. package/dist/bundles/compiler/Parsing/GuardedActionInputs.js.map +1 -1
  129. package/dist/bundles/compiler/Parsing/GuardedActionParser.js +1 -1
  130. package/dist/bundles/compiler/Parsing/GuardedActionParser.js.map +1 -1
  131. package/dist/bundles/compiler/Parsing/GuardedActionShadowing.js.map +1 -1
  132. package/dist/bundles/compiler/Parsing/GuardedActionValidator.js +1 -1
  133. package/dist/bundles/compiler/Parsing/GuardedActionValidator.js.map +1 -1
  134. package/dist/bundles/compiler/Parsing/GuardedInteractions.js +1 -1
  135. package/dist/bundles/compiler/Parsing/GuardedInteractions.js.map +1 -1
  136. package/dist/bundles/compiler/Parsing/IdentifierComplianceValidator.js +1 -1
  137. package/dist/bundles/compiler/Parsing/IdentifierComplianceValidator.js.map +1 -1
  138. package/dist/bundles/compiler/Parsing/IdentityParser.js +1 -1
  139. package/dist/bundles/compiler/Parsing/IdentityParser.js.map +1 -1
  140. package/dist/bundles/compiler/Parsing/IdentityValidator.js.map +1 -1
  141. package/dist/bundles/compiler/Parsing/ImplementationParser.js +2 -2
  142. package/dist/bundles/compiler/Parsing/ImplementationParser.js.map +1 -1
  143. package/dist/bundles/compiler/Parsing/ImportDiscovery.js +1 -1
  144. package/dist/bundles/compiler/Parsing/ImportDiscovery.js.map +1 -1
  145. package/dist/bundles/compiler/Parsing/InlineEventValidator.js.map +1 -1
  146. package/dist/bundles/compiler/Parsing/InputUses.js +1 -1
  147. package/dist/bundles/compiler/Parsing/InputUses.js.map +1 -1
  148. package/dist/bundles/compiler/Parsing/InteractionAlternatives.js +1 -1
  149. package/dist/bundles/compiler/Parsing/InteractionAlternatives.js.map +1 -1
  150. package/dist/bundles/compiler/Parsing/InteractionExecutions.js +1 -1
  151. package/dist/bundles/compiler/Parsing/InteractionExecutions.js.map +1 -1
  152. package/dist/bundles/compiler/Parsing/LegacyTextRulePatterns.js.map +1 -1
  153. package/dist/bundles/compiler/Parsing/LineReader.js.map +1 -1
  154. package/dist/bundles/compiler/Parsing/LineText.js.map +1 -1
  155. package/dist/bundles/compiler/Parsing/MatchAmbiguity.js +1 -1
  156. package/dist/bundles/compiler/Parsing/MatchAmbiguity.js.map +1 -1
  157. package/dist/bundles/compiler/Parsing/MatchAmbiguityCharacters.js.map +1 -1
  158. package/dist/bundles/compiler/Parsing/MatchAmbiguityGraph.js.map +1 -1
  159. package/dist/bundles/compiler/Parsing/MatchAmbiguityParser.js.map +1 -1
  160. package/dist/bundles/compiler/Parsing/MatchOperandValidation.js +1 -1
  161. package/dist/bundles/compiler/Parsing/MatchOperandValidation.js.map +1 -1
  162. package/dist/bundles/compiler/Parsing/ModuleBody.js +1 -1
  163. package/dist/bundles/compiler/Parsing/ModuleBody.js.map +1 -1
  164. package/dist/bundles/compiler/Parsing/ObserverFilterParser.js +1 -1
  165. package/dist/bundles/compiler/Parsing/ObserverFilterParser.js.map +1 -1
  166. package/dist/bundles/compiler/Parsing/ObserverFilterValidator.js.map +1 -1
  167. package/dist/bundles/compiler/Parsing/OperationParser.js +1 -1
  168. package/dist/bundles/compiler/Parsing/OperationParser.js.map +1 -1
  169. package/dist/bundles/compiler/Parsing/OperationValidator.js +1 -1
  170. package/dist/bundles/compiler/Parsing/OperationValidator.js.map +1 -1
  171. package/dist/bundles/compiler/Parsing/ParserContext.js.map +1 -1
  172. package/dist/bundles/compiler/Parsing/PersonaCallerValidator.js.map +1 -1
  173. package/dist/bundles/compiler/Parsing/PolicyParser.js +1 -1
  174. package/dist/bundles/compiler/Parsing/PolicyParser.js.map +1 -1
  175. package/dist/bundles/compiler/Parsing/PortableMatchGroupName.js.map +1 -1
  176. package/dist/bundles/compiler/Parsing/PortableMatchPattern.js.map +1 -1
  177. package/dist/bundles/compiler/Parsing/PortableMatchSuggestions.js.map +1 -1
  178. package/dist/bundles/compiler/Parsing/PossibleEventsParser.js +1 -1
  179. package/dist/bundles/compiler/Parsing/PossibleEventsParser.js.map +1 -1
  180. package/dist/bundles/compiler/Parsing/ProducesParser.js +1 -1
  181. package/dist/bundles/compiler/Parsing/ProducesParser.js.map +1 -1
  182. package/dist/bundles/compiler/Parsing/ProjectionEventScopeValidator.js.map +1 -1
  183. package/dist/bundles/compiler/Parsing/ProjectionExpressionParser.js +1 -1
  184. package/dist/bundles/compiler/Parsing/ProjectionExpressionParser.js.map +1 -1
  185. package/dist/bundles/compiler/Parsing/ProjectionParser.js +1 -1
  186. package/dist/bundles/compiler/Parsing/ProjectionParser.js.map +1 -1
  187. package/dist/bundles/compiler/Parsing/ProjectionTargetValidator.js +1 -1
  188. package/dist/bundles/compiler/Parsing/ProjectionTargetValidator.js.map +1 -1
  189. package/dist/bundles/compiler/Parsing/PropertyLineParser.js +1 -1
  190. package/dist/bundles/compiler/Parsing/PropertyLineParser.js.map +1 -1
  191. package/dist/bundles/compiler/Parsing/PublicEventMetadataValidator.js +1 -1
  192. package/dist/bundles/compiler/Parsing/PublicEventMetadataValidator.js.map +1 -1
  193. package/dist/bundles/compiler/Parsing/PublicEventUsageCollector.js +1 -1
  194. package/dist/bundles/compiler/Parsing/PublicEventUsageCollector.js.map +1 -1
  195. package/dist/bundles/compiler/Parsing/PublicEventUsageValidator.js +1 -1
  196. package/dist/bundles/compiler/Parsing/PublicEventUsageValidator.js.map +1 -1
  197. package/dist/bundles/compiler/Parsing/PurposeParser.js +1 -1
  198. package/dist/bundles/compiler/Parsing/PurposeParser.js.map +1 -1
  199. package/dist/bundles/compiler/Parsing/PurposeValidator.js.map +1 -1
  200. package/dist/bundles/compiler/Parsing/QueryParser.js +1 -1
  201. package/dist/bundles/compiler/Parsing/QueryParser.js.map +1 -1
  202. package/dist/bundles/compiler/Parsing/ReactionIdentityParser.js +1 -1
  203. package/dist/bundles/compiler/Parsing/ReactionIdentityParser.js.map +1 -1
  204. package/dist/bundles/compiler/Parsing/ReactionParser.js +1 -1
  205. package/dist/bundles/compiler/Parsing/ReactionParser.js.map +1 -1
  206. package/dist/bundles/compiler/Parsing/ReactionRefusalValidator.js +1 -1
  207. package/dist/bundles/compiler/Parsing/ReactionRefusalValidator.js.map +1 -1
  208. package/dist/bundles/compiler/Parsing/ReadModelKeyValidator.js.map +1 -1
  209. package/dist/bundles/compiler/Parsing/ReadModelMemberTypeValidator.js.map +1 -1
  210. package/dist/bundles/compiler/Parsing/ReadsParser.js +1 -1
  211. package/dist/bundles/compiler/Parsing/ReadsParser.js.map +1 -1
  212. package/dist/bundles/compiler/Parsing/RedeliveryValues.js.map +1 -1
  213. package/dist/bundles/compiler/Parsing/RefusalDeclarations.js +1 -1
  214. package/dist/bundles/compiler/Parsing/RefusalDeclarations.js.map +1 -1
  215. package/dist/bundles/compiler/Parsing/RefusalValueWalker.js.map +1 -1
  216. package/dist/bundles/compiler/Parsing/ResponseCommandResolver.js.map +1 -1
  217. package/dist/bundles/compiler/Parsing/ResponseDateValues.js.map +1 -1
  218. package/dist/bundles/compiler/Parsing/ResponseValidator.js +1 -1
  219. package/dist/bundles/compiler/Parsing/ResponseValidator.js.map +1 -1
  220. package/dist/bundles/compiler/Parsing/ScreenParser.js +1 -1
  221. package/dist/bundles/compiler/Parsing/ScreenParser.js.map +1 -1
  222. package/dist/bundles/compiler/Parsing/ScreenplayParser.js +1 -1
  223. package/dist/bundles/compiler/Parsing/ScreenplayParser.js.map +1 -1
  224. package/dist/bundles/compiler/Parsing/SeedParser.js +1 -1
  225. package/dist/bundles/compiler/Parsing/SeedParser.js.map +1 -1
  226. package/dist/bundles/compiler/Parsing/SliceParser.js +1 -1
  227. package/dist/bundles/compiler/Parsing/SliceParser.js.map +1 -1
  228. package/dist/bundles/compiler/Parsing/SourceLine.js.map +1 -1
  229. package/dist/bundles/compiler/Parsing/SourceLineSplitter.js.map +1 -1
  230. package/dist/bundles/compiler/Parsing/SourceOptionsParser.js +1 -1
  231. package/dist/bundles/compiler/Parsing/SourceOptionsParser.js.map +1 -1
  232. package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js +1 -1
  233. package/dist/bundles/compiler/Parsing/SpecificationCaseParser.js.map +1 -1
  234. package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js +1 -1
  235. package/dist/bundles/compiler/Parsing/SpecificationCaseValidator.js.map +1 -1
  236. package/dist/bundles/compiler/Parsing/SpecificationCommandExamples.js +1 -1
  237. package/dist/bundles/compiler/Parsing/SpecificationCommandExamples.js.map +1 -1
  238. package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js +1 -1
  239. package/dist/bundles/compiler/Parsing/SpecificationExampleParser.js.map +1 -1
  240. package/dist/bundles/compiler/Parsing/SpecificationParser.js +1 -1
  241. package/dist/bundles/compiler/Parsing/SpecificationParser.js.map +1 -1
  242. package/dist/bundles/compiler/Parsing/SpecificationRedeliveryValidator.js +1 -1
  243. package/dist/bundles/compiler/Parsing/SpecificationRedeliveryValidator.js.map +1 -1
  244. package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js +1 -1
  245. package/dist/bundles/compiler/Parsing/SpecificationResponseParser.js.map +1 -1
  246. package/dist/bundles/compiler/Parsing/SpecificationRouteComparison.js +1 -1
  247. package/dist/bundles/compiler/Parsing/SpecificationRouteComparison.js.map +1 -1
  248. package/dist/bundles/compiler/Parsing/SpecificationStreamValidator.js +1 -1
  249. package/dist/bundles/compiler/Parsing/SpecificationStreamValidator.js.map +1 -1
  250. package/dist/bundles/compiler/Parsing/StateMachineParser.js +1 -1
  251. package/dist/bundles/compiler/Parsing/StateMachineParser.js.map +1 -1
  252. package/dist/bundles/compiler/Parsing/StructuralInteractionSites.js.map +1 -1
  253. package/dist/bundles/compiler/Parsing/StructuredBlockParser.js +1 -1
  254. package/dist/bundles/compiler/Parsing/StructuredBlockParser.js.map +1 -1
  255. package/dist/bundles/compiler/Parsing/StructuredValueParser.js.map +1 -1
  256. package/dist/bundles/compiler/Parsing/TemplateReferenceText.js +1 -1
  257. package/dist/bundles/compiler/Parsing/TemplateReferenceText.js.map +1 -1
  258. package/dist/bundles/compiler/Parsing/TriggerDataParser.js +1 -1
  259. package/dist/bundles/compiler/Parsing/TriggerDataParser.js.map +1 -1
  260. package/dist/bundles/compiler/Parsing/UiBindingParser.js +1 -1
  261. package/dist/bundles/compiler/Parsing/UiBindingParser.js.map +1 -1
  262. package/dist/bundles/compiler/Parsing/UiProfileLegacyLayout.js +1 -1
  263. package/dist/bundles/compiler/Parsing/UiProfileLegacyLayout.js.map +1 -1
  264. package/dist/bundles/compiler/Parsing/WorkflowParser.js +1 -1
  265. package/dist/bundles/compiler/Parsing/WorkflowParser.js.map +1 -1
  266. package/dist/bundles/compiler/Parsing/checkPortableMatchPattern.js.map +1 -1
  267. package/dist/bundles/compiler/Parsing/hasExponentialMatchAmbiguity.js.map +1 -1
  268. package/dist/bundles/compiler/Parsing/trimMatchAmbiguityGraph.js.map +1 -1
  269. package/dist/bundles/compiler/ScreenActionSubjects.js.map +1 -1
  270. package/dist/bundles/compiler/ScreenplayCompiler.js +1 -1
  271. package/dist/bundles/compiler/ScreenplayCompiler.js.map +1 -1
  272. package/dist/bundles/compiler/Syntax/ActionSubjectInvariants.js.map +1 -1
  273. package/dist/bundles/compiler/Syntax/AuthoringProductionResolver.js.map +1 -1
  274. package/dist/bundles/compiler/Syntax/CaptureEventsSource.js.map +1 -1
  275. package/dist/bundles/compiler/Syntax/DependencySources.js.map +1 -1
  276. package/dist/bundles/compiler/Syntax/EventDeclarations.js.map +1 -1
  277. package/dist/bundles/compiler/Syntax/EventSourceCatalog.js.map +1 -1
  278. package/dist/bundles/compiler/Syntax/EventSourceReadConfidence.js.map +1 -1
  279. package/dist/bundles/compiler/Syntax/ExactMathFacts.js.map +1 -1
  280. package/dist/bundles/compiler/Syntax/ExactNumber.js.map +1 -1
  281. package/dist/bundles/compiler/Syntax/InvalidSyntaxJson.js.map +1 -1
  282. package/dist/bundles/compiler/Syntax/LegacyWireProjection.js.map +1 -1
  283. package/dist/bundles/compiler/Syntax/Operations.js.map +1 -1
  284. package/dist/bundles/compiler/Syntax/PersonaCallers.js.map +1 -1
  285. package/dist/bundles/compiler/Syntax/ProductionDestinations.js.map +1 -1
  286. package/dist/bundles/compiler/Syntax/PublicEventInvariants.js.map +1 -1
  287. package/dist/bundles/compiler/Syntax/ScreenplaySyntaxWalker.js.map +1 -1
  288. package/dist/bundles/compiler/Syntax/SourceOptions.js.map +1 -1
  289. package/dist/bundles/compiler/Syntax/SpecificationCaseOrigin.js.map +1 -1
  290. package/dist/bundles/compiler/Syntax/StreamIdFormatter.js.map +1 -1
  291. package/dist/bundles/compiler/Syntax/StrictSyntaxJson.js +1 -1
  292. package/dist/bundles/compiler/Syntax/Structure.js.map +1 -1
  293. package/dist/bundles/compiler/Syntax/SyntaxCollections.js.map +1 -1
  294. package/dist/bundles/compiler/Syntax/SyntaxInvariants.js +1 -1
  295. package/dist/bundles/compiler/Syntax/SyntaxInvariants.js.map +1 -1
  296. package/dist/bundles/compiler/Syntax/SyntaxJson.js +1 -1
  297. package/dist/bundles/compiler/Syntax/SyntaxJson.js.map +1 -1
  298. package/dist/bundles/compiler/Syntax/SyntaxMemberContracts.js.map +1 -1
  299. package/dist/bundles/compiler/Syntax/index.js +1 -1
  300. package/dist/bundles/compiler/Text/ImplementationHintText.js.map +1 -1
  301. package/dist/bundles/compiler/Text/ReservedWords.js.map +1 -1
  302. package/dist/bundles/compiler/Text/SourceStreamNames.js.map +1 -1
  303. package/dist/bundles/compiler/Text/StringLiteral.js.map +1 -1
  304. package/dist/bundles/compiler/Text/ordinalIgnoreCaseKey.js.map +1 -1
  305. package/dist/bundles/compiler/Text/patterns.js.map +1 -1
  306. package/dist/bundles/compiler/index.js +1 -1
  307. package/dist/bundles/completion-items.js +4 -4
  308. package/dist/bundles/completion-items.js.map +1 -1
  309. package/dist/bundles/completion-planner.js +2 -2
  310. package/dist/bundles/completion-planner.js.map +1 -1
  311. package/dist/bundles/completions.js +1 -1
  312. package/dist/bundles/completions.js.map +1 -1
  313. package/dist/bundles/continuation-responses.js +1 -1
  314. package/dist/bundles/continuation-responses.js.map +1 -1
  315. package/dist/bundles/declarations.js.map +1 -1
  316. package/dist/bundles/dependency-completions.js.map +1 -1
  317. package/dist/bundles/dependency-target-analysis.js.map +1 -1
  318. package/dist/bundles/diagnostic-codes.js +1 -1
  319. package/dist/bundles/diagnostic-codes.js.map +1 -1
  320. package/dist/bundles/diagnostics.js +1 -1
  321. package/dist/bundles/diagnostics.js.map +1 -1
  322. package/dist/bundles/document-context.js.map +1 -1
  323. package/dist/bundles/documentation-item.js.map +1 -1
  324. package/dist/bundles/event-analysis-source.js.map +1 -1
  325. package/dist/bundles/event-context-catalog.js.map +1 -1
  326. package/dist/bundles/event-context.js.map +1 -1
  327. package/dist/bundles/event-source-authoring.js +11 -11
  328. package/dist/bundles/event-source-authoring.js.map +1 -1
  329. package/dist/bundles/example-analysis.js +2 -2
  330. package/dist/bundles/example-analysis.js.map +1 -1
  331. package/dist/bundles/example-authoring.js +2 -2
  332. package/dist/bundles/example-authoring.js.map +1 -1
  333. package/dist/bundles/example-declaration-items.js.map +1 -1
  334. package/dist/bundles/example-values.js.map +1 -1
  335. package/dist/bundles/file-imports.js.map +1 -1
  336. package/dist/bundles/file-references.js.map +1 -1
  337. package/dist/bundles/generation-completions.js.map +1 -1
  338. package/dist/bundles/hover-content.js +5 -5
  339. package/dist/bundles/hover-content.js.map +1 -1
  340. package/dist/bundles/hover.js.map +1 -1
  341. package/dist/bundles/index.js +1 -1
  342. package/dist/bundles/index.js.map +1 -1
  343. package/dist/bundles/inlay-hints.js.map +1 -1
  344. package/dist/bundles/inline-completions.js +1 -1
  345. package/dist/bundles/inline-completions.js.map +1 -1
  346. package/dist/bundles/inline-event-validation.js +1 -1
  347. package/dist/bundles/inline-event-validation.js.map +1 -1
  348. package/dist/bundles/keyword-docs.js.map +1 -1
  349. package/dist/bundles/language.js.map +1 -1
  350. package/dist/bundles/named-rule-context.js.map +1 -1
  351. package/dist/bundles/operation-authoring.js +6 -6
  352. package/dist/bundles/operation-authoring.js.map +1 -1
  353. package/dist/bundles/persona-analysis.js +1 -1
  354. package/dist/bundles/persona-analysis.js.map +1 -1
  355. package/dist/bundles/production-destinations.js +1 -1
  356. package/dist/bundles/production-destinations.js.map +1 -1
  357. package/dist/bundles/purpose-items.js.map +1 -1
  358. package/dist/bundles/reaction-authoring.js +3 -3
  359. package/dist/bundles/reaction-authoring.js.map +1 -1
  360. package/dist/bundles/read-model-key-completions.js +1 -1
  361. package/dist/bundles/read-model-key-completions.js.map +1 -1
  362. package/dist/bundles/refusal-context.js.map +1 -1
  363. package/dist/bundles/response-analysis.js.map +1 -1
  364. package/dist/bundles/response-completions.js +1 -1
  365. package/dist/bundles/response-completions.js.map +1 -1
  366. package/dist/bundles/response-tokens.js +2 -2
  367. package/dist/bundles/response-tokens.js.map +1 -1
  368. package/dist/bundles/scope-items.js +3 -3
  369. package/dist/bundles/scope-items.js.map +1 -1
  370. package/dist/bundles/structure-completions.js.map +1 -1
  371. package/dist/bundles/sub-language-registry.js.map +1 -1
  372. package/dist/bundles/sub-languages/capture/CompletionProvider.js.map +1 -1
  373. package/dist/bundles/sub-languages/capture/HoverProvider.js.map +1 -1
  374. package/dist/bundles/sub-languages/capture/Validator.js.map +1 -1
  375. package/dist/bundles/sub-languages/capture/index.js.map +1 -1
  376. package/dist/bundles/sub-languages/capture/language.js.map +1 -1
  377. package/dist/bundles/sub-languages/cdl.js.map +1 -1
  378. package/dist/bundles/sub-languages/pdl.js.map +1 -1
  379. package/dist/bundles/sub-languages/projection/CodeActionProvider.js.map +1 -1
  380. package/dist/bundles/sub-languages/projection/CompletionProvider.js +1 -1
  381. package/dist/bundles/sub-languages/projection/CompletionProvider.js.map +1 -1
  382. package/dist/bundles/sub-languages/projection/HoverProvider.js.map +1 -1
  383. package/dist/bundles/sub-languages/projection/Validator.js.map +1 -1
  384. package/dist/bundles/sub-languages/projection/index.js.map +1 -1
  385. package/dist/bundles/sub-languages/projection/language.js.map +1 -1
  386. package/dist/bundles/symbols.js +2 -2
  387. package/dist/bundles/symbols.js.map +1 -1
  388. package/dist/bundles/themes/screenplay-dark.js.map +1 -1
  389. package/dist/bundles/themes/screenplay-light.js.map +1 -1
  390. package/dist/bundles/tokens.js.map +1 -1
  391. package/dist/bundles/validation.js +2 -2
  392. package/dist/bundles/validation.js.map +1 -1
  393. package/dist/diagnostic-codes.d.ts +1 -0
  394. package/dist/diagnostic-codes.d.ts.map +1 -1
  395. package/package.json +3 -3
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{describePlacement as t,documentPlacement as n,isWithinOrSame as r,samePlacement as i}from"./PlayPlacement.js";import{placementFrom as a}from"../Parsing/ImportDiscovery.js";import{hasWildcard as o,matchesPlayPattern as s,normalizePlayPath as c,resolvePlayPattern as l,staticFolderOf as u}from"./PlayGlob.js";import{discoverImports as d}from"../ScreenplayCompiler.js";function resolveImports(e,t,n){let r=new Resolution(t,n);for(let t of new Set([...e].map(c)))r.addRoot(t);return r.settle(),{documents:r.documents(),diagnostics:r.diagnostics}}var Resolution=class{source;languages;diagnostics=[];#e=[];#t=/* @__PURE__ */ new Set;#n=/* @__PURE__ */ new Map;#r=/* @__PURE__ */ new Map;#i=/* @__PURE__ */ new Map;#a=/* @__PURE__ */ new Map;#o=[];#s=/* @__PURE__ */ new Map;#c=/* @__PURE__ */ new Set;constructor(e,t){this.source=e,this.languages=t}addRoot(e){this.#t.add(e),this.#u(e)}settle(){for(let e=this.#o.shift();e!==void 0;e=this.#o.shift())this.#f(e);this.#v();let e=[...this.#c];for(let t of e)for(let n of(this.#r.get(t)??[]).flatMap(e=>e.targets))this.#c.has(n)||(this.#c.add(n),e.push(n))}documents(){return this.#l().map(e=>({path:e,source:this.#n.get(e),placement:this.#h(e)??n,isPlacementResolved:!this.#c.has(e)}))}#l(){if(this.#t.size!==1)return[...this.#e];let e=/* @__PURE__ */ new Set,t=[];for(let n of this.#e){let r=[n];for(let n=r.pop();n!==void 0;n=r.pop())e.has(n)||(e.add(n),t.push(n),r.push(...(this.#r.get(n)??[]).flatMap(e=>e.targets).reverse()))}return t}#u(e){if(this.#n.has(e))return;this.#e.push(e);let t=this.source.read(e);this.#n.set(e,t),this.#r.set(e,d(t,e,this.languages).map(t=>({discovered:t,targets:this.#d(e,t)}))),this.#o.push(e)}#d(t,n){let{pattern:r,location:i}=n.fileImport,a=l(t,r),d=[...new Set([...this.source.filesBeneath(u(a))].map(c).filter(e=>e!==t&&s(a,e)))].sort();return d.length===0&&this.#y(o(r)?{severity:`warning`,code:e.FileImportMatchesNothing,message:`Import '${r}' matches no .play file`,location:i}:error(e.ImportedFileNotFound,`Imported file '${r}' does not exist`,i)),d}#f(t){let n=this.#h(t);this.#r.get(t).forEach(({discovered:r,targets:i},o)=>{let s=n===void 0?void 0:a(r,n);s!==void 0&&s.length>32&&(this.#y(error(e.ImportCycle,`Import '${r.fileImport.pattern}' places files deeper than 32 levels - the imports form a cycle`,r.fileImport.location)),this.#c.add(t),s=void 0);for(let e of i)this.#u(e),this.#p(e,t,o,s)})}#p(e,t,n,r){let a=this.#i.get(e)??/* @__PURE__ */ new Map;this.#i.set(e,a);let o=JSON.stringify([t,n]),s=a.get(o),c=r===void 0?a.delete(o):s===void 0||!i(s.placement,r);r!==void 0&&a.set(o,{importer:t,index:n,placement:r}),c&&this.#m(e)}#m(t){let n=this.#g(t),r=this.#a.get(t);if(!(r===void 0?n!==void 0:n===void 0||!i(r,n)))return;let a=(this.#s.get(t)??0)+1;if(this.#s.set(t,a),a>32){this.#c.add(t);for(let{discovered:{fileImport:n}}of this.#r.get(t))this.#y(error(e.ImportCycle,`Import '${n.pattern}' is part of imports that keep placing each other - the imports form a cycle`,n.location))}else n===void 0?this.#a.delete(t):this.#a.set(t,n),this.#o.push(t)}#h(e){return this.#a.get(e)??this.#g(e)}#g(e){return[...this.#t.has(e)?[n]:[],...this.#_(e).map(e=>e.placement)].reduce((e,t)=>e===void 0||r(t,e)?t:e,void 0)}#_(e){return[...this.#i.get(e)?.values()??[]].sort((e,t)=>e.importer===t.importer?e.index-t.index:e.importer<t.importer?-1:1)}#v(){for(let n of this.#e){let i=this.#h(n);if(i!==void 0){for(let{importer:a,index:o,placement:s}of this.#_(n))if(!r(i,s)){this.#c.add(n);let{fileImport:r}=this.#r.get(a)[o].discovered;this.#y(error(e.ConflictingImportPlacement,`'${n}' is imported into both ${t(i)} and ${t(s)} - a file belongs in one place`,r.location))}}}}#y(e){let t=keyOf(e);this.diagnostics.some(e=>keyOf(e)===t)||this.diagnostics.push(e)}};const keyOf=e=>JSON.stringify([e.severity,e.code,e.message,e.location]),error=(e,t,n)=>({severity:`error`,code:e,message:t,location:n});export{resolveImports};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{placementFrom as t}from"../Parsing/ImportDiscovery.js";import{discoverImports as n}from"../ScreenplayCompiler.js";import{hasWildcard as r,matchesPlayPattern as i,normalizePlayPath as a,resolvePlayPattern as o,staticFolderOf as s}from"./PlayGlob.js";import{describePlacement as c,documentPlacement as l,isWithinOrSame as u,samePlacement as d}from"./PlayPlacement.js";function resolveImports(e,t,n){let r=new Resolution(t,n);for(let t of new Set([...e].map(a)))r.addRoot(t);return r.settle(),{documents:r.documents(),diagnostics:r.diagnostics}}var Resolution=class{source;languages;diagnostics=[];#e=[];#t=/* @__PURE__ */ new Set;#n=/* @__PURE__ */ new Map;#r=/* @__PURE__ */ new Map;#i=/* @__PURE__ */ new Map;#a=/* @__PURE__ */ new Map;#o=[];#s=/* @__PURE__ */ new Map;#c=/* @__PURE__ */ new Set;constructor(e,t){this.source=e,this.languages=t}addRoot(e){this.#t.add(e),this.#u(e)}settle(){for(let e=this.#o.shift();e!==void 0;e=this.#o.shift())this.#f(e);this.#v();let e=[...this.#c];for(let t of e)for(let n of(this.#r.get(t)??[]).flatMap(e=>e.targets))this.#c.has(n)||(this.#c.add(n),e.push(n))}documents(){return this.#l().map(e=>({path:e,source:this.#n.get(e),placement:this.#h(e)??l,isPlacementResolved:!this.#c.has(e)}))}#l(){if(this.#t.size!==1)return[...this.#e];let e=/* @__PURE__ */ new Set,t=[];for(let n of this.#e){let r=[n];for(let n=r.pop();n!==void 0;n=r.pop())e.has(n)||(e.add(n),t.push(n),r.push(...(this.#r.get(n)??[]).flatMap(e=>e.targets).reverse()))}return t}#u(e){if(this.#n.has(e))return;this.#e.push(e);let t=this.source.read(e);this.#n.set(e,t),this.#r.set(e,n(t,e,this.languages).map(t=>({discovered:t,targets:this.#d(e,t)}))),this.#o.push(e)}#d(t,n){let{pattern:c,location:l}=n.fileImport,u=o(t,c),d=[...new Set([...this.source.filesBeneath(s(u))].map(a).filter(e=>e!==t&&i(u,e)))].sort();return d.length===0&&this.#y(r(c)?{severity:`warning`,code:e.FileImportMatchesNothing,message:`Import '${c}' matches no .play file`,location:l}:error(e.ImportedFileNotFound,`Imported file '${c}' does not exist`,l)),d}#f(n){let r=this.#h(n);this.#r.get(n).forEach(({discovered:i,targets:a},o)=>{let s=r===void 0?void 0:t(i,r);s!==void 0&&s.length>32&&(this.#y(error(e.ImportCycle,`Import '${i.fileImport.pattern}' places files deeper than 32 levels - the imports form a cycle`,i.fileImport.location)),this.#c.add(n),s=void 0);for(let e of a)this.#u(e),this.#p(e,n,o,s)})}#p(e,t,n,r){let i=this.#i.get(e)??/* @__PURE__ */ new Map;this.#i.set(e,i);let a=JSON.stringify([t,n]),o=i.get(a),s=r===void 0?i.delete(a):o===void 0||!d(o.placement,r);r!==void 0&&i.set(a,{importer:t,index:n,placement:r}),s&&this.#m(e)}#m(t){let n=this.#g(t),r=this.#a.get(t);if(!(r===void 0?n!==void 0:n===void 0||!d(r,n)))return;let i=(this.#s.get(t)??0)+1;if(this.#s.set(t,i),i>32){this.#c.add(t);for(let{discovered:{fileImport:n}}of this.#r.get(t))this.#y(error(e.ImportCycle,`Import '${n.pattern}' is part of imports that keep placing each other - the imports form a cycle`,n.location))}else n===void 0?this.#a.delete(t):this.#a.set(t,n),this.#o.push(t)}#h(e){return this.#a.get(e)??this.#g(e)}#g(e){return[...this.#t.has(e)?[l]:[],...this.#_(e).map(e=>e.placement)].reduce((e,t)=>e===void 0||u(t,e)?t:e,void 0)}#_(e){return[...this.#i.get(e)?.values()??[]].sort((e,t)=>e.importer===t.importer?e.index-t.index:e.importer<t.importer?-1:1)}#v(){for(let t of this.#e){let n=this.#h(t);if(n!==void 0){for(let{importer:r,index:i,placement:a}of this.#_(t))if(!u(n,a)){this.#c.add(t);let{fileImport:o}=this.#r.get(r)[i].discovered;this.#y(error(e.ConflictingImportPlacement,`'${t}' is imported into both ${c(n)} and ${c(a)} - a file belongs in one place`,o.location))}}}}#y(e){let t=keyOf(e);this.diagnostics.some(e=>keyOf(e)===t)||this.diagnostics.push(e)}};const keyOf=e=>JSON.stringify([e.severity,e.code,e.message,e.location]),error=(e,t,n)=>({severity:`error`,code:e,message:t,location:n});export{resolveImports};
2
2
  //# sourceMappingURL=PlayImports.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlayImports.js","names":["resolution","source","languages","root","roots","normalizePlayPath","#roots","#find","file","#pending","#propagate","#reportConflicts","unresolved","#unresolved","importer","target","#imports","imported","#orderedPaths","#sources","path","#placement","documentPlacement","#found","seen","ordered","pending","text","discoverImports","#targets","discovered","resolved","resolvePlayPattern","pattern","matches","staticFolderOf","matchesPlayPattern","#report","hasWildcard","DiagnosticCodes","location","placement","placementFrom","targets","#contribute","index","contributions","#contributions","key","current","changed","samePlacement","#recompute","#deepest","#placements","changes","#changes","fileImport","#ordered","contribution","deepest","isWithinOrSame","candidate","left","right","describePlacement","diagnostic","other"],"sources":["../../../../../../Compiler/Files/PlayImports.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Diagnostic } from '../Diagnostics/Diagnostic';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { DiscoveredImport, placementFrom } from '../Parsing/ImportDiscovery';\nimport { discoverImports } from '../ScreenplayCompiler';\nimport { PlacedPlayDocument, PlayDocumentSource } from './PlayDocumentSource';\nimport { hasWildcard, matchesPlayPattern, normalizePlayPath, resolvePlayPattern, staticFolderOf } from './PlayGlob';\nimport { describePlacement, documentPlacement, isWithinOrSame, PlayPlacement, samePlacement } from './PlayPlacement';\n\n// How deep a placement may get, and how often one file's placement may change, before the imports behind it\n// are taken to be a cycle.\nexport const maximumImportDepth = 32;\n\n// The documents of an application, and the diagnostics settling them produced.\nexport interface ResolvedImports {\n readonly documents: readonly PlacedPlayDocument[];\n readonly diagnostics: readonly Diagnostic[];\n}\n\n// Settles which documents make up an application and where each one's top level belongs, by following the\n// file imports from a set of root documents - the port of the C# PlayImports.Resolve.\n//\n// A root document is a whole document. Every file an import matches joins the application once, however many\n// imports match it. When several imports place the same file, the deepest placement wins; two placements where\n// neither lies inside the other are a conflict, and placements that keep deepening are an import cycle. A file's\n// placement depends on the placements of the files importing it, so it is recomputed from every importer's\n// current placement until nothing changes - the order files are found in never decides where one belongs. The\n// documents keep discovery order for multiple roots; a single root follows authored imports depth-first.\nexport function resolveImports(roots: Iterable<string>, source: PlayDocumentSource, languages?: ReadonlySet<string>): ResolvedImports {\n const resolution = new Resolution(source, languages);\n for (const root of new Set([...roots].map(normalizePlayPath))) {\n resolution.addRoot(root);\n }\n resolution.settle();\n return { documents: resolution.documents(), diagnostics: resolution.diagnostics };\n}\n\ninterface FoundImport {\n readonly discovered: DiscoveredImport;\n readonly targets: readonly string[];\n}\n\n// What each import currently contributes to a file's placement, keyed by the importing file and the import.\ntype Contributions = Map<string, { readonly importer: string; readonly index: number; readonly placement: PlayPlacement }>;\n\nclass Resolution {\n readonly diagnostics: Diagnostic[] = [];\n readonly #found: string[] = [];\n readonly #roots = new Set<string>();\n readonly #sources = new Map<string, string>();\n readonly #imports = new Map<string, readonly FoundImport[]>();\n readonly #contributions = new Map<string, Contributions>();\n readonly #placements = new Map<string, PlayPlacement>();\n readonly #pending: string[] = [];\n readonly #changes = new Map<string, number>();\n readonly #unresolved = new Set<string>();\n\n constructor(private readonly source: PlayDocumentSource, private readonly languages?: ReadonlySet<string>) {}\n\n addRoot(root: string): void {\n this.#roots.add(root);\n this.#find(root);\n }\n\n // Placements only deepen, and none is allowed past the maximum depth, so this ends.\n settle(): void {\n for (let file = this.#pending.shift(); file !== undefined; file = this.#pending.shift()) {\n this.#propagate(file);\n }\n this.#reportConflicts();\n const unresolved = [...this.#unresolved];\n for (const importer of unresolved) {\n for (const target of (this.#imports.get(importer) ?? []).flatMap(imported => imported.targets)) {\n if (!this.#unresolved.has(target)) {\n this.#unresolved.add(target);\n unresolved.push(target);\n }\n }\n }\n }\n\n documents(): PlacedPlayDocument[] {\n return this.#orderedPaths().map(path => ({ path, source: this.#sources.get(path) as string, placement: this.#placement(path) ?? documentPlacement, isPlacementResolved: !this.#unresolved.has(path) }));\n }\n\n #orderedPaths(): string[] {\n // Folder compilation keeps discovery order for merge precedence and event ownership.\n // AuthoredOrder records presentation ranks independently, including explicit pins before globs.\n if (this.#roots.size !== 1) return [...this.#found];\n const seen = new Set<string>();\n const ordered: string[] = [];\n for (const root of this.#found) {\n const pending = [root];\n for (let path = pending.pop(); path !== undefined; path = pending.pop()) {\n if (seen.has(path)) continue;\n seen.add(path);\n ordered.push(path);\n pending.push(...(this.#imports.get(path) ?? []).flatMap(imported => imported.targets).reverse());\n }\n }\n return ordered;\n }\n\n #find(file: string): void {\n if (this.#sources.has(file)) return;\n this.#found.push(file);\n const text = this.source.read(file);\n this.#sources.set(file, text);\n this.#imports.set(file, discoverImports(text, file, this.languages).map(discovered => ({ discovered, targets: this.#targets(file, discovered) })));\n this.#pending.push(file);\n }\n\n #targets(file: string, discovered: DiscoveredImport): string[] {\n const { pattern, location } = discovered.fileImport;\n const resolved = resolvePlayPattern(file, pattern);\n // The default sort compares UTF-16 code units, which is the C# ordinal order.\n const matches = [...new Set([...this.source.filesBeneath(staticFolderOf(resolved))]\n .map(normalizePlayPath)\n .filter(path => path !== file && matchesPlayPattern(resolved, path)))].sort();\n if (matches.length === 0) {\n this.#report(hasWildcard(pattern)\n ? { severity: 'warning', code: DiagnosticCodes.FileImportMatchesNothing, message: `Import '${pattern}' matches no .play file`, location }\n : error(DiagnosticCodes.ImportedFileNotFound, `Imported file '${pattern}' does not exist`, location));\n }\n return matches;\n }\n\n #propagate(file: string): void {\n const placement = this.#placement(file);\n (this.#imports.get(file) as readonly FoundImport[]).forEach(({ discovered, targets }, index) => {\n let target = placement === undefined ? undefined : placementFrom(discovered, placement);\n if (target !== undefined && target.length > maximumImportDepth) {\n this.#report(error(DiagnosticCodes.ImportCycle,\n `Import '${discovered.fileImport.pattern}' places files deeper than ${maximumImportDepth} levels - the imports form a cycle`, discovered.fileImport.location));\n this.#unresolved.add(file);\n target = undefined;\n }\n for (const path of targets) {\n this.#find(path);\n this.#contribute(path, file, index, target);\n }\n });\n }\n\n #contribute(file: string, importer: string, index: number, placement: PlayPlacement | undefined): void {\n const contributions = this.#contributions.get(file) ?? new Map();\n this.#contributions.set(file, contributions);\n const key = JSON.stringify([importer, index]);\n const current = contributions.get(key);\n const changed = placement === undefined\n ? contributions.delete(key)\n : current === undefined || !samePlacement(current.placement, placement);\n if (placement !== undefined) {\n contributions.set(key, { importer, index, placement });\n }\n if (changed) {\n this.#recompute(file);\n }\n }\n\n #recompute(file: string): void {\n const placement = this.#deepest(file);\n const current = this.#placements.get(file);\n const changed = current === undefined ? placement !== undefined : placement === undefined || !samePlacement(current, placement);\n if (!changed) return;\n\n // A placement that keeps changing is held up by imports that feed back into themselves.\n const changes = (this.#changes.get(file) ?? 0) + 1;\n this.#changes.set(file, changes);\n if (changes > maximumImportDepth) {\n this.#unresolved.add(file);\n for (const { discovered: { fileImport } } of this.#imports.get(file) as readonly FoundImport[]) {\n this.#report(error(DiagnosticCodes.ImportCycle,\n `Import '${fileImport.pattern}' is part of imports that keep placing each other - the imports form a cycle`, fileImport.location));\n }\n return;\n }\n if (placement === undefined) {\n this.#placements.delete(file);\n } else {\n this.#placements.set(file, placement);\n }\n this.#pending.push(file);\n }\n\n #placement(file: string): PlayPlacement | undefined {\n return this.#placements.get(file) ?? this.#deepest(file);\n }\n\n #deepest(file: string): PlayPlacement | undefined {\n const candidates = [...(this.#roots.has(file) ? [documentPlacement] : []), ...this.#ordered(file).map(contribution => contribution.placement)];\n return candidates.reduce<PlayPlacement | undefined>(\n (deepest, candidate) => deepest === undefined || isWithinOrSame(candidate, deepest) ? candidate : deepest, undefined);\n }\n\n #ordered(file: string) {\n return [...(this.#contributions.get(file)?.values() ?? [])]\n .sort((left, right) => left.importer === right.importer ? left.index - right.index : left.importer < right.importer ? -1 : 1);\n }\n\n #reportConflicts(): void {\n for (const file of this.#found) {\n const placement = this.#placement(file);\n if (placement === undefined) continue;\n for (const { importer, index, placement: contribution } of this.#ordered(file)) {\n if (!isWithinOrSame(placement, contribution)) {\n this.#unresolved.add(file);\n const { fileImport } = (this.#imports.get(importer) as readonly FoundImport[])[index].discovered;\n this.#report(error(DiagnosticCodes.ConflictingImportPlacement,\n `'${file}' is imported into both ${describePlacement(placement)} and ${describePlacement(contribution)} - a file belongs in one place`, fileImport.location));\n }\n }\n }\n }\n\n // Reports a diagnostic once - a file whose placement changes runs its imports again.\n #report(diagnostic: Diagnostic): void {\n const key = keyOf(diagnostic);\n if (!this.diagnostics.some(other => keyOf(other) === key)) {\n this.diagnostics.push(diagnostic);\n }\n }\n}\n\nconst keyOf = (diagnostic: Diagnostic): string => JSON.stringify([diagnostic.severity, diagnostic.code, diagnostic.message, diagnostic.location]);\nconst error = (code: string, message: string, location: SourceLocation): Diagnostic => ({ severity: 'error', code, message, location });\n"],"mappings":"8eA+BA,SAAgB,eAAe,EAAyB,EAA4B,EAAkD,CAClI,IAAMA,EAAa,IAAI,WAAWC,EAAQC,CAAS,EACnD,IAAK,IAAMC,KAAQ,IAAI,IAAI,CAAC,GAAGC,CAAK,CAAC,CAAC,IAAIC,CAAiB,CAAC,EACxDL,EAAW,QAAQG,CAAI,EAG3B,OADAH,EAAW,OAAO,EACX,CAAE,UAAWA,EAAW,UAAU,EAAG,YAAaA,EAAW,WAAY,CACpF,CAUA,IAAM,WAAN,KAAiB,CAYgB,OAA6C,UAX1E,YAAqC,CAAC,EACtC,GAA4B,CAAC,EAC7B,mBAAkB,IAAI,IACtB,mBAAoB,IAAI,IACxB,mBAAoB,IAAI,IACxB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Y,EAAG,CAC1C,KAAK9C,GAAY,IAAIL,CAAI,EACzB,GAAM,CAAE,cAAgB,KAAKQ,GAAS,IAAIF,CAAQ,CAAC,CAA4B+B,EAAM,CAAC,WACtF,KAAKR,GAAQ,MAAME,EAAgB,2BAC/B,IAAI/B,EAAK,0BAA0ByD,EAAkBxB,CAAS,EAAE,OAAOwB,EAAkBN,CAAY,EAAE,gCAAiCF,EAAW,QAAQ,CAAC,CACpK,EAER,CACJ,CAGA,GAAQ,EAA8B,CAClC,IAAMT,EAAM,MAAMkB,CAAU,EACvB,KAAK,YAAY,KAAK,GAAS,MAAMC,CAAK,IAAMnB,CAAG,GACpD,KAAK,YAAY,KAAKkB,CAAU,CAExC,CACJ,EAEA,MAAM,MAAS,GAAmC,KAAK,UAAU,CAACA,EAAW,SAAUA,EAAW,KAAMA,EAAW,QAASA,EAAW,QAAQ,CAAC,EAC1I,OAAS,EAAc,EAAiB,KAA0C,CAAE,SAAU,QAAS,OAAM,UAAS,UAAS"}
1
+ {"version":3,"file":"PlayImports.js","names":["resolution","source","languages","root","roots","normalizePlayPath","#roots","#find","file","#pending","#propagate","#reportConflicts","unresolved","#unresolved","importer","target","#imports","imported","#orderedPaths","#sources","path","#placement","documentPlacement","#found","seen","ordered","pending","text","discoverImports","#targets","discovered","resolved","resolvePlayPattern","pattern","matches","staticFolderOf","matchesPlayPattern","#report","hasWildcard","DiagnosticCodes","location","placement","placementFrom","targets","#contribute","index","contributions","#contributions","key","current","changed","samePlacement","#recompute","#deepest","#placements","changes","#changes","fileImport","#ordered","contribution","deepest","isWithinOrSame","candidate","left","right","describePlacement","diagnostic","other"],"sources":["../../../../../../Compiler/Files/PlayImports.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Diagnostic } from '../Diagnostics/Diagnostic';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { DiscoveredImport, placementFrom } from '../Parsing/ImportDiscovery';\nimport { discoverImports } from '../ScreenplayCompiler';\nimport { PlacedPlayDocument, PlayDocumentSource } from './PlayDocumentSource';\nimport { hasWildcard, matchesPlayPattern, normalizePlayPath, resolvePlayPattern, staticFolderOf } from './PlayGlob';\nimport { describePlacement, documentPlacement, isWithinOrSame, PlayPlacement, samePlacement } from './PlayPlacement';\n\n// How deep a placement may get, and how often one file's placement may change, before the imports behind it\n// are taken to be a cycle.\nexport const maximumImportDepth = 32;\n\n// The documents of an application, and the diagnostics settling them produced.\nexport interface ResolvedImports {\n readonly documents: readonly PlacedPlayDocument[];\n readonly diagnostics: readonly Diagnostic[];\n}\n\n// Settles which documents make up an application and where each one's top level belongs, by following the\n// file imports from a set of root documents - the port of the C# PlayImports.Resolve.\n//\n// A root document is a whole document. Every file an import matches joins the application once, however many\n// imports match it. When several imports place the same file, the deepest placement wins; two placements where\n// neither lies inside the other are a conflict, and placements that keep deepening are an import cycle. A file's\n// placement depends on the placements of the files importing it, so it is recomputed from every importer's\n// current placement until nothing changes - the order files are found in never decides where one belongs. The\n// documents keep discovery order for multiple roots; a single root follows authored imports depth-first.\nexport function resolveImports(roots: Iterable<string>, source: PlayDocumentSource, languages?: ReadonlySet<string>): ResolvedImports {\n const resolution = new Resolution(source, languages);\n for (const root of new Set([...roots].map(normalizePlayPath))) {\n resolution.addRoot(root);\n }\n resolution.settle();\n return { documents: resolution.documents(), diagnostics: resolution.diagnostics };\n}\n\ninterface FoundImport {\n readonly discovered: DiscoveredImport;\n readonly targets: readonly string[];\n}\n\n// What each import currently contributes to a file's placement, keyed by the importing file and the import.\ntype Contributions = Map<string, { readonly importer: string; readonly index: number; readonly placement: PlayPlacement }>;\n\nclass Resolution {\n readonly diagnostics: Diagnostic[] = [];\n readonly #found: string[] = [];\n readonly #roots = new Set<string>();\n readonly #sources = new Map<string, string>();\n readonly #imports = new Map<string, readonly FoundImport[]>();\n readonly #contributions = new Map<string, Contributions>();\n readonly #placements = new Map<string, PlayPlacement>();\n readonly #pending: string[] = [];\n readonly #changes = new Map<string, number>();\n readonly #unresolved = new Set<string>();\n\n constructor(private readonly source: PlayDocumentSource, private readonly languages?: ReadonlySet<string>) {}\n\n addRoot(root: string): void {\n this.#roots.add(root);\n this.#find(root);\n }\n\n // Placements only deepen, and none is allowed past the maximum depth, so this ends.\n settle(): void {\n for (let file = this.#pending.shift(); file !== undefined; file = this.#pending.shift()) {\n this.#propagate(file);\n }\n this.#reportConflicts();\n const unresolved = [...this.#unresolved];\n for (const importer of unresolved) {\n for (const target of (this.#imports.get(importer) ?? []).flatMap(imported => imported.targets)) {\n if (!this.#unresolved.has(target)) {\n this.#unresolved.add(target);\n unresolved.push(target);\n }\n }\n }\n }\n\n documents(): PlacedPlayDocument[] {\n return this.#orderedPaths().map(path => ({ path, source: this.#sources.get(path) as string, placement: this.#placement(path) ?? documentPlacement, isPlacementResolved: !this.#unresolved.has(path) }));\n }\n\n #orderedPaths(): string[] {\n // Folder compilation keeps discovery order for merge precedence and event ownership.\n // AuthoredOrder records presentation ranks independently, including explicit pins before globs.\n if (this.#roots.size !== 1) return [...this.#found];\n const seen = new Set<string>();\n const ordered: string[] = [];\n for (const root of this.#found) {\n const pending = [root];\n for (let path = pending.pop(); path !== undefined; path = pending.pop()) {\n if (seen.has(path)) continue;\n seen.add(path);\n ordered.push(path);\n pending.push(...(this.#imports.get(path) ?? []).flatMap(imported => imported.targets).reverse());\n }\n }\n return ordered;\n }\n\n #find(file: string): void {\n if (this.#sources.has(file)) return;\n this.#found.push(file);\n const text = this.source.read(file);\n this.#sources.set(file, text);\n this.#imports.set(file, discoverImports(text, file, this.languages).map(discovered => ({ discovered, targets: this.#targets(file, discovered) })));\n this.#pending.push(file);\n }\n\n #targets(file: string, discovered: DiscoveredImport): string[] {\n const { pattern, location } = discovered.fileImport;\n const resolved = resolvePlayPattern(file, pattern);\n // The default sort compares UTF-16 code units, which is the C# ordinal order.\n const matches = [...new Set([...this.source.filesBeneath(staticFolderOf(resolved))]\n .map(normalizePlayPath)\n .filter(path => path !== file && matchesPlayPattern(resolved, path)))].sort();\n if (matches.length === 0) {\n this.#report(hasWildcard(pattern)\n ? { severity: 'warning', code: DiagnosticCodes.FileImportMatchesNothing, message: `Import '${pattern}' matches no .play file`, location }\n : error(DiagnosticCodes.ImportedFileNotFound, `Imported file '${pattern}' does not exist`, location));\n }\n return matches;\n }\n\n #propagate(file: string): void {\n const placement = this.#placement(file);\n (this.#imports.get(file) as readonly FoundImport[]).forEach(({ discovered, targets }, index) => {\n let target = placement === undefined ? undefined : placementFrom(discovered, placement);\n if (target !== undefined && target.length > maximumImportDepth) {\n this.#report(error(DiagnosticCodes.ImportCycle,\n `Import '${discovered.fileImport.pattern}' places files deeper than ${maximumImportDepth} levels - the imports form a cycle`, discovered.fileImport.location));\n this.#unresolved.add(file);\n target = undefined;\n }\n for (const path of targets) {\n this.#find(path);\n this.#contribute(path, file, index, target);\n }\n });\n }\n\n #contribute(file: string, importer: string, index: number, placement: PlayPlacement | undefined): void {\n const contributions = this.#contributions.get(file) ?? new Map();\n this.#contributions.set(file, contributions);\n const key = JSON.stringify([importer, index]);\n const current = contributions.get(key);\n const changed = placement === undefined\n ? contributions.delete(key)\n : current === undefined || !samePlacement(current.placement, placement);\n if (placement !== undefined) {\n contributions.set(key, { importer, index, placement });\n }\n if (changed) {\n this.#recompute(file);\n }\n }\n\n #recompute(file: string): void {\n const placement = this.#deepest(file);\n const current = this.#placements.get(file);\n const changed = current === undefined ? placement !== undefined : placement === undefined || !samePlacement(current, placement);\n if (!changed) return;\n\n // A placement that keeps changing is held up by imports that feed back into themselves.\n const changes = (this.#changes.get(file) ?? 0) + 1;\n this.#changes.set(file, changes);\n if (changes > maximumImportDepth) {\n this.#unresolved.add(file);\n for (const { discovered: { fileImport } } of this.#imports.get(file) as readonly FoundImport[]) {\n this.#report(error(DiagnosticCodes.ImportCycle,\n `Import '${fileImport.pattern}' is part of imports that keep placing each other - the imports form a cycle`, fileImport.location));\n }\n return;\n }\n if (placement === undefined) {\n this.#placements.delete(file);\n } else {\n this.#placements.set(file, placement);\n }\n this.#pending.push(file);\n }\n\n #placement(file: string): PlayPlacement | undefined {\n return this.#placements.get(file) ?? this.#deepest(file);\n }\n\n #deepest(file: string): PlayPlacement | undefined {\n const candidates = [...(this.#roots.has(file) ? [documentPlacement] : []), ...this.#ordered(file).map(contribution => contribution.placement)];\n return candidates.reduce<PlayPlacement | undefined>(\n (deepest, candidate) => deepest === undefined || isWithinOrSame(candidate, deepest) ? candidate : deepest, undefined);\n }\n\n #ordered(file: string) {\n return [...(this.#contributions.get(file)?.values() ?? [])]\n .sort((left, right) => left.importer === right.importer ? left.index - right.index : left.importer < right.importer ? -1 : 1);\n }\n\n #reportConflicts(): void {\n for (const file of this.#found) {\n const placement = this.#placement(file);\n if (placement === undefined) continue;\n for (const { importer, index, placement: contribution } of this.#ordered(file)) {\n if (!isWithinOrSame(placement, contribution)) {\n this.#unresolved.add(file);\n const { fileImport } = (this.#imports.get(importer) as readonly FoundImport[])[index].discovered;\n this.#report(error(DiagnosticCodes.ConflictingImportPlacement,\n `'${file}' is imported into both ${describePlacement(placement)} and ${describePlacement(contribution)} - a file belongs in one place`, fileImport.location));\n }\n }\n }\n }\n\n // Reports a diagnostic once - a file whose placement changes runs its imports again.\n #report(diagnostic: Diagnostic): void {\n const key = keyOf(diagnostic);\n if (!this.diagnostics.some(other => keyOf(other) === key)) {\n this.diagnostics.push(diagnostic);\n }\n }\n}\n\nconst keyOf = (diagnostic: Diagnostic): string => JSON.stringify([diagnostic.severity, diagnostic.code, diagnostic.message, diagnostic.location]);\nconst error = (code: string, message: string, location: SourceLocation): Diagnostic => ({ severity: 'error', code, message, location });\n"],"mappings":"A,8eA+BA,SAAgB,eAAe,EAAyB,EAA4B,EAAkD,CAClI,IAAMA,EAAa,IAAI,WAAWC,EAAQC,CAAS,EACnD,IAAK,IAAMC,KAAQ,IAAI,IAAI,CAAC,GAAGC,CAAK,CA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AM,MAAQD,EAAK,SAAWC,EAAM,SAAW,GAAK,CAAC,CACpI,CAEA,IAAyB,CACrB,IAAK,IAAMxD,KAAQ,KAAKe,GAAQ,CAC5B,IAAMkB,EAAY,KAAKpB,GAAWb,CAAI,EACtC,GAAIiC,IAAc,IAAA,GAClB,KAAK,GAAM,CAAE,WAAU,QAAO,UAAWkB,KAAkB,KAAKD,GAASlD,CAAI,EACzE,GAAI,CAACqD,EAAepB,EAAWkB,CAAY,EAAG,CAC1C,KAAK9C,GAAY,IAAIL,CAAI,EACzB,GAAM,CAAE,cAAgB,KAAKQ,GAAS,IAAIF,CAAQ,CAAC,CAA4B+B,EAAM,CAAC,WACtF,KAAKR,GAAQ,MAAME,EAAgB,2BAC/B,IAAI/B,EAAK,0BAA0ByD,EAAkBxB,CAAS,EAAE,OAAOwB,EAAkBN,CAAY,EAAE,gCAAiCF,EAAW,QAAQ,CAAC,CACpK,EAER,CACJ,CAGA,GAAQ,EAA8B,CAClC,IAAMT,EAAM,MAAMkB,CAAU,EACvB,KAAK,YAAY,KAAK,GAAS,MAAMC,CAAK,IAAMnB,CAAG,GACpD,KAAK,YAAY,KAAKkB,CAAU,CAExC,CACJ,EAEA,MAAM,MAAS,GAAmC,KAAK,UAAU,CAACA,EAAW,SAAUA,EAAW,KAAMA,EAAW,QAASA,EAAW,QAAQ,CAAC,EAC1I,OAAS,EAAc,EAAiB,KAA0C,CAAE,SAAU,QAAS,OAAM,UAAS,UAAS,G"}
@@ -1 +1 @@
1
- {"version":3,"file":"PlayPlacement.js","names":["documentPlacement","placement","other","name","index","left","right"],"sources":["../../../../../../Compiler/Files/PlayPlacement.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n// Where the top level of a .play file belongs: the module name followed by the names of the nested features,\n// outermost first, and empty for the application itself - the port of the C# PlayPlacement. A file is placed\n// by the import that brings it in: written inside 'module Ordering' and 'feature Orders', it places the\n// imported file at Ordering.Orders, so what the file declares at its top level is the body of that feature.\nexport type PlayPlacement = readonly string[];\n\n// The placement of a whole document - its top level is the application's.\nexport const documentPlacement: PlayPlacement = [];\n\n// Whether a file is a whole document rather than placed in a module or feature.\nexport const isDocumentPlacement = (placement: PlayPlacement): boolean => placement.length === 0;\n\n// The placement as it reads in a diagnostic, such as module 'Ordering' or feature 'Ordering.Orders'.\nexport function describePlacement(placement: PlayPlacement): string {\n if (placement.length === 0) return 'the application';\n if (placement.length === 1) return `module '${placement[0]}'`;\n return `feature '${placement.join('.')}'`;\n}\n\n// Whether one placement lies inside another, or is the same - the other's scope is a prefix of this one.\nexport const isWithinOrSame = (placement: PlayPlacement, other: PlayPlacement): boolean =>\n other.length <= placement.length && other.every((name, index) => name === placement[index]);\n\nexport const samePlacement = (left: PlayPlacement, right: PlayPlacement): boolean =>\n left.length === right.length && isWithinOrSame(left, right);\n"],"mappings":"qDAUA,MAAaA,EAAmC,CAAC,EAGpC,oBAAuB,GAAsCC,EAAU,SAAW,EAG/F,SAAgB,kBAAkB,EAAkC,CAGhE,OAFIA,EAAU,SAAW,EAAU,kBAC/BA,EAAU,SAAW,EAAU,WAAWA,EAAU,GAAG,GACpD,YAAYA,EAAU,KAAK,GAAG,EAAE,EAC3C,CAGA,MAAa,gBAAkB,EAA0B,IACrDC,EAAM,QAAUD,EAAU,QAAUC,EAAM,OAAO,EAAM,IAAUC,IAASF,EAAUG,EAAM,EAEjF,eAAiB,EAAqB,IAC/CC,EAAK,SAAWC,EAAM,QAAU,eAAeD,EAAMC,CAAK"}
1
+ {"version":3,"file":"PlayPlacement.js","names":["documentPlacement","placement","other","name","index","left","right"],"sources":["../../../../../../Compiler/Files/PlayPlacement.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n// Where the top level of a .play file belongs: the module name followed by the names of the nested features,\n// outermost first, and empty for the application itself - the port of the C# PlayPlacement. A file is placed\n// by the import that brings it in: written inside 'module Ordering' and 'feature Orders', it places the\n// imported file at Ordering.Orders, so what the file declares at its top level is the body of that feature.\nexport type PlayPlacement = readonly string[];\n\n// The placement of a whole document - its top level is the application's.\nexport const documentPlacement: PlayPlacement = [];\n\n// Whether a file is a whole document rather than placed in a module or feature.\nexport const isDocumentPlacement = (placement: PlayPlacement): boolean => placement.length === 0;\n\n// The placement as it reads in a diagnostic, such as module 'Ordering' or feature 'Ordering.Orders'.\nexport function describePlacement(placement: PlayPlacement): string {\n if (placement.length === 0) return 'the application';\n if (placement.length === 1) return `module '${placement[0]}'`;\n return `feature '${placement.join('.')}'`;\n}\n\n// Whether one placement lies inside another, or is the same - the other's scope is a prefix of this one.\nexport const isWithinOrSame = (placement: PlayPlacement, other: PlayPlacement): boolean =>\n other.length <= placement.length && other.every((name, index) => name === placement[index]);\n\nexport const samePlacement = (left: PlayPlacement, right: PlayPlacement): boolean =>\n left.length === right.length && isWithinOrSame(left, right);\n"],"mappings":"A,qDAUA,MAAaA,EAAmC,CAAC,EAGpC,oBAAuB,GAAsCC,EAAU,SAAW,EAG/F,SAAgB,kBAAkB,EAAkC,CAGhE,OAFIA,EAAU,SAAW,EAAU,kBAC/BA,EAAU,SAAW,EAAU,WAAWA,EAAU,GAAG,GACpD,YAAYA,EAAU,KAAK,GAAG,EAAE,EAC3C,CAGA,MAAa,gBAAkB,EAA0B,IACrDC,EAAM,QAAUD,EAAU,QAAUC,EAAM,OAAO,EAAM,IAAUC,IAASF,EAAUG,EAAM,EAEjF,eAAiB,EAAqB,IAC/CC,EAAK,SAAWC,EAAM,QAAU,eAAeD,EAAMC,CAAK,E"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{eventDeclarations as t}from"../Syntax/EventDeclarations.js";import{authoredOrderKey as n,authoredOrderOf as r}from"./AuthoredOrder.js";import{buildingReadModelReferences as i,sliceReferences as a}from"../Dependencies/SliceReferences.js";import{stronglyConnectedGroups as o}from"../Dependencies/StronglyConnectedGroups.js";import{DependencyGraph as s}from"../Dependencies/DependencyGraph.js";import{ordinalIgnoreCaseKey as c}from"../Text/ordinalIgnoreCaseKey.js";function timelineOrderDiagnostics(e){return timelineOrderFindings(e).map(e=>e.diagnostic)}function timelineOrderFindings(l,u=r(l)){let ordered=(e,t)=>e.map(e=>({syntax:e,rank:u.get(n([...t,e.name]))??2**53-1})).sort((e,t)=>e.rank-t.rank).map(e=>e.syntax),d=[],feature=(e,t)=>{let n=[...t,e.name];for(let t of ordered(e.slices,n))d.push({syntax:t,scope:[...n,t.name],identity:[...n.map(e=>`container:${e}`),`slice:${t.name}`],index:d.length});for(let t of ordered(e.features,n))feature(t,n)};for(let e of ordered(l.modules,[]))for(let t of ordered(e.features,[e.name]))feature(t,[e.name]);let f=new Map(d.map(e=>[e,/* @__PURE__ */ new Set([...t(e.syntax).map(e=>c(e.name)),...e.syntax.commands.flatMap(e=>e.produces.map(e=>c(e.event))),...e.syntax.reactions.flatMap(e=>e.triggers.flatMap(e=>e.produces.map(e=>c(e.event))))])])),p=/* @__PURE__ */ new Map;for(let e of d)for(let n of t(e.syntax)){let t=c(n.name);p.has(t)||p.set(t,e)}let m=/* @__PURE__ */ new Map;for(let e of d){let t=n(e.scope);m.has(t)||m.set(t,e)}let h=/* @__PURE__ */ new Map;for(let e of s.for(l,u).edges.filter(e=>e.kind===`decidesFrom`))for(let t of e.evidence){let r=n([...e.consumer.scope,t.name.toLowerCase()]);h.has(r)||h.set(r,m.get(n(e.producer.scope)))}let g=[];for(let e of d){let t=/* @__PURE__ */ new Set,r=a(e.syntax).references.filter(e=>e.timeline).map(e=>({event:e.name,location:e.location,readModel:e.targetKind===`ReadModel`}));for(let a of r){let r=c(a.event),o=`${a.readModel?`ReadModel`:`Event`}:${r}`;if(t.has(o))continue;t.add(o);let s=a.readModel?h.get(n([...e.scope,a.event.toLowerCase()])):p.get(r);if(s===void 0||s===e)continue;let l=0;for(;l<e.scope.length&&l<s.scope.length&&e.identity[l]===s.identity[l];)l++;if(l!==e.scope.length&&l!==s.scope.length){if(a.readModel){let t=e.identity.slice(0,l+1),n=new Set(d.filter(e=>t.every((t,n)=>e.identity[n]===t)).flatMap(e=>[...f.get(e)]));if(i(s.syntax,a.event).some(e=>e.timeline&&e.kind===`usesFactsFrom`&&e.targetKind===`Event`&&n.has(c(e.name))))continue}g.push({...a,consumer:e,producer:s,container:n(e.identity.slice(0,l)),left:e.identity[l],right:s.identity[l]})}}}let compare=(e,t)=>e.consumer.index-t.consumer.index||e.location.line-t.location.line||e.location.column-t.location.column,_=/* @__PURE__ */ new Set,v=[];for(let t of new Set(g.map(e=>e.container))){let r=g.filter(e=>e.container===t),i=/* @__PURE__ */ new Map;for(let e of r)i.has(e.left)||i.set(e.left,/* @__PURE__ */ new Set),i.has(e.right)||i.set(e.right,/* @__PURE__ */ new Set),i.get(e.left).add(e.right);for(let a of o(i).filter(e=>e.length>1)){let i=new Set(a),o=r.filter(e=>i.has(e.left)&&i.has(e.right));o.forEach(e=>_.add(e));let s=o.filter(e=>e.consumer.index<e.producer.index).sort(compare)[0];if(s===void 0)continue;let memberIndex=e=>Math.min(...o.flatMap(e=>[e.consumer,e.producer]).filter(n=>{let r=JSON.parse(t);return n.identity[r.length]===e}).map(e=>e.index));a.sort((e,t)=>memberIndex(e)-memberIndex(t)),v.push({edge:s,members:a,diagnostic:{severity:`information`,code:e.TimelineCycleGroup,message:`Timeline group ${a.map(e=>`${e.startsWith(`slice:`)?`slice`:t===n([])?`module`:`feature`} '${e.slice(e.indexOf(`:`)+1)}'`).join(`, `)} depend on each other's events or read models; reordering these members cannot make every dependency flow left to right.`,location:s.location}})}}for(let t of g){if(t.consumer.index>=t.producer.index||_.has(t))continue;let n=t.consumer.scope.slice(0,-1),r=t.producer.scope.length>t.consumer.scope.length&&n.every((e,n)=>t.producer.scope[n]===e),i=r?` The producer is in the consumer's own sub-feature; this cannot be fixed by reordering.`:` Consider drawing the producer before the consumer.`,a=t.readModel?`reads read model '${t.event}' built by`:`uses event '${t.event}' produced by`;v.push({edge:t,ownSubFeature:r,diagnostic:{severity:`information`,code:e.EventFromLaterSlice,message:`Slice '${t.consumer.syntax.name}' ${a} slice '${t.producer.syntax.name}' drawn after it.${i}`,location:t.location}})}return v.sort((e,t)=>compare(e.edge,t.edge)).map(({edge:e,diagnostic:t,members:r,ownSubFeature:i})=>({diagnostic:t,consumerScope:e.consumer.scope,producerScope:e.producer.scope,readModel:e.readModel,ownSubFeature:i===!0,key:n(r===void 0?[t.code,n(e.consumer.scope),...e.readModel?[`ReadModel`]:[],c(e.event)]:[t.code,e.container,...[...r].sort()])}))}export{timelineOrderDiagnostics,timelineOrderFindings};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{DiagnosticCodes as e}from"../Diagnostics/DiagnosticCodes.js";import{eventDeclarations as t}from"../Syntax/EventDeclarations.js";import{buildingReadModelReferences as n,sliceReferences as r}from"../Dependencies/SliceReferences.js";import{DependencyGraph as i}from"../Dependencies/DependencyGraph.js";import{stronglyConnectedGroups as a}from"../Dependencies/StronglyConnectedGroups.js";import{authoredOrderKey as o,authoredOrderOf as s}from"./AuthoredOrder.js";import{ordinalIgnoreCaseKey as c}from"../Text/ordinalIgnoreCaseKey.js";function timelineOrderDiagnostics(e){return timelineOrderFindings(e).map(e=>e.diagnostic)}function timelineOrderFindings(l,u=s(l)){let ordered=(e,t)=>e.map(e=>({syntax:e,rank:u.get(o([...t,e.name]))??2**53-1})).sort((e,t)=>e.rank-t.rank).map(e=>e.syntax),d=[],feature=(e,t)=>{let n=[...t,e.name];for(let t of ordered(e.slices,n))d.push({syntax:t,scope:[...n,t.name],identity:[...n.map(e=>`container:${e}`),`slice:${t.name}`],index:d.length});for(let t of ordered(e.features,n))feature(t,n)};for(let e of ordered(l.modules,[]))for(let t of ordered(e.features,[e.name]))feature(t,[e.name]);let f=new Map(d.map(e=>[e,/* @__PURE__ */ new Set([...t(e.syntax).map(e=>c(e.name)),...e.syntax.commands.flatMap(e=>e.produces.map(e=>c(e.event))),...e.syntax.reactions.flatMap(e=>e.triggers.flatMap(e=>e.produces.map(e=>c(e.event))))])])),p=/* @__PURE__ */ new Map;for(let e of d)for(let n of t(e.syntax)){let t=c(n.name);p.has(t)||p.set(t,e)}let m=/* @__PURE__ */ new Map;for(let e of d){let t=o(e.scope);m.has(t)||m.set(t,e)}let h=/* @__PURE__ */ new Map;for(let e of i.for(l,u).edges.filter(e=>e.kind===`decidesFrom`))for(let t of e.evidence){let n=o([...e.consumer.scope,t.name.toLowerCase()]);h.has(n)||h.set(n,m.get(o(e.producer.scope)))}let g=[];for(let e of d){let t=/* @__PURE__ */ new Set,i=r(e.syntax).references.filter(e=>e.timeline).map(e=>({event:e.name,location:e.location,readModel:e.targetKind===`ReadModel`}));for(let r of i){let i=c(r.event),a=`${r.readModel?`ReadModel`:`Event`}:${i}`;if(t.has(a))continue;t.add(a);let s=r.readModel?h.get(o([...e.scope,r.event.toLowerCase()])):p.get(i);if(s===void 0||s===e)continue;let l=0;for(;l<e.scope.length&&l<s.scope.length&&e.identity[l]===s.identity[l];)l++;if(l!==e.scope.length&&l!==s.scope.length){if(r.readModel){let t=e.identity.slice(0,l+1),i=new Set(d.filter(e=>t.every((t,n)=>e.identity[n]===t)).flatMap(e=>[...f.get(e)]));if(n(s.syntax,r.event).some(e=>e.timeline&&e.kind===`usesFactsFrom`&&e.targetKind===`Event`&&i.has(c(e.name))))continue}g.push({...r,consumer:e,producer:s,container:o(e.identity.slice(0,l)),left:e.identity[l],right:s.identity[l]})}}}let compare=(e,t)=>e.consumer.index-t.consumer.index||e.location.line-t.location.line||e.location.column-t.location.column,_=/* @__PURE__ */ new Set,v=[];for(let t of new Set(g.map(e=>e.container))){let n=g.filter(e=>e.container===t),r=/* @__PURE__ */ new Map;for(let e of n)r.has(e.left)||r.set(e.left,/* @__PURE__ */ new Set),r.has(e.right)||r.set(e.right,/* @__PURE__ */ new Set),r.get(e.left).add(e.right);for(let i of a(r).filter(e=>e.length>1)){let r=new Set(i),a=n.filter(e=>r.has(e.left)&&r.has(e.right));a.forEach(e=>_.add(e));let s=a.filter(e=>e.consumer.index<e.producer.index).sort(compare)[0];if(s===void 0)continue;let memberIndex=e=>Math.min(...a.flatMap(e=>[e.consumer,e.producer]).filter(n=>{let r=JSON.parse(t);return n.identity[r.length]===e}).map(e=>e.index));i.sort((e,t)=>memberIndex(e)-memberIndex(t)),v.push({edge:s,members:i,diagnostic:{severity:`information`,code:e.TimelineCycleGroup,message:`Timeline group ${i.map(e=>`${e.startsWith(`slice:`)?`slice`:t===o([])?`module`:`feature`} '${e.slice(e.indexOf(`:`)+1)}'`).join(`, `)} depend on each other's events or read models; reordering these members cannot make every dependency flow left to right.`,location:s.location}})}}for(let t of g){if(t.consumer.index>=t.producer.index||_.has(t))continue;let n=t.consumer.scope.slice(0,-1),r=t.producer.scope.length>t.consumer.scope.length&&n.every((e,n)=>t.producer.scope[n]===e),i=r?` The producer is in the consumer's own sub-feature; this cannot be fixed by reordering.`:` Consider drawing the producer before the consumer.`,a=t.readModel?`reads read model '${t.event}' built by`:`uses event '${t.event}' produced by`;v.push({edge:t,ownSubFeature:r,diagnostic:{severity:`information`,code:e.EventFromLaterSlice,message:`Slice '${t.consumer.syntax.name}' ${a} slice '${t.producer.syntax.name}' drawn after it.${i}`,location:t.location}})}return v.sort((e,t)=>compare(e.edge,t.edge)).map(({edge:e,diagnostic:t,members:n,ownSubFeature:r})=>({diagnostic:t,consumerScope:e.consumer.scope,producerScope:e.producer.scope,readModel:e.readModel,ownSubFeature:r===!0,key:o(n===void 0?[t.code,o(e.consumer.scope),...e.readModel?[`ReadModel`]:[],c(e.event)]:[t.code,e.container,...[...n].sort()])}))}export{timelineOrderDiagnostics,timelineOrderFindings};
2
2
  //# sourceMappingURL=TimelineOrder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TimelineOrder.js","names":["application","finding","authoredOrderOf","items","order","authoredOrderKey","outer","syntax","left","right","item","slices","scope","slice","name","child","module","produced","eventDeclarations","ordinalIgnoreCaseKey","event","command","value","reaction","trigger","producers","byScope","key","readers","decision","DependencyGraph","edge","reference","edges","consumer","seen","references","sliceReferences","producer","common","side","facts","index","buildingReadModelReferences","suppressed","findings","container","local","graph","group","stronglyConnectedGroups","members","internal","first","member","DiagnosticCodes","parent","ownSubFeature","consequence","use","diagnostic"],"sources":["../../../../../../Compiler/Files/TimelineOrder.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Diagnostic } from '../Diagnostics/Diagnostic';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { buildingReadModelReferences, sliceReferences } from '../Dependencies/SliceReferences';\nimport { DependencyGraph } from '../Dependencies/DependencyGraph';\nimport { stronglyConnectedGroups } from '../Dependencies/StronglyConnectedGroups';\nimport { ApplicationSyntax, FeatureSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { authoredOrderKey, authoredOrderOf } from './AuthoredOrder';\nimport { ordinalIgnoreCaseKey } from '../Text/ordinalIgnoreCaseKey';\n\ninterface Slice {\n syntax: SliceSyntax;\n scope: readonly string[];\n identity: readonly string[];\n index: number;\n}\ninterface Reference { event: string; location: SourceLocation; readModel: boolean }\ninterface Edge extends Reference { consumer: Slice; producer: Slice; left: string; right: string; container: string }\n\n/** Structured presentation evidence for a repair; never serialized into the model. */\nexport interface TimelineFinding {\n readonly diagnostic: Diagnostic;\n readonly consumerScope: readonly string[];\n readonly producerScope: readonly string[];\n readonly readModel: boolean;\n readonly ownSubFeature: boolean;\n readonly key: string;\n}\n\n// This pass only observes syntax. Its ranks and graph never enter the persisted model.\nexport function timelineOrderDiagnostics(application: ApplicationSyntax): Diagnostic[] {\n return timelineOrderFindings(application).map(finding => finding.diagnostic);\n}\n\nexport function timelineOrderFindings(application: ApplicationSyntax, order: ReadonlyMap<string, number> = authoredOrderOf(application)): TimelineFinding[] {\n const ordered = <T extends { name: string }>(items: readonly T[], outer: readonly string[]): T[] => items\n .map(syntax => ({ syntax, rank: order.get(authoredOrderKey([...outer, syntax.name])) ?? Number.MAX_SAFE_INTEGER }))\n .sort((left, right) => left.rank - right.rank).map(item => item.syntax);\n const slices: Slice[] = [];\n const feature = (syntax: FeatureSyntax, outer: readonly string[]) => {\n const scope = [...outer, syntax.name];\n for (const slice of ordered(syntax.slices, scope)) slices.push({ syntax: slice, scope: [...scope, slice.name], identity: [...scope.map(name => `container:${name}`), `slice:${slice.name}`], index: slices.length });\n for (const child of ordered(syntax.features, scope)) feature(child, scope);\n };\n for (const module of ordered(application.modules, [])) {\n for (const child of ordered(module.features, [module.name])) feature(child, [module.name]);\n }\n const produced = new Map(slices.map(slice => [slice, new Set([\n ...eventDeclarations(slice.syntax).map(event => ordinalIgnoreCaseKey(event.name)),\n ...slice.syntax.commands.flatMap(command => command.produces.map(value => ordinalIgnoreCaseKey(value.event))),\n ...slice.syntax.reactions.flatMap(reaction => reaction.triggers.flatMap(trigger => trigger.produces.map(value => ordinalIgnoreCaseKey(value.event)))),\n ])]));\n const producers = new Map<string, Slice>();\n for (const slice of slices) {\n for (const event of eventDeclarations(slice.syntax)) {\n const name = ordinalIgnoreCaseKey(event.name);\n if (!producers.has(name)) producers.set(name, slice);\n }\n }\n // Use decidesFrom resolution, including builder preference and declaration fallback.\n const byScope = new Map<string, Slice>();\n for (const slice of slices) {\n const key = authoredOrderKey(slice.scope);\n if (!byScope.has(key)) byScope.set(key, slice);\n }\n const readers = new Map<string, Slice>();\n for (const decision of DependencyGraph.for(application, order).edges.filter(edge => edge.kind === 'decidesFrom')) {\n for (const reference of decision.evidence) {\n const key = authoredOrderKey([...decision.consumer.scope, reference.name.toLowerCase()]);\n if (!readers.has(key)) readers.set(key, byScope.get(authoredOrderKey(decision.producer.scope))!);\n }\n }\n const edges: Edge[] = [];\n for (const consumer of slices) {\n const seen = new Set<string>();\n const references = sliceReferences(consumer.syntax).references.filter(reference => reference.timeline)\n .map(reference => ({ event: reference.name, location: reference.location, readModel: reference.targetKind === 'ReadModel' }));\n for (const reference of references) {\n const name = ordinalIgnoreCaseKey(reference.event);\n const key = `${reference.readModel ? 'ReadModel' : 'Event'}:${name}`;\n if (seen.has(key)) continue;\n seen.add(key);\n const producer = reference.readModel ? readers.get(authoredOrderKey([...consumer.scope, reference.event.toLowerCase()])) : producers.get(name);\n if (producer === undefined || producer === consumer) continue;\n let common = 0;\n while (common < consumer.scope.length && common < producer.scope.length && consumer.identity[common] === producer.identity[common]) common++;\n if (common === consumer.scope.length || common === producer.scope.length) continue;\n // At the lowest common container, the reader's whole child supplies feedback\n // only for builders of the read model being read.\n // Exclude this read before SCC grouping, not just backward-edge emission.\n if (reference.readModel) {\n const side = consumer.identity.slice(0, common + 1);\n const facts = new Set(slices.filter(slice => side.every((name, index) => slice.identity[index] === name)).flatMap(slice => [...produced.get(slice)!]));\n if (buildingReadModelReferences(producer.syntax, reference.event).some(value => value.timeline && value.kind === 'usesFactsFrom' && value.targetKind === 'Event' && facts.has(ordinalIgnoreCaseKey(value.name)))) continue;\n }\n edges.push({ ...reference, consumer, producer, container: authoredOrderKey(consumer.identity.slice(0, common)), left: consumer.identity[common], right: producer.identity[common] });\n }\n }\n const compare = (left: Edge, right: Edge) => left.consumer.index - right.consumer.index || left.location.line - right.location.line || left.location.column - right.location.column;\n const suppressed = new Set<Edge>();\n const findings: { edge: Edge; diagnostic: Diagnostic; members?: readonly string[]; ownSubFeature?: boolean }[] = [];\n for (const container of new Set(edges.map(edge => edge.container))) {\n const local = edges.filter(edge => edge.container === container);\n const graph = new Map<string, Set<string>>();\n for (const edge of local) {\n if (!graph.has(edge.left)) graph.set(edge.left, new Set());\n if (!graph.has(edge.right)) graph.set(edge.right, new Set());\n graph.get(edge.left)!.add(edge.right);\n }\n for (const group of stronglyConnectedGroups(graph).filter(group => group.length > 1)) {\n const members = new Set(group);\n const internal = local.filter(edge => members.has(edge.left) && members.has(edge.right));\n internal.forEach(edge => suppressed.add(edge));\n const first = internal.filter(edge => edge.consumer.index < edge.producer.index).sort(compare)[0];\n if (first === undefined) continue;\n const memberIndex = (member: string) => Math.min(...internal.flatMap(edge => [edge.consumer, edge.producer]).filter(slice => {\n const scope = JSON.parse(container) as string[];\n return slice.identity[scope.length] === member;\n }).map(slice => slice.index));\n group.sort((left, right) => memberIndex(left) - memberIndex(right));\n findings.push({ edge: first, members: group, diagnostic: { severity: 'information', code: DiagnosticCodes.TimelineCycleGroup, message: `Timeline group ${group.map(member => `${member.startsWith('slice:') ? 'slice' : container === authoredOrderKey([]) ? 'module' : 'feature'} '${member.slice(member.indexOf(':') + 1)}'`).join(', ')} depend on each other's events or read models; reordering these members cannot make every dependency flow left to right.`, location: first.location } });\n }\n }\n for (const edge of edges) {\n if (edge.consumer.index >= edge.producer.index || suppressed.has(edge)) continue;\n const parent = edge.consumer.scope.slice(0, -1);\n const ownSubFeature = edge.producer.scope.length > edge.consumer.scope.length && parent.every((name, index) => edge.producer.scope[index] === name);\n const consequence = ownSubFeature ? ' The producer is in the consumer\\'s own sub-feature; this cannot be fixed by reordering.' : ' Consider drawing the producer before the consumer.';\n const use = edge.readModel ? `reads read model '${edge.event}' built by` : `uses event '${edge.event}' produced by`;\n findings.push({ edge, ownSubFeature, diagnostic: { severity: 'information', code: DiagnosticCodes.EventFromLaterSlice, message: `Slice '${edge.consumer.syntax.name}' ${use} slice '${edge.producer.syntax.name}' drawn after it.${consequence}`, location: edge.location } });\n }\n return findings.sort((left, right) => compare(left.edge, right.edge)).map(({ edge, diagnostic, members, ownSubFeature }) => ({\n diagnostic, consumerScope: edge.consumer.scope, producerScope: edge.producer.scope, readModel: edge.readModel, ownSubFeature: ownSubFeature === true,\n key: members === undefined ? authoredOrderKey([diagnostic.code, authoredOrderKey(edge.consumer.scope), ...(edge.readModel ? ['ReadModel'] : []), ordinalIgnoreCaseKey(edge.event)])\n :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,QAAQrC,EAAK,KAAMC,EAAM,IAAI,CAAC,CAAC,CAAC,KAAK,CAAE,OAAM,aAAY,UAAS,oBAAqB,CACzH,aAAY,cAAesB,EAAK,SAAS,MAAO,cAAeA,EAAK,SAAS,MAAO,UAAWA,EAAK,UAAW,cAAe0B,IAAkB,GAChJ,IAA6BpD,EAAxB8C,IAAY,IAAA,GAA6B,CAACS,EAAW,KAAMvD,EAAiB0B,EAAK,SAAS,KAAK,EAAG,GAAIA,EAAK,UAAY,CAAC,WAAW,EAAI,CAAC,EAAIZ,EAAqBY,EAAK,KAAK,CAAC,EAC1J,CAAC6B,EAAW,KAAM7B,EAAK,UAAW,GAAG,CAAC,GAAGoB,CAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CACpF,EAAE,CACN"}
1
+ {"version":3,"file":"TimelineOrder.js","names":["application","finding","authoredOrderOf","items","order","authoredOrderKey","outer","syntax","left","right","item","slices","scope","slice","name","child","module","produced","eventDeclarations","ordinalIgnoreCaseKey","event","command","value","reaction","trigger","producers","byScope","key","readers","decision","DependencyGraph","edge","reference","edges","consumer","seen","references","sliceReferences","producer","common","side","facts","index","buildingReadModelReferences","suppressed","findings","container","local","graph","group","stronglyConnectedGroups","members","internal","first","member","DiagnosticCodes","parent","ownSubFeature","consequence","use","diagnostic"],"sources":["../../../../../../Compiler/Files/TimelineOrder.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Diagnostic } from '../Diagnostics/Diagnostic';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { eventDeclarations } from '../Syntax/EventDeclarations';\nimport { buildingReadModelReferences, sliceReferences } from '../Dependencies/SliceReferences';\nimport { DependencyGraph } from '../Dependencies/DependencyGraph';\nimport { stronglyConnectedGroups } from '../Dependencies/StronglyConnectedGroups';\nimport { ApplicationSyntax, FeatureSyntax, SliceSyntax } from '../Syntax/Structure';\nimport { authoredOrderKey, authoredOrderOf } from './AuthoredOrder';\nimport { ordinalIgnoreCaseKey } from '../Text/ordinalIgnoreCaseKey';\n\ninterface Slice {\n syntax: SliceSyntax;\n scope: readonly string[];\n identity: readonly string[];\n index: number;\n}\ninterface Reference { event: string; location: SourceLocation; readModel: boolean }\ninterface Edge extends Reference { consumer: Slice; producer: Slice; left: string; right: string; container: string }\n\n/** Structured presentation evidence for a repair; never serialized into the model. */\nexport interface TimelineFinding {\n readonly diagnostic: Diagnostic;\n readonly consumerScope: readonly string[];\n readonly producerScope: readonly string[];\n readonly readModel: boolean;\n readonly ownSubFeature: boolean;\n readonly key: string;\n}\n\n// This pass only observes syntax. Its ranks and graph never enter the persisted model.\nexport function timelineOrderDiagnostics(application: ApplicationSyntax): Diagnostic[] {\n return timelineOrderFindings(application).map(finding => finding.diagnostic);\n}\n\nexport function timelineOrderFindings(application: ApplicationSyntax, order: ReadonlyMap<string, number> = authoredOrderOf(application)): TimelineFinding[] {\n const ordered = <T extends { name: string }>(items: readonly T[], outer: readonly string[]): T[] => items\n .map(syntax => ({ syntax, rank: order.get(authoredOrderKey([...outer, syntax.name])) ?? Number.MAX_SAFE_INTEGER }))\n .sort((left, right) => left.rank - right.rank).map(item => item.syntax);\n const slices: Slice[] = [];\n const feature = (syntax: FeatureSyntax, outer: readonly string[]) => {\n const scope = [...outer, syntax.name];\n for (const slice of ordered(syntax.slices, scope)) slices.push({ syntax: slice, scope: [...scope, slice.name], identity: [...scope.map(name => `container:${name}`), `slice:${slice.name}`], index: slices.length });\n for (const child of ordered(syntax.features, scope)) feature(child, scope);\n };\n for (const module of ordered(application.modules, [])) {\n for (const child of ordered(module.features, [module.name])) feature(child, [module.name]);\n }\n const produced = new Map(slices.map(slice => [slice, new Set([\n ...eventDeclarations(slice.syntax).map(event => ordinalIgnoreCaseKey(event.name)),\n ...slice.syntax.commands.flatMap(command => command.produces.map(value => ordinalIgnoreCaseKey(value.event))),\n ...slice.syntax.reactions.flatMap(reaction => reaction.triggers.flatMap(trigger => trigger.produces.map(value => ordinalIgnoreCaseKey(value.event)))),\n ])]));\n const producers = new Map<string, Slice>();\n for (const slice of slices) {\n for (const event of eventDeclarations(slice.syntax)) {\n const name = ordinalIgnoreCaseKey(event.name);\n if (!producers.has(name)) producers.set(name, slice);\n }\n }\n // Use decidesFrom resolution, including builder preference and declaration fallback.\n const byScope = new Map<string, Slice>();\n for (const slice of slices) {\n const key = authoredOrderKey(slice.scope);\n if (!byScope.has(key)) byScope.set(key, slice);\n }\n const readers = new Map<string, Slice>();\n for (const decision of DependencyGraph.for(application, order).edges.filter(edge => edge.kind === 'decidesFrom')) {\n for (const reference of decision.evidence) {\n const key = authoredOrderKey([...decision.consumer.scope, reference.name.toLowerCase()]);\n if (!readers.has(key)) readers.set(key, byScope.get(authoredOrderKey(decision.producer.scope))!);\n }\n }\n const edges: Edge[] = [];\n for (const consumer of slices) {\n const seen = new Set<string>();\n const references = sliceReferences(consumer.syntax).references.filter(reference => reference.timeline)\n .map(reference => ({ event: reference.name, location: reference.location, readModel: reference.targetKind === 'ReadModel' }));\n for (const reference of references) {\n const name = ordinalIgnoreCaseKey(reference.event);\n const key = `${reference.readModel ? 'ReadModel' : 'Event'}:${name}`;\n if (seen.has(key)) continue;\n seen.add(key);\n const producer = reference.readModel ? readers.get(authoredOrderKey([...consumer.scope, reference.event.toLowerCase()])) : producers.get(name);\n if (producer === undefined || producer === consumer) continue;\n let common = 0;\n while (common < consumer.scope.length && common < producer.scope.length && consumer.identity[common] === producer.identity[common]) common++;\n if (common === consumer.scope.length || common === producer.scope.length) continue;\n // At the lowest common container, the reader's whole child supplies feedback\n // only for builders of the read model being read.\n // Exclude this read before SCC grouping, not just backward-edge emission.\n if (reference.readModel) {\n const side = consumer.identity.slice(0, common + 1);\n const facts = new Set(slices.filter(slice => side.every((name, index) => slice.identity[index] === name)).flatMap(slice => [...produced.get(slice)!]));\n if (buildingReadModelReferences(producer.syntax, reference.event).some(value => value.timeline && value.kind === 'usesFactsFrom' && value.targetKind === 'Event' && facts.has(ordinalIgnoreCaseKey(value.name)))) continue;\n }\n edges.push({ ...reference, consumer, producer, container: authoredOrderKey(consumer.identity.slice(0, common)), left: consumer.identity[common], right: producer.identity[common] });\n }\n }\n const compare = (left: Edge, right: Edge) => left.consumer.index - right.consumer.index || left.location.line - right.location.line || left.location.column - right.location.column;\n const suppressed = new Set<Edge>();\n const findings: { edge: Edge; diagnostic: Diagnostic; members?: readonly string[]; ownSubFeature?: boolean }[] = [];\n for (const container of new Set(edges.map(edge => edge.container))) {\n const local = edges.filter(edge => edge.container === container);\n const graph = new Map<string, Set<string>>();\n for (const edge of local) {\n if (!graph.has(edge.left)) graph.set(edge.left, new Set());\n if (!graph.has(edge.right)) graph.set(edge.right, new Set());\n graph.get(edge.left)!.add(edge.right);\n }\n for (const group of stronglyConnectedGroups(graph).filter(group => group.length > 1)) {\n const members = new Set(group);\n const internal = local.filter(edge => members.has(edge.left) && members.has(edge.right));\n internal.forEach(edge => suppressed.add(edge));\n const first = internal.filter(edge => edge.consumer.index < edge.producer.index).sort(compare)[0];\n if (first === undefined) continue;\n const memberIndex = (member: string) => Math.min(...internal.flatMap(edge => [edge.consumer, edge.producer]).filter(slice => {\n const scope = JSON.parse(container) as string[];\n return slice.identity[scope.length] === member;\n }).map(slice => slice.index));\n group.sort((left, right) => memberIndex(left) - memberIndex(right));\n findings.push({ edge: first, members: group, diagnostic: { severity: 'information', code: DiagnosticCodes.TimelineCycleGroup, message: `Timeline group ${group.map(member => `${member.startsWith('slice:') ? 'slice' : container === authoredOrderKey([]) ? 'module' : 'feature'} '${member.slice(member.indexOf(':') + 1)}'`).join(', ')} depend on each other's events or read models; reordering these members cannot make every dependency flow left to right.`, location: first.location } });\n }\n }\n for (const edge of edges) {\n if (edge.consumer.index >= edge.producer.index || suppressed.has(edge)) continue;\n const parent = edge.consumer.scope.slice(0, -1);\n const ownSubFeature = edge.producer.scope.length > edge.consumer.scope.length && parent.every((name, index) => edge.producer.scope[index] === name);\n const consequence = ownSubFeature ? ' The producer is in the consumer\\'s own sub-feature; this cannot be fixed by reordering.' : ' Consider drawing the producer before the consumer.';\n const use = edge.readModel ? `reads read model '${edge.event}' built by` : `uses event '${edge.event}' produced by`;\n findings.push({ edge, ownSubFeature, diagnostic: { severity: 'information', code: DiagnosticCodes.EventFromLaterSlice, message: `Slice '${edge.consumer.syntax.name}' ${use} slice '${edge.producer.syntax.name}' drawn after it.${consequence}`, location: edge.location } });\n }\n return findings.sort((left, right) => compare(left.edge, right.edge)).map(({ edge, diagnostic, members, ownSubFeature }) => ({\n diagnostic, consumerScope: edge.consumer.scope, producerScope: edge.producer.scope, readModel: edge.readModel, ownSubFeature: ownSubFeature === true,\n key: members === undefined ? authoredOrderKey([diagnostic.code, authoredOrderKey(edge.consumer.scope), ...(edge.readModel ? ['ReadModel'] : []), ordinalIgnoreCaseKey(edge.event)])\n : authoredOrderKey([diagnostic.code, edge.container, ...[...members].sort()]),\n }));\n}\n"],"mappings":"A,8kBAkCA,SAAgB,yBAAyB,EAA8C,CACnF,OAAO,sBAAsBA,CAAW,CAAC,CAAC,IAAI,GAAWC,EAAQ,UAAU,CAC/E,CAEA,SAAgB,sBAAsB,EAAgC,EAAqCC,EAAgBF,CAAW,EAAsB,CACxJ,IAAM,SAAuC,EAAqB,IAAkCG,EAC/F,IAAI,IAAW,CAAE,SAAQ,KAAMC,EAAM,IAAIC,EAAiB,CAAC,GAAGC,EAAOC,EAAO,IAAI,CAAC,CAAC,UAA6B,EAAE,CAAC,CAClH,MAAM,EAAM,IAAUC,EAAK,KAAOC,EAAM,IAAI,CAAC,CAAC,IAAI,GAAQC,EAAK,MAAM,EACpEC,EAAkB,CAAC,EACnB,SAAW,EAAuB,IAA6B,CACjE,IAAMC,EAAQ,CAAC,GAAGN,EAAOC,EAAO,IAAI,EACpC,IAAK,IAAMM,KAAS,QAAQN,EAAO,OAAQK,CAAK,EAAGD,EAAO,KAAK,CAAE,OAAQE,E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AIb,CAAI,EAAG,SACxE,IAAMyB,EAASzB,EAAK,SAAS,MAAM,MAAM,EAAG,EAAE,EACxC0B,EAAgB1B,EAAK,SAAS,MAAM,OAASA,EAAK,SAAS,MAAM,QAAUyB,EAAO,OAAO,EAAM,IAAUzB,EAAK,SAAS,MAAMW,KAAW5B,CAAI,EAC5I4C,EAAcD,EAAgB,0FAA6F,sDAC3HE,EAAM5B,EAAK,UAAY,qBAAqBA,EAAK,MAAM,YAAc,eAAeA,EAAK,MAAM,eACrGc,EAAS,KAAK,CAAE,OAAM,gBAAe,WAAY,CAAE,SAAU,cAAe,KAAMU,EAAgB,oBAAqB,QAAS,UAAUxB,EAAK,SAAS,OAAO,KAAK,IAAI4B,EAAI,UAAU5B,EAAK,SAAS,OAAO,KAAK,mBAAmB2B,IAAe,SAAU3B,EAAK,QAAS,CAAE,CAAC,CACjR,CACA,OAAOc,EAAS,MAAM,EAAM,IAAU,QAAQrC,EAAK,KAAMC,EAAM,IAAI,CAAC,CAAC,CAAC,KAAK,CAAE,OAAM,aAAY,UAAS,oBAAqB,CACzH,aAAY,cAAesB,EAAK,SAAS,MAAO,cAAeA,EAAK,SAAS,MAAO,UAAWA,EAAK,UAAW,cAAe0B,IAAkB,GAChJ,IAA6BpD,EAAxB8C,IAAY,IAAA,GAA6B,CAACS,EAAW,KAAMvD,EAAiB0B,EAAK,SAAS,KAAK,EAAG,GAAIA,EAAK,UAAY,CAAC,WAAW,EAAI,CAAC,EAAIZ,EAAqBY,EAAK,KAAK,CAAC,EAC1J,CAAC6B,EAAW,KAAM7B,EAAK,UAAW,GAAG,CAAC,GAAGoB,CAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CACpF,EAAE,CACN,C"}
@@ -1 +1 @@
1
- import"./RegexExpression.js";import"./GenerationRuleProof.js";import"./TextRuleExpression.js";import"./FinitePatternContainment.js";
1
+ import"./FinitePatternContainment.js";import"./GenerationRuleProof.js";import"./RegexExpression.js";import"./TextRuleExpression.js";
@@ -1 +1 @@
1
- {"version":3,"file":"GenerationAssessmentCache.js","names":["capacity","pattern","assess","key","checksum","year","existing","result"],"sources":["../../../../../../Compiler/Generation/GenerationAssessmentCache.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ChecksumAlgorithm } from './ChecksumAlgorithm';\n\n/** Bounded FIFO of successful immutable counts; no assessment time enters the model. */\nexport class GenerationAssessmentCache {\n private readonly entries = new Map<string, bigint>();\n\n constructor(private readonly capacity = 128) {\n if (!Number.isSafeInteger(capacity) || capacity < 1) throw new Error('Assessment cache capacity must be positive.');\n }\n\n get(pattern: string, checksum: ChecksumAlgorithm | undefined, year: number, assess: () => bigint): bigint {\n if (pattern.length > 4096) return assess();\n const key = JSON.stringify([pattern, checksum, year]);\n const existing = this.entries.get(key);\n if (existing !== undefined) return existing;\n const result = assess(); // Failures are never retained.\n if (this.entries.size === this.capacity) this.entries.delete(this.entries.keys().next().value!);\n this.entries.set(key, result);\n return result;\n }\n}\n"],"mappings":"qDAMA,IAAa,0BAAb,KAAuC,CAGN,SAF7B,wBAA2B,IAAI,IAE/B,YAAY,EAA4B,IAAK,CACzC,GADyB,KAAA,SAAAA,EACrB,CAAC,OAAO,cAAcA,CAAQ,GAAKA,EAAW,EAAG,MAAU,MAAM,6CAA6C,CACtH,CAEA,IAAI,EAAiB,EAAyC,EAAc,EAA8B,CACtG,GAAIC,EAAQ,OAAS,KAAM,OAAOC,EAAO,EACzC,IAAMC,EAAM,KAAK,UAAU,CAACF,EAASG,EAAUC,CAAI,CAAC,EAC9CC,EAAW,KAAK,QAAQ,IAAIH,CAAG,EACrC,GAAIG,IAAa,IAAA,GAAW,OAAOA,EACnC,IAAMC,EAASL,EAAO,EAGtB,OAFI,KAAK,QAAQ,OAAS,KAAK,UAAU,KAAK,QAAQ,OAAO,KAAK,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAM,EAC9F,KAAK,QAAQ,IAAIC,EAAKI,CAAM,EACrBA,CACX,CACJ"}
1
+ {"version":3,"file":"GenerationAssessmentCache.js","names":["capacity","pattern","assess","key","checksum","year","existing","result"],"sources":["../../../../../../Compiler/Generation/GenerationAssessmentCache.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ChecksumAlgorithm } from './ChecksumAlgorithm';\n\n/** Bounded FIFO of successful immutable counts; no assessment time enters the model. */\nexport class GenerationAssessmentCache {\n private readonly entries = new Map<string, bigint>();\n\n constructor(private readonly capacity = 128) {\n if (!Number.isSafeInteger(capacity) || capacity < 1) throw new Error('Assessment cache capacity must be positive.');\n }\n\n get(pattern: string, checksum: ChecksumAlgorithm | undefined, year: number, assess: () => bigint): bigint {\n if (pattern.length > 4096) return assess();\n const key = JSON.stringify([pattern, checksum, year]);\n const existing = this.entries.get(key);\n if (existing !== undefined) return existing;\n const result = assess(); // Failures are never retained.\n if (this.entries.size === this.capacity) this.entries.delete(this.entries.keys().next().value!);\n this.entries.set(key, result);\n return result;\n }\n}\n"],"mappings":"A,qDAMA,IAAa,0BAAb,KAAuC,CAGN,SAF7B,wBAA2B,IAAI,IAE/B,YAAY,EAA4B,IAAK,CACzC,GADyB,KAAA,SAAAA,EACrB,CAAC,OAAO,cAAcA,CAAQ,GAAKA,EAAW,EAAG,MAAU,MAAM,6CAA6C,CACtH,CAEA,IAAI,EAAiB,EAAyC,EAAc,EAA8B,CACtG,GAAIC,EAAQ,OAAS,KAAM,OAAOC,EAAO,EACzC,IAAMC,EAAM,KAAK,UAAU,CAACF,EAASG,EAAUC,CAAI,CAAC,EAC9CC,EAAW,KAAK,QAAQ,IAAIH,CAAG,EACrC,GAAIG,IAAa,IAAA,GAAW,OAAOA,EACnC,IAAMC,EAASL,EAAO,EAGtB,OAFI,KAAK,QAAQ,OAAS,KAAK,UAAU,KAAK,QAAQ,OAAO,KAAK,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAM,EAC9F,KAAK,QAAQ,IAAIC,EAAKI,CAAM,EACrBA,CACX,CACJ,E"}
@@ -1 +1 @@
1
- {"version":3,"file":"GenerationChecksum.js","names":["algorithm"],"sources":["../../../../../../Compiler/Generation/GenerationChecksum.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ChecksumAlgorithm } from './ChecksumAlgorithm';\n\nexport function checksumWidth(algorithm: ChecksumAlgorithm): number {\n switch (algorithm) {\n case ChecksumAlgorithm.Luhn: case ChecksumAlgorithm.Mod11: return 1;\n case ChecksumAlgorithm.Mod97: return 2;\n default: throw new Error('Checksum requires luhn, mod11 or mod97.');\n }\n}\n\nexport function generationChecksum(payload: string, algorithm: ChecksumAlgorithm): string | null {\n checksumWidth(algorithm);\n if (!printable(payload)) throw new Error('Checksum payload must contain printable ASCII characters.');\n const digits = [...payload].filter(character => character >= '0' && character <= '9').map(character => character.charCodeAt(0) - 48);\n const value = algorithm === ChecksumAlgorithm.Luhn ? luhn(digits) : algorithm === ChecksumAlgorithm.Mod11 ? mod11(digits) : mod97(digits);\n return algorithm === ChecksumAlgorithm.Mod11 && value === 10 ? null : value.toString().padStart(checksumWidth(algorithm), '0');\n}\n\nexport function matchesChecksum(value: string, algorithm: ChecksumAlgorithm): boolean {\n const width = checksumWidth(algorithm);\n if (value.length < width || !printable(value)) return false;\n const suffix = value.slice(-width);\n if (![...suffix].every(character => character >= '0' && character <= '9')) return false;\n return suffix === generationChecksum(value.slice(0, -width), algorithm);\n}\n\nfunction printable(value: string): boolean {\n return [...value].every(character => character >= ' ' && character <= '~');\n}\n\nfunction luhn(digits: number[]): number {\n let sum = 0;\n for (let index = 0; index < digits.length; index++) {\n const digit = digits[digits.length - index - 1] * (index % 2 === 0 ? 2 : 1);\n sum = (sum + (digit > 9 ? digit - 9 : digit)) % 10;\n }\n return (10 - sum % 10) % 10;\n}\n\nfunction mod11(digits: number[]): number {\n let sum = 0;\n for (let index = 0; index < digits.length; index++) sum = (sum + digits[digits.length - index - 1] * (2 + index % 6)) % 11;\n return (11 - sum % 11) % 11;\n}\n\nfunction mod97(digits: number[]): number {\n let residue = 0;\n for (const digit of digits) residue = (residue * 10 + digit) % 97;\n return 98 - residue * 100 % 97;\n}\n"],"mappings":"qDAKA,SAAgB,cAAc,EAAsC,CAChE,OAAQA,EAAR,CACI,IAAA,OAA6B,IAAA,QAA8B,MAAO,GAClE,IAAA,QAA8B,MAAO,GACrC,QAAS,MAAU,MAAM,yCAAyC,CACtE,CACJ"}
1
+ {"version":3,"file":"GenerationChecksum.js","names":["algorithm"],"sources":["../../../../../../Compiler/Generation/GenerationChecksum.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ChecksumAlgorithm } from './ChecksumAlgorithm';\n\nexport function checksumWidth(algorithm: ChecksumAlgorithm): number {\n switch (algorithm) {\n case ChecksumAlgorithm.Luhn: case ChecksumAlgorithm.Mod11: return 1;\n case ChecksumAlgorithm.Mod97: return 2;\n default: throw new Error('Checksum requires luhn, mod11 or mod97.');\n }\n}\n\nexport function generationChecksum(payload: string, algorithm: ChecksumAlgorithm): string | null {\n checksumWidth(algorithm);\n if (!printable(payload)) throw new Error('Checksum payload must contain printable ASCII characters.');\n const digits = [...payload].filter(character => character >= '0' && character <= '9').map(character => character.charCodeAt(0) - 48);\n const value = algorithm === ChecksumAlgorithm.Luhn ? luhn(digits) : algorithm === ChecksumAlgorithm.Mod11 ? mod11(digits) : mod97(digits);\n return algorithm === ChecksumAlgorithm.Mod11 && value === 10 ? null : value.toString().padStart(checksumWidth(algorithm), '0');\n}\n\nexport function matchesChecksum(value: string, algorithm: ChecksumAlgorithm): boolean {\n const width = checksumWidth(algorithm);\n if (value.length < width || !printable(value)) return false;\n const suffix = value.slice(-width);\n if (![...suffix].every(character => character >= '0' && character <= '9')) return false;\n return suffix === generationChecksum(value.slice(0, -width), algorithm);\n}\n\nfunction printable(value: string): boolean {\n return [...value].every(character => character >= ' ' && character <= '~');\n}\n\nfunction luhn(digits: number[]): number {\n let sum = 0;\n for (let index = 0; index < digits.length; index++) {\n const digit = digits[digits.length - index - 1] * (index % 2 === 0 ? 2 : 1);\n sum = (sum + (digit > 9 ? digit - 9 : digit)) % 10;\n }\n return (10 - sum % 10) % 10;\n}\n\nfunction mod11(digits: number[]): number {\n let sum = 0;\n for (let index = 0; index < digits.length; index++) sum = (sum + digits[digits.length - index - 1] * (2 + index % 6)) % 11;\n return (11 - sum % 11) % 11;\n}\n\nfunction mod97(digits: number[]): number {\n let residue = 0;\n for (const digit of digits) residue = (residue * 10 + digit) % 97;\n return 98 - residue * 100 % 97;\n}\n"],"mappings":"A,qDAKA,SAAgB,cAAc,EAAsC,CAChE,OAAQA,EAAR,CACI,IAAA,OAA6B,IAAA,QAA8B,MAAO,GAClE,IAAA,QAA8B,MAAO,GACrC,QAAS,MAAU,MAAM,yCAAyC,CACtE,CACJ,C"}
@@ -1,2 +1,2 @@
1
- import"../../_virtual/_virtual/_rolldown/runtime.js";import{checksumWidth as e}from"./GenerationChecksum.js";import{tokenWidth as t}from"./GenerationPatternToken.js";import{InvalidGenerationPattern as n}from"./InvalidGenerationPattern.js";import{GenerationPatternParser as r}from"./GenerationPatternParser.js";function parseGenerationPattern(i,a){let o=new r(i).parse(),s=a===void 0?0:e(a),c=o.reduce((e,n)=>e+t(n)*n.minimum,s),l=o.reduce((e,n)=>e+t(n)*n.maximum,s);if(l>256)throw new n(`final expanded length exceeds 256 characters including check digits`,i.length);return{tokens:o,checksum:a,checksumWidth:s,minimumLength:c,maximumLength:l,hasDates:o.some(e=>e.segment!==void 0)}}export{parseGenerationPattern};
1
+ import"../../_virtual/_virtual/_rolldown/runtime.js";import{checksumWidth as e}from"./GenerationChecksum.js";import{GenerationPatternParser as t}from"./GenerationPatternParser.js";import{tokenWidth as n}from"./GenerationPatternToken.js";import{InvalidGenerationPattern as r}from"./InvalidGenerationPattern.js";function parseGenerationPattern(i,a){let o=new t(i).parse(),s=a===void 0?0:e(a),c=o.reduce((e,t)=>e+n(t)*t.minimum,s),l=o.reduce((e,t)=>e+n(t)*t.maximum,s);if(l>256)throw new r(`final expanded length exceeds 256 characters including check digits`,i.length);return{tokens:o,checksum:a,checksumWidth:s,minimumLength:c,maximumLength:l,hasDates:o.some(e=>e.segment!==void 0)}}export{parseGenerationPattern};
2
2
  //# sourceMappingURL=GenerationPattern.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GenerationPattern.js","names":["tokens","GenerationPatternParser","pattern","width","checksum","checksumWidth","minimumLength","sum","tokenWidth","token","maximumLength","InvalidGenerationPattern"],"sources":["../../../../../../Compiler/Generation/GenerationPattern.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ChecksumAlgorithm } from './ChecksumAlgorithm';\nimport { checksumWidth } from './GenerationChecksum';\nimport { GenerationPatternParser } from './GenerationPatternParser';\nimport { GenerationPatternToken, tokenWidth } from './GenerationPatternToken';\nimport { InvalidGenerationPattern } from './InvalidGenerationPattern';\n\nexport interface GenerationPattern {\n readonly tokens: readonly GenerationPatternToken[];\n readonly checksum?: ChecksumAlgorithm;\n readonly checksumWidth: number;\n readonly minimumLength: number;\n readonly maximumLength: number;\n readonly hasDates: boolean;\n}\nexport function parseGenerationPattern(pattern: string, checksum?: ChecksumAlgorithm): GenerationPattern {\n const tokens = new GenerationPatternParser(pattern).parse();\n const width = checksum === undefined ? 0 : checksumWidth(checksum);\n const minimumLength = tokens.reduce((sum, token) => sum + tokenWidth(token) * token.minimum, width);\n const maximumLength = tokens.reduce((sum, token) => sum + tokenWidth(token) * token.maximum, width);\n if (maximumLength > 256) throw new InvalidGenerationPattern('final expanded length exceeds 256 characters including check digits', pattern.length);\n return { tokens, checksum, checksumWidth: width, minimumLength, maximumLength, hasDates: tokens.some(token => token.segment !== undefined) };\n}\n"],"mappings":"sTAiBA,SAAgB,uBAAuB,EAAiB,EAAiD,CACrG,IAAMA,EAAS,IAAIC,EAAwBC,CAAO,CAAC,CAAC,MAAM,EACpDC,EAAQC,IAAa,IAAA,GAAY,EAAIC,EAAcD,CAAQ,EAC3DE,EAAgBN,EAAO,QAAQ,EAAK,IAAUO,EAAMC,EAAWC,CAAK,EAAIA,EAAM,QAASN,CAAK,EAC5FO,EAAgBV,EAAO,QAAQ,EAAK,IAAUO,EAAMC,EAAWC,CAAK,EAAIA,EAAM,QAASN,CAAK,EAClG,GAAIO,EAAgB,IAAK,MAAM,IAAIC,EAAyB,sEAAuET,EAAQ,MAAM,EACjJ,MAAO,CAAE,SAAQ,WAAU,cAAeC,EAAO,gBAAe,gBAAe,SAAUH,EAAO,KAAK,GAASS,EAAM,UAAY,IAAA,EAAS,CAAE,CAC/I"}
1
+ {"version":3,"file":"GenerationPattern.js","names":["tokens","GenerationPatternParser","pattern","width","checksum","checksumWidth","minimumLength","sum","tokenWidth","token","maximumLength","InvalidGenerationPattern"],"sources":["../../../../../../Compiler/Generation/GenerationPattern.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ChecksumAlgorithm } from './ChecksumAlgorithm';\nimport { checksumWidth } from './GenerationChecksum';\nimport { GenerationPatternParser } from './GenerationPatternParser';\nimport { GenerationPatternToken, tokenWidth } from './GenerationPatternToken';\nimport { InvalidGenerationPattern } from './InvalidGenerationPattern';\n\nexport interface GenerationPattern {\n readonly tokens: readonly GenerationPatternToken[];\n readonly checksum?: ChecksumAlgorithm;\n readonly checksumWidth: number;\n readonly minimumLength: number;\n readonly maximumLength: number;\n readonly hasDates: boolean;\n}\nexport function parseGenerationPattern(pattern: string, checksum?: ChecksumAlgorithm): GenerationPattern {\n const tokens = new GenerationPatternParser(pattern).parse();\n const width = checksum === undefined ? 0 : checksumWidth(checksum);\n const minimumLength = tokens.reduce((sum, token) => sum + tokenWidth(token) * token.minimum, width);\n const maximumLength = tokens.reduce((sum, token) => sum + tokenWidth(token) * token.maximum, width);\n if (maximumLength > 256) throw new InvalidGenerationPattern('final expanded length exceeds 256 characters including check digits', pattern.length);\n return { tokens, checksum, checksumWidth: width, minimumLength, maximumLength, hasDates: tokens.some(token => token.segment !== undefined) };\n}\n"],"mappings":"A,sTAiBA,SAAgB,uBAAuB,EAAiB,EAAiD,CACrG,IAAMA,EAAS,IAAIC,EAAwBC,CAAO,CAAC,CAAC,MAAM,EACpDC,EAAQC,IAAa,IAAA,GAAY,EAAIC,EAAcD,CAAQ,EAC3DE,EAAgBN,EAAO,QAAQ,EAAK,IAAUO,EAAMC,EAAWC,CAAK,EAAIA,EAAM,QAASN,CAAK,EAC5FO,EAAgBV,EAAO,QAAQ,EAAK,IAAUO,EAAMC,EAAWC,CAAK,EAAIA,EAAM,QAASN,CAAK,EAClG,GAAIO,EAAgB,IAAK,MAAM,IAAIC,EAAyB,sEAAuET,EAAQ,MAAM,EACjJ,MAAO,CAAE,SAAQ,WAAU,cAAeC,EAAO,gBAAe,gBAAe,SAAUH,EAAO,KAAK,GAASS,EAAM,UAAY,IAAA,EAAS,CAAE,CAC/I,C"}
@@ -1 +1 @@
1
- {"version":3,"file":"GenerationPatternAssessment.js","names":["GenerationAssessmentCache"],"sources":["../../../../../../Compiler/Generation/GenerationPatternAssessment.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { GenerationPattern } from './GenerationPattern';\nimport { GenerationDateClasses } from './GenerationDateClasses';\nimport { generationPatternCount } from './GenerationPatternSupport';\nimport { GenerationWorkBudget } from './GenerationWorkBudget';\nimport { GenerationAssessmentCache } from './GenerationAssessmentCache';\n\nconst assessments = new GenerationAssessmentCache();\n\nexport class EmptyGenerationSupport extends Error {\n constructor(date: Date | undefined, checksum: string | undefined) { super(`Generation support is empty${date === undefined ? '' : ' on UTC ' + date.toISOString().slice(0, 10)} with checksum '${checksum ?? 'none'}'.`); }\n}\n\nexport function minimumGenerationPatternCount(pattern: GenerationPattern, utcYear: number, budget: GenerationWorkBudget | undefined = undefined): bigint {\n // Explicit budgets always assess actual cold work. The complete parsed pattern is the key,\n // including its derived bounds, so programmatic callers cannot alias differing contracts.\n if (budget !== undefined) return assess(pattern, utcYear, budget);\n return assessments.get(JSON.stringify(pattern), pattern.checksum, utcYear, () => assess(pattern, utcYear, new GenerationWorkBudget()));\n}\n\nfunction assess(pattern: GenerationPattern, utcYear: number, budget: GenerationWorkBudget): bigint {\n if (!pattern.hasDates) {\n const count = generationPatternCount(pattern, undefined, budget);\n if (count === 0n) throw new EmptyGenerationSupport(undefined, pattern.checksum);\n return count;\n }\n if (!Number.isInteger(utcYear) || utcYear < 1 || utcYear > 9899) throw new Error('Generation assessment year must allow the complete 100-year UTC horizon.');\n const date = new Date(0);\n date.setUTCFullYear(utcYear, 0, 1);\n const counts = new Map<string, bigint>();\n const classes = new GenerationDateClasses(pattern);\n let minimum: bigint | undefined;\n while (date.getUTCFullYear() <= utcYear + 100) {\n budget.spend();\n const key = classes.key(date, budget);\n let count = counts.get(key);\n if (count === undefined) { count = generationPatternCount(pattern, date, budget); counts.set(key, count); }\n if (count === 0n) throw new EmptyGenerationSupport(date, pattern.checksum);\n if (minimum === undefined || count < minimum) minimum = count;\n date.setUTCDate(date.getUTCDate() + 1);\n }\n return minimum!;\n}\n"],"mappings":"2EASoB,IAAIA"}
1
+ {"version":3,"file":"GenerationPatternAssessment.js","names":["GenerationAssessmentCache"],"sources":["../../../../../../Compiler/Generation/GenerationPatternAssessment.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { GenerationPattern } from './GenerationPattern';\nimport { GenerationDateClasses } from './GenerationDateClasses';\nimport { generationPatternCount } from './GenerationPatternSupport';\nimport { GenerationWorkBudget } from './GenerationWorkBudget';\nimport { GenerationAssessmentCache } from './GenerationAssessmentCache';\n\nconst assessments = new GenerationAssessmentCache();\n\nexport class EmptyGenerationSupport extends Error {\n constructor(date: Date | undefined, checksum: string | undefined) { super(`Generation support is empty${date === undefined ? '' : ' on UTC ' + date.toISOString().slice(0, 10)} with checksum '${checksum ?? 'none'}'.`); }\n}\n\nexport function minimumGenerationPatternCount(pattern: GenerationPattern, utcYear: number, budget: GenerationWorkBudget | undefined = undefined): bigint {\n // Explicit budgets always assess actual cold work. The complete parsed pattern is the key,\n // including its derived bounds, so programmatic callers cannot alias differing contracts.\n if (budget !== undefined) return assess(pattern, utcYear, budget);\n return assessments.get(JSON.stringify(pattern), pattern.checksum, utcYear, () => assess(pattern, utcYear, new GenerationWorkBudget()));\n}\n\nfunction assess(pattern: GenerationPattern, utcYear: number, budget: GenerationWorkBudget): bigint {\n if (!pattern.hasDates) {\n const count = generationPatternCount(pattern, undefined, budget);\n if (count === 0n) throw new EmptyGenerationSupport(undefined, pattern.checksum);\n return count;\n }\n if (!Number.isInteger(utcYear) || utcYear < 1 || utcYear > 9899) throw new Error('Generation assessment year must allow the complete 100-year UTC horizon.');\n const date = new Date(0);\n date.setUTCFullYear(utcYear, 0, 1);\n const counts = new Map<string, bigint>();\n const classes = new GenerationDateClasses(pattern);\n let minimum: bigint | undefined;\n while (date.getUTCFullYear() <= utcYear + 100) {\n budget.spend();\n const key = classes.key(date, budget);\n let count = counts.get(key);\n if (count === undefined) { count = generationPatternCount(pattern, date, budget); counts.set(key, count); }\n if (count === 0n) throw new EmptyGenerationSupport(date, pattern.checksum);\n if (minimum === undefined || count < minimum) minimum = count;\n date.setUTCDate(date.getUTCDate() + 1);\n }\n return minimum!;\n}\n"],"mappings":"A,2EASoB,IAAIA"}
@@ -1 +1 @@
1
- {"version":3,"file":"GenerationPatternParser.js","names":["character","pattern","tokens","maximumLength","token","tokenWidth","end","segment","parts","part","minimum","maximum","allowed","characters","first","last","value","InvalidGenerationPattern","reason"],"sources":["../../../../../../Compiler/Generation/GenerationPatternParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { GenerationPatternToken, tokenWidth } from './GenerationPatternToken';\nimport { InvalidGenerationPattern } from './InvalidGenerationPattern';\n\nconst digit = (character: string | undefined): boolean => character !== undefined && character >= '0' && character <= '9';\n\nexport class GenerationPatternParser {\n private offset = 0;\n private hasRandom = false;\n constructor(private readonly pattern: string) {}\n parse(): readonly GenerationPatternToken[] {\n if (this.pattern.length === 0) this.fail('empty pattern');\n if ([...this.pattern].some(character => character < ' ' || character > '~')) this.fail('patterns require printable ASCII');\n const tokens: GenerationPatternToken[] = [];\n let maximumLength = 0;\n while (this.offset < this.pattern.length) {\n let token = this.token();\n if (this.pattern[this.offset] === '{' && digit(this.pattern[this.offset + 1])) token = this.repeat(token);\n maximumLength += tokenWidth(token) * token.maximum;\n if (maximumLength > 256) this.fail('final expanded length exceeds 256 characters including check digits');\n tokens.push(token);\n }\n if (!this.hasRandom) this.fail('pattern requires a random token (#, ?, *, or a class)');\n return tokens;\n }\n private token(): GenerationPatternToken {\n const character = this.pattern[this.offset++];\n const token = (characters: string): GenerationPatternToken => ({ characters, minimum: 1, maximum: 1 });\n switch (character) {\n case '#': this.hasRandom = true; return token('0123456789');\n case '?': this.hasRandom = true; return token('ABCDEFGHIJKLMNOPQRSTUVWXYZ');\n case '*': this.hasRandom = true; return token('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ');\n case '[': this.hasRandom = true; return token(this.characterClass());\n case '\\\\': return token(this.escape('#?*[]{}\\\\'));\n case '{': return this.segment();\n case ']': case '}': this.fail('unescaped closing delimiter');\n }\n return token(character);\n }\n private segment(): GenerationPatternToken {\n const end = this.pattern.indexOf('}', this.offset);\n if (end < 0) this.fail('unclosed date segment');\n const segment = this.pattern.slice(this.offset, end);\n if (digit(segment[0])) this.fail('repeat has no preceding token');\n if (!['yyyy', 'yy', 'MM', 'dd'].includes(segment)) this.fail('unknown date segment; use yyyy, yy, MM or dd');\n this.offset = end + 1;\n return { characters: '', minimum: 1, maximum: 1, segment };\n }\n private repeat(token: GenerationPatternToken): GenerationPatternToken {\n this.offset++;\n const end = this.pattern.indexOf('}', this.offset);\n if (end < 0) this.fail('unclosed repeat');\n const parts = this.pattern.slice(this.offset, end).split(',');\n if (parts.length > 2 || parts.some(part => part.length === 0 || [...part].some(character => !digit(character)))) this.fail('malformed repeat; use {n} or {m,n}');\n const minimum = Number(parts[0]);\n const maximum = Number(parts[parts.length - 1]);\n if (!Number.isSafeInteger(minimum) || !Number.isSafeInteger(maximum) || minimum > 2147483647 || maximum > 2147483647) this.fail('repeat bound exceeds 64');\n if (minimum < 1) this.fail('repeat minimum must be at least 1');\n if (minimum > maximum) this.fail('repeat minimum exceeds maximum');\n if (maximum > 64) this.fail('repeat maximum exceeds 64');\n this.offset = end + 1;\n return { ...token, minimum, maximum };\n }\n private escape(allowed: string): string {\n if (this.offset === this.pattern.length) this.fail('dangling escape');\n const character = this.pattern[this.offset++];\n if (!allowed.includes(character)) this.fail('illegal escape');\n return character;\n }\n private characterClass(): string {\n if (this.pattern[this.offset] === '^') this.fail('negated classes are not supported');\n const characters = new Set<string>();\n while (this.offset < this.pattern.length && this.pattern[this.offset] !== ']') {\n const first = this.classCharacter();\n if (this.pattern[this.offset] === '-') {\n this.offset++;\n if (this.offset === this.pattern.length || this.pattern[this.offset] === ']') this.fail('class range needs an endpoint; escape a literal hyphen');\n const last = this.classCharacter();\n if (last < first) this.fail('descending class range');\n for (let value = first.charCodeAt(0); value <= last.charCodeAt(0); value++) characters.add(String.fromCharCode(value));\n } else characters.add(first);\n }\n if (this.offset === this.pattern.length) this.fail('unclosed class');\n if (characters.size === 0) this.fail('empty class');\n this.offset++;\n return [...characters].sort().join('');\n }\n private classCharacter(): string {\n const character = this.pattern[this.offset++];\n if (character === '\\\\') return this.escape(']-\\\\');\n if (character === '-' || character === '[') this.fail('escape a literal class delimiter or hyphen');\n return character;\n }\n private fail(reason: string): never { throw new In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,KAAK,MAAM,CAAG,CACnG"}
1
+ {"version":3,"file":"GenerationPatternParser.js","names":["character","pattern","tokens","maximumLength","token","tokenWidth","end","segment","parts","part","minimum","maximum","allowed","characters","first","last","value","InvalidGenerationPattern","reason"],"sources":["../../../../../../Compiler/Generation/GenerationPatternParser.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { GenerationPatternToken, tokenWidth } from './GenerationPatternToken';\nimport { InvalidGenerationPattern } from './InvalidGenerationPattern';\n\nconst digit = (character: string | undefined): boolean => character !== undefined && character >= '0' && character <= '9';\n\nexport class GenerationPatternParser {\n private offset = 0;\n private hasRandom = false;\n constructor(private readonly pattern: string) {}\n parse(): readonly GenerationPatternToken[] {\n if (this.pattern.length === 0) this.fail('empty pattern');\n if ([...this.pattern].some(character => character < ' ' || character > '~')) this.fail('patterns require printable ASCII');\n const tokens: GenerationPatternToken[] = [];\n let maximumLength = 0;\n while (this.offset < this.pattern.length) {\n let token = this.token();\n if (this.pattern[this.offset] === '{' && digit(this.pattern[this.offset + 1])) token = this.repeat(token);\n maximumLength += tokenWidth(token) * token.maximum;\n if (maximumLength > 256) this.fail('final expanded length exceeds 256 characters including check digits');\n tokens.push(token);\n }\n if (!this.hasRandom) this.fail('pattern requires a random token (#, ?, *, or a class)');\n return tokens;\n }\n private token(): GenerationPatternToken {\n const character = this.pattern[this.offset++];\n const token = (characters: string): GenerationPatternToken => ({ characters, minimum: 1, maximum: 1 });\n switch (character) {\n case '#': this.hasRandom = true; return token('0123456789');\n case '?': this.hasRandom = true; return token('ABCDEFGHIJKLMNOPQRSTUVWXYZ');\n case '*': this.hasRandom = true; return token('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ');\n case '[': this.hasRandom = true; return token(this.characterClass());\n case '\\\\': return token(this.escape('#?*[]{}\\\\'));\n case '{': return this.segment();\n case ']': case '}': this.fail('unescaped closing delimiter');\n }\n return token(character);\n }\n private segment(): GenerationPatternToken {\n const end = this.pattern.indexOf('}', this.offset);\n if (end < 0) this.fail('unclosed date segment');\n const segment = this.pattern.slice(this.offset, end);\n if (digit(segment[0])) this.fail('repeat has no preceding token');\n if (!['yyyy', 'yy', 'MM', 'dd'].includes(segment)) this.fail('unknown date segment; use yyyy, yy, MM or dd');\n this.offset = end + 1;\n return { characters: '', minimum: 1, maximum: 1, segment };\n }\n private repeat(token: GenerationPatternToken): GenerationPatternToken {\n this.offset++;\n const end = this.pattern.indexOf('}', this.offset);\n if (end < 0) this.fail('unclosed repeat');\n const parts = this.pattern.slice(this.offset, end).split(',');\n if (parts.length > 2 || parts.some(part => part.length === 0 || [...part].some(character => !digit(character)))) this.fail('malformed repeat; use {n} or {m,n}');\n const minimum = Number(parts[0]);\n const maximum = Number(parts[parts.length - 1]);\n if (!Number.isSafeInteger(minimum) || !Number.isSafeInteger(maximum) || minimum > 2147483647 || maximum > 2147483647) this.fail('repeat bound exceeds 64');\n if (minimum < 1) this.fail('repeat minimum must be at least 1');\n if (minimum > maximum) this.fail('repeat minimum exceeds maximum');\n if (maximum > 64) this.fail('repeat maximum exceeds 64');\n this.offset = end + 1;\n return { ...token, minimum, maximum };\n }\n private escape(allowed: string): string {\n if (this.offset === this.pattern.length) this.fail('dangling escape');\n const character = this.pattern[this.offset++];\n if (!allowed.includes(character)) this.fail('illegal escape');\n return character;\n }\n private characterClass(): string {\n if (this.pattern[this.offset] === '^') this.fail('negated classes are not supported');\n const characters = new Set<string>();\n while (this.offset < this.pattern.length && this.pattern[this.offset] !== ']') {\n const first = this.classCharacter();\n if (this.pattern[this.offset] === '-') {\n this.offset++;\n if (this.offset === this.pattern.length || this.pattern[this.offset] === ']') this.fail('class range needs an endpoint; escape a literal hyphen');\n const last = this.classCharacter();\n if (last < first) this.fail('descending class range');\n for (let value = first.charCodeAt(0); value <= last.charCodeAt(0); value++) characters.add(String.fromCharCode(value));\n } else characters.add(first);\n }\n if (this.offset === this.pattern.length) this.fail('unclosed class');\n if (characters.size === 0) this.fail('empty class');\n this.offset++;\n return [...characters].sort().join('');\n }\n private classCharacter(): string {\n const character = this.pattern[this.offset++];\n if (character === '\\\\') return this.escape(']-\\\\');\n if (character === '-' || character === '[') this.fail('escape a literal class delimiter or hyphen');\n return character;\n }\n private fail(reason: string): never { throw new InvalidGenerationPattern(reason, this.offset); }\n}\n"],"mappings":"A,uLAMA,MAAM,MAAS,GAA2CA,IAAc,IAAA,IAAaA,GAAa,KAAOA,GAAa,IAEtH,IAAa,wBAAb,KAAqC,CAGJ,QAF7B,OAAiB,EACjB,UAAoB,GACpB,YAAY,EAAkC,CAAjB,KAAA,QAAAC,CAAkB,CAC/C,OAA2C,CACnC,KAAK,QAAQ,SAAW,GAAG,KAAK,KAAK,eAAe,EACpD,CAAC,GAAG,KAAK,OAAO,CAAC,CAAC,KAAK,GAAaD,EAAY,KAAOA,EAAY,GAAG,GAAG,KAAK,KAAK,kCAAkC,EACzH,IAAME,EAAmC,CAAC,EACtCC,EAAgB,EACpB,KAAO,KAAK,OAAS,KAAK,QAAQ,QAAQ,CACtC,IAAIC,EAAQ,KAAK,MAAM,EACnB,KAAK,QAAQ,KAAK,UAAY,KAAO,MAAM,KAAK,QAAQ,KAAK,OAAS,EAAE,IAAG,EAAQ,KAAK,OAAOA,CAAK,GACxG,GAAiBC,EAAWD,CAAK,EAAIA,EAAM,QACvCD,EAAgB,KAAK,KAAK,KAAK,qEAAqE,EACxGD,EAAO,KAAKE,CAAK,CACrB,CAEA,OADK,KAAK,WAAW,KAAK,KAAK,uDAAuD,EAC/EF,CACX,CACA,OAAwC,CACpC,IAAMF,EAAY,KAAK,QAAQ,KAAK,UAC9B,MAAS,IAAgD,CAAE,aAAY,QAAS,EAAG,QAAS,CAAE,GACpG,OAAQA,EAAR,CACI,IAAK,IAA4B,MAAvB,MAAK,UAAY,GAAa,MAAM,YAAY,EAC1D,IAAK,IAA4B,MAAvB,MAAK,UAAY,GAAa,MAAM,4BAA4B,EAC1E,IAAK,IA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AMb,EAAY,KAAK,QAAQ,KAAK,UAGpC,OAFIA,IAAc,KAAa,KAAK,OAAO,MAAM,IAC7CA,IAAc,KAAOA,IAAc,MAAK,KAAK,KAAK,4CAA4C,EAC3FA,EACX,CACA,KAAa,EAAuB,CAAE,MAAM,IAAIiB,EAAyBC,EAAQ,KAAK,MAAM,CAAG,CACnG,E"}
@@ -1 +1 @@
1
- {"version":3,"file":"GenerationPatternToken.js","names":["token"],"sources":["../../../../../../Compiler/Generation/GenerationPatternToken.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nexport interface GenerationPatternToken {\n readonly characters: string;\n readonly minimum: number;\n readonly maximum: number;\n readonly segment?: string;\n}\n\nexport function tokenWidth(token: GenerationPatternToken): number { return token.segment === 'yyyy' ? 4 : token.segment !== undefined ? 2 : 1; }\n\nexport function expandToken(token: GenerationPatternToken, date?: Date): string[] {\n if (token.segment === undefined) return [token.characters];\n if (date === undefined) return Array<string>(tokenWidth(token)).fill('0123456789');\n const year = date.getUTCFullYear();\n const value = token.segment === 'yyyy' ? year : token.segment === 'yy' ? year % 100 : token.segment === 'MM' ? date.getUTCMonth() + 1 : date.getUTCDate();\n return [...value.toString().padStart(tokenWidth(token), '0')];\n}\n"],"mappings":"qDAUA,SAAgB,WAAW,EAAuC,CAAE,OAAOA,EAAM,UAAY,OAAS,EAAIA,EAAM,UAAY,IAAA,GAAgB,EAAJ,CAAO"}
1
+ {"version":3,"file":"GenerationPatternToken.js","names":["token"],"sources":["../../../../../../Compiler/Generation/GenerationPatternToken.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nexport interface GenerationPatternToken {\n readonly characters: string;\n readonly minimum: number;\n readonly maximum: number;\n readonly segment?: string;\n}\n\nexport function tokenWidth(token: GenerationPatternToken): number { return token.segment === 'yyyy' ? 4 : token.segment !== undefined ? 2 : 1; }\n\nexport function expandToken(token: GenerationPatternToken, date?: Date): string[] {\n if (token.segment === undefined) return [token.characters];\n if (date === undefined) return Array<string>(tokenWidth(token)).fill('0123456789');\n const year = date.getUTCFullYear();\n const value = token.segment === 'yyyy' ? year : token.segment === 'yy' ? year % 100 : token.segment === 'MM' ? date.getUTCMonth() + 1 : date.getUTCDate();\n return [...value.toString().padStart(tokenWidth(token), '0')];\n}\n"],"mappings":"A,qDAUA,SAAgB,WAAW,EAAuC,CAAE,OAAOA,EAAM,UAAY,OAAS,EAAIA,EAAM,UAAY,IAAA,GAAgB,EAAJ,CAAO,C"}
@@ -1 +1 @@
1
- import"./RegexFragmentR.js";import"./BoundedRegexSamples.js";
1
+ import"./BoundedRegexSamples.js";import"./RegexFragmentR.js";
@@ -1 +1 @@
1
- {"version":3,"file":"InvalidGenerationPattern.js","names":["reason","offset"],"sources":["../../../../../../Compiler/Generation/InvalidGenerationPattern.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nexport class InvalidGenerationPattern extends Error {\n constructor(reason: string, readonly offset: number) { super(`${reason} at pattern offset ${offset}.`); }\n}\n"],"mappings":"qDAGA,IAAa,yBAAb,cAA8C,KAAM,CACX,OAArC,YAAY,EAAgB,EAAyB,CAAE,MAAM,GAAGA,EAAO,qBAAqBC,EAAO,EAAE,EAAhE,KAAA,OAAAA,CAAmE,CAC5G"}
1
+ {"version":3,"file":"InvalidGenerationPattern.js","names":["reason","offset"],"sources":["../../../../../../Compiler/Generation/InvalidGenerationPattern.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nexport class InvalidGenerationPattern extends Error {\n constructor(reason: string, readonly offset: number) { super(`${reason} at pattern offset ${offset}.`); }\n}\n"],"mappings":"A,qDAGA,IAAa,yBAAb,cAA8C,KAAM,CACX,OAArC,YAAY,EAAgB,EAAyB,CAAE,MAAM,GAAGA,EAAO,qBAAqBC,EAAO,EAAE,EAAhE,KAAA,OAAAA,CAAmE,CAC5G,E"}
@@ -1 +1 @@
1
- {"version":3,"file":"RegexCharacters.js","names":["index"],"sources":["../../../../../../Compiler/Generation/RegexCharacters.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { OutsideRegexFragment } from './RegexProofErrors';\n\nexport const printable = Array.from({ length: 95 }, (_, index) => String.fromCharCode(index + 32)).join('');\nexport function complement(characters: string): string { return [...printable].filter(character => !characters.includes(character)).join(''); }\nexport function regexEscape(character: string, inClass: boolean): string {\n switch (character) {\n case 'd': return '0123456789';\n case 'D': return complement('0123456789');\n case 'w': return 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_';\n case 'W': return complement('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_');\n case 's': return ' ';\n case 'S': return complement(' ');\n case 't': return '\\t';\n case 'n': return '\\n';\n case 'r': return '\\r';\n case 'f': return '\\f';\n case 'v': return '\\v';\n case 'b': case 'B': throw new OutsideRegexFragment('word boundary');\n case 'x': case 'u': case 'c': case '0': throw new OutsideRegexFragment(`\\\\${character} escape`);\n }\n if (character >= '1' && character <= '9') throw new OutsideRegexFragment('backreference');\n if ('\\\\^$.|?*+()[]{}'.includes(character) || (inClass && character === '-')) return character;\n throw new OutsideRegexFragment(`identity escape \\\\${character}`);\n}\n"],"mappings":"qDAKyB,MAAM,KAAK,CAAE,OAAQ,EAAG,GAAI,EAAG,IAAU,OAAO,aAAaA,EAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE"}
1
+ {"version":3,"file":"RegexCharacters.js","names":["index"],"sources":["../../../../../../Compiler/Generation/RegexCharacters.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { OutsideRegexFragment } from './RegexProofErrors';\n\nexport const printable = Array.from({ length: 95 }, (_, index) => String.fromCharCode(index + 32)).join('');\nexport function complement(characters: string): string { return [...printable].filter(character => !characters.includes(character)).join(''); }\nexport function regexEscape(character: string, inClass: boolean): string {\n switch (character) {\n case 'd': return '0123456789';\n case 'D': return complement('0123456789');\n case 'w': return 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_';\n case 'W': return complement('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_');\n case 's': return ' ';\n case 'S': return complement(' ');\n case 't': return '\\t';\n case 'n': return '\\n';\n case 'r': return '\\r';\n case 'f': return '\\f';\n case 'v': return '\\v';\n case 'b': case 'B': throw new OutsideRegexFragment('word boundary');\n case 'x': case 'u': case 'c': case '0': throw new OutsideRegexFragment(`\\\\${character} escape`);\n }\n if (character >= '1' && character <= '9') throw new OutsideRegexFragment('backreference');\n if ('\\\\^$.|?*+()[]{}'.includes(character) || (inClass && character === '-')) return character;\n throw new OutsideRegexFragment(`identity escape \\\\${character}`);\n}\n"],"mappings":"A,qDAKyB,MAAM,KAAK,CAAE,OAAQ,EAAG,GAAI,EAAG,IAAU,OAAO,aAAaA,EAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"RegexExpression.js","names":["RegexExpression","kind","characters","left","right","minimum","maximum","expression","character","text"],"sources":["../../../../../../Compiler/Generation/RegexExpression.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { RegexExpressionKind as Kind } from './RegexExpressionKind';\n\n/** Immutable expression with cached minima; flat authored literals never recurse during analysis. */\nexport class RegexExpression {\n readonly minimumLength: number;\n readonly hasNullableRepeat: boolean;\n private constructor(\n readonly kind: Kind,\n readonly characters = '',\n readonly left?: RegexExpression,\n readonly right?: RegexExpression,\n readonly minimum = 0,\n readonly maximum: number | null = 0\n ) {\n switch (kind) {\n case Kind.Empty: this.minimumLength = 0; break;\n case Kind.None: this.minimumLength = Number.MAX_SAFE_INTEGER; break;\n case Kind.Characters: this.minimumLength = characters.length === 0 ? Number.MAX_SAFE_INTEGER : 1; break;\n case Kind.Alternate: this.minimumLength = Math.min(left!.minimumLength, right!.minimumLength); break;\n case Kind.Concat: this.minimumLength = Math.min(Number.MAX_SAFE_INTEGER, left!.minimumLength + right!.minimumLength); break;\n case Kind.Repeat: this.minimumLength = Math.min(Number.MAX_SAFE_INTEGER, left!.minimumLength * minimum); break;\n }\n this.hasNullableRepeat = kind === Kind.Repeat\n ? left!.hasNullableRepeat || (left!.minimumLength === 0 && (maximum === null || maximum > 1))\n : (left?.hasNullableRepeat ?? false) || (right?.hasNullableRepeat ?? false);\n }\n static readonly empty = new RegexExpression(Kind.Empty);\n static readonly none = new RegexExpression(Kind.None);\n static character(characters: string): RegexExpression { return new RegexExpression(Kind.Characters, characters); }\n static alternate(left: RegexExpression, right: RegexExpression): RegexExpression { return new RegexExpression(Kind.Alternate, '', left, right); }\n static concat(left: RegexExpression, right: RegexExpression): RegexExpression { return new RegexExpression(Kind.Concat, '', left, right); }\n static repeat(expression: RegexExpression, minimum: number, maximum: number | null): RegexExpression { return new RegexExpression(Kind.Repeat, '', expression, undefined, minimum, maximum); }\n static literal(text: string): RegexExpression {\n let expression = RegexExpression.empty;\n for (const character of text) expression = RegexExpression.concat(expression, RegexExpression.character(character));\n return expression;\n }\n}\n"],"mappings":"qDAMA,IAAaA,EAAb,MAAa,eAAgB,CAIZ,KACA,WACA,KACA,MACA,QACA,QARb,cACA,kBACA,YACI,EACA,EAAsB,GACtB,EACA,EACA,EAAmB,EACnB,EAAkC,EACpC,CACE,OAPS,KAAA,KAAAC,EACA,KAAA,WAAAC,EACA,KAAA,KAAAC,EACA,KAAA,MAAAC,EACA,KAAA,QAAAC,EACA,KAAA,QAAAC,EAEDL,EAAR,CACI,IAAA,GAAiB,KAAK,cAAgB,EAAG,MACzC,IAAA,GAAgB,KAAK,sBAAyC,MAC9D,IAAA,GAAsB,KAAK,cAAgBC,EAAW,SAAW,UAA8B,EAAG,MAClG,IAAA,GAAqB,KAAK,cAAgB,KAAK,IAAIC,EAAM,cAAeC,EAAO,aAAa,EAAG,MAC/F,IAAA,GAAkB,KAAK,cAAgB,KAAK,YAA6BD,EAAM,cAAgBC,EAAO,aAAa,EAAG,MACtH,IAAA,GAAkB,KAAK,cAAgB,KAAK,YAA6BD,EAAM,cAAgBE,CAAO,CAC1G,CACA,KAAK,kBAAoBJ,IAAA,EACnBE,EAAM,mBAAsBA,EAAM,gBAAkB,IAAMG,IAAY,MAAQA,EAAU,IACvFH,GAAM,mBAAqB,MAAWC,GAAO,mBAAqB,GAC7E,CACA,OAAgB,MAAQ,IAAI,gBAAA,CAA0B,EACtD,OAAgB,KAAO,IAAI,gBAAA,CAAyB,EACpD,OAAO,UAAU,EAAqC,CAAE,OAAO,IAAI,gBAAA,EAAiCF,CAAU,CAAG,CACjH,OAAO,UAAU,EAAuB,EAAyC,CAAE,OAAO,IAAI,gBAAA,EAAgC,GAAIC,EAAMC,CAAK,CAAG,CAChJ,OAAO,OAAO,EAAuB,EAAyC,CAAE,OAAO,IAAI,gBAAA,EAA6B,GAAID,EAAMC,CAAK,CAAG,CAC1I,OAAO,OAAO,EAA6B,EAAiB,EAAyC,CAAE,OAAO,IAAI,gBAAA,EAA6B,GAAIG,EAAY,IAAA,GAAWF,EAASC,CAAO,CAAG,CAC7L,OAAO,QAAQ,EAA+B,CAC1C,IAAIC,EAAa,gBAAgB,MACjC,IAAK,IAAMC,KAAaC,EAAM,EAAa,gBAAgB,OAAOF,EAAY,gBAAgB,UAAUC,CAAS,CAAC,EAClH,OAAOD,CACX,CACJ"}
1
+ {"version":3,"file":"RegexExpression.js","names":["RegexExpression","kind","characters","left","right","minimum","maximum","expression","character","text"],"sources":["../../../../../../Compiler/Generation/RegexExpression.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { RegexExpressionKind as Kind } from './RegexExpressionKind';\n\n/** Immutable expression with cached minima; flat authored literals never recurse during analysis. */\nexport class RegexExpression {\n readonly minimumLength: number;\n readonly hasNullableRepeat: boolean;\n private constructor(\n readonly kind: Kind,\n readonly characters = '',\n readonly left?: RegexExpression,\n readonly right?: RegexExpression,\n readonly minimum = 0,\n readonly maximum: number | null = 0\n ) {\n switch (kind) {\n case Kind.Empty: this.minimumLength = 0; break;\n case Kind.None: this.minimumLength = Number.MAX_SAFE_INTEGER; break;\n case Kind.Characters: this.minimumLength = characters.length === 0 ? Number.MAX_SAFE_INTEGER : 1; break;\n case Kind.Alternate: this.minimumLength = Math.min(left!.minimumLength, right!.minimumLength); break;\n case Kind.Concat: this.minimumLength = Math.min(Number.MAX_SAFE_INTEGER, left!.minimumLength + right!.minimumLength); break;\n case Kind.Repeat: this.minimumLength = Math.min(Number.MAX_SAFE_INTEGER, left!.minimumLength * minimum); break;\n }\n this.hasNullableRepeat = kind === Kind.Repeat\n ? left!.hasNullableRepeat || (left!.minimumLength === 0 && (maximum === null || maximum > 1))\n : (left?.hasNullableRepeat ?? false) || (right?.hasNullableRepeat ?? false);\n }\n static readonly empty = new RegexExpression(Kind.Empty);\n static readonly none = new RegexExpression(Kind.None);\n static character(characters: string): RegexExpression { return new RegexExpression(Kind.Characters, characters); }\n static alternate(left: RegexExpression, right: RegexExpression): RegexExpression { return new RegexExpression(Kind.Alternate, '', left, right); }\n static concat(left: RegexExpression, right: RegexExpression): RegexExpression { return new RegexExpression(Kind.Concat, '', left, right); }\n static repeat(expression: RegexExpression, minimum: number, maximum: number | null): RegexExpression { return new RegexExpression(Kind.Repeat, '', expression, undefined, minimum, maximum); }\n static literal(text: string): RegexExpression {\n let expression = RegexExpression.empty;\n for (const character of text) expression = RegexExpression.concat(expression, RegexExpression.character(character));\n return expression;\n }\n}\n"],"mappings":"A,qDAMA,IAAaA,EAAb,MAAa,eAAgB,CAI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a,gBAAgB,MACjC,IAAK,IAAMC,KAAaC,EAAM,EAAa,gBAAgB,OAAOF,EAAY,gBAAgB,UAAUC,CAAS,CAAC,EAClH,OAAOD,CACX,CACJ,E"}
@@ -1 +1 @@
1
- import"./RegexExpression.js";import"./GenerationRuleProof.js";import"./TextRuleExpression.js";
1
+ import"./GenerationRuleProof.js";import"./RegexExpression.js";import"./TextRuleExpression.js";
@@ -1 +1 @@
1
- {"version":3,"file":"ActionSubjectClause.js","names":["word","pattern","stringBodyPattern","label","clause","input","line","context","DiagnosticCodes","locationOf","inputs","argument","boundary","isHeader","words","part","clauses","labelWord","header","text","match","unescapeString","start","action","content"],"sources":["../../../../../../Compiler/Parsing/ActionSubjectClause.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { InteractionArgumentSyntax, ScreenActionSubjectKind } from '../Syntax/Screens';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { pattern } from '../Text/patterns';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst word = new RegExp(pattern(`\"${stringBodyPattern}\"|\\\\S+`).source, 'gu');\nconst label = pattern(`^label\\\\s+(?:\"(${stringBodyPattern})\"|(\\\\$strings\\\\.\\\\w+(?:\\\\.\\\\w+)*))$`);\nconst clause = pattern('^for\\\\s+(item|screen)$');\n\nexport function parsePlainActionInput(context: ParserContext, line: SourceLine, inputs: readonly InteractionArgumentSyntax[]): InteractionArgumentSyntax | undefined {\n const input = pattern('^with\\\\s+([A-Za-z_]\\\\w*)\\\\s+from\\\\s+(.+)$').exec(line.content);\n if (input === null) {\n context.error(DiagnosticCodes.InvalidInteractionArgument, `Invalid argument '${line.content}' - expected 'with <name> from <binding>'`, locationOf(line));\n return undefined;\n }\n if (inputs.some(argument => argument.name === input[1])) context.error(DiagnosticCodes.InvalidInteractionArgument, `Duplicate argument '${input[1]}' - supply each input only once`, locationOf(line));\n return { kind: 'InteractionArgumentSyntax', name: input[1], binding: input[2].trim(), location: locationOf(line) };\n}\n\nexport function parseSubjectClause(context: ParserContext, line: SourceLine, action: boolean, isHeader: (content: string) => boolean): { header: string; subject?: ScreenActionSubjectKind; label?: string } {\n const boundary = subjectHeaderBoundary(line.content, isHeader);\n const words = [...line.content.matchAll(word)].filter(part => part.index! >= boundary);\n const clauses = words.filter(part => part[0] === 'for');\n const labelWord = words.find(part => part[0] === 'label');\n let header = line.content;\n let text: string | undefined;\n if (labelWord !== undefined) {\n const match = label.exec(header.substring(labelWord.index));\n if (match !== null) {\n text = match[1] !== undefined ? unescapeString(match[1]) : match[2];\n header = header.substring(0, labelWord.index).trimEnd();\n }\n }\n if (clauses.length === 0) return { header, label: text };\n const start = clauses[0].index!;\n const match = clause.exec(header.substring(start));\n header = header.substring(0, start).trimEnd();\n if (!action || clauses.length !== 1 || match === null || labelWord !== undefined && labelWord.index! < start) {\n context.error(DiagnosticCodes.InvalidActionSubjectClause, \"Invalid action subject clause - expected one 'for item' or 'for screen' before the label on an action\", locationOf(line));\n return { header: line.content.substring(0, boundary).trimEnd(), label: text };\n }\n return { header, subject: match[1] === 'item' ? 'Item' : 'Screen', label: text };\n}\n\nfunction subjectHeaderBoundary(content: string, isHeader: (header: string) => boolean): number {\n // A complete existing header wins, including keyword-looking required operands.\n if (isHeader(content)) return content.length;\n return [...content.matchAll(word)].reverse().find(part => isHeader(content.substring(0, part.index).trimEnd()))?.index ?? content.length;\n}\n"],"mappings":"qSAUA,MAAMA,EAAO,IAAI,OAAOC,EAAQ,IAAIC,EAAkB,OAAO,CAAC,CAAC,OAAQ,IAAI,EACrEC,EAAQF,EAAQ,kBAAkBC,EAAkB,qCAAqC,EACzFE,EAASH,EAAQ,wBAAwB,EAE/C,SAAgB,sBAAsB,EAAwB,EAAkB,EAAqF,CACjK,IAAMI,EAAQJ,EAAQ,2CAA2C,CAAC,CAAC,KA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,MAAQH,IAAc,IAAA,IAAaA,EAAU,MAASK,GACnGf,EAAQ,MAAMC,EAAgB,2BAA4B,wGAAyGC,EAAWH,CAAI,CAAC,EAC5K,CAAE,OAAQA,EAAK,QAAQ,UAAU,EAAGM,CAAQ,CAAC,CAAC,QAAQ,EAAG,MAAOO,CAAK,GAEzE,CAAE,SAAQ,QAASC,EAAM,KAAO,OAAS,OAAS,SAAU,MAAOD,CAAK,CACnF,CAEA,SAAS,sBAAsB,EAAiB,EAA+C,CAG3F,OADIN,EAASW,CAAO,EAAUA,EAAQ,OAC/B,CAAC,GAAGA,EAAQ,SAASxB,CAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,GAAQa,EAASW,EAAQ,UAAU,EAAGT,EAAK,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAASS,EAAQ,MACtI"}
1
+ {"version":3,"file":"ActionSubjectClause.js","names":["word","pattern","stringBodyPattern","label","clause","input","line","context","DiagnosticCodes","locationOf","inputs","argument","boundary","isHeader","words","part","clauses","labelWord","header","text","match","unescapeString","start","action","content"],"sources":["../../../../../../Compiler/Parsing/ActionSubjectClause.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { InteractionArgumentSyntax, ScreenActionSubjectKind } from '../Syntax/Screens';\nimport { stringBodyPattern, unescapeString } from '../Text/StringLiteral';\nimport { pattern } from '../Text/patterns';\nimport { ParserContext } from './ParserContext';\nimport { locationOf, SourceLine } from './SourceLine';\n\nconst word = new RegExp(pattern(`\"${stringBodyPattern}\"|\\\\S+`).source, 'gu');\nconst label = pattern(`^label\\\\s+(?:\"(${stringBodyPattern})\"|(\\\\$strings\\\\.\\\\w+(?:\\\\.\\\\w+)*))$`);\nconst clause = pattern('^for\\\\s+(item|screen)$');\n\nexport function parsePlainActionInput(context: ParserContext, line: SourceLine, inputs: readonly InteractionArgumentSyntax[]): InteractionArgumentSyntax | undefined {\n const input = pattern('^with\\\\s+([A-Za-z_]\\\\w*)\\\\s+from\\\\s+(.+)$').exec(line.content);\n if (input === null) {\n context.error(DiagnosticCodes.InvalidInteractionArgument, `Invalid argument '${line.content}' - expected 'with <name> from <binding>'`, locationOf(line));\n return undefined;\n }\n if (inputs.some(argument => argument.name === input[1])) context.error(DiagnosticCodes.InvalidInteractionArgument, `Duplicate argument '${input[1]}' - supply each input only once`, locationOf(line));\n return { kind: 'InteractionArgumentSyntax', name: input[1], binding: input[2].trim(), location: locationOf(line) };\n}\n\nexport function parseSubjectClause(context: ParserContext, line: SourceLine, action: boolean, isHeader: (content: string) => boolean): { header: string; subject?: ScreenActionSubjectKind; label?: string } {\n const boundary = subjectHeaderBoundary(line.content, isHeader);\n const words = [...line.content.matchAll(word)].filter(part => part.index! >= boundary);\n const clauses = words.filter(part => part[0] === 'for');\n const labelWord = words.find(part => part[0] === 'label');\n let header = line.content;\n let text: string | undefined;\n if (labelWord !== undefined) {\n const match = label.exec(header.substring(labelWord.index));\n if (match !== null) {\n text = match[1] !== undefined ? unescapeString(match[1]) : match[2];\n header = header.substring(0, labelWord.index).trimEnd();\n }\n }\n if (clauses.length === 0) return { header, label: text };\n const start = clauses[0].index!;\n const match = clause.exec(header.substring(start));\n header = header.substring(0, start).trimEnd();\n if (!action || clauses.length !== 1 || match === null || labelWord !== undefined && labelWord.index! < start) {\n context.error(DiagnosticCodes.InvalidActionSubjectClause, \"Invalid action subject clause - expected one 'for item' or 'for screen' before the label on an action\", locationOf(line));\n return { header: line.content.substring(0, boundary).trimEnd(), label: text };\n }\n return { header, subject: match[1] === 'item' ? 'Item' : 'Screen', label: text };\n}\n\nfunction subjectHeaderBoundary(content: string, isHeader: (header: string) => boolean): number {\n // A complete existing header wins, including keyword-looking required operands.\n if (isHeader(content)) return content.length;\n return [...content.matchAll(word)].reverse().find(part => isHeader(content.substring(0, part.index).trimEnd()))?.index ??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C,QAAQ,EAE9D,CACA,GAAID,EAAQ,SAAW,EAAG,MAAO,CAAE,SAAQ,MAAOG,CAAK,EACvD,IAAMG,EAAQN,EAAQ,EAAE,CAAC,MACnBI,EAAQhB,EAAO,KAAKc,EAAO,UAAUI,CAAK,CAAC,EAMjD,MALA,GAASJ,EAAO,UAAU,EAAGI,CAAK,CAAC,CAAC,QAAQ,EACxC,CAACC,GAAUP,EAAQ,SAAW,GAAKI,IAAU,MAAQH,IAAc,IAAA,IAAaA,EAAU,MAASK,GACnGf,EAAQ,MAAMC,EAAgB,2BAA4B,wGAAyGC,EAAWH,CAAI,CAAC,EAC5K,CAAE,OAAQA,EAAK,QAAQ,UAAU,EAAGM,CAAQ,CAAC,CAAC,QAAQ,EAAG,MAAOO,CAAK,GAEzE,CAAE,SAAQ,QAASC,EAAM,KAAO,OAAS,OAAS,SAAU,MAAOD,CAAK,CACnF,CAEA,SAAS,sBAAsB,EAAiB,EAA+C,CAG3F,OADIN,EAASW,CAAO,EAAUA,EAAQ,OAC/B,CAAC,GAAGA,EAAQ,SAASxB,CAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,GAAQa,EAASW,EAAQ,UAAU,EAAGT,EAAK,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,OAASS,EAAQ,MACtI,C"}
@@ -1 +1 @@
1
- {"version":3,"file":"ActionSubjectInputs.js","names":["declarations","diagnostics","context","entry","name","key","input","concept","properties","property","named","keys","authored","identifiers","command","item","DiagnosticCodes","bound","inputs","legacy","current","result","argument","matches"],"sources":["../../../../../../Compiler/Parsing/ActionSubjectInputs.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Diagnostic } from '../Diagnostics/Diagnostic';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { PropertySyntax } from '../Syntax/Declarations';\nimport { InteractionArgumentSyntax, ScreenActionSubjectKind, ScreenDataSyntax } from '../Syntax/Screens';\nimport { SliceSyntax } from '../Syntax/Structure';\nimport { RefusalDeclarations } from './RefusalDeclarations';\n\nexport interface ActionSubjectContext {\n readonly data: readonly ScreenDataSyntax[];\n readonly slice: SliceSyntax;\n readonly location: SourceLocation;\n}\n\nexport class ActionSubjectInputs {\n constructor(readonly declarations: RefusalDeclarations, readonly diagnostics: Diagnostic[]) {}\n\n properties(context: ActionSubjectContext): readonly PropertySyntax[] {\n return context.data.length === 1 ? this.declarations.resolve(context.data[0].type.name, context.slice, entry => entry.readModels)?.node.properties ?? [] : [];\n }\n\n command(name: string, context: ActionSubjectContext): readonly PropertySyntax[] {\n return this.declarations.resolve(name, context.slice, entry => entry.commands)?.node.properties ?? [];\n }\n\n sameConcept(input: PropertySyntax, key: PropertySyntax): boolean {\n return !key.type.isCollection && !key.type.isOptional && input.type.name === key.type.name && this.declarations.application.concepts.filter(concept => concept.name === input.type.name).length === 1;\n }\n\n eligible(input: PropertySyntax): boolean {\n return input.isIdentifier && !input.isGenerated && !input.type.isOptional && !input.type.isCollection;\n }\n\n keys(input: PropertySyntax, properties: readonly PropertySyntax[]): readonly PropertySyntax[] {\n return this.eligible(input) ? properties.filter(property => property.isKey && this.sameConcept(input, property)) : [];\n }\n\n binding(input: PropertySyntax, properties: readonly PropertySyntax[]): PropertySyntax | null {\n const named = properties.filter(property => property.name === input.name && this.declarations.compatible(property.type, input.type) === true);\n if (named.length === 1) return named[0];\n const keys = this.keys(input, properties);\n return keys.length === 1 ? keys[0] : null;\n }\n\n subject(authored: ScreenActionSubjectKind | null | undefined, command: string, bound: readonly string[], context: ActionSubjectContext): ScreenActionSubjectKind | null {\n if (authored != null) return authored;\n const identifiers = this.command(command, context).filter(input => this.eligible(input));\n const keys = identifiers.length === 1 ? this.keys(identifiers[0], this.properties(context)) : [];\n const item = context.data.length === 1 && context.data[0].type.isCollection && keys.length === 1;\n this.diagnostics.push({ severity: 'information', code: DiagnosticCodes.InferredActionSubject, message: `Action '${command}' infers 'for ${item ? 'item' : 'screen'}' from its declared data and identifier types`, location: context.location });\n this.migration(command, bound, context, item);\n return item ? 'Item' : null;\n }\n\n migration(command: string, bound: readonly string[], context: ActionSubjectContext, item: boolean): void {\n if (context.data.length !== 1 || !context.data[0].type.isCollection) return;\n const properties = this.properties(context);\n const inputs = this.command(command, context).filter(input => !input.isGenerated && !bound.includes(input.name));\n const legacy = inputs.flatMap(input => properties.filter(property => input.name.toLowerCase() === property.name.toLowerCase()).map(property => `${input.name} from item.${property.name}`));\n const current = item ? inputs.flatMap(input => {\n const property = this.binding(input, properties);\n return property === null ? [] : [`${input.name} from item.${property.name}`];\n }) : [];\n if (JSON.stringify(legacy) !== JSON.stringify(current)) this.diagnostics.push({ severity: 'warning', code: DiagnosticCodes.ChangedActionSubject, message: `Action '${command}' now infers 'for ${item ? 'item' : 'screen'}'; legacy row-name matching would use ${legacy.length === 0 ? 'no row property' : legacy.join(', ')}`, location: context.location });\n }\n\n legacyInputs(command: string, authored: readonly InteractionArgumentSyntax[], context: ActionSubjectContext): readonly InteractionArgumentSyntax[] | null {\n if (context.data.length !== 1 || !context.data[0].type.isCollection) return null;\n const result = [...authored];\n const properties = this.properties(context);\n for (const input of this.command(command, context).filter(input => !input.isGenerated)) {\n if (result.some(argument => argument.name === input.name)) continue;\n const matches = properties.filter(property => property.name.toLowerCase() === input.name.toLowerCase());\n if (!this.legacyMatchIsSafe(input, properties, matches.length)) return null;\n if (matches.length === 1) result.push({ kind: 'InteractionArgumentSyntax', name: input.name, binding: `item.${matches[0].name}`, location: context.location });\n }\n return result;\n }\n\n private legacyMatchIsSafe(input: PropertySyntax, properties: readonly PropertySyntax[], matches: number): boolean {\n if (matches > 1) return false;\n return matches > 0 || this.keys(input, properties).length === 0;\n }\n\n inputs(command: string, authored: readonly InteractionArgumentSyntax[], context: ActionSubjectContext): readonly InteractionArgumentSyntax[] {\n const result = [...authored];\n if (context.data.length !== 1) return result;\n const properties = this.properties(context);\n for (const input of this.command(command, context).filter(input => !input.isGenerated)) {\n if (result.some(argument => argument.name === input.name)) continue;\n const property = this.binding(input, properties);\n if (property !== null) result.push({ kind: 'InteractionArgumentSyntax', name: input.name, binding: `item.${property.name}`, location: context.location });\n else if (this.keys(input, properties).length > 1) this.diagnostics.push({ severity: 'warning', code: DiagnosticCodes.AmbiguousActionInputBinding, message: `Input '${input.name}' of action '${command}' matches several declared key fields - write an explicit binding`, location: context.location });\n }\n return result;\n }\n}\n"],"mappings":"yHAiBA,IAAa,oBAAb,KAAiC,CACR,aAA4C,YAAjE,YAAY,EAA4C,EAAoC,CAAvE,KAAA,aAAAA,EAA4C,KAAA,YAAAC,CAA4B,CAE7F,WAAW,EAA0D,CACjE,OAAOC,EAAQ,KAAK,SAAW,EAAI,KAAK,aAAa,QAAQA,EAAQ,KAAK,EAAE,CAAC,KAAK,KAAMA,EAAQ,MAAO,GAASC,EAAM,UAAU,CAAC,EAAE,KAAK,YAAc,CAAC,EAAI,CAAC,CAChK,CAEA,QAAQ,EAAc,EAA0D,CAC5E,OAAO,KAAK,aAAa,QAAQC,EAAMF,EAAQ,MAAO,GAASC,EAAM,QAAQ,CAAC,EAAE,KAAK,YAAc,CAAC,CACxG,CAEA,YAAY,EAAuB,EAA8B,CAC7D,MAAO,CAACE,EAAI,KAAK,cAAgB,CAACA,EAAI,KAAK,YAAcC,EAAM,KAAK,OAASD,EAAI,KAAK,MAAQ,KAAK,aAAa,YAAY,SAAS,OAAO,GAAWE,EAAQ,OAASD,EAAM,KAAK,IAAI,CAAC,CAAC,SAAW,CACxM,CAEA,SAAS,EAAgC,CACrC,OAAOA,EAAM,cAAgB,CAACA,EAAM,aAAe,CAACA,EAAM,KAAK,YAAc,CAACA,EAAM,KAAK,YAC7F,CAEA,KAAK,EAAuB,EAAkE,CAC1F,OAAO,KAAK,SAASA,CAAK,EAAIE,EAAW,OAAO,GAAYC,EAAS,OAAS,KAAK,YAAYH,EAAOG,C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UrB,EAAQ,QAAS,CAAC,CACjK,CACA,OAAOmB,CACX,CAEA,kBAA0B,EAAuB,EAAuC,EAA0B,CAE9G,OADIE,EAAU,EAAU,GACjBA,EAAU,GAAK,KAAK,KAAKjB,EAAOE,CAAU,CAAC,CAAC,SAAW,CAClE,CAEA,OAAO,EAAiB,EAAgD,EAAqE,CACzI,IAAMa,EAAS,CAAC,GAAGT,CAAQ,EAC3B,GAAIV,EAAQ,KAAK,SAAW,EAAG,OAAOmB,EACtC,IAAMb,EAAa,KAAK,WAAWN,CAAO,EAC1C,IAAK,IAAMI,KAAS,KAAK,QAAQQ,EAASZ,CAAO,CAAC,CAAC,OAAO,GAAS,CAACI,EAAM,WAAW,EAAG,CACpF,GAAIe,EAAO,KAAK,GAAYC,EAAS,OAAShB,EAAM,IAAI,EAAG,SAC3D,IAAMG,EAAW,KAAK,QAAQH,EAAOE,CAAU,EAC3CC,IAAa,KACR,KAAK,KAAKH,EAAOE,CAAU,CAAC,CAAC,OAAS,GAAG,KAAK,YAAY,KAAK,CAAE,SAAU,UAAW,KAAMQ,EAAgB,4BAA6B,QAAS,UAAUV,EAAM,KAAK,eAAeQ,EAAQ,mEAAoE,SAAUZ,EAAQ,QAAS,CAAC,EADhRmB,EAAO,KAAK,CAAE,KAAM,4BAA6B,KAAMf,EAAM,KAAM,QAAS,QAAQG,EAAS,OAAQ,SAAUP,EAAQ,QAAS,CAAC,CAE5J,CACA,OAAOmB,CACX,CACJ"}
1
+ {"version":3,"file":"ActionSubjectInputs.js","names":["declarations","diagnostics","context","entry","name","key","input","concept","properties","property","named","keys","authored","identifiers","command","item","DiagnosticCodes","bound","inputs","legacy","current","result","argument","matches"],"sources":["../../../../../../Compiler/Parsing/ActionSubjectInputs.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Diagnostic } from '../Diagnostics/Diagnostic';\nimport { DiagnosticCodes } from '../Diagnostics/DiagnosticCodes';\nimport { SourceLocation } from '../Diagnostics/SourceLocation';\nimport { PropertySyntax } from '../Syntax/Declarations';\nimport { InteractionArgumentSyntax, ScreenActionSubjectKind, ScreenDataSyntax } from '../Syntax/Screens';\nimport { SliceSyntax } from '../Syntax/Structure';\nimport { RefusalDeclarations } from './RefusalDeclarations';\n\nexport interface ActionSubjectContext {\n readonly data: readonly ScreenDataSyntax[];\n readonly slice: SliceSyntax;\n readonly location: SourceLocation;\n}\n\nexport class ActionSubjectInputs {\n constructor(readonly declarations: RefusalDeclarations, readonly diagnostics: Diagnostic[]) {}\n\n properties(context: ActionSubjectContext): readonly PropertySyntax[] {\n return context.data.length === 1 ? this.declarations.resolve(context.data[0].type.name, context.slice, entry => entry.readModels)?.node.properties ?? [] : [];\n }\n\n command(name: string, context: ActionSubjectContext): readonly PropertySyntax[] {\n return this.declarations.resolve(name, context.slice, entry => entry.commands)?.node.properties ?? [];\n }\n\n sameConcept(input: PropertySyntax, key: PropertySyntax): boolean {\n return !key.type.isCollection && !key.type.isOptional && input.type.name === key.type.name && this.declarations.application.concepts.filter(concept => concept.name === input.type.name).length === 1;\n }\n\n eligible(input: PropertySyntax): boolean {\n return input.isIdentifier && !input.isGenerated && !input.type.isOptional && !input.type.isCollection;\n }\n\n keys(input: PropertySyntax, properties: readonly PropertySyntax[]): readonly PropertySyntax[] {\n return this.eligible(input) ? properties.filter(property => property.isKey && this.sameConcept(input, property)) : [];\n }\n\n binding(input: PropertySyntax, properties: readonly PropertySyntax[]): PropertySyntax | null {\n const named = properties.filter(property => property.name === input.name && this.declarations.compatible(property.type, input.type) === true);\n if (named.length === 1) return named[0];\n const keys = this.keys(input, properties);\n return keys.length === 1 ? keys[0] : null;\n }\n\n subject(authored: ScreenActionSubjectKind | null | undefined, command: string, bound: readonly string[], context: ActionSubjectContext): ScreenActionSubjectKind | null {\n if (authored != null) return authored;\n const identifiers = this.command(command, context).filter(input => this.eligible(input));\n const keys = identifiers.length === 1 ? this.keys(identifiers[0], this.properties(context)) : [];\n const item = context.data.length === 1 && context.data[0].type.isCollection && keys.length === 1;\n this.diagnostics.push({ severity: 'information', code: DiagnosticCodes.InferredActionSubject, message: `Action '${command}' infers 'for ${item ? 'item' : 'screen'}' from its declared data and identifier types`, location: context.location });\n this.migration(command, bound, context, item);\n return item ? 'Item' : null;\n }\n\n migration(command: string, bound: readonly string[], context: ActionSubjectContext, item: boolean): void {\n if (context.data.length !== 1 || !context.data[0].type.isCollection) return;\n const properties = this.properties(context);\n const inputs = this.command(command, context).filter(input => !input.isGenerated && !bound.includes(input.name));\n const legacy = inputs.flatMap(input => properties.filter(property => input.name.toLowerCase() === property.name.toLowerCase()).map(property => `${input.name} from item.${property.name}`));\n const current = item ? inputs.flatMap(input => {\n const property = this.binding(input, properties);\n return property === null ? [] : [`${input.name} from item.${property.name}`];\n }) : [];\n if (JSON.stringify(legacy) !== JSON.stringify(current)) this.diagnostics.push({ severity: 'warning', code: DiagnosticCodes.ChangedActionSubject, message: `Action '${command}' now infers 'for ${item ? 'item' : 'screen'}'; legacy row-name matching would use ${legacy.length === 0 ? 'no row property' : legacy.join(', ')}`, location: context.location });\n }\n\n legacyInputs(command: string, authored: readonly InteractionArgumentSyntax[], context: ActionSubjectContext): readonly InteractionArgumentSyntax[] | null {\n if (context.data.length !== 1 || !context.data[0].type.isCollection) return null;\n const result = [...authored];\n const properties = this.properties(context);\n for (const input of this.command(command, context).filter(input => !input.isGenerated)) {\n if (result.some(argument => argument.name === input.name)) continue;\n const matches = properties.filter(property => property.name.toLowerCase() === input.name.toLowerCase());\n if (!this.legacyMatchIsSafe(input, properties, matches.length)) return null;\n if (matches.length === 1) result.push({ kind: 'InteractionArgumentSyntax', name: input.name, binding: `item.${matches[0].name}`, location: context.location });\n }\n return result;\n }\n\n private legacyMatchIsSafe(input: PropertySyntax, properties: readonly PropertySyntax[], matches: number): boolean {\n if (matches > 1) return false;\n return matches > 0 || this.keys(input, properties).length === 0;\n }\n\n inputs(command: string, authored: readonly InteractionArgumentSyntax[], context: ActionSubjectContext): readonly InteractionArgumentSyntax[] {\n const result = [...authored];\n if (context.data.length !== 1) return result;\n const properties = this.properties(context);\n for (const input of this.command(command, context).filter(input => !input.isGenerated)) {\n if (result.some(argument => argument.name === input.name)) continue;\n const property = this.binding(input, properties);\n if (property !== null) result.push({ kind: 'InteractionArgumentSyntax', name: input.name, binding: `item.${property.name}`, location: context.location });\n else if (this.keys(input, properties).length > 1) this.diagnostics.push({ severity: 'warning', code: DiagnosticCodes.AmbiguousActionInputBinding, message: `Input '${input.name}' of action '${command}' matches several declared key fields - write an explicit binding`, location: context.location });\n }\n return result;\n }\n}\n"],"mappings":"A,yHAiBA,IAAa,oBAAb,KAAiC,CACR,aAA4C,YAAjE,YAAY,EAA4C,EAAoC,CAAvE,KAAA,aAAAA,EAA4C,KAAA,YAAAC,CAA4B,CAE7F,WAAW,EAA0D,CACjE,OAAOC,EAAQ,KAAK,SAAW,EAAI,KAAK,aAAa,QAAQA,EAAQ,KAAK,EAAE,CAAC,KAAK,KAAMA,EAAQ,MAAO,GAASC,EAAM,UAAU,CAAC,EAAE,KAAK,YAAc,CAAC,EAAI,CAAC,CAChK,CAEA,QAAQ,EAAc,EAA0D,CAC5E,OAAO,KAAK,aAAa,QAAQC,EAAMF,EAAQ,MAAO,GAASC,EAAM,QAAQ,CAAC,EAAE,KAAK,YAAc,CAAC,CACxG,CAEA,YAAY,EAAuB,EAA8B,CAC7D,MAAO,CAACE,EAAI,KAAK,cAAgB,CAACA,EAAI,KAAK,YAAcC,EAAM,KAAK,OAASD,EAAI,KAAK,MAAQ,KAAK,aAAa,YAAY,SAAS,OAAO,GAAWE,EAAQ,OAASD,EAAM,KAAK,IAAI,CAAC,CAAC,SAAW,CACxM,CAEA,SAAS,EAAgC,CACrC,OAAOA,EAAM,cAAgB,CAACA,EAAM,aAAe,CAACA,EAAM,KAAK,YAAc,CAACA,EAAM,KAAK,YAC7F,CAEA,KAAK,EAAuB,EAAkE,CAC1F,OAAO,KAAK,SAAS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