solve-engine 2.6.0 → 2.8.0

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 (177) hide show
  1. package/dist/{PackageCompatibility-CCdud__Q.d.cts → PackageCompatibility-BG0iur4I.d.cts} +1 -1
  2. package/dist/{PackageCompatibility-4QtIErfx.d.ts → PackageCompatibility-BlIcQg5v.d.ts} +1 -1
  3. package/dist/{PackageRegistry-B7wkfSrY.d.ts → PackageRegistry-BJ0QQd3k.d.ts} +4 -4
  4. package/dist/{PackageRegistry-Hx85XD01.d.cts → PackageRegistry-DeGDZkNt.d.cts} +4 -4
  5. package/dist/{Parselet-CTNpfuEB.d.cts → Parselet-BSndkWEY.d.cts} +1 -1
  6. package/dist/{Parselet-DONNUpur.d.ts → Parselet-Blq8B0Gj.d.ts} +1 -1
  7. package/dist/{ScopeManager-BkbDXK_R.d.ts → ScopeManager-CF3cZUqW.d.ts} +2 -2
  8. package/dist/{ScopeManager-Cvgypcu4.d.cts → ScopeManager-D8nLv--u.d.cts} +2 -2
  9. package/dist/{VMCheckpoints-9zBQnTsN.d.ts → VMCheckpoints-BsR5_auF.d.ts} +2 -2
  10. package/dist/{VMCheckpoints-CBMGiSqw.d.cts → VMCheckpoints-Dy39SVHa.d.cts} +2 -2
  11. package/dist/{Value-D1XlMwe2.d.cts → Value-DCTqTSeP.d.cts} +22 -5
  12. package/dist/{Value-D1XlMwe2.d.ts → Value-DCTqTSeP.d.ts} +22 -5
  13. package/dist/{chunk-T52Y5G24.js → chunk-2V44X7GH.js} +4 -4
  14. package/dist/{chunk-T52Y5G24.js.map → chunk-2V44X7GH.js.map} +1 -1
  15. package/dist/{chunk-5FO4PDIG.js → chunk-3GAWAMT4.js} +2 -2
  16. package/dist/{chunk-5FO4PDIG.js.map → chunk-3GAWAMT4.js.map} +1 -1
  17. package/dist/{chunk-32GC2FHC.cjs → chunk-3HYO3QYW.cjs} +2 -2
  18. package/dist/{chunk-32GC2FHC.cjs.map → chunk-3HYO3QYW.cjs.map} +1 -1
  19. package/dist/{chunk-2JMFUQZH.js → chunk-44EOEWGP.js} +2 -2
  20. package/dist/chunk-44EOEWGP.js.map +1 -0
  21. package/dist/chunk-5TCSFTZD.js +2 -0
  22. package/dist/chunk-5TCSFTZD.js.map +1 -0
  23. package/dist/chunk-5TVI2UPZ.cjs +2 -0
  24. package/dist/chunk-5TVI2UPZ.cjs.map +1 -0
  25. package/dist/{chunk-CIQOK7Q4.cjs → chunk-6QRHN3I6.cjs} +2 -2
  26. package/dist/chunk-6QRHN3I6.cjs.map +1 -0
  27. package/dist/chunk-6TPXH6Y5.cjs +3 -0
  28. package/dist/chunk-6TPXH6Y5.cjs.map +1 -0
  29. package/dist/{chunk-ZOOVGXMK.cjs → chunk-75XDS65A.cjs} +2 -2
  30. package/dist/{chunk-ZOOVGXMK.cjs.map → chunk-75XDS65A.cjs.map} +1 -1
  31. package/dist/chunk-A33K7NY4.js +2 -0
  32. package/dist/chunk-A33K7NY4.js.map +1 -0
  33. package/dist/chunk-BKSKZA4W.cjs +2 -0
  34. package/dist/chunk-BKSKZA4W.cjs.map +1 -0
  35. package/dist/{chunk-VAGS5JS7.cjs → chunk-C65UDMWH.cjs} +2 -2
  36. package/dist/{chunk-VAGS5JS7.cjs.map → chunk-C65UDMWH.cjs.map} +1 -1
  37. package/dist/{chunk-OVQ3V4CG.cjs → chunk-CIENDLKV.cjs} +2 -2
  38. package/dist/{chunk-OVQ3V4CG.cjs.map → chunk-CIENDLKV.cjs.map} +1 -1
  39. package/dist/chunk-DLAKPF5T.js +2 -0
  40. package/dist/chunk-DLAKPF5T.js.map +1 -0
  41. package/dist/chunk-EOMHELRL.js +2 -0
  42. package/dist/chunk-EOMHELRL.js.map +1 -0
  43. package/dist/chunk-EURCQMZK.cjs +2 -0
  44. package/dist/{chunk-Z5KBBQOJ.cjs.map → chunk-EURCQMZK.cjs.map} +1 -1
  45. package/dist/{chunk-HOQU47MF.cjs → chunk-FNNIAJNY.cjs} +2 -2
  46. package/dist/{chunk-HOQU47MF.cjs.map → chunk-FNNIAJNY.cjs.map} +1 -1
  47. package/dist/{chunk-3AVWA5IZ.cjs → chunk-FUDVKPB7.cjs} +2 -2
  48. package/dist/{chunk-3AVWA5IZ.cjs.map → chunk-FUDVKPB7.cjs.map} +1 -1
  49. package/dist/{chunk-4XTD4B77.js → chunk-GAAXTO4K.js} +3 -3
  50. package/dist/{chunk-4XTD4B77.js.map → chunk-GAAXTO4K.js.map} +1 -1
  51. package/dist/{chunk-G7TBEQRQ.js → chunk-GMSBBLUQ.js} +2 -2
  52. package/dist/{chunk-G7TBEQRQ.js.map → chunk-GMSBBLUQ.js.map} +1 -1
  53. package/dist/chunk-HDVZZ7JN.js +3 -0
  54. package/dist/chunk-HDVZZ7JN.js.map +1 -0
  55. package/dist/{chunk-SWKYVSMP.js → chunk-JEFMG6CV.js} +2 -2
  56. package/dist/{chunk-SWKYVSMP.js.map → chunk-JEFMG6CV.js.map} +1 -1
  57. package/dist/{chunk-P6BLASAA.js → chunk-JQBG3LX4.js} +2 -2
  58. package/dist/{chunk-P6BLASAA.js.map → chunk-JQBG3LX4.js.map} +1 -1
  59. package/dist/{chunk-GHW2X7PS.js → chunk-KHCNMNZZ.js} +2 -2
  60. package/dist/{chunk-GHW2X7PS.js.map → chunk-KHCNMNZZ.js.map} +1 -1
  61. package/dist/chunk-LH7URJZT.js +3 -0
  62. package/dist/chunk-LH7URJZT.js.map +1 -0
  63. package/dist/{chunk-R7T3NGUE.cjs → chunk-MVP2YD4X.cjs} +2 -2
  64. package/dist/{chunk-R7T3NGUE.cjs.map → chunk-MVP2YD4X.cjs.map} +1 -1
  65. package/dist/{chunk-KSDTVFXA.cjs → chunk-OZ6SKIPD.cjs} +4 -4
  66. package/dist/{chunk-KSDTVFXA.cjs.map → chunk-OZ6SKIPD.cjs.map} +1 -1
  67. package/dist/chunk-PNDQRCRQ.cjs +2 -0
  68. package/dist/chunk-PNDQRCRQ.cjs.map +1 -0
  69. package/dist/{chunk-YAHGSBMC.js → chunk-QYO7IEPR.js} +2 -2
  70. package/dist/{chunk-YAHGSBMC.js.map → chunk-QYO7IEPR.js.map} +1 -1
  71. package/dist/{chunk-2LFLR3VZ.cjs → chunk-SNVPM27Q.cjs} +2 -2
  72. package/dist/{chunk-2LFLR3VZ.cjs.map → chunk-SNVPM27Q.cjs.map} +1 -1
  73. package/dist/{chunk-AR7L5OJ2.js → chunk-T3FBAFRR.js} +2 -2
  74. package/dist/{chunk-AR7L5OJ2.js.map → chunk-T3FBAFRR.js.map} +1 -1
  75. package/dist/chunk-TUBLMUTZ.cjs +2 -0
  76. package/dist/chunk-TUBLMUTZ.cjs.map +1 -0
  77. package/dist/chunk-U47GA63S.cjs +3 -0
  78. package/dist/chunk-U47GA63S.cjs.map +1 -0
  79. package/dist/{chunk-HMEZJXLX.js → chunk-UKDUFMT5.js} +2 -2
  80. package/dist/{chunk-HMEZJXLX.js.map → chunk-UKDUFMT5.js.map} +1 -1
  81. package/dist/chunk-UWAXJX5G.js +2 -0
  82. package/dist/chunk-UWAXJX5G.js.map +1 -0
  83. package/dist/chunk-WEAKI5V5.cjs +2 -0
  84. package/dist/chunk-WEAKI5V5.cjs.map +1 -0
  85. package/dist/{chunk-VYWGUMFW.js → chunk-WTEXBPBR.js} +2 -2
  86. package/dist/{chunk-VYWGUMFW.js.map → chunk-WTEXBPBR.js.map} +1 -1
  87. package/dist/{chunk-NXIMGB4S.cjs → chunk-WYIOXAFW.cjs} +2 -2
  88. package/dist/{chunk-NXIMGB4S.cjs.map → chunk-WYIOXAFW.cjs.map} +1 -1
  89. package/dist/{chunk-B4P4M4ZW.cjs → chunk-YORX7723.cjs} +3 -3
  90. package/dist/{chunk-B4P4M4ZW.cjs.map → chunk-YORX7723.cjs.map} +1 -1
  91. package/dist/chunk-YTCTUBR2.js +2 -0
  92. package/dist/{chunk-XTM4HTRB.js.map → chunk-YTCTUBR2.js.map} +1 -1
  93. package/dist/constants.cjs +1 -1
  94. package/dist/constants.js +1 -1
  95. package/dist/engine.cjs +1 -1
  96. package/dist/engine.d.cts +7 -7
  97. package/dist/engine.d.ts +7 -7
  98. package/dist/engine.js +1 -1
  99. package/dist/format.cjs +1 -1
  100. package/dist/format.d.cts +1 -1
  101. package/dist/format.d.ts +1 -1
  102. package/dist/format.js +1 -1
  103. package/dist/index.cjs +1 -1
  104. package/dist/index.d.cts +7 -7
  105. package/dist/index.d.ts +7 -7
  106. package/dist/index.js +1 -1
  107. package/dist/language.cjs +1 -1
  108. package/dist/language.d.cts +6 -6
  109. package/dist/language.d.ts +6 -6
  110. package/dist/language.js +1 -1
  111. package/dist/lexer.cjs +1 -1
  112. package/dist/lexer.js +1 -1
  113. package/dist/normalizer.cjs +1 -1
  114. package/dist/normalizer.js +1 -1
  115. package/dist/packages.cjs +1 -1
  116. package/dist/packages.d.cts +6 -6
  117. package/dist/packages.d.ts +6 -6
  118. package/dist/packages.js +1 -1
  119. package/dist/parser.cjs +1 -1
  120. package/dist/parser.d.cts +3 -3
  121. package/dist/parser.d.ts +3 -3
  122. package/dist/parser.js +1 -1
  123. package/dist/{pipeline-DY0rhgQG.d.cts → pipeline-BM8xc0CZ.d.cts} +3 -3
  124. package/dist/{pipeline-BH7BFOTJ.d.ts → pipeline-J2ehIm7t.d.ts} +3 -3
  125. package/dist/resolvers.d.cts +1 -1
  126. package/dist/resolvers.d.ts +1 -1
  127. package/dist/testing.cjs +2 -2
  128. package/dist/testing.d.cts +6 -6
  129. package/dist/testing.d.ts +6 -6
  130. package/dist/testing.js +1 -1
  131. package/dist/uom.cjs +1 -1
  132. package/dist/uom.d.cts +1 -1
  133. package/dist/uom.d.ts +1 -1
  134. package/dist/uom.js +1 -1
  135. package/dist/vm.cjs +1 -1
  136. package/dist/vm.d.cts +6 -6
  137. package/dist/vm.d.ts +6 -6
  138. package/dist/vm.js +1 -1
  139. package/dist/worker.cjs +2 -2
  140. package/dist/worker.cjs.map +1 -1
  141. package/dist/worker.d.cts +15 -5
  142. package/dist/worker.d.ts +15 -5
  143. package/dist/worker.js +2 -2
  144. package/dist/worker.js.map +1 -1
  145. package/package.json +1 -1
  146. package/dist/chunk-2JMFUQZH.js.map +0 -1
  147. package/dist/chunk-3DD2RVBI.cjs +0 -3
  148. package/dist/chunk-3DD2RVBI.cjs.map +0 -1
  149. package/dist/chunk-5FGOIDLS.cjs +0 -2
  150. package/dist/chunk-5FGOIDLS.cjs.map +0 -1
  151. package/dist/chunk-5OIXCVB2.js +0 -3
  152. package/dist/chunk-5OIXCVB2.js.map +0 -1
  153. package/dist/chunk-CIQOK7Q4.cjs.map +0 -1
  154. package/dist/chunk-ESUN2THE.cjs +0 -2
  155. package/dist/chunk-ESUN2THE.cjs.map +0 -1
  156. package/dist/chunk-FWW3M36J.cjs +0 -2
  157. package/dist/chunk-FWW3M36J.cjs.map +0 -1
  158. package/dist/chunk-GKDZ7TSX.cjs +0 -2
  159. package/dist/chunk-GKDZ7TSX.cjs.map +0 -1
  160. package/dist/chunk-IANAMBJQ.cjs +0 -2
  161. package/dist/chunk-IANAMBJQ.cjs.map +0 -1
  162. package/dist/chunk-IO374J6Z.js +0 -2
  163. package/dist/chunk-IO374J6Z.js.map +0 -1
  164. package/dist/chunk-R2ENWQ76.js +0 -2
  165. package/dist/chunk-R2ENWQ76.js.map +0 -1
  166. package/dist/chunk-SOSUS2SK.cjs +0 -3
  167. package/dist/chunk-SOSUS2SK.cjs.map +0 -1
  168. package/dist/chunk-T4Y5XOT2.js +0 -3
  169. package/dist/chunk-T4Y5XOT2.js.map +0 -1
  170. package/dist/chunk-TRBXW6HW.js +0 -2
  171. package/dist/chunk-TRBXW6HW.js.map +0 -1
  172. package/dist/chunk-WGZ3FNHI.js +0 -2
  173. package/dist/chunk-WGZ3FNHI.js.map +0 -1
  174. package/dist/chunk-XTM4HTRB.js +0 -2
  175. package/dist/chunk-Z5KBBQOJ.cjs +0 -2
  176. package/dist/chunk-ZJPAPBP3.js +0 -2
  177. package/dist/chunk-ZJPAPBP3.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/uom/UnitConversion.ts","../src/uom/UomConverter.ts"],"names":["UNIT_LOOKUP","UNIT_TABLE","DIFFERENCE_LOOKUP","UNIT_DIFFERENCES","lookupUnit","unit","convertRaw","quantity","from","to","parsedFrom","parsedTo","convertResolved","fromEntry","toEntry","fromRatio","toRatio","fromDifference","toDifference","convertToBestMetric","best","BEST_UNITS_METRIC","smallestUnit","bestUnit","baseQuantity","absQuantity","i","bestEntry","WORKDAY_UNIT_NAMES","WORKDAY_TO_DAY_FACTOR","isWorkdayUnit","resolveUnit","getMeasure","extended","EXTENDED_UNITS","entry","MEASURE_KIND_NAMES","canConvert","fromMeasure","toMeasure","fromExtended","toExtended","bridgesToBaseMeasure","extendedUnit","baseUnit","base","convertUnit","value","days","fExt","tExt","baseUnitFor","symbol","candidate","getConvertiblePossibilities","resolved","symbols","MEASURE_SYMBOLS","s","isConvertibleUnit","getBestUnit","u","result","FUEL_RATE_UNITS","expandUnitToRate","fuel","slash","ext","rateAxisFactor","convertRate","source","targetNumerator","targetDenominator","targetScale","fuelTarget","numeratorFactor","denominatorFactor","crossNumerator","crossDenominator"],"mappings":"qDAmCA,IAAMA,CAAAA,CAA8C,IAAI,GAAA,CAAI,MAAA,CAAO,OAAA,CAAQC,CAAU,CAAC,CAAA,CAShFC,CAAAA,CAAiD,IAAI,GAAA,CAAI,MAAA,CAAO,QAAQC,CAAgB,CAAC,CAAA,CAgBxF,SAASC,CAAAA,CAAWC,CAAAA,CAAqC,CAC9D,OAAOL,CAAAA,CAAY,GAAA,CAAIK,CAAI,CAC7B,CAWO,SAASC,EAAWC,CAAAA,CAAkBC,CAAAA,CAAcC,CAAAA,CAAoB,CAC7E,IAAMC,CAAAA,CAAaV,CAAAA,CAAY,GAAA,CAAIQ,CAAI,CAAA,CACvC,GAAIE,CAAAA,GAAe,MAAA,CACjB,MAAM,IAAI,UAAA,CAAW,CAAA,EAAGF,CAAI,CA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CAAaC,CAAe,CAAA,CACnEO,CAAAA,CAAmBV,CAAAA,CAAeE,CAAAA,CAAO,SAAA,CAAWE,CAAiB,CAAA,CAC3E,OAAIK,CAAAA,GAAmB,IAAA,EAAQC,CAAAA,GAAqB,IAAA,EAAQR,CAAAA,CAAO,KAAA,GAAU,CAAA,CACnEO,CAAAA,CAAiBC,CAAAA,CAAmBR,CAAAA,CAAO,KAAA,CAASG,CAAAA,CAGvD,IACT","file":"chunk-DLAKPF5T.js","sourcesContent":["/**\n * The unit conversion algorithm, ported from the `convert` npm package v7.0.2\n * alongside its tables (see `generated/UnitTable.generated.ts` and\n * THIRD-PARTY-NOTICES.md).\n *\n * Transliterated expression for expression rather than rewritten. Floating\n * point is not associative, so `(q + d) * (a / b) - d2` and any algebraically\n * equal rearrangement disagree in the last bits. Those bits are observable:\n * `0.5 l` best-converts to `500.00000000000006 mL` today, and the test suite\n * pins several conversions to ten decimal places.\n *\n * This module is deliberately unaware of the engine's own additions. Workdays,\n * extended units, currency and the caches all live in `UomConverter.ts`, which\n * layers them on top of these three functions.\n */\n\nimport {\n UNIT_TABLE,\n UNIT_DIFFERENCES,\n BEST_UNITS_METRIC,\n type UnitEntry,\n} from \"./generated/UnitTable.generated\";\n\n/**\n * The generated tables re-keyed into Maps once at module load.\n *\n * Not a micro-optimization. A 1456-key object literal lands in V8's dictionary\n * mode, and guarding a read on it against inherited names (`constructor`,\n * `toString`) costs about 123ns per call with either `hasOwnProperty.call` or\n * `Object.hasOwn`, measured. `Map.get` is about 6ns and needs no guard at all,\n * because a Map has no prototype chain to fall through to. That is a 20x\n * difference on the single hottest operation in the unit system: `convertRaw`\n * performs two of these per call, and `LanguageService` sweeps all 1456 keys\n * to build completions.\n */\nconst UNIT_LOOKUP: ReadonlyMap<string, UnitEntry> = new Map(Object.entries(UNIT_TABLE));\n\n/**\n * Temperature offsets, as a Map for the same reason.\n *\n * Also removes a latent hazard: the upstream code tests membership with `in`,\n * and `\"toString\" in UNIT_DIFFERENCES` is true, so an inherited name reaching\n * that branch would add a function to a number.\n */\nconst DIFFERENCE_LOOKUP: ReadonlyMap<string, number> = new Map(Object.entries(UNIT_DIFFERENCES));\n\n/**\n * Looks up a unit spelling.\n *\n * @returns its `[kind, ratio]` entry, or `undefined` if the spelling is not a\n * unit. Case-sensitive: no normalization or aliasing happens anywhere in this\n * module.\n *\n * The one deliberate deviation from upstream. `convert` tests membership with\n * `in` and reads the property directly, so inherited names like \"constructor\"\n * and \"toString\" reach its measure comparison and fail there with \"Cannot\n * convert between different measures\" instead of \"is not a valid unit\". Both\n * throw a RangeError and both report no measure, so nothing downstream can\n * tell the difference, and naming the real problem is the better message.\n */\nexport function lookupUnit(unit: string): UnitEntry | undefined {\n return UNIT_LOOKUP.get(unit);\n}\n\n/**\n * Converts `quantity` from one unit to another.\n *\n * THROWS a `RangeError` for an unknown unit or a pair in different measures.\n * Callers depend on that: `VM.ts`'s `extractDurationMs()` calls this with an\n * arbitrary unit inside a bare try/catch and treats the throw as \"not a\n * duration, contribute zero\". Returning NaN or the input unchanged instead\n * would turn `<date> + 5 kg` into an Invalid Date rather than a no-op.\n */\nexport function convertRaw(quantity: number, from: string, to: string): number {\n const parsedFrom = UNIT_LOOKUP.get(from);\n if (parsedFrom === undefined) {\n throw new RangeError(`${from} is not a valid unit`);\n }\n\n const parsedTo = UNIT_LOOKUP.get(to);\n if (parsedTo === undefined) {\n throw new RangeError(`${to} is not a valid unit`);\n }\n\n return convertResolved(quantity, from, to, parsedFrom, parsedTo);\n}\n\n/**\n * The conversion arithmetic, for callers that have already looked both units\n * up and want to skip doing it twice.\n *\n * Split out for `UomConverter.convertUnit()`, which has to check whether\n * either side is a workday or an extended unit before it can dispatch, and\n * would otherwise resolve each unit once to decide and again to convert. The\n * entries MUST be the ones this module returned for these exact spellings.\n */\nexport function convertResolved(\n quantity: number,\n from: string,\n to: string,\n fromEntry: UnitEntry,\n toEntry: UnitEntry\n): number {\n const parsedFrom = fromEntry;\n const parsedTo = toEntry;\n\n if (parsedFrom[0] !== parsedTo[0]) {\n // DELIBERATE DEVIATION from the ported original, which silently reinterpreted\n // \"m\" as minutes whenever the other side was a time unit. That is a guess,\n // and this project's stated position is that refusing to guess is the safer\n // default for a tool doing arithmetic on someone's real numbers (see\n // docs/architecture/design-decisions.md). The guess was not harmless: it\n // reached `<date> + <duration>` through VM.ts's extractDurationMs(), where\n // `today + 5 m` silently added five MINUTES for someone who wrote metres.\n //\n // Minutes are spelled \"min\", \"minute\" or \"minutes\", all of which the table\n // has always accepted.\n throw new RangeError(`Cannot convert between different measures: ${from} and ${to}`);\n }\n\n const fromRatio = parsedFrom[1];\n const toRatio = parsedTo[1];\n\n // Only six units in the whole table carry an offset, so the common path is\n // both misses. Reading the Map once per side and reusing the value beats\n // testing membership and then reading it again.\n const fromDifference = DIFFERENCE_LOOKUP.get(from);\n const toDifference = DIFFERENCE_LOOKUP.get(to);\n\n // Scales that do not share an origin (temperature) need the offset applied\n // around the ratio. Do not refactor the four branches into one expression:\n // the grouping is what makes the result bit-identical to the original.\n if (fromDifference !== undefined) {\n if (toDifference !== undefined) {\n return (quantity + fromDifference) * (fromRatio / toRatio) - toDifference;\n }\n return (quantity + fromDifference) * (fromRatio / toRatio);\n }\n\n if (toDifference !== undefined) {\n return quantity * (fromRatio / toRatio) - toDifference;\n }\n\n return quantity * (fromRatio / toRatio);\n}\n\n/**\n * Picks the most readable metric unit for a magnitude and converts to it.\n *\n * Only the metric lists are ported; nothing has ever requested the imperial\n * ones. Note the final conversion goes from the ORIGINAL unit to the chosen\n * one directly rather than via the smallest unit, which is what keeps the\n * result exact.\n */\nexport function convertToBestMetric(\n quantity: number,\n from: string\n): { quantity: number; unit: string } {\n const parsedFrom = UNIT_LOOKUP.get(from);\n if (parsedFrom === undefined) {\n throw new RangeError(`${from} is not a valid unit`);\n }\n\n const best = BEST_UNITS_METRIC[parsedFrom[0]];\n const smallestUnit = best[0][0];\n let bestUnit = smallestUnit;\n\n const baseQuantity = convertRaw(quantity, from, smallestUnit);\n const absQuantity = baseQuantity < 0 ? -baseQuantity : baseQuantity;\n\n // Thresholds are expressed in the smallest unit and ascend, so the last one\n // the magnitude reaches wins. Breaking early rather than scanning the whole\n // list matters for zero and for negatives, which stay on the smallest unit.\n for (let i = 0; i < best.length; i++) {\n const bestEntry = best[i];\n if (absQuantity >= bestEntry[1]) {\n bestUnit = bestEntry[0];\n } else {\n break;\n }\n }\n\n return { quantity: convertRaw(quantity, from, bestUnit), unit: bestUnit };\n}\n","/**\n * UoM Converter, built on the in-house unit tables in `UnitConversion.ts` and\n * `generated/UnitTable.generated.ts` (ported from the `convert` npm package\n * v7.0.2 so the engine ships with no runtime dependencies).\n *\n * Units are strictly case-sensitive and are looked up without aliasing. No unit\n * remapping, what you type is what you get.\n * e.g. 'C' = Celsius, 'c' = cup; 'MB' = megabytes, 'mb' = millibits.\n *\n * This file owns everything the base tables do not: the workday shim, the\n * extended (custom-measure) units, and the two caches.\n */\n\nimport { lookupUnit, convertRaw, convertResolved, convertToBestMetric } from \"@solve-js/uom/UnitConversion\";\nimport { MEASURE_KIND_NAMES, MEASURE_SYMBOLS, UNIT_TABLE } from \"@solve-js/uom/generated/UnitTable.generated\";\nimport { EXTENDED_UNITS } from \"@solve-js/uom/ExtendedUnits\";\n\n// ── \"workday\", a synthetic unit with no entry in the base table ───────────\n//\n// A business day (Mon-Fri) backing the datetime package's `<date> + N\n// workdays` arithmetic and `$X/workday` Rate literals\n// (packages/datetime/). NOT a real physical unit, a business day has no\n// fixed duration, since it depends on which calendar dates are weekends\n// so the ported base table has no concept of it and can't be\n// taught one without monkey-patching its internal unit table.\n//\n// For RATE-MATH purposes only (e.g. \"$500/workday x 4 weeks\" needs a\n// workday count to multiply by), a workday is treated as a FIXED 7/5 of a\n// calendar day: 5 workdays span exactly 7 calendar days in a whole week,\n// so this ratio is exact for whole-week spans and a reasonable linear\n// approximation otherwise. This is deliberately NOT the same\n// calendar-aware, weekend-skipping logic real \"<date> + N workdays\" date\n// arithmetic needs (see vm/VM.ts's addBusinessDays()), that can't be\n// reduced to a fixed ratio, since the exact skip pattern depends on which\n// day of the week the calculation actually starts from.\n//\n// Handled here as a thin pre/post layer in front of the normal\n// base-table path (rather than inside the tables themselves) so every\n// caller of getMeasure()/convertUnit()/canConvert() automatically gets\n// workday support for free.\nconst WORKDAY_UNIT_NAMES = new Set([\"workday\", \"workdays\"]);\nconst WORKDAY_TO_DAY_FACTOR = 7 / 5; // 1 workday == 1.4 calendar days\n\n/** Whether `unit` is the synthetic \"workday\" unit (see module note above). */\nexport function isWorkdayUnit(unit: string | undefined): unit is string {\n return typeof unit === \"string\" && WORKDAY_UNIT_NAMES.has(unit);\n}\n\n/**\n * Validate `unit` against the known unit table.\n *\n * @returns `unit` unchanged in all cases. This does NOT normalize casing\n * or aliasing (units are strictly case-sensitive, see the module note\n * above). A unit the table doesn't recognize is still\n * returned as-is (not thrown), so callers must not assume a returned\n * string is actually convertible, check with {@link isConvertibleUnit}\n * or {@link canConvert} first if that matters.\n *\n * Kept as an identity function purely for API compatibility. It used to guard\n * a validity cache, which existed because validating a unit meant a\n * throw/catch round trip through the old dependency. Validation is now a Map\n * lookup, so the cache cost more than it saved: worse, it was capped at 1000\n * entries against a 1456-unit table, so any sweep over the full vocabulary\n * (which is exactly what LanguageService does to build completions) evicted\n * on almost every call. That one change took the full-table sweep from 7.7ms\n * to under 20us.\n */\nexport function resolveUnit(unit: string): string {\n return unit;\n}\n\n// MEASURE_KIND_NAMES now comes from the generated table (it is derived data,\n// so the generator emits it rather than it being retyped here). The reason it\n// is a module-level constant has not changed: getMeasure() runs at least twice\n// per conversion, and this used to be reallocated on every call.\n\n/**\n * Get the measure/dimension kind for `unit` (e.g. `\"length\"`, `\"mass\"`,\n * `\"temperature\"`), used to check whether two units are even in the same\n * dimension before attempting a conversion.\n *\n * @returns `undefined` if `unit` isn't recognized, rather than throwing.\n */\nexport function getMeasure(unit: string): string | undefined {\n // Workday is a Time-measure unit by convention (see isWorkdayUnit's doc\n // comment) and is not in the base table, so resolve its measure via \"day\"\n // instead of attempting the real lookup below.\n if (isWorkdayUnit(unit)) return getMeasure(\"day\");\n\n // Extended (custom) categories the base table has no measure kind for,\n // see ExtendedUnits.ts.\n const extended = EXTENDED_UNITS[unit];\n if (extended) return extended.measure;\n\n const entry = lookupUnit(unit);\n if (entry === undefined) return undefined;\n\n return MEASURE_KIND_NAMES[entry[0]];\n}\n\n/**\n * Check whether `from` can be converted to `to`. Same unit, or same\n * measure kind (length, mass, ...) and the underlying tables accept the pair.\n * Never throws; returns `false` on any failure.\n */\nexport function canConvert(from: string, to: string): boolean {\n if (from === to) return true;\n if (isWorkdayUnit(from) || isWorkdayUnit(to)) {\n const fromMeasure = getMeasure(from);\n const toMeasure = getMeasure(to);\n return !!fromMeasure && fromMeasure === toMeasure;\n }\n // One table read per side, comparing numeric kind ids. The old shape called\n // getMeasure() on each side (two more reads) purely to compare the resulting\n // STRINGS, then did a throwaway conversion to confirm what the kind check had\n // already established.\n const fromEntry = lookupUnit(from);\n const toEntry = lookupUnit(to);\n if (fromEntry !== undefined && toEntry !== undefined) {\n return fromEntry[0] === toEntry[0];\n }\n\n // Extended (custom) categories aren't in the base table at all, so they are\n // compared on their own measure names instead.\n const fromExtended = EXTENDED_UNITS[from];\n const toExtended = EXTENDED_UNITS[to];\n if (fromExtended !== undefined && toExtended !== undefined) {\n return fromExtended.measure === toExtended.measure;\n }\n\n // Mixed: one side is in the base table and the other is extended. That used\n // to be refused outright, on the grounds that the two measure spaces are\n // disjoint. They are not, once an extended unit names a measure the base\n // table also has: `furlong` is a length and so is `m`, and the ratio between\n // them is exactly what both tables already record.\n return bridgesToBaseMeasure(from, to) || bridgesToBaseMeasure(to, from);\n}\n\n/**\n * Whether `extendedUnit` extends a measure the base table also knows, so a\n * value in it can reach `baseUnit`.\n *\n * The bridge works because both tables express a unit as a ratio to the same\n * physical base: the generated table's length ratios are metres and its mass\n * ratios are grams, and an extended unit declaring `measure: \"length\"` states\n * its `toBase` in the same metres. Composing the two ratios is then ordinary\n * arithmetic rather than a second conversion system.\n *\n * A measure the base table has no concept of, such as pace, still fails here,\n * which is the behaviour this replaced and the reason the check is by measure\n * name rather than by presence in the extended table.\n */\nfunction bridgesToBaseMeasure(extendedUnit: string, baseUnit: string): boolean {\n const extended = EXTENDED_UNITS[extendedUnit];\n if (extended === undefined) return false;\n\n const base = lookupUnit(resolveUnit(baseUnit));\n if (base === undefined) return false;\n\n return MEASURE_KIND_NAMES[base[0]] === extended.measure;\n}\n\n/**\n * Convert `value` from unit `from` to unit `to`.\n *\n * Does not validate that the conversion is possible, callers should check\n * with {@link canConvert} first if `from`/`to` aren't already known-good.\n *\n * THROWS a RangeError for an unknown unit or a cross-measure pair. `VM.ts`'s\n * `extractDurationMs()` depends on that, see {@link convertRaw}.\n *\n * This used to memoize a per-pair conversion factor in an LFU cache. The cache\n * is gone: computing the factor is now two Map reads, while the cache cost a\n * template-string key allocation on every call plus the LFU's own frequency\n * bookkeeping, so it was slower than the work it avoided. Removing it is\n * bit-exact, not merely close: the cache stored `convertRaw(1, f, t)`, which is\n * exactly `fromRatio / toRatio`, and then multiplied, which is the identical\n * expression `convertRaw(value, f, t)` evaluates. It also deleted the special\n * case that existed only to keep offset-based temperature pairs out of a\n * factor cache.\n */\nexport function convertUnit(value: number, from: string, to: string): number {\n if (from === to) return value;\n\n // Fast path first: two ordinary units, which is nearly every call. Resolving\n // both here and handing the entries to convertResolved() avoids looking them\n // up again inside convertRaw(). Neither workdays nor extended units appear in\n // the base table, so they always fall through to the branches below and this\n // ordering cannot steal a case from them. UnitVocabulary.spec.ts pins that\n // the two vocabularies stay disjoint.\n const fromEntry = lookupUnit(from);\n const toEntry = lookupUnit(to);\n if (fromEntry !== undefined && toEntry !== undefined) {\n return convertResolved(value, from, to, fromEntry, toEntry);\n }\n\n // Workday <-> any other Time-measure unit: pivot through \"day\" using the\n // fixed 7/5 ratio (see isWorkdayUnit's doc comment above).\n if (isWorkdayUnit(from) && isWorkdayUnit(to)) return value; // \"workday\" <-> \"workdays\" alias\n if (isWorkdayUnit(from)) {\n const days = value * WORKDAY_TO_DAY_FACTOR;\n return to === \"day\" ? days : convertUnit(days, \"day\", to);\n }\n if (isWorkdayUnit(to)) {\n const days = from === \"day\" ? value : convertUnit(value, from, \"day\");\n return days / WORKDAY_TO_DAY_FACTOR;\n }\n\n // Extended (custom) categories the base table has no measure kind for\n // (see ExtendedUnits.ts), compute the ratio directly from each unit's\n // factor-to-base value instead of calling convertRaw(), which would throw\n // on an unrecognized unit string. Every extended category is a pure linear\n // ratio scale (no Temperature-style offset), so this is always safe.\n const fExt = EXTENDED_UNITS[from];\n const tExt = EXTENDED_UNITS[to];\n if (fExt !== undefined && tExt !== undefined) {\n return value * (fExt.toBase / tExt.toBase);\n }\n\n // One side extended, the other in the base table, sharing a measure. Convert\n // through the measure's base unit, which both tables state their ratios\n // against: an extended length declares its `toBase` in metres, and the\n // generated table's length ratios are metres too.\n if (fExt !== undefined && bridgesToBaseMeasure(from, to)) {\n return convertRaw(value * fExt.toBase, baseUnitFor(to), to);\n }\n if (tExt !== undefined && bridgesToBaseMeasure(to, from)) {\n return convertRaw(value, from, baseUnitFor(from)) / tExt.toBase;\n }\n\n // Offsets, cross-measure rejection and the unknown-unit throw all live in\n // convertRaw. Nothing is layered on top here any more.\n return convertRaw(value, from, to);\n}\n\n/**\n * The unit a measure states its ratios against, found from any unit in it.\n *\n * Read out of the table rather than hard-coded, so it cannot drift from the\n * ratios it has to agree with: the base is whichever unit of that measure has\n * a ratio of exactly one.\n */\nfunction baseUnitFor(unit: string): string {\n const entry = lookupUnit(resolveUnit(unit));\n if (entry === undefined) return unit;\n\n for (const symbol of Object.keys(UNIT_TABLE)) {\n const candidate = UNIT_TABLE[symbol];\n if (candidate[0] === entry[0] && candidate[1] === 1) return symbol;\n }\n return unit;\n}\n\n/**\n * List every unit symbol in the same measure/dimension as `unit` (wiki:\n * Units-Of-Measurement, \"Conversion Possibilities\", `sourceUnit to ?`\n * e.g. `cm to ?\"` → every Length unit). Excludes `unit` itself.\n *\n * Reads MEASURE_SYMBOLS, which is a curated symbols-only vocabulary and\n * deliberately NOT the keys of the unit table filtered by kind. The two\n * differ: Volume's symbols include `c` and `pt` but not `cup`/`cups`, and\n * Time's include `wk` and `mo` but not `week`/`month`. Deriving this list\n * from the unit table instead would roughly quadruple every answer.\n *\n * @returns `[]` if `unit` isn't recognized, rather than throwing.\n */\nexport function getConvertiblePossibilities(unit: string): string[] {\n const resolved = resolveUnit(unit);\n const entry = lookupUnit(resolved);\n if (entry === undefined) return [];\n const symbols = MEASURE_SYMBOLS[entry[0]];\n if (!symbols) return [];\n return symbols.filter((s) => s !== resolved);\n}\n\n/** Check whether `unit` is a unit the conversion tables recognize. Never throws. */\nexport function isConvertibleUnit(unit: string): boolean {\n if (isWorkdayUnit(unit)) return true;\n if (EXTENDED_UNITS[unit]) return true;\n return lookupUnit(resolveUnit(unit)) !== undefined;\n}\n\n/**\n * Convert `value` (in `unit`) to whichever unit of the same measure gives\n * the most human-readable magnitude, e.g. 1500 metres becomes 1.5 km. Falls\n * back to returning `value`/`unit` unchanged if `unit` isn't recognized,\n * which is what every extended unit and workday does.\n *\n * Note the chosen unit is drawn from the best-unit lists, which are not\n * restricted to spellings the lexer accepts: 0.5 l reports \"mL\".\n */\nexport function getBestUnit(value: number, unit: string): { value: number; unit: string } {\n const u = resolveUnit(unit);\n try {\n const result = convertToBestMetric(value, u);\n return { value: result.quantity, unit: result.unit };\n } catch {\n return { value, unit: u };\n }\n}\n\n// ── Rate and derived-unit conversion ───────────────────────────────────────\n//\n// A rate value carries a compound unit spelled \"numerator/denominator\" (e.g.\n// \"km/h\", \"m/s\"), see vm/Value.ts's rateValue(). Plain convertUnit() cannot\n// touch one, because neither half is the whole unit and getMeasure(\"km/h\") is\n// undefined. This section converts a rate to another rate, and bridges a rate\n// to the single-token speed spellings (mph, kph, mps, ...) that ExtendedUnits.ts\n// already carries, so \"100 km/h in mph\" and \"60 mph in km/h\" resolve instead of\n// reporting incompatible units.\n\n/** A rate reduced to a numerator unit over a denominator unit. */\ninterface RateForm {\n /** Magnitude, scaled so `value numerator/denominator` is the physical quantity. */\n value: number;\n /** Numerator unit spelling, or `\"\"` for a countless rate such as `30/week`. */\n numerator: string;\n /** Denominator unit spelling. */\n denominator: string;\n}\n\n/**\n * Express `value unit` as a numerator/denominator rate, or `null` when `unit`\n * is neither a compound rate spelling nor a single-token speed alias.\n *\n * A speed alias (mph, kph, ...) is one unit standing for a length/time rate, so\n * it expands to the base pair `m`/`s` with its value scaled by the alias's\n * metres-per-second factor. That collapses both inputs to one shape, so a\n * single routine handles rate/rate and rate/alias without a second code path.\n */\n/**\n * The single-token fuel-economy units, each as the `numerator/denominator` rate\n * it stands for and the factor that turns one of it into that rate's base. `mpg`\n * is `km/l` scaled, `l/100km` is `l/km` scaled by a hundredth (issue #190).\n */\nconst FUEL_RATE_UNITS: Record<string, { numerator: string; denominator: string; factor: number }> = {\n mpg: { numerator: \"km\", denominator: \"l\", factor: 1.609344 / 3.785411784 },\n kmpl: { numerator: \"km\", denominator: \"l\", factor: 1 },\n l100km: { numerator: \"l\", denominator: \"km\", factor: 0.01 },\n};\n\nfunction expandUnitToRate(value: number, unit: string): RateForm | null {\n const fuel = FUEL_RATE_UNITS[unit];\n if (fuel !== undefined) {\n return { value: value * fuel.factor, numerator: fuel.numerator, denominator: fuel.denominator };\n }\n const slash = unit.indexOf(\"/\");\n if (slash >= 0) {\n return { value, numerator: unit.slice(0, slash), denominator: unit.slice(slash + 1) };\n }\n const ext = EXTENDED_UNITS[unit];\n if (ext !== undefined && ext.measure === \"speed\") {\n // 1 alias == ext.toBase m/s, so `value alias` is `value * toBase` m/s.\n return { value: value * ext.toBase, numerator: \"m\", denominator: \"s\" };\n }\n return null;\n}\n\n/**\n * The factor that turns one `from` into `to` along a single rate axis, or\n * `null` when the two cannot line up.\n *\n * Same spelling needs no conversion. A countless axis (`\"\"`) only lines up with\n * another countless one, never with a real unit. Otherwise both sides must name\n * the same measure, which is what keeps a length numerator from pairing with a\n * mass one.\n */\nfunction rateAxisFactor(from: string, to: string): number | null {\n if (from === to) return 1;\n if (from === \"\" || to === \"\") return null;\n const fromMeasure = getMeasure(from);\n const toMeasure = getMeasure(to);\n if (fromMeasure === undefined || toMeasure === undefined || fromMeasure !== toMeasure) {\n return null;\n }\n return convertUnit(1, from, to);\n}\n\n/**\n * Convert `value` from a rate/speed unit `from` to a rate/speed unit `to`,\n * returning the converted magnitude, or `null` when the pair is not\n * rate-convertible (so the caller falls back to its own incompatible-units\n * handling).\n *\n * Handles rate to rate (`10 m/s in km/h`), rate to speed alias\n * (`100 km/h in mph`) and speed alias to rate (`60 mph in km/h`). Plain\n * same-measure pairs (`kph in mph`, `km in miles`) never reach here, they are\n * resolved by {@link convertUnit} first.\n *\n * The rule is the ordinary one for a quotient of quantities: convert the\n * numerator and the denominator each on their own, so `A/B -> C/D` scales by\n * `(A->C) / (B->D)`.\n */\nexport function convertRate(value: number, from: string, to: string): number | null {\n const source = expandUnitToRate(value, from);\n if (source === null) return null;\n\n // The target is either a rate spelling or a single-token speed alias. An\n // alias expands to the base m/s pair, and `targetScale` is what the base-form\n // magnitude is divided by to read out in the alias itself.\n let targetNumerator: string;\n let targetDenominator: string;\n let targetScale: number;\n const fuelTarget = FUEL_RATE_UNITS[to];\n const slash = to.indexOf(\"/\");\n if (fuelTarget !== undefined) {\n // The base-pair magnitude divided by the fuel unit's own factor reads out in\n // that unit (so a l/km magnitude becomes a l/100km figure).\n targetNumerator = fuelTarget.numerator;\n targetDenominator = fuelTarget.denominator;\n targetScale = fuelTarget.factor;\n } else if (slash >= 0) {\n targetNumerator = to.slice(0, slash);\n targetDenominator = to.slice(slash + 1);\n targetScale = 1;\n } else {\n const ext = EXTENDED_UNITS[to];\n if (ext === undefined || ext.measure !== \"speed\") return null;\n targetNumerator = \"m\";\n targetDenominator = \"s\";\n targetScale = ext.toBase;\n }\n\n const numeratorFactor = rateAxisFactor(source.numerator, targetNumerator);\n const denominatorFactor = rateAxisFactor(source.denominator, targetDenominator);\n if (numeratorFactor !== null && denominatorFactor !== null) {\n return (source.value * numeratorFactor) / denominatorFactor / targetScale;\n }\n\n // A reciprocal pairing: distance-per-volume against volume-per-distance, the\n // fuel-economy case (miles per gallon to litres per kilometre). The two rates\n // measure the same thing upside down, so the source's numerator lines up with\n // the target's denominator and its denominator with the target's numerator,\n // and the magnitude is inverted. `40 miles/gallon` becomes `0.0588 l/km`:\n // one over forty, scaled gallon-to-litre over mile-to-kilometre. See issue\n // #190; this is why fuel economy needs its own route and is not a rescale of\n // each axis like `mph` to `km/h`.\n const crossNumerator = rateAxisFactor(source.denominator, targetNumerator);\n const crossDenominator = rateAxisFactor(source.numerator, targetDenominator);\n if (crossNumerator !== null && crossDenominator !== null && source.value !== 0) {\n return (crossNumerator / crossDenominator / source.value) / targetScale;\n }\n\n return null;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import {c as c$2}from'./chunk-KHCNMNZZ.js';import {y,C,a as a$1,G,J as J$1,e as e$2,h as h$1,t as t$1,p,k as k$1,m,n as n$1,g as g$1,q as q$3,f as f$2,u as u$1,o as o$1,s as s$1,j as j$2,r as r$2,l,b as b$2,c as c$6}from'./chunk-YTCTUBR2.js';import {c as c$5}from'./chunk-YAYBVVG2.js';import {b}from'./chunk-YNMMRH44.js';import {ea,T,U,X,S,Y,q as q$1,aa as aa$1,ma,j as j$1,$,_,ia,ra,ua}from'./chunk-WTEXBPBR.js';import {n,g,j,a,P,c as c$3,Q,I,e,C as C$1,F,M,x,y as y$1,w,u,t,v,r as r$1,N,G as G$1,k,K,f as f$1,R,L,s,q as q$2,p as p$1,o,d,A,b as b$1,B}from'./chunk-A33K7NY4.js';import {c as c$4,e as e$1,i,h,f,a as a$2}from'./chunk-DLAKPF5T.js';import {a as a$3}from'./chunk-44EOEWGP.js';import {c as c$1,r,d as d$1}from'./chunk-MPB7KUN5.js';var Ot=class{constructor(){this.consumers=new Map;this.dependencies=new Map;this.writes=new Map;this.lineReads=new Map;this.dataSourceDependencies=new Map;this.dataSourceConsumers=new Map;}registerLine(a,s,u){let l=this.lineReads.get(a);if(l)for(let g of l){let b=this.consumers.get(g);b&&b.delete(a);}this.lineReads.set(a,new Set(s));for(let g of s)this.consumers.has(g)||this.consumers.set(g,new Set),this.consumers.get(g).add(a);if(u.length>0){this.dependencies.set(a,new Set(s)),this.writes.set(a,new Set(u));for(let g of u){let b=this.consumers.get(g);b&&b.delete(a);}}}registerLineDataSourceDependency(a,s,u){let l=JSON.stringify(u),g=`${s}:${l}`;this.dataSourceDependencies.has(a)||this.dataSourceDependencies.set(a,new Set),this.dataSourceDependencies.get(a).add(g),this.dataSourceConsumers.has(g)||this.dataSourceConsumers.set(g,new Set),this.dataSourceConsumers.get(g).add(a);}getAffectedLines(a){let s=new Set,u=[a];for(;u.length>0;){let l=u.pop(),g=this.consumers.get(l);if(g)for(let b of g){if(s.has(b))continue;s.add(b);let f=this.writes.get(b);if(f)for(let y of f)u.push(y);}}return s}getAffectedLinesInOrder(a){let s=this.getAffectedLines(a);if(s.size===0)return [];let u=new Map,l=new Map;for(let y of s)u.has(y)||u.set(y,0),l.has(y)||l.set(y,[]);let g=new Map;for(let y of s){let x=this.writes.get(y);if(x)for(let A of x)g.set(A,y);}for(let y of s){let x=this.lineReads.get(y);if(x)for(let A of x){let C=g.get(A);C!==void 0&&C!==y&&(l.get(C).push(y),u.set(y,(u.get(y)??0)+1));}}let b=[];for(let[y,x]of u)x===0&&b.push(y);if(b.length===0&&s.size>0){let y=Array.from(s).sort((x,A)=>x-A);b.push(y[0]);}let f=[];for(;b.length>0;){let y=b.shift();f.push(y);for(let x of l.get(y)??[]){let A=(u.get(x)??1)-1;u.set(x,A),A===0&&b.push(x);}}if(f.length<s.size){let y=new Set(f),x=Array.from(s).filter(A=>!y.has(A)).sort((A,C)=>A-C);f.push(...x);}return f}getAffectedLinesByDataSource(a,s){let u=JSON.stringify(s),l=`${a}:${u}`;return this.dataSourceConsumers.get(l)??new Set}removeLine(a){let s=this.lineReads.get(a);if(s){for(let l of s){let g=this.consumers.get(l);g&&g.delete(a);}this.lineReads.delete(a);}this.dependencies.delete(a),this.writes.delete(a);let u=this.dataSourceDependencies.get(a);if(u){for(let l of u)this.dataSourceConsumers.get(l)?.delete(a);this.dataSourceDependencies.delete(a);}}getConsumers(a){return this.consumers.get(a)??new Set}getDependencies(a){return this.dependencies.get(a)??new Set}getWrites(a){return this.writes.get(a)??new Set}getSnapshot(){let a={};for(let[b,f]of this.consumers)a[b]=Array.from(f);let s={};for(let[b,f]of this.writes)s[b]=Array.from(f);let u={};for(let[b,f]of this.lineReads)u[b]=Array.from(f);let l={};for(let[b,f]of this.dataSourceDependencies)l[b]=Array.from(f);let g={};for(let[b,f]of this.dataSourceConsumers)g[b]=Array.from(f);return {consumers:a,writes:s,reads:u,dataSourceDeps:l,dataSourceConsumers:g}}clear(){this.consumers.clear(),this.dependencies.clear(),this.writes.clear(),this.lineReads.clear(),this.dataSourceDependencies.clear(),this.dataSourceConsumers.clear();}};var vt=class{constructor(){this.definitions=new Map;}write(a,s,u){this.definitions.has(a)||this.definitions.set(a,[]);let l=this.definitions.get(a);l.push({line:s,expr:u}),l.sort((g,b)=>g.line-b.line);}read(a,s){let u=this.definitions.get(a);if(u){for(let l=u.length-1;l>=0;l--)if(u[l].line<=s)return u[l].expr.lastResult}}invalidateDownstream(a,s){let u=this.definitions.get(a);if(!u)return;let l=u.findIndex(g=>g.line===s);l!==-1&&u.splice(l+1);}clear(){this.definitions.clear();}};var je={kg:{dim:[1,0,0,0],si:1},g:{dim:[1,0,0,0],si:.001},tonne:{dim:[1,0,0,0],si:1e3},t:{dim:[1,0,0,0],si:1e3},m:{dim:[0,1,0,0],si:1},cm:{dim:[0,1,0,0],si:.01},mm:{dim:[0,1,0,0],si:.001},km:{dim:[0,1,0,0],si:1e3},s:{dim:[0,0,1,0],si:1},ms:{dim:[0,0,1,0],si:.001},min:{dim:[0,0,1,0],si:60},minute:{dim:[0,0,1,0],si:60},minutes:{dim:[0,0,1,0],si:60},h:{dim:[0,0,1,0],si:3600},hr:{dim:[0,0,1,0],si:3600},hour:{dim:[0,0,1,0],si:3600},hours:{dim:[0,0,1,0],si:3600},A:{dim:[0,0,0,1],si:1},mA:{dim:[0,0,0,1],si:.001},kA:{dim:[0,0,0,1],si:1e3},ampere:{dim:[0,0,0,1],si:1},amperes:{dim:[0,0,0,1],si:1},mps2:{dim:[0,1,-2,0],si:1},N:{dim:[1,1,-2,0],si:1},kN:{dim:[1,1,-2,0],si:1e3},newton:{dim:[1,1,-2,0],si:1},newtons:{dim:[1,1,-2,0],si:1},J:{dim:[1,2,-2,0],si:1},kJ:{dim:[1,2,-2,0],si:1e3},MJ:{dim:[1,2,-2,0],si:1e6},joule:{dim:[1,2,-2,0],si:1},joules:{dim:[1,2,-2,0],si:1},Wh:{dim:[1,2,-2,0],si:3600},kWh:{dim:[1,2,-2,0],si:36e5},W:{dim:[1,2,-3,0],si:1},kW:{dim:[1,2,-3,0],si:1e3},MW:{dim:[1,2,-3,0],si:1e6},watt:{dim:[1,2,-3,0],si:1},watts:{dim:[1,2,-3,0],si:1},Pa:{dim:[1,-1,-2,0],si:1},kPa:{dim:[1,-1,-2,0],si:1e3},MPa:{dim:[1,-1,-2,0],si:1e6},pascal:{dim:[1,-1,-2,0],si:1},pascals:{dim:[1,-1,-2,0],si:1},V:{dim:[1,2,-3,-1],si:1},mV:{dim:[1,2,-3,-1],si:.001},kV:{dim:[1,2,-3,-1],si:1e3},volt:{dim:[1,2,-3,-1],si:1},volts:{dim:[1,2,-3,-1],si:1}},en={"1,1,-2,0":"N","1,2,-2,0":"J","1,2,-3,0":"W","1,-1,-2,0":"Pa","1,2,-3,-1":"V"},tn=r=>r.join(",");function ze(r,a,s){if(r.type!==6||a.type!==6)return null;let u$1=r.unit?je[r.unit]:void 0,l=a.unit?je[a.unit]:void 0;if(u$1===void 0||l===void 0)return null;let g=[u$1.dim[0]+(s?l.dim[0]:-l.dim[0]),u$1.dim[1]+(s?l.dim[1]:-l.dim[1]),u$1.dim[2]+(s?l.dim[2]:-l.dim[2]),u$1.dim[3]+(s?l.dim[3]:-l.dim[3])],b=en[tn(g)];if(b===void 0)return null;let f=r.toNumber()*u$1.si,y=a.toNumber()*l.si,x=s?f*y:f/y;return u(x/je[b].si,b)}function nn(r){let a=new Date(r).getDay();return a===0||a===6}function Vt(r,a){return nn(r)?false:a?!a(r):true}function Rt(r){let a=new Date(r);return new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime()}function Bt(r,a,s,u){let l=Math.trunc(Math.abs(a)),g=a>=0?1:-1,b=new Date(r),f=0;for(;l>0;){if(b.setDate(b.getDate()+g),f++,f>u)return null;Vt(b.getTime(),s)&&l--;}return b.getTime()}function Ft(r,a,s,u){let l=Rt(Math.min(r,a)),g=Rt(Math.max(r,a)),b=Math.round((g-l)/864e5);if(b>u)return null;let f=0,y=new Date(l);for(let x=0;x<=b;x++)Vt(y.getTime(),s)&&f++,y.setDate(y.getDate()+1);return f}var an={0:{name:"sqrt",min:1,max:1},1:{name:"abs",min:1,max:1},2:{name:"sin",min:1,max:1},3:{name:"cos",min:1,max:1},4:{name:"tan",min:1,max:1},5:{name:"log",min:1,max:1},6:{name:"ceil",min:1,max:1},7:{name:"floor",min:1,max:1},8:{name:"round",min:1,max:2},9:{name:"min",min:1,max:1/0},10:{name:"max",min:1,max:1/0},11:{name:"asin",min:1,max:1},12:{name:"acos",min:1,max:1},13:{name:"atan",min:1,max:1},14:{name:"atan2",min:2,max:2},15:{name:"sinh",min:1,max:1},16:{name:"cosh",min:1,max:1},17:{name:"tanh",min:1,max:1},18:{name:"asinh",min:1,max:1},19:{name:"acosh",min:1,max:1},20:{name:"atanh",min:1,max:1},21:{name:"cbrt",min:1,max:1},22:{name:"clz32",min:1,max:1},23:{name:"expm1",min:1,max:1},24:{name:"exp",min:1,max:1},25:{name:"fround",min:1,max:1},26:{name:"hypot",min:1,max:1/0},27:{name:"imul",min:2,max:2},28:{name:"log10",min:1,max:1},29:{name:"log1p",min:1,max:1},30:{name:"log2",min:1,max:1},31:{name:"pow",min:2,max:2},32:{name:"random",min:0,max:0},33:{name:"sign",min:1,max:1},34:{name:"trunc",min:1,max:1},35:{name:"degtorad",min:1,max:1},36:{name:"radtodeg",min:1,max:1},37:{name:"roll",min:2,max:2},38:{name:"gcd",min:2,max:2},39:{name:"lcm",min:2,max:2},40:{name:"permutation",min:2,max:2},41:{name:"combination",min:2,max:2},42:{name:"average",min:0,max:1/0},43:{name:"median",min:0,max:1/0},44:{name:"total",min:0,max:1/0},45:{name:"count",min:0,max:1/0},46:{name:"proportion",min:3,max:3},47:{name:"clamp",min:3,max:3},48:{name:"hex",min:1,max:1},49:{name:"bin",min:1,max:1},50:{name:"int",min:1,max:1},51:{name:"compoundInterest",min:3,max:3},52:{name:"interestEarned",min:3,max:3},53:{name:"compoundInterestRate",min:3,max:3},54:{name:"compoundInterestYears",min:3,max:3},55:{name:"loanRepayment",min:4,max:4},56:{name:"loanInterest",min:4,max:4},57:{name:"monthlyPayment",min:3,max:3},58:{name:"taxAdd",min:2,max:2},59:{name:"taxRemove",min:2,max:2},60:{name:"inflationAdjust",min:3,max:3},61:{name:"root",min:2,max:2},62:{name:"fact",min:1,max:1},63:{name:"transpose",min:1,max:1},64:{name:"det",min:1,max:1},65:{name:"inv",min:1,max:1},66:{name:"dot",min:2,max:2},67:{name:"expand",min:1,max:1},68:{name:"factor",min:1,max:1},69:{name:"solve",min:3,max:3},70:{name:"der",min:2,max:3},71:{name:"integral",min:2,max:2},72:{name:"taylor",min:4,max:4},73:{name:"jacobian",min:1,max:1/0},74:{name:"imaginary",min:1,max:1},75:{name:"conj",min:1,max:1},76:{name:"re",min:1,max:1},77:{name:"im",min:1,max:1},78:{name:"cancel",min:1,max:1},79:{name:"apart",min:1,max:1},80:{name:"compoundInterestEvery",min:4,max:4},81:{name:"compoundInterestEarnedEvery",min:4,max:4},82:{name:"presentValue",min:3,max:3},83:{name:"roi",min:2,max:2},84:{name:"annualisedReturn",min:3,max:3},85:{name:"taxIn",min:2,max:2},86:{name:"taxOn",min:2,max:2},87:{name:"sind",min:1,max:1},88:{name:"cosd",min:1,max:1},89:{name:"tand",min:1,max:1},90:{name:"asind",min:1,max:1},91:{name:"acosd",min:1,max:1},92:{name:"atand",min:1,max:1},93:{name:"daysCount",min:1,max:1},94:{name:"asTwoUnits",min:3,max:3},95:{name:"makeRate",min:2,max:2},96:{name:"atRate",min:2,max:2},97:{name:"roundToPlaces",min:2,max:2},98:{name:"splitEach",min:2,max:2},99:{name:"savingsGoalPayment",min:3,max:3},100:{name:"savingsGoalPeriods",min:5,max:5},101:{name:"standardDeviation",min:0,max:1/0},102:{name:"sampleStandardDeviation",min:0,max:1/0},103:{name:"variance",min:0,max:1/0},104:{name:"sampleVariance",min:0,max:1/0},105:{name:"spread",min:0,max:1/0},106:{name:"mode",min:0,max:1/0},107:{name:"weightedAverage",min:2,max:1/0}};function ke(r){return r===1?"1 argument":`${r} arguments`}function rn(r){return r.max===1/0?`at least ${ke(r.min)}`:r.min===r.max?ke(r.min):`${r.min} to ${ke(r.max)}`}function Lt(r,a){let s=an[r];if(s!==void 0&&!(a>=s.min&&a<=s.max))return c$1.execution("BUILTIN_ARITY_MISMATCH",`${s.name}() takes ${rn(s)}, but was given ${a===0?"none":ke(a)}`,{functionName:s.name,expectedMin:s.min,expectedMax:s.max,actual:a})}function aa(r,a=200,s=5e4,u=50,l=1e5,g=2e6,b=1e4,f=100,y$1=-100,x=y,A){let C=[],I=new Map,L=0,j,$,n$1=[],Q=new Map,G=new Map,K=new Map;return {push(d){C.length<a&&C.push(d);},getMaxStackDepth(){return a},getMaxCollectionSize(){return l},getMaxAllocatedElements(){return g},getMaxFunctionCalls(){return b},getMaxDateOffsetYears(){return f},getMinDateOffsetYears(){return y$1},isHoliday(d){return A?A(d):false},pop(){return C.length===0?n(0):C.pop()},popNumber(){return c(C).toNumber()},popString(){return q(c(C),"VM.popString()")},peek(){return C[C.length-1]},getStack(){return C},registry:r,getVar(d){if(n$1.length>0){let e=n$1[n$1.length-1].get(d);if(e!==void 0)return e}return I.get(d)},setVar(d,e){I.set(d,e);},deleteVar(d){I.delete(d);},pushCallFrame(d){if(n$1.length>=u)throw c$1.execution("FUNCTION_RECURSION_LIMIT_EXCEEDED",`Function call nesting exceeded maximum depth of ${u} (possible infinite recursion, e.g. f(x) = f(x))`,{maxFunctionRecursionDepth:u});n$1.push(d);},popCallFrame(){n$1.pop();},getCallFrame(){return n$1.length>0?n$1[n$1.length-1]:void 0},defineUserFunction(d,e,t){Q.set(d,{name:d,params:e,program:t});},getUserFunction(d){return Q.get(d)},hasUserFunction(d){return Q.has(d)},getVariableEntries(){return Array.from(I.entries())},getUserFunctionDefs(){return Array.from(Q.values())},defineEquation(d,e,t){G.set(d,{variable:d,factorNames:e,rhsProgram:t});},getEquation(d){return G.get(d)},hasEquation(d){return G.has(d)},defineScalarEquation(d,e,t){K.set(d,{variable:d,lhsProgram:e,rhsProgram:t});},getScalarEquation(d){return K.get(d)},hasScalarEquation(d){return K.has(d)},reset(){C.length=0,I.clear(),n$1.length=0,Q.clear(),G.clear(),K.clear(),L=0,$&&($(),$=void 0),j=void 0;},get activeSignal(){return j},set activeSignal(d){j=d;},get abortCurrent(){return $},set abortCurrent(d){$=d;},context:x,getMaxInstructions(){return s},getInstructionCount(){return L},incrementInstructions(d){if(L+=d,L>s)throw c$1.execution("INSTRUCTION_LIMIT_EXCEEDED",`Execution exceeded maximum of ${s} instructions`)}}}function sn(r,a){return r.rows===1&&r.cols===1?a.data.length:a.rows===1&&a.cols===1?r.data.length:r.cols!==a.rows?0:r.rows*a.cols}function on(r,a){return !Number.isInteger(a)||a<0?0:r.rows*r.cols*(1+(a<2?1:2*Math.floor(Math.log2(a))))}function c(r){if(r.length===0)throw c$1.internal({code:"STACK_UNDERFLOW",message:"Stack underflow: an opcode expected a value on the stack but it was empty",expected:"at least one value on the VM stack",found:"an empty stack",suggestion:"this indicates corrupted bytecode or a bug in a package's parselet (mismatched push/pop counts), not a user-input error"});return r.pop()}var Jt="bytecode is caller input on this entry point: rebuild the program with the engine's compiler, or fix the hand-assembled stream";function un(r){return typeof r=="number"?b(r):r}function oe(r,a,s,u,l,g={}){let b=un(a);return c$1.validation({code:r,message:`Malformed bytecode: ${b} ${s}`,expected:u,found:l,suggestion:Jt,context:typeof a=="number"?{opcode:a,opcodeName:b,...g}:{site:b,...g}})}function O(r,a,s,u){if(a>=r.length)throw oe("MALFORMED_BYTECODE_TRUNCATED",s,`is missing its ${u}: the program ends mid-instruction`,`an operand byte at offset ${a}`,`a program only ${r.length} byte(s) long`,{offset:a,length:r.length,role:u});return r[a]}function Je(r,a,s,u,l,g){let b=O(r,a,s,u);if(b>=l)throw oe("MALFORMED_BYTECODE_CONSTANT_INDEX",s,`reads ${g} entry ${b}, which does not exist`,`an index below ${l}`,`${b}`,{index:b,poolSize:l,pool:g});return b}function J(r,a,s,u,l){return Se(s,O(r,a,u,l),u)}function Se(r,a,s){let u=r[a];if(typeof u!="string")throw oe("MALFORMED_BYTECODE_CONSTANT_INDEX",s,`reads string-pool entry ${a}, which is ${a>=r.length?"past the end of the pool":"not a string"}`,`an index below ${r.length}, holding a string`,a>=r.length?`${a}`:typeof u,{index:a,poolSize:r.length,pool:"string-pool"});return u}function q(r,a,s){if(typeof r.value!="string")throw oe("MALFORMED_BYTECODE_OPERAND_TYPE",a,`expected a ${s??"string"} on the stack`,s?`a string value holding the ${s}`:"a string value",`a ${g[r.type]??"unknown"} value`,s?{role:s,valueType:r.type}:{valueType:r.type});return r.value}function $t(r,a,s){if(r!==0&&r!==1&&r!==2)throw oe("MALFORMED_BYTECODE_BODY_KIND",s,`has body kind ${r}, which is not one this VM knows`,"0 (inline body), 1 (builtin function) or 2 (user-defined function)",`${r}`,{kind:r,ref:a})}function mn(r,a){try{return BigInt(r)}catch{throw oe("MALFORMED_BYTECODE_BIGINT_LITERAL",a,`cannot read "${r}" as a whole number`,"a string holding an integer, with no decimal point or separators",`"${r}"`,{literal:r})}}function ln(r){if(r===null||typeof r!="object")return `expected a bytecode program, got ${r===null?"null":typeof r}`;let a=r;return typeof a.opcodes?.length!="number"?"the program has no `opcodes` array":typeof a.numbers?.length!="number"?"the program has no `numbers` pool":typeof a.strings?.length!="number"?"the program has no `strings` pool":null}var Pt=64;function Qe(r,a,s,u,l,g,b,f){let y=new Map;for(let A=0;A<r.length;A++)y.set(r[A],s[A]);u.pushCallFrame(y);let x;try{x=tt(a,u,l,g,b,f);}finally{u.popCallFrame();}if(x.type==="pending")throw c$1.execution("MAP_REDUCE_ASYNC_UNSUPPORTED","map/reduce transform bodies calling an async operation (weather, stocks, currency, ...) aren't supported");if(x.type==="error")throw x.error;return x.value}function cn(r,a,s,u,l,g,b){let f=new Map(s.getCallFrame());f.set(r,K(q$1(r))),s.pushCallFrame(f);let y;try{y=tt(a,s,u,l,g,b);}finally{s.popCallFrame();}if(y.type==="pending")throw c$1.execution("SYMBOLIC_ASYNC_UNSUPPORTED","an algebra verb's expression cannot call an async operation (weather, stocks, currency, ...)");if(y.type==="error")throw y.error;return y.value}function Yt(r,a){if(r.type!==6||a.type!==6)return null;let s=r.unit,u=a.unit;if(s===void 0||u===void 0)return null;let l=s.indexOf("/"),g=u.indexOf("/");if(l<0||g<0||s.slice(0,l)!==u.slice(0,g))return null;let b=a$3[s.slice(l+1).toLowerCase()],f=a$3[u.slice(g+1).toLowerCase()];return b===void 0||f===void 0||b[0]!==f[0]?null:r.toNumber()*(f[1]/b[1])}function Wt(r,a){if(r.type!==6||a.type!==6)return null;let s=r.unit,u$1=a.unit;if(s===void 0||u$1===void 0||s.includes("/")||u$1.includes("/"))return null;let l=ua[s.toUpperCase()]!==void 0,g=ua[u$1.toUpperCase()]!==void 0;return l===g?null:u(r.toNumber()*a.toNumber(),l?s:u$1)}function Xt(r,a,s){if(r.type===5)return a.type===6&&a.unit!==void 0?c$6(a,a.unit,r.toNumber(),s):a.type!==5&&a.type!==0?null:N(r.toNumber()+s*a.toNumber());if(a.type!==5)return null;let u=1+s*a.toNumber();if(r.type===0){let l=r.toNumber()*u;return r.uncertainty!==void 0?q$2(l,Math.abs(r.uncertainty*u)):n(l)}return r.type===6&&r.unit!==void 0?c$6(r,r.unit,a.toNumber(),s):null}function pn(r,a){let s=r.type===5?r:a.type===5?a:null;if(s===null)return null;let u=s===r?a:r;if(u.type!==0||u.uncertainty===void 0)return null;let l=s.toNumber();return q$2(u.toNumber()*l,Math.abs(u.uncertainty*l))}function dn(r,a){let s=r.type===6?r:a,u=r.type===6?a:r;return s.type!==6||s.unit===void 0||!c$5.isCurrency(s.unit)||u.type!==0&&u.type!==5||u.rational!==void 0?null:b$2(s,u.toNumber(),s.unit)}function fn(r,a){if(a.type===5&&r.type===0&&r.uncertainty!==void 0){let s=a.toNumber();return s===0?null:q$2(r.toNumber()/s,Math.abs(r.uncertainty/s))}if(r.type===5&&a.type===0&&a.uncertainty!==void 0){let s=a.toNumber();return s===0?null:q$2(r.toNumber()/s,Math.abs(r.toNumber()*a.uncertainty/(s*s)))}return null}function bn(r){if(r.type===6){let a=r.unit;if(a&&c$4(a)==="time")try{return e$1(r.toNumber(),a,"ms")}catch{}return 0}return r.toNumber()}var Gt=260;function Qt(r,a,s){let u=Math.trunc(Math.abs(a)),g=(a>=0?1:-1)>0?s.getMaxDateOffsetYears():-s.getMinDateOffsetYears(),b=Math.floor(g*Gt);if(u>b)throw c$1.execution("DATE_OFFSET_LIMIT_EXCEEDED",`A date offset of ${u.toLocaleString("en-US")} workdays is about ${Math.round(u/Gt).toLocaleString("en-US")} years, past the limit of ${g} years for a workday offset`,{requestedWorkdays:u,limitYears:g,limitWorkdays:b});let f=b*7+7,y=Bt(r,a,x=>s.isHoliday(x),f);if(y===null)throw c$1.execution("DATE_OFFSET_LIMIT_EXCEEDED",`A working-day offset of ${u.toLocaleString("en-US")} could not be reached within the ${g}-year limit; the configured holiday calendar leaves too few working days`,{requestedWorkdays:u,limitYears:g,maxCalendarSteps:f});return y}var Kt=864e5,hn={month:1,months:1,mo:1,year:12,years:12,yr:12,y:12,a:12,decade:120,decades:120,dec:120,century:1200,centuries:1200,millennium:12e3,millennia:12e3};function gn(r,a){return new Date(r,a+1,0).getDate()}function Zt(r,a){let s=Math.trunc(a),u=new Date(r);u.setDate(u.getDate()+s);let l=u.getTime();return Number.isNaN(l)?r+a*Kt:l+(a-s)*Kt}function yn(r,a){let s=Math.trunc(a),u=new Date(r),l=u.getDate();u.setDate(1),u.setMonth(u.getMonth()+s),u.setDate(Math.min(l,gn(u.getFullYear(),u.getMonth())));let g=u.getTime(),b=e$1(1,"month","ms");return Number.isNaN(g)?r+a*b:g+(a-s)*b}function he(r,a,s,u){if(a.type===6&&a.unit!==void 0){let l=a.unit,g=s*a.toNumber();if(a$2(l))return Qt(r,g,u);let b=hn[l];if(b!==void 0)return yn(r,g*b);if(c$4(l)==="time"){let f=0;try{f=e$1(1,l,"day");}catch{}if(Number.isInteger(f)&&f>=1)return Zt(r,g*f)}}return r+s*bn(a)}function Ht(r,a,s){let u$1=B(r.unit);if(a.type===6&&A(a.unit)){let l=B(a.unit);return l!==u$1?P("TIMECODE_FPS_MISMATCH",`Cannot combine timecodes at different frame rates (${u$1} fps vs ${l} fps)`):s===1?u(r.toNumber()+a.toNumber(),r.unit):u(r.toNumber()-a.toNumber(),"frames")}if(a.type===6&&a.unit==="frames")return u(r.toNumber()+s*a.toNumber(),r.unit);if(a.type===6&&a.unit&&c$4(a.unit)==="time"){let l=e$1(a.toNumber(),a.unit,"s");return u(r.toNumber()+s*l*u$1,r.unit)}return u(r.toNumber()+s*a.toNumber(),r.unit)}function ge(r){return r.type===10?r.value:r.toNumber()!==0}function qt(r,a){let s=l(r,a);return P("INCOMPATIBLE_UNITS",s??`Cannot convert ${r} to ${a}: they do not measure the same thing`)}var Te=65536;function Nn(r,a){if(!Number.isInteger(a)||a<0)return null;if(a===0)return 1;let s=Math.abs(r.toNumber());return s<=1?1:(s<=2?1:Math.log2(s))*a}function xn(r,a){let s=1n,u=r,l=a;for(;l>0n;)l%2n===1n&&(s*=u),l/=2n,l>0n&&(u*=u);return s}var Ze=Te;function jt(r){let a=r<0n?-r:r;if(a===0n)return 0;let s=Number(a);return Number.isFinite(s)?Math.floor(Math.log2(s))+1:a.toString(16).length*4}function zt(r,a,s$1){let u=n$1(r),l=n$1(a);if(u===0n)return s(0n);let g=s$1*Number(l);if(g<=0||jt(u)+g<=Ze)return s(s$1===1?u<<l:u>>l);throw c$1.execution("BIGINT_SHIFT_LIMIT_EXCEEDED",`Shifting by ${l} would build an exact integer of about ${(jt(u)+g).toLocaleString("en-US")} bits, past the limit of ${Ze.toLocaleString("en-US")} bits`,{shift:String(l),limitBits:Ze})}function et(r,a){let{numerator:s,denominator:u$1}=y$1(r.unit),l=c$4(u$1),g=c$4(a.unit);if(!l||l!==g)return P("RATE_MUL_MEASURE_MISMATCH",`Cannot multiply a "${u$1}"-denominated rate by "${a.unit}" \u2014 different measures`);let b=e$1(a.toNumber(),a.unit,u$1),f=r.toNumber()*b;return s?u(f,s):n(f)}function En(r){if(Number.isNaN(r))return "NaN";if(!isFinite(r))return r>0?"Infinity":"-Infinity";let a=r<0,s=Math.abs(r),u=Math.floor(s),l=s-u;if(l<1e-9)return `${a?"-":""}${u}`;let g=0,b=1,f=1,y=0,x=l,A=1e6;for(let I=0;I<30;I++){let L=Math.floor(x+1e-9),j=L*b+g,$=L*y+f;if($>A||(g=b,b=j,f=y,y=$,Math.abs(l-b/y)<1e-9))break;let n=x-L;if(n<1e-9)break;x=1/n;}let C=u*y+b;return `${a?"-":""}${C}/${y}`}function In(r){return r.d===1n?String(r.n):`${r.n}/${r.d}`}function Mn(r){let a=r.toNumber(),s=r.type===5?1+a:a;return `${Math.round(s*1e6)/1e6}x`}function Dn(r){if(!Number.isFinite(r))return String(r);if(r===0)return "0e+0";let[a,s]=r.toExponential().split("e");return `${a.includes(".")?a.replace(/0+$/,"").replace(/\.$/,""):a}e${s}`}function tt(r$3,a$2,s$2,u$2,l,g$2){let b$2=ln(r$3);if(b$2)return {type:"error",error:c$1.validation({code:"MALFORMED_BYTECODE_PROGRAM",message:`Malformed bytecode: ${b$2}`,expected:"a BytecodeProgram with opcodes, numbers and strings",found:b$2,suggestion:Jt})};let{opcodes:f$3,numbers:y,strings:x$1,userFunctionBodies:A$1,anonymousBodies:C$2}=r$3,I$1=0,L$1=0,j$3=a$2.getMaxInstructions(),$$1=a$2.getMaxStackDepth(),n$2=a$2.getStack(),Q$1=s$2?.hasCollectors??false,G$2=j();if(f$3.length===0)return {type:"value",value:n(0)};a(a$2);try{for(;I$1<f$3.length;){if(++L$1>j$3)throw c$1.execution("INSTRUCTION_LIMIT_EXCEEDED",`Execution exceeded maximum of ${j$3} instructions`);if(n$2.length>$$1)throw c$1.execution("STACK_LIMIT_EXCEEDED",`Execution exceeded maximum stack depth of ${$$1}`);let d$1=f$3[I$1++];if(Q$1){let e=n$2.map(t=>({type:t.type,value:t.value,unit:t.unit}));s$2.fireVmStep({type:c$2.VmStep,elapsedNs:0,expression:u$2??"",opcode:d$1,opcodeName:b(d$1),ip:I$1-1,stackDepth:n$2.length,instructionNumber:L$1,stack:e});}switch(d$1){case 0:break;case 1:{let e=c(n$2);return {type:"value",value:G$2?k(e):e}}case 3:{let e=c(n$2);n$2.push(e),n$2.push(e);break}case 2:{let e=c(n$2),t=c(n$2);n$2.push(e),n$2.push(t);break}case 10:n$2.push(n(y[Je(f$3,I$1++,d$1,"constant-pool index",y.length,"number-pool")]));break;case 11:n$2.push(s(mn(J(f$3,I$1++,x$1,d$1,"constant-pool index"),d$1)));break;case 16:{let e=ia(J(f$3,I$1++,x$1,d$1,"constant-pool index"));n$2.push(o(ra(e),e));break}case 12:n$2.push(r$1(y[Je(f$3,I$1++,d$1,"constant-pool index",y.length,"number-pool")]));break;case 13:n$2.push(t(J(f$3,I$1++,x$1,d$1,"constant-pool index")));break;case 14:n$2.push(L(O(f$3,I$1++,d$1,"boolean operand")===1));break;case 20:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.uncertainty!==void 0||e.uncertainty!==void 0){let p=s$1(t,e,"add");if(p){n$2.push(p);break}}if(t.rational!==void 0||e.rational!==void 0){let p=r$2(t,e,"add");if(p){n$2.push(p);break}}let i=Xt(t,e,1),m=i===null?Yt(t,e):null;i!==null?n$2.push(i):m!==null?n$2.push(u(m+e.toNumber(),e.unit)):t.type===0&&e.type===0?n$2.push(n(t.value+e.value)):t.type===10&&e.type===10?n$2.push(L(t.value&&e.value)):t.type===4?e.type===4?n$2.push(P("INVALID_DATETIME_OP","Cannot add two datetimes together")):n$2.push(M(he(t.toNumber(),e,1,a$2))):t.type===6&&A(t.unit)?n$2.push(Ht(t,e,1)):e.type===4?n$2.push(M(he(e.toNumber(),t,1,a$2))):n$2.push(u$1(t,e,(p,h)=>p+h,(p,h)=>p+h,"add"));break}case 21:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.uncertainty!==void 0||e.uncertainty!==void 0){let p=s$1(t,e,"sub");if(p){n$2.push(p);break}}if(t.rational!==void 0||e.rational!==void 0){let p=r$2(t,e,"sub");if(p){n$2.push(p);break}}let i=Xt(t,e,-1),m=i===null?Yt(t,e):null;i!==null?n$2.push(i):m!==null?n$2.push(u(m-e.toNumber(),e.unit)):t.type===0&&e.type===0?n$2.push(n(t.value-e.value)):t.type===4?e.type===4?n$2.push(u(t.toNumber()-e.toNumber(),"ms")):n$2.push(M(he(t.toNumber(),e,-1,a$2))):t.type===6&&A(t.unit)?n$2.push(Ht(t,e,-1)):e.type===4?n$2.push(P("INVALID_DATETIME_OP","Cannot subtract a datetime from a value that is not a datetime")):n$2.push(u$1(t,e,(p,h)=>p-h,(p,h)=>p-h,"sub"));break}case 22:{let e=c(n$2),t=c(n$2),o=pn(t,e);if(o){n$2.push(o);break}if(t.uncertainty!==void 0||e.uncertainty!==void 0){let m=s$1(t,e,"mul");if(m){n$2.push(m);break}}if(t.rational!==void 0||e.rational!==void 0){let m=r$2(t,e,"mul");if(m){n$2.push(m);break}}let i=dn(t,e);if(i){n$2.push(i);break}if(t.type===0&&e.type===0)n$2.push(n(t.value*e.value));else if(t.type===7&&e.type===7)d(sn(t.value,e.value),"matrix cells"),n$2.push(_(t.value,e.value));else if(t.type===6&&x(t.unit)&&e.type===6&&e.unit)n$2.push(et(t,e));else if(e.type===6&&x(e.unit)&&t.type===6&&t.unit)n$2.push(et(e,t));else if(Wt(t,e)!==null)n$2.push(Wt(t,e));else {let m=ze(t,e,!0);m?n$2.push(m):n$2.push(u$1(t,e,(p,h)=>p*h,(p,h)=>p*h,"mul"));}break}case 23:{let e=c(n$2),t=c(n$2),o=fn(t,e);if(o){n$2.push(o);break}if(t.uncertainty!==void 0||e.uncertainty!==void 0){let i=s$1(t,e,"div");if(i){n$2.push(i);break}}if(t.type===6&&e.type===6){let{lv:i,rv:m,sameMeasure:p}=j$2(t,e);if(p)n$2.push(n(i/m));else if(c$5.isCurrency(t.unit)&&c$5.isCurrency(e.unit))n$2.push(P("INCOMPATIBLE_UNITS",`Cannot combine incompatible units: ${t.unit} and ${e.unit}`));else {let h=ze(t,e,!1);if(h){n$2.push(h);break}n$2.push(w(i/m,t.unit,e.unit));}}else {let i=r$2(t,e,"div");if(i){n$2.push(i);break}n$2.push(u$1(t,e,(m,p)=>m/p,(m,p)=>{if(p===0n)throw o$1();return m/p},"div"));}break}case 24:{let e=c(n$2),t=c(n$2);n$2.push(u$1(t,e,(o,i)=>o%i,(o,i)=>{if(i===0n)throw o$1();return o%i}));break}case 25:{let e=c(n$2),t=c(n$2);if(t.type===13){n$2.push(t);break}if(e.type===13){n$2.push(e);break}if(t.type===12){n$2.push(t);break}if(e.type===12){n$2.push(e);break}if(t.type===0&&e.type===0){n$2.push(n(q$3(t.value,e.value)));break}if(t.type===7||e.type===7){if(t.type!==7||e.type!==0){n$2.push(P("MATRIX_POWER_UNSUPPORTED",`^: a matrix may only be the base, raised to a whole number (as in "[1,2;3,4]^2"); "${g[t.type]} ^ ${g[e.type]}" has no matrix reading.`));break}d(on(t.value,e.value),"matrix cells"),n$2.push($(t.value,e.value));break}if(t.type===9||e.type===9){n$2.push(f$2(t,e));break}if(t.type===2||e.type===2){let o=Nn(t,e.toNumber());if(o!==null){if(o>Te)throw c$1.execution("BIGINT_POW_LIMIT_EXCEEDED",`That power would build an exact integer of about ${Math.round(o).toLocaleString("en-US")} bits, past the limit of ${Te.toLocaleString("en-US")} bits`,{limitBits:Te});n$2.push(s(xn(n$1(t),n$1(e))));break}}n$2.push(n(q$3(t.toNumber(),e.toNumber())));break}case 26:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}e.type===2?n$2.push(s(-e.value)):e.type===6&&e.exact!==void 0?n$2.push(v(-e.toNumber(),e.unit,ma(e.exact))):e.type===6?n$2.push(u(-e.toNumber(),e.unit)):e.type===5?n$2.push(N(-e.toNumber())):e.type===9?n$2.push(g$1(e)):e.type===0&&e.rational!==void 0?n$2.push(p$1(-e.toNumber(),j$1(e.rational))):e.type===0&&e.exact!==void 0?n$2.push(o(-e.toNumber(),ma(e.exact))):n$2.push(n(-e.toNumber()));break}case 27:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}e.type===6&&e.exact!==void 0?n$2.push(v(e.toNumber(),e.unit,e.exact)):e.type===6?n$2.push(u(e.toNumber(),e.unit)):e.type===5?n$2.push(N(e.toNumber())):e.type===0&&e.rational!==void 0?n$2.push(p$1(e.toNumber(),e.rational)):e.type===0&&e.exact!==void 0?n$2.push(o(e.toNumber(),e.exact)):n$2.push(n(e.toNumber()));break}case 28:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}n$2.push(q$2(t.toNumber(),Math.abs(e.toNumber())));break}case 30:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}t.type===2||e.type===2?n$2.push(zt(t,e,1)):n$2.push(n(t.toNumber()<<e.toNumber()));break}case 31:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}t.type===2||e.type===2?n$2.push(zt(t,e,-1)):n$2.push(n(t.toNumber()>>e.toNumber()));break}case 32:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}n$2.push(n(t.toNumber()>>>e.toNumber()));break}case 33:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}t.type===2||e.type===2?n$2.push(s(n$1(t)&n$1(e))):n$2.push(n(t.toNumber()&e.toNumber()));break}case 34:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}t.type===2||e.type===2?n$2.push(s(n$1(t)|n$1(e))):n$2.push(n(t.toNumber()|e.toNumber()));break}case 35:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}t.type===2||e.type===2?n$2.push(s(n$1(t)^n$1(e))):n$2.push(n(t.toNumber()^e.toNumber()));break}case 36:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}e.type===2?n$2.push(s(~e.value)):n$2.push(n(~e.toNumber()));break}case 40:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.rational!==void 0||e.rational!==void 0){let i=t$1(t,e);if(i!==null){n$2.push(L(i===0));break}}if(t.type===0&&e.type===0)n$2.push(L(t.value===e.value));else if(t.type===2||e.type===2){let i=p(t,e);n$2.push(L(i===null?t.toNumber()===e.toNumber():i===0));}else if(t.type===3&&e.type===3)n$2.push(L(t.value===e.value));else if(t.type===6&&e.type===6){let{equal:i,sameMeasure:m}=k$1(t,e);n$2.push(L(m&&i));}else if(t.type===7&&e.type===7)n$2.push(aa$1(t.value,e.value,(i,m)=>i===m));else if(t.type===14||e.type===14)if(t.type===14&&e.type===14){let i=t.value,m=e.value;n$2.push(L(i.r===m.r&&i.g===m.g&&i.b===m.b&&i.a===m.a));}else n$2.push(L(!1));else n$2.push(L(t.toNumber()===e.toNumber()));break}case 41:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.rational!==void 0||e.rational!==void 0){let i=t$1(t,e);if(i!==null){n$2.push(L(i!==0));break}}if(t.type===0&&e.type===0)n$2.push(L(t.value!==e.value));else if(t.type===2||e.type===2){let i=p(t,e);n$2.push(L(i===null?t.toNumber()!==e.toNumber():i!==0));}else if(t.type===3&&e.type===3)n$2.push(L(t.value!==e.value));else if(t.type===6&&e.type===6){let{equal:i,sameMeasure:m}=k$1(t,e);n$2.push(L(!m||!i));}else if(t.type===7&&e.type===7)n$2.push(aa$1(t.value,e.value,(i,m)=>i!==m));else if(t.type===14||e.type===14)if(t.type===14&&e.type===14){let i=t.value,m=e.value;n$2.push(L(!(i.r===m.r&&i.g===m.g&&i.b===m.b&&i.a===m.a)));}else n$2.push(L(!0));else n$2.push(L(t.toNumber()!==e.toNumber()));break}case 42:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.rational!==void 0||e.rational!==void 0){let i=t$1(t,e);if(i!==null){n$2.push(L(i<0));break}}if(t.type===0&&e.type===0)n$2.push(L(t.value<e.value));else if(t.type===2||e.type===2){let i=p(t,e);n$2.push(L(i===null?t.toNumber()<e.toNumber():i<0));}else if(t.type===6&&e.type===6){let{lv:i,rv:m$1,equal:p,sameMeasure:h}=k$1(t,e);n$2.push(h?L(!p&&i<m$1):m(t,e));}else t.type===7&&e.type===7?n$2.push(aa$1(t.value,e.value,(i,m)=>i<m)):n$2.push(L(t.toNumber()<e.toNumber()));break}case 43:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.rational!==void 0||e.rational!==void 0){let i=t$1(t,e);if(i!==null){n$2.push(L(i<=0));break}}if(t.type===0&&e.type===0)n$2.push(L(t.value<=e.value));else if(t.type===2||e.type===2){let i=p(t,e);n$2.push(L(i===null?t.toNumber()<=e.toNumber():i<=0));}else if(t.type===6&&e.type===6){let{lv:i,rv:m$1,equal:p,sameMeasure:h}=k$1(t,e);n$2.push(h?L(p||i<=m$1):m(t,e));}else t.type===7&&e.type===7?n$2.push(aa$1(t.value,e.value,(i,m)=>i<=m)):n$2.push(L(t.toNumber()<=e.toNumber()));break}case 44:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.rational!==void 0||e.rational!==void 0){let i=t$1(t,e);if(i!==null){n$2.push(L(i>0));break}}if(t.type===0&&e.type===0)n$2.push(L(t.value>e.value));else if(t.type===2||e.type===2){let i=p(t,e);n$2.push(L(i===null?t.toNumber()>e.toNumber():i>0));}else if(t.type===6&&e.type===6){let{lv:i,rv:m$1,equal:p,sameMeasure:h}=k$1(t,e);n$2.push(h?L(!p&&i>m$1):m(t,e));}else t.type===7&&e.type===7?n$2.push(aa$1(t.value,e.value,(i,m)=>i>m)):n$2.push(L(t.toNumber()>e.toNumber()));break}case 45:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.rational!==void 0||e.rational!==void 0){let i=t$1(t,e);if(i!==null){n$2.push(L(i>=0));break}}if(t.type===0&&e.type===0)n$2.push(L(t.value>=e.value));else if(t.type===2||e.type===2){let i=p(t,e);n$2.push(L(i===null?t.toNumber()>=e.toNumber():i>=0));}else if(t.type===6&&e.type===6){let{lv:i,rv:m$1,equal:p,sameMeasure:h}=k$1(t,e);n$2.push(h?L(p||i>=m$1):m(t,e));}else t.type===7&&e.type===7?n$2.push(aa$1(t.value,e.value,(i,m)=>i>=m)):n$2.push(L(t.toNumber()>=e.toNumber()));break}case 130:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}n$2.push(L(ge(t)&&ge(e)));break}case 131:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}n$2.push(L(ge(t)||ge(e)));break}case 132:{let e=c(n$2),t=c(n$2),o=c(n$2),i=Q(o);if(i){n$2.push(i);break}n$2.push(ge(o)?t:e);break}case 50:{let e=O(f$3,I$1++,d$1,"plugin-function index"),t=O(f$3,I$1++,d$1,"argument count"),o=[];for(let p=0;p<t;p++)o.push(c(n$2));o.reverse();let i=a$2.context.pluginFunctions[e],m=R(o);if(m)n$2.push(m);else if(!i)n$2.push(n(0));else {let p=i(o,l);if(p instanceof Promise){let h=`plugin:${e}:${o.map(B=>String(B.value??"")).join("|")}`,E=a$2.activeSignal,U=a$2.context.pluginFunctionOwners[e]??"";return {type:"pending",queryKey:h,resolver:p,packageId:U,signal:E}}n$2.push(p);}break}case 51:{let e=O(f$3,I$1++,d$1,"builtin-function index"),t=O(f$3,I$1++,d$1,"argument count"),o=Lt(e,t);if(o)throw o;let i=[],m=!1;for(let E=0;E<t;E++){let U=c(n$2);U.type===9&&(m=!0),i.push(U);}let p=R(i);if(p){n$2.push(p);break}let h=C[e];if(h){let E=i.reverse(),U=m&&!e$2.has(e);n$2.push(U?h$1(e,E):h(E));}break}case 150:{let e=O(f$3,I$1++,d$1,"function-body index"),t=A$1?.[e];if(!t)throw c$1.internal("INTERNAL_MISSING_FUNCTION_BODY",`Internal error: DEFINE_USER_FUNCTION referenced missing body index ${e}`,{bodyIdx:e});a$2.defineUserFunction(t.name,t.params,t.program);break}case 151:{let e=J(f$3,I$1++,x$1,d$1,"function-name index"),t=O(f$3,I$1++,d$1,"argument count"),o=[];for(let h=0;h<t;h++)o.push(c(n$2));o.reverse();let i=a$2.getUserFunction(e);if(!i)throw c$1.execution("UNDEFINED_FUNCTION",`Undefined function: ${e}`,{name:e});if(t!==i.params.length)throw c$1.execution("FUNCTION_ARITY_MISMATCH",`${e} expects ${i.params.length} argument(s) but got ${t}`,{name:e,expected:i.params.length,actual:t});let m=new Map;for(let h=0;h<i.params.length;h++)m.set(i.params[h],o[h]);f$1(),a$2.pushCallFrame(m);let p;try{p=tt(i.program,a$2,s$2,u$2,l);}finally{a$2.popCallFrame();}if(p.type==="pending")throw c$1.execution("USER_FUNCTION_ASYNC_UNSUPPORTED",`${e}: user-defined functions with async bodies (weather, stocks, currency, ...) aren't supported`,{name:e});if(p.type==="error")throw p.error;n$2.push(p.value);break}case 60:{let e=J(f$3,I$1++,x$1,d$1,"variable-name index"),t=a$2.getVar(e);if(t!==void 0)n$2.push(t);else if(g$2)n$2.push(K(q$1(e)));else throw c$1.execution("UNDEFINED_VARIABLE",`Undefined variable: ${e}`,{varName:e});break}case 61:{let e=c(n$2),t=J(f$3,I$1++,x$1,d$1,"variable-name index");a$2.setVar(t,G$2?k(e):e),n$2.push(e);break}case 62:{let e=J(f$3,I$1++,x$1,d$1,"variable-name index"),t=J$1.get(e);if(t===void 0)throw c$1.internal({code:"GLOBAL_VARIABLE_NOT_RESOLVED",message:`Global variable "${e}" was read before it resolved`,expected:`global variable "${e}" to already be resolved (async preflight should guarantee this)`,found:"no value in the global variable store",context:{varName:e}});n$2.push(t);break}case 63:{let e=c(n$2),t=J(f$3,I$1++,x$1,d$1,"variable-name index");J$1.set(t,G$2?k(e):e),n$2.push(e);break}case 70:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}n$2.push(n(e.toNumber()));break}case 71:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}if(e.type===14){let o=e.value;n$2.push(G$1({r:o.r,g:o.g,b:o.b,a:o.a,format:"hex"}));break}n$2.push(r$1(e.type===2?e.value:e.toNumber()));break}case 74:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}n$2.push(N(e.toNumber()));break}case 140:{let e=c(n$2),t$1=Q(e);if(t$1){n$2.push(t$1);break}n$2.push(t(e.rational!==void 0?In(e.rational):En(e.toNumber())));break}case 141:{let e=c(n$2),t$1=Q(e);if(t$1){n$2.push(t$1);break}n$2.push(t(Mn(e)));break}case 142:{let e=c(n$2),t$1=Q(e);if(t$1){n$2.push(t$1);break}n$2.push(t(Dn(e.toNumber())));break}case 143:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}n$2.push(r$1(e.type===2?e.value:e.toNumber(),"bin"));break}case 144:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}n$2.push(r$1(e.type===2?e.value:e.toNumber(),"oct"));break}case 145:{let e=q(c(n$2),d$1,"converter name").toLowerCase(),t=c(n$2),o=Q(t);if(o){n$2.push(o);break}let i=G.get(e);i?n$2.push(i(t)):n$2.push(P("UNKNOWN_AS_CONVERTER",`Unknown converter "as ${e}"`));break}case 80:{let e=q(c(n$2),d$1,"unit name"),t=c(n$2),o=Q(t);if(o){n$2.push(o);break}let i=a$1(t,e);i?n$2.push(v(t.toNumber(),e,i)):n$2.push(u(t.toNumber(),e));break}case 81:{let e=q(c(n$2),d$1,"target unit name"),t=q(c(n$2),d$1,"source unit name"),o=c(n$2),i$1=Q(o);if(i$1){n$2.push(i$1);break}let m=o.toNumber(),p=c$4(t),h=c$5.isCurrency(t)&&c$5.isCurrency(e);if(p&&c$4(e)===p)n$2.push(u(e$1(m,t,e),e));else if(h){let E=c$5.convertSync(m,t,e);E!==null?n$2.push(u(E,e)):n$2.push(P("CURRENCY_RATE_UNAVAILABLE",`No exchange rate available for ${t} to ${e}`));}else {let E=i(m,t,e);E!==null?n$2.push(u(E,e)):n$2.push(qt(t,e));}break}case 85:{let e=q(c(n$2),d$1,"unit name"),t$1=f(e);n$2.push(t(t$1.length>0?t$1.join(", "):`No known units for "${e}"`));break}case 83:{let e=q(c(n$2),d$1,"unit name"),t=c(n$2),o=Q(t);if(o){n$2.push(o);break}let{value:i,unit:m}=h(t.toNumber(),e);n$2.push(u(i,m));break}case 84:{let e=q(c(n$2),d$1,"target unit name"),t=c(n$2),o=Q(t);if(o){n$2.push(o);break}if(t.type===6){let i$1=t.unit,m=t.toNumber(),p=c$4(i$1),h=c$5.isCurrency(i$1)&&c$5.isCurrency(e);if(p&&c$4(e)===p)n$2.push(u(e$1(m,i$1,e),e));else if(h){let E=c$5.convertSync(m,i$1,e);E!==null?n$2.push(u(E,e)):n$2.push(P("CURRENCY_RATE_UNAVAILABLE",`No exchange rate available for ${i$1} to ${e}`));}else {let E=i(m,i$1,e);E!==null?n$2.push(u(E,e)):n$2.push(qt(i$1,e));}}else n$2.push(u(t.toNumber(),e));break}case 82:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}n$2.push(n(e.toNumber()));break}case 110:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(e.type!==6||!e.unit){n$2.push(P("RATE_MISSING_DENOMINATOR_UNIT",'Cannot build a rate: the right-hand side of "/" has no unit'));break}let i=t.type===6?t.unit??"":"";n$2.push(w(t.toNumber()/e.toNumber(),i,e.unit));break}case 111:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.type!==6||!x(t.unit)){n$2.push(P("RATE_MUL_LEFT_NOT_A_RATE",'Left-hand side of a rate multiplication must be a rate (e.g. "$50/week")'));break}if(e.type!==6||!e.unit){n$2.push(P("RATE_MUL_RIGHT_MISSING_UNIT","Right-hand side of a rate multiplication must have a unit matching the rate's denominator"));break}n$2.push(et(t,e));break}case 112:{let e=q(c(n$2),d$1,"denominator unit name"),t=c(n$2),o=Q(t);if(o){n$2.push(o);break}if(t.type!==6||!x(t.unit)){n$2.push(P("RATE_CONVERT_NOT_A_RATE","Cannot convert a non-rate value's denominator"));break}let{numerator:i,denominator:m}=y$1(t.unit),p=c$4(m),h=c$4(e);if(!p||p!==h){n$2.push(P("RATE_CONVERT_MEASURE_MISMATCH",`Cannot convert a "${m}"-denominated rate to "${e}" \u2014 different measures`));break}let E=e$1(1,e,m);n$2.push(w(t.toNumber()*E,i,e));break}case 120:{let e=c(n$2),t=Q(e);if(t){n$2.push(t);break}let o=e.toNumber(),i=new Date,m=new Date(i.getFullYear(),i.getMonth(),i.getDate(),0,0,0,0);m.setMinutes(o),n$2.push(M(m.getTime()));break}case 90:n$2.push(M(Date.now()));break;case 95:n$2.push(M(y[Je(f$3,I$1++,d$1,"constant-pool index",y.length,"number-pool")]));break;case 91:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}n$2.push(M(he(t.toNumber(),e,1,a$2)));break}case 92:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}n$2.push(M(he(t.toNumber(),e,-1,a$2)));break}case 96:{let e=O(f$3,I$1++,d$1,"workday offset direction")===1?-1:1,t=c(n$2),o=c(n$2),i=Q(o,t);if(i){n$2.push(i);break}if(t.type!==4){n$2.push(P(r.WORKDAY_OFFSET_EXPECTED_DATE,`"working days after/before/from" expects a date to count from, got ${g[t.type]??"an unsupported value"}`));break}n$2.push(M(Qt(t.toNumber(),e*o.toNumber(),a$2)));break}case 97:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.type!==4||e.type!==4){n$2.push(P(r.WORKDAYS_BETWEEN_EXPECTED_DATES,`"working days between" expects two dates, got ${g[t.type]??"an unsupported value"} and ${g[e.type]??"an unsupported value"}`));break}let i=Math.ceil((a$2.getMaxDateOffsetYears()-a$2.getMinDateOffsetYears())*366),m=Ft(t.toNumber(),e.toNumber(),p=>a$2.isHoliday(p),i);if(m===null){n$2.push(P(r.WORKDAYS_BETWEEN_RANGE_TOO_LARGE,`The two dates are more than ${a$2.getMaxDateOffsetYears()-a$2.getMinDateOffsetYears()} years apart, past the working-day count's limit`));break}n$2.push(n(m));break}case 93:case 94:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}let i=e.toNumber(),m=t.toNumber(),p=new Date(m).getDay(),h=d$1===93?(i-p+7)%7:(p-i+7)%7;h===0&&(h=7),n$2.push(M(Zt(m,d$1===93?h:-h)));break}case 152:{let e$1=O(f$3,I$1++,d$1,"row count"),t=O(f$3,I$1++,d$1,"column count"),o=e$1*t,i=e(o,"matrix cells"),m=null;for(let p=o-1;p>=0;p--){let h=c(n$2);m===null&&(m=Q(h)),i[p]=h.type===10||h.type===9?h.value:h.toNumber();}if(m){n$2.push(m);break}n$2.push(C$1(e$1,t,Y(e$1,t,i)));break}case 153:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.type!==7){n$2.push(P("MATRIX_INDEX_NOT_A_MATRIX",'Cannot index a non-matrix value with "[...]".'));break}let i=t.value,m=Math.trunc(e.toNumber());if(m<0||m>=i.data.length){n$2.push(P("MATRIX_INDEX_OUT_OF_BOUNDS",`Index ${m} is out of bounds for a ${i.rows}x${i.cols} matrix (valid range: 0-${i.data.length-1}).`));break}let p=S(i,m);n$2.push(X(p));break}case 154:{let e=c(n$2),t=c(n$2),o=c(n$2),i=Q(o,t,e);if(i){n$2.push(i);break}if(o.type!==7){n$2.push(P("MATRIX_INDEX_NOT_A_MATRIX",'Cannot index a non-matrix value with "[...]".'));break}let m=o.value,p=Math.trunc(t.toNumber()),h=Math.trunc(e.toNumber());if(!U(m,p,h)){n$2.push(P("MATRIX_INDEX_OUT_OF_BOUNDS",`[${p}, ${h}] is out of bounds for a ${m.rows}x${m.cols} matrix.`));break}let E=T(m,p,h);n$2.push(X(E));break}case 156:{let e=c(n$2),t=c(n$2),o=Q(t,e);if(o){n$2.push(o);break}if(t.type!==0||e.type!==0){n$2.push(P("INVALID_RANGE_BOUND",`A range's bounds must be plain numbers (e.g. "0:3").`));break}let i=t.value,m=e.value;if(!Number.isInteger(i)||!Number.isInteger(m)){n$2.push(P("NON_INTEGER_RANGE_BOUND",`A range's bounds must be whole numbers, got "${i}:${m}".`));break}if(i>m){n$2.push(P("DESCENDING_RANGE",`A range's min (${i}) cannot be greater than its max (${m}) \u2014 did you mean "${m}:${i}"?`));break}n$2.push(F(i,m));break}case 155:{let e$1=c(n$2),t=c(n$2),o=c(n$2),i=Q(o,t,e$1);if(i){n$2.push(i);break}if(o.type!==7){n$2.push(P("MATRIX_INDEX_NOT_A_MATRIX",'Cannot slice a non-matrix value with "[...]".'));break}if(t.type!==8||e$1.type!==8){n$2.push(P("INVALID_MATRIX_SLICE_BOUND",'Matrix slicing needs range bounds (e.g. "a[0:1, 1:2]").'));break}let m=o.value,p=t.value,h=e$1.value;if(p.min<0||p.max>=m.rows||h.min<0||h.max>=m.cols){n$2.push(P("MATRIX_INDEX_OUT_OF_BOUNDS",`Slice [${p.min}:${p.max}, ${h.min}:${h.max}] is out of bounds for a ${m.rows}x${m.cols} matrix.`));break}let E=p.max-p.min+1,U=h.max-h.min+1,B=e(E*U,"matrix cells");for(let V=0;V<E;V++)for(let _=0;_<U;_++)B[V+_*E]=T(m,p.min+V,h.min+_);n$2.push(C$1(E,U,B));break}case 157:{let e$1=O(f$3,I$1++,d$1,"body kind"),t=O(f$3,I$1++,d$1,"body reference"),o=O(f$3,I$1++,d$1,"collection count");$t(e$1,t,d$1);let i=new Array(o);for(let k=o-1;k>=0;k--)i[k]=c(n$2);let m=[],p;if(e$1===0){let k=C$2?.[t];if(!k)throw c$1.internal("INTERNAL_MISSING_ANONYMOUS_BODY",`Internal error: MAP_INVOKE referenced missing anonymous body index ${t}`,{ref:t});m=k.params,p=k.program;}else if(e$1===2){let k=Se(x$1,t,d$1),v=a$2.getUserFunction(k);if(!v){n$2.push(P("UNDEFINED_FUNCTION",`map: undefined function "${k}"`));break}if(v.params.length!==o){n$2.push(P("FUNCTION_ARITY_MISMATCH",`map: "${k}" expects ${v.params.length} argument(s) but ${o} collection(s) were given`));break}m=v.params,p=v.program;}let h=-1,E=new Array(o),U;for(let k=0;k<o;k++){let v=ea(i[k],a$2.getMaxCollectionSize());if(!Array.isArray(v)){U=v;break}if(c$3(v.length,"collection elements"),h===-1)h=v.length;else if(v.length!==h){U=P("MAP_COLLECTION_LENGTH_MISMATCH",`map: all collections must have the same length (got ${h} and ${v.length}).`);break}E[k]=v;}if(U){n$2.push(U);break}let B=e(h,"matrix cells"),V;for(let k=0;k<h;k++){let v=new Array(o);for(let ye=0;ye<o;ye++)v[ye]=E[ye][k];let ae=e$1===1?C[t]?.(v)??P("UNKNOWN_BUILTIN_FUNCTION",`map: unknown builtin function index ${t}`):Qe(m,p,v,a$2,s$2,u$2,l,!!g$2),nt=Q(ae);if(nt){V=nt;break}B[k]=ae.type===10||ae.type===9?ae.value:ae.toNumber();}if(V){n$2.push(V);break}let _=i[0],R=_?.type===7?_.value:void 0;R&&R.rows*R.cols===h?n$2.push(C$1(R.rows,R.cols,B)):n$2.push(C$1(1,h,B));break}case 160:{let e=O(f$3,I$1++,d$1,"plot body reference"),t=O(f$3,I$1++,d$1,"plot expression"),o=Se(x$1,t,d$1),i=c(n$2).toNumber(),m=c(n$2).toNumber(),p=C$2?.[e];if(!p)throw c$1.internal("INTERNAL_MISSING_ANONYMOUS_BODY",`Internal error: PLOT_INVOKE referenced missing anonymous body index ${e}`,{ref:e});if(!Number.isFinite(m)||!Number.isFinite(i)){n$2.push(P("PLOT_INVALID_RANGE",`plot: the range bounds must be finite numbers (got ${m} to ${i})`));break}let h=[];for(let _=0;_<Pt;_++){let R=m+_/(Pt-1)*(i-m),k;try{k=Qe(p.params,p.program,[n(R)],a$2,s$2,u$2,l,!!g$2).toNumber();}catch{continue}Number.isFinite(k)&&h.push([R,k]);}let E=h.map(_=>_[1]),U=E.length?Math.min(...E):0,B=E.length?Math.max(...E):0,V=_=>Number.isInteger(_)?String(_):String(Number(_.toFixed(2)));n$2.push(I({kind:"plot",points:h,label:`${o} over [${V(m)}, ${V(i)}]`,domain:[m,i],range:[U,B],expr:o}));break}case 158:{let e=O(f$3,I$1++,d$1,"body kind"),t=O(f$3,I$1++,d$1,"body reference"),o=O(f$3,I$1++,d$1,"initial-value flag");$t(e,t,d$1);let i=o?c(n$2):void 0,m=c(n$2),p=[],h;if(e===0){let _=C$2?.[t];if(!_)throw c$1.internal("INTERNAL_MISSING_ANONYMOUS_BODY",`Internal error: REDUCE_INVOKE referenced missing anonymous body index ${t}`,{ref:t});p=_.params,h=_.program;}else if(e===2){let _=Se(x$1,t,d$1),R=a$2.getUserFunction(_);if(!R){n$2.push(P("UNDEFINED_FUNCTION",`reduce: undefined function "${_}"`));break}if(R.params.length!==2){n$2.push(P("FUNCTION_ARITY_MISMATCH",`reduce: "${_}" must take exactly 2 arguments (accumulator, element), got ${R.params.length}`));break}p=R.params,h=R.program;}let E=ea(m,a$2.getMaxCollectionSize());if(!Array.isArray(E)){n$2.push(E);break}c$3(E.length,"collection elements");let U,B;if(i!==void 0){let _=Q(i);if(_){n$2.push(_);break}U=i,B=0;}else {if(E.length===0){n$2.push(P("REDUCE_EMPTY_COLLECTION","reduce: cannot reduce an empty collection without an initial value."));break}U=E[0],B=1;}let V;for(let _=B;_<E.length;_++){let R=[U,E[_]],k=e===1?C[t]?.(R)??P("UNKNOWN_BUILTIN_FUNCTION",`reduce: unknown builtin function index ${t}`):Qe(p,h,R,a$2,s$2,u$2,l,!!g$2),v=Q(k);if(v){V=v;break}U=k;}if(V){n$2.push(V);break}n$2.push(U);break}case 159:{let e=O(f$3,I$1++,d$1,"body reference"),t=C$2?.[e];if(!t)throw c$1.internal("INTERNAL_MISSING_ANONYMOUS_BODY",`Internal error: BIND_UNKNOWN referenced missing anonymous body index ${e}`,{ref:e});n$2.push(cn(t.params[0],t.program,a$2,s$2,u$2,l,!!g$2));break}}}let K$1=c(n$2);return {type:"value",value:G$2?k(K$1):K$1}}catch(K){return {type:"error",error:d$1(K)}}finally{b$1();}}export{Ot as a,vt as b,aa as c,tt as d};//# sourceMappingURL=chunk-EOMHELRL.js.map
2
+ //# sourceMappingURL=chunk-EOMHELRL.js.map