@archivist-gg/dnd5e 0.3.17 → 0.3.24

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 (439) hide show
  1. package/LICENSE +48 -21
  2. package/README.md +26 -48
  3. package/dist/armor/armor.codec.d.ts +0 -7
  4. package/dist/armor/armor.codec.js +1 -9
  5. package/dist/armor/armor.parser.js +1 -8
  6. package/dist/armor/armor.schema.js +1 -7
  7. package/dist/armor/armor.types.d.ts +0 -3
  8. package/dist/background/background.codec.d.ts +0 -6
  9. package/dist/background/background.codec.js +1 -12
  10. package/dist/background/background.parser.js +1 -11
  11. package/dist/background/background.schema.js +1 -12
  12. package/dist/background/background.types.d.ts +0 -5
  13. package/dist/chunk-2EOGK6R6.js +1 -0
  14. package/dist/chunk-2HRRH3WL.js +1 -0
  15. package/dist/chunk-2LCGKNVM.js +1 -0
  16. package/dist/chunk-2NUDWOFG.js +1 -0
  17. package/dist/chunk-334WLI7V.js +1 -0
  18. package/dist/chunk-3LWOVRLA.js +1 -0
  19. package/dist/chunk-3QQOATV3.js +1 -0
  20. package/dist/chunk-4E2GIWJE.js +1 -0
  21. package/dist/chunk-4GN3GYMP.js +1 -0
  22. package/dist/chunk-4IAMSRHD.js +1 -0
  23. package/dist/chunk-4JEF3CET.js +1 -0
  24. package/dist/chunk-4KVVAENP.js +1 -0
  25. package/dist/chunk-56JK6VCL.js +1 -0
  26. package/dist/chunk-5FEXHY4U.js +1 -0
  27. package/dist/chunk-63YJPWTM.js +1 -0
  28. package/dist/chunk-6ASJ3MVB.js +1 -0
  29. package/dist/chunk-6IC53O3Q.js +1 -0
  30. package/dist/chunk-6LCNV26D.js +1 -0
  31. package/dist/chunk-6W253VHH.js +1 -0
  32. package/dist/chunk-7AKJBRBD.js +1 -0
  33. package/dist/chunk-7EL3GWWJ.js +1 -0
  34. package/dist/chunk-7FPQJDFD.js +1 -0
  35. package/dist/chunk-7J5BNH2D.js +1 -0
  36. package/dist/chunk-7LPKI27J.js +1 -0
  37. package/dist/chunk-7UPYRKMF.js +1 -0
  38. package/dist/chunk-A7H6LX47.js +1 -0
  39. package/dist/chunk-AINRPPLH.js +1 -0
  40. package/dist/chunk-BC52J4LA.js +1 -0
  41. package/dist/chunk-BCXGB4HP.js +1 -0
  42. package/dist/chunk-BGX36NPE.js +1 -0
  43. package/dist/chunk-BPKG6RZ7.js +1 -0
  44. package/dist/chunk-BREHZNTL.js +1 -0
  45. package/dist/chunk-BZ6BGGZS.js +1 -0
  46. package/dist/chunk-CAPYNIGK.js +1 -0
  47. package/dist/chunk-CCFIINBA.js +1 -0
  48. package/dist/chunk-CMIEZQL4.js +1 -0
  49. package/dist/chunk-DVUXUIPV.js +1 -0
  50. package/dist/chunk-DY6FVAGA.js +1 -0
  51. package/dist/chunk-DZITM5AG.js +1 -0
  52. package/dist/chunk-DZKSXSJF.js +1 -0
  53. package/dist/chunk-EAARMPCW.js +1 -0
  54. package/dist/chunk-EVT7MGAC.js +1 -0
  55. package/dist/chunk-FOLHTMSC.js +1 -0
  56. package/dist/chunk-GCYUCIDN.js +1 -0
  57. package/dist/chunk-GIOV6JW7.js +1 -0
  58. package/dist/chunk-HCK6IUB3.js +1 -0
  59. package/dist/chunk-HR5MKCP2.js +1 -0
  60. package/dist/chunk-I26FHSI6.js +1 -0
  61. package/dist/chunk-I4O2FIDT.js +1 -0
  62. package/dist/chunk-IGVRLGLM.js +1 -0
  63. package/dist/chunk-IHPLT2ZT.js +1 -0
  64. package/dist/chunk-IOCJIWCV.js +1 -0
  65. package/dist/chunk-JXDX2DKF.js +1 -0
  66. package/dist/chunk-KBFSJ5WE.js +1 -0
  67. package/dist/chunk-KM75CC6Q.js +1 -0
  68. package/dist/chunk-KZDDFG4O.js +1 -0
  69. package/dist/chunk-LJNT3PJP.js +1 -0
  70. package/dist/chunk-LR6UMA5V.js +1 -0
  71. package/dist/chunk-M6RPOLKS.js +1 -0
  72. package/dist/chunk-MC6PLWRZ.js +1 -0
  73. package/dist/chunk-MGGKZGLG.js +1 -0
  74. package/dist/chunk-N3RYJ7RE.js +1 -0
  75. package/dist/chunk-NEMX7QGG.js +1 -0
  76. package/dist/chunk-NI364WV7.js +1 -0
  77. package/dist/chunk-O2QZ73GA.js +1 -0
  78. package/dist/chunk-O776WL7O.js +1 -0
  79. package/dist/chunk-OTFNINUY.js +1 -0
  80. package/dist/chunk-PQAVMK3T.js +1 -0
  81. package/dist/chunk-PZ3ZZ5H5.js +1 -0
  82. package/dist/chunk-PZ4L2EEG.js +1 -0
  83. package/dist/chunk-PZUPZBTN.js +1 -0
  84. package/dist/chunk-QBA757AU.js +1 -0
  85. package/dist/chunk-QFIGPOFW.js +1 -0
  86. package/dist/chunk-QMEKQTUT.js +1 -0
  87. package/dist/chunk-QVWT67WA.js +1 -0
  88. package/dist/chunk-RDXQAZBA.js +1 -0
  89. package/dist/chunk-RE5Z5RNK.js +1 -0
  90. package/dist/chunk-RL4VY2AL.js +1 -0
  91. package/dist/chunk-RQGTBHJW.js +1 -0
  92. package/dist/chunk-RQZCGXUZ.js +1 -0
  93. package/dist/chunk-S5UCI27C.js +1 -0
  94. package/dist/chunk-SEOASDO4.js +1 -0
  95. package/dist/chunk-SU4MEZ5P.js +1 -0
  96. package/dist/chunk-T55DELVL.js +1 -0
  97. package/dist/chunk-TKIEPC6F.js +1 -0
  98. package/dist/chunk-TLXFGGWH.js +1 -0
  99. package/dist/chunk-UBUKCRZ3.js +1 -0
  100. package/dist/chunk-V6NQ547U.js +1 -0
  101. package/dist/chunk-VA3ZWV7C.js +1 -0
  102. package/dist/chunk-VIP3FH2O.js +1 -0
  103. package/dist/chunk-VTQ4RWEG.js +1 -0
  104. package/dist/chunk-WUHTSLG4.js +1 -0
  105. package/dist/chunk-X22SISGM.js +1 -0
  106. package/dist/chunk-XKJXT2PN.js +1 -0
  107. package/dist/chunk-XQMKH4R4.js +1 -0
  108. package/dist/chunk-YGH7S5ZF.js +1 -0
  109. package/dist/chunk-ZE46ADXS.js +1 -0
  110. package/dist/chunk-ZI3FEUX3.js +1 -0
  111. package/dist/class/class.codec.d.ts +0 -7
  112. package/dist/class/class.codec.js +1 -18
  113. package/dist/class/class.parser.js +1 -17
  114. package/dist/class/class.schema.d.ts +2 -1
  115. package/dist/class/class.schema.js +1 -15
  116. package/dist/class/class.slug.d.ts +0 -11
  117. package/dist/class/class.slug.js +1 -8
  118. package/dist/class/class.standard-array.d.ts +0 -7
  119. package/dist/class/class.standard-array.js +1 -20
  120. package/dist/class/class.types.d.ts +0 -20
  121. package/dist/condition/condition.codec.d.ts +0 -6
  122. package/dist/condition/condition.parser.d.ts +0 -10
  123. package/dist/condition/condition.parser.js +1 -7
  124. package/dist/condition/condition.schema.d.ts +0 -16
  125. package/dist/condition/condition.types.d.ts +0 -3
  126. package/dist/data-srd/index.generated.js +1 -146
  127. package/dist/dnd/amount-text.d.ts +4 -27
  128. package/dist/dnd/amount-text.js +1 -13
  129. package/dist/dnd/constants.d.ts +0 -18
  130. package/dist/dnd/constants.js +1 -42
  131. package/dist/dnd/formula-tags.d.ts +0 -2
  132. package/dist/dnd/formula-tags.js +1 -119
  133. package/dist/dnd/math.d.ts +0 -26
  134. package/dist/dnd/math.js +1 -45
  135. package/dist/dnd/prose-tags.d.ts +1 -15
  136. package/dist/dnd/prose-tags.js +1 -18
  137. package/dist/dnd/resource-die.d.ts +0 -4
  138. package/dist/dnd/resource-die.js +1 -17
  139. package/dist/dnd/resource-formula.d.ts +0 -43
  140. package/dist/dnd/resource-formula.js +1 -14
  141. package/dist/dnd/resource-words.d.ts +0 -2
  142. package/dist/dnd/resource-words.js +1 -30
  143. package/dist/dnd/srd-tag-converter.d.ts +0 -21
  144. package/dist/dnd/srd-tag-converter.js +1 -12
  145. package/dist/dnd/tag-grammar.js +1 -12
  146. package/dist/dnd/warn-once.js +1 -8
  147. package/dist/encounter/encounter.ai-schema.js +1 -8
  148. package/dist/entities/base-item-resolver.d.ts +0 -26
  149. package/dist/entities/base-item-resolver.js +1 -11
  150. package/dist/entities/registry-revision.d.ts +10 -0
  151. package/dist/entities/registry-revision.js +1 -0
  152. package/dist/entities/slug.d.ts +1 -31
  153. package/dist/entities/slug.js +1 -12
  154. package/dist/entities/wikilink-display.d.ts +0 -2
  155. package/dist/entities/wikilink-display.js +1 -10
  156. package/dist/feat/feat.category-codes.d.ts +1 -26
  157. package/dist/feat/feat.category-codes.js +1 -14
  158. package/dist/feat/feat.codec.d.ts +0 -6
  159. package/dist/feat/feat.codec.js +1 -12
  160. package/dist/feat/feat.parser.js +1 -11
  161. package/dist/feat/feat.schema.d.ts +31 -1
  162. package/dist/feat/feat.schema.js +1 -10
  163. package/dist/feat/feat.types.d.ts +0 -6
  164. package/dist/index.js +45 -138113
  165. package/dist/inline-tag-parser.js +1 -6
  166. package/dist/item/item.actions-map.d.ts +4 -63
  167. package/dist/item/item.actions-map.js +1 -10
  168. package/dist/item/item.ai-schema.js +1 -6
  169. package/dist/item/item.attunement.d.ts +0 -14
  170. package/dist/item/item.attunement.js +1 -6
  171. package/dist/item/item.bonuses.js +1 -10
  172. package/dist/item/item.codec.js +1 -9
  173. package/dist/item/item.conditions.d.ts +0 -7
  174. package/dist/item/item.conditions.js +1 -11
  175. package/dist/item/item.conditions.types.d.ts +0 -2
  176. package/dist/item/item.cost.js +1 -29
  177. package/dist/item/item.enrichment.js +1 -9
  178. package/dist/item/item.icon.d.ts +0 -8
  179. package/dist/item/item.icon.js +1 -211
  180. package/dist/item/item.parser.js +1 -8
  181. package/dist/item/item.schema.d.ts +2 -0
  182. package/dist/item/item.schema.js +1 -11
  183. package/dist/item/item.types.d.ts +2 -28
  184. package/dist/monster/monster.ai-schema.js +1 -6
  185. package/dist/monster/monster.codec.d.ts +0 -10
  186. package/dist/monster/monster.enrichment.js +1 -19
  187. package/dist/monster/monster.format.d.ts +0 -69
  188. package/dist/monster/monster.format.js +1 -78
  189. package/dist/monster/monster.parser.d.ts +0 -4
  190. package/dist/monster/monster.parser.js +1 -15
  191. package/dist/monster/monster.resolve.d.ts +0 -4
  192. package/dist/monster/monster.schema.d.ts +0 -9
  193. package/dist/monster/monster.schema.js +1 -34
  194. package/dist/monster/monster.types.d.ts +0 -3
  195. package/dist/monster/monster.types.js +1 -1
  196. package/dist/optional-feature/optional-feature.codec.d.ts +0 -11
  197. package/dist/optional-feature/optional-feature.codec.js +1 -13
  198. package/dist/optional-feature/optional-feature.parser.js +1 -12
  199. package/dist/optional-feature/optional-feature.schema.d.ts +30 -1
  200. package/dist/optional-feature/optional-feature.schema.js +1 -15
  201. package/dist/pack.d.ts +0 -9
  202. package/dist/pc/conditions.constants.js +1 -6
  203. package/dist/pc/decision-recognizer.js +1 -8
  204. package/dist/pc/pc.additional-spells.d.ts +4 -14
  205. package/dist/pc/pc.additional-spells.js +1 -23
  206. package/dist/pc/pc.amount-bindings.d.ts +4 -20
  207. package/dist/pc/pc.amount-bindings.js +1 -23
  208. package/dist/pc/pc.asi-flatten.d.ts +0 -59
  209. package/dist/pc/pc.asi-flatten.js +1 -16
  210. package/dist/pc/pc.conditions.d.ts +1 -0
  211. package/dist/pc/pc.conditions.js +1 -6
  212. package/dist/pc/pc.containment.d.ts +0 -5
  213. package/dist/pc/pc.containment.js +1 -24
  214. package/dist/pc/pc.decision-engine.d.ts +4 -141
  215. package/dist/pc/pc.decision-engine.js +1 -52
  216. package/dist/pc/pc.defense-normalize.d.ts +0 -10
  217. package/dist/pc/pc.defense-normalize.js +1 -6
  218. package/dist/pc/pc.entry-overrides.d.ts +0 -58
  219. package/dist/pc/pc.entry-overrides.js +1 -40
  220. package/dist/pc/pc.equipment.d.ts +2 -22
  221. package/dist/pc/pc.equipment.js +1 -33
  222. package/dist/pc/pc.feature-effects.d.ts +23 -275
  223. package/dist/pc/pc.feature-effects.js +1 -26
  224. package/dist/pc/pc.formula-context.js +1 -11
  225. package/dist/pc/pc.infusions.d.ts +0 -65
  226. package/dist/pc/pc.infusions.js +1 -64
  227. package/dist/pc/pc.item-effects.d.ts +18 -0
  228. package/dist/pc/pc.member-choices.d.ts +18 -49
  229. package/dist/pc/pc.member-choices.js +1 -32
  230. package/dist/pc/pc.parser.js +1 -58
  231. package/dist/pc/pc.pools.d.ts +7 -10
  232. package/dist/pc/pc.pools.js +1 -26
  233. package/dist/pc/pc.proficiencies.d.ts +7 -33
  234. package/dist/pc/pc.proficiencies.js +1 -107
  235. package/dist/pc/pc.proficiency-grants.d.ts +0 -26
  236. package/dist/pc/pc.proficiency-normalize.d.ts +4 -25
  237. package/dist/pc/pc.proficiency-normalize.js +1 -12
  238. package/dist/pc/pc.proficiency-query.d.ts +0 -13
  239. package/dist/pc/pc.proficiency-query.js +1 -27
  240. package/dist/pc/pc.recalc.d.ts +7 -131
  241. package/dist/pc/pc.recalc.js +1 -946
  242. package/dist/pc/pc.resolver.d.ts +0 -104
  243. package/dist/pc/pc.resolver.js +1 -59
  244. package/dist/pc/pc.resource-seed.d.ts +0 -8
  245. package/dist/pc/pc.resource-seed.js +1 -42
  246. package/dist/pc/pc.resources.d.ts +1 -59
  247. package/dist/pc/pc.resources.js +1 -23
  248. package/dist/pc/pc.rest.d.ts +1 -20
  249. package/dist/pc/pc.rest.js +1 -230
  250. package/dist/pc/pc.schema.d.ts +19 -2
  251. package/dist/pc/pc.schema.js +1 -9
  252. package/dist/pc/pc.slotting.d.ts +0 -29
  253. package/dist/pc/pc.slotting.js +1 -28
  254. package/dist/pc/pc.speeds.d.ts +19 -0
  255. package/dist/pc/pc.spell-scope.d.ts +6 -0
  256. package/dist/pc/pc.spellcasting.d.ts +0 -70
  257. package/dist/pc/pc.spellcasting.js +1 -28
  258. package/dist/pc/pc.table-column.d.ts +0 -22
  259. package/dist/pc/pc.table-column.js +1 -18
  260. package/dist/pc/pc.tool-picks.d.ts +0 -27
  261. package/dist/pc/pc.tool-picks.js +1 -18
  262. package/dist/pc/pc.types.d.ts +85 -344
  263. package/dist/pc/pc.weapon-grant.d.ts +0 -6
  264. package/dist/pc/pool-layout.d.ts +0 -39
  265. package/dist/pc/pool-layout.js +1 -18
  266. package/dist/pc/resource-equivalents.d.ts +2 -40
  267. package/dist/pc/roll-scope.js +1 -8
  268. package/dist/pc/roll-tag-labels.d.ts +0 -32
  269. package/dist/pc/roll-tag-labels.js +1 -17
  270. package/dist/pc/spell-source.d.ts +0 -11
  271. package/dist/pc/spell-source.js +1 -8
  272. package/dist/race/race.codec.d.ts +0 -6
  273. package/dist/race/race.codec.js +1 -15
  274. package/dist/race/race.parser.js +1 -14
  275. package/dist/race/race.schema.d.ts +0 -8
  276. package/dist/race/race.schema.js +1 -14
  277. package/dist/race/race.structural.d.ts +0 -6
  278. package/dist/race/race.structural.js +1 -6
  279. package/dist/race/race.types.d.ts +0 -8
  280. package/dist/schemas/attack-schema.d.ts +5 -0
  281. package/dist/schemas/caster-type-schema.d.ts +1 -6
  282. package/dist/schemas/caster-type-schema.js +1 -6
  283. package/dist/schemas/choice-schema.js +1 -7
  284. package/dist/schemas/duration-schema.d.ts +0 -2
  285. package/dist/schemas/duration-schema.js +1 -6
  286. package/dist/schemas/entity-extras-schema.d.ts +0 -30
  287. package/dist/schemas/entity-extras-schema.js +1 -10
  288. package/dist/schemas/equipment-grant-schema.d.ts +0 -2
  289. package/dist/schemas/equipment-grant-schema.js +1 -12
  290. package/dist/schemas/feature-alias.d.ts +0 -27
  291. package/dist/schemas/feature-effect-schema.d.ts +30 -1
  292. package/dist/schemas/feature-effect-schema.js +1 -6
  293. package/dist/schemas/feature-schema.d.ts +0 -6
  294. package/dist/schemas/feature-schema.js +1 -12
  295. package/dist/schemas/resource-schema.d.ts +1 -34
  296. package/dist/schemas/resource-schema.js +1 -12
  297. package/dist/schemas/selection-pool-schema.js +1 -10
  298. package/dist/spell/casting-time.d.ts +0 -15
  299. package/dist/spell/casting-time.js +1 -6
  300. package/dist/spell/spell.access.d.ts +0 -6
  301. package/dist/spell/spell.access.js +1 -45
  302. package/dist/spell/spell.ai-schema.js +1 -6
  303. package/dist/spell/spell.codec.js +1 -9
  304. package/dist/spell/spell.enrichment.js +1 -9
  305. package/dist/spell/spell.filter.d.ts +0 -5
  306. package/dist/spell/spell.filter.js +1 -75
  307. package/dist/spell/spell.parser.d.ts +0 -31
  308. package/dist/spell/spell.parser.js +1 -16
  309. package/dist/spell/spell.scaling.d.ts +0 -46
  310. package/dist/spell/spell.scaling.js +1 -79
  311. package/dist/spell/spell.schema.js +1 -7
  312. package/dist/spell/spell.types.d.ts +0 -7
  313. package/dist/srd/retired-items.d.ts +0 -4
  314. package/dist/srd/retired-items.js +1 -11
  315. package/dist/srd-store.d.ts +0 -33
  316. package/dist/subclass/subclass.codec.d.ts +0 -8
  317. package/dist/subclass/subclass.codec.js +1 -17
  318. package/dist/subclass/subclass.parser.js +1 -16
  319. package/dist/subclass/subclass.schema.d.ts +2 -1
  320. package/dist/subclass/subclass.schema.js +1 -14
  321. package/dist/subclass/subclass.types.d.ts +0 -3
  322. package/dist/types/attack.d.ts +2 -0
  323. package/dist/types/casting-option.d.ts +0 -4
  324. package/dist/types/choice.d.ts +1 -72
  325. package/dist/types/choice.js +1 -24
  326. package/dist/types/edition.d.ts +0 -3
  327. package/dist/types/equipment-grant.d.ts +1 -27
  328. package/dist/types/equipment-grant.js +1 -12
  329. package/dist/types/feature-effect.d.ts +14 -14
  330. package/dist/types/feature.d.ts +0 -22
  331. package/dist/types/optional-feature.types.d.ts +1 -31
  332. package/dist/types/resource.d.ts +1 -21
  333. package/dist/types/selection-pool.d.ts +0 -24
  334. package/dist/weapon/weapon-mastery.d.ts +0 -1
  335. package/dist/weapon/weapon.classify.d.ts +0 -11
  336. package/dist/weapon/weapon.classify.js +1 -7
  337. package/dist/weapon/weapon.codec.d.ts +0 -9
  338. package/dist/weapon/weapon.codec.js +1 -9
  339. package/dist/weapon/weapon.parser.js +1 -8
  340. package/dist/weapon/weapon.schema.js +1 -7
  341. package/dist/weapon/weapon.types.d.ts +0 -3
  342. package/package.json +3 -3
  343. package/src/data-srd/ATTRIBUTION.md +1 -1
  344. package/dist/chunk-2FRUSVZS.js +0 -489
  345. package/dist/chunk-2JSQE3DD.js +0 -206
  346. package/dist/chunk-2LULMQTF.js +0 -14
  347. package/dist/chunk-2UDSN6VW.js +0 -18
  348. package/dist/chunk-3LWMFYKS.js +0 -57
  349. package/dist/chunk-3MGQFFNE.js +0 -110
  350. package/dist/chunk-3TM34RSJ.js +0 -23
  351. package/dist/chunk-3VZZDKRA.js +0 -1014
  352. package/dist/chunk-4U55VNC7.js +0 -22
  353. package/dist/chunk-5GKJAUMX.js +0 -59
  354. package/dist/chunk-5MXFW4O3.js +0 -71
  355. package/dist/chunk-656QCX4U.js +0 -22
  356. package/dist/chunk-6EI737IO.js +0 -19
  357. package/dist/chunk-6GNXYAYP.js +0 -25
  358. package/dist/chunk-6PXTNCBP.js +0 -133
  359. package/dist/chunk-6X2NV665.js +0 -33
  360. package/dist/chunk-7ATNGKBS.js +0 -178
  361. package/dist/chunk-7Q2VPKCD.js +0 -181
  362. package/dist/chunk-7QN7XSAK.js +0 -19
  363. package/dist/chunk-A54HHCWW.js +0 -67
  364. package/dist/chunk-AZRGFUSR.js +0 -18
  365. package/dist/chunk-B3DP42OM.js +0 -55
  366. package/dist/chunk-CJYCVNW2.js +0 -7
  367. package/dist/chunk-CM5CWO4K.js +0 -735
  368. package/dist/chunk-DEEHHLAP.js +0 -271
  369. package/dist/chunk-DOXSFYLH.js +0 -158
  370. package/dist/chunk-DPUJDOKV.js +0 -365
  371. package/dist/chunk-EJP263OP.js +0 -186
  372. package/dist/chunk-EVMUJYUD.js +0 -195
  373. package/dist/chunk-EYX4JMAU.js +0 -101
  374. package/dist/chunk-FANQVQ3D.js +0 -89
  375. package/dist/chunk-FC4IGH5Y.js +0 -18
  376. package/dist/chunk-G6MHJDVT.js +0 -41
  377. package/dist/chunk-G6PBI2BU.js +0 -18
  378. package/dist/chunk-H5PTKYXL.js +0 -101
  379. package/dist/chunk-HHBD4SQ6.js +0 -24
  380. package/dist/chunk-HS6FIOLP.js +0 -52
  381. package/dist/chunk-HTYMW5CH.js +0 -228
  382. package/dist/chunk-IHE6KVC3.js +0 -13
  383. package/dist/chunk-IN4M4X7P.js +0 -34
  384. package/dist/chunk-IUAAXXNO.js +0 -58
  385. package/dist/chunk-JCMUVZIK.js +0 -133
  386. package/dist/chunk-JSM6JFZR.js +0 -709
  387. package/dist/chunk-K5NJBTE2.js +0 -18
  388. package/dist/chunk-KR6JF3BF.js +0 -14
  389. package/dist/chunk-KSTV7J2U.js +0 -112
  390. package/dist/chunk-KU3YLF6D.js +0 -106
  391. package/dist/chunk-LBEXLN6I.js +0 -91
  392. package/dist/chunk-LF5AGJA4.js +0 -81
  393. package/dist/chunk-LHZXYFBU.js +0 -94
  394. package/dist/chunk-LSLSG67V.js +0 -31
  395. package/dist/chunk-LVQLWRCU.js +0 -15
  396. package/dist/chunk-MBX25B6D.js +0 -18
  397. package/dist/chunk-MYY2C5MB.js +0 -233
  398. package/dist/chunk-OFCSP6MT.js +0 -23
  399. package/dist/chunk-ONTGZR5T.js +0 -1806
  400. package/dist/chunk-OOSRUJBI.js +0 -19
  401. package/dist/chunk-PDJSUH24.js +0 -110
  402. package/dist/chunk-PKX6TGRE.js +0 -93
  403. package/dist/chunk-PQZ4LM4Z.js +0 -19
  404. package/dist/chunk-PTXBIDG7.js +0 -63
  405. package/dist/chunk-PVCEA4HZ.js +0 -6
  406. package/dist/chunk-PXVNAY7T.js +0 -84
  407. package/dist/chunk-QH36K2PU.js +0 -158
  408. package/dist/chunk-QS5L5YTJ.js +0 -24
  409. package/dist/chunk-QYZV2MQA.js +0 -97
  410. package/dist/chunk-QZSWN2KT.js +0 -18
  411. package/dist/chunk-RLGQ5PZZ.js +0 -16
  412. package/dist/chunk-RYLXAYIQ.js +0 -18
  413. package/dist/chunk-S3YUXDSC.js +0 -278
  414. package/dist/chunk-S7REMWW4.js +0 -21
  415. package/dist/chunk-T6QIF5XR.js +0 -348
  416. package/dist/chunk-TOM66P2P.js +0 -38
  417. package/dist/chunk-TULQ4FFX.js +0 -353
  418. package/dist/chunk-UA5KS2PL.js +0 -26
  419. package/dist/chunk-UUBJCNQU.js +0 -187
  420. package/dist/chunk-UZXG6QSY.js +0 -58
  421. package/dist/chunk-VPYBK2MG.js +0 -18
  422. package/dist/chunk-VRV3NNTA.js +0 -161
  423. package/dist/chunk-VTTA2ALZ.js +0 -16
  424. package/dist/chunk-W6GC6OKK.js +0 -16
  425. package/dist/chunk-WELIKLZF.js +0 -256
  426. package/dist/chunk-WSVMLNTO.js +0 -31
  427. package/dist/chunk-WYGD2UGN.js +0 -14
  428. package/dist/chunk-XCFC7LGF.js +0 -122
  429. package/dist/chunk-XJ2F2WO6.js +0 -8
  430. package/dist/chunk-Y5VVP73C.js +0 -23
  431. package/dist/chunk-YBLDE5CG.js +0 -42
  432. package/dist/chunk-YD2VAHA6.js +0 -159
  433. package/dist/chunk-YDGMBMYI.js +0 -25
  434. package/dist/chunk-YHYTW5QA.js +0 -20
  435. package/dist/chunk-YKL6SHRJ.js +0 -23
  436. package/dist/chunk-ZCTUYGNV.js +0 -26
  437. package/dist/chunk-ZDAEGJH4.js +0 -102
  438. package/dist/chunk-ZJXSXVFP.js +0 -58
  439. package/dist/chunk-ZUQW5VBZ.js +0 -89
@@ -1,1806 +0,0 @@
1
- import {
2
- equipmentCategoryKey,
3
- isCategoryGrant
4
- } from "./chunk-2LULMQTF.js";
5
- import {
6
- TOOL_CATEGORIES,
7
- backgroundToolPicks,
8
- categoryWords,
9
- classToolPicks,
10
- expandToolPool,
11
- toolCategoriesOf
12
- } from "./chunk-H5PTKYXL.js";
13
- import {
14
- assembleEffectFeatures,
15
- collectProficiencyEffectGrants
16
- } from "./chunk-TULQ4FFX.js";
17
- import {
18
- ALL_LANGUAGES,
19
- ALL_SKILL_SLUGS,
20
- ALL_TOOLS
21
- } from "./chunk-KU3YLF6D.js";
22
- import {
23
- featOfSite,
24
- featPickSites,
25
- isTargetChoice,
26
- memberChoices,
27
- poolMemberSites,
28
- poolMemberSitesOf
29
- } from "./chunk-HTYMW5CH.js";
30
- import {
31
- resolveFeatureResources,
32
- resolveResourceIndex
33
- } from "./chunk-KSTV7J2U.js";
34
- import {
35
- attributeUnclassedSpell,
36
- effectiveSpellcastingAbility,
37
- normalizeKnownSpell,
38
- resolveSpellcasting
39
- } from "./chunk-DPUJDOKV.js";
40
- import {
41
- convertibleLegacyAsi,
42
- flattenAsiOrFeat,
43
- resolveLegacyAsiFeat
44
- } from "./chunk-LBEXLN6I.js";
45
- import {
46
- humanizeProficiency,
47
- proficiencyLabel,
48
- toProfSlug
49
- } from "./chunk-RLGQ5PZZ.js";
50
- import {
51
- bindFeatureConsumers,
52
- buildInfusionContext,
53
- resolveAllPools,
54
- resolveOptionRows,
55
- strandedPicks
56
- } from "./chunk-3VZZDKRA.js";
57
- import {
58
- countColumnsFor,
59
- readTableColumn
60
- } from "./chunk-IUAAXXNO.js";
61
- import {
62
- recognizeDecision
63
- } from "./chunk-YHYTW5QA.js";
64
- import {
65
- collectAdditionalSpells
66
- } from "./chunk-VRV3NNTA.js";
67
- import {
68
- isItemEntity,
69
- resolveEntityForEntry
70
- } from "./chunk-LHZXYFBU.js";
71
- import {
72
- FEATURE_TYPE_FOR_CATEGORY,
73
- featProgressionCategory
74
- } from "./chunk-YBLDE5CG.js";
75
- import {
76
- warnOnce
77
- } from "./chunk-LVQLWRCU.js";
78
- import {
79
- isValidMaxFormula
80
- } from "./chunk-EVMUJYUD.js";
81
- import {
82
- bareEntitySlug,
83
- wikilinkTailSlug
84
- } from "./chunk-ZCTUYGNV.js";
85
- import {
86
- mirrorSpellShapes
87
- } from "./chunk-7Q2VPKCD.js";
88
- import {
89
- ABILITY_KEYS
90
- } from "./chunk-WELIKLZF.js";
91
- import {
92
- withResolvedActionCost
93
- } from "./chunk-4U55VNC7.js";
94
-
95
- // src/pc/pc.proficiency-grants.ts
96
- var UNKNOWN_SOURCE = "Unknown";
97
- function collectProficiencyGrants(resolved) {
98
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
99
- const classArmor = [];
100
- const classWeaponFixed = [];
101
- const classWeaponCategories = [];
102
- const classToolFixed = [];
103
- for (const c of resolved.classes) {
104
- const prof = (_a = c.entity) == null ? void 0 : _a.proficiencies;
105
- if (!prof) continue;
106
- const source = (_c = (_b = c.entity) == null ? void 0 : _b.name) != null ? _c : UNKNOWN_SOURCE;
107
- for (const a of (_d = prof.armor) != null ? _d : []) classArmor.push({ value: a, source });
108
- for (const w of (_f = (_e = prof.weapons) == null ? void 0 : _e.fixed) != null ? _f : []) classWeaponFixed.push({ value: w, source });
109
- for (const w of (_h = (_g = prof.weapons) == null ? void 0 : _g.categories) != null ? _h : []) classWeaponCategories.push({ value: w, source });
110
- for (const t of (_j = (_i = prof.tools) == null ? void 0 : _i.fixed) != null ? _j : []) classToolFixed.push({ value: t, source });
111
- for (const t of classToolPicks(c.entity).grants) classToolFixed.push({ value: t, source });
112
- }
113
- const raceSource = (_l = (_k = resolved.race) == null ? void 0 : _k.name) != null ? _l : UNKNOWN_SOURCE;
114
- const raceLangFixed = ((_o = (_n = (_m = resolved.race) == null ? void 0 : _m.languages) == null ? void 0 : _n.fixed) != null ? _o : []).map(
115
- (l) => ({ value: l, source: raceSource })
116
- );
117
- const bgToolFixed = [];
118
- const bgLangFixed = [];
119
- const bg = resolved.background;
120
- if (bg) {
121
- const source = (_p = bg.name) != null ? _p : UNKNOWN_SOURCE;
122
- for (const entry of (_q = bg.tool_proficiencies) != null ? _q : []) {
123
- if (entry.kind === "fixed") {
124
- for (const t of entry.items) bgToolFixed.push({ value: t, source });
125
- }
126
- }
127
- for (const t of backgroundToolPicks(bg).grants) bgToolFixed.push({ value: t, source });
128
- for (const entry of (_r = bg.language_proficiencies) != null ? _r : []) {
129
- if (entry.kind === "fixed") {
130
- for (const l of entry.languages) bgLangFixed.push({ value: l, source });
131
- }
132
- }
133
- }
134
- const featArmor = [];
135
- const featWeapons = [];
136
- const featTools = [];
137
- const featLanguages = [];
138
- for (const f of (_s = resolved.feats) != null ? _s : []) {
139
- const featView = f;
140
- const grants = featView.proficiencies;
141
- if (!grants) continue;
142
- const source = (_t = f.name) != null ? _t : UNKNOWN_SOURCE;
143
- for (const a of (_u = grants.armor) != null ? _u : []) featArmor.push({ value: a, source });
144
- for (const w of (_v = grants.weapons) != null ? _v : []) featWeapons.push({ value: w, source });
145
- for (const t of (_w = grants.tools) != null ? _w : []) featTools.push({ value: t, source });
146
- for (const l of (_x = grants.languages) != null ? _x : []) featLanguages.push({ value: l, source });
147
- }
148
- const { features: effectFeatures, activeBuffs } = assembleEffectFeatures(resolved);
149
- const fx = collectProficiencyEffectGrants(effectFeatures, activeBuffs);
150
- const nameFor = (kind, slug) => {
151
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2;
152
- switch (kind) {
153
- case "class":
154
- return (_d2 = (_c2 = (_b2 = (_a2 = resolved.classes) == null ? void 0 : _a2.find((c) => {
155
- var _a3;
156
- return ((_a3 = c.entity) == null ? void 0 : _a3.slug) === slug;
157
- })) == null ? void 0 : _b2.entity) == null ? void 0 : _c2.name) != null ? _d2 : UNKNOWN_SOURCE;
158
- case "subclass":
159
- return (_h2 = (_g2 = (_f2 = (_e2 = resolved.classes) == null ? void 0 : _e2.find((c) => {
160
- var _a3;
161
- return ((_a3 = c.subclass) == null ? void 0 : _a3.slug) === slug;
162
- })) == null ? void 0 : _f2.subclass) == null ? void 0 : _g2.name) != null ? _h2 : UNKNOWN_SOURCE;
163
- case "race":
164
- return (_j2 = (_i2 = resolved.race) == null ? void 0 : _i2.name) != null ? _j2 : UNKNOWN_SOURCE;
165
- case "background":
166
- return (_l2 = (_k2 = resolved.background) == null ? void 0 : _k2.name) != null ? _l2 : UNKNOWN_SOURCE;
167
- case "feat":
168
- return (_o2 = (_n2 = (_m2 = resolved.feats) == null ? void 0 : _m2.find((f) => f.slug === slug)) == null ? void 0 : _n2.name) != null ? _o2 : UNKNOWN_SOURCE;
169
- default:
170
- return UNKNOWN_SOURCE;
171
- }
172
- };
173
- const toGrants = (list, useRaw) => list.map((g) => ({ value: useRaw ? g.raw : g.value, source: nameFor(g.sourceKind, g.sourceSlug), ...g.expertise ? { expertise: true } : {} }));
174
- const effectArmor = toGrants(fx.armor, true);
175
- const effectWeapons = toGrants(fx.weapons, true);
176
- const effectTools = toGrants(fx.tools, false);
177
- const effectLanguages = toGrants(fx.languages, false);
178
- return {
179
- classArmor,
180
- classWeaponFixed,
181
- classWeaponCategories,
182
- classToolFixed,
183
- raceLangFixed,
184
- bgToolFixed,
185
- bgLangFixed,
186
- featArmor,
187
- featWeapons,
188
- featTools,
189
- featLanguages,
190
- effectArmor,
191
- effectWeapons,
192
- effectTools,
193
- effectLanguages
194
- };
195
- }
196
-
197
- // src/pc/pc.decision-engine.ts
198
- var warnedDegradedEquipment = /* @__PURE__ */ new Set();
199
- var warnedAmbiguousBare = /* @__PURE__ */ new Set();
200
- var foldedTypeMemo = /* @__PURE__ */ new Map();
201
- function foldedType(s) {
202
- let v = foldedTypeMemo.get(s);
203
- if (v === void 0) {
204
- v = categoryWords(s).join(" ");
205
- foldedTypeMemo.set(s, v);
206
- }
207
- return v;
208
- }
209
- function matchesFilter(e, where, ownerBare) {
210
- var _a, _b, _c, _d, _e;
211
- const d = e.data;
212
- if (where.feature_type && d.feature_type !== where.feature_type) return false;
213
- if (where.category && d.category !== where.category) return false;
214
- if (where.list && !((_a = d.classes) != null ? _a : []).includes(where.list)) return false;
215
- if (where.level !== void 0 && ((_b = d.level) != null ? _b : 0) !== where.level) return false;
216
- if (where.edition && d.edition !== where.edition) return false;
217
- if (where.ritual && d.ritual !== true) return false;
218
- if (where.weapon_category) {
219
- const cat = ((_c = d.category) != null ? _c : "").toLowerCase();
220
- if (!cat.startsWith(`${where.weapon_category}-`) && cat !== where.weapon_category) return false;
221
- }
222
- if (where.armor_category) {
223
- if (((_d = d.category) != null ? _d : "").toLowerCase() !== where.armor_category) return false;
224
- }
225
- if (where.item_type) {
226
- const t = foldedType(typeof d.type === "string" ? d.type : "");
227
- if (!t || !where.item_type.some((x) => foldedType(x) === t)) return false;
228
- }
229
- if (where.mundane) {
230
- const r = typeof d.rarity === "string" ? d.rarity.trim().toLowerCase() : "";
231
- if (r && r !== "none" && r !== "mundane") return false;
232
- }
233
- if (where.parent_class === "self") {
234
- if (!d.parent_class || wikilinkTailSlug(d.parent_class) !== ownerBare) return false;
235
- }
236
- if (where.available_to === "self") {
237
- const list = (_e = d.available_to) != null ? _e : [];
238
- if (!list.some((l) => wikilinkTailSlug(l) === ownerBare)) return false;
239
- }
240
- return true;
241
- }
242
- var __matchesFilterForTest = matchesFilter;
243
- function parseEquipmentCategory(category) {
244
- const tools = toolCategoriesOf(category);
245
- if (tools) return { kind: "tool", tools };
246
- const words = categoryWords(category).filter((w) => w !== "any");
247
- const has = (w) => words.includes(w);
248
- const only = (allowed) => words.every((w) => allowed.includes(w));
249
- if (words.length === 1 && has("shield")) return { kind: "shield" };
250
- if (has("armor") && only(["armor", "light", "medium", "heavy"]) && words.length <= 2) {
251
- const armor = ["light", "medium", "heavy"].find((k) => has(k));
252
- return { kind: "armor", armor };
253
- }
254
- if (has("weapon") && only(["weapon", "simple", "martial", "melee", "ranged"])) {
255
- const klass = ["simple", "martial"].filter((k) => has(k));
256
- const range = ["melee", "ranged"].filter((k) => has(k));
257
- if (klass.length === 1 && range.length <= 1 && words.length === 2 + range.length) {
258
- return { kind: "weapon", weapon: klass[0], range: range[0] };
259
- }
260
- }
261
- return void 0;
262
- }
263
- function categoryToEntitySelect(category, id) {
264
- const spec = parseEquipmentCategory(category);
265
- const pick = { kind: "select-entity", id, count: 1 };
266
- switch (spec == null ? void 0 : spec.kind) {
267
- case "shield":
268
- return { ...pick, label: "Choose a shield", entity_type: "armor", where: { armor_category: "shield" } };
269
- case "armor":
270
- return spec.armor ? { ...pick, label: `Choose ${spec.armor} armor`, entity_type: "armor", where: { armor_category: spec.armor } } : { ...pick, label: "Choose armor", entity_type: "armor" };
271
- case "weapon":
272
- return {
273
- ...pick,
274
- label: `Choose a ${spec.weapon}${spec.range ? ` ${spec.range}` : ""} weapon`,
275
- entity_type: "weapon",
276
- where: { weapon_category: spec.weapon }
277
- };
278
- case "tool":
279
- return {
280
- ...pick,
281
- label: `Choose ${spec.tools.map((t) => TOOL_CATEGORIES[t].label).join(" or ")}`,
282
- entity_type: "item",
283
- where: { item_type: spec.tools.map((t) => TOOL_CATEGORIES[t].itemType), mundane: true }
284
- };
285
- default:
286
- warnOnce(
287
- `equipment-category:${category}`,
288
- `Archivist: starting-equipment category "${category}" is not a known item category; its pick offers no options.`
289
- );
290
- return { ...pick, label: `Choose a ${category.replace(/[-_]+/g, " ")}`, entity_type: "item", from: [] };
291
- }
292
- }
293
- var __categoryToEntitySelectForTest = categoryToEntitySelect;
294
- function equipmentDecisions(entries, ownerSlug) {
295
- const out = [];
296
- let degraded = false;
297
- (entries != null ? entries : []).forEach((eq, i) => {
298
- var _a;
299
- if ((eq == null ? void 0 : eq.kind) !== "choice") return;
300
- const options = (_a = eq.options) != null ? _a : [];
301
- out.push({
302
- kind: "select-inline",
303
- id: `equipment-${i}`,
304
- label: "Starting Equipment",
305
- count: 1,
306
- options: options.map((opt, j) => {
307
- var _a2;
308
- const label = typeof opt === "string" ? opt : (_a2 = opt == null ? void 0 : opt.label) != null ? _a2 : "";
309
- const wellFormed = !!opt && typeof opt === "object" && Array.isArray(opt.grants);
310
- if (!wellFormed) degraded = true;
311
- const grants = wellFormed ? opt.grants : [];
312
- return {
313
- value: `option-${j}`,
314
- label,
315
- choices: grants.flatMap((g, k) => isCategoryGrant(g) ? [categoryToEntitySelect(g.category, equipmentCategoryKey(i, j, k))] : [])
316
- };
317
- })
318
- });
319
- });
320
- if (degraded && !warnedDegradedEquipment.has(ownerSlug)) {
321
- warnedDegradedEquipment.add(ownerSlug);
322
- console.warn(
323
- `[archivist] Starting equipment for "${ownerSlug}" is in an outdated/unstructured format; its nested picks and seeding are skipped. Re-sync the compendium (delete _compendium.md and reload) to fix.`
324
- );
325
- }
326
- return out;
327
- }
328
- function authoredProficiencyPool(choice) {
329
- if (!choice.from) return void 0;
330
- return choice.domain === "tool" ? expandToolPool(choice.from) : choice.from;
331
- }
332
- function enumerateOptions(choice, ctx, ownerBare) {
333
- var _a, _b;
334
- switch (choice.kind) {
335
- case "select-inline":
336
- return choice.options.map((o) => ({ value: o.value, label: o.label, description: o.description }));
337
- case "select-entity": {
338
- if (choice.from) {
339
- let byBare;
340
- const bareIndex = () => {
341
- var _a2, _b2, _c, _d;
342
- if (byBare) return byBare;
343
- const built = /* @__PURE__ */ new Map();
344
- const pool = ctx.registry.search("", choice.entity_type, Number.POSITIVE_INFINITY).slice().sort((a, b) => a.name.localeCompare(b.name) || a.slug.localeCompare(b.slug));
345
- const seed = (e) => {
346
- const bare = bareEntitySlug(e.slug);
347
- if (built.has(bare)) {
348
- if (!warnedAmbiguousBare.has(bare)) {
349
- warnedAmbiguousBare.add(bare);
350
- console.warn(`Archivist: bare slug "${bare}" matches multiple ${choice.entity_type} entities; using "${built.get(bare).slug}"`);
351
- }
352
- return;
353
- }
354
- built.set(bare, e);
355
- };
356
- for (const e of pool) if ((_b2 = (_a2 = ctx.isEntityVisible) == null ? void 0 : _a2.call(ctx, e)) != null ? _b2 : true) seed(e);
357
- for (const e of pool) if (!((_d = (_c = ctx.isEntityVisible) == null ? void 0 : _c.call(ctx, e)) != null ? _d : true)) seed(e);
358
- byBare = built;
359
- return built;
360
- };
361
- return choice.from.map((slug) => {
362
- var _a2;
363
- const e = (_a2 = ctx.registry.getByTypeAndSlug(choice.entity_type, slug)) != null ? _a2 : bareIndex().get(slug);
364
- return e ? { value: e.slug, label: e.name, entity: e } : { value: slug, label: slug, missing: true };
365
- });
366
- }
367
- const all = ctx.registry.search("", choice.entity_type, Number.POSITIVE_INFINITY);
368
- const filtered = choice.where ? all.filter((e) => matchesFilter(e, choice.where, ownerBare)) : all;
369
- return filtered.map((e) => ({ value: e.slug, label: e.name, entity: e }));
370
- }
371
- case "select-proficiency": {
372
- const pool = (_a = authoredProficiencyPool(choice)) != null ? _a : choice.domain === "skill" ? [...ALL_SKILL_SLUGS] : choice.domain === "language" ? [...ALL_LANGUAGES] : choice.domain === "tool" ? [...ALL_TOOLS] : [];
373
- return pool.map((v) => ({ value: v, label: humanizeProficiency(v) }));
374
- }
375
- case "ability-points": {
376
- const pool = (_b = choice.pool) != null ? _b : ["str", "dex", "con", "int", "wis", "cha"];
377
- return pool.map((a) => ({ value: a, label: a.toUpperCase() }));
378
- }
379
- }
380
- }
381
- function selectionCount(choice, selected) {
382
- if (selected === void 0) return 0;
383
- if (choice.kind === "ability-points") {
384
- if (typeof selected !== "object" || Array.isArray(selected)) return 0;
385
- return Object.values(selected).reduce((s, v) => s + (typeof v === "number" ? v : 0), 0);
386
- }
387
- if (Array.isArray(selected)) return selected.length;
388
- return typeof selected === "string" && selected.length > 0 ? 1 : 0;
389
- }
390
- function requiredCount(choice) {
391
- var _a;
392
- if (choice.kind === "ability-points") return choice.points;
393
- if (choice.kind === "select-proficiency") return choice.count;
394
- return (_a = choice.count) != null ? _a : 1;
395
- }
396
- function capAtCount(choice, value) {
397
- const folds = choice.kind === "select-proficiency" || choice.kind === "select-entity" && choice.entity_type === "weapon" && choice.id !== "weapon-mastery";
398
- if (!folds || !Array.isArray(value)) return value;
399
- const n = requiredCount(choice);
400
- return value.length > n ? value.slice(0, n) : value;
401
- }
402
- function statusOf(choice, selected, satisfied) {
403
- const n = selectionCount(choice, selected);
404
- const need = requiredCount(choice);
405
- if (satisfied) return "resolved";
406
- if (n === 0) return "unresolved";
407
- return n >= need ? "resolved" : "partial";
408
- }
409
- var matchPool = (v, pool) => pool.find((p) => toProfSlug(p) === toProfSlug(v));
410
- var canonicalizeSelection = (value, pool) => {
411
- var _a;
412
- if (typeof value === "string") return (_a = matchPool(value, pool)) != null ? _a : value;
413
- if (Array.isArray(value)) return value.map((v) => {
414
- var _a2;
415
- return (_a2 = matchPool(v, pool)) != null ? _a2 : v;
416
- });
417
- return value;
418
- };
419
- function resolveEntityRef(ctx, entityType, value) {
420
- if (typeof value !== "string" || value.length === 0) return void 0;
421
- const raw = value.replace(/^\[\[/, "").replace(/\]\]$/, "");
422
- const direct = ctx.registry.getByTypeAndSlug(entityType, raw);
423
- if (direct) return direct;
424
- for (const e of ctx.registry.search("", entityType, Number.POSITIVE_INFINITY)) {
425
- if (e.slug === raw || bareEntitySlug(e.slug) === raw) return e;
426
- }
427
- return void 0;
428
- }
429
- function buildItem(inputChoice, source, level, featureName, readValue, ctx, ownerBare, effective, opts) {
430
- var _a, _b, _c, _d;
431
- const choice = flattenAsiOrFeat(inputChoice);
432
- const keyPrefix = (_a = opts == null ? void 0 : opts.keyPrefix) != null ? _a : "";
433
- const expandFeatChildren = (_b = opts == null ? void 0 : opts.expandFeatChildren) != null ? _b : true;
434
- const key = keyPrefix + choice.id;
435
- const raw = capAtCount(choice, readValue(key));
436
- const preExclusionOptions = enumerateOptions(choice, ctx, ownerBare);
437
- let options = preExclusionOptions;
438
- const mine = new Set(
439
- (Array.isArray(raw) ? raw : raw === void 0 ? [] : [raw]).map((v) => toProfSlug(String(v)))
440
- );
441
- if (choice.kind === "select-proficiency" && choice.domain === "skill" && choice.from_proficient) {
442
- options = options.filter((o) => effective.skill.has(toProfSlug(o.value)) || mine.has(toProfSlug(o.value)));
443
- }
444
- const postInclusionOptions = options;
445
- const excludes = choice.kind === "select-proficiency" && (choice.domain === "language" || choice.domain === "tool" || choice.domain === "skill" && choice.expertise === true);
446
- if (excludes && choice.kind === "select-proficiency") {
447
- const known = choice.domain === "skill" ? effective.skillExpertise : effective[choice.domain];
448
- options = options.filter((o) => !known.has(toProfSlug(o.value)) || mine.has(toProfSlug(o.value)));
449
- }
450
- const satisfied = excludes && postInclusionOptions.length > 0 && options.length === 0;
451
- const selected = choice.kind === "select-proficiency" ? canonicalizeSelection(raw, options.map((o) => o.value)) : raw;
452
- const item = {
453
- key,
454
- source,
455
- level,
456
- featureName,
457
- choice,
458
- description: opts == null ? void 0 : opts.description,
459
- options,
460
- selected,
461
- status: statusOf(choice, selected, satisfied),
462
- satisfied
463
- };
464
- if (choice.kind === "select-inline" && typeof selected === "string") {
465
- const branch = choice.options.find((o) => o.value === selected);
466
- if ((_c = branch == null ? void 0 : branch.choices) == null ? void 0 : _c.length) {
467
- item.children = branch.choices.map((c) => buildItem(
468
- c,
469
- source,
470
- level,
471
- featureName,
472
- readValue,
473
- ctx,
474
- ownerBare,
475
- effective,
476
- { keyPrefix, expandFeatChildren }
477
- ));
478
- if (item.status === "resolved" && item.children.some((c) => c.status !== "resolved")) {
479
- item.status = "partial";
480
- }
481
- }
482
- }
483
- if (choice.kind === "select-entity" && choice.entity_type === "feat" && expandFeatChildren && typeof selected === "string") {
484
- const entity = resolveEntityRef(ctx, "feat", selected);
485
- const rawChoices = (_d = entity == null ? void 0 : entity.data) == null ? void 0 : _d.choices;
486
- const featChoices = Array.isArray(rawChoices) ? rawChoices : [];
487
- if (featChoices.length) {
488
- const childPrefix = `${keyPrefix}feat:`;
489
- item.children = featChoices.map((c) => buildItem(
490
- c,
491
- source,
492
- level,
493
- featureName,
494
- readValue,
495
- ctx,
496
- ownerBare,
497
- effective,
498
- { keyPrefix: childPrefix, expandFeatChildren: false }
499
- ));
500
- if (item.status === "resolved" && item.children.some((c) => c.status !== "resolved")) {
501
- item.status = "partial";
502
- }
503
- }
504
- }
505
- return item;
506
- }
507
- function buildSubclassItem(choice, source, level, featureName, c, ctx, ownerBare, description) {
508
- const selected = c.subclass ? c.subclass.slug : void 0;
509
- return {
510
- key: "subclass",
511
- source,
512
- level,
513
- featureName,
514
- description,
515
- choice,
516
- options: enumerateOptions(choice, ctx, ownerBare),
517
- selected,
518
- status: selected ? "resolved" : "unresolved",
519
- // A subclass pick is a select-entity, never a proficiency choice, so no
520
- // exclusion can empty its pool.
521
- satisfied: false
522
- };
523
- }
524
- function visitProficiencyChoices(resolved, visit) {
525
- var _a, _b, _c;
526
- const walk = (choices, read) => {
527
- for (const ch of choices != null ? choices : []) {
528
- visit(ch, read(ch.id));
529
- if (ch.kind === "select-inline") {
530
- const sel = read(ch.id);
531
- const branch = typeof sel === "string" ? ch.options.find((o) => o.value === sel) : void 0;
532
- if (branch == null ? void 0 : branch.choices) walk(branch.choices, read);
533
- }
534
- }
535
- };
536
- const oc = (_a = resolved.definition.origin_choices) != null ? _a : {};
537
- const originRead = (ns) => (id) => oc[`${ns}:${id}`];
538
- const stripRef = (ref) => ref.replace(/^\[\[/, "").replace(/\]\]$/, "");
539
- const featBySlug = new Map(((_b = resolved.feats) != null ? _b : []).map((f) => [f.slug, f]));
540
- const memberSites = poolMemberSitesOf(resolved);
541
- const featSites = featPickSites(resolved.classes, memberSites, (ci) => {
542
- var _a2, _b2, _c2, _d;
543
- return (_d = (_c2 = (_b2 = (_a2 = resolved.classes) == null ? void 0 : _a2[ci]) == null ? void 0 : _b2.entity) == null ? void 0 : _c2.slug) != null ? _d : null;
544
- });
545
- resolved.classes.forEach((c, i) => {
546
- var _a2, _b2, _c2, _d, _e;
547
- if (!c.entity) return;
548
- const entity = c.entity;
549
- const readAt = (lvl) => (id) => {
550
- var _a3;
551
- return (_a3 = c.choices[lvl]) == null ? void 0 : _a3[id];
552
- };
553
- if (i === 0 && ((_b2 = (_a2 = entity.skill_choices) == null ? void 0 : _a2.from) == null ? void 0 : _b2.length)) {
554
- visit({
555
- kind: "select-proficiency",
556
- id: "skills",
557
- count: entity.skill_choices.count,
558
- domain: "skill",
559
- from: entity.skill_choices.from
560
- }, readAt(1)("skills"));
561
- }
562
- if (i === 0) walk(entity.choices, readAt(1));
563
- if (i === 0) walk(classToolPicks(entity).decisions, readAt(1));
564
- for (const rf of resolved.features) {
565
- if (rf.source.kind !== "class" && rf.source.kind !== "subclass") continue;
566
- const belongs = rf.source.kind === "class" ? rf.source.slug === entity.slug : c.subclass != null && rf.source.slug === c.subclass.slug;
567
- if (!belongs) continue;
568
- for (const copy of (_c2 = rf.foldedFrom) != null ? _c2 : []) walk(copy.choices, readAt(copy.level));
569
- walk(rf.feature.choices, readAt(rf.source.level));
570
- }
571
- for (const site of featSites) {
572
- if (site.classIndex !== i) continue;
573
- const feat = (_e = featBySlug.get(stripRef(site.slug))) != null ? _e : featOfSite(site, (_d = resolved.feats) != null ? _d : []);
574
- if (!feat) continue;
575
- walk(feat.choices, site.read);
576
- }
577
- for (const site of memberSites) if (site.classIndex === i) walk(site.choices, site.read);
578
- });
579
- if (resolved.race) {
580
- walk(resolved.race.choices, originRead("race"));
581
- for (const t of (_c = resolved.race.traits) != null ? _c : []) walk(t.choices, originRead("race"));
582
- }
583
- if (resolved.background) {
584
- walk(resolved.background.choices, originRead("background"));
585
- walk(backgroundToolPicks(resolved.background).decisions, originRead("background"));
586
- if (resolved.background.feature) {
587
- const feature = resolved.background.feature;
588
- walk(feature.choices, originRead("background"));
589
- }
590
- }
591
- if (resolved.originFeatSlug) {
592
- const of = featBySlug.get(resolved.originFeatSlug);
593
- if (of) walk(of.choices, (id) => oc[`background:feat:${id}`]);
594
- }
595
- }
596
- var filterToPool = (vals, pool) => pool ? vals.map((v) => matchPool(v, pool)).filter((v) => !!v) : vals;
597
- function collectChosenProficiencies(resolved) {
598
- const out = { skills: [], expertise: [], languages: [], tools: [], weapons: [], saves: [] };
599
- const isAbility = (v) => ABILITY_KEYS.includes(v);
600
- visitProficiencyChoices(resolved, (choice, stored) => {
601
- const selected = capAtCount(choice, stored);
602
- const vals = Array.isArray(selected) ? selected : typeof selected === "string" ? [selected] : [];
603
- if (choice.kind === "select-entity" && choice.entity_type === "weapon") {
604
- if (choice.id === "weapon-mastery") return;
605
- for (const v of vals) {
606
- const bare = bareEntitySlug(String(v));
607
- if (bare && !out.weapons.includes(bare)) out.weapons.push(bare);
608
- }
609
- return;
610
- }
611
- if (choice.kind !== "select-proficiency") return;
612
- const valid = filterToPool(vals, authoredProficiencyPool(choice));
613
- if (choice.domain === "save") {
614
- for (const v of valid) if (isAbility(v) && !out.saves.includes(v)) out.saves.push(v);
615
- return;
616
- }
617
- const bucket = choice.domain === "skill" ? choice.expertise ? out.expertise : out.skills : choice.domain === "language" ? out.languages : choice.domain === "tool" ? out.tools : null;
618
- if (bucket) {
619
- for (const v of valid) if (!bucket.includes(v)) bucket.push(v);
620
- }
621
- });
622
- return out;
623
- }
624
- function proficiencyEntryFor(raw, vocab, origin, sources, expertise) {
625
- const hit = matchPool(raw, vocab);
626
- const value = hit ? toProfSlug(hit) : raw;
627
- const label = hit ? humanizeProficiency(value) : origin === "custom" ? raw : proficiencyLabel(raw);
628
- return { value, label, sources, origin, ...expertise ? { expertise: true } : {} };
629
- }
630
- function computeEffectiveProficiencies(resolved) {
631
- const grants = collectProficiencyGrants(resolved);
632
- const chosen = collectChosenProficiencies(resolved);
633
- const build = (domain) => {
634
- var _a, _b, _c, _d, _e, _f, _g, _h;
635
- const vocab = domain === "languages" ? ALL_LANGUAGES : ALL_TOOLS;
636
- const ov = (_b = (_a = resolved.definition) == null ? void 0 : _a.overrides) == null ? void 0 : _b[domain];
637
- const adds = (_c = ov == null ? void 0 : ov.add) != null ? _c : [];
638
- const removes = (_d = ov == null ? void 0 : ov.remove) != null ? _d : [];
639
- const byValue = /* @__PURE__ */ new Map();
640
- const push = (raw, origin, source, expertise) => {
641
- const probe = proficiencyEntryFor(raw, vocab, origin, source ? [source] : [], expertise);
642
- const existing = byValue.get(probe.value);
643
- if (!existing) {
644
- byValue.set(probe.value, probe);
645
- return;
646
- }
647
- if (source && !existing.sources.includes(source)) existing.sources.push(source);
648
- if (expertise) existing.expertise = true;
649
- const rank = { grant: 0, pick: 1, manual: 2, custom: 3 };
650
- if (rank[origin] < rank[existing.origin]) existing.origin = origin;
651
- };
652
- const grantBuckets = domain === "languages" ? [grants.raceLangFixed, grants.bgLangFixed, grants.featLanguages, grants.effectLanguages] : [grants.classToolFixed, grants.bgToolFixed, grants.featTools, grants.effectTools];
653
- for (const b of grantBuckets) for (const g of b) push(g.value, "grant", g.source, g.expertise);
654
- for (const v of domain === "languages" ? chosen.languages : chosen.tools) push(v, "pick");
655
- for (const v of adds) push(v, matchPool(v, vocab) ? "manual" : "custom");
656
- const triSuppressed = /* @__PURE__ */ new Set();
657
- if (domain === "tools") {
658
- const tri = (_h = (_g = (_f = (_e = resolved.definition) == null ? void 0 : _e.overrides) == null ? void 0 : _f.tools) == null ? void 0 : _g.proficiency) != null ? _h : {};
659
- for (const [tool, state] of Object.entries(tri)) {
660
- const key = toProfSlug(tool);
661
- if (state === "none") {
662
- triSuppressed.add(key);
663
- continue;
664
- }
665
- let entry = [...byValue.values()].find((e) => toProfSlug(e.value) === key);
666
- if (!entry) {
667
- push(tool, matchPool(tool, vocab) ? "manual" : "custom");
668
- entry = [...byValue.values()].find((e) => toProfSlug(e.value) === key);
669
- }
670
- if (!entry) continue;
671
- if (state === "expertise") entry.expertise = true;
672
- else delete entry.expertise;
673
- }
674
- }
675
- const suppressed = /* @__PURE__ */ new Set([...removes.map((r) => toProfSlug(r)), ...triSuppressed]);
676
- return [...byValue.values()].filter((e) => !suppressed.has(toProfSlug(e.value))).sort((a, b) => a.label < b.label ? -1 : a.label > b.label ? 1 : 0);
677
- };
678
- return { languages: build("languages"), tools: build("tools") };
679
- }
680
- function collectChosenAbilityPoints(resolved) {
681
- var _a, _b, _c;
682
- const oc = (_a = resolved.definition.origin_choices) != null ? _a : {};
683
- const out = { race: {}, background: {} };
684
- const fold = (ns, choices) => {
685
- var _a2;
686
- for (const ch of choices != null ? choices : []) {
687
- if (ch.kind !== "ability-points") continue;
688
- const raw = oc[`${ns}:${ch.id}`];
689
- if (!raw || typeof raw !== "object" || Array.isArray(raw)) continue;
690
- let left = ch.points;
691
- for (const ab of ABILITY_KEYS) {
692
- if (ch.pool && !ch.pool.includes(ab)) continue;
693
- const v = raw[ab];
694
- if (typeof v !== "number" || v <= 0 || left <= 0) continue;
695
- const take = Math.min(v, ch.max_per, left);
696
- out[ns][ab] = ((_a2 = out[ns][ab]) != null ? _a2 : 0) + take;
697
- left -= take;
698
- }
699
- }
700
- };
701
- const race = resolved.race;
702
- if (race) {
703
- fold("race", race.choices);
704
- for (const t of (_b = race.traits) != null ? _b : []) fold("race", t.choices);
705
- }
706
- const bg = resolved.background;
707
- if (bg) {
708
- fold("background", bg.choices);
709
- fold("background", (_c = bg.feature) == null ? void 0 : _c.choices);
710
- }
711
- return out;
712
- }
713
- function buildDecisionLedger(resolved, ctx) {
714
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
715
- const eff = computeEffectiveProficiencies(resolved);
716
- const chosen = collectChosenProficiencies(resolved);
717
- const { features, activeBuffs } = assembleEffectFeatures(resolved);
718
- const effectGrants = collectProficiencyEffectGrants(features, activeBuffs);
719
- const effective = {
720
- language: new Set(eff.languages.map((e) => toProfSlug(e.value))),
721
- tool: new Set(eff.tools.map((e) => toProfSlug(e.value))),
722
- // Same precedent as computeEffectiveProficiencies' `resolved.definition?.overrides?.[domain]`: the
723
- // type says `skills` is non-optional, but consumers build ResolvedCharacter by cast and `tests/` is
724
- // typechecked by nothing (the plugin's equipment-step fixtures pass a `definition` with no `skills`).
725
- skill: new Set([
726
- ...(_c = (_b = (_a = resolved.definition) == null ? void 0 : _a.skills) == null ? void 0 : _b.proficient) != null ? _c : [],
727
- ...(_e = (_d = resolved.background) == null ? void 0 : _d.skill_proficiencies) != null ? _e : [],
728
- ...chosen.skills,
729
- ...effectGrants.skills.map((g) => g.value)
730
- ].map(toProfSlug)),
731
- skillExpertise: new Set([
732
- ...(_h = (_g = (_f = resolved.definition) == null ? void 0 : _f.skills) == null ? void 0 : _g.expertise) != null ? _h : [],
733
- ...chosen.expertise,
734
- ...effectGrants.skills.filter((g) => g.expertise).map((g) => g.value)
735
- ].map(toProfSlug))
736
- };
737
- const classes = [];
738
- resolved.classes.forEach((c, classIndex) => {
739
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o;
740
- if (!c.entity) return;
741
- const entity = c.entity;
742
- const ownerBare = bareEntitySlug(entity.slug);
743
- const byLevel = /* @__PURE__ */ new Map();
744
- const push = (lvl, item) => {
745
- var _a3;
746
- const arr = (_a3 = byLevel.get(lvl)) != null ? _a3 : [];
747
- arr.push(item);
748
- byLevel.set(lvl, arr);
749
- };
750
- const readAt = (lvl) => (id) => {
751
- var _a3;
752
- return (_a3 = c.choices[lvl]) == null ? void 0 : _a3[id];
753
- };
754
- let legacyAsiFeat;
755
- const legacyAsiReader = (choice, lvl) => {
756
- const alloc = convertibleLegacyAsi(c.choices[lvl]);
757
- if (!alloc) return null;
758
- const flat = flattenAsiOrFeat(choice);
759
- if (flat.kind !== "select-entity" || flat.entity_type !== "feat" || flat.from || flat.where) return null;
760
- if (legacyAsiFeat === void 0) legacyAsiFeat = resolveLegacyAsiFeat(ctx.registry, entity);
761
- const asi = legacyAsiFeat;
762
- if (!asi) return null;
763
- const raw = readAt(lvl);
764
- const childKey = `feat:${asi.childId}`;
765
- return (id) => id === "feat" ? asi.slug : id === childKey ? alloc : raw(id);
766
- };
767
- const featProgressions = [...(_a2 = entity.feat_progression) != null ? _a2 : [], ...(_c2 = (_b2 = c.subclass) == null ? void 0 : _b2.feat_progression) != null ? _c2 : []];
768
- const suppressedFeatureTypes = /* @__PURE__ */ new Set();
769
- for (const decl of [...(_d2 = entity.selection_pools) != null ? _d2 : [], ...(_f2 = (_e2 = c.subclass) == null ? void 0 : _e2.selection_pools) != null ? _f2 : []]) {
770
- const rp = resolved.pools.find((p) => p.classIndex === classIndex && p.id === decl.id);
771
- if (rp && rp.count >= 1) suppressedFeatureTypes.add(decl.source.where.feature_type);
772
- }
773
- for (const entry of featProgressions) {
774
- const category = featProgressionCategory(entry.category);
775
- const ft = category ? FEATURE_TYPE_FOR_CATEGORY[category] : void 0;
776
- if (ft) suppressedFeatureTypes.add(ft);
777
- }
778
- if (classIndex === 0 && ((_h2 = (_g2 = entity.skill_choices) == null ? void 0 : _g2.from) == null ? void 0 : _h2.length)) {
779
- const skillChoice = {
780
- kind: "select-proficiency",
781
- id: "skills",
782
- label: "Skill Proficiencies",
783
- count: entity.skill_choices.count,
784
- domain: "skill",
785
- from: entity.skill_choices.from
786
- };
787
- push(1, buildItem(
788
- skillChoice,
789
- { kind: "class", slug: entity.slug, level: 1 },
790
- 1,
791
- "Proficiencies",
792
- readAt(1),
793
- ctx,
794
- ownerBare,
795
- effective
796
- ));
797
- }
798
- if (classIndex === 0) {
799
- for (const ch of [...(_i2 = entity.choices) != null ? _i2 : [], ...classToolPicks(entity).decisions]) {
800
- push(1, buildItem(
801
- ch,
802
- { kind: "class", slug: entity.slug, level: 1 },
803
- 1,
804
- "Proficiencies",
805
- readAt(1),
806
- ctx,
807
- ownerBare,
808
- effective
809
- ));
810
- }
811
- }
812
- if (classIndex === 0) {
813
- for (const ch of equipmentDecisions(entity.starting_equipment, entity.slug)) {
814
- push(1, buildItem(
815
- ch,
816
- { kind: "class", slug: entity.slug, level: 1 },
817
- 1,
818
- "Starting Equipment",
819
- readAt(1),
820
- ctx,
821
- ownerBare,
822
- effective
823
- ));
824
- }
825
- }
826
- let sawAuthoredSubclass = false;
827
- const staged = [];
828
- const authoredRank = (kind, level, feature) => {
829
- var _a3, _b3, _c3;
830
- const at = (_c3 = (_b3 = (_a3 = kind === "class" ? entity : c.subclass) == null ? void 0 : _a3.features_by_level) == null ? void 0 : _b3[level]) != null ? _c3 : [];
831
- const index = at.findIndex((f) => feature.id ? f.id === feature.id : f.name === feature.name);
832
- return (kind === "class" ? 0 : 1) * 1e6 + (index < 0 ? 999999 : index);
833
- };
834
- for (const rf of resolved.features) {
835
- const src = rf.source;
836
- if (src.kind !== "class" && src.kind !== "subclass") continue;
837
- const belongs = src.kind === "class" ? src.slug === entity.slug : c.subclass != null && src.slug === c.subclass.slug;
838
- if (!belongs) continue;
839
- const lvl = src.level;
840
- const stage = (atLvl, item) => {
841
- staged.push({ level: atLvl, item, rank: authoredRank(src.kind, atLvl, rf.feature), seq: staged.length });
842
- };
843
- const emitChoices = (list, atLvl, name, description) => {
844
- var _a3, _b3;
845
- for (const ch of list) {
846
- if (ch.kind === "select-entity" && ch.entity_type === "subclass") {
847
- sawAuthoredSubclass = true;
848
- stage(atLvl, buildSubclassItem(ch, src, atLvl, name, c, ctx, ownerBare, description));
849
- continue;
850
- }
851
- let emitted = ch;
852
- if (ch.kind === "select-entity") {
853
- const columns = countColumnsFor(ch.id);
854
- const fromTable = columns ? readTableColumn(entity.table, c.level, columns) : null;
855
- if (fromTable != null) emitted = { ...ch, count: Math.max((_a3 = ch.count) != null ? _a3 : 1, fromTable) };
856
- }
857
- stage(atLvl, buildItem(
858
- emitted,
859
- src,
860
- atLvl,
861
- name,
862
- (_b3 = legacyAsiReader(emitted, atLvl)) != null ? _b3 : readAt(atLvl),
863
- ctx,
864
- ownerBare,
865
- effective,
866
- { description }
867
- ));
868
- }
869
- };
870
- const informationalItem = (atLvl, name, description) => {
871
- var _a3, _b3;
872
- return {
873
- key: (_a3 = rf.feature.id) != null ? _a3 : name,
874
- source: src,
875
- level: atLvl,
876
- featureName: name,
877
- description,
878
- choice: { kind: "select-inline", id: (_b3 = rf.feature.id) != null ? _b3 : name, options: [{ value: "_", label: "_" }] },
879
- options: [],
880
- selected: void 0,
881
- status: "informational",
882
- satisfied: false
883
- };
884
- };
885
- const emitCopy = (copy) => {
886
- let list = copy.choices;
887
- if (!(list == null ? void 0 : list.length)) {
888
- const recognized = recognizeDecision({ id: rf.feature.id, name: copy.name, description: copy.description });
889
- if (recognized === "informational") {
890
- stage(copy.level, informationalItem(copy.level, copy.name, copy.prose));
891
- return;
892
- }
893
- list = recognized != null ? recognized : void 0;
894
- if (list == null ? void 0 : list.length) {
895
- list = list.filter((ch) => {
896
- var _a3;
897
- if (ch.kind !== "select-entity") return true;
898
- const ft = (_a3 = ch.where) == null ? void 0 : _a3.feature_type;
899
- return !(ft !== void 0 && suppressedFeatureTypes.has(ft));
900
- });
901
- }
902
- }
903
- if (!(list == null ? void 0 : list.length)) {
904
- if (copy.prose) stage(copy.level, informationalItem(copy.level, copy.name, copy.prose));
905
- return;
906
- }
907
- emitChoices(list, copy.level, copy.name, copy.description);
908
- };
909
- for (const copy of (_j2 = rf.foldedFrom) != null ? _j2 : []) emitCopy({ ...copy, prose: copy.description });
910
- emitCopy({
911
- level: lvl,
912
- name: rf.feature.name,
913
- description: rf.feature.description,
914
- // The card prose: the description, else the entries joined. `||`, not `??`, so an EMPTY description
915
- // falls through to the entries the way this branch's own guard always did.
916
- prose: rf.feature.description || (((_k2 = rf.feature.entries) == null ? void 0 : _k2.length) ? rf.feature.entries.join("\n\n") : void 0),
917
- choices: rf.feature.choices
918
- });
919
- }
920
- staged.sort((a, b) => a.rank - b.rank || a.seq - b.seq);
921
- for (const s of staged) push(s.level, s.item);
922
- const subclassLevel = (_l2 = entity.subclass_level) != null ? _l2 : null;
923
- if (subclassLevel != null && subclassLevel <= c.level && !sawAuthoredSubclass) {
924
- const featureName = (_m2 = entity.subclass_feature_name) != null ? _m2 : "Subclass";
925
- const synthChoice = {
926
- kind: "select-entity",
927
- id: "subclass",
928
- label: featureName,
929
- count: 1,
930
- entity_type: "subclass",
931
- where: { parent_class: "self" }
932
- };
933
- push(subclassLevel, buildSubclassItem(
934
- synthChoice,
935
- { kind: "class", slug: entity.slug, level: subclassLevel },
936
- subclassLevel,
937
- featureName,
938
- c,
939
- ctx,
940
- ownerBare
941
- ));
942
- }
943
- for (const pool of resolved.pools) {
944
- if (pool.classIndex !== classIndex || pool.count < 1) continue;
945
- const stranded = strandedPicks(pool);
946
- const strandedSlugs = new Set(stranded.map((e) => e.slug));
947
- const synth = {
948
- kind: "select-entity",
949
- id: pool.id,
950
- label: pool.label,
951
- count: pool.count,
952
- entity_type: "optional-feature",
953
- from: [...pool.available.map((e) => e.slug), ...stranded.map((e) => e.slug)]
954
- };
955
- const item = buildItem(
956
- synth,
957
- { kind: "class", slug: entity.slug, level: pool.anchorLevel },
958
- pool.anchorLevel,
959
- pool.label,
960
- () => pool.selected.map((e) => e.key),
961
- ctx,
962
- ownerBare,
963
- effective
964
- );
965
- item.pool = { id: pool.id, anchorLevel: pool.anchorLevel };
966
- const repeatables = pool.available.filter((e) => e.entity.repeatable === true);
967
- if (repeatables.length > 0) {
968
- item.repeatable = repeatables.map((e) => {
969
- var _a3, _b3;
970
- return {
971
- noteSlug: e.slug,
972
- itemChoice: (_a3 = e.entity.item_choice) != null ? _a3 : "learn",
973
- rows: resolveOptionRows(e.entity, ctx.registry, { edition: resolved.definition.edition, isEntityVisible: (_b3 = ctx.isEntityVisible) == null ? void 0 : _b3.bind(ctx) })
974
- };
975
- });
976
- }
977
- for (const o of item.options) if (strandedSlugs.has(o.value)) o.stranded = true;
978
- const memberChildren = [];
979
- for (const entry of pool.selected) {
980
- for (const ch of memberChoices(entry.entity)) {
981
- const child = buildItem(
982
- ch,
983
- { kind: "class", slug: entity.slug, level: pool.anchorLevel },
984
- pool.anchorLevel,
985
- entry.entity.name,
986
- readAt(pool.anchorLevel),
987
- ctx,
988
- ownerBare,
989
- effective,
990
- { keyPrefix: `${pool.id}:${entry.key}:` }
991
- );
992
- child.parentLabel = entry.entity.name;
993
- memberChildren.push(child);
994
- }
995
- }
996
- if (memberChildren.length) {
997
- item.children = memberChildren;
998
- if (item.status === "resolved" && memberChildren.some((c2) => c2.status !== "resolved")) item.status = "partial";
999
- }
1000
- push(pool.anchorLevel, item);
1001
- }
1002
- for (const entry of featProgressions) {
1003
- const category = featProgressionCategory(entry.category);
1004
- if (!category) {
1005
- warnOnce(
1006
- `feat-progression-category:${entity.slug}:${entry.name}`,
1007
- `Archivist: feat_progression "${entry.name}" on "${entity.slug}" carries no category this engine maps (${((_n2 = entry.category) != null ? _n2 : []).join(", ")}); no decision is offered`
1008
- );
1009
- continue;
1010
- }
1011
- const progression = entry.progression;
1012
- if (Array.isArray(progression)) continue;
1013
- for (const key of Object.keys(progression)) {
1014
- const lvl = Number.parseInt(key, 10);
1015
- if (!Number.isInteger(lvl) || String(lvl) !== key) continue;
1016
- if (lvl > c.level) continue;
1017
- if (((_o = byLevel.get(lvl)) != null ? _o : []).some((i) => i.key === "feat")) {
1018
- warnOnce(
1019
- `feat-progression-collision:${entity.slug}:${lvl}`,
1020
- `Archivist: "${entry.name}" on "${entity.slug}" would add a second feat pick at level ${lvl}, where one already exists; skipping`
1021
- );
1022
- continue;
1023
- }
1024
- const progressionChoice = {
1025
- kind: "select-entity",
1026
- id: "feat",
1027
- label: entry.name,
1028
- count: 1,
1029
- entity_type: "feat",
1030
- where: { category }
1031
- };
1032
- push(lvl, buildItem(
1033
- progressionChoice,
1034
- { kind: "class", slug: entity.slug, level: lvl },
1035
- lvl,
1036
- entry.name,
1037
- readAt(lvl),
1038
- ctx,
1039
- ownerBare,
1040
- effective
1041
- ));
1042
- }
1043
- }
1044
- const levels = [...byLevel.entries()].sort(([a], [b]) => a - b).map(([level, items]) => ({ level, items }));
1045
- classes.push({ classIndex, levels });
1046
- });
1047
- const origin = [];
1048
- const oc = (_i = resolved.definition.origin_choices) != null ? _i : {};
1049
- const originRead = (ns) => (id) => oc[`${ns}:${id}`];
1050
- const pushOrigin = (choices, ns, source, featureName, ownerBare, description) => {
1051
- for (const ch of choices != null ? choices : []) {
1052
- origin.push(buildItem(
1053
- ch,
1054
- source,
1055
- 0,
1056
- featureName,
1057
- originRead(ns),
1058
- ctx,
1059
- ownerBare,
1060
- effective,
1061
- { description }
1062
- ));
1063
- }
1064
- };
1065
- if (resolved.race) {
1066
- const bare = bareEntitySlug(resolved.race.slug);
1067
- pushOrigin(
1068
- resolved.race.choices,
1069
- "race",
1070
- { kind: "race", slug: resolved.race.slug },
1071
- (_j = resolved.race.name) != null ? _j : "Race",
1072
- bare,
1073
- resolved.race.description
1074
- );
1075
- for (const t of (_k = resolved.race.traits) != null ? _k : []) {
1076
- pushOrigin(
1077
- t.choices,
1078
- "race",
1079
- { kind: "race", slug: resolved.race.slug },
1080
- t.name,
1081
- bare,
1082
- t.description
1083
- );
1084
- }
1085
- }
1086
- if (resolved.background) {
1087
- const bare = bareEntitySlug(resolved.background.slug);
1088
- pushOrigin(
1089
- [...(_l = resolved.background.choices) != null ? _l : [], ...backgroundToolPicks(resolved.background).decisions],
1090
- "background",
1091
- { kind: "background", slug: resolved.background.slug },
1092
- (_m = resolved.background.name) != null ? _m : "Background",
1093
- bare,
1094
- resolved.background.description
1095
- );
1096
- if (resolved.background.feature) {
1097
- pushOrigin(
1098
- resolved.background.feature.choices,
1099
- "background",
1100
- { kind: "background", slug: resolved.background.slug },
1101
- resolved.background.feature.name,
1102
- bare,
1103
- resolved.background.feature.description
1104
- );
1105
- }
1106
- if (resolved.background.origin_feat) {
1107
- const originFeat = resolveOriginFeat(
1108
- ctx.registry,
1109
- resolved.background.origin_feat,
1110
- resolved.background.slug
1111
- );
1112
- if (originFeat) {
1113
- const featSource = { kind: "feat", slug: originFeat.feat.slug };
1114
- const featBare = bareEntitySlug(originFeat.feat.slug);
1115
- for (const ch of (_n = originFeat.feat.choices) != null ? _n : []) {
1116
- origin.push(buildItem(
1117
- ch,
1118
- featSource,
1119
- 0,
1120
- originFeat.display,
1121
- originRead("background"),
1122
- ctx,
1123
- featBare,
1124
- effective,
1125
- { keyPrefix: "feat:" }
1126
- ));
1127
- }
1128
- }
1129
- }
1130
- for (const ch of equipmentDecisions(resolved.background.equipment, resolved.background.slug)) {
1131
- origin.push(buildItem(
1132
- ch,
1133
- { kind: "background", slug: resolved.background.slug },
1134
- 0,
1135
- "Starting Equipment",
1136
- originRead("background"),
1137
- ctx,
1138
- bare,
1139
- effective
1140
- ));
1141
- }
1142
- }
1143
- return { classes, origin };
1144
- }
1145
-
1146
- // src/pc/pc.resolver.ts
1147
- var SLUG_RE = /^\[\[(.+?)\]\]$/;
1148
- function stripSlug(ref) {
1149
- if (!ref) return null;
1150
- const m = ref.match(SLUG_RE);
1151
- return m ? m[1] : ref;
1152
- }
1153
- function resolveOriginFeat(entities, originFeatRef, ownerSlug) {
1154
- var _a, _b, _c;
1155
- if (!originFeatRef) return null;
1156
- const slug = wikilinkTailSlug(originFeatRef);
1157
- const inner = originFeatRef.replace(/^\[\[/, "").replace(/\]\]$/, "").trim();
1158
- const rawTail = (_b = (_a = inner.split("/").pop()) == null ? void 0 : _a.trim()) != null ? _b : "";
1159
- const base = rawTail.replace(/\s*\([^()]*\)\s*$/, "").trim();
1160
- const baseSlug = base && base !== rawTail ? wikilinkTailSlug(`[[${base}]]`) : null;
1161
- const baseInner = baseSlug ? inner.slice(0, inner.length - rawTail.length) + base : null;
1162
- const prefix = (ownerSlug == null ? void 0 : ownerSlug.includes("_")) ? ownerSlug.slice(0, ownerSlug.indexOf("_")) : null;
1163
- const feats = entities.search("", "feat", Number.POSITIVE_INFINITY);
1164
- const byPath = (p) => feats.find((f) => f.filePath === `${p}.md` || f.filePath.endsWith(`/${p}.md`));
1165
- const sameCompendiumTail = (s) => prefix ? feats.find((f) => f.slug.startsWith(`${prefix}_feat_`) && f.slug.endsWith(`_${s}`)) : void 0;
1166
- const anyTail = (s) => feats.find((f) => f.slug.endsWith(`_${s}`));
1167
- const tiers = [
1168
- () => {
1169
- var _a2;
1170
- return (_a2 = feats.find((f) => f.slug === inner)) != null ? _a2 : feats.find((f) => f.slug === slug);
1171
- },
1172
- // 1 exact slug
1173
- () => byPath(inner),
1174
- // 2 PATH
1175
- () => baseInner ? byPath(baseInner) : void 0,
1176
- // 3 PATH, parenthetical stripped
1177
- () => sameCompendiumTail(slug),
1178
- // 4 same-compendium tail
1179
- () => baseSlug ? sameCompendiumTail(baseSlug) : void 0,
1180
- // 5 same-compendium tail, stripped
1181
- () => anyTail(slug),
1182
- // 6 any tail
1183
- () => baseSlug ? anyTail(baseSlug) : void 0
1184
- // 7 any tail, stripped
1185
- ];
1186
- let reg;
1187
- let hitTier = 0;
1188
- for (let i = 0; i < tiers.length && !reg; i++) {
1189
- reg = tiers[i]();
1190
- hitTier = i + 1;
1191
- }
1192
- if (!reg) return null;
1193
- const variantName = baseSlug && (hitTier === 3 || hitTier === 5 || hitTier === 7) ? rawTail : void 0;
1194
- const data = reg.data;
1195
- const feat = data.slug == null ? { ...data, slug: reg.slug } : data;
1196
- return { feat, display: (_c = variantName != null ? variantName : feat.name) != null ? _c : slug };
1197
- }
1198
- var PCResolver = class {
1199
- constructor(entities) {
1200
- this.entities = entities;
1201
- }
1202
- /** Exposed so recalc() can apply equipment bonuses (Pass A / Pass B). */
1203
- get registry() {
1204
- return this.entities;
1205
- }
1206
- resolve(character) {
1207
- var _a, _b, _c, _d, _e, _f, _g, _h;
1208
- const warnings = [];
1209
- const lookup = (rawRef, type) => {
1210
- const slug = stripSlug(rawRef);
1211
- if (!slug) return null;
1212
- const reg = this.entities.getByTypeAndSlug(type, slug);
1213
- if (!reg) {
1214
- warnings.push(`Slug [[${slug}]] not found in compendium as ${type}.`);
1215
- return null;
1216
- }
1217
- const data = reg.data;
1218
- return data.slug == null ? { ...data, slug: reg.slug } : data;
1219
- };
1220
- const race = lookup(character.race, "race");
1221
- const background = lookup(character.background, "background");
1222
- const classes = character.class.map((c) => ({
1223
- entity: lookup(c.name, "class"),
1224
- level: c.level,
1225
- subclass: lookup(c.subclass, "subclass"),
1226
- choices: c.choices
1227
- }));
1228
- const memberSites = poolMemberSites(classes, this.entities);
1229
- const classSlugOf = (i) => {
1230
- var _a2, _b2, _c2, _d2, _e2;
1231
- return (_e2 = (_b2 = (_a2 = classes[i]) == null ? void 0 : _a2.entity) == null ? void 0 : _b2.slug) != null ? _e2 : stripSlug((_d2 = (_c2 = character.class[i]) == null ? void 0 : _c2.name) != null ? _d2 : null);
1232
- };
1233
- const featSites = featPickSites(character.class, memberSites, classSlugOf);
1234
- const feats = [];
1235
- const featVia = /* @__PURE__ */ new Map();
1236
- for (const site of featSites) {
1237
- const f = lookup(`[[${site.slug}]]`, "feat");
1238
- if (!f) continue;
1239
- if (!feats.some((x) => x.slug === f.slug)) feats.push(f);
1240
- if (site.via && !featVia.has(f.slug)) featVia.set(f.slug, site.via);
1241
- }
1242
- const originFeat = (background == null ? void 0 : background.origin_feat) ? resolveOriginFeat(this.entities, background.origin_feat, background.slug) : null;
1243
- const originFeatSlug = originFeat == null ? void 0 : originFeat.feat.slug;
1244
- if (originFeat && !feats.some((f) => f.slug === originFeat.feat.slug)) {
1245
- feats.push(originFeat.feat);
1246
- }
1247
- if (originFeat && background && !featVia.has(originFeat.feat.slug)) {
1248
- featVia.set(originFeat.feat.slug, { kind: "background", slug: background.slug });
1249
- }
1250
- const totalLevel = classes.reduce((sum, c) => sum + c.level, 0);
1251
- const features = collectResolvedFeatures(race, classes, background, feats, featVia);
1252
- const extraFeatures = collectChosenGrantedFeatures(character, classes, this.entities, race, background, memberSites);
1253
- features.push(...extraFeatures);
1254
- features.push(...collectAdditionalFeatures(character, this.entities, warnings));
1255
- const casters = [];
1256
- classes.forEach((c, i) => {
1257
- const profile = c.entity ? resolveSpellcasting(c) : null;
1258
- const classSlug = profile ? stripSlug(character.class[i].name) : null;
1259
- if (profile && classSlug != null) casters.push({ classSlug, spellList: profile.spellList });
1260
- });
1261
- const spells = [];
1262
- for (const raw of (_a = character.spells.known) != null ? _a : []) {
1263
- const n = normalizeKnownSpell(raw);
1264
- const reg = this.entities.getByTypeAndSlug("spell", n.slug);
1265
- if (!reg) {
1266
- warnings.push(`Spell [[${n.slug}]] not found in compendium.`);
1267
- continue;
1268
- }
1269
- const entity = mirrorSpellShapes(reg.data);
1270
- const isCantrip = ((_b = entity.level) != null ? _b : 0) === 0;
1271
- const classSlug = (_c = n.classSlug) != null ? _c : attributeUnclassedSpell(entity.classes, casters, this.entities);
1272
- const prep = isCantrip || n.alwaysPrepared ? true : (_d = n.preparedFlag) != null ? _d : false;
1273
- spells.push({ entity, slug: n.slug, classSlug, source: n.source, prepared: prep, alwaysPrepared: n.alwaysPrepared, persisted: true });
1274
- }
1275
- const oc = (_e = character.origin_choices) != null ? _e : {};
1276
- if (originFeat) {
1277
- const read = (childId) => oc[`background:feat:${childId}`];
1278
- spells.push(...collectFeatGrantedSpells(originFeat.feat, read, this.entities, warnings));
1279
- }
1280
- for (const site of featSites) {
1281
- const reg = this.entities.getByTypeAndSlug("feat", site.slug);
1282
- if (!reg) continue;
1283
- const feat = reg.data;
1284
- spells.push(...collectFeatGrantedSpells(feat, site.read, this.entities, warnings));
1285
- }
1286
- for (const site of memberSites) {
1287
- const classSlug = stripSlug((_g = (_f = character.class[site.classIndex]) == null ? void 0 : _f.name) != null ? _g : null);
1288
- for (const ch of site.choices) {
1289
- if (ch.kind !== "select-entity" || ch.entity_type !== "spell" || isTargetChoice(ch)) continue;
1290
- const v = site.read(ch.id);
1291
- for (const ref of Array.isArray(v) ? v : typeof v === "string" ? [v] : []) {
1292
- const slug = typeof ref === "string" ? stripSlug(ref) : null;
1293
- if (!slug) continue;
1294
- const reg = this.entities.getByTypeAndSlug("spell", slug);
1295
- if (!reg) {
1296
- warnings.push(`Spell [[${slug}]] not found in compendium.`);
1297
- continue;
1298
- }
1299
- const entity = mirrorSpellShapes(reg.data);
1300
- spells.push({ entity, slug, classSlug, source: "class", prepared: true, alwaysPrepared: true });
1301
- }
1302
- }
1303
- }
1304
- const ownSpellcastingAbility = (_h = classes.map((c) => {
1305
- if (!c.entity) return null;
1306
- const p = resolveSpellcasting(c);
1307
- return p ? effectiveSpellcastingAbility(c.entity.slug, p.ability, character.overrides) : null;
1308
- }).find((a) => a != null)) != null ? _h : null;
1309
- spells.push(...collectItemGrantedSpells(character, ownSpellcastingAbility, this.entities, warnings));
1310
- spells.push(...collectAdditionalSpells({
1311
- race,
1312
- feats,
1313
- classes,
1314
- totalLevel,
1315
- ownAbility: ownSpellcastingAbility,
1316
- alreadyCollected: spells,
1317
- entities: this.entities,
1318
- warnings
1319
- }));
1320
- const chosenMasteries = collectChosenWeaponMasteries(character);
1321
- if (chosenMasteries.full.length > 0) {
1322
- const target = features.find(
1323
- (rf) => {
1324
- var _a2;
1325
- return rf.feature.id === "weapon-mastery" || ((_a2 = rf.feature.choices) == null ? void 0 : _a2.some(
1326
- (ch) => ch.kind === "select-entity" && ch.id === "weapon-mastery" && ch.entity_type === "weapon"
1327
- ));
1328
- }
1329
- );
1330
- if (target) {
1331
- const names = chosenMasteries.full.map(
1332
- (fullSlug) => {
1333
- var _a2, _b2;
1334
- return (_b2 = (_a2 = this.entities.getByTypeAndSlug("weapon", fullSlug)) == null ? void 0 : _a2.name) != null ? _b2 : fullSlug;
1335
- }
1336
- );
1337
- const entry = { label: "Mastered weapons", description: names.join(", ") };
1338
- target.chosenInline = target.chosenInline ? [...target.chosenInline, entry] : [entry];
1339
- }
1340
- }
1341
- const featureResources = resolveFeatureResources(features);
1342
- const resolvedCharacter = {
1343
- definition: character,
1344
- race,
1345
- classes,
1346
- background,
1347
- feats,
1348
- ...originFeatSlug ? { originFeatSlug } : {},
1349
- totalLevel,
1350
- features,
1351
- spells: dedupeResolvedSpells(spells),
1352
- pools: [],
1353
- resources: featureResources,
1354
- weaponMasteries: chosenMasteries.bare,
1355
- state: character.state
1356
- };
1357
- resolvedCharacter.pools = resolveAllPools(resolvedCharacter, this.entities, featureResources);
1358
- resolvedCharacter.resources = resolveResourceIndex(resolvedCharacter);
1359
- resolvedCharacter.features = bindFeatureConsumers(resolvedCharacter.features, resolvedCharacter.resources, classes);
1360
- const infusions = buildInfusionContext(character, resolvedCharacter, this.entities);
1361
- if (infusions) resolvedCharacter.infusions = infusions;
1362
- return { character: resolvedCharacter, warnings };
1363
- }
1364
- };
1365
- function collectChosenWeaponMasteries(character) {
1366
- var _a, _b;
1367
- const full = /* @__PURE__ */ new Set();
1368
- for (const cls of (_a = character.class) != null ? _a : []) {
1369
- for (const lvl of Object.values((_b = cls.choices) != null ? _b : {})) {
1370
- const pick = lvl["weapon-mastery"];
1371
- if (Array.isArray(pick)) {
1372
- for (const s of pick) if (typeof s === "string") full.add(s);
1373
- }
1374
- }
1375
- }
1376
- return { full: [...full], bare: [...new Set([...full].map(bareEntitySlug))] };
1377
- }
1378
- function collectFeatPicks(character) {
1379
- const picks = /* @__PURE__ */ new Map();
1380
- for (const site of featPickSites(character.class, [], () => null)) {
1381
- if (!picks.has(site.slug)) picks.set(site.slug, { slug: site.slug, classIndex: site.classIndex, level: site.level });
1382
- }
1383
- return [...picks.values()];
1384
- }
1385
- function collectFeatGrantedSpells(feat, read, entities, warnings) {
1386
- var _a;
1387
- const ability = readChosenSpellAbility(read);
1388
- const slugs = [];
1389
- collectSpellPickSlugs(feat.choices, read, slugs);
1390
- const out = [];
1391
- for (const rawSlug of slugs) {
1392
- const slug = (_a = stripSlug(rawSlug)) != null ? _a : rawSlug;
1393
- const reg = entities.getByTypeAndSlug("spell", slug);
1394
- if (!reg) {
1395
- warnings.push(`Feat spell [[${slug}]] not found in compendium.`);
1396
- continue;
1397
- }
1398
- const entity = mirrorSpellShapes(reg.data);
1399
- out.push({ entity, slug, classSlug: null, source: "feat", prepared: true, alwaysPrepared: true, ability });
1400
- }
1401
- return out;
1402
- }
1403
- function collectItemGrantedSpells(character, ownAbility, entities, warnings) {
1404
- var _a;
1405
- const out = [];
1406
- ((_a = character.equipment) != null ? _a : []).forEach((entry, entryIndex) => {
1407
- var _a2, _b, _c, _d, _e, _f;
1408
- const spellRef = (_a2 = entry.overrides) == null ? void 0 : _a2.spell;
1409
- if (!spellRef) return;
1410
- const { entity: itemEntity } = resolveEntityForEntry(entry.item, entities);
1411
- const scrollLevel = isItemEntity(itemEntity) ? itemEntity.scroll_level : void 0;
1412
- if (scrollLevel == null) return;
1413
- const slug = (_b = stripSlug(spellRef)) != null ? _b : spellRef;
1414
- const reg = entities.getByTypeAndSlug("spell", slug);
1415
- if (!reg) {
1416
- warnings.push(`Scroll spell [[${slug}]] not found in compendium.`);
1417
- return;
1418
- }
1419
- const entity = mirrorSpellShapes(reg.data);
1420
- const ability = (_f = (_d = (_c = entry.overrides) == null ? void 0 : _c.spell_ability) != null ? _d : ownAbility) != null ? _f : (_e = character.overrides) == null ? void 0 : _e.spellcasting_ability;
1421
- out.push({ entity, slug, classSlug: null, source: "item", prepared: true, alwaysPrepared: true, ability, entryIndex });
1422
- });
1423
- return out;
1424
- }
1425
- function dedupeResolvedSpells(spells) {
1426
- const byKey = /* @__PURE__ */ new Map();
1427
- for (const s of spells) {
1428
- const key = s.source === "item" ? `${s.slug}#${s.entryIndex}` : s.slug;
1429
- const existing = byKey.get(key);
1430
- if (!existing) {
1431
- byKey.set(key, s);
1432
- continue;
1433
- }
1434
- if (existing.source === "feat" && s.source !== "feat") {
1435
- byKey.set(key, { ...s, alwaysPrepared: s.alwaysPrepared || existing.alwaysPrepared, prepared: s.prepared || existing.alwaysPrepared, ...existing.persisted || s.persisted ? { persisted: true } : {} });
1436
- } else if (s.alwaysPrepared && !existing.alwaysPrepared) {
1437
- byKey.set(key, { ...existing, alwaysPrepared: true, prepared: true });
1438
- }
1439
- }
1440
- return [...byKey.values()];
1441
- }
1442
- function readChosenSpellAbility(read) {
1443
- const pick = read("spellcasting-ability");
1444
- return typeof pick === "string" && ABILITY_KEYS.includes(pick) ? pick : null;
1445
- }
1446
- function collectSpellPickSlugs(choices, read, out) {
1447
- for (const ch of choices != null ? choices : []) {
1448
- if (ch.kind === "select-entity" && ch.entity_type === "spell") {
1449
- const sel = read(ch.id);
1450
- const picks = Array.isArray(sel) ? sel : typeof sel === "string" ? [sel] : [];
1451
- for (const p of picks) if (typeof p === "string" && p.length > 0) out.push(p);
1452
- } else if (ch.kind === "select-inline") {
1453
- const sel = read(ch.id);
1454
- const branch = typeof sel === "string" ? ch.options.find((o) => o.value === sel) : void 0;
1455
- if (branch == null ? void 0 : branch.choices) collectSpellPickSlugs(branch.choices, read, out);
1456
- }
1457
- }
1458
- }
1459
- function collectChosenGrantedFeatures(character, classes, registry, race = null, background = null, memberSites = []) {
1460
- var _a, _b, _c, _d;
1461
- const out = [];
1462
- for (const site of memberSites) {
1463
- const classSlug = (_b = (_a = classes[site.classIndex]) == null ? void 0 : _a.entity) == null ? void 0 : _b.slug;
1464
- if (!classSlug) continue;
1465
- const at = {};
1466
- const grants = site.choices.filter((ch) => !isTargetChoice(ch));
1467
- for (const ch of grants) at[ch.id] = site.read(ch.id);
1468
- walkChoiceGrants(grants, at, (granted, suppress) => {
1469
- out.push({ feature: granted, source: { kind: "class", slug: classSlug, level: site.level }, ...suppress ? { renderSuppressed: true } : {} });
1470
- }, registry);
1471
- }
1472
- classes.forEach((c, i) => {
1473
- var _a2, _b2, _c2, _d2;
1474
- if (!c.entity) return;
1475
- const entity = c.entity;
1476
- const entry = character.class[i];
1477
- if (!entry) return;
1478
- for (const [lvlStr, atLevel] of Object.entries(entry.choices)) {
1479
- const lvl = Number(lvlStr);
1480
- if (!Number.isFinite(lvl) || lvl > entry.level) continue;
1481
- const features = (_b2 = ((_a2 = entity.features_by_level) != null ? _a2 : {})[lvl]) != null ? _b2 : [];
1482
- const subFeatures = c.subclass ? (_d2 = ((_c2 = c.subclass.features_by_level) != null ? _c2 : {})[lvl]) != null ? _d2 : [] : [];
1483
- for (const feature of [...features, ...subFeatures]) {
1484
- walkChoiceGrants(feature.choices, atLevel, (granted, suppress) => {
1485
- out.push({
1486
- feature: granted,
1487
- source: { kind: "class", slug: entity.slug, level: lvl },
1488
- ...suppress ? { renderSuppressed: true } : {}
1489
- });
1490
- }, registry);
1491
- }
1492
- }
1493
- });
1494
- const oc = (_c = character.origin_choices) != null ? _c : {};
1495
- const originAt = (ns) => {
1496
- const at = {};
1497
- for (const [key, val] of Object.entries(oc)) {
1498
- if (key.startsWith(`${ns}:`)) at[key.slice(ns.length + 1)] = val;
1499
- }
1500
- return at;
1501
- };
1502
- if (race) {
1503
- const atRace = originAt("race");
1504
- const emitRace = (granted, suppress) => {
1505
- out.push({
1506
- feature: granted,
1507
- source: { kind: "race", slug: race.slug },
1508
- ...suppress ? { renderSuppressed: true } : {}
1509
- });
1510
- };
1511
- walkChoiceGrants(race.choices, atRace, emitRace, registry);
1512
- for (const trait of (_d = race.traits) != null ? _d : []) {
1513
- walkChoiceGrants(trait.choices, atRace, emitRace, registry);
1514
- }
1515
- }
1516
- if (background) {
1517
- const atBg = originAt("background");
1518
- const emitBg = (granted, suppress) => {
1519
- out.push({
1520
- feature: granted,
1521
- source: { kind: "background", slug: background.slug },
1522
- ...suppress ? { renderSuppressed: true } : {}
1523
- });
1524
- };
1525
- walkChoiceGrants(background.choices, atBg, emitBg, registry);
1526
- if (background.feature) {
1527
- walkChoiceGrants(background.feature.choices, atBg, emitBg, registry);
1528
- }
1529
- }
1530
- return out;
1531
- }
1532
- function collectAdditionalFeatures(character, entities, warnings) {
1533
- var _a, _b, _c, _d, _e, _f, _g, _h;
1534
- const out = [];
1535
- for (const entry of (_a = character.additional_features) != null ? _a : []) {
1536
- const slug = (_b = stripSlug(entry)) != null ? _b : entry;
1537
- const reg = entities.getByTypeAndSlug("optional-feature", slug);
1538
- if (!reg) {
1539
- warnings.push(`Granted feature [[${slug}]] not found in compendium as optional-feature.`);
1540
- continue;
1541
- }
1542
- const d = reg.data;
1543
- const feature = {
1544
- id: (_c = d.slug) != null ? _c : slug,
1545
- name: (_d = d.name) != null ? _d : slug,
1546
- description: d.description,
1547
- ...((_e = d.effects) == null ? void 0 : _e.length) ? { effects: d.effects } : {},
1548
- ...d.action_cost ? { action: d.action_cost } : {},
1549
- ...d.passive !== void 0 ? { passive: d.passive } : {},
1550
- ...d.activatable !== void 0 ? { activatable: d.activatable } : {},
1551
- ...d.duration ? { duration: d.duration } : {},
1552
- ...d.consumes ? { consumes: d.consumes } : {}
1553
- };
1554
- const uses = d.uses;
1555
- if (uses) {
1556
- const maxFormula = String(uses.max);
1557
- if (isValidMaxFormula(maxFormula)) {
1558
- feature.resources = [{
1559
- id: (_f = d.slug) != null ? _f : slug,
1560
- name: (_g = d.name) != null ? _g : slug,
1561
- max_formula: maxFormula,
1562
- reset: uses.recharge,
1563
- ...((_h = uses.recovery) == null ? void 0 : _h.length) ? { recovery: uses.recovery } : {},
1564
- // Presentation rides the resource, so the band and the tab read one object.
1565
- ...d.rendering_hint ? { rendering_hint: d.rendering_hint } : {},
1566
- ...d.surface ? { surface: d.surface } : {}
1567
- }];
1568
- } else {
1569
- warnings.push(`Granted feature "${slug}" has a prose uses.max (${JSON.stringify(uses.max)}); no tracker.`);
1570
- }
1571
- }
1572
- out.push({ feature, source: { kind: "campaign", slug } });
1573
- }
1574
- return out;
1575
- }
1576
- function walkChoiceGrants(choices, atLevel, emit, registry) {
1577
- var _a, _b, _c, _d, _e;
1578
- for (const ch of choices != null ? choices : []) {
1579
- const sel = atLevel[ch.id];
1580
- if (ch.kind === "select-entity" && ch.entity_type === "optional-feature") {
1581
- const slugs = Array.isArray(sel) ? sel : typeof sel === "string" ? [sel] : [];
1582
- for (const slug of slugs) {
1583
- const reg = registry.getByTypeAndSlug("optional-feature", (_a = stripSlug(String(slug))) != null ? _a : String(slug));
1584
- if (!reg) continue;
1585
- const d = reg.data;
1586
- emit({
1587
- id: (_b = d.slug) != null ? _b : String(slug),
1588
- name: (_c = d.name) != null ? _c : String(slug),
1589
- description: d.description,
1590
- effects: d.effects,
1591
- ...d.action_cost ? { action: d.action_cost } : {}
1592
- });
1593
- }
1594
- }
1595
- if (ch.kind === "select-inline") {
1596
- const branch = typeof sel === "string" ? ch.options.find((o) => o.value === sel) : void 0;
1597
- if ((_d = branch == null ? void 0 : branch.effects) == null ? void 0 : _d.length) {
1598
- const wc = (_e = branch.choices) == null ? void 0 : _e.find(
1599
- (c) => c.kind === "select-entity" && c.entity_type === "weapon"
1600
- );
1601
- const picked = wc ? atLevel == null ? void 0 : atLevel[wc.id] : void 0;
1602
- const effects = branch.effects.map(
1603
- (e) => e.kind === "weapon-ability" && e.weapons === "chosen" && typeof picked === "string" ? { ...e, weapons: [bareEntitySlug(picked)] } : e
1604
- );
1605
- emit({ id: `${ch.id}-${branch.value}`, name: branch.label, description: branch.description, effects }, true);
1606
- }
1607
- if (branch == null ? void 0 : branch.choices) walkChoiceGrants(branch.choices, atLevel, emit, registry);
1608
- }
1609
- }
1610
- }
1611
- function resolveChosenInline(feature, atLevel) {
1612
- var _a;
1613
- if (!atLevel) return void 0;
1614
- const picks = [];
1615
- for (const ch of (_a = feature.choices) != null ? _a : []) {
1616
- if (ch.kind !== "select-inline") continue;
1617
- const sel = atLevel[ch.id];
1618
- if (typeof sel !== "string") continue;
1619
- const opt = ch.options.find((o) => o.value === sel);
1620
- if (!opt) continue;
1621
- picks.push({ label: opt.label, description: opt.description });
1622
- }
1623
- return picks.length ? picks : void 0;
1624
- }
1625
- function isAsiSlotFeature(feature) {
1626
- var _a, _b, _c, _d;
1627
- return feature.id === "ability-score-improvement" && !((_a = feature.effects) != null ? _a : []).some((e) => !(e.kind === "ability-score-increase" && e.abilities === "chosen")) && !((_b = feature.resources) == null ? void 0 : _b.length) && !feature.action && !((_c = feature.sub_features) == null ? void 0 : _c.length) && !((_d = feature.attacks) == null ? void 0 : _d.length);
1628
- }
1629
- function foldRepeated(list) {
1630
- const byId = /* @__PURE__ */ new Map();
1631
- for (const rf of list) {
1632
- const id = rf.feature.id;
1633
- if (!id || rf.buildOnly) continue;
1634
- const arr = byId.get(id);
1635
- if (arr) arr.push(rf);
1636
- else byId.set(id, [rf]);
1637
- }
1638
- const out = [];
1639
- for (const rf of list) {
1640
- if (!rf.feature.id || rf.buildOnly) {
1641
- out.push(rf);
1642
- continue;
1643
- }
1644
- const arr = byId.get(rf.feature.id);
1645
- if (!arr || arr.length === 1) {
1646
- out.push(rf);
1647
- continue;
1648
- }
1649
- const sorted = [...arr].sort((a, b) => a.source.level - b.source.level);
1650
- const top = sorted[sorted.length - 1];
1651
- if (rf !== top) continue;
1652
- const effects = sorted.flatMap((c) => {
1653
- var _a;
1654
- return (_a = c.feature.effects) != null ? _a : [];
1655
- });
1656
- const seen = /* @__PURE__ */ new Set();
1657
- const resources = sorted.flatMap((c) => {
1658
- var _a;
1659
- return ((_a = c.feature.resources) != null ? _a : []).filter((r) => !seen.has(r.id) && seen.add(r.id));
1660
- });
1661
- const chosenInline = sorted.flatMap((c) => c.chosenInline ? [c.chosenInline] : []);
1662
- const cardProse = (f) => {
1663
- var _a, _b;
1664
- return (_b = f.description) != null ? _b : ((_a = f.entries) == null ? void 0 : _a.length) ? f.entries.join("\n\n") : void 0;
1665
- };
1666
- const foldedFrom = sorted.slice(0, -1).map((c) => {
1667
- var _a;
1668
- return {
1669
- level: c.source.level,
1670
- name: c.feature.name,
1671
- ...cardProse(c.feature) ? { description: cardProse(c.feature) } : {},
1672
- ...((_a = c.feature.choices) == null ? void 0 : _a.length) ? { choices: c.feature.choices } : {}
1673
- };
1674
- });
1675
- out.push({
1676
- ...top,
1677
- feature: { ...top.feature, ...effects.length ? { effects } : {}, ...resources.length ? { resources } : {} },
1678
- ...chosenInline.length ? { chosenInline: chosenInline.flat() } : {},
1679
- ...foldedFrom.length ? { foldedFrom } : {}
1680
- });
1681
- }
1682
- return out;
1683
- }
1684
- function collectResolvedFeatures(race, classes, background, feats, featVia = /* @__PURE__ */ new Map()) {
1685
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
1686
- const out = [];
1687
- for (const c of classes) {
1688
- if (!c.entity) continue;
1689
- const slug = c.entity.slug;
1690
- const byLevel = (_a = c.entity.features_by_level) != null ? _a : {};
1691
- const classFeatures = [];
1692
- const subclassFeatures = [];
1693
- for (const [lvlStr, feats0] of Object.entries(byLevel)) {
1694
- const lvl = parseInt(lvlStr, 10);
1695
- if (Number.isNaN(lvl) || lvl > c.level) continue;
1696
- for (const feat of feats0) {
1697
- const chosenInline = resolveChosenInline(feat, (_b = c.choices) == null ? void 0 : _b[lvl]);
1698
- const feature = withResolvedActionCost(feat);
1699
- classFeatures.push({
1700
- feature,
1701
- source: { kind: "class", slug, level: lvl },
1702
- ...chosenInline ? { chosenInline } : {},
1703
- ...isAsiSlotFeature(feature) ? { buildOnly: true } : {}
1704
- });
1705
- }
1706
- }
1707
- if (c.subclass) {
1708
- const sSlug = c.subclass.slug;
1709
- const sByLevel = (_c = c.subclass.features_by_level) != null ? _c : {};
1710
- for (const [lvlStr, feats0] of Object.entries(sByLevel)) {
1711
- const lvl = parseInt(lvlStr, 10);
1712
- if (Number.isNaN(lvl) || lvl > c.level) continue;
1713
- for (const feat of feats0) {
1714
- const chosenInline = resolveChosenInline(feat, (_d = c.choices) == null ? void 0 : _d[lvl]);
1715
- const feature = withResolvedActionCost(feat);
1716
- subclassFeatures.push({
1717
- feature,
1718
- source: { kind: "subclass", slug: sSlug, level: lvl },
1719
- ...chosenInline ? { chosenInline } : {},
1720
- ...isAsiSlotFeature(feature) ? { buildOnly: true } : {}
1721
- });
1722
- }
1723
- }
1724
- }
1725
- const foldedClass = foldRepeated(classFeatures);
1726
- const foldedSubclass = foldRepeated(subclassFeatures);
1727
- out.push(...foldedClass);
1728
- if ((_e = c.entity.resources) == null ? void 0 : _e.length) {
1729
- out.push({
1730
- feature: { name: c.entity.name, resources: c.entity.resources },
1731
- source: { kind: "class", slug, level: 1 }
1732
- });
1733
- }
1734
- out.push(...foldedSubclass);
1735
- if ((_g = (_f = c.subclass) == null ? void 0 : _f.resources) == null ? void 0 : _g.length) {
1736
- out.push({
1737
- feature: { name: c.subclass.name, resources: c.subclass.resources },
1738
- source: { kind: "subclass", slug: c.subclass.slug, level: 1 }
1739
- });
1740
- }
1741
- }
1742
- if (race) {
1743
- const traits = (_h = race.traits) != null ? _h : [];
1744
- for (const feat of traits) {
1745
- out.push({ feature: withResolvedActionCost(feat), source: { kind: "race", slug: race.slug } });
1746
- }
1747
- }
1748
- if (background) {
1749
- const bgFeature = background.feature;
1750
- if (bgFeature) {
1751
- out.push({ feature: withResolvedActionCost(bgFeature), source: { kind: "background", slug: background.slug } });
1752
- }
1753
- }
1754
- for (const feat of feats) {
1755
- const via = featVia.get(feat.slug);
1756
- const featSource = { kind: "feat", slug: feat.slug, ...via ? { via } : {} };
1757
- const bundled = (_i = feat.features) != null ? _i : [];
1758
- const entityEffects = (_j = feat.effects) != null ? _j : [];
1759
- if (bundled.length > 0) {
1760
- bundled.forEach((f, i) => {
1761
- var _a2, _b2;
1762
- const feature = i === 0 ? { ...f, action: (_a2 = f.action) != null ? _a2 : feat.action_cost, ...entityEffects.length > 0 ? { effects: [...(_b2 = f.effects) != null ? _b2 : [], ...entityEffects] } : {} } : f;
1763
- out.push({ feature, source: featSource });
1764
- });
1765
- } else {
1766
- const name = (_k = feat.name) != null ? _k : feat.slug;
1767
- const foldedDesc = [feat.description, ...(_l = feat.benefits) != null ? _l : []].filter(Boolean).join("\n\n") || void 0;
1768
- const buildOnly = ((_m = feat.choices) != null ? _m : []).some((c) => c.kind === "ability-points" && c.points >= 2) && !((_n = feat.effects) == null ? void 0 : _n.length) && !((_o = feat.resources) == null ? void 0 : _o.length) && bundled.length === 0;
1769
- out.push({
1770
- feature: {
1771
- name,
1772
- ...foldedDesc ? { description: foldedDesc } : {},
1773
- ...feat.resources ? { resources: feat.resources } : {},
1774
- // R4-G3a §10.2.3: a feat's ENTITY-level action cost (SRD 2024 Boon of the Night Spirit)
1775
- // reaches the synthesized feature, so the row routes off Passive onto its own economy.
1776
- ...feat.action_cost ? { action: feat.action_cost } : {},
1777
- ...entityEffects.length > 0 ? { effects: entityEffects } : {}
1778
- },
1779
- source: featSource,
1780
- ...buildOnly ? { buildOnly: true } : {}
1781
- });
1782
- }
1783
- }
1784
- return out;
1785
- }
1786
-
1787
- export {
1788
- stripSlug,
1789
- resolveOriginFeat,
1790
- PCResolver,
1791
- collectChosenWeaponMasteries,
1792
- collectFeatPicks,
1793
- collectFeatGrantedSpells,
1794
- collectItemGrantedSpells,
1795
- dedupeResolvedSpells,
1796
- collectChosenGrantedFeatures,
1797
- collectAdditionalFeatures,
1798
- collectResolvedFeatures,
1799
- collectProficiencyGrants,
1800
- __matchesFilterForTest,
1801
- __categoryToEntitySelectForTest,
1802
- collectChosenProficiencies,
1803
- computeEffectiveProficiencies,
1804
- collectChosenAbilityPoints,
1805
- buildDecisionLedger
1806
- };