solve-engine 2.16.0 → 2.18.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.
- package/dist/{BytecodeBuilder-CRYfrFfq.d.cts → BytecodeBuilder-aqVa7Plx.d.cts} +10 -0
- package/dist/{BytecodeBuilder-CRYfrFfq.d.ts → BytecodeBuilder-aqVa7Plx.d.ts} +10 -0
- package/dist/{EngineError-Cv5q4Rbv.d.cts → EngineError-DTk7I7hZ.d.cts} +24 -0
- package/dist/{EngineError-Cv5q4Rbv.d.ts → EngineError-DTk7I7hZ.d.ts} +24 -0
- package/dist/{PackageCompatibility-CHQ4kDT8.d.ts → PackageCompatibility-BGXSFuL9.d.ts} +1 -1
- package/dist/{PackageCompatibility-BET0iFb9.d.cts → PackageCompatibility-BZCqaTOO.d.cts} +1 -1
- package/dist/{PackageRegistry-YmfowYr1.d.ts → PackageRegistry-BRoVOYzg.d.ts} +78 -5
- package/dist/{PackageRegistry-DzmG-Rvu.d.cts → PackageRegistry-rMGnTh7W.d.cts} +78 -5
- package/dist/{Parselet-CK0bNO1l.d.ts → Parselet-B-WyUtX4.d.ts} +5 -1
- package/dist/{Parselet-DOGmj6N6.d.cts → Parselet-Bkbp9CKD.d.cts} +5 -1
- package/dist/{ScopeManager-BtqiTVjG.d.cts → ScopeManager-bCYewWVt.d.cts} +2 -2
- package/dist/{ScopeManager-C6c1WmJD.d.ts → ScopeManager-gB9UengK.d.ts} +2 -2
- package/dist/{TokenNormalizer-BfTHg1qt.d.cts → TokenNormalizer-MXaKLJ_m.d.cts} +182 -0
- package/dist/{TokenNormalizer-d7F1KQFs.d.ts → TokenNormalizer-OTPS0Otq.d.ts} +182 -0
- package/dist/{VMCheckpoints-DJdvpliw.d.ts → VMCheckpoints-BDRY1Kx8.d.ts} +2 -2
- package/dist/{VMCheckpoints-BFDlaGse.d.cts → VMCheckpoints-DGar9Yg8.d.cts} +2 -2
- package/dist/{WorkerError-FH7KXX4_.d.cts → WorkerError-DGBNM3gA.d.cts} +1 -1
- package/dist/{WorkerError-J3v3ix_z.d.ts → WorkerError-DpZgKRks.d.ts} +1 -1
- package/dist/{chunk-UZSPBFZN.js → chunk-2DPKJ2SM.js} +2 -2
- package/dist/{chunk-UZSPBFZN.js.map → chunk-2DPKJ2SM.js.map} +1 -1
- package/dist/{chunk-O3ALJLYC.js → chunk-3GR46UOX.js} +2 -2
- package/dist/{chunk-O3ALJLYC.js.map → chunk-3GR46UOX.js.map} +1 -1
- package/dist/{chunk-PREIL3IB.cjs → chunk-3SSMOVWB.cjs} +2 -2
- package/dist/{chunk-PREIL3IB.cjs.map → chunk-3SSMOVWB.cjs.map} +1 -1
- package/dist/{chunk-VOTTSM4L.cjs → chunk-43FUDMIP.cjs} +3 -3
- package/dist/{chunk-VOTTSM4L.cjs.map → chunk-43FUDMIP.cjs.map} +1 -1
- package/dist/{chunk-XK23K3EJ.js → chunk-4ETS224G.js} +2 -2
- package/dist/{chunk-XK23K3EJ.js.map → chunk-4ETS224G.js.map} +1 -1
- package/dist/chunk-4XXUXRST.js +2 -0
- package/dist/chunk-4XXUXRST.js.map +1 -0
- package/dist/{chunk-55B4PSPM.js → chunk-6ERKCASV.js} +2 -2
- package/dist/{chunk-55B4PSPM.js.map → chunk-6ERKCASV.js.map} +1 -1
- package/dist/{chunk-GWCBPITD.cjs → chunk-6YM67DWH.cjs} +3 -3
- package/dist/{chunk-GWCBPITD.cjs.map → chunk-6YM67DWH.cjs.map} +1 -1
- package/dist/{chunk-6U66HQKQ.cjs → chunk-75JLWK4L.cjs} +2 -2
- package/dist/{chunk-6U66HQKQ.cjs.map → chunk-75JLWK4L.cjs.map} +1 -1
- package/dist/chunk-AYRVYGQO.js +3 -0
- package/dist/chunk-AYRVYGQO.js.map +1 -0
- package/dist/{chunk-VJP4GGCW.cjs → chunk-BNCBB4H5.cjs} +2 -2
- package/dist/{chunk-VJP4GGCW.cjs.map → chunk-BNCBB4H5.cjs.map} +1 -1
- package/dist/chunk-CCTO74QZ.js +5 -0
- package/dist/chunk-CCTO74QZ.js.map +1 -0
- package/dist/chunk-CO2BI6WL.cjs +3 -0
- package/dist/chunk-CO2BI6WL.cjs.map +1 -0
- package/dist/chunk-EN3CDYOS.cjs +2 -0
- package/dist/chunk-EN3CDYOS.cjs.map +1 -0
- package/dist/{chunk-GWJJRH32.js → chunk-EQDT42JG.js} +3 -3
- package/dist/{chunk-GWJJRH32.js.map → chunk-EQDT42JG.js.map} +1 -1
- package/dist/chunk-G2MFTERZ.cjs +2 -0
- package/dist/chunk-G2MFTERZ.cjs.map +1 -0
- package/dist/chunk-G63TMUL2.js +2 -0
- package/dist/chunk-G63TMUL2.js.map +1 -0
- package/dist/{chunk-5EX2FCM3.js → chunk-GE5VBDFX.js} +3 -3
- package/dist/{chunk-5EX2FCM3.js.map → chunk-GE5VBDFX.js.map} +1 -1
- package/dist/{chunk-UUAFDZK6.cjs → chunk-H3JXNH7X.cjs} +3 -3
- package/dist/{chunk-UUAFDZK6.cjs.map → chunk-H3JXNH7X.cjs.map} +1 -1
- package/dist/{chunk-2XZCLDHJ.cjs → chunk-J7ABVGZH.cjs} +2 -2
- package/dist/{chunk-2XZCLDHJ.cjs.map → chunk-J7ABVGZH.cjs.map} +1 -1
- package/dist/chunk-JVMINMAB.js +2 -0
- package/dist/chunk-JVMINMAB.js.map +1 -0
- package/dist/chunk-JYLNQOPU.cjs +2 -0
- package/dist/chunk-JYLNQOPU.cjs.map +1 -0
- package/dist/{chunk-JOIQFDZQ.js → chunk-KEA5HRL3.js} +2 -2
- package/dist/{chunk-JOIQFDZQ.js.map → chunk-KEA5HRL3.js.map} +1 -1
- package/dist/chunk-KWA257PC.cjs +3 -0
- package/dist/chunk-KWA257PC.cjs.map +1 -0
- package/dist/{chunk-TVE2DNPU.js → chunk-LJFS3XHW.js} +2 -2
- package/dist/{chunk-TVE2DNPU.js.map → chunk-LJFS3XHW.js.map} +1 -1
- package/dist/{chunk-C5MP74ER.js → chunk-MRRMIBHE.js} +2 -2
- package/dist/{chunk-C5MP74ER.js.map → chunk-MRRMIBHE.js.map} +1 -1
- package/dist/chunk-N64ZK6CL.cjs +2 -0
- package/dist/{chunk-EEVUKZ5B.cjs.map → chunk-N64ZK6CL.cjs.map} +1 -1
- package/dist/chunk-O3BDXOQJ.js +2 -0
- package/dist/chunk-O3BDXOQJ.js.map +1 -0
- package/dist/chunk-PHNSXQ4L.cjs +2 -0
- package/dist/chunk-PHNSXQ4L.cjs.map +1 -0
- package/dist/chunk-PIZQIQVM.js +3 -0
- package/dist/chunk-PIZQIQVM.js.map +1 -0
- package/dist/{chunk-IPOU3JTA.js → chunk-QTSDIDAS.js} +3 -3
- package/dist/{chunk-IPOU3JTA.js.map → chunk-QTSDIDAS.js.map} +1 -1
- package/dist/{chunk-P4ETODMP.js → chunk-RLTH2H3U.js} +2 -2
- package/dist/{chunk-P4ETODMP.js.map → chunk-RLTH2H3U.js.map} +1 -1
- package/dist/{chunk-WOIJPV7Z.js → chunk-SEOIKHYK.js} +2 -2
- package/dist/{chunk-WOIJPV7Z.js.map → chunk-SEOIKHYK.js.map} +1 -1
- package/dist/{chunk-XZYZS4BP.cjs → chunk-TCHKFSZD.cjs} +2 -2
- package/dist/{chunk-XZYZS4BP.cjs.map → chunk-TCHKFSZD.cjs.map} +1 -1
- package/dist/{chunk-W5ELYJ4Z.cjs → chunk-TL545PXW.cjs} +2 -2
- package/dist/{chunk-W5ELYJ4Z.cjs.map → chunk-TL545PXW.cjs.map} +1 -1
- package/dist/{chunk-FAGFPVYK.cjs → chunk-TRDOYAKJ.cjs} +2 -2
- package/dist/{chunk-FAGFPVYK.cjs.map → chunk-TRDOYAKJ.cjs.map} +1 -1
- package/dist/chunk-X7DFJS7R.cjs +5 -0
- package/dist/chunk-X7DFJS7R.cjs.map +1 -0
- package/dist/{chunk-EXCFCHAT.cjs → chunk-XPJGDGJF.cjs} +2 -2
- package/dist/{chunk-EXCFCHAT.cjs.map → chunk-XPJGDGJF.cjs.map} +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/engine.cjs +1 -1
- package/dist/engine.d.cts +8 -8
- package/dist/engine.d.ts +8 -8
- package/dist/engine.js +1 -1
- package/dist/errors.cjs +1 -1
- package/dist/errors.d.cts +3 -3
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +1 -1
- package/dist/format.cjs +1 -1
- package/dist/format.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +1 -1
- package/dist/language.d.cts +7 -7
- package/dist/language.d.ts +7 -7
- package/dist/lexer.cjs +1 -1
- package/dist/lexer.js +1 -1
- package/dist/normalizer.cjs +1 -1
- package/dist/normalizer.d.cts +2 -2
- package/dist/normalizer.d.ts +2 -2
- package/dist/normalizer.js +1 -1
- package/dist/packages.cjs +1 -1
- package/dist/packages.d.cts +6 -6
- package/dist/packages.d.ts +6 -6
- package/dist/packages.js +1 -1
- package/dist/parser.cjs +1 -1
- package/dist/parser.d.cts +2 -2
- package/dist/parser.d.ts +2 -2
- package/dist/parser.js +1 -1
- package/dist/resolvers.d.cts +1 -1
- package/dist/resolvers.d.ts +1 -1
- package/dist/testing.cjs +2 -2
- package/dist/testing.d.cts +7 -7
- package/dist/testing.d.ts +7 -7
- package/dist/testing.js +1 -1
- package/dist/uom.cjs +1 -1
- package/dist/uom.d.cts +1 -1
- package/dist/uom.d.ts +1 -1
- package/dist/uom.js +1 -1
- package/dist/vm.cjs +1 -1
- package/dist/vm.d.cts +5 -5
- package/dist/vm.d.ts +5 -5
- package/dist/vm.js +1 -1
- package/dist/worker.cjs +2 -2
- package/dist/worker.d.cts +7 -7
- package/dist/worker.d.ts +7 -7
- package/dist/worker.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-35RNQ2OQ.js +0 -5
- package/dist/chunk-35RNQ2OQ.js.map +0 -1
- package/dist/chunk-5CWVWMIY.js +0 -2
- package/dist/chunk-5CWVWMIY.js.map +0 -1
- package/dist/chunk-7EMZOBGW.cjs +0 -3
- package/dist/chunk-7EMZOBGW.cjs.map +0 -1
- package/dist/chunk-CUDPOWXA.js +0 -2
- package/dist/chunk-CUDPOWXA.js.map +0 -1
- package/dist/chunk-EEVUKZ5B.cjs +0 -2
- package/dist/chunk-ERMNQ5QJ.js +0 -2
- package/dist/chunk-ERMNQ5QJ.js.map +0 -1
- package/dist/chunk-FVQWN5HZ.cjs +0 -2
- package/dist/chunk-FVQWN5HZ.cjs.map +0 -1
- package/dist/chunk-IMXSVHQK.cjs +0 -2
- package/dist/chunk-IMXSVHQK.cjs.map +0 -1
- package/dist/chunk-LZSSAH5D.cjs +0 -2
- package/dist/chunk-LZSSAH5D.cjs.map +0 -1
- package/dist/chunk-NAZ6PGLS.cjs +0 -3
- package/dist/chunk-NAZ6PGLS.cjs.map +0 -1
- package/dist/chunk-Q3PSTNSY.js +0 -2
- package/dist/chunk-Q3PSTNSY.js.map +0 -1
- package/dist/chunk-SPOECHDG.cjs +0 -5
- package/dist/chunk-SPOECHDG.cjs.map +0 -1
- package/dist/chunk-W64AWQCX.js +0 -3
- package/dist/chunk-W64AWQCX.js.map +0 -1
- package/dist/chunk-YAZ4DUJJ.js +0 -3
- package/dist/chunk-YAZ4DUJJ.js.map +0 -1
- package/dist/chunk-Z4BXU65Y.cjs +0 -2
- package/dist/chunk-Z4BXU65Y.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/format/FormattingSettings.ts","../src/format/FormatEngine.ts"],"names":["DEFAULT_FORMATTING_SETTINGS","formatNumber","value","locale","settings","decimalPlaces","sep","loc","formatted","dp","autoFormatIntegerOrFloat","formatUncertain","center","uncertainty","useGrouping","spreadMax","centerText","spreadText","formatHex","base","negative","sign","digits","radix","padding","hex","MAX_DISPLAYED_BIGINT_DIGITS","formatBigInt","magnitude","bits","log10","exponent","mantissa","formatString","formatBoolean","formatDatetime","d","format","isMidnight","dateStr","p2","n","year","month","day","datePart","time","formatMsDuration","ms","totalSeconds","hours","minutes","seconds","mm","ss","formatUom","unit","exact","isTimeSpan","currencyDisplay","CURRENCY_DISPLAY","moneyText","decimalToFixed","formatMatrixEntry","entry","formatSymbolic","formatMatrix","m","rowMajor","columnMajorToRowMajor","rows","r","cells","c","formatMatrixAligned","us","row","colWidth","width","cell","formatRange","min","max","formatPercentage","formatUnit","formatIpCidr","data","dotted","formatIp","formatSplit","prefix","render","share","v","Value","text","formatValue","high","each","shareWord","localeCode","getLocale","formatColour"],"mappings":"mNA8CO,IAAMA,CAAAA,CAAkD,CAC7D,WAAA,CAAa,CACX,aAAA,CAAe,CAAA,CACf,eAAA,CAAiB,IACnB,CAAA,CACA,YAAA,CAAc,CACZ,sBAAA,CAAwB,OAC1B,EACA,SAAA,CAAW,CACT,aAAA,CAAe,KAAA,CACf,YAAA,CAAc,CAChB,CAAA,CACA,uBAAA,CAAyB,CACvB,aAAA,CAAe,CACjB,CAAA,CACA,gBAAA,CAAkB,CAChB,cAAe,CACjB,CAAA,CACA,UAAA,CAAY,CACV,MAAA,CAAQ,MACV,CACF,ECxDA,SAASC,CAAAA,CAAaC,CAAAA,CAAeC,CAAAA,CAAiBC,CAAAA,CAA8BC,CAAAA,CAAgC,CAClH,IAAMC,CAAAA,CAAMF,CAAAA,CAAS,WAAA,CAAY,eAAA,CAC3BG,CAAAA,CAAMH,CAAAA,CAAS,YAAA,CAAa,sBAAA,CAMlC,GAAIC,CAAAA,GAAkB,MAAA,EAAa,MAAA,CAAO,QAAA,CAASH,CAAK,CAAA,CAAG,CACzD,IAAMM,CAAAA,CAAYN,CAAAA,CAAM,cAAA,CAAeK,CAAAA,EAAO,OAAA,CAAS,CACrD,qBAAA,CAAuBF,CAAAA,CACvB,qBAAA,CAAuBA,CAAAA,CACvB,WAAA,CAAaC,CACf,CAAC,CAAA,CACD,OAAO,CAAA,EAAGH,CAAAA,CAAO,OAAA,CAAQ,YAAY,CAAA,EAAGK,CAAS,CAAA,CACnD,CACA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,EAAGC,CAAAA,CAAO,QAAQ,YAAY,CAAA,EAAGkF,EAAanF,CAAAA,CAAM,KAAmB,CAAC,CAAA,CAAA,CACjF,KAAA,CAAA,CACE,OAAO+D,GAAAA,CAAe/D,CAAAA,CAAM,KAAqB,CAAA,CACnD,KAAA,CAAA,CACE,OAAOiF,CAAAA,CAAiBjF,CAAAA,CAAM,MAAiBC,CAAAA,CAAQwE,CAAE,EAC3D,KAAA,EAAA,CACE,OAAOS,EAAWlF,CAAAA,CAAM,KAAA,CAAiBA,EAAM,IAAI,CAAA,CACrD,QAKE,OAAOA,CAAAA,CAAM,MAAQ,MAAA,CAAOA,CAAAA,CAAM,KAAK,CAAA,CACzC,QACE,OAAO,CAAA,EAAA,EAAK,MAAA,CAAOA,EAAM,KAAK,CAAC,EACnC,CACF","file":"chunk-IPOU3JTA.js","sourcesContent":["/**\n * How a Datetime value is rendered.\n *\n * - `'long'`: the spelled-out form, \"Tuesday, March 10, 2026\" (the default).\n * - `'iso'`: \"2026-03-10\" (ISO 8601, with a `T`-separated time when present).\n * - `'dmy'`: \"10/03/2026\" (day first).\n * - `'mdy'`: \"03/10/2026\" (month first).\n *\n * The weekday and long month name in `'long'` are localised through the same\n * locale the number separators come from; the numeric forms are locale-neutral.\n */\nexport type DateOutputFormat = \"long\" | \"iso\" | \"dmy\" | \"mdy\";\n\n/**\n * Minimal formatting settings interface for the engine\n * This allows the engine to format values without depending on app-specific settings\n */\nexport interface FormattingSettings {\n floatResult: {\n decimalPlaces: number;\n enableSeperator: boolean;\n };\n numberResult: {\n decimalSeparatorLocale: string;\n };\n hexResult: {\n enablePadding: boolean;\n paddingZeros: number;\n };\n unitOfMeasurementResult: {\n decimalPlaces: number;\n };\n percentageResult: {\n decimalPlaces: number;\n };\n /**\n * Optional so a host that built a `FormattingSettings` before this field\n * existed still compiles; a missing `dateResult` reads as `'long'`, the\n * historic output.\n */\n dateResult?: {\n format: DateOutputFormat;\n };\n}\n\n/** Formatting used when a host supplies none. */\nexport const DEFAULT_FORMATTING_SETTINGS: FormattingSettings = {\n floatResult: {\n decimalPlaces: 2,\n enableSeperator: true,\n },\n numberResult: {\n decimalSeparatorLocale: \"en-US\",\n },\n hexResult: {\n enablePadding: false,\n paddingZeros: 0,\n },\n unitOfMeasurementResult: {\n decimalPlaces: 2,\n },\n percentageResult: {\n decimalPlaces: 2,\n },\n dateResult: {\n format: \"long\",\n },\n};\n","import { Value, ValueType, type MatrixData, type MatrixEntry, type RangeData, type ColourData, type SplitData, type SplitShare, type ChartData, type IpCidrData } from \"@solve-js/vm/Value\";\nimport { formatColour } from \"@solve-js/packages/colour/ColourMath\";\nimport { formatIp } from \"@solve-js/packages/ip/IpMath\";\nimport { decimalToFixed, type DecimalData } from \"@solve-js/decimal\";\nimport { getLocale, type ILocale } from \"@solve-js/constants/locales\";\nimport { autoFormatIntegerOrFloat } from \"@solve-js/utilities/Number\";\nimport { FormattingSettings, DEFAULT_FORMATTING_SETTINGS } from \"./FormattingSettings\";\nimport { CURRENCY_DISPLAY } from \"@solve-js/uom/CurrencyAliases\";\nimport { columnMajorToRowMajor } from \"@solve-js/vm/MatrixOps\";\nimport { formatSymbolic, type SymbolicNode } from \"@solve-js/symbolic\";\n\nfunction formatNumber(value: number, locale: ILocale, settings: FormattingSettings, decimalPlaces?: number): string {\n const sep = settings.floatResult.enableSeperator;\n const loc = settings.numberResult.decimalSeparatorLocale;\n // An explicit precision (`3.14159 to 4 dp`, `round(1.5, 2)`) shows EXACTLY that\n // many places with trailing zeros kept, where the default trims them and shows\n // an integer with none. The value was already rounded to this precision when\n // it was set (see VMBuiltins' roundToPlaces, exact where an exact decimal was\n // there), so rendering it to the same place count reproduces that rounding.\n if (decimalPlaces !== undefined && Number.isFinite(value)) {\n const formatted = value.toLocaleString(loc || \"en-US\", {\n minimumFractionDigits: decimalPlaces,\n maximumFractionDigits: decimalPlaces,\n useGrouping: sep,\n });\n return `${locale.display.resultPrefix}${formatted}`;\n }\n const dp = settings.floatResult.decimalPlaces;\n const formatted = autoFormatIntegerOrFloat(value, dp, sep, loc);\n return `${locale.display.resultPrefix}${formatted}`;\n}\n\n/**\n * Renders a measurement that carries a one-sigma uncertainty as\n * `center ± spread`, e.g. `49.2 ± 2.0`.\n *\n * The center is shown the way any number is, whole numbers as integers and\n * trailing zeros trimmed, so a tolerance-free-looking center still reads\n * cleanly (\"30 ± 2.24\", not \"30.00 ± 2.24\"). The spread is shown to the same\n * decimal-place budget but always keeps at least one fractional digit, which is\n * what distinguishes it as a tolerance and gives \"± 2.0\" rather than \"± 2\".\n * Both use `Intl` with `maximumFractionDigits`, so the trailing-zero trimming is\n * locale-correct (a comma-decimal locale is not string-sliced on \".\").\n *\n * The symbol is always the `±` glyph on output, even when the input was the\n * ASCII `+/-`, since the glyph is the conventional notation and unambiguous to\n * read back.\n */\nfunction formatUncertain(center: number, uncertainty: number, locale: ILocale, settings: FormattingSettings): string {\n const dp = settings.floatResult.decimalPlaces;\n const useGrouping = settings.floatResult.enableSeperator;\n const loc = settings.numberResult.decimalSeparatorLocale || \"en-US\";\n // The spread needs room for at least one fractional digit, so a zero-decimal\n // budget cannot leave minimumFractionDigits above maximumFractionDigits.\n const spreadMax = Math.max(dp, 1);\n const centerText = center.toLocaleString(loc, { useGrouping, minimumFractionDigits: 0, maximumFractionDigits: dp });\n const spreadText = Math.abs(uncertainty).toLocaleString(loc, { useGrouping, minimumFractionDigits: 1, maximumFractionDigits: spreadMax });\n return `${locale.display.resultPrefix}${centerText} ± ${spreadText}`;\n}\n\n/**\n * Renders a number in whichever base it is tagged with.\n *\n * The zero padding is a hexadecimal setting and stays one. Applying it to a\n * binary rendering would pad `0b101` out to the same digit count as a hex\n * value, which is a different quantity of zeros and not what the setting asks\n * for.\n */\nfunction formatHex(value: number | bigint, settings: FormattingSettings, base?: string): string {\n // An infinity or a NaN has no digits in any base, and asking for them\n // produced `0xINFINITY`, a literal that reads back as nothing at all. Render\n // the value itself, which is what every other non-finite result shows.\n if (typeof value === \"number\" && !Number.isFinite(value)) return `= ${value}`;\n\n // Truncate and take the sign off before converting. `Number.toString(radix)`\n // does neither: it renders -255 as \"-ff\", which lands the minus inside the\n // literal as `0x-FF`, and it renders 255.7 as \"ff.b3333333333\", inventing\n // fractional hex digits for a notation that has no use for them. Both were\n // visible on `as hex` until the builtins started sharing this path.\n //\n // A bigint needs neither truncation nor a Math call, and must not be routed\n // through one: passing it to Math.trunc() throws, and converting it to a\n // double first is exactly the precision loss it is carried as a bigint to\n // avoid.\n const negative = typeof value === \"bigint\" ? value < 0n : value < 0;\n const sign = negative ? \"-\" : \"\";\n const digits = (radix: number): string =>\n typeof value === \"bigint\"\n ? (negative ? -value : value).toString(radix)\n : Math.abs(Math.trunc(value)).toString(radix);\n\n if (base === \"bin\") return `= ${sign}0b${digits(2)}`;\n if (base === \"oct\") return `= ${sign}0o${digits(8)}`;\n const padding = settings.hexResult.enablePadding ? settings.hexResult.paddingZeros : 0;\n const hex = digits(16).toUpperCase().padStart(padding, \"0\");\n return `= ${sign}0x${hex}`;\n}\n\n/**\n * How many decimal digits of an exact integer this will render in full.\n *\n * A little above the ~19,729 digits of the largest bigint the VM will build\n * (`vm/VM.ts`'s MAX_EXACT_POW_BITS / MAX_EXACT_SHIFT_BITS, 65,536 bits), so\n * every value the engine can produce through `^` or `<<` still prints exactly\n * and this ceiling only ever meets a value that came from somewhere else.\n */\nconst MAX_DISPLAYED_BIGINT_DIGITS = 20000;\n\n/**\n * Renders an exact integer, or describes it when writing it out is itself the\n * expensive operation.\n *\n * This used to be a bare `= ${value}` template, which renders whatever it is\n * handed: `1n << 100000000` took 8.5 seconds here turning a 12.5MB integer\n * into a thirty-million-character string, and a host has no way to opt out,\n * since displaying the answer is what it asked the engine for. The VM's own\n * ceiling on `<<` and `^` now stops that value existing, so this is the\n * backstop for every other way a large bigint can arrive (repeated `x * x`,\n * a Value a host built itself), and it costs one comparison for every value\n * that is not absurd.\n *\n * The digit count is estimated from the bit length rather than measured, since\n * measuring means doing the conversion this exists to avoid. Bit length comes\n * off the hexadecimal form, which is linear in the size of the value where the\n * decimal form is not.\n */\nfunction formatBigInt(value: bigint): string {\n const magnitude = value < 0n ? -value : value;\n // Every bigint a person actually reads takes this line and nothing else:\n // anything a double can hold is at most 309 digits, so it is printable\n // without measuring it at all.\n if (Number.isFinite(Number(magnitude))) return `= ${value}`;\n const bits = magnitude.toString(16).length * 4;\n if (bits * Math.LN2 / Math.LN10 <= MAX_DISPLAYED_BIGINT_DIGITS) return `= ${value}`;\n const log10 = bits * Math.LN2 / Math.LN10;\n const exponent = Math.floor(log10);\n const mantissa = Math.pow(10, log10 - exponent);\n const sign = value < 0n ? \"-\" : \"\";\n return `= ${sign}~${mantissa.toFixed(3)}e+${exponent} (an exact integer of about ${(exponent + 1).toLocaleString(\"en-US\")} digits, too large to print)`;\n}\n\nfunction formatString(value: string): string {\n return `= ${value}`;\n}\n\nfunction formatBoolean(value: boolean): string {\n return `= ${value}`;\n}\n\n/**\n * Renders a Datetime value locale-aware, the previous implementation\n * called `d.toLocaleString()` with no arguments, which always uses the JS\n * runtime's own default locale and never actually consulted `locale.code`\n * despite receiving it as a parameter (both branches of its old\n * `dateFormat === \"default\"` check were byte-for-byte identical, dead\n * groundwork for a distinction that was never implemented). Concretely,\n * this meant every configured locale (including the shipped German one)\n * always displayed weekday/month names in English. See GitHub issue #77.\n *\n * Uses `weekday`/`month`: \"long\" for a spelled-out date (\"Monday,\n * November 17, 2025\" / \"lundi 17 novembre 2025\") since that's what a\n * literal weekday name is for; a bare numeric date doesn't need\n * localizing beyond the decimal/thousands separators `formatNumber()`\n * already handles. The time-of-day portion is only appended when it's\n * not exactly local midnight, bare date literals (\"today\", \"17/11/2025\")\n * always anchor to local midnight, and showing \"00:00:00\" on every one of\n * those would be noise, not information.\n */\nfunction formatDatetime(value: number, locale: ILocale, settings: FormattingSettings): string {\n const d = new Date(value);\n const format = settings.dateResult?.format ?? \"long\";\n const isMidnight = d.getHours() === 0 && d.getMinutes() === 0 && d.getSeconds() === 0 && d.getMilliseconds() === 0;\n\n // The spelled-out default, localised through the locale's own names.\n if (format === \"long\") {\n const dateStr = d.toLocaleDateString(locale.code, { weekday: \"long\", year: \"numeric\", month: \"long\", day: \"numeric\" });\n if (isMidnight) return `= ${dateStr}`;\n return `= ${dateStr}, ${d.toLocaleTimeString(locale.code)}`;\n }\n\n // The numeric forms, built from the local calendar fields so they read the\n // same regardless of the JS runtime's own default locale.\n const p2 = (n: number) => String(n).padStart(2, \"0\");\n const year = d.getFullYear();\n const month = p2(d.getMonth() + 1);\n const day = p2(d.getDate());\n let datePart: string;\n if (format === \"iso\") datePart = `${year}-${month}-${day}`;\n else if (format === \"dmy\") datePart = `${day}/${month}/${year}`;\n else datePart = `${month}/${day}/${year}`; // mdy\n\n if (isMidnight) return `= ${datePart}`;\n const time = `${p2(d.getHours())}:${p2(d.getMinutes())}:${p2(d.getSeconds())}`;\n // ISO joins date and time with `T`; the slash forms with a space.\n return format === \"iso\" ? `= ${datePart}T${time}` : `= ${datePart} ${time}`;\n}\n\n/**\n * Renders a millisecond duration as clock-style `H:MM` (or `H:MM:SS` when\n * there's a non-zero seconds component). `ms` is never a user-typeable\n * unit (confirmed: it appears nowhere in `lexer/units.ts`), it's only\n * ever produced by subtracting two clock times/datetimes (`9:30 - 8:30`,\n * `VM.ts`'s Datetime SUB case), so this is a safe, narrow special case,\n * not a general change to how durations display.\n */\nfunction formatMsDuration(ms: number): string {\n const sign = ms < 0 ? \"-\" : \"\";\n const totalSeconds = Math.round(Math.abs(ms) / 1000);\n const hours = Math.floor(totalSeconds / 3600);\n const minutes = Math.floor((totalSeconds % 3600) / 60);\n const seconds = totalSeconds % 60;\n const mm = String(minutes).padStart(2, \"0\");\n if (seconds === 0) return `${sign}${hours}:${mm}`;\n const ss = String(seconds).padStart(2, \"0\");\n return `${sign}${hours}:${mm}:${ss}`;\n}\n\nfunction formatUom(value: number, unit: string | undefined, locale: ILocale, settings: FormattingSettings, exact?: DecimalData): string {\n if (unit === \"ms\") return `= ${formatMsDuration(value)}`;\n // A fuel-consumption unit is stored slash-free (so it is not read as a rate)\n // but shown the way it is written.\n if (unit === \"l100km\") unit = \"l/100km\";\n if (unit === \"mps2\") unit = \"m/s²\";\n\n const dp = settings.unitOfMeasurementResult.decimalPlaces;\n\n // For TimeSpan values (days, weeks, hours, etc.), format as integer if the value is a whole number\n const timeSpanUnits = [\"days\", \"weeks\", \"months\", \"years\", \"hours\", \"minutes\", \"seconds\", \"day\", \"week\", \"month\", \"year\", \"hour\", \"minute\", \"second\"];\n const isTimeSpan = unit && timeSpanUnits.includes(unit);\n\n let formatted: string;\n if (isTimeSpan && value === Math.floor(value)) {\n // For whole number TimeSpan values, format as integer\n formatted = value.toString();\n } else {\n // For other values, use the configured decimal places\n formatted = value.toFixed(dp);\n }\n\n // Currency display: symbol + culturally-conventional placement (e.g.\n // \"$100.00\" prefix vs \"100.00 kr\" suffix) instead of the generic\n // \"amount CODE\" fallback below. See uom/CurrencyAliases.ts's\n // CURRENCY_DISPLAY table for the exact set covered and the reasoning\n // behind each placement choice. Any currency code NOT in that table\n // (most of the ~150 `CurrencyExchange.isCurrency()` recognizes) falls\n // through to the unchanged \"amount CODE\" format below.\n const currencyDisplay = unit ? CURRENCY_DISPLAY[unit.toUpperCase()] : undefined;\n if (currencyDisplay) {\n // An exact money amount rounds from its decimal, not from the double: a\n // half-cent like \"$1.005\" reads as \"$1.01\" here, where \"(1.005).toFixed(2)\"\n // answers \"1.00\" because the double it is handed already sits below the\n // value the user typed. Amounts with no exact decimal (a currency\n // conversion, whose rate is a double) keep the toFixed rendering above.\n const moneyText = exact ? decimalToFixed(exact, dp) : formatted;\n const sep = currencyDisplay.spaced ? \" \" : \"\";\n const withSymbol = currencyDisplay.position === \"prefix\"\n ? `${currencyDisplay.symbol}${sep}${moneyText}`\n : `${moneyText}${sep}${currencyDisplay.symbol}`;\n return `= ${withSymbol}`;\n }\n\n // The unit is written as the symbol the value carries. There used to be a\n // `unitOfMeasurementResult.unitNames` setting here whose two branches were\n // the same expression, so it never changed anything, and it was removed\n // rather than implemented: the engine has no unit-name data to render from.\n // The generated unit table maps a spelling to [measure, ratio] only, and\n // names cannot be recovered from it, because units that differ by an OFFSET\n // share a ratio, so \"20 C\" would come back as \"20 kelvins\". A real\n // implementation needs a hand-authored name per unit plus pluralization and\n // per-locale spelling (metre against meter), which is a feature rather than\n // the repair of a dead ternary.\n //\n // An exact currency with no symbol in the display table above (one of the\n // less common ISO codes) still rounds from its decimal here, so \"1.005 UYW\"\n // reads the same way \"$1.005\" does. Non-currency Uoms never carry an exact,\n // so this leaves \"1.50 kg\" exactly as it was.\n const genericText = exact ? decimalToFixed(exact, dp) : formatted;\n return `= ${genericText} ${unit || \"\"}`.trim();\n}\n\nfunction formatMatrixEntry(entry: MatrixEntry, settings: FormattingSettings): string {\n if (typeof entry === \"boolean\") return entry ? \"true\" : \"false\";\n if (typeof entry === \"object\" && entry !== null) return formatSymbolic(entry);\n const dp = settings.floatResult.decimalPlaces;\n const sep = settings.floatResult.enableSeperator;\n const loc = settings.numberResult.decimalSeparatorLocale;\n return autoFormatIntegerOrFloat(entry, dp, sep, loc);\n}\n\n/**\n * Renders a Matrix matching its own literal syntax: a single row (1xN,\n * including plain vectors) as `[a, b, c]`, a single column (Nx1) as\n * `[a; b; c]`, and a general shape as `[r0c0, r0c1; r1c0, r1c1]`, row-major\n * textual output read back out of the column-major storage\n * (`columnMajorToRowMajor()`), matching how `[1,2;3,4]` is written.\n */\nfunction formatMatrix(m: MatrixData, locale: ILocale, settings: FormattingSettings): string {\n const rowMajor = columnMajorToRowMajor(m);\n const rows: string[] = [];\n for (let r = 0; r < m.rows; r++) {\n const cells: string[] = [];\n for (let c = 0; c < m.cols; c++) {\n cells.push(formatMatrixEntry(rowMajor[r * m.cols + c], settings));\n }\n rows.push(cells.join(\", \"));\n }\n return `${locale.display.resultPrefix}[${rows.join(\"; \")}]`;\n}\n\n/**\n * Render a matrix as a multi-line, column-aligned block: one row per line (the\n * newline is where {@link formatValue}'s compact form writes `;`), each column\n * right-padded to its widest cell, and every row wrapped in `[ ... ]`. For\n * display where a grid reads better than a line, e.g. a docs notepad or a REPL:\n *\n * ```text\n * [ 1 2 ]\n * [ 30 4 ]\n * ```\n *\n * This is deliberately separate from {@link formatValue}, whose single-line\n * matrix form stays the stable, assertable text the API and the worker DTO use.\n * A 1xN row vector is one line; an Nx1 column vector is N lines.\n */\nexport function formatMatrixAligned(m: MatrixData, settings?: FormattingSettings): string {\n const us = settings || DEFAULT_FORMATTING_SETTINGS;\n const rowMajor = columnMajorToRowMajor(m);\n const cells: string[][] = [];\n for (let r = 0; r < m.rows; r++) {\n const row: string[] = [];\n for (let c = 0; c < m.cols; c++) {\n row.push(formatMatrixEntry(rowMajor[r * m.cols + c], us));\n }\n cells.push(row);\n }\n const colWidth: number[] = [];\n for (let c = 0; c < m.cols; c++) {\n let width = 0;\n for (let r = 0; r < m.rows; r++) width = Math.max(width, cells[r][c].length);\n colWidth.push(width);\n }\n return cells\n .map((row) => `[ ${row.map((cell, c) => cell.padStart(colWidth[c])).join(\" \")} ]`)\n .join(\"\\n\");\n}\n\nfunction formatRange(min: number, max: number, locale: ILocale): string {\n return `${locale.display.resultPrefix}${min}:${max}`;\n}\n\nfunction formatPercentage(value: number, locale: ILocale, settings: FormattingSettings): string {\n // ValueType.Percentage stores a fraction (0.25 for 25%). See Value.ts's\n // documented contract and the sole producer, VM.ts's TO_PERCENTAGE opcode\n // (`right/left - 1`, e.g. 0.25 for \"800 to 1000\"). Multiply by 100 before\n // formatting; without this every percentage-change result displayed as\n // e.g. \"0.25%\" instead of \"25.00%\".\n const dp = settings.percentageResult.decimalPlaces;\n const formatted = (value * 100).toFixed(dp);\n return `= ${formatted}${locale.display.percentageSuffix}`;\n}\n\nfunction formatUnit(value: number, unit: string | undefined): string {\n return `= ${value} ${unit || \"\"}`.trim();\n}\n\n/**\n * Renders a per-person bill split: \"= $45.00 each\", or, when the division is\n * uneven, \"= $33.33 each, with 1 share paying $33.34\". Each share's amount is\n * rendered through the ordinary value formatter (a throwaway {@link Value}), so\n * a currency share honours the same symbol placement, decimal places and locale\n * as any other money and a bare share trims trailing zeros the way a plain\n * number does; the \"= \" prefix is added once, around the whole sentence, not\n * per share.\n */\n/**\n * An IP/CIDR as text: the dotted quad, plus `/prefix` when present, or a bare\n * `/prefix` when there is no address (`netmask of /24` before it resolves).\n */\nfunction formatIpCidr(data: IpCidrData): string {\n\tif (data.addr === undefined) return `/${data.prefix}`;\n\tconst dotted = formatIp(data.addr);\n\treturn data.prefix === undefined ? dotted : `${dotted}/${data.prefix}`;\n}\n\nfunction formatSplit(data: SplitData, locale: ILocale, settings: FormattingSettings): string {\n const prefix = locale.display.resultPrefix;\n const render = (share: SplitShare): string => {\n const v = data.unit !== undefined\n ? new Value(ValueType.Uom, share.value, data.unit)\n : new Value(ValueType.Number, share.value);\n v.exact = share.exact;\n const text = formatValue(v, settings);\n return text.startsWith(prefix) ? text.slice(prefix.length) : text;\n };\n\n const [base, high] = data.shares;\n const each = `${render(base)} each`;\n if (high === undefined) return `${prefix}${each}`;\n const shareWord = high.count === 1 ? \"share\" : \"shares\";\n return `${prefix}${each}, with ${high.count} ${shareWord} paying ${render(high)}`;\n}\n\n/**\n * Render an evaluated {@link Value} as a display string, dispatching on\n * `value.type` to the type-specific formatter (number, hex, datetime, unit\n * of measurement, matrix, range, percentage, ...).\n *\n * Most branches produce a `\"= \"`-prefixed result string (matching the\n * plugin's inline-result convention); `ValueType.Error` is the one\n * exception, it returns the human-readable error message directly\n * (stored in `value.unit`), not an `\"= \"`-prefixed string.\n *\n * @param value - The evaluated value to format.\n * @param settings - Locale/precision/separator options; defaults to\n * {@link DEFAULT_FORMATTING_SETTINGS} when omitted.\n * @example\n * ```typescript\n * const value = engine.evaluateExpression(\"10 USD to GBP\");\n * formatValue(value); // \"= £7.85\" (exact output depends on live exchange rates)\n * ```\n */\nexport function formatValue(value: Value, settings?: FormattingSettings): string {\n const us = settings || DEFAULT_FORMATTING_SETTINGS;\n const localeCode = us.numberResult.decimalSeparatorLocale || \"en\";\n const locale = getLocale(localeCode);\n\n switch (value.type) {\n case ValueType.Number:\n // A measurement with a tolerance renders as \"center ± spread\"; every\n // other number is unchanged, so a plain value is byte-for-byte what it was.\n if (value.uncertainty !== undefined) {\n return formatUncertain(value.value as number, value.uncertainty, locale, us);\n }\n return formatNumber(value.value as number, locale, us, value.decimalPlaces);\n case ValueType.Hex:\n return formatHex(value.value as number | bigint, us, value.unit);\n case ValueType.BigInt:\n return formatBigInt(value.value as bigint);\n case ValueType.String:\n return formatString(value.value as string);\n case ValueType.Boolean:\n return formatBoolean(value.value as boolean);\n case ValueType.Datetime:\n return formatDatetime(value.value as number, locale, us);\n case ValueType.Uom:\n return formatUom(value.value as number, value.unit, locale, us, value.exact);\n case ValueType.Matrix:\n return formatMatrix(value.value as MatrixData, locale, us);\n case ValueType.Range: {\n const r = value.value as RangeData;\n return formatRange(r.min, r.max, locale);\n }\n case ValueType.Colour:\n return `${locale.display.resultPrefix}${formatColour(value.value as ColourData)}`;\n case ValueType.Split:\n return formatSplit(value.value as SplitData, locale, us);\n case ValueType.Chart:\n // A chart is drawn from its data by the host; the text answer is its label\n // (`sin(x) over [0, 6.28]`, or the series a sparkline came from).\n return `${locale.display.resultPrefix}${(value.value as ChartData).label}`;\n case ValueType.IpCidr:\n return `${locale.display.resultPrefix}${formatIpCidr(value.value as IpCidrData)}`;\n case ValueType.Symbolic:\n return formatSymbolic(value.value as SymbolicNode);\n case ValueType.Percentage:\n return formatPercentage(value.value as number, locale, us);\n case ValueType.Unit:\n return formatUnit(value.value as number, value.unit);\n case ValueType.Error:\n // errorValue(code, message) stores the human-readable message in\n // `.unit` (code goes in `.value`), falling through to the default\n // case here previously displayed the raw code (e.g.\n // \"CURRENCY_RATE_UNAVAILABLE\") instead of the actual message.\n return value.unit ?? String(value.value);\n default:\n return `= ${String(value.value)}`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/format/FormattingSettings.ts","../src/format/FormatEngine.ts"],"names":["DEFAULT_FORMATTING_SETTINGS","formatNumber","value","locale","settings","decimalPlaces","sep","loc","formatted","dp","autoFormatIntegerOrFloat","formatUncertain","center","uncertainty","useGrouping","spreadMax","centerText","spreadText","formatHex","base","negative","sign","digits","radix","padding","hex","MAX_DISPLAYED_BIGINT_DIGITS","formatBigInt","magnitude","bits","log10","exponent","mantissa","formatString","formatBoolean","formatDatetime","d","format","isMidnight","dateStr","p2","n","year","month","day","datePart","time","formatMsDuration","ms","totalSeconds","hours","minutes","seconds","mm","ss","formatUom","unit","exact","isTimeSpan","currencyDisplay","CURRENCY_DISPLAY","moneyText","decimalToFixed","formatMatrixEntry","entry","formatSymbolic","formatMatrix","m","rowMajor","columnMajorToRowMajor","rows","r","cells","c","formatMatrixAligned","us","row","colWidth","width","cell","formatRange","min","max","formatPercentage","formatUnit","formatIpCidr","data","dotted","formatIp","formatSplit","prefix","render","share","v","Value","text","formatValue","high","each","shareWord","localeCode","getLocale","formatColour"],"mappings":"mNA8CO,IAAMA,CAAAA,CAAkD,CAC7D,WAAA,CAAa,CACX,aAAA,CAAe,CAAA,CACf,eAAA,CAAiB,IACnB,CAAA,CACA,YAAA,CAAc,CACZ,sBAAA,CAAwB,OAC1B,EACA,SAAA,CAAW,CACT,aAAA,CAAe,KAAA,CACf,YAAA,CAAc,CAChB,CAAA,CACA,uBAAA,CAAyB,CACvB,aAAA,CAAe,CACjB,CAAA,CACA,gBAAA,CAAkB,CAChB,cAAe,CACjB,CAAA,CACA,UAAA,CAAY,CACV,MAAA,CAAQ,MACV,CACF,ECxDA,SAASC,CAAAA,CAAaC,CAAAA,CAAeC,CAAAA,CAAiBC,CAAAA,CAA8BC,CAAAA,CAAgC,CAClH,IAAMC,CAAAA,CAAMF,CAAAA,CAAS,WAAA,CAAY,eAAA,CAC3BG,CAAAA,CAAMH,CAAAA,CAAS,YAAA,CAAa,sBAAA,CAMlC,GAAIC,CAAAA,GAAkB,MAAA,EAAa,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A,CAAO,OAAA,CAAQ,YAAY,CAAA,EAAGmG,CAAAA,CAAapG,EAAM,KAAmB,CAAC,GACjF,KAAA,EAAA,CACE,OAAOuF,EAAYvF,CAAAA,CAAM,KAAA,CAAoBC,EAAQwE,CAAE,CAAA,CACzD,QAGE,OAAO,CAAA,EAAGxE,EAAO,OAAA,CAAQ,YAAY,GAAID,CAAAA,CAAM,KAAA,CAAoB,KAAK,CAAA,CAAA,CAC1E,KAAA,EAAA,CACE,OAAO,CAAA,EAAGC,CAAAA,CAAO,QAAQ,YAAY,CAAA,EAAGkF,EAAanF,CAAAA,CAAM,KAAmB,CAAC,CAAA,CAAA,CACjF,KAAA,CAAA,CACE,OAAO+D,GAAAA,CAAe/D,CAAAA,CAAM,KAAqB,CAAA,CACnD,KAAA,CAAA,CACE,OAAOiF,CAAAA,CAAiBjF,CAAAA,CAAM,MAAiBC,CAAAA,CAAQwE,CAAE,EAC3D,KAAA,EAAA,CACE,OAAOS,EAAWlF,CAAAA,CAAM,KAAA,CAAiBA,EAAM,IAAI,CAAA,CACrD,QAKE,OAAOA,CAAAA,CAAM,MAAQ,MAAA,CAAOA,CAAAA,CAAM,KAAK,CAAA,CACzC,QACE,OAAO,CAAA,EAAA,EAAK,MAAA,CAAOA,EAAM,KAAK,CAAC,EACnC,CACF","file":"chunk-QTSDIDAS.js","sourcesContent":["/**\n * How a Datetime value is rendered.\n *\n * - `'long'`: the spelled-out form, \"Tuesday, March 10, 2026\" (the default).\n * - `'iso'`: \"2026-03-10\" (ISO 8601, with a `T`-separated time when present).\n * - `'dmy'`: \"10/03/2026\" (day first).\n * - `'mdy'`: \"03/10/2026\" (month first).\n *\n * The weekday and long month name in `'long'` are localised through the same\n * locale the number separators come from; the numeric forms are locale-neutral.\n */\nexport type DateOutputFormat = \"long\" | \"iso\" | \"dmy\" | \"mdy\";\n\n/**\n * Minimal formatting settings interface for the engine\n * This allows the engine to format values without depending on app-specific settings\n */\nexport interface FormattingSettings {\n floatResult: {\n decimalPlaces: number;\n enableSeperator: boolean;\n };\n numberResult: {\n decimalSeparatorLocale: string;\n };\n hexResult: {\n enablePadding: boolean;\n paddingZeros: number;\n };\n unitOfMeasurementResult: {\n decimalPlaces: number;\n };\n percentageResult: {\n decimalPlaces: number;\n };\n /**\n * Optional so a host that built a `FormattingSettings` before this field\n * existed still compiles; a missing `dateResult` reads as `'long'`, the\n * historic output.\n */\n dateResult?: {\n format: DateOutputFormat;\n };\n}\n\n/** Formatting used when a host supplies none. */\nexport const DEFAULT_FORMATTING_SETTINGS: FormattingSettings = {\n floatResult: {\n decimalPlaces: 2,\n enableSeperator: true,\n },\n numberResult: {\n decimalSeparatorLocale: \"en-US\",\n },\n hexResult: {\n enablePadding: false,\n paddingZeros: 0,\n },\n unitOfMeasurementResult: {\n decimalPlaces: 2,\n },\n percentageResult: {\n decimalPlaces: 2,\n },\n dateResult: {\n format: \"long\",\n },\n};\n","import { Value, ValueType, type MatrixData, type MatrixEntry, type RangeData, type ColourData, type SplitData, type SplitShare, type ChartData, type IpCidrData } from \"@solve-js/vm/Value\";\nimport { formatColour } from \"@solve-js/packages/colour/ColourMath\";\nimport { formatIp } from \"@solve-js/packages/ip/IpMath\";\nimport { decimalToFixed, type DecimalData } from \"@solve-js/decimal\";\nimport { getLocale, type ILocale } from \"@solve-js/constants/locales\";\nimport { autoFormatIntegerOrFloat } from \"@solve-js/utilities/Number\";\nimport { FormattingSettings, DEFAULT_FORMATTING_SETTINGS } from \"./FormattingSettings\";\nimport { CURRENCY_DISPLAY } from \"@solve-js/uom/CurrencyAliases\";\nimport { columnMajorToRowMajor } from \"@solve-js/vm/MatrixOps\";\nimport { formatSymbolic, type SymbolicNode } from \"@solve-js/symbolic\";\n\nfunction formatNumber(value: number, locale: ILocale, settings: FormattingSettings, decimalPlaces?: number): string {\n const sep = settings.floatResult.enableSeperator;\n const loc = settings.numberResult.decimalSeparatorLocale;\n // An explicit precision (`3.14159 to 4 dp`, `round(1.5, 2)`) shows EXACTLY that\n // many places with trailing zeros kept, where the default trims them and shows\n // an integer with none. The value was already rounded to this precision when\n // it was set (see VMBuiltins' roundToPlaces, exact where an exact decimal was\n // there), so rendering it to the same place count reproduces that rounding.\n if (decimalPlaces !== undefined && Number.isFinite(value)) {\n const formatted = value.toLocaleString(loc || \"en-US\", {\n minimumFractionDigits: decimalPlaces,\n maximumFractionDigits: decimalPlaces,\n useGrouping: sep,\n });\n return `${locale.display.resultPrefix}${formatted}`;\n }\n const dp = settings.floatResult.decimalPlaces;\n const formatted = autoFormatIntegerOrFloat(value, dp, sep, loc);\n return `${locale.display.resultPrefix}${formatted}`;\n}\n\n/**\n * Renders a measurement that carries a one-sigma uncertainty as\n * `center ± spread`, e.g. `49.2 ± 2.0`.\n *\n * The center is shown the way any number is, whole numbers as integers and\n * trailing zeros trimmed, so a tolerance-free-looking center still reads\n * cleanly (\"30 ± 2.24\", not \"30.00 ± 2.24\"). The spread is shown to the same\n * decimal-place budget but always keeps at least one fractional digit, which is\n * what distinguishes it as a tolerance and gives \"± 2.0\" rather than \"± 2\".\n * Both use `Intl` with `maximumFractionDigits`, so the trailing-zero trimming is\n * locale-correct (a comma-decimal locale is not string-sliced on \".\").\n *\n * The symbol is always the `±` glyph on output, even when the input was the\n * ASCII `+/-`, since the glyph is the conventional notation and unambiguous to\n * read back.\n */\nfunction formatUncertain(center: number, uncertainty: number, locale: ILocale, settings: FormattingSettings): string {\n const dp = settings.floatResult.decimalPlaces;\n const useGrouping = settings.floatResult.enableSeperator;\n const loc = settings.numberResult.decimalSeparatorLocale || \"en-US\";\n // The spread needs room for at least one fractional digit, so a zero-decimal\n // budget cannot leave minimumFractionDigits above maximumFractionDigits.\n const spreadMax = Math.max(dp, 1);\n const centerText = center.toLocaleString(loc, { useGrouping, minimumFractionDigits: 0, maximumFractionDigits: dp });\n const spreadText = Math.abs(uncertainty).toLocaleString(loc, { useGrouping, minimumFractionDigits: 1, maximumFractionDigits: spreadMax });\n return `${locale.display.resultPrefix}${centerText} ± ${spreadText}`;\n}\n\n/**\n * Renders a number in whichever base it is tagged with.\n *\n * The zero padding is a hexadecimal setting and stays one. Applying it to a\n * binary rendering would pad `0b101` out to the same digit count as a hex\n * value, which is a different quantity of zeros and not what the setting asks\n * for.\n */\nfunction formatHex(value: number | bigint, settings: FormattingSettings, base?: string): string {\n // An infinity or a NaN has no digits in any base, and asking for them\n // produced `0xINFINITY`, a literal that reads back as nothing at all. Render\n // the value itself, which is what every other non-finite result shows.\n if (typeof value === \"number\" && !Number.isFinite(value)) return `= ${value}`;\n\n // Truncate and take the sign off before converting. `Number.toString(radix)`\n // does neither: it renders -255 as \"-ff\", which lands the minus inside the\n // literal as `0x-FF`, and it renders 255.7 as \"ff.b3333333333\", inventing\n // fractional hex digits for a notation that has no use for them. Both were\n // visible on `as hex` until the builtins started sharing this path.\n //\n // A bigint needs neither truncation nor a Math call, and must not be routed\n // through one: passing it to Math.trunc() throws, and converting it to a\n // double first is exactly the precision loss it is carried as a bigint to\n // avoid.\n const negative = typeof value === \"bigint\" ? value < 0n : value < 0;\n const sign = negative ? \"-\" : \"\";\n const digits = (radix: number): string =>\n typeof value === \"bigint\"\n ? (negative ? -value : value).toString(radix)\n : Math.abs(Math.trunc(value)).toString(radix);\n\n if (base === \"bin\") return `= ${sign}0b${digits(2)}`;\n if (base === \"oct\") return `= ${sign}0o${digits(8)}`;\n const padding = settings.hexResult.enablePadding ? settings.hexResult.paddingZeros : 0;\n const hex = digits(16).toUpperCase().padStart(padding, \"0\");\n return `= ${sign}0x${hex}`;\n}\n\n/**\n * How many decimal digits of an exact integer this will render in full.\n *\n * A little above the ~19,729 digits of the largest bigint the VM will build\n * (`vm/VM.ts`'s MAX_EXACT_POW_BITS / MAX_EXACT_SHIFT_BITS, 65,536 bits), so\n * every value the engine can produce through `^` or `<<` still prints exactly\n * and this ceiling only ever meets a value that came from somewhere else.\n */\nconst MAX_DISPLAYED_BIGINT_DIGITS = 20000;\n\n/**\n * Renders an exact integer, or describes it when writing it out is itself the\n * expensive operation.\n *\n * This used to be a bare `= ${value}` template, which renders whatever it is\n * handed: `1n << 100000000` took 8.5 seconds here turning a 12.5MB integer\n * into a thirty-million-character string, and a host has no way to opt out,\n * since displaying the answer is what it asked the engine for. The VM's own\n * ceiling on `<<` and `^` now stops that value existing, so this is the\n * backstop for every other way a large bigint can arrive (repeated `x * x`,\n * a Value a host built itself), and it costs one comparison for every value\n * that is not absurd.\n *\n * The digit count is estimated from the bit length rather than measured, since\n * measuring means doing the conversion this exists to avoid. Bit length comes\n * off the hexadecimal form, which is linear in the size of the value where the\n * decimal form is not.\n */\nfunction formatBigInt(value: bigint): string {\n const magnitude = value < 0n ? -value : value;\n // Every bigint a person actually reads takes this line and nothing else:\n // anything a double can hold is at most 309 digits, so it is printable\n // without measuring it at all.\n if (Number.isFinite(Number(magnitude))) return `= ${value}`;\n const bits = magnitude.toString(16).length * 4;\n if (bits * Math.LN2 / Math.LN10 <= MAX_DISPLAYED_BIGINT_DIGITS) return `= ${value}`;\n const log10 = bits * Math.LN2 / Math.LN10;\n const exponent = Math.floor(log10);\n const mantissa = Math.pow(10, log10 - exponent);\n const sign = value < 0n ? \"-\" : \"\";\n return `= ${sign}~${mantissa.toFixed(3)}e+${exponent} (an exact integer of about ${(exponent + 1).toLocaleString(\"en-US\")} digits, too large to print)`;\n}\n\nfunction formatString(value: string): string {\n return `= ${value}`;\n}\n\nfunction formatBoolean(value: boolean): string {\n return `= ${value}`;\n}\n\n/**\n * Renders a Datetime value locale-aware, the previous implementation\n * called `d.toLocaleString()` with no arguments, which always uses the JS\n * runtime's own default locale and never actually consulted `locale.code`\n * despite receiving it as a parameter (both branches of its old\n * `dateFormat === \"default\"` check were byte-for-byte identical, dead\n * groundwork for a distinction that was never implemented). Concretely,\n * this meant every configured locale (including the shipped German one)\n * always displayed weekday/month names in English. See GitHub issue #77.\n *\n * Uses `weekday`/`month`: \"long\" for a spelled-out date (\"Monday,\n * November 17, 2025\" / \"lundi 17 novembre 2025\") since that's what a\n * literal weekday name is for; a bare numeric date doesn't need\n * localizing beyond the decimal/thousands separators `formatNumber()`\n * already handles. The time-of-day portion is only appended when it's\n * not exactly local midnight, bare date literals (\"today\", \"17/11/2025\")\n * always anchor to local midnight, and showing \"00:00:00\" on every one of\n * those would be noise, not information.\n */\nfunction formatDatetime(value: number, locale: ILocale, settings: FormattingSettings): string {\n const d = new Date(value);\n const format = settings.dateResult?.format ?? \"long\";\n const isMidnight = d.getHours() === 0 && d.getMinutes() === 0 && d.getSeconds() === 0 && d.getMilliseconds() === 0;\n\n // The spelled-out default, localised through the locale's own names.\n if (format === \"long\") {\n const dateStr = d.toLocaleDateString(locale.code, { weekday: \"long\", year: \"numeric\", month: \"long\", day: \"numeric\" });\n if (isMidnight) return `= ${dateStr}`;\n return `= ${dateStr}, ${d.toLocaleTimeString(locale.code)}`;\n }\n\n // The numeric forms, built from the local calendar fields so they read the\n // same regardless of the JS runtime's own default locale.\n const p2 = (n: number) => String(n).padStart(2, \"0\");\n const year = d.getFullYear();\n const month = p2(d.getMonth() + 1);\n const day = p2(d.getDate());\n let datePart: string;\n if (format === \"iso\") datePart = `${year}-${month}-${day}`;\n else if (format === \"dmy\") datePart = `${day}/${month}/${year}`;\n else datePart = `${month}/${day}/${year}`; // mdy\n\n if (isMidnight) return `= ${datePart}`;\n const time = `${p2(d.getHours())}:${p2(d.getMinutes())}:${p2(d.getSeconds())}`;\n // ISO joins date and time with `T`; the slash forms with a space.\n return format === \"iso\" ? `= ${datePart}T${time}` : `= ${datePart} ${time}`;\n}\n\n/**\n * Renders a millisecond duration as clock-style `H:MM` (or `H:MM:SS` when\n * there's a non-zero seconds component). `ms` is never a user-typeable\n * unit (confirmed: it appears nowhere in `lexer/units.ts`), it's only\n * ever produced by subtracting two clock times/datetimes (`9:30 - 8:30`,\n * `VM.ts`'s Datetime SUB case), so this is a safe, narrow special case,\n * not a general change to how durations display.\n */\nfunction formatMsDuration(ms: number): string {\n const sign = ms < 0 ? \"-\" : \"\";\n const totalSeconds = Math.round(Math.abs(ms) / 1000);\n const hours = Math.floor(totalSeconds / 3600);\n const minutes = Math.floor((totalSeconds % 3600) / 60);\n const seconds = totalSeconds % 60;\n const mm = String(minutes).padStart(2, \"0\");\n if (seconds === 0) return `${sign}${hours}:${mm}`;\n const ss = String(seconds).padStart(2, \"0\");\n return `${sign}${hours}:${mm}:${ss}`;\n}\n\nfunction formatUom(value: number, unit: string | undefined, locale: ILocale, settings: FormattingSettings, exact?: DecimalData): string {\n if (unit === \"ms\") return `= ${formatMsDuration(value)}`;\n // A fuel-consumption unit is stored slash-free (so it is not read as a rate)\n // but shown the way it is written.\n if (unit === \"l100km\") unit = \"l/100km\";\n if (unit === \"mps2\") unit = \"m/s²\";\n\n const dp = settings.unitOfMeasurementResult.decimalPlaces;\n\n // For TimeSpan values (days, weeks, hours, etc.), format as integer if the value is a whole number\n const timeSpanUnits = [\"days\", \"weeks\", \"months\", \"years\", \"hours\", \"minutes\", \"seconds\", \"day\", \"week\", \"month\", \"year\", \"hour\", \"minute\", \"second\"];\n const isTimeSpan = unit && timeSpanUnits.includes(unit);\n\n let formatted: string;\n if (isTimeSpan && value === Math.floor(value)) {\n // For whole number TimeSpan values, format as integer\n formatted = value.toString();\n } else {\n // For other values, use the configured decimal places\n formatted = value.toFixed(dp);\n }\n\n // Currency display: symbol + culturally-conventional placement (e.g.\n // \"$100.00\" prefix vs \"100.00 kr\" suffix) instead of the generic\n // \"amount CODE\" fallback below. See uom/CurrencyAliases.ts's\n // CURRENCY_DISPLAY table for the exact set covered and the reasoning\n // behind each placement choice. Any currency code NOT in that table\n // (most of the ~150 `CurrencyExchange.isCurrency()` recognizes) falls\n // through to the unchanged \"amount CODE\" format below.\n const currencyDisplay = unit ? CURRENCY_DISPLAY[unit.toUpperCase()] : undefined;\n if (currencyDisplay) {\n // An exact money amount rounds from its decimal, not from the double: a\n // half-cent like \"$1.005\" reads as \"$1.01\" here, where \"(1.005).toFixed(2)\"\n // answers \"1.00\" because the double it is handed already sits below the\n // value the user typed. Amounts with no exact decimal (a currency\n // conversion, whose rate is a double) keep the toFixed rendering above.\n const moneyText = exact ? decimalToFixed(exact, dp) : formatted;\n const sep = currencyDisplay.spaced ? \" \" : \"\";\n const withSymbol = currencyDisplay.position === \"prefix\"\n ? `${currencyDisplay.symbol}${sep}${moneyText}`\n : `${moneyText}${sep}${currencyDisplay.symbol}`;\n return `= ${withSymbol}`;\n }\n\n // The unit is written as the symbol the value carries. There used to be a\n // `unitOfMeasurementResult.unitNames` setting here whose two branches were\n // the same expression, so it never changed anything, and it was removed\n // rather than implemented: the engine has no unit-name data to render from.\n // The generated unit table maps a spelling to [measure, ratio] only, and\n // names cannot be recovered from it, because units that differ by an OFFSET\n // share a ratio, so \"20 C\" would come back as \"20 kelvins\". A real\n // implementation needs a hand-authored name per unit plus pluralization and\n // per-locale spelling (metre against meter), which is a feature rather than\n // the repair of a dead ternary.\n //\n // An exact currency with no symbol in the display table above (one of the\n // less common ISO codes) still rounds from its decimal here, so \"1.005 UYW\"\n // reads the same way \"$1.005\" does. Non-currency Uoms never carry an exact,\n // so this leaves \"1.50 kg\" exactly as it was.\n const genericText = exact ? decimalToFixed(exact, dp) : formatted;\n return `= ${genericText} ${unit || \"\"}`.trim();\n}\n\nfunction formatMatrixEntry(entry: MatrixEntry, settings: FormattingSettings): string {\n if (typeof entry === \"boolean\") return entry ? \"true\" : \"false\";\n if (typeof entry === \"object\" && entry !== null) return formatSymbolic(entry);\n const dp = settings.floatResult.decimalPlaces;\n const sep = settings.floatResult.enableSeperator;\n const loc = settings.numberResult.decimalSeparatorLocale;\n return autoFormatIntegerOrFloat(entry, dp, sep, loc);\n}\n\n/**\n * Renders a Matrix matching its own literal syntax: a single row (1xN,\n * including plain vectors) as `[a, b, c]`, a single column (Nx1) as\n * `[a; b; c]`, and a general shape as `[r0c0, r0c1; r1c0, r1c1]`, row-major\n * textual output read back out of the column-major storage\n * (`columnMajorToRowMajor()`), matching how `[1,2;3,4]` is written.\n */\nfunction formatMatrix(m: MatrixData, locale: ILocale, settings: FormattingSettings): string {\n const rowMajor = columnMajorToRowMajor(m);\n const rows: string[] = [];\n for (let r = 0; r < m.rows; r++) {\n const cells: string[] = [];\n for (let c = 0; c < m.cols; c++) {\n cells.push(formatMatrixEntry(rowMajor[r * m.cols + c], settings));\n }\n rows.push(cells.join(\", \"));\n }\n return `${locale.display.resultPrefix}[${rows.join(\"; \")}]`;\n}\n\n/**\n * Render a matrix as a multi-line, column-aligned block: one row per line (the\n * newline is where {@link formatValue}'s compact form writes `;`), each column\n * right-padded to its widest cell, and every row wrapped in `[ ... ]`. For\n * display where a grid reads better than a line, e.g. a docs notepad or a REPL:\n *\n * ```text\n * [ 1 2 ]\n * [ 30 4 ]\n * ```\n *\n * This is deliberately separate from {@link formatValue}, whose single-line\n * matrix form stays the stable, assertable text the API and the worker DTO use.\n * A 1xN row vector is one line; an Nx1 column vector is N lines.\n */\nexport function formatMatrixAligned(m: MatrixData, settings?: FormattingSettings): string {\n const us = settings || DEFAULT_FORMATTING_SETTINGS;\n const rowMajor = columnMajorToRowMajor(m);\n const cells: string[][] = [];\n for (let r = 0; r < m.rows; r++) {\n const row: string[] = [];\n for (let c = 0; c < m.cols; c++) {\n row.push(formatMatrixEntry(rowMajor[r * m.cols + c], us));\n }\n cells.push(row);\n }\n const colWidth: number[] = [];\n for (let c = 0; c < m.cols; c++) {\n let width = 0;\n for (let r = 0; r < m.rows; r++) width = Math.max(width, cells[r][c].length);\n colWidth.push(width);\n }\n return cells\n .map((row) => `[ ${row.map((cell, c) => cell.padStart(colWidth[c])).join(\" \")} ]`)\n .join(\"\\n\");\n}\n\nfunction formatRange(min: number, max: number, locale: ILocale): string {\n return `${locale.display.resultPrefix}${min}:${max}`;\n}\n\nfunction formatPercentage(value: number, locale: ILocale, settings: FormattingSettings): string {\n // ValueType.Percentage stores a fraction (0.25 for 25%). See Value.ts's\n // documented contract and the sole producer, VM.ts's TO_PERCENTAGE opcode\n // (`right/left - 1`, e.g. 0.25 for \"800 to 1000\"). Multiply by 100 before\n // formatting; without this every percentage-change result displayed as\n // e.g. \"0.25%\" instead of \"25.00%\".\n const dp = settings.percentageResult.decimalPlaces;\n const formatted = (value * 100).toFixed(dp);\n return `= ${formatted}${locale.display.percentageSuffix}`;\n}\n\nfunction formatUnit(value: number, unit: string | undefined): string {\n return `= ${value} ${unit || \"\"}`.trim();\n}\n\n/**\n * Renders a per-person bill split: \"= $45.00 each\", or, when the division is\n * uneven, \"= $33.33 each, with 1 share paying $33.34\". Each share's amount is\n * rendered through the ordinary value formatter (a throwaway {@link Value}), so\n * a currency share honours the same symbol placement, decimal places and locale\n * as any other money and a bare share trims trailing zeros the way a plain\n * number does; the \"= \" prefix is added once, around the whole sentence, not\n * per share.\n */\n/**\n * An IP/CIDR as text: the dotted quad, plus `/prefix` when present, or a bare\n * `/prefix` when there is no address (`netmask of /24` before it resolves).\n */\nfunction formatIpCidr(data: IpCidrData): string {\n\tif (data.addr === undefined) return `/${data.prefix}`;\n\tconst dotted = formatIp(data.addr);\n\treturn data.prefix === undefined ? dotted : `${dotted}/${data.prefix}`;\n}\n\nfunction formatSplit(data: SplitData, locale: ILocale, settings: FormattingSettings): string {\n const prefix = locale.display.resultPrefix;\n const render = (share: SplitShare): string => {\n const v = data.unit !== undefined\n ? new Value(ValueType.Uom, share.value, data.unit)\n : new Value(ValueType.Number, share.value);\n v.exact = share.exact;\n const text = formatValue(v, settings);\n return text.startsWith(prefix) ? text.slice(prefix.length) : text;\n };\n\n const [base, high] = data.shares;\n const each = `${render(base)} each`;\n if (high === undefined) return `${prefix}${each}`;\n const shareWord = high.count === 1 ? \"share\" : \"shares\";\n return `${prefix}${each}, with ${high.count} ${shareWord} paying ${render(high)}`;\n}\n\n/**\n * Render an evaluated {@link Value} as a display string, dispatching on\n * `value.type` to the type-specific formatter (number, hex, datetime, unit\n * of measurement, matrix, range, percentage, ...).\n *\n * Most branches produce a `\"= \"`-prefixed result string (matching the\n * plugin's inline-result convention); `ValueType.Error` is the one\n * exception, it returns the human-readable error message directly\n * (stored in `value.unit`), not an `\"= \"`-prefixed string.\n *\n * @param value - The evaluated value to format.\n * @param settings - Locale/precision/separator options; defaults to\n * {@link DEFAULT_FORMATTING_SETTINGS} when omitted.\n * @example\n * ```typescript\n * const value = engine.evaluateExpression(\"10 USD to GBP\");\n * formatValue(value); // \"= £7.85\" (exact output depends on live exchange rates)\n * ```\n */\nexport function formatValue(value: Value, settings?: FormattingSettings): string {\n const us = settings || DEFAULT_FORMATTING_SETTINGS;\n const localeCode = us.numberResult.decimalSeparatorLocale || \"en\";\n const locale = getLocale(localeCode);\n\n switch (value.type) {\n case ValueType.Number:\n // A measurement with a tolerance renders as \"center ± spread\"; every\n // other number is unchanged, so a plain value is byte-for-byte what it was.\n if (value.uncertainty !== undefined) {\n return formatUncertain(value.value as number, value.uncertainty, locale, us);\n }\n return formatNumber(value.value as number, locale, us, value.decimalPlaces);\n case ValueType.Hex:\n return formatHex(value.value as number | bigint, us, value.unit);\n case ValueType.BigInt:\n return formatBigInt(value.value as bigint);\n case ValueType.String:\n return formatString(value.value as string);\n case ValueType.Boolean:\n return formatBoolean(value.value as boolean);\n case ValueType.Datetime:\n return formatDatetime(value.value as number, locale, us);\n case ValueType.Uom:\n return formatUom(value.value as number, value.unit, locale, us, value.exact);\n case ValueType.Matrix:\n return formatMatrix(value.value as MatrixData, locale, us);\n case ValueType.Range: {\n const r = value.value as RangeData;\n return formatRange(r.min, r.max, locale);\n }\n case ValueType.Colour:\n return `${locale.display.resultPrefix}${formatColour(value.value as ColourData)}`;\n case ValueType.Split:\n return formatSplit(value.value as SplitData, locale, us);\n case ValueType.Chart:\n // A chart is drawn from its data by the host; the text answer is its label\n // (`sin(x) over [0, 6.28]`, or the series a sparkline came from).\n return `${locale.display.resultPrefix}${(value.value as ChartData).label}`;\n case ValueType.IpCidr:\n return `${locale.display.resultPrefix}${formatIpCidr(value.value as IpCidrData)}`;\n case ValueType.Symbolic:\n return formatSymbolic(value.value as SymbolicNode);\n case ValueType.Percentage:\n return formatPercentage(value.value as number, locale, us);\n case ValueType.Unit:\n return formatUnit(value.value as number, value.unit);\n case ValueType.Error:\n // errorValue(code, message) stores the human-readable message in\n // `.unit` (code goes in `.value`), falling through to the default\n // case here previously displayed the raw code (e.g.\n // \"CURRENCY_RATE_UNAVAILABLE\") instead of the actual message.\n return value.unit ?? String(value.value);\n default:\n return `= ${String(value.value)}`;\n }\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {c as c$2}from'./chunk-JP4JMQOG.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-WOIJPV7Z.js';import {c as c$5}from'./chunk-GWJJRH32.js';import {b}from'./chunk-TZYMXNIB.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-JOIQFDZQ.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-O3ALJLYC.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-YAZ4DUJJ.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 h=this.consumers.get(g);h&&h.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 h=this.consumers.get(g);h&&h.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 h of g){if(s.has(h))continue;s.add(h);let d=this.writes.get(h);if(d)for(let y of d)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 h=[];for(let[y,x]of u)x===0&&h.push(y);if(h.length===0&&s.size>0){let y=Array.from(s).sort((x,A)=>x-A);h.push(y[0]);}let d=[];for(;h.length>0;){let y=h.shift();d.push(y);for(let x of l.get(y)??[]){let A=(u.get(x)??1)-1;u.set(x,A),A===0&&h.push(x);}}if(d.length<s.size){let y=new Set(d),x=Array.from(s).filter(A=>!y.has(A)).sort((A,C)=>A-C);d.push(...x);}return d}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[h,d]of this.consumers)a[h]=Array.from(d);let s={};for(let[h,d]of this.writes)s[h]=Array.from(d);let u={};for(let[h,d]of this.lineReads)u[h]=Array.from(d);let l={};for(let[h,d]of this.dataSourceDependencies)l[h]=Array.from(d);let g={};for(let[h,d]of this.dataSourceConsumers)g[h]=Array.from(d);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,h)=>g.line-h.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])],h=en[tn(g)];if(h===void 0)return null;let d=r.toNumber()*u$1.si,y=a.toNumber()*l.si,x=s?d*y:d/y;return u(x/je[h].si,h)}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,h=new Date(r),d=0;for(;l>0;){if(h.setDate(h.getDate()+g),d++,d>u)return null;Vt(h.getTime(),s)&&l--;}return h.getTime()}function Lt(r,a,s,u){let l=Rt(Math.min(r,a)),g=Rt(Math.max(r,a)),h=Math.round((g-l)/864e5);if(h>u)return null;let d=0,y=new Date(l);for(let x=0;x<=h;x++)Vt(y.getTime(),s)&&d++,y.setDate(y.getDate()+1);return d}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 Ft(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,h=1e4,d=100,y$1=-100,x=y,A){let C=[],E=new Map,F=0,j,$,n$1=[],Q=new Map,X=new Map,K=new Map;return {push(f){C.length<a&&C.push(f);},getMaxStackDepth(){return a},getMaxCollectionSize(){return l},getMaxAllocatedElements(){return g},getMaxFunctionCalls(){return h},getMaxDateOffsetYears(){return d},getMinDateOffsetYears(){return y$1},isHoliday(f){return A?A(f):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(f){if(n$1.length>0){let e=n$1[n$1.length-1].get(f);if(e!==void 0)return e}return E.get(f)},setVar(f,e){E.set(f,e);},deleteVar(f){E.delete(f);},pushCallFrame(f){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(f);},popCallFrame(){n$1.pop();},getCallFrame(){return n$1.length>0?n$1[n$1.length-1]:void 0},defineUserFunction(f,e,t){Q.set(f,{name:f,params:e,program:t});},getUserFunction(f){return Q.get(f)},hasUserFunction(f){return Q.has(f)},getVariableEntries(){return Array.from(E.entries())},getUserFunctionDefs(){return Array.from(Q.values())},defineEquation(f,e,t){X.set(f,{variable:f,factorNames:e,rhsProgram:t});},getEquation(f){return X.get(f)},hasEquation(f){return X.has(f)},defineScalarEquation(f,e,t){K.set(f,{variable:f,lhsProgram:e,rhsProgram:t});},getScalarEquation(f){return K.get(f)},hasScalarEquation(f){return K.has(f)},reset(){C.length=0,E.clear(),n$1.length=0,Q.clear(),X.clear(),K.clear(),F=0,$&&($(),$=void 0),j=void 0;},get activeSignal(){return j},set activeSignal(f){j=f;},get abortCurrent(){return $},set abortCurrent(f){$=f;},context:x,getMaxInstructions(){return s},getInstructionCount(){return F},incrementInstructions(f){if(F+=f,F>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 h=un(a);return c$1.validation({code:r,message:`Malformed bytecode: ${h} ${s}`,expected:u,found:l,suggestion:Jt,context:typeof a=="number"?{opcode:a,opcodeName:h,...g}:{site:h,...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 h=O(r,a,s,u);if(h>=l)throw oe("MALFORMED_BYTECODE_CONSTANT_INDEX",s,`reads ${g} entry ${h}, which does not exist`,`an index below ${l}`,`${h}`,{index:h,poolSize:l,pool:g});return h}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,h,d){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,h,d);}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,h){let d=new Map(s.getCallFrame());d.set(r,K(q$1(r))),s.pushCallFrame(d);let y;try{y=tt(a,s,u,l,g,h);}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 h=a$3[s.slice(l+1).toLowerCase()],d=a$3[u.slice(g+1).toLowerCase()];return h===void 0||d===void 0||h[0]!==d[0]?null:r.toNumber()*(d[1]/h[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 Gt(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 fn(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 dn(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 Xt=260;function Qt(r,a,s){let u=Math.trunc(Math.abs(a)),g=(a>=0?1:-1)>0?s.getMaxDateOffsetYears():-s.getMinDateOffsetYears(),h=Math.floor(g*Xt);if(u>h)throw c$1.execution("DATE_OFFSET_LIMIT_EXCEEDED",`A date offset of ${u.toLocaleString("en-US")} workdays is about ${Math.round(u/Xt).toLocaleString("en-US")} years, past the limit of ${g} years for a workday offset`,{requestedWorkdays:u,limitYears:g,limitWorkdays:h});let d=h*7+7,y=Bt(r,a,x=>s.isHoliday(x),d);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:d});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(),h=e$1(1,"month","ms");return Number.isNaN(g)?r+a*h:g+(a-s)*h}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 h=hn[l];if(h!==void 0)return yn(r,g*h);if(c$4(l)==="time"){let d=0;try{d=e$1(1,l,"day");}catch{}if(Number.isInteger(d)&&d>=1)return Zt(r,g*d)}}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 h=e$1(a.toNumber(),a.unit,u$1),d=r.toNumber()*h;return s?u(d,s):n(d)}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,h=1,d=1,y=0,x=l,A=1e6;for(let E=0;E<30;E++){let F=Math.floor(x+1e-9),j=F*h+g,$=F*y+d;if($>A||(g=h,h=j,d=y,y=$,Math.abs(l-h/y)<1e-9))break;let n=x-F;if(n<1e-9)break;x=1/n;}let C=u*y+h;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 h$2=ln(r$3);if(h$2)return {type:"error",error:c$1.validation({code:"MALFORMED_BYTECODE_PROGRAM",message:`Malformed bytecode: ${h$2}`,expected:"a BytecodeProgram with opcodes, numbers and strings",found:h$2,suggestion:Jt})};let{opcodes:d$2,numbers:y,strings:x$1,userFunctionBodies:A$1,anonymousBodies:C$2}=r$3,E=0,F$1=0,j$3=a$2.getMaxInstructions(),$$1=a$2.getMaxStackDepth(),n$2=a$2.getStack(),Q$1=s$2?.hasCollectors??false,X$1=j();if(d$2.length===0)return {type:"value",value:n(0)};a(a$2);try{for(;E<d$2.length;){if(++F$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 f$3=d$2[E++];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:f$3,opcodeName:b(f$3),ip:E-1,stackDepth:n$2.length,instructionNumber:F$1,stack:e});}switch(f$3){case 0:break;case 1:{let e=c(n$2);return {type:"value",value:X$1?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(d$2,E++,f$3,"constant-pool index",y.length,"number-pool")]));break;case 11:n$2.push(s(mn(J(d$2,E++,x$1,f$3,"constant-pool index"),f$3)));break;case 16:{let e=ia(J(d$2,E++,x$1,f$3,"constant-pool index"));n$2.push(o(ra(e),e));break}case 12:n$2.push(r$1(y[Je(d$2,E++,f$3,"constant-pool index",y.length,"number-pool")]));break;case 13:n$2.push(t(J(d$2,E++,x$1,f$3,"constant-pool index")));break;case 14:n$2.push(L(O(d$2,E++,f$3,"boolean operand")===1));break;case 20:{let e=c(n$2),t$1=c(n$2),o=Q(t$1,e);if(o){n$2.push(o);break}if(t$1.uncertainty!==void 0||e.uncertainty!==void 0){let p=s$1(t$1,e,"add");if(p){n$2.push(p);break}}if(t$1.rational!==void 0||e.rational!==void 0){let p=r$2(t$1,e,"add");if(p){n$2.push(p);break}}let i=Gt(t$1,e,1),m=i===null?Yt(t$1,e):null;i!==null?n$2.push(i):m!==null?n$2.push(u(m+e.toNumber(),e.unit)):t$1.type===0&&e.type===0?n$2.push(n(t$1.value+e.value)):t$1.type===10&&e.type===10?n$2.push(L(t$1.value&&e.value)):t$1.type===4?e.type===4?n$2.push(P("INVALID_DATETIME_OP","Cannot add two datetimes together")):n$2.push(M(he(t$1.toNumber(),e,1,a$2))):t$1.type===6&&A(t$1.unit)?n$2.push(Ht(t$1,e,1)):e.type===4?n$2.push(M(he(e.toNumber(),t$1,1,a$2))):t$1.type===3&&e.type===3?n$2.push(t(t$1.value+e.value)):n$2.push(u$1(t$1,e,(p,b)=>p+b,(p,b)=>p+b,"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=Gt(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,b)=>p-b,(p,b)=>p-b,"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=fn(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,b)=>p*b,(p,b)=>p*b,"mul"));}break}case 23:{let e=c(n$2),t=c(n$2),o=dn(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 b=ze(t,e,!1);if(b){n$2.push(b);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:b}=k$1(t,e);n$2.push(b?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:b}=k$1(t,e);n$2.push(b?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:b}=k$1(t,e);n$2.push(b?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:b}=k$1(t,e);n$2.push(b?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:case 161:{let e;if(f$3===161){let p=O(d$2,E++,f$3,"plugin-function index (low byte)"),b=O(d$2,E++,f$3,"plugin-function index (high byte)");e=p|b<<8;}else e=O(d$2,E++,f$3,"plugin-function index");let t=O(d$2,E++,f$3,"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 b=`plugin:${e}:${o.map(B=>String(B.value??"")).join("|")}`,I=a$2.activeSignal,U=a$2.context.pluginFunctionOwners[e]??"";return {type:"pending",queryKey:b,resolver:p,packageId:U,signal:I}}n$2.push(p);}break}case 51:{let e=O(d$2,E++,f$3,"builtin-function index"),t=O(d$2,E++,f$3,"argument count"),o=Ft(e,t);if(o)throw o;let i=[],m=!1;for(let I=0;I<t;I++){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 b=C[e];if(b){let I=i.reverse(),U=m&&!e$2.has(e);n$2.push(U?h$1(e,I):b(I));}break}case 150:{let e=O(d$2,E++,f$3,"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(d$2,E++,x$1,f$3,"function-name index"),t=O(d$2,E++,f$3,"argument count"),o=[];for(let b=0;b<t;b++)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 b=0;b<i.params.length;b++)m.set(i.params[b],o[b]);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(d$2,E++,x$1,f$3,"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(d$2,E++,x$1,f$3,"variable-name index");a$2.setVar(t,X$1?k(e):e),n$2.push(e);break}case 62:{let e=J(d$2,E++,x$1,f$3,"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(d$2,E++,x$1,f$3,"variable-name index");J$1.set(t,X$1?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),f$3,"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),f$3,"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),f$3,"target unit name"),t=q(c(n$2),f$3,"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),b=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(b){let I=c$5.convertSync(m,t,e);I!==null?n$2.push(u(I,e)):n$2.push(P("CURRENCY_RATE_UNAVAILABLE",`No exchange rate available for ${t} to ${e}`));}else {let I=i(m,t,e);I!==null?n$2.push(u(I,e)):n$2.push(qt(t,e));}break}case 85:{let e=q(c(n$2),f$3,"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),f$3,"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),f$3,"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),b=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(b){let I=c$5.convertSync(m,i$1,e);I!==null?n$2.push(u(I,e)):n$2.push(P("CURRENCY_RATE_UNAVAILABLE",`No exchange rate available for ${i$1} to ${e}`));}else {let I=i(m,i$1,e);I!==null?n$2.push(u(I,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),f$3,"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),b=c$4(e);if(!p||p!==b){n$2.push(P("RATE_CONVERT_MEASURE_MISMATCH",`Cannot convert a "${m}"-denominated rate to "${e}" \u2014 different measures`));break}let I=e$1(1,e,m);n$2.push(w(t.toNumber()*I,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(d$2,E++,f$3,"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(d$2,E++,f$3,"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=Lt(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(),b=f$3===93?(i-p+7)%7:(p-i+7)%7;b===0&&(b=7),n$2.push(M(Zt(m,f$3===93?b:-b)));break}case 152:{let e$1=O(d$2,E++,f$3,"row count"),t=O(d$2,E++,f$3,"column count"),o=e$1*t,i=e(o,"matrix cells"),m=null;for(let p=o-1;p>=0;p--){let b=c(n$2);m===null&&(m=Q(b)),i[p]=b.type===10||b.type===9?b.value:b.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()),b=Math.trunc(e.toNumber());if(!U(m,p,b)){n$2.push(P("MATRIX_INDEX_OUT_OF_BOUNDS",`[${p}, ${b}] is out of bounds for a ${m.rows}x${m.cols} matrix.`));break}let I=T(m,p,b);n$2.push(X(I));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,b=e$1.value;if(p.min<0||p.max>=m.rows||b.min<0||b.max>=m.cols){n$2.push(P("MATRIX_INDEX_OUT_OF_BOUNDS",`Slice [${p.min}:${p.max}, ${b.min}:${b.max}] is out of bounds for a ${m.rows}x${m.cols} matrix.`));break}let I=p.max-p.min+1,U=b.max-b.min+1,B=e(I*U,"matrix cells");for(let V=0;V<I;V++)for(let _=0;_<U;_++)B[V+_*I]=T(m,p.min+V,b.min+_);n$2.push(C$1(I,U,B));break}case 157:{let e$1=O(d$2,E++,f$3,"body kind"),t=O(d$2,E++,f$3,"body reference"),o=O(d$2,E++,f$3,"collection count");$t(e$1,t,f$3);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,f$3),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 b=-1,I=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"),b===-1)b=v.length;else if(v.length!==b){U=P("MAP_COLLECTION_LENGTH_MISMATCH",`map: all collections must have the same length (got ${b} and ${v.length}).`);break}I[k]=v;}if(U){n$2.push(U);break}let B=e(b,"matrix cells"),V;for(let k=0;k<b;k++){let v=new Array(o);for(let ye=0;ye<o;ye++)v[ye]=I[ye][k];let re=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(re);if(nt){V=nt;break}B[k]=re.type===10||re.type===9?re.value:re.toNumber();}if(V){n$2.push(V);break}let _=i[0],R=_?.type===7?_.value:void 0;R&&R.rows*R.cols===b?n$2.push(C$1(R.rows,R.cols,B)):n$2.push(C$1(1,b,B));break}case 160:{let e=O(d$2,E++,f$3,"plot body reference"),t=O(d$2,E++,f$3,"plot expression"),o=Se(x$1,t,f$3),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 b=[];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)&&b.push([R,k]);}let I$1=b.map(_=>_[1]),U=I$1.length?Math.min(...I$1):0,B=I$1.length?Math.max(...I$1):0,V=_=>Number.isInteger(_)?String(_):String(Number(_.toFixed(2)));n$2.push(I({kind:"plot",points:b,label:`${o} over [${V(m)}, ${V(i)}]`,domain:[m,i],range:[U,B],expr:o}));break}case 158:{let e=O(d$2,E++,f$3,"body kind"),t=O(d$2,E++,f$3,"body reference"),o=O(d$2,E++,f$3,"initial-value flag");$t(e,t,f$3);let i=o?c(n$2):void 0,m=c(n$2),p=[],b;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,b=_.program;}else if(e===2){let _=Se(x$1,t,f$3),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,b=R.program;}let I=ea(m,a$2.getMaxCollectionSize());if(!Array.isArray(I)){n$2.push(I);break}c$3(I.length,"collection elements");let U,B;if(i!==void 0){let _=Q(i);if(_){n$2.push(_);break}U=i,B=0;}else {if(I.length===0){n$2.push(P("REDUCE_EMPTY_COLLECTION","reduce: cannot reduce an empty collection without an initial value."));break}U=I[0],B=1;}let V;for(let _=B;_<I.length;_++){let R=[U,I[_]],k=e===1?C[t]?.(R)??P("UNKNOWN_BUILTIN_FUNCTION",`reduce: unknown builtin function index ${t}`):Qe(p,b,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(d$2,E++,f$3,"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:X$1?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-P4ETODMP.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {c as c$2}from'./chunk-JP4JMQOG.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-SEOIKHYK.js';import {c as c$5}from'./chunk-EQDT42JG.js';import {b}from'./chunk-TZYMXNIB.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-KEA5HRL3.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-3GR46UOX.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-PIZQIQVM.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 h=this.consumers.get(g);h&&h.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 h=this.consumers.get(g);h&&h.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 h of g){if(s.has(h))continue;s.add(h);let d=this.writes.get(h);if(d)for(let y of d)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 h=[];for(let[y,x]of u)x===0&&h.push(y);if(h.length===0&&s.size>0){let y=Array.from(s).sort((x,A)=>x-A);h.push(y[0]);}let d=[];for(;h.length>0;){let y=h.shift();d.push(y);for(let x of l.get(y)??[]){let A=(u.get(x)??1)-1;u.set(x,A),A===0&&h.push(x);}}if(d.length<s.size){let y=new Set(d),x=Array.from(s).filter(A=>!y.has(A)).sort((A,C)=>A-C);d.push(...x);}return d}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[h,d]of this.consumers)a[h]=Array.from(d);let s={};for(let[h,d]of this.writes)s[h]=Array.from(d);let u={};for(let[h,d]of this.lineReads)u[h]=Array.from(d);let l={};for(let[h,d]of this.dataSourceDependencies)l[h]=Array.from(d);let g={};for(let[h,d]of this.dataSourceConsumers)g[h]=Array.from(d);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,h)=>g.line-h.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])],h=en[tn(g)];if(h===void 0)return null;let d=r.toNumber()*u$1.si,y=a.toNumber()*l.si,x=s?d*y:d/y;return u(x/je[h].si,h)}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,h=new Date(r),d=0;for(;l>0;){if(h.setDate(h.getDate()+g),d++,d>u)return null;Vt(h.getTime(),s)&&l--;}return h.getTime()}function Lt(r,a,s,u){let l=Rt(Math.min(r,a)),g=Rt(Math.max(r,a)),h=Math.round((g-l)/864e5);if(h>u)return null;let d=0,y=new Date(l);for(let x=0;x<=h;x++)Vt(y.getTime(),s)&&d++,y.setDate(y.getDate()+1);return d}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 Ft(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,h=1e4,d=100,y$1=-100,x=y,A){let C=[],E=new Map,F=0,j,$,n$1=[],Q=new Map,X=new Map,K=new Map;return {push(f){C.length<a&&C.push(f);},getMaxStackDepth(){return a},getMaxCollectionSize(){return l},getMaxAllocatedElements(){return g},getMaxFunctionCalls(){return h},getMaxDateOffsetYears(){return d},getMinDateOffsetYears(){return y$1},isHoliday(f){return A?A(f):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(f){if(n$1.length>0){let e=n$1[n$1.length-1].get(f);if(e!==void 0)return e}return E.get(f)},setVar(f,e){E.set(f,e);},deleteVar(f){E.delete(f);},pushCallFrame(f){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(f);},popCallFrame(){n$1.pop();},getCallFrame(){return n$1.length>0?n$1[n$1.length-1]:void 0},defineUserFunction(f,e,t){Q.set(f,{name:f,params:e,program:t});},getUserFunction(f){return Q.get(f)},hasUserFunction(f){return Q.has(f)},getVariableEntries(){return Array.from(E.entries())},getUserFunctionDefs(){return Array.from(Q.values())},defineEquation(f,e,t){X.set(f,{variable:f,factorNames:e,rhsProgram:t});},getEquation(f){return X.get(f)},hasEquation(f){return X.has(f)},defineScalarEquation(f,e,t){K.set(f,{variable:f,lhsProgram:e,rhsProgram:t});},getScalarEquation(f){return K.get(f)},hasScalarEquation(f){return K.has(f)},reset(){C.length=0,E.clear(),n$1.length=0,Q.clear(),X.clear(),K.clear(),F=0,$&&($(),$=void 0),j=void 0;},get activeSignal(){return j},set activeSignal(f){j=f;},get abortCurrent(){return $},set abortCurrent(f){$=f;},context:x,getMaxInstructions(){return s},getInstructionCount(){return F},incrementInstructions(f){if(F+=f,F>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 h=un(a);return c$1.validation({code:r,message:`Malformed bytecode: ${h} ${s}`,expected:u,found:l,suggestion:Jt,context:typeof a=="number"?{opcode:a,opcodeName:h,...g}:{site:h,...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 h=O(r,a,s,u);if(h>=l)throw oe("MALFORMED_BYTECODE_CONSTANT_INDEX",s,`reads ${g} entry ${h}, which does not exist`,`an index below ${l}`,`${h}`,{index:h,poolSize:l,pool:g});return h}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,h,d){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,h,d);}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,h){let d=new Map(s.getCallFrame());d.set(r,K(q$1(r))),s.pushCallFrame(d);let y;try{y=tt(a,s,u,l,g,h);}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 h=a$3[s.slice(l+1).toLowerCase()],d=a$3[u.slice(g+1).toLowerCase()];return h===void 0||d===void 0||h[0]!==d[0]?null:r.toNumber()*(d[1]/h[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 Gt(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 fn(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 dn(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 Xt=260;function Qt(r,a,s){let u=Math.trunc(Math.abs(a)),g=(a>=0?1:-1)>0?s.getMaxDateOffsetYears():-s.getMinDateOffsetYears(),h=Math.floor(g*Xt);if(u>h)throw c$1.execution("DATE_OFFSET_LIMIT_EXCEEDED",`A date offset of ${u.toLocaleString("en-US")} workdays is about ${Math.round(u/Xt).toLocaleString("en-US")} years, past the limit of ${g} years for a workday offset`,{requestedWorkdays:u,limitYears:g,limitWorkdays:h});let d=h*7+7,y=Bt(r,a,x=>s.isHoliday(x),d);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:d});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(),h=e$1(1,"month","ms");return Number.isNaN(g)?r+a*h:g+(a-s)*h}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 h=hn[l];if(h!==void 0)return yn(r,g*h);if(c$4(l)==="time"){let d=0;try{d=e$1(1,l,"day");}catch{}if(Number.isInteger(d)&&d>=1)return Zt(r,g*d)}}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 h=e$1(a.toNumber(),a.unit,u$1),d=r.toNumber()*h;return s?u(d,s):n(d)}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,h=1,d=1,y=0,x=l,A=1e6;for(let E=0;E<30;E++){let F=Math.floor(x+1e-9),j=F*h+g,$=F*y+d;if($>A||(g=h,h=j,d=y,y=$,Math.abs(l-h/y)<1e-9))break;let n=x-F;if(n<1e-9)break;x=1/n;}let C=u*y+h;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 h$2=ln(r$3);if(h$2)return {type:"error",error:c$1.validation({code:"MALFORMED_BYTECODE_PROGRAM",message:`Malformed bytecode: ${h$2}`,expected:"a BytecodeProgram with opcodes, numbers and strings",found:h$2,suggestion:Jt})};let{opcodes:d$2,numbers:y,strings:x$1,userFunctionBodies:A$1,anonymousBodies:C$2}=r$3,E=0,F$1=0,j$3=a$2.getMaxInstructions(),$$1=a$2.getMaxStackDepth(),n$2=a$2.getStack(),Q$1=s$2?.hasCollectors??false,X$1=j();if(d$2.length===0)return {type:"value",value:n(0)};a(a$2);try{for(;E<d$2.length;){if(++F$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 f$3=d$2[E++];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:f$3,opcodeName:b(f$3),ip:E-1,stackDepth:n$2.length,instructionNumber:F$1,stack:e});}switch(f$3){case 0:break;case 1:{let e=c(n$2);return {type:"value",value:X$1?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(d$2,E++,f$3,"constant-pool index",y.length,"number-pool")]));break;case 11:n$2.push(s(mn(J(d$2,E++,x$1,f$3,"constant-pool index"),f$3)));break;case 16:{let e=ia(J(d$2,E++,x$1,f$3,"constant-pool index"));n$2.push(o(ra(e),e));break}case 12:n$2.push(r$1(y[Je(d$2,E++,f$3,"constant-pool index",y.length,"number-pool")]));break;case 13:n$2.push(t(J(d$2,E++,x$1,f$3,"constant-pool index")));break;case 14:n$2.push(L(O(d$2,E++,f$3,"boolean operand")===1));break;case 20:{let e=c(n$2),t$1=c(n$2),o=Q(t$1,e);if(o){n$2.push(o);break}if(t$1.uncertainty!==void 0||e.uncertainty!==void 0){let p=s$1(t$1,e,"add");if(p){n$2.push(p);break}}if(t$1.rational!==void 0||e.rational!==void 0){let p=r$2(t$1,e,"add");if(p){n$2.push(p);break}}let i=Gt(t$1,e,1),m=i===null?Yt(t$1,e):null;i!==null?n$2.push(i):m!==null?n$2.push(u(m+e.toNumber(),e.unit)):t$1.type===0&&e.type===0?n$2.push(n(t$1.value+e.value)):t$1.type===10&&e.type===10?n$2.push(L(t$1.value&&e.value)):t$1.type===4?e.type===4?n$2.push(P("INVALID_DATETIME_OP","Cannot add two datetimes together")):n$2.push(M(he(t$1.toNumber(),e,1,a$2))):t$1.type===6&&A(t$1.unit)?n$2.push(Ht(t$1,e,1)):e.type===4?n$2.push(M(he(e.toNumber(),t$1,1,a$2))):t$1.type===3&&e.type===3?n$2.push(t(t$1.value+e.value)):n$2.push(u$1(t$1,e,(p,b)=>p+b,(p,b)=>p+b,"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=Gt(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,b)=>p-b,(p,b)=>p-b,"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=fn(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,b)=>p*b,(p,b)=>p*b,"mul"));}break}case 23:{let e=c(n$2),t=c(n$2),o=dn(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 b=ze(t,e,!1);if(b){n$2.push(b);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:b}=k$1(t,e);n$2.push(b?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:b}=k$1(t,e);n$2.push(b?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:b}=k$1(t,e);n$2.push(b?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:b}=k$1(t,e);n$2.push(b?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:case 161:{let e;if(f$3===161){let p=O(d$2,E++,f$3,"plugin-function index (low byte)"),b=O(d$2,E++,f$3,"plugin-function index (high byte)");e=p|b<<8;}else e=O(d$2,E++,f$3,"plugin-function index");let t=O(d$2,E++,f$3,"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 b=`plugin:${e}:${o.map(B=>String(B.value??"")).join("|")}`,I=a$2.activeSignal,U=a$2.context.pluginFunctionOwners[e]??"";return {type:"pending",queryKey:b,resolver:p,packageId:U,signal:I}}n$2.push(p);}break}case 51:{let e=O(d$2,E++,f$3,"builtin-function index"),t=O(d$2,E++,f$3,"argument count"),o=Ft(e,t);if(o)throw o;let i=[],m=!1;for(let I=0;I<t;I++){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 b=C[e];if(b){let I=i.reverse(),U=m&&!e$2.has(e);n$2.push(U?h$1(e,I):b(I));}break}case 150:{let e=O(d$2,E++,f$3,"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(d$2,E++,x$1,f$3,"function-name index"),t=O(d$2,E++,f$3,"argument count"),o=[];for(let b=0;b<t;b++)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 b=0;b<i.params.length;b++)m.set(i.params[b],o[b]);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(d$2,E++,x$1,f$3,"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(d$2,E++,x$1,f$3,"variable-name index");a$2.setVar(t,X$1?k(e):e),n$2.push(e);break}case 62:{let e=J(d$2,E++,x$1,f$3,"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(d$2,E++,x$1,f$3,"variable-name index");J$1.set(t,X$1?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),f$3,"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),f$3,"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),f$3,"target unit name"),t=q(c(n$2),f$3,"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),b=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(b){let I=c$5.convertSync(m,t,e);I!==null?n$2.push(u(I,e)):n$2.push(P("CURRENCY_RATE_UNAVAILABLE",`No exchange rate available for ${t} to ${e}`));}else {let I=i(m,t,e);I!==null?n$2.push(u(I,e)):n$2.push(qt(t,e));}break}case 85:{let e=q(c(n$2),f$3,"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),f$3,"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),f$3,"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),b=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(b){let I=c$5.convertSync(m,i$1,e);I!==null?n$2.push(u(I,e)):n$2.push(P("CURRENCY_RATE_UNAVAILABLE",`No exchange rate available for ${i$1} to ${e}`));}else {let I=i(m,i$1,e);I!==null?n$2.push(u(I,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),f$3,"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),b=c$4(e);if(!p||p!==b){n$2.push(P("RATE_CONVERT_MEASURE_MISMATCH",`Cannot convert a "${m}"-denominated rate to "${e}" \u2014 different measures`));break}let I=e$1(1,e,m);n$2.push(w(t.toNumber()*I,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(d$2,E++,f$3,"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(d$2,E++,f$3,"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=Lt(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(),b=f$3===93?(i-p+7)%7:(p-i+7)%7;b===0&&(b=7),n$2.push(M(Zt(m,f$3===93?b:-b)));break}case 152:{let e$1=O(d$2,E++,f$3,"row count"),t=O(d$2,E++,f$3,"column count"),o=e$1*t,i=e(o,"matrix cells"),m=null;for(let p=o-1;p>=0;p--){let b=c(n$2);m===null&&(m=Q(b)),i[p]=b.type===10||b.type===9?b.value:b.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()),b=Math.trunc(e.toNumber());if(!U(m,p,b)){n$2.push(P("MATRIX_INDEX_OUT_OF_BOUNDS",`[${p}, ${b}] is out of bounds for a ${m.rows}x${m.cols} matrix.`));break}let I=T(m,p,b);n$2.push(X(I));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,b=e$1.value;if(p.min<0||p.max>=m.rows||b.min<0||b.max>=m.cols){n$2.push(P("MATRIX_INDEX_OUT_OF_BOUNDS",`Slice [${p.min}:${p.max}, ${b.min}:${b.max}] is out of bounds for a ${m.rows}x${m.cols} matrix.`));break}let I=p.max-p.min+1,U=b.max-b.min+1,B=e(I*U,"matrix cells");for(let V=0;V<I;V++)for(let _=0;_<U;_++)B[V+_*I]=T(m,p.min+V,b.min+_);n$2.push(C$1(I,U,B));break}case 157:{let e$1=O(d$2,E++,f$3,"body kind"),t=O(d$2,E++,f$3,"body reference"),o=O(d$2,E++,f$3,"collection count");$t(e$1,t,f$3);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,f$3),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 b=-1,I=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"),b===-1)b=v.length;else if(v.length!==b){U=P("MAP_COLLECTION_LENGTH_MISMATCH",`map: all collections must have the same length (got ${b} and ${v.length}).`);break}I[k]=v;}if(U){n$2.push(U);break}let B=e(b,"matrix cells"),V;for(let k=0;k<b;k++){let v=new Array(o);for(let ye=0;ye<o;ye++)v[ye]=I[ye][k];let re=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(re);if(nt){V=nt;break}B[k]=re.type===10||re.type===9?re.value:re.toNumber();}if(V){n$2.push(V);break}let _=i[0],R=_?.type===7?_.value:void 0;R&&R.rows*R.cols===b?n$2.push(C$1(R.rows,R.cols,B)):n$2.push(C$1(1,b,B));break}case 160:{let e=O(d$2,E++,f$3,"plot body reference"),t=O(d$2,E++,f$3,"plot expression"),o=Se(x$1,t,f$3),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 b=[];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)&&b.push([R,k]);}let I$1=b.map(_=>_[1]),U=I$1.length?Math.min(...I$1):0,B=I$1.length?Math.max(...I$1):0,V=_=>Number.isInteger(_)?String(_):String(Number(_.toFixed(2)));n$2.push(I({kind:"plot",points:b,label:`${o} over [${V(m)}, ${V(i)}]`,domain:[m,i],range:[U,B],expr:o}));break}case 158:{let e=O(d$2,E++,f$3,"body kind"),t=O(d$2,E++,f$3,"body reference"),o=O(d$2,E++,f$3,"initial-value flag");$t(e,t,f$3);let i=o?c(n$2):void 0,m=c(n$2),p=[],b;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,b=_.program;}else if(e===2){let _=Se(x$1,t,f$3),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,b=R.program;}let I=ea(m,a$2.getMaxCollectionSize());if(!Array.isArray(I)){n$2.push(I);break}c$3(I.length,"collection elements");let U,B;if(i!==void 0){let _=Q(i);if(_){n$2.push(_);break}U=i,B=0;}else {if(I.length===0){n$2.push(P("REDUCE_EMPTY_COLLECTION","reduce: cannot reduce an empty collection without an initial value."));break}U=I[0],B=1;}let V;for(let _=B;_<I.length;_++){let R=[U,I[_]],k=e===1?C[t]?.(R)??P("UNKNOWN_BUILTIN_FUNCTION",`reduce: unknown builtin function index ${t}`):Qe(p,b,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(d$2,E++,f$3,"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:X$1?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-RLTH2H3U.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-RLTH2H3U.js.map
|