@archivist-gg/dnd5e 0.3.19 → 0.3.26

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 (441) 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-2NUDWOFG.js +1 -0
  16. package/dist/chunk-3LWOVRLA.js +1 -0
  17. package/dist/chunk-3QQOATV3.js +1 -0
  18. package/dist/chunk-4E2GIWJE.js +1 -0
  19. package/dist/chunk-4GN3GYMP.js +1 -0
  20. package/dist/chunk-4IAMSRHD.js +1 -0
  21. package/dist/chunk-4JEF3CET.js +1 -0
  22. package/dist/chunk-4KVVAENP.js +1 -0
  23. package/dist/chunk-4SYAKWY4.js +1 -0
  24. package/dist/chunk-56JK6VCL.js +1 -0
  25. package/dist/chunk-5XDCM6YK.js +1 -0
  26. package/dist/chunk-63YJPWTM.js +1 -0
  27. package/dist/chunk-6R46KYGU.js +1 -0
  28. package/dist/chunk-6W253VHH.js +1 -0
  29. package/dist/chunk-72PRMZRD.js +1 -0
  30. package/dist/chunk-757KM22B.js +1 -0
  31. package/dist/chunk-7EL3GWWJ.js +1 -0
  32. package/dist/chunk-7FPQJDFD.js +1 -0
  33. package/dist/chunk-AINRPPLH.js +1 -0
  34. package/dist/chunk-BC52J4LA.js +1 -0
  35. package/dist/chunk-BCXGB4HP.js +1 -0
  36. package/dist/chunk-BREHZNTL.js +1 -0
  37. package/dist/chunk-BZ6BGGZS.js +1 -0
  38. package/dist/chunk-CAPYNIGK.js +1 -0
  39. package/dist/chunk-CCAVZANF.js +1 -0
  40. package/dist/chunk-CCFIINBA.js +1 -0
  41. package/dist/chunk-CEHL7PPC.js +1 -0
  42. package/dist/chunk-CMIEZQL4.js +1 -0
  43. package/dist/chunk-CNMHADNV.js +1 -0
  44. package/dist/chunk-CSTAQQGX.js +1 -0
  45. package/dist/chunk-DTB7YBMZ.js +1 -0
  46. package/dist/chunk-DVUXUIPV.js +1 -0
  47. package/dist/chunk-DZITM5AG.js +1 -0
  48. package/dist/chunk-E3MS4M3N.js +1 -0
  49. package/dist/chunk-E7KFJLDR.js +1 -0
  50. package/dist/chunk-EAARMPCW.js +1 -0
  51. package/dist/chunk-EPA24PVZ.js +1 -0
  52. package/dist/chunk-ETDMOGFO.js +1 -0
  53. package/dist/chunk-EVT7MGAC.js +1 -0
  54. package/dist/chunk-FOLHTMSC.js +1 -0
  55. package/dist/chunk-GCYUCIDN.js +1 -0
  56. package/dist/chunk-GD7WRCNH.js +1 -0
  57. package/dist/chunk-GGQDQSIF.js +1 -0
  58. package/dist/chunk-GIQLIBC7.js +1 -0
  59. package/dist/chunk-HX7WBOKR.js +1 -0
  60. package/dist/chunk-I26FHSI6.js +1 -0
  61. package/dist/chunk-IHPLT2ZT.js +1 -0
  62. package/dist/chunk-J3RP5C7L.js +1 -0
  63. package/dist/chunk-J5GL6FLP.js +1 -0
  64. package/dist/chunk-JXDX2DKF.js +1 -0
  65. package/dist/chunk-KEXSF3CH.js +1 -0
  66. package/dist/chunk-KM75CC6Q.js +1 -0
  67. package/dist/chunk-L2DXF7YS.js +1 -0
  68. package/dist/chunk-LHH5XSEA.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-MGGKZGLG.js +1 -0
  73. package/dist/chunk-NEMX7QGG.js +1 -0
  74. package/dist/chunk-NIWLD33X.js +1 -0
  75. package/dist/chunk-NU2Z7MTS.js +1 -0
  76. package/dist/chunk-NYPH7RQN.js +1 -0
  77. package/dist/chunk-NYTR6NJS.js +1 -0
  78. package/dist/chunk-O2QZ73GA.js +1 -0
  79. package/dist/chunk-O776WL7O.js +1 -0
  80. package/dist/chunk-ONCXJMJM.js +1 -0
  81. package/dist/chunk-OTRH62HY.js +1 -0
  82. package/dist/chunk-PFQPP77Q.js +1 -0
  83. package/dist/chunk-PKIMOVQG.js +1 -0
  84. package/dist/chunk-PZ3ZZ5H5.js +1 -0
  85. package/dist/chunk-PZ4L2EEG.js +1 -0
  86. package/dist/chunk-QMEKQTUT.js +1 -0
  87. package/dist/chunk-QVWT67WA.js +1 -0
  88. package/dist/chunk-RE5Z5RNK.js +1 -0
  89. package/dist/chunk-RHIEOYDX.js +1 -0
  90. package/dist/chunk-RQZCGXUZ.js +1 -0
  91. package/dist/chunk-S5UCI27C.js +1 -0
  92. package/dist/chunk-SEOASDO4.js +1 -0
  93. package/dist/chunk-SFK57JAA.js +1 -0
  94. package/dist/chunk-SU4MEZ5P.js +1 -0
  95. package/dist/chunk-T55DELVL.js +1 -0
  96. package/dist/chunk-TKIEPC6F.js +1 -0
  97. package/dist/chunk-UBUKCRZ3.js +1 -0
  98. package/dist/chunk-VA3ZWV7C.js +1 -0
  99. package/dist/chunk-VIP3FH2O.js +1 -0
  100. package/dist/chunk-VTQ4RWEG.js +1 -0
  101. package/dist/chunk-VVJXZZ4Z.js +1 -0
  102. package/dist/chunk-WAUNLUFQ.js +1 -0
  103. package/dist/chunk-X22SISGM.js +1 -0
  104. package/dist/chunk-XKJXT2PN.js +1 -0
  105. package/dist/chunk-XPF53K54.js +1 -0
  106. package/dist/chunk-YGH7S5ZF.js +1 -0
  107. package/dist/chunk-ZE46ADXS.js +1 -0
  108. package/dist/chunk-ZI3FEUX3.js +1 -0
  109. package/dist/chunk-ZS5BMNXC.js +1 -0
  110. package/dist/chunk-ZVL5FXXO.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 +4 -3
  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 +3 -30
  128. package/dist/dnd/amount-text.js +1 -15
  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 +0 -15
  151. package/dist/entities/registry-revision.js +1 -10
  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 +46 -4
  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 -141495
  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 +5 -0
  182. package/dist/item/item.schema.js +1 -11
  183. package/dist/item/item.types.d.ts +5 -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 +44 -3
  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 +0 -24
  205. package/dist/pc/pc.additional-spells.js +1 -26
  206. package/dist/pc/pc.amount-bindings.d.ts +3 -28
  207. package/dist/pc/pc.amount-bindings.js +1 -28
  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 +6 -145
  215. package/dist/pc/pc.decision-engine.js +1 -55
  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 +19 -58
  219. package/dist/pc/pc.entry-overrides.js +1 -41
  220. package/dist/pc/pc.equipment.d.ts +2 -22
  221. package/dist/pc/pc.equipment.js +1 -34
  222. package/dist/pc/pc.feature-effects.d.ts +27 -281
  223. package/dist/pc/pc.feature-effects.js +1 -39
  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 -65
  227. package/dist/pc/pc.item-effects.d.ts +19 -0
  228. package/dist/pc/pc.item-effects.js +1 -0
  229. package/dist/pc/pc.member-choices.d.ts +3 -66
  230. package/dist/pc/pc.member-choices.js +1 -39
  231. package/dist/pc/pc.parser.js +1 -58
  232. package/dist/pc/pc.pools.d.ts +7 -10
  233. package/dist/pc/pc.pools.js +1 -27
  234. package/dist/pc/pc.proficiencies.d.ts +0 -40
  235. package/dist/pc/pc.proficiencies.js +1 -156
  236. package/dist/pc/pc.proficiency-grants.d.ts +3 -27
  237. package/dist/pc/pc.proficiency-normalize.d.ts +0 -35
  238. package/dist/pc/pc.proficiency-normalize.js +1 -18
  239. package/dist/pc/pc.proficiency-query.d.ts +0 -13
  240. package/dist/pc/pc.proficiency-query.js +1 -27
  241. package/dist/pc/pc.recalc.d.ts +8 -131
  242. package/dist/pc/pc.recalc.js +1 -1042
  243. package/dist/pc/pc.resolver.d.ts +9 -107
  244. package/dist/pc/pc.resolver.js +1 -60
  245. package/dist/pc/pc.resource-seed.d.ts +0 -8
  246. package/dist/pc/pc.resource-seed.js +1 -42
  247. package/dist/pc/pc.resources.d.ts +1 -59
  248. package/dist/pc/pc.resources.js +1 -23
  249. package/dist/pc/pc.rest.d.ts +1 -20
  250. package/dist/pc/pc.rest.js +1 -231
  251. package/dist/pc/pc.schema.d.ts +20 -2
  252. package/dist/pc/pc.schema.js +1 -9
  253. package/dist/pc/pc.slotting.d.ts +0 -29
  254. package/dist/pc/pc.slotting.js +1 -28
  255. package/dist/pc/pc.speeds.d.ts +36 -0
  256. package/dist/pc/pc.spell-scope.d.ts +0 -16
  257. package/dist/pc/pc.spellcasting.d.ts +0 -70
  258. package/dist/pc/pc.spellcasting.js +1 -28
  259. package/dist/pc/pc.table-column.d.ts +3 -22
  260. package/dist/pc/pc.table-column.js +1 -18
  261. package/dist/pc/pc.tool-picks.d.ts +0 -27
  262. package/dist/pc/pc.tool-picks.js +1 -18
  263. package/dist/pc/pc.types.d.ts +59 -374
  264. package/dist/pc/pc.weapon-grant.d.ts +0 -6
  265. package/dist/pc/pool-layout.d.ts +0 -39
  266. package/dist/pc/pool-layout.js +1 -18
  267. package/dist/pc/resource-equivalents.d.ts +2 -40
  268. package/dist/pc/roll-scope.js +1 -8
  269. package/dist/pc/roll-tag-labels.d.ts +0 -32
  270. package/dist/pc/roll-tag-labels.js +1 -17
  271. package/dist/pc/spell-source.d.ts +0 -11
  272. package/dist/pc/spell-source.js +1 -8
  273. package/dist/race/race.codec.d.ts +0 -6
  274. package/dist/race/race.codec.js +1 -15
  275. package/dist/race/race.parser.js +1 -14
  276. package/dist/race/race.schema.d.ts +0 -8
  277. package/dist/race/race.schema.js +1 -14
  278. package/dist/race/race.structural.d.ts +0 -6
  279. package/dist/race/race.structural.js +1 -6
  280. package/dist/race/race.types.d.ts +0 -8
  281. package/dist/schemas/attack-schema.d.ts +5 -0
  282. package/dist/schemas/caster-type-schema.d.ts +1 -6
  283. package/dist/schemas/caster-type-schema.js +1 -6
  284. package/dist/schemas/choice-schema.js +1 -7
  285. package/dist/schemas/duration-schema.d.ts +0 -2
  286. package/dist/schemas/duration-schema.js +1 -6
  287. package/dist/schemas/entity-extras-schema.d.ts +0 -30
  288. package/dist/schemas/entity-extras-schema.js +1 -10
  289. package/dist/schemas/equipment-grant-schema.d.ts +0 -2
  290. package/dist/schemas/equipment-grant-schema.js +1 -12
  291. package/dist/schemas/feature-alias.d.ts +0 -27
  292. package/dist/schemas/feature-effect-schema.d.ts +44 -3
  293. package/dist/schemas/feature-effect-schema.js +1 -6
  294. package/dist/schemas/feature-schema.d.ts +0 -6
  295. package/dist/schemas/feature-schema.js +1 -12
  296. package/dist/schemas/resource-schema.d.ts +1 -34
  297. package/dist/schemas/resource-schema.js +1 -12
  298. package/dist/schemas/selection-pool-schema.js +1 -10
  299. package/dist/spell/casting-time.d.ts +0 -15
  300. package/dist/spell/casting-time.js +1 -6
  301. package/dist/spell/spell.access.d.ts +0 -6
  302. package/dist/spell/spell.access.js +1 -45
  303. package/dist/spell/spell.ai-schema.js +1 -6
  304. package/dist/spell/spell.codec.js +1 -9
  305. package/dist/spell/spell.enrichment.js +1 -9
  306. package/dist/spell/spell.filter.d.ts +0 -5
  307. package/dist/spell/spell.filter.js +1 -75
  308. package/dist/spell/spell.parser.d.ts +0 -31
  309. package/dist/spell/spell.parser.js +1 -16
  310. package/dist/spell/spell.scaling.d.ts +0 -46
  311. package/dist/spell/spell.scaling.js +1 -79
  312. package/dist/spell/spell.schema.js +1 -7
  313. package/dist/spell/spell.types.d.ts +0 -7
  314. package/dist/srd/retired-items.d.ts +0 -4
  315. package/dist/srd/retired-items.js +1 -11
  316. package/dist/srd-store.d.ts +0 -33
  317. package/dist/subclass/subclass.codec.d.ts +0 -8
  318. package/dist/subclass/subclass.codec.js +1 -17
  319. package/dist/subclass/subclass.parser.js +1 -16
  320. package/dist/subclass/subclass.schema.d.ts +2 -1
  321. package/dist/subclass/subclass.schema.js +1 -14
  322. package/dist/subclass/subclass.types.d.ts +0 -3
  323. package/dist/types/attack.d.ts +2 -0
  324. package/dist/types/casting-option.d.ts +0 -4
  325. package/dist/types/choice.d.ts +1 -72
  326. package/dist/types/choice.js +1 -24
  327. package/dist/types/edition.d.ts +0 -3
  328. package/dist/types/equipment-grant.d.ts +1 -27
  329. package/dist/types/equipment-grant.js +1 -12
  330. package/dist/types/feature-effect.d.ts +11 -23
  331. package/dist/types/feature.d.ts +0 -22
  332. package/dist/types/optional-feature.types.d.ts +1 -31
  333. package/dist/types/resource.d.ts +1 -21
  334. package/dist/types/selection-pool.d.ts +0 -24
  335. package/dist/weapon/weapon-mastery.d.ts +0 -1
  336. package/dist/weapon/weapon.classify.d.ts +0 -11
  337. package/dist/weapon/weapon.classify.js +1 -7
  338. package/dist/weapon/weapon.codec.d.ts +0 -9
  339. package/dist/weapon/weapon.codec.js +1 -9
  340. package/dist/weapon/weapon.parser.js +1 -8
  341. package/dist/weapon/weapon.schema.js +1 -7
  342. package/dist/weapon/weapon.types.d.ts +0 -3
  343. package/package.json +3 -3
  344. package/src/data-srd/ATTRIBUTION.md +1 -1
  345. package/dist/chunk-2FRUSVZS.js +0 -489
  346. package/dist/chunk-2LULMQTF.js +0 -14
  347. package/dist/chunk-3LWMFYKS.js +0 -57
  348. package/dist/chunk-3SFGWFVQ.js +0 -19
  349. package/dist/chunk-3SIUAFDQ.js +0 -18
  350. package/dist/chunk-3TM34RSJ.js +0 -23
  351. package/dist/chunk-4J6DS3EJ.js +0 -30
  352. package/dist/chunk-4U55VNC7.js +0 -22
  353. package/dist/chunk-5GKJAUMX.js +0 -59
  354. package/dist/chunk-5JXFJ5AU.js +0 -26
  355. package/dist/chunk-64VNLMSG.js +0 -375
  356. package/dist/chunk-656QCX4U.js +0 -22
  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-7Q2VPKCD.js +0 -181
  361. package/dist/chunk-7XJHI5H5.js +0 -709
  362. package/dist/chunk-A54HHCWW.js +0 -67
  363. package/dist/chunk-B2QHP6UF.js +0 -159
  364. package/dist/chunk-B3DP42OM.js +0 -55
  365. package/dist/chunk-BJGOSM76.js +0 -18
  366. package/dist/chunk-BJWSOQUC.js +0 -133
  367. package/dist/chunk-CJYCVNW2.js +0 -7
  368. package/dist/chunk-CM5CWO4K.js +0 -735
  369. package/dist/chunk-DEEHHLAP.js +0 -271
  370. package/dist/chunk-DPUJDOKV.js +0 -365
  371. package/dist/chunk-EJD47JHL.js +0 -1838
  372. package/dist/chunk-EJP263OP.js +0 -186
  373. package/dist/chunk-EVMUJYUD.js +0 -195
  374. package/dist/chunk-EYX4JMAU.js +0 -101
  375. package/dist/chunk-FC4IGH5Y.js +0 -18
  376. package/dist/chunk-FJYBLXV7.js +0 -89
  377. package/dist/chunk-FMUD3LDV.js +0 -19
  378. package/dist/chunk-FMYWORTP.js +0 -93
  379. package/dist/chunk-FVXLP7P3.js +0 -18
  380. package/dist/chunk-G6MHJDVT.js +0 -41
  381. package/dist/chunk-GVWEFECG.js +0 -18
  382. package/dist/chunk-HHBD4SQ6.js +0 -24
  383. package/dist/chunk-HS6FIOLP.js +0 -52
  384. package/dist/chunk-HY2SRSVM.js +0 -23
  385. package/dist/chunk-IHE6KVC3.js +0 -13
  386. package/dist/chunk-IN4M4X7P.js +0 -34
  387. package/dist/chunk-IUAAXXNO.js +0 -58
  388. package/dist/chunk-JXWNXIIZ.js +0 -219
  389. package/dist/chunk-K5NJBTE2.js +0 -18
  390. package/dist/chunk-KR6JF3BF.js +0 -14
  391. package/dist/chunk-KSTV7J2U.js +0 -112
  392. package/dist/chunk-KU3YLF6D.js +0 -106
  393. package/dist/chunk-LBEXLN6I.js +0 -91
  394. package/dist/chunk-LHZXYFBU.js +0 -94
  395. package/dist/chunk-LICYHPI3.js +0 -237
  396. package/dist/chunk-LNT64X7C.js +0 -81
  397. package/dist/chunk-LSLSG67V.js +0 -31
  398. package/dist/chunk-LVQLWRCU.js +0 -15
  399. package/dist/chunk-MYY2C5MB.js +0 -233
  400. package/dist/chunk-NKZMQV2C.js +0 -19
  401. package/dist/chunk-NTU2DXNG.js +0 -355
  402. package/dist/chunk-NXUY5XQN.js +0 -1062
  403. package/dist/chunk-NZO7M5GV.js +0 -18
  404. package/dist/chunk-OOL4KMG2.js +0 -71
  405. package/dist/chunk-OOSRUJBI.js +0 -19
  406. package/dist/chunk-PDJSUH24.js +0 -110
  407. package/dist/chunk-PTXBIDG7.js +0 -63
  408. package/dist/chunk-PVCEA4HZ.js +0 -6
  409. package/dist/chunk-QA3YCOML.js +0 -101
  410. package/dist/chunk-QFWQKS3M.js +0 -110
  411. package/dist/chunk-QS5L5YTJ.js +0 -24
  412. package/dist/chunk-QYZV2MQA.js +0 -97
  413. package/dist/chunk-RD2MID3M.js +0 -292
  414. package/dist/chunk-S3YUXDSC.js +0 -278
  415. package/dist/chunk-S7REMWW4.js +0 -21
  416. package/dist/chunk-TOM66P2P.js +0 -38
  417. package/dist/chunk-TRBGC4ZG.js +0 -112
  418. package/dist/chunk-UA5KS2PL.js +0 -26
  419. package/dist/chunk-UJCK5IW4.js +0 -187
  420. package/dist/chunk-UNYR5GLI.js +0 -23
  421. package/dist/chunk-UZXG6QSY.js +0 -58
  422. package/dist/chunk-VN5DLURA.js +0 -158
  423. package/dist/chunk-VP5TIXDK.js +0 -178
  424. package/dist/chunk-VPYBK2MG.js +0 -18
  425. package/dist/chunk-VTTA2ALZ.js +0 -16
  426. package/dist/chunk-W6GC6OKK.js +0 -16
  427. package/dist/chunk-WELIKLZF.js +0 -256
  428. package/dist/chunk-WOHX7YTH.js +0 -165
  429. package/dist/chunk-WSVMLNTO.js +0 -31
  430. package/dist/chunk-WYGD2UGN.js +0 -14
  431. package/dist/chunk-XCFC7LGF.js +0 -122
  432. package/dist/chunk-XJ2F2WO6.js +0 -8
  433. package/dist/chunk-XTEFPUSN.js +0 -23
  434. package/dist/chunk-YBLDE5CG.js +0 -42
  435. package/dist/chunk-YDGMBMYI.js +0 -25
  436. package/dist/chunk-YHYTW5QA.js +0 -20
  437. package/dist/chunk-ZCTUYGNV.js +0 -26
  438. package/dist/chunk-ZDAEGJH4.js +0 -102
  439. package/dist/chunk-ZJXSXVFP.js +0 -58
  440. package/dist/chunk-ZOWKWMD2.js +0 -18
  441. package/dist/chunk-ZUQW5VBZ.js +0 -89
@@ -1,1042 +1 @@
1
- import {
2
- buildUnarmedRow,
3
- computeAppliedBonuses,
4
- computeSlotsAndAttacks,
5
- emptyAppliedBonuses
6
- } from "../chunk-7XJHI5H5.js";
7
- import "../chunk-3LWMFYKS.js";
8
- import "../chunk-YDGMBMYI.js";
9
- import {
10
- amountBindingsFor
11
- } from "../chunk-TRBGC4ZG.js";
12
- import "../chunk-KR6JF3BF.js";
13
- import {
14
- computeConditionEffects
15
- } from "../chunk-MYY2C5MB.js";
16
- import "../chunk-EJP263OP.js";
17
- import {
18
- collectChosenAbilityPoints,
19
- collectChosenProficiencies
20
- } from "../chunk-EJD47JHL.js";
21
- import "../chunk-2LULMQTF.js";
22
- import "../chunk-QA3YCOML.js";
23
- import {
24
- assembleEffectFeatures,
25
- computeFeatureEffects,
26
- foldsNow,
27
- selfEffectsOf
28
- } from "../chunk-64VNLMSG.js";
29
- import "../chunk-TOM66P2P.js";
30
- import "../chunk-KU3YLF6D.js";
31
- import {
32
- proficiencyKey
33
- } from "../chunk-5JXFJ5AU.js";
34
- import {
35
- featPickSites,
36
- poolMemberSitesOf,
37
- spellsReached
38
- } from "../chunk-RD2MID3M.js";
39
- import "../chunk-LICYHPI3.js";
40
- import "../chunk-PVCEA4HZ.js";
41
- import {
42
- resourceLevelFor
43
- } from "../chunk-KSTV7J2U.js";
44
- import {
45
- computeSpellLimits,
46
- deriveSpellSlots,
47
- effectiveSpellcastingAbility,
48
- resolveSpellcasting
49
- } from "../chunk-DPUJDOKV.js";
50
- import {
51
- legacyAsiBranch
52
- } from "../chunk-LBEXLN6I.js";
53
- import {
54
- toDefenseSlug
55
- } from "../chunk-XJ2F2WO6.js";
56
- import "../chunk-NXUY5XQN.js";
57
- import "../chunk-W6GC6OKK.js";
58
- import "../chunk-B3DP42OM.js";
59
- import {
60
- diceColumnAt,
61
- unarmedDieColumnFor
62
- } from "../chunk-IUAAXXNO.js";
63
- import "../chunk-YHYTW5QA.js";
64
- import "../chunk-ZUQW5VBZ.js";
65
- import "../chunk-IHE6KVC3.js";
66
- import "../chunk-HHBD4SQ6.js";
67
- import "../chunk-A54HHCWW.js";
68
- import "../chunk-LHZXYFBU.js";
69
- import "../chunk-YBLDE5CG.js";
70
- import "../chunk-LVQLWRCU.js";
71
- import "../chunk-CM5CWO4K.js";
72
- import "../chunk-4J6DS3EJ.js";
73
- import {
74
- resolveAmountText
75
- } from "../chunk-WOHX7YTH.js";
76
- import "../chunk-EVMUJYUD.js";
77
- import "../chunk-VTTA2ALZ.js";
78
- import {
79
- bareEntitySlug,
80
- slugify
81
- } from "../chunk-ZCTUYGNV.js";
82
- import "../chunk-7Q2VPKCD.js";
83
- import "../chunk-ZDAEGJH4.js";
84
- import "../chunk-3TM34RSJ.js";
85
- import {
86
- abilityModifier,
87
- attackBonus,
88
- isCanonicalDamageType,
89
- isChosenDamageType,
90
- proficiencyFromLevel,
91
- saveDC,
92
- savingThrow,
93
- skillBonus
94
- } from "../chunk-PDJSUH24.js";
95
- import {
96
- ABILITY_KEYS,
97
- ALL_SKILLS,
98
- SKILL_ABILITY
99
- } from "../chunk-WELIKLZF.js";
100
- import "../chunk-4U55VNC7.js";
101
- import "../chunk-UA5KS2PL.js";
102
-
103
- // src/pc/pc.spell-scope.ts
104
- var lower = (s) => (s != null ? s : "").trim().toLowerCase();
105
- function namedSpellSlug(ref) {
106
- var _a;
107
- const inner = ref.replace(/^\[\[/, "").replace(/\]\]$/, "").split("|")[0];
108
- return slugify((_a = inner.split("/").pop()) != null ? _a : inner);
109
- }
110
- function dealsDamage(spell) {
111
- var _a, _b;
112
- return ((_b = (_a = spell.damage) == null ? void 0 : _a.types) != null ? _b : []).some((t) => t.trim() !== "");
113
- }
114
- function spellsInScope(scope, spells, pickedTypes) {
115
- var _a, _b;
116
- if (!scope) return [];
117
- const picked = scope.damage_type_pick !== void 0 ? pickedTypes(scope.damage_type_pick).map(lower) : null;
118
- const types = (_a = scope.damage_types) == null ? void 0 : _a.map(lower);
119
- const named = (_b = scope.spells) == null ? void 0 : _b.map(namedSpellSlug);
120
- const hit = spells.filter(({ slug, entity: e }) => {
121
- var _a2, _b2, _c, _d, _e;
122
- if (!dealsDamage(e)) return false;
123
- const own = ((_b2 = (_a2 = e.damage) == null ? void 0 : _a2.types) != null ? _b2 : []).map(lower);
124
- if (scope.list !== void 0 && !((_c = e.classes) != null ? _c : []).map(lower).includes(lower(scope.list))) return false;
125
- if (scope.level !== void 0 && ((_d = e.level) != null ? _d : 0) !== scope.level) return false;
126
- if (scope.school !== void 0 && lower(e.school) !== lower(scope.school)) return false;
127
- if (types && !own.some((t) => types.includes(t))) return false;
128
- if (picked && !own.some((t) => picked.includes(t))) return false;
129
- if (named && !named.includes(bareEntitySlug(slug)) && !named.includes(slugify((_e = e.name) != null ? _e : ""))) return false;
130
- return true;
131
- });
132
- return [...new Set(hit.map((s) => s.slug))];
133
- }
134
- function pickedDamageTypes(resolved, choiceId) {
135
- var _a, _b, _c, _d, _e, _f;
136
- const out = /* @__PURE__ */ new Set();
137
- for (const c of (_a = resolved.classes) != null ? _a : []) {
138
- for (const owner of [c.entity, c.subclass]) {
139
- for (const [lvl, feats] of Object.entries((_b = owner == null ? void 0 : owner.features_by_level) != null ? _b : {})) {
140
- for (const feat of feats != null ? feats : []) {
141
- for (const ch of (_c = feat.choices) != null ? _c : []) {
142
- if (ch.kind !== "select-inline" || ch.id !== choiceId) continue;
143
- const sel = ((_e = (_d = c.choices) == null ? void 0 : _d[Number(lvl)]) != null ? _e : {})[ch.id];
144
- if (typeof sel !== "string") continue;
145
- const opt = ch.options.find((o) => o.value === sel);
146
- for (const word of `${sel} ${(_f = opt == null ? void 0 : opt.label) != null ? _f : ""}`.split(/[^A-Za-z]+/)) {
147
- if (word && isCanonicalDamageType(word)) out.add(word.toLowerCase());
148
- }
149
- }
150
- }
151
- }
152
- }
153
- }
154
- return [...out];
155
- }
156
-
157
- // src/pc/pc.recalc.ts
158
- var WEAPON_CATEGORY_WORDS = /* @__PURE__ */ new Set([
159
- "simple",
160
- "martial",
161
- "simple-melee",
162
- "simple-ranged",
163
- "martial-melee",
164
- "martial-ranged",
165
- "natural"
166
- ]);
167
- function phbAverageForDie(hitDieStr) {
168
- const n = parseDieSize(hitDieStr);
169
- if (n == null) return 4;
170
- return Math.floor(n / 2) + 1;
171
- }
172
- function parseDieSize(die) {
173
- if (die == null) return null;
174
- if (typeof die === "number") return die;
175
- const m = die.match(/^d?(\d+)$/i);
176
- return m ? parseInt(m[1], 10) : null;
177
- }
178
- function skillSlugFromDisplay(display) {
179
- return display.toLowerCase().replace(/\s+/g, "-");
180
- }
181
- function skillSlugToAbilityLookup(slug) {
182
- return slug.replace(/-/g, " ");
183
- }
184
- function flattenRaceAsi(race) {
185
- var _a;
186
- const out = {};
187
- if (!(race == null ? void 0 : race.ability_score_increases)) return out;
188
- for (const asi of race.ability_score_increases) {
189
- if ("ability" in asi) {
190
- out[asi.ability] = ((_a = out[asi.ability]) != null ? _a : 0) + asi.amount;
191
- }
192
- }
193
- return out;
194
- }
195
- function subraceAsi(resolved) {
196
- var _a, _b, _c, _d, _e;
197
- const subSlug = (_b = (_a = resolved.definition.subrace) == null ? void 0 : _a.replace(/\[\[|\]\]/g, "")) != null ? _b : null;
198
- if (!subSlug) return [];
199
- const subraces = (_d = (_c = resolved.race) == null ? void 0 : _c.subraces) != null ? _d : [];
200
- const sub = subraces.find((s) => s.slug === subSlug);
201
- return (_e = sub == null ? void 0 : sub.ability_score_increases) != null ? _e : [];
202
- }
203
- function collectClassAsiBranch(resolved) {
204
- var _a;
205
- const out = {};
206
- for (const c of resolved.classes) {
207
- for (const choice of Object.values(c.choices)) {
208
- const alloc = legacyAsiBranch(choice);
209
- if (!alloc) continue;
210
- for (const ab of ABILITY_KEYS) {
211
- const v = alloc[ab];
212
- if (typeof v === "number") out[ab] = ((_a = out[ab]) != null ? _a : 0) + v;
213
- }
214
- }
215
- }
216
- return out;
217
- }
218
- function abilityBonusBreakdown(resolved, featureEffects) {
219
- var _a, _b, _c, _d, _e, _f, _g;
220
- const race = flattenRaceAsi(resolved.race);
221
- const origin = collectChosenAbilityPoints(resolved);
222
- const sub = subraceAsi(resolved);
223
- const classAsi = collectClassAsiBranch(resolved);
224
- const featPoints = collectClassFeatAbilityPoints(resolved);
225
- const out = {};
226
- for (const ab of ABILITY_KEYS) {
227
- let species = ((_a = race[ab]) != null ? _a : 0) + ((_b = origin.race[ab]) != null ? _b : 0);
228
- for (const asi of sub) {
229
- if (asi.ability === ab && typeof asi.amount === "number") species += asi.amount;
230
- }
231
- let feat = (_c = featPoints[ab]) != null ? _c : 0;
232
- for (const f of resolved.feats) {
233
- const bonus = (_d = f.ability_bonuses) == null ? void 0 : _d[ab];
234
- if (typeof bonus === "number") feat += bonus;
235
- }
236
- out[ab] = { species, background: (_e = origin.background[ab]) != null ? _e : 0, class: ((_f = classAsi[ab]) != null ? _f : 0) + ((_g = featureEffects == null ? void 0 : featureEffects.ability_bonus[ab]) != null ? _g : 0), feat };
237
- }
238
- return out;
239
- }
240
- function hitDiceAverageSum(classes) {
241
- var _a;
242
- let total = 0;
243
- let firstLevelCounted = false;
244
- for (const c of classes) {
245
- const die = parseDieSize((_a = c.entity) == null ? void 0 : _a.hit_die);
246
- if (!c.entity || die == null || c.level < 1) continue;
247
- for (let lvl = 1; lvl <= c.level; lvl++) {
248
- if (!firstLevelCounted) {
249
- total += die;
250
- firstLevelCounted = true;
251
- } else {
252
- total += Math.floor(die / 2) + 1;
253
- }
254
- }
255
- }
256
- return total;
257
- }
258
- function hpLevelCount(classes) {
259
- var _a;
260
- let count = 0;
261
- for (const c of classes) {
262
- const die = parseDieSize((_a = c.entity) == null ? void 0 : _a.hit_die);
263
- if (!c.entity || die == null || c.level < 1) continue;
264
- count += c.level;
265
- }
266
- return count;
267
- }
268
- function multiclassMaxHP(classes, conMod) {
269
- return Math.max(1, hitDiceAverageSum(classes) + conMod * hpLevelCount(classes));
270
- }
271
- function resolveDamageRider(rider, rowDamageType, bindings) {
272
- const { owner, ...rest } = rider;
273
- const out = { ...rest, amount: resolveAmountText(rider.amount, bindings(owner)) };
274
- if (rider.damage_type !== void 0 && !isChosenDamageType(rider.damage_type)) {
275
- const resolved = isCanonicalDamageType(rider.damage_type) ? rider.damage_type : rowDamageType;
276
- if (resolved) out.damage_type = resolved;
277
- else delete out.damage_type;
278
- }
279
- return out;
280
- }
281
- function riderReachesRow(rider, row) {
282
- var _a;
283
- if (!((_a = rider.scope) == null ? void 0 : _a.length)) return true;
284
- return rider.scope.some((word) => {
285
- switch (word) {
286
- case "weapon":
287
- return true;
288
- case "unarmed":
289
- return row.unarmed === true;
290
- case "melee":
291
- case "ranged":
292
- return row.weaponCategory === word;
293
- case "finesse":
294
- case "thrown":
295
- return row.properties.includes(word);
296
- }
297
- });
298
- }
299
- function unarmoredAC(resolved, mods, warnings) {
300
- return unarmoredACBreakdown(resolved, mods, warnings).total;
301
- }
302
- function unarmoredACBreakdown(resolved, mods, warnings, shieldBonus = 0) {
303
- var _a, _b, _c, _d, _e;
304
- const baseTerms = [
305
- { source: "Unarmored", amount: 10, kind: "unarmored" },
306
- { source: "DEX modifier", amount: mods.dex, kind: "dex" }
307
- ];
308
- const { activeBuffs } = assembleEffectFeatures(resolved);
309
- const candidates = [
310
- { total: 10 + mods.dex, terms: baseTerms, shieldAllowed: true }
311
- ];
312
- for (const rf of resolved.features) {
313
- if (!foldsNow(rf, activeBuffs)) continue;
314
- for (const eff of selfEffectsOf(rf.feature)) {
315
- if (eff.kind !== "unarmored-ac") continue;
316
- const base = (_a = eff.base) != null ? _a : 10;
317
- const terms = [{ source: "Unarmored", amount: base, kind: "unarmored" }];
318
- let total = base;
319
- for (const ab of eff.abilities) {
320
- terms.push(ab === "dex" ? { source: "DEX modifier", amount: mods.dex, kind: "dex" } : { source: `${ab.toUpperCase()} modifier (${(_b = rf.feature.name) != null ? _b : "Unarmored"})`, amount: mods[ab], kind: "ability" });
321
- total += mods[ab];
322
- }
323
- candidates.push({ total, terms, shieldAllowed: eff.allow_shield === true });
324
- }
325
- }
326
- if (candidates.length > 1) {
327
- const applied = (c) => c.total + (c.shieldAllowed ? shieldBonus : 0);
328
- let best = candidates[0];
329
- for (const c of candidates) if (applied(c) > applied(best)) best = c;
330
- return best;
331
- }
332
- for (const rf of resolved.features) {
333
- const feat = rf.feature;
334
- if ((_c = feat.unarmored_defense) == null ? void 0 : _c.ability) {
335
- const ab = feat.unarmored_defense.ability;
336
- const amt = (_d = mods[ab]) != null ? _d : 0;
337
- const terms = [
338
- ...baseTerms,
339
- { source: `${ab.toUpperCase()} modifier (Unarmored Defense)`, amount: amt, kind: "ability" }
340
- ];
341
- return { total: 10 + mods.dex + amt, terms, shieldAllowed: true };
342
- }
343
- }
344
- for (const rf of resolved.features) {
345
- const name = ((_e = rf.feature.name) != null ? _e : "").toLowerCase();
346
- if (!/unarmored\s*defense/.test(name)) continue;
347
- if (rf.source.kind === "class" && rf.source.slug.includes("monk")) {
348
- const terms = [
349
- ...baseTerms,
350
- { source: "WIS modifier (Unarmored Defense)", amount: mods.wis, kind: "ability" }
351
- ];
352
- return { total: 10 + mods.dex + mods.wis, terms, shieldAllowed: true };
353
- }
354
- if (rf.source.kind === "class" && rf.source.slug.includes("barbarian")) {
355
- const terms = [
356
- ...baseTerms,
357
- { source: "CON modifier (Unarmored Defense)", amount: mods.con, kind: "ability" }
358
- ];
359
- return { total: 10 + mods.dex + mods.con, terms, shieldAllowed: true };
360
- }
361
- }
362
- return { total: 10 + mods.dex, terms: baseTerms, shieldAllowed: true };
363
- }
364
- function resolveUnarmedStrike(resolved) {
365
- var _a, _b, _c;
366
- const dice = [];
367
- const abilities = /* @__PURE__ */ new Set();
368
- const classOf = (rf) => rf.source.kind === "class" ? resolved.classes.find((c) => {
369
- var _a2;
370
- return ((_a2 = c.entity) == null ? void 0 : _a2.slug) === rf.source.slug;
371
- }) : void 0;
372
- const readDie = (rf, d) => {
373
- var _a2, _b2;
374
- if (typeof d === "string") return d;
375
- if (!d) return void 0;
376
- const cls = classOf(rf);
377
- return cls ? (_b2 = diceColumnAt((_a2 = cls.entity) == null ? void 0 : _a2.table, cls.level, d.column)) != null ? _b2 : void 0 : void 0;
378
- };
379
- for (const rf of resolved.features) {
380
- const authored = selfEffectsOf(rf.feature).filter((e) => e.kind === "unarmed-strike");
381
- for (const e of authored) {
382
- const d2 = readDie(rf, e.dice);
383
- if (d2) dice.push(d2);
384
- for (const ab of (_a = e.abilities) != null ? _a : []) abilities.add(ab);
385
- }
386
- if (authored.length || rf.source.kind !== "class") continue;
387
- const slug = ((_c = (_b = rf.feature.id) != null ? _b : rf.feature.name) != null ? _c : "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
388
- const column = unarmedDieColumnFor(slug);
389
- if (!column) continue;
390
- const d = readDie(rf, { column });
391
- if (!d) continue;
392
- dice.push(d);
393
- abilities.add("dex");
394
- }
395
- const avg = (d) => {
396
- const m = /^(\d+)d(\d+)$/i.exec(d);
397
- return m ? Number(m[1]) * (Number(m[2]) + 1) / 2 : 1;
398
- };
399
- const best = dice.sort((a, b) => avg(b) - avg(a))[0];
400
- return { ...best ? { dice: best } : {}, ...abilities.size ? { abilities: [...abilities] } : {} };
401
- }
402
- function initiativeBonus(dexMod, feats, edition) {
403
- let bonus = dexMod;
404
- for (const f of feats) {
405
- if (f.slug === "alert" && edition === "2014") bonus += 5;
406
- const initBonus = f.initiative_bonus;
407
- if (typeof initBonus === "number") bonus += initBonus;
408
- }
409
- return bonus;
410
- }
411
- function speedFromRace(resolved) {
412
- var _a, _b, _c;
413
- const base = (_c = (_b = (_a = resolved.race) == null ? void 0 : _a.speed) == null ? void 0 : _b.walk) != null ? _c : 30;
414
- let extra = 0;
415
- for (const f of resolved.feats) {
416
- const bonus = f.speed_bonus;
417
- if (typeof bonus === "number") extra += bonus;
418
- }
419
- return base + extra;
420
- }
421
- function collectClassFeatAbilityPoints(resolved) {
422
- var _a, _b;
423
- const out = {};
424
- const stripRef = (ref) => ref.replace(/^\[\[/, "").replace(/\]\]$/, "");
425
- const featBySlug = /* @__PURE__ */ new Map();
426
- for (const f of resolved.feats) featBySlug.set(f.slug, f);
427
- const sites = featPickSites(resolved.classes, poolMemberSitesOf(resolved), (ci) => {
428
- var _a2, _b2, _c, _d;
429
- return (_d = (_c = (_b2 = (_a2 = resolved.classes) == null ? void 0 : _a2[ci]) == null ? void 0 : _b2.entity) == null ? void 0 : _c.slug) != null ? _d : null;
430
- });
431
- for (const site of sites) {
432
- {
433
- const feat = featBySlug.get(stripRef(site.slug));
434
- if (!feat) continue;
435
- for (const ch of (_a = feat.choices) != null ? _a : []) {
436
- if (ch.kind !== "ability-points") continue;
437
- const raw = site.read(ch.id);
438
- if (!raw || typeof raw !== "object" || Array.isArray(raw)) continue;
439
- let left = ch.points;
440
- for (const ab of ABILITY_KEYS) {
441
- if (ch.pool && !ch.pool.includes(ab)) continue;
442
- const v = raw[ab];
443
- if (typeof v !== "number" || v <= 0 || left <= 0) continue;
444
- const take = Math.min(v, ch.max_per, left);
445
- out[ab] = ((_b = out[ab]) != null ? _b : 0) + take;
446
- left -= take;
447
- }
448
- }
449
- }
450
- }
451
- return out;
452
- }
453
- function computeAbilityScores(resolved, overrides) {
454
- var _a, _b, _c, _d, _e, _f;
455
- const out = { ...resolved.definition.abilities };
456
- const raceBonuses = flattenRaceAsi(resolved.race);
457
- for (const ab of ABILITY_KEYS) {
458
- const b = raceBonuses[ab];
459
- if (typeof b === "number") out[ab] = ((_a = out[ab]) != null ? _a : 0) + b;
460
- }
461
- for (const asi of subraceAsi(resolved)) {
462
- if (asi.ability && typeof asi.amount === "number") out[asi.ability] = ((_b = out[asi.ability]) != null ? _b : 0) + asi.amount;
463
- }
464
- const originPoints = collectChosenAbilityPoints(resolved);
465
- for (const src of [originPoints.race, originPoints.background]) {
466
- for (const ab of ABILITY_KEYS) {
467
- const v = src[ab];
468
- if (typeof v === "number") out[ab] = ((_c = out[ab]) != null ? _c : 0) + v;
469
- }
470
- }
471
- const classAsi = collectClassAsiBranch(resolved);
472
- for (const ab of ABILITY_KEYS) {
473
- const v = classAsi[ab];
474
- if (typeof v === "number") out[ab] = ((_d = out[ab]) != null ? _d : 0) + v;
475
- }
476
- const featPoints = collectClassFeatAbilityPoints(resolved);
477
- for (const ab of ABILITY_KEYS) {
478
- const v = featPoints[ab];
479
- if (typeof v === "number") out[ab] = ((_e = out[ab]) != null ? _e : 0) + v;
480
- }
481
- for (const f of resolved.feats) {
482
- const bonuses = f.ability_bonuses;
483
- if (bonuses) {
484
- for (const ab of ABILITY_KEYS) {
485
- const v = bonuses[ab];
486
- if (typeof v === "number") out[ab] = ((_f = out[ab]) != null ? _f : 0) + v;
487
- }
488
- }
489
- }
490
- if (overrides.scores) {
491
- for (const ab of ABILITY_KEYS) {
492
- const v = overrides.scores[ab];
493
- if (typeof v === "number") out[ab] = v;
494
- }
495
- }
496
- for (const ab of ABILITY_KEYS) {
497
- if (typeof out[ab] !== "number") out[ab] = 10;
498
- }
499
- return out;
500
- }
501
- function normalizeArmorProf(input) {
502
- var _a, _b;
503
- if (!input) return { categories: [], specific: [] };
504
- if (Array.isArray(input)) return { categories: input, specific: [] };
505
- return { categories: (_a = input.categories) != null ? _a : [], specific: (_b = input.specific) != null ? _b : [] };
506
- }
507
- function normalizeWeaponToolProf(input) {
508
- var _a, _b, _c;
509
- if (!input) return { categories: [], specific: [] };
510
- if (Array.isArray(input)) return { categories: [], specific: input };
511
- return { categories: (_a = input.categories) != null ? _a : [], specific: ((_b = input.fixed) != null ? _b : []).concat((_c = input.specific) != null ? _c : []) };
512
- }
513
- function mergeInto(target, source) {
514
- for (const c of source.categories) if (!target.categories.includes(c)) target.categories.push(c);
515
- for (const s of source.specific) if (!target.specific.includes(s)) target.specific.push(s);
516
- }
517
- function applyArmorWeaponOverrides(profs, overrides) {
518
- var _a, _b;
519
- for (const kind of ["armor", "weapons"]) {
520
- const ov = overrides == null ? void 0 : overrides[kind];
521
- if (!ov) continue;
522
- const set = profs[kind];
523
- const key = (v) => proficiencyKey(kind, v);
524
- const removes = new Set(((_a = ov.remove) != null ? _a : []).map(key));
525
- for (const v of (_b = ov.add) != null ? _b : []) {
526
- const k = key(v);
527
- if (removes.has(k)) continue;
528
- const category = kind === "armor" || k === "simple" || k === "martial";
529
- const target = category ? set.categories : set.specific;
530
- if (!target.some((e) => key(e) === k)) target.push(category ? k : v);
531
- }
532
- set.categories = set.categories.filter((e) => !removes.has(key(e)));
533
- set.specific = set.specific.filter((e) => !removes.has(key(e)));
534
- }
535
- }
536
- var ORIGIN_RANK = { manual: 0, equipment: 1, grant: 2 };
537
- function composeDefenseEntries(manual, equipment, grants) {
538
- var _a;
539
- const byValue = /* @__PURE__ */ new Map();
540
- const consider = (list, origin) => {
541
- for (const raw of list) {
542
- const value = toDefenseSlug(raw);
543
- if (!value) continue;
544
- const existing = byValue.get(value);
545
- if (!existing) {
546
- byValue.set(value, { value, label: raw.trim(), origin });
547
- continue;
548
- }
549
- if (ORIGIN_RANK[origin] > ORIGIN_RANK[existing.origin]) existing.origin = origin;
550
- }
551
- };
552
- consider(manual, "manual");
553
- consider(equipment, "equipment");
554
- for (const g of grants) {
555
- const value = toDefenseSlug(g.value);
556
- if (!value) continue;
557
- const existing = byValue.get(value);
558
- if (!existing) {
559
- byValue.set(value, {
560
- value,
561
- label: g.value.trim(),
562
- origin: "grant",
563
- sources: [...g.sources],
564
- ...g.condition ? { condition: g.condition } : {}
565
- });
566
- continue;
567
- }
568
- if (ORIGIN_RANK.grant > ORIGIN_RANK[existing.origin]) existing.origin = "grant";
569
- const sources = (_a = existing.sources) != null ? _a : existing.sources = [];
570
- for (const src of g.sources) if (!sources.includes(src)) sources.push(src);
571
- if (!existing.condition && g.condition) existing.condition = g.condition;
572
- }
573
- return [...byValue.values()];
574
- }
575
- function suppress(resolved, bucket, entries) {
576
- var _a, _b, _c, _d, _e;
577
- const suppressed = new Set(
578
- ((_e = (_d = (_c = (_b = (_a = resolved.definition) == null ? void 0 : _a.overrides) == null ? void 0 : _b.defenses) == null ? void 0 : _c[bucket]) == null ? void 0 : _d.remove) != null ? _e : []).map(toDefenseSlug)
579
- );
580
- return entries.filter((e) => !suppressed.has(e.value));
581
- }
582
- function computeProficiencies(resolved) {
583
- var _a, _b, _c, _d, _e, _f, _g;
584
- const armor = { categories: [], specific: [] };
585
- const weapons = { categories: [], specific: [] };
586
- const tools = { categories: [], specific: [] };
587
- const languages = /* @__PURE__ */ new Set();
588
- for (const c of resolved.classes) {
589
- const p = (_a = c.entity) == null ? void 0 : _a.proficiencies;
590
- if (!p) continue;
591
- mergeInto(armor, normalizeArmorProf(p.armor));
592
- mergeInto(weapons, normalizeWeaponToolProf(p.weapons));
593
- mergeInto(tools, normalizeWeaponToolProf(p.tools));
594
- (_b = p.languages) == null ? void 0 : _b.forEach((l) => languages.add(l));
595
- }
596
- const racePr = (_c = resolved.race) == null ? void 0 : _c.proficiencies;
597
- if (racePr) {
598
- mergeInto(armor, normalizeArmorProf(racePr.armor));
599
- mergeInto(weapons, normalizeWeaponToolProf(racePr.weapons));
600
- mergeInto(tools, normalizeWeaponToolProf(racePr.tools));
601
- (_d = racePr.languages) == null ? void 0 : _d.forEach((l) => languages.add(l));
602
- }
603
- const bgPr = (_e = resolved.background) == null ? void 0 : _e.proficiencies;
604
- if (bgPr) {
605
- mergeInto(armor, normalizeArmorProf(bgPr.armor));
606
- mergeInto(weapons, normalizeWeaponToolProf(bgPr.weapons));
607
- mergeInto(tools, normalizeWeaponToolProf(bgPr.tools));
608
- (_f = bgPr.languages) == null ? void 0 : _f.forEach((l) => languages.add(l));
609
- }
610
- for (const f of resolved.feats) {
611
- const grants = f.grants_proficiency;
612
- if (!grants) continue;
613
- mergeInto(armor, normalizeArmorProf(grants.armor));
614
- mergeInto(weapons, normalizeWeaponToolProf(grants.weapons));
615
- mergeInto(tools, normalizeWeaponToolProf(grants.tools));
616
- (_g = grants.languages) == null ? void 0 : _g.forEach((l) => languages.add(l));
617
- }
618
- return {
619
- armor,
620
- weapons,
621
- tools,
622
- languages: Array.from(languages).sort(),
623
- saves: []
624
- };
625
- }
626
- function recalc(resolved, registry) {
627
- 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, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$;
628
- const warnings = [];
629
- const overrides = (_a = resolved.definition.overrides) != null ? _a : {};
630
- const chosenProfs = collectChosenProficiencies(resolved);
631
- const { features: effectFeatures, activeBuffs } = assembleEffectFeatures(resolved);
632
- const tableDiceFor = (src, column, level) => {
633
- var _a2;
634
- const cls = src.kind === "class" ? resolved.classes.find((c) => {
635
- var _a3;
636
- return ((_a3 = c.entity) == null ? void 0 : _a3.slug) === src.slug;
637
- }) : src.kind === "subclass" ? resolved.classes.find((c) => {
638
- var _a3;
639
- return ((_a3 = c.subclass) == null ? void 0 : _a3.slug) === src.slug;
640
- }) : void 0;
641
- return cls ? diceColumnAt((_a2 = cls.entity) == null ? void 0 : _a2.table, level, column) : null;
642
- };
643
- const featureEffects = computeFeatureEffects(effectFeatures, { activeBuffs, levelFor: (src) => resourceLevelFor(src, resolved), tableDiceFor });
644
- const profsForApply = computeProficiencies(resolved);
645
- for (const t of chosenProfs.tools) {
646
- if (!profsForApply.tools.specific.includes(t)) profsForApply.tools.specific.push(t);
647
- }
648
- for (const l of chosenProfs.languages) {
649
- if (!profsForApply.languages.includes(l)) profsForApply.languages.push(l);
650
- }
651
- for (const w of chosenProfs.weapons) {
652
- if (!profsForApply.weapons.specific.includes(w)) profsForApply.weapons.specific.push(w);
653
- }
654
- for (const t of featureEffects.proficiencies.tools) {
655
- if (!profsForApply.tools.specific.includes(t)) profsForApply.tools.specific.push(t);
656
- }
657
- for (const l of featureEffects.proficiencies.languages) {
658
- if (!profsForApply.languages.includes(l)) profsForApply.languages.push(l);
659
- }
660
- for (const a of featureEffects.proficiencies.armor) {
661
- if (!profsForApply.armor.categories.includes(a)) profsForApply.armor.categories.push(a);
662
- }
663
- for (const w of featureEffects.proficiencies.weapons) {
664
- if (!profsForApply.weapons.categories.includes(w)) profsForApply.weapons.categories.push(w);
665
- if (!WEAPON_CATEGORY_WORDS.has(w) && !profsForApply.weapons.specific.includes(w)) {
666
- profsForApply.weapons.specific.push(w);
667
- }
668
- }
669
- profsForApply.languages.sort();
670
- applyArmorWeaponOverrides(profsForApply, (_b = resolved.definition) == null ? void 0 : _b.overrides);
671
- const applied = registry ? computeAppliedBonuses(resolved, profsForApply, registry, warnings) : emptyAppliedBonuses();
672
- const savesInformational = applied.informational.filter(
673
- (i) => i.field === "saving_throws"
674
- );
675
- const spellcastingInformational = applied.informational.filter(
676
- (i) => i.field === "spell_attack" || i.field === "spell_save_dc"
677
- );
678
- const speedInformational = applied.informational.filter(
679
- (i) => i.field.startsWith("speed.")
680
- );
681
- const baseScores = computeAbilityScores(resolved, overrides);
682
- const scores = { ...baseScores };
683
- for (const ab of ABILITY_KEYS) {
684
- const bonus = applied.ability_bonuses[ab];
685
- scores[ab] += (typeof bonus === "number" ? bonus : 0) + ((_c = featureEffects.ability_bonus[ab]) != null ? _c : 0);
686
- }
687
- for (const ab of ABILITY_KEYS) {
688
- const stat = applied.ability_statics[ab];
689
- if (typeof stat === "number" && stat > scores[ab]) scores[ab] = stat;
690
- }
691
- if (overrides.scores) {
692
- for (const ab of ABILITY_KEYS) {
693
- const o = overrides.scores[ab];
694
- if (typeof o === "number") scores[ab] = o;
695
- }
696
- }
697
- const mods = {
698
- str: abilityModifier(scores.str),
699
- dex: abilityModifier(scores.dex),
700
- con: abilityModifier(scores.con),
701
- int: abilityModifier(scores.int),
702
- wis: abilityModifier(scores.wis),
703
- cha: abilityModifier(scores.cha)
704
- };
705
- const totalLevel = resolved.classes.reduce((s, c) => s + c.level, 0);
706
- const proficiencyBonus = proficiencyFromLevel(totalLevel || 1);
707
- const conditionEffects = computeConditionEffects(
708
- resolved.state,
709
- resolved.definition.edition,
710
- scores
711
- );
712
- const firstClass = (_e = (_d = resolved.classes[0]) == null ? void 0 : _d.entity) != null ? _e : null;
713
- const saveProfs = new Set((_f = firstClass == null ? void 0 : firstClass.saving_throws) != null ? _f : []);
714
- for (const ab of featureEffects.proficiencies.saves) saveProfs.add(ab);
715
- for (const ab of chosenProfs.saves) saveProfs.add(ab);
716
- const saves = {};
717
- const saveBreakdowns = {};
718
- const activeSaveBonusTerms = featureEffects.save_bonus_terms.filter((t) => {
719
- var _a2;
720
- return t.inactiveWhile === "incapacitated" ? !conditionEffects.actions_disabled : t.inactiveWhile === "unconscious" ? !((_a2 = resolved.state.conditions) != null ? _a2 : []).includes("unconscious") : true;
721
- });
722
- for (const ab of ABILITY_KEYS) {
723
- const override = (_g = overrides.saves) == null ? void 0 : _g[ab];
724
- const prof = (_h = override == null ? void 0 : override.proficient) != null ? _h : saveProfs.has(ab);
725
- const featureTerms = [];
726
- for (const t of activeSaveBonusTerms) {
727
- if (t.saves.length > 0 && !t.saves.includes(ab)) continue;
728
- const amount = Math.max(t.minimum, mods[t.ability]);
729
- const prior = featureTerms.find((x) => x.source === t.label);
730
- if (prior === void 0) featureTerms.push({ source: t.label, amount });
731
- else if (amount > prior.amount) prior.amount = amount;
732
- }
733
- const derivedBonus = savingThrow(scores[ab], prof, proficiencyBonus) + applied.save_bonus + featureTerms.reduce((sum, t) => sum + t.amount, 0) + conditionEffects.d20_test_penalty;
734
- const bonus = (_i = override == null ? void 0 : override.bonus) != null ? _i : derivedBonus;
735
- saves[ab] = { bonus, proficient: prof };
736
- saveBreakdowns[ab] = [
737
- { source: ab.toUpperCase(), amount: mods[ab] },
738
- ...prof ? [{ source: "Proficiency", amount: proficiencyBonus }] : [],
739
- ...applied.save_terms.map((t) => ({ ...t })),
740
- ...featureTerms,
741
- ...conditionEffects.d20_test_penalty ? [{ source: `Exhaustion ${conditionEffects.exhaustion_level}`, amount: conditionEffects.d20_test_penalty }] : []
742
- ];
743
- }
744
- const profSet = /* @__PURE__ */ new Set([
745
- ...resolved.definition.skills.proficient,
746
- ...(_k = (_j = resolved.background) == null ? void 0 : _j.skill_proficiencies) != null ? _k : [],
747
- ...chosenProfs.skills,
748
- ...featureEffects.proficiencies.skills
749
- ]);
750
- const expSet = /* @__PURE__ */ new Set([...resolved.definition.skills.expertise, ...chosenProfs.expertise, ...featureEffects.proficiencies.skillExpertise]);
751
- const skills = {};
752
- const skillBreakdowns = {};
753
- for (const skill of ALL_SKILLS) {
754
- const skillKey = skillSlugFromDisplay(skill);
755
- const ab = SKILL_ABILITY[skillSlugToAbilityLookup(skillKey)];
756
- const override = (_l = overrides.skills) == null ? void 0 : _l[skillKey];
757
- const tri = (_m = override == null ? void 0 : override.proficiency) != null ? _m : expSet.has(skillKey) ? "expertise" : profSet.has(skillKey) ? "proficient" : "none";
758
- const skillTerms = featureEffects.skill_bonus_terms.filter((t) => t.skills.includes(skillKey)).map((t) => ({ source: t.label, amount: Math.max(t.minimum, mods[t.ability]) }));
759
- const halfProfTerms = tri !== "none" ? [] : featureEffects.half_proficiency_terms.filter((t) => t.skills.length === 0 || t.skills.includes(skillKey)).map((t) => ({ source: t.label, amount: t.round === "up" ? Math.ceil(proficiencyBonus / 2) : Math.floor(proficiencyBonus / 2) }));
760
- const halfProfBest = halfProfTerms.length ? halfProfTerms.reduce((best, t) => t.amount > best.amount ? t : best) : null;
761
- const bonus = (_o = override == null ? void 0 : override.bonus) != null ? _o : skillBonus(scores[ab], tri, proficiencyBonus) + skillTerms.reduce((sum, t) => sum + t.amount, 0) + ((_n = halfProfBest == null ? void 0 : halfProfBest.amount) != null ? _n : 0) + conditionEffects.d20_test_penalty;
762
- skillBreakdowns[skillKey] = [
763
- { source: ab.toUpperCase(), amount: mods[ab] },
764
- ...tri !== "none" ? [{ source: tri === "expertise" ? "Expertise" : "Proficiency", amount: proficiencyBonus * (tri === "expertise" ? 2 : 1) }] : [],
765
- ...skillTerms,
766
- ...halfProfBest ? [halfProfBest] : [],
767
- ...conditionEffects.d20_test_penalty ? [{ source: "Conditions", amount: conditionEffects.d20_test_penalty }] : []
768
- ];
769
- skills[skillKey] = {
770
- bonus,
771
- proficiency: tri,
772
- ability: ab,
773
- ...halfProfBest ? { halfProficiency: { source: halfProfBest.source, amount: halfProfBest.amount } } : {}
774
- };
775
- }
776
- const passives = {
777
- perception: (_q = (_p = overrides.passives) == null ? void 0 : _p.perception) != null ? _q : 10 + skills.perception.bonus,
778
- investigation: (_s = (_r = overrides.passives) == null ? void 0 : _r.investigation) != null ? _s : 10 + skills.investigation.bonus,
779
- insight: (_u = (_t = overrides.passives) == null ? void 0 : _t.insight) != null ? _u : 10 + skills.insight.bonus
780
- };
781
- const hpRolled = (_w = (_v = overrides.hp) == null ? void 0 : _v.rolled) != null ? _w : null;
782
- const hpModifier = (_y = (_x = overrides.hp) == null ? void 0 : _x.modifier) != null ? _y : null;
783
- const averageDiceSum = hitDiceAverageSum(resolved.classes);
784
- const conLevels = hpLevelCount(resolved.classes);
785
- const diceSum = hpRolled != null ? hpRolled : averageDiceSum;
786
- const diceConRaw = diceSum + mods.con * conLevels;
787
- const diceConClamped = Math.max(1, diceConRaw);
788
- const hpMaxDerived = diceConClamped + featureEffects.hp_per_level_bonus * totalLevel + (hpModifier != null ? hpModifier : 0);
789
- const hpMaxAfterConditions = Math.max(0, Math.floor(hpMaxDerived * conditionEffects.hp_max_multiplier));
790
- const hpMax = (_A = (_z = overrides.hp) == null ? void 0 : _z.max) != null ? _A : hpMaxAfterConditions;
791
- const hpBreakdown = {
792
- diceSum,
793
- diceSource: hpRolled != null ? "rolled" : "average",
794
- averageDiceSum,
795
- conMod: mods.con,
796
- conLevels,
797
- clampApplied: diceConClamped !== diceConRaw,
798
- perLevelTerms: featureEffects.hp_per_level_terms.map((t) => ({
799
- label: t.label,
800
- perLevel: t.value,
801
- levels: totalLevel,
802
- total: t.value * totalLevel
803
- })),
804
- modifier: hpModifier,
805
- exhaustionMultiplier: conditionEffects.hp_max_multiplier,
806
- exhaustionLevel: conditionEffects.exhaustion_level,
807
- derivedMax: hpMaxAfterConditions,
808
- override: (_C = (_B = overrides.hp) == null ? void 0 : _B.max) != null ? _C : null,
809
- final: hpMax
810
- };
811
- const featureAcTermsFor = (hasArmor) => featureEffects.ac_terms.filter((t) => !t.requires_armor || hasArmor).map((t) => ({ source: t.label, amount: t.value, kind: "feature", condition: t.condition }));
812
- const sumTerms = (terms) => terms.reduce((s, t) => s + t.amount, 0);
813
- const weaponAbilities = [...featureEffects.weaponAbilities];
814
- const wantsSpellcasting = resolved.features.some((rf) => selfEffectsOf(rf.feature).some((e) => e.kind === "weapon-ability" && e.ability === "spellcasting"));
815
- if (wantsSpellcasting) {
816
- let primaryCasterAbility = null;
817
- for (const c of resolved.classes) {
818
- if (!c.entity) continue;
819
- const profile = resolveSpellcasting(c);
820
- if (profile) {
821
- primaryCasterAbility = effectiveSpellcastingAbility(c.entity.slug, profile.ability, overrides);
822
- break;
823
- }
824
- }
825
- if (primaryCasterAbility) weaponAbilities.unshift({ ability: primaryCasterAbility });
826
- }
827
- let derivedEquipment = null;
828
- let acDerived;
829
- let acBreakdownDerived = [];
830
- let acInformationalDerived = [];
831
- if (registry) {
832
- derivedEquipment = computeSlotsAndAttacks(resolved, mods, profsForApply, registry, warnings, proficiencyBonus, weaponAbilities, (_D = resolved.weaponMasteries) != null ? _D : [], featureEffects.attunement_set);
833
- if (derivedEquipment.equippedSlots.armor) {
834
- const featTerms = featureAcTermsFor(true);
835
- acDerived = derivedEquipment.ac + sumTerms(featTerms);
836
- acBreakdownDerived = [...derivedEquipment.acBreakdown, ...featTerms];
837
- acInformationalDerived = derivedEquipment.acInformational;
838
- } else {
839
- const shieldBonus = derivedEquipment.acBreakdown.filter((b) => b.kind === "shield").reduce((sum, b) => sum + b.amount, 0);
840
- const { total: unarmored, terms: unarmoredTerms, shieldAllowed } = unarmoredACBreakdown(resolved, mods, warnings, shieldBonus);
841
- const additive = derivedEquipment.acBreakdown.filter(
842
- (b) => b.kind === "item" || b.kind === "override" || b.kind === "shield" && shieldAllowed
843
- );
844
- const featTerms = featureAcTermsFor(false);
845
- const additiveSum = additive.reduce((sum, b) => sum + b.amount, 0);
846
- acDerived = unarmored + additiveSum + sumTerms(featTerms);
847
- acBreakdownDerived = [...unarmoredTerms, ...additive, ...featTerms];
848
- acInformationalDerived = derivedEquipment.acInformational;
849
- }
850
- } else {
851
- const { total, terms } = unarmoredACBreakdown(resolved, mods, warnings);
852
- const featTerms = featureAcTermsFor(false);
853
- acDerived = total + sumTerms(featTerms);
854
- acBreakdownDerived = [...terms, ...featTerms];
855
- }
856
- const ac = (_E = overrides.ac) != null ? _E : acDerived;
857
- const additiveSpeed = speedFromRace(resolved) + applied.speed_bonuses.walk + featureEffects.speed_walk_bonus;
858
- const baseSpeed = Math.max(featureEffects.speed_walk_set, additiveSpeed);
859
- const adjustedSpeed = baseSpeed * conditionEffects.speed_multiplier - conditionEffects.speed_reduction_ft;
860
- const conditionSpeed = conditionEffects.speed_floor_zero ? 0 : Math.max(0, Math.floor(adjustedSpeed));
861
- const speed = (_F = overrides.speed) != null ? _F : conditionSpeed;
862
- const raceSpeed = (_I = (_H = (_G = resolved.race) == null ? void 0 : _G.speed) == null ? void 0 : _H.walk) != null ? _I : 30;
863
- const speedBreakdown = [
864
- { source: "Base speed", amount: raceSpeed },
865
- ...speedFromRace(resolved) !== raceSpeed ? [{ source: "Feats", amount: speedFromRace(resolved) - raceSpeed }] : [],
866
- ...applied.speed_bonuses.walk ? [{ source: "Equipment", amount: applied.speed_bonuses.walk }] : [],
867
- ...featureEffects.speed_walk_terms.map((term) => ({ source: term.label, amount: term.value })),
868
- ...baseSpeed > additiveSpeed ? [{ source: "Minimum speed", amount: baseSpeed - additiveSpeed }] : [],
869
- ...conditionSpeed !== baseSpeed ? [{ source: "Conditions", amount: conditionSpeed - baseSpeed }] : []
870
- ];
871
- if (!resolved.race) warnings.push("No race resolved; speed defaulted to 30.");
872
- const init = (_J = overrides.initiative) != null ? _J : initiativeBonus(mods.dex, resolved.feats, resolved.definition.edition) + featureEffects.initiative_bonus;
873
- const initiativeBreakdown = [
874
- { source: "DEX", amount: mods.dex },
875
- ...initiativeBonus(mods.dex, resolved.feats, resolved.definition.edition) !== mods.dex ? [{ source: "Feats", amount: initiativeBonus(mods.dex, resolved.feats, resolved.definition.edition) - mods.dex }] : [],
876
- ...featureEffects.initiative_terms.map((term) => ({ source: term.label, amount: term.value }))
877
- ];
878
- const senses = {
879
- darkvision: Math.max((_M = (_L = (_K = resolved.race) == null ? void 0 : _K.vision) == null ? void 0 : _L.darkvision) != null ? _M : 0, featureEffects.senses.darkvision, applied.senses.darkvision),
880
- blindsight: Math.max(featureEffects.senses.blindsight, applied.senses.blindsight),
881
- tremorsense: Math.max(featureEffects.senses.tremorsense, applied.senses.tremorsense),
882
- truesight: Math.max(featureEffects.senses.truesight, applied.senses.truesight)
883
- };
884
- const spellcastingClasses = [];
885
- const slotInputs = [];
886
- const limitInputs = [];
887
- for (const c of resolved.classes) {
888
- if (!c.entity) continue;
889
- const profile = resolveSpellcasting(c);
890
- if (!profile) continue;
891
- const ab = effectiveSpellcastingAbility(c.entity.slug, profile.ability, overrides);
892
- const dc = saveDC(scores[ab], proficiencyBonus) + applied.spell_save_dc;
893
- const atk = attackBonus(scores[ab], proficiencyBonus) + applied.spell_attack;
894
- spellcastingClasses.push({
895
- classSlug: c.entity.slug,
896
- className: c.entity.name,
897
- ability: ab,
898
- defaultAbility: profile.ability,
899
- saveDC: dc,
900
- attackBonus: atk,
901
- casterType: profile.casterType,
902
- preparation: profile.preparation,
903
- spellList: profile.spellList
904
- });
905
- slotInputs.push({ casterType: profile.casterType, level: c.level });
906
- limitInputs.push({ classSlug: c.entity.slug, level: c.level, profile, abilityScore: scores[ab] });
907
- }
908
- const spellcasting = spellcastingClasses.length > 0 ? {
909
- ability: spellcastingClasses[0].ability,
910
- saveDC: spellcastingClasses[0].saveDC,
911
- attackBonus: spellcastingClasses[0].attackBonus
912
- } : null;
913
- const abilitySpellcasting = {};
914
- for (const s of resolved.spells) {
915
- const ab = s.ability;
916
- if (!ab || abilitySpellcasting[ab]) continue;
917
- abilitySpellcasting[ab] = {
918
- saveDC: saveDC(scores[ab], proficiencyBonus) + applied.spell_save_dc,
919
- attackBonus: attackBonus(scores[ab], proficiencyBonus) + applied.spell_attack
920
- };
921
- }
922
- const derivedSlots = deriveSpellSlots(slotInputs);
923
- const spellLimits = computeSpellLimits(limitInputs);
924
- const defenses = {
925
- resistances: suppress(resolved, "resistances", composeDefenseEntries(
926
- (_O = (_N = resolved.definition.defenses) == null ? void 0 : _N.resistances) != null ? _O : [],
927
- applied.defenses.resistances,
928
- featureEffects.resistances
929
- )),
930
- immunities: suppress(resolved, "immunities", composeDefenseEntries(
931
- (_Q = (_P = resolved.definition.defenses) == null ? void 0 : _P.immunities) != null ? _Q : [],
932
- applied.defenses.immunities,
933
- featureEffects.immunities
934
- )),
935
- vulnerabilities: suppress(resolved, "vulnerabilities", composeDefenseEntries(
936
- (_S = (_R = resolved.definition.defenses) == null ? void 0 : _R.vulnerabilities) != null ? _S : [],
937
- applied.defenses.vulnerabilities,
938
- featureEffects.vulnerabilities
939
- )),
940
- condition_immunities: suppress(resolved, "condition_immunities", composeDefenseEntries(
941
- (_U = (_T = resolved.definition.defenses) == null ? void 0 : _T.condition_immunities) != null ? _U : [],
942
- applied.defenses.condition_immunities,
943
- featureEffects.condition_immunities
944
- ))
945
- };
946
- const attackRows = [...(_V = derivedEquipment == null ? void 0 : derivedEquipment.attacks) != null ? _V : [], buildUnarmedRow(mods, proficiencyBonus, resolveUnarmedStrike(resolved))];
947
- const riderBindings = (owner) => amountBindingsFor(owner, resolved, { proficiencyBonus, mods, spellcastingClasses });
948
- const ownSpells = (_W = resolved.spells) != null ? _W : [];
949
- const spellDamageRiders = featureEffects.spellDamageBonuses.flatMap((r) => {
950
- const reached = /* @__PURE__ */ new Set([...spellsReached(r.targets, ownSpells), ...spellsInScope(r.scope, ownSpells, (id) => pickedDamageTypes(resolved, id))]);
951
- const spells = [...new Set(ownSpells.map((s) => s.slug))].filter((slug) => reached.has(slug));
952
- if (!spells.length) return [];
953
- const { owner, targets: _targets, scope, damage_type, ...rest } = r;
954
- return [{
955
- ...rest,
956
- amount: resolveAmountText(r.amount, riderBindings(owner)),
957
- ...damage_type && isCanonicalDamageType(damage_type) ? { damage_type } : {},
958
- ...(scope == null ? void 0 : scope.once) ? { once: true } : {},
959
- spells
960
- }];
961
- });
962
- return {
963
- totalLevel,
964
- proficiencyBonus,
965
- scores,
966
- mods,
967
- saves,
968
- proficiencies: profsForApply,
969
- skills,
970
- statBreakdowns: { skills: skillBreakdowns, saves: saveBreakdowns, speed: speedBreakdown, initiative: initiativeBreakdown },
971
- passives,
972
- senses,
973
- hp: {
974
- max: hpMax,
975
- current: resolved.state.hp.current,
976
- temp: resolved.state.hp.temp
977
- },
978
- hpBreakdown,
979
- ac,
980
- speed,
981
- initiative: init,
982
- spellcasting,
983
- spellcastingClasses,
984
- abilitySpellcasting,
985
- derivedSpellSlots: derivedSlots.standard,
986
- pactMagic: derivedSlots.pact,
987
- spellLimits,
988
- warnings,
989
- defenses,
990
- acBreakdown: acBreakdownDerived,
991
- acInformational: acInformationalDerived,
992
- savesInformational,
993
- spellcastingInformational,
994
- speedInformational,
995
- // Always ≥ 1; non-stacking (Math.max) extra attacks fold in pc.feature-effects.
996
- attacksPerAction: 1 + featureEffects.extraAttack,
997
- // Consolidated post-apply over the built attack rows: the d20 condition
998
- // penalty (always), plus display-only annotations conditionally spread so
999
- // untouched rows keep `critRange`/`attackNotes` ABSENT (not 20 / not []).
1000
- // crit-range: folded weapon crit threshold, only when an effect lowered it.
1001
- // attackNotes: reroll-damage / attack-rule captions, only when non-empty.
1002
- attacks: attackRows.map((a) => {
1003
- var _a2;
1004
- const riders = [...(_a2 = a.damageRiders) != null ? _a2 : [], ...featureEffects.damageBonuses.filter((r) => riderReachesRow(r, a))].map((r) => resolveDamageRider(r, a.damageType, riderBindings));
1005
- return {
1006
- ...a,
1007
- toHit: a.toHit + conditionEffects.d20_test_penalty,
1008
- ...featureEffects.critRange < 20 ? { critRange: featureEffects.critRange } : {},
1009
- ...featureEffects.attackNotes.length ? { attackNotes: featureEffects.attackNotes } : {},
1010
- ...riders.length ? { damageRiders: riders } : {}
1011
- };
1012
- }),
1013
- ...spellDamageRiders.length ? { spellDamageRiders } : {},
1014
- equippedSlots: (_X = derivedEquipment == null ? void 0 : derivedEquipment.equippedSlots) != null ? _X : {},
1015
- carriedWeight: (_Y = derivedEquipment == null ? void 0 : derivedEquipment.carriedWeight) != null ? _Y : 0,
1016
- attunementUsed: (_Z = derivedEquipment == null ? void 0 : derivedEquipment.attunementUsed) != null ? _Z : 0,
1017
- attunementLimit: (_$ = derivedEquipment == null ? void 0 : derivedEquipment.attunementLimit) != null ? _$ : (__ = overrides.attunement_limit) != null ? __ : Math.max(3, featureEffects.attunement_set),
1018
- conditionEffects,
1019
- rollModifiers: featureEffects.rollModifiers,
1020
- saveOutcomes: featureEffects.saveOutcomes
1021
- };
1022
- }
1023
- export {
1024
- abilityBonusBreakdown,
1025
- collectClassAsiBranch,
1026
- collectClassFeatAbilityPoints,
1027
- computeAbilityScores,
1028
- computeProficiencies,
1029
- flattenRaceAsi,
1030
- hitDiceAverageSum,
1031
- hpLevelCount,
1032
- initiativeBonus,
1033
- multiclassMaxHP,
1034
- parseDieSize,
1035
- phbAverageForDie,
1036
- recalc,
1037
- resolveUnarmedStrike,
1038
- riderReachesRow,
1039
- speedFromRace,
1040
- unarmoredAC,
1041
- unarmoredACBreakdown
1042
- };
1
+ import{buildFeatureAttackRows,buildUnarmedRow,computeAppliedBonuses,computeSlotsAndAttacks,emptyAppliedBonuses,pactWeaponIndexes}from"../chunk-E3MS4M3N.js";import"../chunk-T55DELVL.js";import"../chunk-SEOASDO4.js";import{amountBindingsFor,ownerClassSlug}from"../chunk-CCAVZANF.js";import"../chunk-PZ3ZZ5H5.js";import{computeConditionEffects,speedConditionNames}from"../chunk-VA3ZWV7C.js";import"../chunk-4E2GIWJE.js";import{collectChosenAbilityPoints,collectChosenProficiencies}from"../chunk-J5GL6FLP.js";import"../chunk-2EOGK6R6.js";import"../chunk-RQZCGXUZ.js";import{assembleEffectFeatures,computeFeatureEffects,foldsNow,mergeDefenseItems,selfEffectsOf}from"../chunk-GD7WRCNH.js";import"../chunk-FOLHTMSC.js";import"../chunk-4JEF3CET.js";import{proficiencyKey}from"../chunk-VTQ4RWEG.js";import{itemLabel}from"../chunk-J3RP5C7L.js";import{featPickSites,poolMemberSitesOf,spellsReached}from"../chunk-WAUNLUFQ.js";import"../chunk-CEHL7PPC.js";import"../chunk-UBUKCRZ3.js";import{resourceLevelFor}from"../chunk-KEXSF3CH.js";import{computeSpellLimits,deriveSpellSlots,effectiveSpellcastingAbility,resolveSpellcasting}from"../chunk-PFQPP77Q.js";import{legacyAsiBranch}from"../chunk-QVWT67WA.js";import{toDefenseSlug}from"../chunk-LR6UMA5V.js";import"../chunk-PKIMOVQG.js";import"../chunk-CMIEZQL4.js";import{diceColumnAt,tableCellAt,unarmedDieColumnFor}from"../chunk-CSTAQQGX.js";import"../chunk-O776WL7O.js";import"../chunk-3LWOVRLA.js";import"../chunk-DVUXUIPV.js";import"../chunk-YGH7S5ZF.js";import"../chunk-NEMX7QGG.js";import"../chunk-56JK6VCL.js";import{effectiveArmor,isShieldArmor}from"../chunk-4IAMSRHD.js";import"../chunk-3QQOATV3.js";import"../chunk-DZITM5AG.js";import"../chunk-PZ4L2EEG.js";import"../chunk-QMEKQTUT.js";import{resolveAmountText}from"../chunk-VIP3FH2O.js";import"../chunk-EAARMPCW.js";import"../chunk-CAPYNIGK.js";import{bareEntitySlug,slugify}from"../chunk-63YJPWTM.js";import"../chunk-4KVVAENP.js";import"../chunk-7EL3GWWJ.js";import"../chunk-BREHZNTL.js";import{abilityModifier,attackBonus,isCanonicalDamageType,isChosenDamageType,proficiencyFromLevel,saveDC,savingThrow,skillBonus}from"../chunk-7FPQJDFD.js";import{ABILITY_KEYS,ALL_SKILLS,SKILL_ABILITY}from"../chunk-EVT7MGAC.js";import"../chunk-S5UCI27C.js";import"../chunk-ZVL5FXXO.js";import"../chunk-I26FHSI6.js";var lower=s=>(s!=null?s:"").trim().toLowerCase();function namedSpellSlug(ref){var _a;const inner=ref.replace(/^\[\[/,"").replace(/\]\]$/,"").split("|")[0];return slugify((_a=inner.split("/").pop())!=null?_a:inner)}function dealsDamage(spell){var _a,_b;return((_b=(_a=spell.damage)==null?void 0:_a.types)!=null?_b:[]).some(t=>t.trim()!=="")}function spellsInScope(scope,spells,pickedTypes){var _a,_b;if(!scope)return[];const picked=scope.damage_type_pick!==void 0?pickedTypes(scope.damage_type_pick).map(lower):null;const types=(_a=scope.damage_types)==null?void 0:_a.map(lower);const named=(_b=scope.spells)==null?void 0:_b.map(namedSpellSlug);const hit=spells.filter(({slug,entity:e})=>{var _a2,_b2,_c,_d,_e;if(!dealsDamage(e))return false;const own=((_b2=(_a2=e.damage)==null?void 0:_a2.types)!=null?_b2:[]).map(lower);if(scope.list!==void 0&&!((_c=e.classes)!=null?_c:[]).map(lower).includes(lower(scope.list)))return false;if(scope.level!==void 0&&((_d=e.level)!=null?_d:0)!==scope.level)return false;if(scope.school!==void 0&&lower(e.school)!==lower(scope.school))return false;if(types&&!own.some(t=>types.includes(t)))return false;if(picked&&!own.some(t=>picked.includes(t)))return false;if(named&&!named.includes(bareEntitySlug(slug))&&!named.includes(slugify((_e=e.name)!=null?_e:"")))return false;return true});return[...new Set(hit.map(s=>s.slug))]}function pickedDamageTypes(resolved,choiceId){var _a,_b,_c,_d,_e,_f;const out=new Set;for(const c of(_a=resolved.classes)!=null?_a:[]){for(const owner of[c.entity,c.subclass]){for(const[lvl,feats]of Object.entries((_b=owner==null?void 0:owner.features_by_level)!=null?_b:{})){for(const feat of feats!=null?feats:[]){for(const ch of(_c=feat.choices)!=null?_c:[]){if(ch.kind!=="select-inline"||ch.id!==choiceId)continue;const sel=((_e=(_d=c.choices)==null?void 0:_d[Number(lvl)])!=null?_e:{})[ch.id];if(typeof sel!=="string")continue;const opt=ch.options.find(o=>o.value===sel);for(const word of`${sel} ${(_f=opt==null?void 0:opt.label)!=null?_f:""}`.split(/[^A-Za-z]+/)){if(word&&isCanonicalDamageType(word))out.add(word.toLowerCase())}}}}}}return[...out]}var OTHER_MODES=["fly","swim","climb","burrow"];function wornArmor(slots,registry){const body=slots==null?void 0:slots.armor;const armor=body&&registry?effectiveArmor(body.entity,registry):null;const isBody=armor!==null&&!isShieldArmor(armor);const score=isBody?strengthRequirementOf(armor):void 0;return{heavy:isBody&&armor.category==="heavy",armor:isBody,shield:(slots==null?void 0:slots.shield)!==void 0,strength:body&&isBody&&typeof score==="number"&&score>0?{label:itemLabel(body.entry,body.entity),score}:null}}function strengthRequirementOf(armor){var _a;return(_a=armor.strength_requirement)!=null?_a:armor.strength_required}function speedTermActive(t,worn){var _a;const holds=w=>w==="heavy-armor"?worn.heavy:w==="armor"?worn.armor:worn.shield;return!((_a=t.inactiveWhile)!=null?_a:[]).some(holds)}function armorStrengthPenalty(worn,str,ignoredBy){if(!worn.strength||str>=worn.strength.score||ignoredBy.length>0)return null;return{source:`${worn.strength.label} (Strength ${str} < ${worn.strength.score})`,amount:-ARMOR_STRENGTH_PENALTY}}var ARMOR_STRENGTH_PENALTY=10;function speedAfterConditions(pre,ce){if(ce.speed_floor_zero)return 0;return Math.max(0,Math.floor(pre*ce.speed_multiplier-ce.speed_reduction_ft))}var term=(source,amount,condition)=>({source,amount,...condition?{condition}:{}});function walkTerms(i,species){var _a,_b,_c;const terms=[term(species,i.walk.race)];for(const f of i.resolved.feats){const bonus=f.speed_bonus;if(typeof bonus==="number"&&bonus!==0)terms.push(term((_a=f.name)!=null?_a:"Feat",bonus))}for(const t of i.applied.speed_terms)if(t.mode==="walk"&&t.kind==="bonus")terms.push(term(t.source,t.amount));for(const t of i.features.speed_terms)if(t.mode==="walk"&&!t.set)terms.push(term(t.label,t.value,t.condition));if(i.armorPenalty)terms.push(i.armorPenalty.term);if(i.walk.base>i.walk.additive){const itemWins=i.applied.speed_walk_set===i.walk.base&&i.applied.speed_walk_set>i.features.speed_walk_set;const source=itemWins?(_b=i.applied.speed_walk_set_terms.find(t=>t.amount===i.walk.base))==null?void 0:_b.source:(_c=i.features.speed_terms.find(t=>t.mode==="walk"&&t.set&&t.value===i.walk.base))==null?void 0:_c.label;terms.push(term(source!=null?source:"Minimum speed",i.walk.base-i.walk.additive))}if(i.walk.final!==i.walk.base)terms.push(term(conditionLabel(i),i.walk.final-i.walk.base));return terms}var conditionLabel=i=>i.conditionNames.join(", ")||"Conditions";function otherLine(i,mode,species){var _a,_b,_c,_d,_e;const grants=[];const own=(_b=(_a=i.resolved.race)==null?void 0:_a.speed)==null?void 0:_b[mode];if(typeof own==="number"&&own>0)grants.push(term(species,own));for(const t of i.features.speed_terms)if(t.mode===mode&&t.set&&t.value>0)grants.push(term(t.label,t.value,t.condition));for(const t of i.applied.speed_terms)if(t.mode===mode&&t.kind==="grant"&&t.amount>0)grants.push(term(t.source,t.amount));for(const t of i.applied.speed_terms)if(t.mode===mode&&t.kind==="walk")grants.push({...term(t.source,i.walk.base),equalsWalk:true});for(const t of i.features.speed_terms)if(t.mode===mode&&t.equalsWalk)grants.push({...term(t.label,i.walk.base,t.condition),equalsWalk:true});if(grants.length===0)return null;const penalty=((_c=i.armorPenalty)==null?void 0:_c.everyMode)?-i.armorPenalty.term.amount:0;const after=g=>g.equalsWalk?g.amount:g.amount-Math.min(penalty,g.amount);const best=grants.reduce((a,b)=>after(b)>after(a)?b:a);if(best.amount<=0)return null;const{equalsWalk,...bestTerm}=best;const bonuses=i.features.speed_terms.filter(t=>t.mode===mode&&!t.set&&!t.equalsWalk&&t.value!==0).map(t=>term(t.label,t.value,t.condition));const terms=[bestTerm,...bonuses];if(i.armorPenalty&&penalty>0&&!equalsWalk){const cut=Math.min(penalty,terms.reduce((s,t)=>s+t.amount,0));if(cut>0)terms.push({...i.armorPenalty.term,amount:-cut})}const pre=terms.reduce((s,t)=>s+t.amount,0);const value=speedAfterConditions(pre,i.conditions);if(value!==pre)terms.push(term(conditionLabel(i),value-pre));return{mode,value,...equalsWalk&&bonuses.length===0?{equalsWalk:true}:{},...mode==="fly"&&((_e=(_d=i.resolved.race)==null?void 0:_d.speed)==null?void 0:_e.hover)===true&&typeof own==="number"&&own>0?{hover:true}:{},terms}}function buildSpeedLines(i){var _a,_b;const species=(_b=(_a=i.resolved.race)==null?void 0:_a.name)!=null?_b:"Base speed";const lines=[{mode:"walk",value:i.walk.final,terms:walkTerms(i,species)}];for(const mode of OTHER_MODES){const line=otherLine(i,mode,species);if(line)lines.push(line)}return lines}var WEAPON_CATEGORY_WORDS=new Set(["simple","martial","simple-melee","simple-ranged","martial-melee","martial-ranged","natural"]);function phbAverageForDie(hitDieStr){const n=parseDieSize(hitDieStr);if(n==null)return 4;return Math.floor(n/2)+1}function parseDieSize(die){if(die==null)return null;if(typeof die==="number")return die;const m=die.match(/^d?(\d+)$/i);return m?parseInt(m[1],10):null}function skillSlugFromDisplay(display){return display.toLowerCase().replace(/\s+/g,"-")}function skillSlugToAbilityLookup(slug){return slug.replace(/-/g," ")}function flattenRaceAsi(race){var _a;const out={};if(!(race==null?void 0:race.ability_score_increases))return out;for(const asi of race.ability_score_increases){if("ability"in asi){out[asi.ability]=((_a=out[asi.ability])!=null?_a:0)+asi.amount}}return out}function subraceAsi(resolved){var _a,_b,_c,_d,_e;const subSlug=(_b=(_a=resolved.definition.subrace)==null?void 0:_a.replace(/\[\[|\]\]/g,""))!=null?_b:null;if(!subSlug)return[];const subraces=(_d=(_c=resolved.race)==null?void 0:_c.subraces)!=null?_d:[];const sub=subraces.find(s=>s.slug===subSlug);return(_e=sub==null?void 0:sub.ability_score_increases)!=null?_e:[]}function collectClassAsiBranch(resolved){var _a;const out={};for(const c of resolved.classes){for(const choice of Object.values(c.choices)){const alloc=legacyAsiBranch(choice);if(!alloc)continue;for(const ab of ABILITY_KEYS){const v=alloc[ab];if(typeof v==="number")out[ab]=((_a=out[ab])!=null?_a:0)+v}}}return out}function abilityBonusBreakdown(resolved,featureEffects){var _a,_b,_c,_d,_e,_f,_g,_h;const race=flattenRaceAsi(resolved.race);const origin=collectChosenAbilityPoints(resolved);const sub=subraceAsi(resolved);const classAsi=collectClassAsiBranch(resolved);const featPoints=collectClassFeatAbilityPoints(resolved);const out={};for(const ab of ABILITY_KEYS){let species=((_a=race[ab])!=null?_a:0)+((_b=origin.race[ab])!=null?_b:0);for(const asi of sub){if(asi.ability===ab&&typeof asi.amount==="number")species+=asi.amount}let feat=(_c=featPoints[ab])!=null?_c:0;for(const f of resolved.feats){const bonus=(_d=f.ability_bonuses)==null?void 0:_d[ab];if(typeof bonus==="number")feat+=bonus;feat+=(_e=fixedFeatAbilityIncrease(f)[ab])!=null?_e:0}out[ab]={species,background:(_f=origin.background[ab])!=null?_f:0,class:((_g=classAsi[ab])!=null?_g:0)+((_h=featureEffects==null?void 0:featureEffects.ability_bonus[ab])!=null?_h:0),feat}}return out}function fixedFeatAbilityIncrease(f){var _a;const g=f.grants_asi;if(!g||typeof g.amount!=="number"||g.amount<=0||!Array.isArray(g.pool)||g.pool.length!==1)return{};if(((_a=f.choices)!=null?_a:[]).some(c=>c.kind==="ability-points"))return{};const ab=g.pool[0];return ABILITY_KEYS.includes(ab)?{[ab]:g.amount}:{}}function hitDiceAverageSum(classes){var _a;let total=0;let firstLevelCounted=false;for(const c of classes){const die=parseDieSize((_a=c.entity)==null?void 0:_a.hit_die);if(!c.entity||die==null||c.level<1)continue;for(let lvl=1;lvl<=c.level;lvl++){if(!firstLevelCounted){total+=die;firstLevelCounted=true}else{total+=Math.floor(die/2)+1}}}return total}function hpLevelCount(classes){var _a;let count=0;for(const c of classes){const die=parseDieSize((_a=c.entity)==null?void 0:_a.hit_die);if(!c.entity||die==null||c.level<1)continue;count+=c.level}return count}function multiclassMaxHP(classes,conMod){return Math.max(1,hitDiceAverageSum(classes)+conMod*hpLevelCount(classes))}function resolveDamageRider(rider,rowDamageType,bindings){const{owner,scope:_scope,...rest}=rider;const out={...rest,amount:resolveAmountText(rider.amount,bindings(owner))};if(rider.damage_type!==void 0&&!isChosenDamageType(rider.damage_type)){const resolved=isCanonicalDamageType(rider.damage_type)?rider.damage_type:rowDamageType;if(resolved)out.damage_type=resolved;else delete out.damage_type}return out}function riderReachesRow(rider,row,opts){return scopeReachesRow(rider.scope,row,opts)}function scopeReachesRow(scope,row,opts){if(!(scope==null?void 0:scope.length))return true;return scope.some(word=>{switch(word){case"weapon":return row.unarmed!==true;case"pact-weapon":return(opts==null?void 0:opts.pactPicked)===true?row.pactWeapon===true:row.unarmed!==true;case"unarmed":return row.unarmed===true;case"melee":case"ranged":return row.weaponCategory===word;case"finesse":case"thrown":case"heavy":return row.properties.includes(word)}})}function unarmoredAC(resolved,mods,warnings){return unarmoredACBreakdown(resolved,mods,warnings).total}function unarmoredACBreakdown(resolved,mods,warnings,shieldBonus=0){var _a,_b,_c,_d,_e,_f;const baseTerms=[{source:"Unarmored",amount:10,kind:"unarmored"},{source:"DEX modifier",amount:mods.dex,kind:"dex"}];const{activeBuffs}=assembleEffectFeatures(resolved);const candidates=[{total:10+mods.dex,terms:baseTerms,shieldAllowed:true}];for(const rf of[...resolved.features,...(_a=resolved.itemFeatures)!=null?_a:[]]){if(!foldsNow(rf,activeBuffs))continue;for(const eff of selfEffectsOf(rf.feature)){if(eff.kind!=="unarmored-ac")continue;const base=(_b=eff.base)!=null?_b:10;const terms=[{source:"Unarmored",amount:base,kind:"unarmored"}];let total=base;for(const ab of eff.abilities){terms.push(ab==="dex"?{source:"DEX modifier",amount:mods.dex,kind:"dex"}:{source:`${ab.toUpperCase()} modifier (${(_c=rf.feature.name)!=null?_c:"Unarmored"})`,amount:mods[ab],kind:"ability"});total+=mods[ab]}candidates.push({total,terms,shieldAllowed:eff.allow_shield===true})}}if(candidates.length>1){const applied=c=>c.total+(c.shieldAllowed?shieldBonus:0);let best=candidates[0];for(const c of candidates)if(applied(c)>applied(best))best=c;return best}for(const rf of resolved.features){const feat=rf.feature;if((_d=feat.unarmored_defense)==null?void 0:_d.ability){const ab=feat.unarmored_defense.ability;const amt=(_e=mods[ab])!=null?_e:0;const terms=[...baseTerms,{source:`${ab.toUpperCase()} modifier (Unarmored Defense)`,amount:amt,kind:"ability"}];return{total:10+mods.dex+amt,terms,shieldAllowed:true}}}for(const rf of resolved.features){const name=((_f=rf.feature.name)!=null?_f:"").toLowerCase();if(!/unarmored\s*defense/.test(name))continue;if(rf.source.kind==="class"&&rf.source.slug.includes("monk")){const terms=[...baseTerms,{source:"WIS modifier (Unarmored Defense)",amount:mods.wis,kind:"ability"}];return{total:10+mods.dex+mods.wis,terms,shieldAllowed:true}}if(rf.source.kind==="class"&&rf.source.slug.includes("barbarian")){const terms=[...baseTerms,{source:"CON modifier (Unarmored Defense)",amount:mods.con,kind:"ability"}];return{total:10+mods.dex+mods.con,terms,shieldAllowed:true}}}return{total:10+mods.dex,terms:baseTerms,shieldAllowed:true}}function resolveUnarmedStrike(resolved){var _a,_b,_c;const dice=[];const abilities=new Set;const classOf=rf=>rf.source.kind==="class"?resolved.classes.find(c=>{var _a2;return((_a2=c.entity)==null?void 0:_a2.slug)===rf.source.slug}):void 0;const readDie=(rf,d)=>{var _a2,_b2;if(typeof d==="string")return d;if(!d)return void 0;const cls=classOf(rf);return cls?(_b2=diceColumnAt((_a2=cls.entity)==null?void 0:_a2.table,cls.level,d.column))!=null?_b2:void 0:void 0};for(const rf of resolved.features){const authored=selfEffectsOf(rf.feature).filter(e=>e.kind==="unarmed-strike");for(const e of authored){const d2=readDie(rf,e.dice);if(d2)dice.push(d2);for(const ab of(_a=e.abilities)!=null?_a:[])abilities.add(ab)}if(authored.length||rf.source.kind!=="class")continue;const slug=((_c=(_b=rf.feature.id)!=null?_b:rf.feature.name)!=null?_c:"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"");const column=unarmedDieColumnFor(slug);if(!column)continue;const d=readDie(rf,{column});if(!d)continue;dice.push(d);abilities.add("dex")}const avg=d=>{const m=/^(\d+)d(\d+)$/i.exec(d);return m?Number(m[1])*(Number(m[2])+1)/2:1};const best=dice.sort((a,b)=>avg(b)-avg(a))[0];return{...best?{dice:best}:{},...abilities.size?{abilities:[...abilities]}:{}}}function initiativeBonus(dexMod,feats,edition){var _a,_b,_c;let bonus=dexMod;for(const f of feats){const featEdition=(_a=f.edition)!=null?_a:edition;const hasData=((_b=f.effects)!=null?_b:[]).some(e=>e.kind==="initiative-bonus");if(bareEntitySlug((_c=f.slug)!=null?_c:"")==="alert"&&featEdition==="2014"&&!hasData)bonus+=5;const initBonus=f.initiative_bonus;if(typeof initBonus==="number")bonus+=initBonus}return bonus}function speedFromRace(resolved){var _a,_b,_c;const base=(_c=(_b=(_a=resolved.race)==null?void 0:_a.speed)==null?void 0:_b.walk)!=null?_c:30;let extra=0;for(const f of resolved.feats){const bonus=f.speed_bonus;if(typeof bonus==="number")extra+=bonus}return base+extra}function collectClassFeatAbilityPoints(resolved){var _a,_b;const out={};const stripRef=ref=>ref.replace(/^\[\[/,"").replace(/\]\]$/,"");const featBySlug=new Map;for(const f of resolved.feats)featBySlug.set(f.slug,f);const sites=featPickSites(resolved.classes,poolMemberSitesOf(resolved),ci=>{var _a2,_b2,_c,_d;return(_d=(_c=(_b2=(_a2=resolved.classes)==null?void 0:_a2[ci])==null?void 0:_b2.entity)==null?void 0:_c.slug)!=null?_d:null});for(const site of sites){{const feat=featBySlug.get(stripRef(site.slug));if(!feat)continue;for(const ch of(_a=feat.choices)!=null?_a:[]){if(ch.kind!=="ability-points")continue;const raw=site.read(ch.id);if(!raw||typeof raw!=="object"||Array.isArray(raw))continue;let left=ch.points;for(const ab of ABILITY_KEYS){if(ch.pool&&!ch.pool.includes(ab))continue;const v=raw[ab];if(typeof v!=="number"||v<=0||left<=0)continue;const take=Math.min(v,ch.max_per,left);out[ab]=((_b=out[ab])!=null?_b:0)+take;left-=take}}}}return out}function computeAbilityScores(resolved,overrides){var _a,_b,_c,_d,_e,_f,_g;const out={...resolved.definition.abilities};const raceBonuses=flattenRaceAsi(resolved.race);for(const ab of ABILITY_KEYS){const b=raceBonuses[ab];if(typeof b==="number")out[ab]=((_a=out[ab])!=null?_a:0)+b}for(const asi of subraceAsi(resolved)){if(asi.ability&&typeof asi.amount==="number")out[asi.ability]=((_b=out[asi.ability])!=null?_b:0)+asi.amount}const originPoints=collectChosenAbilityPoints(resolved);for(const src of[originPoints.race,originPoints.background]){for(const ab of ABILITY_KEYS){const v=src[ab];if(typeof v==="number")out[ab]=((_c=out[ab])!=null?_c:0)+v}}const classAsi=collectClassAsiBranch(resolved);for(const ab of ABILITY_KEYS){const v=classAsi[ab];if(typeof v==="number")out[ab]=((_d=out[ab])!=null?_d:0)+v}const featPoints=collectClassFeatAbilityPoints(resolved);for(const ab of ABILITY_KEYS){const v=featPoints[ab];if(typeof v==="number")out[ab]=((_e=out[ab])!=null?_e:0)+v}for(const f of resolved.feats){const bonuses=f.ability_bonuses;if(bonuses){for(const ab of ABILITY_KEYS){const v=bonuses[ab];if(typeof v==="number")out[ab]=((_f=out[ab])!=null?_f:0)+v}}for(const[ab,v]of Object.entries(fixedFeatAbilityIncrease(f)))out[ab]=((_g=out[ab])!=null?_g:0)+v}if(overrides.scores){for(const ab of ABILITY_KEYS){const v=overrides.scores[ab];if(typeof v==="number")out[ab]=v}}for(const ab of ABILITY_KEYS){if(typeof out[ab]!=="number")out[ab]=10}return out}function normalizeArmorProf(input){var _a,_b;if(!input)return{categories:[],specific:[]};if(Array.isArray(input))return{categories:input,specific:[]};return{categories:(_a=input.categories)!=null?_a:[],specific:(_b=input.specific)!=null?_b:[]}}function normalizeWeaponToolProf(input){var _a,_b,_c;if(!input)return{categories:[],specific:[]};if(Array.isArray(input))return{categories:[],specific:input};return{categories:(_a=input.categories)!=null?_a:[],specific:((_b=input.fixed)!=null?_b:[]).concat((_c=input.specific)!=null?_c:[])}}function mergeInto(target,source){for(const c of source.categories)if(!target.categories.includes(c))target.categories.push(c);for(const s of source.specific)if(!target.specific.includes(s))target.specific.push(s)}function applyArmorWeaponOverrides(profs,overrides){var _a,_b;for(const kind of["armor","weapons"]){const ov=overrides==null?void 0:overrides[kind];if(!ov)continue;const set=profs[kind];const key=v=>proficiencyKey(kind,v);const removes=new Set(((_a=ov.remove)!=null?_a:[]).map(key));for(const v of(_b=ov.add)!=null?_b:[]){const k=key(v);if(removes.has(k))continue;const category=kind==="armor"||k==="simple"||k==="martial";const target=category?set.categories:set.specific;if(!target.some(e=>key(e)===k))target.push(category?k:v)}set.categories=set.categories.filter(e=>!removes.has(key(e)));set.specific=set.specific.filter(e=>!removes.has(key(e)))}}var ORIGIN_RANK={manual:0,equipment:1,grant:2};function composeDefenseEntries(manual,equipment,grants){const byValue=new Map;for(const raw of manual){const value=toDefenseSlug(raw);if(!value||byValue.has(value))continue;byValue.set(value,{value,label:raw.trim(),origin:"manual"})}const consider=(list,origin)=>{var _a,_b,_c,_d;for(const g of list){const value=toDefenseSlug(g.value);if(!value)continue;const existing=byValue.get(value);if(!existing){byValue.set(value,{value,label:g.value.trim(),origin,sources:[...g.sources],...g.condition?{condition:g.condition}:{},...((_a=g.items)==null?void 0:_a.length)?{items:g.items.map(it=>({...it}))}:{}});continue}if(ORIGIN_RANK[origin]>ORIGIN_RANK[existing.origin])existing.origin=origin;const sources=(_b=existing.sources)!=null?_b:existing.sources=[];for(const src of g.sources)if(!sources.includes(src))sources.push(src);if(!existing.condition&&g.condition)existing.condition=g.condition;if((_c=g.items)==null?void 0:_c.length)mergeDefenseItems((_d=existing.items)!=null?_d:existing.items=[],g.items)}};consider(equipment,"equipment");consider(grants,"grant");return[...byValue.values()]}function suppress(resolved,bucket,entries){var _a,_b,_c,_d,_e;const suppressed=new Set(((_e=(_d=(_c=(_b=(_a=resolved.definition)==null?void 0:_a.overrides)==null?void 0:_b.defenses)==null?void 0:_c[bucket])==null?void 0:_d.remove)!=null?_e:[]).map(toDefenseSlug));return entries.filter(e=>!suppressed.has(e.value))}function computeProficiencies(resolved){var _a,_b,_c,_d,_e,_f,_g;const armor={categories:[],specific:[]};const weapons={categories:[],specific:[]};const tools={categories:[],specific:[]};const languages=new Set;for(const c of resolved.classes){const p=(_a=c.entity)==null?void 0:_a.proficiencies;if(!p)continue;mergeInto(armor,normalizeArmorProf(p.armor));mergeInto(weapons,normalizeWeaponToolProf(p.weapons));mergeInto(tools,normalizeWeaponToolProf(p.tools));(_b=p.languages)==null?void 0:_b.forEach(l=>languages.add(l))}const racePr=(_c=resolved.race)==null?void 0:_c.proficiencies;if(racePr){mergeInto(armor,normalizeArmorProf(racePr.armor));mergeInto(weapons,normalizeWeaponToolProf(racePr.weapons));mergeInto(tools,normalizeWeaponToolProf(racePr.tools));(_d=racePr.languages)==null?void 0:_d.forEach(l=>languages.add(l))}const bgPr=(_e=resolved.background)==null?void 0:_e.proficiencies;if(bgPr){mergeInto(armor,normalizeArmorProf(bgPr.armor));mergeInto(weapons,normalizeWeaponToolProf(bgPr.weapons));mergeInto(tools,normalizeWeaponToolProf(bgPr.tools));(_f=bgPr.languages)==null?void 0:_f.forEach(l=>languages.add(l))}for(const f of resolved.feats){const grants=f.grants_proficiency;if(!grants)continue;mergeInto(armor,normalizeArmorProf(grants.armor));mergeInto(weapons,normalizeWeaponToolProf(grants.weapons));mergeInto(tools,normalizeWeaponToolProf(grants.tools));(_g=grants.languages)==null?void 0:_g.forEach(l=>languages.add(l))}return{armor,weapons,tools,languages:Array.from(languages).sort(),saves:[]}}var HAND_SET_HALF_SOURCE="Set by you";function recalc(resolved,registry){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,_y,_z,_A,_B,_C,_D,_E,_F,_G,_H,_I,_J,_K,_L,_M,_N,_O,_P,_Q,_R,_S,_T,_U,_V,_W,_X,_Y,_Z,__,_$,_aa,_ba;const warnings=[];const overrides=(_a=resolved.definition.overrides)!=null?_a:{};const chosenProfs=collectChosenProficiencies(resolved);const{features:effectFeatures,activeBuffs}=assembleEffectFeatures(resolved);const tableDiceFor=(src,column,level)=>{var _a2;const cls=src.kind==="class"?resolved.classes.find(c=>{var _a3;return((_a3=c.entity)==null?void 0:_a3.slug)===src.slug}):src.kind==="subclass"?resolved.classes.find(c=>{var _a3;return((_a3=c.subclass)==null?void 0:_a3.slug)===src.slug}):void 0;return cls?diceColumnAt((_a2=cls.entity)==null?void 0:_a2.table,level,column):null};const tableCellFor=(src,column)=>{var _a2;const slug=ownerClassSlug(src,resolved);const cls=slug?resolved.classes.find(c=>{var _a3;return((_a3=c.entity)==null?void 0:_a3.slug)===slug}):void 0;return cls?tableCellAt((_a2=cls.entity)==null?void 0:_a2.table,cls.level,column):null};const featureEffects=computeFeatureEffects(effectFeatures,{activeBuffs,levelFor:src=>resourceLevelFor(src,resolved),tableDiceFor,tableCellFor});const profsForApply=computeProficiencies(resolved);for(const t of chosenProfs.tools){if(!profsForApply.tools.specific.includes(t))profsForApply.tools.specific.push(t)}for(const l of chosenProfs.languages){if(!profsForApply.languages.includes(l))profsForApply.languages.push(l)}for(const w of chosenProfs.weapons){if(!profsForApply.weapons.specific.includes(w))profsForApply.weapons.specific.push(w)}for(const t of featureEffects.proficiencies.tools){if(!profsForApply.tools.specific.includes(t))profsForApply.tools.specific.push(t)}for(const l of featureEffects.proficiencies.languages){if(!profsForApply.languages.includes(l))profsForApply.languages.push(l)}for(const a of featureEffects.proficiencies.armor){if(!profsForApply.armor.categories.includes(a))profsForApply.armor.categories.push(a)}for(const w of featureEffects.proficiencies.weapons){if(!profsForApply.weapons.categories.includes(w))profsForApply.weapons.categories.push(w);if(!WEAPON_CATEGORY_WORDS.has(w)&&!profsForApply.weapons.specific.includes(w)){profsForApply.weapons.specific.push(w)}}profsForApply.languages.sort();applyArmorWeaponOverrides(profsForApply,(_b=resolved.definition)==null?void 0:_b.overrides);const applied=registry?computeAppliedBonuses(resolved,profsForApply,registry,warnings):emptyAppliedBonuses();const savesInformational=applied.informational.filter(i=>i.field==="saving_throws");const spellcastingInformational=applied.informational.filter(i=>i.field==="spell_attack"||i.field==="spell_save_dc");const speedInformational=applied.informational.filter(i=>i.field.startsWith("speed."));const baseScores=computeAbilityScores(resolved,overrides);const scores={...baseScores};for(const ab of ABILITY_KEYS){const bonus=applied.ability_bonuses[ab];scores[ab]+=(typeof bonus==="number"?bonus:0)+((_c=featureEffects.ability_bonus[ab])!=null?_c:0)}for(const ab of ABILITY_KEYS){const stat=applied.ability_statics[ab];if(typeof stat==="number"&&stat>scores[ab])scores[ab]=stat}if(overrides.scores){for(const ab of ABILITY_KEYS){const o=overrides.scores[ab];if(typeof o==="number")scores[ab]=o}}const mods={str:abilityModifier(scores.str),dex:abilityModifier(scores.dex),con:abilityModifier(scores.con),int:abilityModifier(scores.int),wis:abilityModifier(scores.wis),cha:abilityModifier(scores.cha)};const totalLevel=resolved.classes.reduce((s,c)=>s+c.level,0);const proficiencyBonus=proficiencyFromLevel(totalLevel||1);const conditionEffects=computeConditionEffects(resolved.state,resolved.definition.edition,scores);const firstClass=(_e=(_d=resolved.classes[0])==null?void 0:_d.entity)!=null?_e:null;const saveProfs=new Set((_f=firstClass==null?void 0:firstClass.saving_throws)!=null?_f:[]);for(const ab of featureEffects.proficiencies.saves)saveProfs.add(ab);for(const ab of chosenProfs.saves)saveProfs.add(ab);const saves={};const saveBreakdowns={};const activeSaveBonusTerms=featureEffects.save_bonus_terms.filter(t=>{var _a2;return t.inactiveWhile==="incapacitated"?!conditionEffects.actions_disabled:t.inactiveWhile==="unconscious"?!((_a2=resolved.state.conditions)!=null?_a2:[]).includes("unconscious"):true});for(const ab of ABILITY_KEYS){const override=(_g=overrides.saves)==null?void 0:_g[ab];const prof=(_h=override==null?void 0:override.proficient)!=null?_h:saveProfs.has(ab);const featureTerms=[];for(const t of activeSaveBonusTerms){if(t.saves.length>0&&!t.saves.includes(ab))continue;const amount=Math.max(t.minimum,mods[t.ability]);const prior=featureTerms.find(x=>x.source===t.label);if(prior===void 0)featureTerms.push({source:t.label,amount});else if(amount>prior.amount)prior.amount=amount}const derivedBonus=savingThrow(scores[ab],prof,proficiencyBonus)+applied.save_bonus+featureTerms.reduce((sum,t)=>sum+t.amount,0)+conditionEffects.d20_test_penalty;const bonus=(_i=override==null?void 0:override.bonus)!=null?_i:derivedBonus;saves[ab]={bonus,proficient:prof};saveBreakdowns[ab]=[{source:ab.toUpperCase(),amount:mods[ab]},...prof?[{source:"Proficiency",amount:proficiencyBonus}]:[],...applied.save_terms.map(t=>({...t})),...featureTerms,...conditionEffects.d20_test_penalty?[{source:`Exhaustion ${conditionEffects.exhaustion_level}`,amount:conditionEffects.d20_test_penalty}]:[]]}const profSet=new Set([...resolved.definition.skills.proficient,...(_k=(_j=resolved.background)==null?void 0:_j.skill_proficiencies)!=null?_k:[],...chosenProfs.skills,...featureEffects.proficiencies.skills]);const expSet=new Set([...resolved.definition.skills.expertise,...chosenProfs.expertise,...featureEffects.proficiencies.skillExpertise]);const skills={};const skillBreakdowns={};for(const skill of ALL_SKILLS){const skillKey=skillSlugFromDisplay(skill);const ab=SKILL_ABILITY[skillSlugToAbilityLookup(skillKey)];const override=(_l=overrides.skills)==null?void 0:_l[skillKey];const tri=(_m=override==null?void 0:override.proficiency)!=null?_m:expSet.has(skillKey)?"expertise":profSet.has(skillKey)?"proficient":"none";const skillTerms=featureEffects.skill_bonus_terms.filter(t=>t.skills.includes(skillKey)).map(t=>({source:t.label,amount:Math.max(t.minimum,mods[t.ability])}));const halfProfTerms=tri!=="none"?[]:[...featureEffects.half_proficiency_terms.filter(t=>t.skills.length===0||t.skills.includes(skillKey)).map(t=>({source:t.label,amount:t.round==="up"?Math.ceil(proficiencyBonus/2):Math.floor(proficiencyBonus/2)})),...((_n=resolved.definition.skills.half)==null?void 0:_n.includes(skillKey))?[{source:HAND_SET_HALF_SOURCE,amount:Math.floor(proficiencyBonus/2)}]:[]];const halfProfBest=halfProfTerms.length?halfProfTerms.reduce((best,t)=>t.amount>best.amount?t:best):null;const bonus=(_p=override==null?void 0:override.bonus)!=null?_p:skillBonus(scores[ab],tri,proficiencyBonus)+skillTerms.reduce((sum,t)=>sum+t.amount,0)+((_o=halfProfBest==null?void 0:halfProfBest.amount)!=null?_o:0)+conditionEffects.d20_test_penalty;skillBreakdowns[skillKey]=[{source:ab.toUpperCase(),amount:mods[ab]},...tri!=="none"?[{source:tri==="expertise"?"Expertise":"Proficiency",amount:proficiencyBonus*(tri==="expertise"?2:1)}]:[],...skillTerms,...halfProfBest?[halfProfBest]:[],...conditionEffects.d20_test_penalty?[{source:"Conditions",amount:conditionEffects.d20_test_penalty}]:[]];skills[skillKey]={bonus,proficiency:tri,ability:ab,...halfProfBest?{halfProficiency:{source:halfProfBest.source,amount:halfProfBest.amount}}:{}}}const passives={perception:(_r=(_q=overrides.passives)==null?void 0:_q.perception)!=null?_r:10+skills.perception.bonus,investigation:(_t=(_s=overrides.passives)==null?void 0:_s.investigation)!=null?_t:10+skills.investigation.bonus,insight:(_v=(_u=overrides.passives)==null?void 0:_u.insight)!=null?_v:10+skills.insight.bonus};const hpRolled=(_x=(_w=overrides.hp)==null?void 0:_w.rolled)!=null?_x:null;const hpModifier=(_z=(_y=overrides.hp)==null?void 0:_y.modifier)!=null?_z:null;const averageDiceSum=hitDiceAverageSum(resolved.classes);const conLevels=hpLevelCount(resolved.classes);const diceSum=hpRolled!=null?hpRolled:averageDiceSum;const diceConRaw=diceSum+mods.con*conLevels;const diceConClamped=Math.max(1,diceConRaw);const hpMaxDerived=diceConClamped+featureEffects.hp_per_level_bonus*totalLevel+(hpModifier!=null?hpModifier:0);const hpMaxAfterConditions=Math.max(0,Math.floor(hpMaxDerived*conditionEffects.hp_max_multiplier));const hpMax=(_B=(_A=overrides.hp)==null?void 0:_A.max)!=null?_B:hpMaxAfterConditions;const hpBreakdown={diceSum,diceSource:hpRolled!=null?"rolled":"average",averageDiceSum,conMod:mods.con,conLevels,clampApplied:diceConClamped!==diceConRaw,perLevelTerms:featureEffects.hp_per_level_terms.map(t=>({label:t.label,perLevel:t.value,levels:totalLevel,total:t.value*totalLevel})),modifier:hpModifier,exhaustionMultiplier:conditionEffects.hp_max_multiplier,exhaustionLevel:conditionEffects.exhaustion_level,derivedMax:hpMaxAfterConditions,override:(_D=(_C=overrides.hp)==null?void 0:_C.max)!=null?_D:null,final:hpMax};const featureAcTermsFor=hasArmor=>featureEffects.ac_terms.filter(t=>!t.requires_armor||hasArmor).map(t=>({source:t.label,amount:t.value,kind:"feature",condition:t.condition}));const sumTerms=terms=>terms.reduce((s,t)=>s+t.amount,0);const weaponAbilities=[...featureEffects.weaponAbilities];const wantsSpellcasting=resolved.features.some(rf=>selfEffectsOf(rf.feature).some(e=>e.kind==="weapon-ability"&&e.ability==="spellcasting"));if(wantsSpellcasting){let primaryCasterAbility=null;for(const c of resolved.classes){if(!c.entity)continue;const profile=resolveSpellcasting(c);if(profile){primaryCasterAbility=effectiveSpellcastingAbility(c.entity.slug,profile.ability,overrides);break}}if(primaryCasterAbility)weaponAbilities.unshift({ability:primaryCasterAbility})}let derivedEquipment=null;let acDerived;let acBreakdownDerived=[];let acInformationalDerived=[];if(registry){derivedEquipment=computeSlotsAndAttacks(resolved,mods,profsForApply,registry,warnings,proficiencyBonus,weaponAbilities,(_E=resolved.weaponMasteries)!=null?_E:[],featureEffects.attunement_set);if(derivedEquipment.equippedSlots.armor){const featTerms=featureAcTermsFor(true);acDerived=derivedEquipment.ac+sumTerms(featTerms);acBreakdownDerived=[...derivedEquipment.acBreakdown,...featTerms];acInformationalDerived=derivedEquipment.acInformational}else{const shieldBonus=derivedEquipment.acBreakdown.filter(b=>b.kind==="shield").reduce((sum,b)=>sum+b.amount,0);const{total:unarmored,terms:unarmoredTerms,shieldAllowed}=unarmoredACBreakdown(resolved,mods,warnings,shieldBonus);const additive=derivedEquipment.acBreakdown.filter(b=>b.kind==="item"||b.kind==="override"||b.kind==="shield"&&shieldAllowed);const featTerms=featureAcTermsFor(false);const additiveSum=additive.reduce((sum,b)=>sum+b.amount,0);acDerived=unarmored+additiveSum+sumTerms(featTerms);acBreakdownDerived=[...unarmoredTerms,...additive,...featTerms];acInformationalDerived=derivedEquipment.acInformational}}else{const{total,terms}=unarmoredACBreakdown(resolved,mods,warnings);const featTerms=featureAcTermsFor(false);acDerived=total+sumTerms(featTerms);acBreakdownDerived=[...terms,...featTerms]}const ac=(_F=overrides.ac)!=null?_F:acDerived;const worn=wornArmor(derivedEquipment==null?void 0:derivedEquipment.equippedSlots,registry);const featureSpeedTerms=featureEffects.speed_terms.filter(t=>speedTermActive(t,worn));const gatedWalk=featureSpeedTerms.filter(t=>t.mode==="walk"&&t.inactiveWhile!==void 0);const featureWalkBonus=featureEffects.speed_walk_bonus+gatedWalk.filter(t=>!t.set).reduce((sum,t)=>sum+t.value,0);const featureWalkFloor=Math.max(featureEffects.speed_walk_set,...gatedWalk.filter(t=>t.set).map(t=>t.value));const armorPenalty=armorStrengthPenalty(worn,scores.str,featureEffects.ignore_armor_strength);const additiveSpeed=speedFromRace(resolved)+applied.speed_bonuses.walk+featureWalkBonus+((_G=armorPenalty==null?void 0:armorPenalty.amount)!=null?_G:0);const baseSpeed=Math.max(featureWalkFloor,applied.speed_walk_set,additiveSpeed);const adjustedSpeed=baseSpeed*conditionEffects.speed_multiplier-conditionEffects.speed_reduction_ft;const conditionSpeed=conditionEffects.speed_floor_zero?0:Math.max(0,Math.floor(adjustedSpeed));const speed=(_H=overrides.speed)!=null?_H:conditionSpeed;const raceSpeed=(_K=(_J=(_I=resolved.race)==null?void 0:_I.speed)==null?void 0:_J.walk)!=null?_K:30;const speeds=buildSpeedLines({resolved,applied,features:{speed_terms:featureSpeedTerms,speed_walk_set:featureWalkFloor},conditions:conditionEffects,conditionNames:speedConditionNames(resolved.state,resolved.definition.edition),walk:{race:raceSpeed,additive:additiveSpeed,base:baseSpeed,final:conditionSpeed},armorPenalty:armorPenalty?{term:armorPenalty,everyMode:resolved.definition.edition==="2024"}:null});const speedBreakdown=speeds[0].terms;if(!resolved.race)warnings.push("No race resolved; speed defaulted to 30.");const initiativeAmountTerms=featureEffects.initiative_amount_terms.flatMap(term2=>{const text=resolveAmountText(term2.amount,amountBindingsFor(term2.owner,resolved,{proficiencyBonus,mods,spellcastingClasses:[]}));const n=Number(text);if(!Number.isInteger(n)){warnings.push(`${term2.label}: initiative amount "${term2.amount}" is not a number; nothing added.`);return[]}return[{source:term2.label,amount:n}]});const init=(_L=overrides.initiative)!=null?_L:initiativeBonus(mods.dex,resolved.feats,resolved.definition.edition)+featureEffects.initiative_bonus+initiativeAmountTerms.reduce((s,t)=>s+t.amount,0);const initiativeBreakdown=[{source:"DEX",amount:mods.dex},...initiativeBonus(mods.dex,resolved.feats,resolved.definition.edition)!==mods.dex?[{source:"Feats",amount:initiativeBonus(mods.dex,resolved.feats,resolved.definition.edition)-mods.dex}]:[],...featureEffects.initiative_terms.map(term2=>({source:term2.label,amount:term2.value})),...initiativeAmountTerms];const senses={darkvision:Math.max((_O=(_N=(_M=resolved.race)==null?void 0:_M.vision)==null?void 0:_N.darkvision)!=null?_O:0,featureEffects.senses.darkvision,applied.senses.darkvision),blindsight:Math.max(featureEffects.senses.blindsight,applied.senses.blindsight),tremorsense:Math.max(featureEffects.senses.tremorsense,applied.senses.tremorsense),truesight:Math.max(featureEffects.senses.truesight,applied.senses.truesight)};const spellcastingClasses=[];const slotInputs=[];const limitInputs=[];for(const c of resolved.classes){if(!c.entity)continue;const profile=resolveSpellcasting(c);if(!profile)continue;const ab=effectiveSpellcastingAbility(c.entity.slug,profile.ability,overrides);const dc=saveDC(scores[ab],proficiencyBonus)+applied.spell_save_dc;const atk=attackBonus(scores[ab],proficiencyBonus)+applied.spell_attack;spellcastingClasses.push({classSlug:c.entity.slug,className:c.entity.name,ability:ab,defaultAbility:profile.ability,saveDC:dc,attackBonus:atk,casterType:profile.casterType,preparation:profile.preparation,spellList:profile.spellList});slotInputs.push({casterType:profile.casterType,level:c.level});limitInputs.push({classSlug:c.entity.slug,level:c.level,profile,abilityScore:scores[ab]})}const spellcasting=spellcastingClasses.length>0?{ability:spellcastingClasses[0].ability,saveDC:spellcastingClasses[0].saveDC,attackBonus:spellcastingClasses[0].attackBonus}:null;const abilitySpellcasting={};for(const s of resolved.spells){const ab=s.ability;if(!ab||abilitySpellcasting[ab])continue;abilitySpellcasting[ab]={saveDC:saveDC(scores[ab],proficiencyBonus)+applied.spell_save_dc,attackBonus:attackBonus(scores[ab],proficiencyBonus)+applied.spell_attack}}const derivedSlots=deriveSpellSlots(slotInputs);const spellLimits=computeSpellLimits(limitInputs);const defenses={resistances:suppress(resolved,"resistances",composeDefenseEntries((_Q=(_P=resolved.definition.defenses)==null?void 0:_P.resistances)!=null?_Q:[],applied.defenses.resistances,featureEffects.resistances)),immunities:suppress(resolved,"immunities",composeDefenseEntries((_S=(_R=resolved.definition.defenses)==null?void 0:_R.immunities)!=null?_S:[],applied.defenses.immunities,featureEffects.immunities)),vulnerabilities:suppress(resolved,"vulnerabilities",composeDefenseEntries((_U=(_T=resolved.definition.defenses)==null?void 0:_T.vulnerabilities)!=null?_U:[],applied.defenses.vulnerabilities,featureEffects.vulnerabilities)),condition_immunities:suppress(resolved,"condition_immunities",composeDefenseEntries((_W=(_V=resolved.definition.defenses)==null?void 0:_V.condition_immunities)!=null?_W:[],applied.defenses.condition_immunities,featureEffects.condition_immunities))};const attackRows=[...(_X=derivedEquipment==null?void 0:derivedEquipment.attacks)!=null?_X:[],...buildFeatureAttackRows(resolved,mods,profsForApply,proficiencyBonus,weaponAbilities),buildUnarmedRow(mods,proficiencyBonus,resolveUnarmedStrike(resolved))];const scopeOpts={pactPicked:pactWeaponIndexes(resolved,registry)!==null};const riderBindings=owner=>amountBindingsFor(owner,resolved,{proficiencyBonus,mods,spellcastingClasses});const ownSpells=(_Y=resolved.spells)!=null?_Y:[];const spellDamageRiders=featureEffects.spellDamageBonuses.flatMap(r=>{const reached=new Set([...spellsReached(r.targets,ownSpells),...spellsInScope(r.scope,ownSpells,id=>pickedDamageTypes(resolved,id))]);const spells=[...new Set(ownSpells.map(s=>s.slug))].filter(slug=>reached.has(slug));if(!spells.length)return[];const{owner,targets:_targets,scope,damage_type,...rest}=r;return[{...rest,amount:resolveAmountText(r.amount,riderBindings(owner)),...damage_type&&isCanonicalDamageType(damage_type)?{damage_type}:{},...(scope==null?void 0:scope.once)?{once:true}:{},spells}]});const scopedExtra=featureEffects.scopedExtraAttacks;const rowAttacks=attackRows.map(a=>scopedExtra.length?1+Math.max(featureEffects.extraAttack,...scopedExtra.filter(x=>scopeReachesRow(x.scope,a,scopeOpts)).map(x=>x.count)):void 0);return{totalLevel,proficiencyBonus,scores,mods,saves,proficiencies:profsForApply,skills,statBreakdowns:{skills:skillBreakdowns,saves:saveBreakdowns,speed:speedBreakdown,initiative:initiativeBreakdown},passives,senses,hp:{max:hpMax,current:resolved.state.hp.current,temp:resolved.state.hp.temp},hpBreakdown,ac,speed,speeds,initiative:init,spellcasting,spellcastingClasses,abilitySpellcasting,derivedSpellSlots:derivedSlots.standard,pactMagic:derivedSlots.pact,spellLimits,warnings,defenses,acBreakdown:acBreakdownDerived,acInformational:acInformationalDerived,savesInformational,spellcastingInformational,speedInformational,attacksPerAction:Math.max(1+featureEffects.extraAttack,...rowAttacks.filter(n=>n!==void 0)),attacks:attackRows.map((a,i)=>{var _a2,_b2,_c2;const critRange=Math.min((_a2=a.critRange)!=null?_a2:20,featureEffects.critRange);const conditionalCrits=[...(_b2=a.conditionalCrits)!=null?_b2:[],...featureEffects.conditionalCrits].filter(c=>c.minRoll<critRange);const riders=[...(_c2=a.damageRiders)!=null?_c2:[],...featureEffects.damageBonuses.filter(r=>riderReachesRow(r,a,scopeOpts))].map(r=>resolveDamageRider(r,a.damageType,riderBindings));const{critRange:_ownCrit,conditionalCrits:_ownConditional,...row}=a;return{...row,toHit:a.toHit+conditionEffects.d20_test_penalty,...critRange<20?{critRange}:{},...conditionalCrits.length?{conditionalCrits}:{},...featureEffects.attackNotes.length?{attackNotes:featureEffects.attackNotes}:{},...riders.length?{damageRiders:riders}:{},...rowAttacks[i]!==void 0?{attacksPerAction:rowAttacks[i]}:{}}}),...spellDamageRiders.length?{spellDamageRiders}:{},equippedSlots:(_Z=derivedEquipment==null?void 0:derivedEquipment.equippedSlots)!=null?_Z:{},carriedWeight:(__=derivedEquipment==null?void 0:derivedEquipment.carriedWeight)!=null?__:0,attunementUsed:(_$=derivedEquipment==null?void 0:derivedEquipment.attunementUsed)!=null?_$:0,attunementLimit:(_ba=derivedEquipment==null?void 0:derivedEquipment.attunementLimit)!=null?_ba:(_aa=overrides.attunement_limit)!=null?_aa:Math.max(3,featureEffects.attunement_set),conditionEffects,rollModifiers:featureEffects.rollModifiers,saveOutcomes:featureEffects.saveOutcomes}}export{HAND_SET_HALF_SOURCE,abilityBonusBreakdown,collectClassAsiBranch,collectClassFeatAbilityPoints,computeAbilityScores,computeProficiencies,fixedFeatAbilityIncrease,flattenRaceAsi,hitDiceAverageSum,hpLevelCount,initiativeBonus,multiclassMaxHP,parseDieSize,phbAverageForDie,recalc,resolveUnarmedStrike,riderReachesRow,scopeReachesRow,speedFromRace,unarmoredAC,unarmoredACBreakdown};