solve-engine 2.32.0 → 2.34.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/{EngineError-CqGtaT_v.d.cts → EngineError-Bm4OYmw8.d.cts} +6 -0
- package/dist/{EngineError-CqGtaT_v.d.ts → EngineError-Bm4OYmw8.d.ts} +6 -0
- package/dist/{Lexer-CqFjYoRA.d.ts → Lexer-DPn5dfCH.d.ts} +1 -13
- package/dist/{Lexer-sCI05tqO.d.cts → Lexer-DaWkCu84.d.cts} +1 -13
- package/dist/{PackageCompatibility-phvSFP4f.d.ts → PackageCompatibility-CkzZfoJ3.d.ts} +1 -1
- package/dist/{PackageCompatibility-Bn-T_xKW.d.cts → PackageCompatibility-E_5GtcQW.d.cts} +1 -1
- package/dist/{PackageRegistry-C78jVkI9.d.ts → PackageRegistry-DSqic8kz.d.ts} +132 -23
- package/dist/{PackageRegistry-B-C1duZw.d.cts → PackageRegistry-js47hr28.d.cts} +132 -23
- package/dist/{Parselet-Dgymjxzd.d.ts → Parselet-CQjcHOKw.d.ts} +13 -6
- package/dist/{Parselet-DF3864la.d.cts → Parselet-s1sRRn8H.d.cts} +13 -6
- package/dist/{TokenNormalizer-Pe3_390t.d.cts → TokenNormalizer-D382VSYh.d.cts} +4 -1
- package/dist/{TokenNormalizer-IF7nPRMp.d.ts → TokenNormalizer-DAzPp-j1.d.ts} +4 -1
- package/dist/{VMBuiltins-BkKzhj6C.d.cts → VMBuiltins-JCavlQUj.d.cts} +53 -18
- package/dist/{VMBuiltins-Du9y8sEo.d.ts → VMBuiltins-qgzA6qGi.d.ts} +53 -18
- package/dist/{VMCheckpoints-WdUQrdc9.d.cts → VMCheckpoints-BxPzmdu0.d.cts} +2 -2
- package/dist/{VMCheckpoints-gvy_yxYh.d.ts → VMCheckpoints-DjjE92mf.d.ts} +2 -2
- package/dist/{Value-BYHw-x7q.d.cts → Value-2TIKi-YL.d.cts} +19 -0
- package/dist/{Value-BYHw-x7q.d.ts → Value-2TIKi-YL.d.ts} +19 -0
- package/dist/{WorkerError-DTrl3Jag.d.ts → WorkerError-BaN8_eok.d.ts} +1 -1
- package/dist/{WorkerError-CRoM8Ju1.d.cts → WorkerError-CexHHmbb.d.cts} +1 -1
- package/dist/{chunk-IJE4AEDX.js → chunk-24OW3AAU.js} +3 -3
- package/dist/{chunk-IJE4AEDX.js.map → chunk-24OW3AAU.js.map} +1 -1
- package/dist/{chunk-CAJTDZ5B.cjs → chunk-2XOLAHW6.cjs} +2 -2
- package/dist/{chunk-CAJTDZ5B.cjs.map → chunk-2XOLAHW6.cjs.map} +1 -1
- package/dist/{chunk-AGCNMEP2.cjs → chunk-3MG7VIPL.cjs} +2 -2
- package/dist/{chunk-AGCNMEP2.cjs.map → chunk-3MG7VIPL.cjs.map} +1 -1
- package/dist/chunk-4ASM522I.js +2 -0
- package/dist/chunk-4ASM522I.js.map +1 -0
- package/dist/{chunk-KH4QXKLT.js → chunk-4MD5L23F.js} +2 -2
- package/dist/{chunk-KH4QXKLT.js.map → chunk-4MD5L23F.js.map} +1 -1
- package/dist/{chunk-IQVSCL2R.js → chunk-4XWZXP6I.js} +3 -3
- package/dist/{chunk-IQVSCL2R.js.map → chunk-4XWZXP6I.js.map} +1 -1
- package/dist/{chunk-RELMEWY6.js → chunk-6G2NES2I.js} +2 -2
- package/dist/chunk-6G2NES2I.js.map +1 -0
- package/dist/{chunk-CDE2ZUGG.js → chunk-6NL7RBAG.js} +2 -2
- package/dist/{chunk-CDE2ZUGG.js.map → chunk-6NL7RBAG.js.map} +1 -1
- package/dist/{chunk-SUAGBRQ7.cjs → chunk-6SYU4MH7.cjs} +2 -2
- package/dist/chunk-6SYU4MH7.cjs.map +1 -0
- package/dist/chunk-72J5V7SN.cjs +2 -0
- package/dist/chunk-72J5V7SN.cjs.map +1 -0
- package/dist/{chunk-TSJ4RQLZ.js → chunk-AENL3Z66.js} +2 -2
- package/dist/{chunk-TSJ4RQLZ.js.map → chunk-AENL3Z66.js.map} +1 -1
- package/dist/chunk-APYRNAU2.js +2 -0
- package/dist/chunk-APYRNAU2.js.map +1 -0
- package/dist/{chunk-AXTYQFIV.cjs → chunk-D7URPV5Z.cjs} +3 -3
- package/dist/{chunk-AXTYQFIV.cjs.map → chunk-D7URPV5Z.cjs.map} +1 -1
- package/dist/chunk-DB5ISONG.js +2 -0
- package/dist/chunk-DB5ISONG.js.map +1 -0
- package/dist/chunk-DGDVY6XI.js +3 -0
- package/dist/chunk-DGDVY6XI.js.map +1 -0
- package/dist/chunk-EOKHRS2T.js +2 -0
- package/dist/chunk-EOKHRS2T.js.map +1 -0
- package/dist/{chunk-NQFCXLEF.js → chunk-EOO6M65F.js} +2 -2
- package/dist/{chunk-NQFCXLEF.js.map → chunk-EOO6M65F.js.map} +1 -1
- package/dist/{chunk-A764BY7L.cjs → chunk-EQNKDTMX.cjs} +2 -2
- package/dist/{chunk-A764BY7L.cjs.map → chunk-EQNKDTMX.cjs.map} +1 -1
- package/dist/chunk-FESR6PZI.cjs +2 -0
- package/dist/chunk-FESR6PZI.cjs.map +1 -0
- package/dist/chunk-G2LCDR52.cjs +3 -0
- package/dist/chunk-G2LCDR52.cjs.map +1 -0
- package/dist/chunk-G5TZ6TDA.js +2 -0
- package/dist/chunk-G5TZ6TDA.js.map +1 -0
- package/dist/chunk-GDLYXRMA.cjs +2 -0
- package/dist/chunk-GDLYXRMA.cjs.map +1 -0
- package/dist/{chunk-7DJYS5PO.cjs → chunk-HSTGWWU2.cjs} +2 -2
- package/dist/{chunk-7DJYS5PO.cjs.map → chunk-HSTGWWU2.cjs.map} +1 -1
- package/dist/{chunk-OE2DBN4K.js → chunk-INMJ7ZXL.js} +2 -2
- package/dist/chunk-INMJ7ZXL.js.map +1 -0
- package/dist/chunk-ITH2RLRG.js +5 -0
- package/dist/chunk-ITH2RLRG.js.map +1 -0
- package/dist/{chunk-5AKT36UK.cjs → chunk-K3PZ66XR.cjs} +2 -2
- package/dist/{chunk-5AKT36UK.cjs.map → chunk-K3PZ66XR.cjs.map} +1 -1
- package/dist/chunk-LI6LYJDA.cjs +2 -0
- package/dist/chunk-LI6LYJDA.cjs.map +1 -0
- package/dist/{chunk-WQGHJAW2.cjs → chunk-M4UC2PB6.cjs} +2 -2
- package/dist/{chunk-WQGHJAW2.cjs.map → chunk-M4UC2PB6.cjs.map} +1 -1
- package/dist/chunk-O7HF345B.js +2 -0
- package/dist/chunk-O7HF345B.js.map +1 -0
- package/dist/{chunk-CM2WM5CM.cjs → chunk-OBZJKZ2F.cjs} +2 -2
- package/dist/{chunk-CM2WM5CM.cjs.map → chunk-OBZJKZ2F.cjs.map} +1 -1
- package/dist/{chunk-Q7TBBV62.cjs → chunk-P5YWBIIU.cjs} +2 -2
- package/dist/chunk-P5YWBIIU.cjs.map +1 -0
- package/dist/chunk-PICFFFJV.js +3 -0
- package/dist/chunk-PICFFFJV.js.map +1 -0
- package/dist/{chunk-P43SV4NJ.cjs → chunk-QOOTRUY7.cjs} +3 -3
- package/dist/{chunk-P43SV4NJ.cjs.map → chunk-QOOTRUY7.cjs.map} +1 -1
- package/dist/chunk-R3W53ZMP.cjs +2 -0
- package/dist/chunk-R3W53ZMP.cjs.map +1 -0
- package/dist/chunk-RMDCGYZM.js +2 -0
- package/dist/chunk-RMDCGYZM.js.map +1 -0
- package/dist/{chunk-CB3EXUM2.js → chunk-RU3KGJRA.js} +2 -2
- package/dist/chunk-RU3KGJRA.js.map +1 -0
- package/dist/chunk-S3SPDK6N.cjs +2 -0
- package/dist/chunk-S3SPDK6N.cjs.map +1 -0
- package/dist/chunk-SF5QVUEI.cjs +3 -0
- package/dist/chunk-SF5QVUEI.cjs.map +1 -0
- package/dist/{chunk-FXB5GCBT.js → chunk-TJKN466F.js} +2 -2
- package/dist/{chunk-FXB5GCBT.js.map → chunk-TJKN466F.js.map} +1 -1
- package/dist/{chunk-VLX7ZVK4.js → chunk-U5MESNRT.js} +2 -2
- package/dist/{chunk-VLX7ZVK4.js.map → chunk-U5MESNRT.js.map} +1 -1
- package/dist/chunk-WCVPXBCW.cjs +5 -0
- package/dist/chunk-WCVPXBCW.cjs.map +1 -0
- package/dist/{chunk-YWF6C2IO.cjs → chunk-WFT3XUSH.cjs} +2 -2
- package/dist/{chunk-YWF6C2IO.cjs.map → chunk-WFT3XUSH.cjs.map} +1 -1
- package/dist/{chunk-3ZGFAE3Q.js → chunk-X2GQAKL2.js} +2 -2
- package/dist/{chunk-3ZGFAE3Q.js.map → chunk-X2GQAKL2.js.map} +1 -1
- package/dist/{chunk-G3POUURF.js → chunk-YID47OPR.js} +2 -2
- package/dist/{chunk-G3POUURF.js.map → chunk-YID47OPR.js.map} +1 -1
- package/dist/chunk-YV4GDW5A.cjs +2 -0
- package/dist/chunk-YV4GDW5A.cjs.map +1 -0
- package/dist/chunk-ZSXQP7PD.cjs +2 -0
- package/dist/chunk-ZSXQP7PD.cjs.map +1 -0
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/engine.cjs +1 -1
- package/dist/engine.d.cts +10 -10
- package/dist/engine.d.ts +10 -10
- package/dist/engine.js +1 -1
- package/dist/engine.worker.cjs +1 -1
- package/dist/engine.worker.cjs.map +1 -1
- package/dist/engine.worker.js +1 -1
- package/dist/engine.worker.js.map +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.d.cts +1 -1
- package/dist/format.d.ts +1 -1
- package/dist/format.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/language.d.cts +9 -9
- package/dist/language.d.ts +9 -9
- package/dist/lexer.cjs +1 -1
- package/dist/lexer.d.cts +3 -3
- package/dist/lexer.d.ts +3 -3
- 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 +8 -8
- package/dist/packages.d.ts +8 -8
- package/dist/packages.js +1 -1
- package/dist/parser.cjs +1 -1
- package/dist/parser.d.cts +3 -3
- package/dist/parser.d.ts +3 -3
- package/dist/parser.js +1 -1
- package/dist/{pipeline-BYkKNpql.d.cts → pipeline-Bum6y1B9.d.cts} +1 -1
- package/dist/{pipeline-Cl7KW8CB.d.ts → pipeline-DOo3KHaq.d.ts} +1 -1
- package/dist/resolvers.cjs +1 -1
- package/dist/resolvers.d.cts +69 -3
- package/dist/resolvers.d.ts +69 -3
- package/dist/resolvers.js +1 -1
- package/dist/temporal.cjs +1 -1
- package/dist/temporal.js +1 -1
- package/dist/testing.cjs +2 -2
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +9 -9
- package/dist/testing.d.ts +9 -9
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/uom.cjs +1 -1
- package/dist/uom.d.cts +35 -2
- package/dist/uom.d.ts +35 -2
- package/dist/uom.js +1 -1
- package/dist/vm.cjs +1 -1
- package/dist/vm.d.cts +6 -6
- package/dist/vm.d.ts +6 -6
- package/dist/vm.js +1 -1
- package/dist/worker.cjs +2 -2
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +9 -9
- package/dist/worker.d.ts +9 -9
- package/dist/worker.js +1 -1
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-4DR5RBHQ.cjs +0 -2
- package/dist/chunk-4DR5RBHQ.cjs.map +0 -1
- package/dist/chunk-4IC5OARK.js +0 -3
- package/dist/chunk-4IC5OARK.js.map +0 -1
- package/dist/chunk-7ODHPWQC.js +0 -5
- package/dist/chunk-7ODHPWQC.js.map +0 -1
- package/dist/chunk-A755LVPT.cjs +0 -2
- package/dist/chunk-A755LVPT.cjs.map +0 -1
- package/dist/chunk-AF6NDOIE.js +0 -2
- package/dist/chunk-AF6NDOIE.js.map +0 -1
- package/dist/chunk-B2NL65FI.js +0 -2
- package/dist/chunk-B2NL65FI.js.map +0 -1
- package/dist/chunk-CB3EXUM2.js.map +0 -1
- package/dist/chunk-DUFEONVN.cjs +0 -3
- package/dist/chunk-DUFEONVN.cjs.map +0 -1
- package/dist/chunk-IJHL3LMH.js +0 -2
- package/dist/chunk-IJHL3LMH.js.map +0 -1
- package/dist/chunk-LCYQQFUH.cjs +0 -2
- package/dist/chunk-LCYQQFUH.cjs.map +0 -1
- package/dist/chunk-LP3JYC3A.js +0 -2
- package/dist/chunk-LP3JYC3A.js.map +0 -1
- package/dist/chunk-OE2DBN4K.js.map +0 -1
- package/dist/chunk-OKKGPINQ.cjs +0 -5
- package/dist/chunk-OKKGPINQ.cjs.map +0 -1
- package/dist/chunk-OM7NOHJF.cjs +0 -2
- package/dist/chunk-OM7NOHJF.cjs.map +0 -1
- package/dist/chunk-PTXUWGRR.js +0 -3
- package/dist/chunk-PTXUWGRR.js.map +0 -1
- package/dist/chunk-Q7TBBV62.cjs.map +0 -1
- package/dist/chunk-RELMEWY6.js.map +0 -1
- package/dist/chunk-SFM4XFGJ.js +0 -2
- package/dist/chunk-SFM4XFGJ.js.map +0 -1
- package/dist/chunk-SRAU3BLV.cjs +0 -3
- package/dist/chunk-SRAU3BLV.cjs.map +0 -1
- package/dist/chunk-SUAGBRQ7.cjs.map +0 -1
- package/dist/chunk-UNKZ5XRC.cjs +0 -2
- package/dist/chunk-UNKZ5XRC.cjs.map +0 -1
- package/dist/chunk-WU7SBKVU.cjs +0 -2
- package/dist/chunk-WU7SBKVU.cjs.map +0 -1
- package/dist/chunk-X5K72MBV.js +0 -2
- package/dist/chunk-X5K72MBV.js.map +0 -1
- package/dist/chunk-ZVPZQ66D.cjs +0 -2
- package/dist/chunk-ZVPZQ66D.cjs.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var E=[10,11,12,13,14,16,60,61,62,63,150,159,95,96],O=[50,51,151,152,160],A=[157,158,161],n=(()=>{let _=new Array(256).fill(0);for(let o of E)_[o]=1;for(let o of O)_[o]=2;for(let o of A)_[o]=3;return _})();[...E,...O,...A];function N(_,o){return o+1+(n[_[o]]??0)}export{N as a};//# sourceMappingURL=chunk-EOKHRS2T.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-EOKHRS2T.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/parser/OperandWidth.ts"],"names":["ONE_OPERAND","TWO_OPERANDS","THREE_OPERANDS","OPERAND_BYTES","widths","op","nextInstruction","opcodes","index"],"mappings":"AAwBA,IAAMA,CAAAA,CAAiC,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,EAAA,CAAA,GAAA,CAAA,GAAA,CAAA,EAAA,CAAA,EAwBvC,CAAA,CAOMC,CAAAA,CAAkC,kBAOxC,CAAA,CASMC,CAAAA,CAAoC,CAAA,GAAA,CAAA,GAAA,CAAA,GAAiE,CAAA,CAQ9FC,CAAAA,CAAAA,CAAoC,IAAM,CACtD,IAAMC,EAAS,IAAI,KAAA,CAAc,GAAG,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,CAC5C,IAAA,IAAWC,KAAML,CAAAA,CAAaI,CAAAA,CAAOC,CAAE,CAAA,CAAI,CAAA,CAC3C,IAAA,IAAWA,CAAAA,IAAMJ,CAAAA,CAAcG,EAAOC,CAAE,CAAA,CAAI,CAAA,CAC5C,IAAA,IAAWA,CAAAA,IAAMH,CAAAA,CAAgBE,CAAAA,CAAOC,CAAE,EAAI,CAAA,CAC9C,OAAOD,CACR,CAAA,GAAG,CAOqD,CACvD,GAAGJ,EACH,GAAGC,CAAAA,CACH,GAAGC,CACJ,EAaO,SAASI,CAAAA,CAAgBC,CAAAA,CAAqBC,EAAuB,CAC3E,OAAOA,CAAAA,CAAQ,CAAA,EAAKL,CAAAA,CAAcI,CAAAA,CAAQC,CAAK,CAAC,GAAK,CAAA,CACtD","file":"chunk-EOKHRS2T.js","sourcesContent":["/**\n * How many operand bytes follow each opcode, and how to step over one.\n *\n * Anything walking a bytecode stream without executing it needs this: the\n * resolver preflight scanners look for specific opcodes and must skip past\n * everything else without mistaking an operand byte for an instruction.\n *\n * It used to be a hand-copied switch in each of those scanners. They had\n * already drifted: two counted `CALL_PLUGIN` as three bytes wide and the third\n * omitted it from that arm, so a stream containing one desynchronised there and\n * every opcode after it was read at the wrong offset. Adding an opcode meant\n * remembering every copy, and nothing checked that you had.\n *\n * `__tests__/parser/OperandWidth.spec.ts` asserts every opcode has a width, so\n * a new one fails a test rather than silently defaulting to zero operands.\n */\n\nimport { OpCode } from \"@solve-js/parser/OpCode\";\n\n/**\n * Opcodes taking one operand byte.\n *\n * A constant-pool index, or a variable-name index.\n */\nconst ONE_OPERAND: readonly OpCode[] = [\n\tOpCode.PUSH_NUMBER,\n\tOpCode.PUSH_BIGINT,\n\tOpCode.PUSH_HEX,\n\tOpCode.PUSH_STRING,\n\tOpCode.PUSH_BOOLEAN,\n\t// Its operand is a string-pool index holding the exact decimal text, so a\n\t// scanner must step over one byte exactly as it does for PUSH_STRING.\n\tOpCode.PUSH_DECIMAL,\n\tOpCode.LOAD_VAR,\n\tOpCode.STORE_VAR,\n\tOpCode.LOAD_GLOBAL_VAR,\n\tOpCode.STORE_GLOBAL_VAR,\n\tOpCode.DEFINE_USER_FUNCTION,\n\tOpCode.BIND_UNKNOWN,\n\t// Its operand is a constant-pool index, like PUSH_NUMBER's: the epoch-ms\n\t// was resolved at parse time and stored in `numbers`. Omitting it made\n\t// every scanner read that index byte as an opcode, so an ordinary date\n\t// literal desynchronised the whole preflight walk.\n\tOpCode.DATE_LITERAL,\n\t// One byte, the offset direction (0 forward, 1 backward) for \"N working\n\t// days after/before/from <date>\". See WorkdayOffsetParselet. DATE_WORKDAYS_BETWEEN\n\t// takes no operand and so is not listed here.\n\tOpCode.DATE_WORKDAY_OFFSET,\n];\n\n/**\n * Opcodes taking two operand bytes.\n *\n * A callable index plus an argument count, or a matrix's row and column counts.\n */\nconst TWO_OPERANDS: readonly OpCode[] = [\n\tOpCode.CALL_PLUGIN,\n\tOpCode.CALL_BUILTIN,\n\tOpCode.CALL_USER_FUNCTION,\n\tOpCode.MAT_NEW,\n\t// A body index plus the pooled source-expression string.\n\tOpCode.PLOT_INVOKE,\n];\n\n/**\n * Opcodes taking three operand bytes.\n *\n * The map and reduce invocations, which carry a body index alongside their\n * other operands.\n */\n// CALL_PLUGIN_WIDE: a two-byte plugin index plus the one-byte argument count.\nconst THREE_OPERANDS: readonly OpCode[] = [OpCode.MAP_INVOKE, OpCode.REDUCE_INVOKE, OpCode.CALL_PLUGIN_WIDE];\n\n/**\n * Operand byte count for every opcode, indexed by opcode value.\n *\n * A dense array rather than a map, because the preflight scanners run on every\n * keystroke and this is read once per instruction.\n */\nexport const OPERAND_BYTES: readonly number[] = (() => {\n\tconst widths = new Array<number>(256).fill(0);\n\tfor (const op of ONE_OPERAND) widths[op] = 1;\n\tfor (const op of TWO_OPERANDS) widths[op] = 2;\n\tfor (const op of THREE_OPERANDS) widths[op] = 3;\n\treturn widths;\n})();\n\n/**\n * Every opcode that takes at least one operand.\n *\n * Exported so a test can assert the table stays complete as opcodes are added.\n */\nexport const OPCODES_WITH_OPERANDS: readonly OpCode[] = [\n\t...ONE_OPERAND,\n\t...TWO_OPERANDS,\n\t...THREE_OPERANDS,\n];\n\n/**\n * Offset of the instruction after the one at `index`.\n *\n * @param opcodes - The bytecode stream.\n * @param index - Offset of an opcode, not of an operand byte. Passing an\n * operand offset yields nonsense, which is the failure mode this exists to\n * prevent: a caller stepping by hand and getting one width wrong reads the rest\n * of the stream misaligned.\n * @returns Offset of the next opcode. May be past the end when the instruction\n * at `index` is the last one, so callers loop while it is under `opcodes.length`.\n */\nexport function nextInstruction(opcodes: Uint8Array, index: number): number {\n\treturn index + 1 + (OPERAND_BYTES[opcodes[index]] ?? 0);\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {b,l as l$1,a,m,n,k as k$1,c as c$1,j,o,p}from'./chunk-J4K72CQN.js';import {c,s as s$1}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {b,l as l$1,a,m,n,k as k$1,c as c$1,j,o,p}from'./chunk-J4K72CQN.js';import {c,s as s$1}from'./chunk-6G2NES2I.js';var s=class{now(){return Date.now()}fields(t){let e=new Date(t);return {year:e.getFullYear(),month0:e.getMonth(),day:e.getDate(),weekday:e.getDay(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds()}}localMidnight(t,e,n){return new Date(t,e,n).getTime()}localWallClock(t,e,n,r){let a=new Date(t,e,n,0,0,0,0);return a.setMinutes(r),a.getTime()}addDays(t,e){let n=new Date(t);return n.setDate(n.getDate()+e),n.getTime()}addMonths(t,e){let n=new Date(t),r=n.getDate();return n.setDate(1),n.setMonth(n.getMonth()+e),n.setDate(Math.min(r,b(n.getFullYear(),n.getMonth()))),n.getTime()}utcOffsetMinutes(t){return 0-new Date(t).getTimezoneOffset()}parseIso8601(t){return new Date(t).getTime()}formatLongDate(t,e){return new Date(t).toLocaleDateString(e,{weekday:"long",year:"numeric",month:"long",day:"numeric"})}formatTimeOfDay(t,e){return new Date(t).toLocaleTimeString(e)}zoneOffsetMinutes(t,e){let n=l$1(t,e);return Math.round((a(n.year,n.month0,n.day,n.hour,n.minute,n.second)-e)/6e4)||0}fieldsInZone(t,e){return l$1(t,e)}formatTimeInZone(t,e){return m(t,e)}formatDateInZone(t,e){return n(t,e)}},k=new s;function L(o){return o?.calendar??k}var O=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?$/,l=class extends s{constructor(e){super();this.namedZone=e;}zone(){return this.namedZone}fields(e){let n=l$1(this.namedZone,e),r=((c$1(n.year,n.month0,n.day)+4)%7+7)%7;return {year:n.year,month0:n.month0,day:n.day,weekday:r,hour:n.hour,minute:n.minute,second:n.second,millisecond:(e%1e3+1e3)%1e3}}localMidnight(e,n,r){return j(e,n,r,0,0,this.namedZone,this)}localWallClock(e,n,r,a){return j(e,n,r,0,a,this.namedZone,this)}addDays(e,n){let r=l$1(this.namedZone,e);return this.reanchor(r,r.day+n,e)}addMonths(e,n){let r=l$1(this.namedZone,e),a=new Date(Date.UTC(r.year,r.month0+n,1)),i=Math.min(r.day,b(a.getUTCFullYear(),a.getUTCMonth()));return j(a.getUTCFullYear(),a.getUTCMonth(),i,r.hour,r.minute,this.namedZone,this)+r.second*1e3+(e%1e3+1e3)%1e3}utcOffsetMinutes(e){return this.zoneOffsetMinutes(this.namedZone,e)}parseIso8601(e){let n=O.exec(e.trim());if(n===null)return super.parseIso8601(e);let[,r,a,i,w,p,c,b]=n,I=b===void 0?0:Number(b.slice(0,3).padEnd(3,"0"));return j(Number(r),Number(a)-1,Number(i),Number(w),Number(p),this.namedZone,this)+(c===void 0?0:Number(c))*1e3+I}formatLongDate(e,n){return o(this.namedZone,e,n)}formatTimeOfDay(e,n){return p(this.namedZone,e,n)}reanchor(e,n,r){return j(e.year,e.month0,n,e.hour,e.minute,this.namedZone,this)+e.second*1e3+(r%1e3+1e3)%1e3}};function U(o){if(!k$1(o))throw c.config(s$1.DATE_ZONE_UNKNOWN,`dateCalendarInZone("${o}") is not a time zone this runtime knows.`);return new l(o)}export{s as a,k as b,L as c,U as d};//# sourceMappingURL=chunk-EOO6M65F.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-EOO6M65F.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/calendar/DateCalendar.ts"],"names":["DateCalendar","epochMs","d","year","month0","day","minutesPastMidnight","anchored","days","date","months","dayOfMonth","daysInMonth","text","locale","zone","f","zonedFields","utcMs","timeInZone","dateInZone","DATE_CALENDAR","calendarOf","context","ISO_LOCAL_DATE_TIME","ZonedDateCalendar","namedZone","weekday","dayNumber","zonedWallClockToUtcMs","target","clampedDay","matched","month","hour","minute","second","fraction","millisecond","longDateInZone","timeOfDayInZone","dateCalendarInZone","isSupportedZone","ErrorFactory","DatetimeErrorCodes"],"mappings":"wHA0BO,IAAMA,EAAN,KAA8C,CACpD,GAAA,EAAc,CACb,OAAO,IAAA,CAAK,GAAA,EACb,CAEA,OAAOC,CAAAA,CAAiC,CACvC,IAAMC,CAAAA,CAAI,IAAI,IAAA,CAAKD,CAAO,CAAA,CAC1B,OAAO,CACN,IAAA,CAAMC,CAAAA,CAAE,WAAA,EAAY,CACpB,OAAQA,CAAAA,CAAE,QAAA,EAAS,CACnB,GAAA,CAAKA,EAAE,OAAA,EAAQ,CACf,QAASA,CAAAA,CAAE,MAAA,GACX,IAAA,CAAMA,CAAAA,CAAE,QAAA,EAAS,CACjB,OAAQA,CAAAA,CAAE,UAAA,EAAW,CACrB,MAAA,CAAQA,EAAE,UAAA,EAAW,CACrB,WAAA,CAAaA,CAAAA,CAAE,iBAChB,CACD,CAEA,aAAA,CAAcC,EAAcC,CAAAA,CAAgBC,CAAAA,CAAqB,CAChE,OAAO,IAAI,IAAA,CAAKF,CAAAA,CAAMC,CAAAA,CAAQC,CAAG,EAAE,OAAA,EACpC,CAEA,cAAA,CAAeF,EAAcC,CAAAA,CAAgBC,CAAAA,CAAaC,EAAqC,CAG9F,IAAMC,EAAW,IAAI,IAAA,CAAKJ,CAAAA,CAAMC,CAAAA,CAAQC,EAAK,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAC,EACvD,OAAAE,CAAAA,CAAS,UAAA,CAAWD,CAAmB,EAChCC,CAAAA,CAAS,OAAA,EACjB,CAEA,QAAQN,CAAAA,CAAiBO,CAAAA,CAAsB,CAC9C,IAAMC,EAAO,IAAI,IAAA,CAAKR,CAAO,CAAA,CAC7B,OAAAQ,CAAAA,CAAK,OAAA,CAAQA,CAAAA,C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CAAM,CACvD,CAGQ,QAAA,CAASE,CAAAA,CAAgBX,EAAaJ,CAAAA,CAAyB,CACtE,OAAO4B,CAAAA,CAAsBb,CAAAA,CAAE,KAAMA,CAAAA,CAAE,MAAA,CAAQX,CAAAA,CAAKW,CAAAA,CAAE,KAAMA,CAAAA,CAAE,MAAA,CAAQ,IAAA,CAAK,SAAA,CAAW,IAAI,CAAA,CACvFA,CAAAA,CAAE,MAAA,CAAS,GAAA,CAAA,CAAUf,EAAU,GAAA,CAAQ,GAAA,EAAQ,GACnD,CACD,CAAA,CA6BO,SAASwC,CAAAA,CAAmB1B,CAAAA,CAA+B,CACjE,GAAI,CAAC2B,GAAAA,CAAgB3B,CAAI,CAAA,CACxB,MAAM4B,EAAa,MAAA,CAClBC,GAAAA,CAAmB,iBAAA,CACnB,CAAA,oBAAA,EAAuB7B,CAAI,CAAA,yCAAA,CAC5B,CAAA,CAED,OAAO,IAAIU,CAAAA,CAAkBV,CAAI,CAClC","file":"chunk-NQFCXLEF.js","sourcesContent":["import { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\nimport { DatetimeErrorCodes } from \"@solve-js/errors/ErrorCode\";\nimport type { CalendarBackend, CalendarFields, ZonedFields } from \"./CalendarBackend\";\nimport { dayNumber, daysInMonth, utcMs } from \"./Gregorian\";\nimport { dateInZone, isSupportedZone, longDateInZone, timeInZone, timeOfDayInZone, zonedFields, zonedWallClockToUtcMs } from \"./IntlZone\";\n\n/**\n * The default {@link CalendarBackend}: the JavaScript `Date` object, read in\n * the host process's time zone, with `Intl.DateTimeFormat` for named zones.\n *\n * This is the calendar code the engine has always run, moved behind the\n * interface method by method rather than rewritten, so a host that configures\n * nothing sees the same instants and the same strings it did before the\n * backend existed. Where `Date` has a quirk (a two-digit year in a\n * constructor maps to the 1900s, an out-of-range instant answers `NaN`), the\n * quirk is kept here deliberately: the point of this backend is to be the\n * behaviour the `Temporal` backend is measured against, not to improve on it.\n *\n * It stays the default because it is the one calendar every supported runtime\n * has. `Temporal` ships unflagged in Node 26 and in current Chrome, Firefox\n * and Deno, but not in Safari or in the Node 22 and 24 the engine supports,\n * and the smallest polyfill adds about twenty kilobytes gzipped to a bundle\n * that a host doing plain arithmetic never needs. A host that wants\n * `Temporal` opts in through the engine's `calendar` option with the backend\n * from `solve-engine/temporal`, and pays for it only then.\n */\nexport class DateCalendar implements CalendarBackend {\n\tnow(): number {\n\t\treturn Date.now();\n\t}\n\n\tfields(epochMs: number): CalendarFields {\n\t\tconst d = new Date(epochMs);\n\t\treturn {\n\t\t\tyear: d.getFullYear(),\n\t\t\tmonth0: d.getMonth(),\n\t\t\tday: d.getDate(),\n\t\t\tweekday: d.getDay(),\n\t\t\thour: d.getHours(),\n\t\t\tminute: d.getMinutes(),\n\t\t\tsecond: d.getSeconds(),\n\t\t\tmillisecond: d.getMilliseconds(),\n\t\t};\n\t}\n\n\tlocalMidnight(year: number, month0: number, day: number): number {\n\t\treturn new Date(year, month0, day).getTime();\n\t}\n\n\tlocalWallClock(year: number, month0: number, day: number, minutesPastMidnight: number): number {\n\t\t// Anchored at midnight and then moved by the minutes FIELD, so the\n\t\t// result is the wall-clock reading asked for whatever the day's length.\n\t\tconst anchored = new Date(year, month0, day, 0, 0, 0, 0);\n\t\tanchored.setMinutes(minutesPastMidnight);\n\t\treturn anchored.getTime();\n\t}\n\n\taddDays(epochMs: number, days: number): number {\n\t\tconst date = new Date(epochMs);\n\t\tdate.setDate(date.getDate() + days);\n\t\treturn date.getTime();\n\t}\n\n\taddMonths(epochMs: number, months: number): number {\n\t\tconst date = new Date(epochMs);\n\t\tconst dayOfMonth = date.getDate();\n\t\t// Parked on the 1st before the month field moves: `setMonth()` keeps\n\t\t// the day number, so a 31st aimed at a 30-day month would overflow\n\t\t// into the month after it. Clamping afterwards is what keeps the month\n\t\t// the caller asked for.\n\t\tdate.setDate(1);\n\t\tdate.setMonth(date.getMonth() + months);\n\t\tdate.setDate(Math.min(dayOfMonth, daysInMonth(date.getFullYear(), date.getMonth())));\n\t\treturn date.getTime();\n\t}\n\n\tutcOffsetMinutes(epochMs: number): number {\n\t\t// `getTimezoneOffset()` is (UTC minus local), so its sign is inverted\n\t\t// relative to the \"+HH:MM ahead of UTC\" reading every caller wants.\n\t\t// Subtracted from zero rather than negated, so a zero offset is 0 and\n\t\t// not -0, which a second backend could not be expected to reproduce.\n\t\treturn 0 - new Date(epochMs).getTimezoneOffset();\n\t}\n\n\tparseIso8601(text: string): number {\n\t\treturn new Date(text).getTime();\n\t}\n\n\tformatLongDate(epochMs: number, locale: string): string {\n\t\treturn new Date(epochMs).toLocaleDateString(locale, { weekday: \"long\", year: \"numeric\", month: \"long\", day: \"numeric\" });\n\t}\n\n\tformatTimeOfDay(epochMs: number, locale: string): string {\n\t\treturn new Date(epochMs).toLocaleTimeString(locale);\n\t}\n\n\tzoneOffsetMinutes(zone: string, epochMs: number): number {\n\t\t// The `Intl` round trip: read the instant as the zone's wall-clock\n\t\t// fields, re-read those fields as if they were UTC, and the difference\n\t\t// from the instant is the zone's offset then, daylight saving included.\n\t\tconst f = zonedFields(zone, epochMs);\n\t\t// `|| 0` folds the -0 a negative sub-minute difference rounds to.\n\t\treturn Math.round((utcMs(f.year, f.month0, f.day, f.hour, f.minute, f.second) - epochMs) / 60000) || 0;\n\t}\n\n\tfieldsInZone(zone: string, epochMs: number): ZonedFields {\n\t\treturn zonedFields(zone, epochMs);\n\t}\n\n\tformatTimeInZone(zone: string, epochMs: number): string {\n\t\treturn timeInZone(zone, epochMs);\n\t}\n\n\tformatDateInZone(zone: string, epochMs: number): string {\n\t\treturn dateInZone(zone, epochMs);\n\t}\n}\n\n/**\n * The one `Date` backend, shared by every engine that configures no other.\n *\n * Stateless, so sharing is safe: it holds no zone of its own and reads the\n * process's. It is also what the sites with no engine in hand use (the\n * normaliser rules that fuse a literal, `days in <period>`, the stocks and\n * historical-currency date phrases, and `formatValue`), which is why an\n * engine's own backend is the default here rather than a second copy.\n */\nexport const DATE_CALENDAR: CalendarBackend = new DateCalendar();\n\n/**\n * The backend a plugin function or converter should compute with: the one\n * on its execution context, or the `Date` backend when the handler was\n * called with no context (a direct call from a test, or an `as` converter\n * invoked outside the VM).\n *\n * @param context - The execution context the handler received, if any.\n * @returns The engine's backend when the context carries one, else {@link DATE_CALENDAR}.\n */\nexport function calendarOf(context?: { readonly calendar?: CalendarBackend }): CalendarBackend {\n\treturn context?.calendar ?? DATE_CALENDAR;\n}\n\n/**\n * The `Date` backend, computing in a named IANA zone instead of the host\n * process's.\n *\n * Every zone-free answer is inherited unchanged from {@link DateCalendar}:\n * `now()` is still the clock, `parseIso8601` still reads the two ECMAScript\n * spellings, and the four named-zone methods already took the zone as an\n * argument. What changes is what \"local\" means, which is exactly the set of\n * questions {@link CalendarBackend} says depends on a zone: which day an\n * instant falls on, what a wall-clock reading names, what a day or a month\n * later is, and what the offset from UTC is.\n *\n * Those are answered through `Intl`, the same data the base class already\n * reads named zones with, so the accuracy is the same and nothing new is\n * bundled. The one place it is a simplification is a wall clock that a\n * daylight-saving transition made ambiguous or non-existent (01:30 on a\n * spring-forward morning): {@link zonedWallClockToUtcMs} resolves it one way,\n * and a `Temporal` backend's `disambiguation: 'compatible'` may resolve it an\n * hour differently.\n */\n/**\n * An ISO 8601 date-time with a time of day and NO offset and no `Z`: the one\n * spelling whose instant depends on which zone reads it. Anchored at both\n * ends, so a date-only string and anything carrying an offset fall through to\n * the base class untouched.\n */\nconst ISO_LOCAL_DATE_TIME = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d+))?)?$/;\n\nclass ZonedDateCalendar extends DateCalendar {\n\t/**\n\t * @param namedZone - An IANA zone name `Intl` accepts.\n\t */\n\tconstructor(private readonly namedZone: string) {\n\t\tsuper();\n\t}\n\n\tzone(): string {\n\t\treturn this.namedZone;\n\t}\n\n\tfields(epochMs: number): CalendarFields {\n\t\tconst f = zonedFields(this.namedZone, epochMs);\n\t\t// `zonedFields` answers no weekday and no millisecond: the weekday is a\n\t\t// pure function of the zoned date (`Gregorian.dayNumber`, counting from a\n\t\t// Thursday), and the millisecond is the instant's own, which no zone\n\t\t// offset in use is fractional enough to move.\n\t\tconst weekday = (((dayNumber(f.year, f.month0, f.day) + 4) % 7) + 7) % 7;\n\t\treturn {\n\t\t\tyear: f.year, month0: f.month0, day: f.day, weekday,\n\t\t\thour: f.hour, minute: f.minute, second: f.second,\n\t\t\tmillisecond: ((epochMs % 1000) + 1000) % 1000,\n\t\t};\n\t}\n\n\tlocalMidnight(year: number, month0: number, day: number): number {\n\t\treturn zonedWallClockToUtcMs(year, month0, day, 0, 0, this.namedZone, this);\n\t}\n\n\tlocalWallClock(year: number, month0: number, day: number, minutesPastMidnight: number): number {\n\t\t// The minutes go in as the MINUTE field, not as elapsed time, so a\n\t\t// reading of 540 is 09:00 on that date even on a 23-hour day. `Date.UTC`\n\t\t// rolls a minute field past 59 into the hour, which is what makes one\n\t\t// argument enough.\n\t\treturn zonedWallClockToUtcMs(year, month0, day, 0, minutesPastMidnight, this.namedZone, this);\n\t}\n\n\taddDays(epochMs: number, days: number): number {\n\t\tconst f = zonedFields(this.namedZone, epochMs);\n\t\treturn this.reanchor(f, f.day + days, epochMs);\n\t}\n\n\taddMonths(epochMs: number, months: number): number {\n\t\tconst f = zonedFields(this.namedZone, epochMs);\n\t\tconst target = new Date(Date.UTC(f.year, f.month0 + months, 1));\n\t\tconst clampedDay = Math.min(f.day, daysInMonth(target.getUTCFullYear(), target.getUTCMonth()));\n\t\treturn zonedWallClockToUtcMs(\n\t\t\ttarget.getUTCFullYear(), target.getUTCMonth(), clampedDay,\n\t\t\tf.hour, f.minute, this.namedZone, this,\n\t\t) + f.second * 1000 + (((epochMs % 1000) + 1000) % 1000);\n\t}\n\n\tutcOffsetMinutes(epochMs: number): number {\n\t\treturn this.zoneOffsetMinutes(this.namedZone, epochMs);\n\t}\n\n\tparseIso8601(text: string): number {\n\t\t// The one reading in that contract that depends on a zone: a date-time\n\t\t// with no offset and no `Z` is LOCAL time, and local here is the named\n\t\t// zone. Without this the backend contradicted itself, computing\n\t\t// `2026-04-03` at New York midnight while reading `2026-04-03T09:30` as\n\t\t// half past nine in the host process's zone. It is also what the\n\t\t// `Temporal` backend already does (`TemporalCalendar.parseIso8601`\n\t\t// resolves a bare wall clock in its own zone), so the two agree.\n\t\t//\n\t\t// Everything else is the base class byte for byte: a date-only string is\n\t\t// still UTC midnight and an explicit offset is still subtracted, both\n\t\t// frozen by the interface's contract.\n\t\tconst matched = ISO_LOCAL_DATE_TIME.exec(text.trim());\n\t\tif (matched === null) return super.parseIso8601(text);\n\t\tconst [, year, month, day, hour, minute, second, fraction] = matched;\n\t\tconst millisecond = fraction === undefined ? 0 : Number(fraction.slice(0, 3).padEnd(3, \"0\"));\n\t\treturn zonedWallClockToUtcMs(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute), this.namedZone, this)\n\t\t\t+ (second === undefined ? 0 : Number(second)) * 1000 + millisecond;\n\t}\n\n\tformatLongDate(epochMs: number, locale: string): string {\n\t\treturn longDateInZone(this.namedZone, epochMs, locale);\n\t}\n\n\tformatTimeOfDay(epochMs: number, locale: string): string {\n\t\treturn timeOfDayInZone(this.namedZone, epochMs, locale);\n\t}\n\n\t/** Rebuild an instant on a (possibly overflowed) day, holding its wall clock down to the millisecond. */\n\tprivate reanchor(f: ZonedFields, day: number, epochMs: number): number {\n\t\treturn zonedWallClockToUtcMs(f.year, f.month0, day, f.hour, f.minute, this.namedZone, this)\n\t\t\t+ f.second * 1000 + (((epochMs % 1000) + 1000) % 1000);\n\t}\n}\n\n/**\n * A `Date` backend that computes in a named time zone rather than the host\n * process's.\n *\n * This is how a host pins the zone the engine reads dates in, and it is the\n * only knob for it: the zone belongs to the calendar backend, which already\n * owns what \"local\" means, so there is deliberately no `date.zone` config\n * field to drift against it.\n *\n * ```ts\n * import { createEngine, dateCalendarInZone } from \"solve-engine\";\n * const engine = createEngine({ calendar: dateCalendarInZone(\"Asia/Tokyo\") });\n * ```\n *\n * It ships on the `Date` backend on purpose. `Temporal` is undefined on Node\n * 24 and in Safari, so \"pass a `Temporal` backend\" would put the zone out of\n * reach for most hosts today; `Temporal` stays an accuracy upgrade for the\n * ambiguous wall clocks around a daylight-saving transition, never a\n * prerequisite for naming a zone at all.\n *\n * @param zone - An IANA zone name, e.g. `\"Asia/Tokyo\"`.\n * @returns A backend whose local zone is that one.\n * @throws A `DATE_ZONE_UNKNOWN` config error when this runtime's `Intl` does\n * not know the zone. Refused here rather than per line, because a backend\n * that cannot compute in the zone it was asked for must not quietly answer\n * in another one.\n */\nexport function dateCalendarInZone(zone: string): CalendarBackend {\n\tif (!isSupportedZone(zone)) {\n\t\tthrow ErrorFactory.config(\n\t\t\tDatetimeErrorCodes.DATE_ZONE_UNKNOWN,\n\t\t\t`dateCalendarInZone(\"${zone}\") is not a time zone this runtime knows.`,\n\t\t);\n\t}\n\treturn new ZonedDateCalendar(zone);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/calendar/DateCalendar.ts"],"names":["DateCalendar","epochMs","d","year","month0","day","minutesPastMidnight","anchored","days","date","months","dayOfMonth","daysInMonth","text","locale","zone","f","zonedFields","utcMs","timeInZone","dateInZone","DATE_CALENDAR","calendarOf","context","ISO_LOCAL_DATE_TIME","ZonedDateCalendar","namedZone","weekday","dayNumber","zonedWallClockToUtcMs","target","clampedDay","matched","month","hour","minute","second","fraction","millisecond","longDateInZone","timeOfDayInZone","dateCalendarInZone","isSupportedZone","ErrorFactory","DatetimeErrorCodes"],"mappings":"wHA0BO,IAAMA,EAAN,KAA8C,CACpD,GAAA,EAAc,CACb,OAAO,IAAA,CAAK,GAAA,EACb,CAEA,OAAOC,CAAAA,CAAiC,CACvC,IAAMC,CAAAA,CAAI,IAAI,IAAA,CAAKD,CAAO,CAAA,CAC1B,OAAO,CACN,IAAA,CAAMC,CAAAA,CAAE,WAAA,EAAY,CACpB,OAAQA,CAAAA,CAAE,QAAA,EAAS,CACnB,GAAA,CAAKA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BC,GAAAA,CAAmB,iBAAA,CACnB,CAAA,oBAAA,EAAuB7B,CAAI,CAAA,yCAAA,CAC5B,CAAA,CAED,OAAO,IAAIU,CAAAA,CAAkBV,CAAI,CAClC","file":"chunk-EOO6M65F.js","sourcesContent":["import { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\nimport { DatetimeErrorCodes } from \"@solve-js/errors/ErrorCode\";\nimport type { CalendarBackend, CalendarFields, ZonedFields } from \"./CalendarBackend\";\nimport { dayNumber, daysInMonth, utcMs } from \"./Gregorian\";\nimport { dateInZone, isSupportedZone, longDateInZone, timeInZone, timeOfDayInZone, zonedFields, zonedWallClockToUtcMs } from \"./IntlZone\";\n\n/**\n * The default {@link CalendarBackend}: the JavaScript `Date` object, read in\n * the host process's time zone, with `Intl.DateTimeFormat` for named zones.\n *\n * This is the calendar code the engine has always run, moved behind the\n * interface method by method rather than rewritten, so a host that configures\n * nothing sees the same instants and the same strings it did before the\n * backend existed. Where `Date` has a quirk (a two-digit year in a\n * constructor maps to the 1900s, an out-of-range instant answers `NaN`), the\n * quirk is kept here deliberately: the point of this backend is to be the\n * behaviour the `Temporal` backend is measured against, not to improve on it.\n *\n * It stays the default because it is the one calendar every supported runtime\n * has. `Temporal` ships unflagged in Node 26 and in current Chrome, Firefox\n * and Deno, but not in Safari or in the Node 22 and 24 the engine supports,\n * and the smallest polyfill adds about twenty kilobytes gzipped to a bundle\n * that a host doing plain arithmetic never needs. A host that wants\n * `Temporal` opts in through the engine's `calendar` option with the backend\n * from `solve-engine/temporal`, and pays for it only then.\n */\nexport class DateCalendar implements CalendarBackend {\n\tnow(): number {\n\t\treturn Date.now();\n\t}\n\n\tfields(epochMs: number): CalendarFields {\n\t\tconst d = new Date(epochMs);\n\t\treturn {\n\t\t\tyear: d.getFullYear(),\n\t\t\tmonth0: d.getMonth(),\n\t\t\tday: d.getDate(),\n\t\t\tweekday: d.getDay(),\n\t\t\thour: d.getHours(),\n\t\t\tminute: d.getMinutes(),\n\t\t\tsecond: d.getSeconds(),\n\t\t\tmillisecond: d.getMilliseconds(),\n\t\t};\n\t}\n\n\tlocalMidnight(year: number, month0: number, day: number): number {\n\t\treturn new Date(year, month0, day).getTime();\n\t}\n\n\tlocalWallClock(year: number, month0: number, day: number, minutesPastMidnight: number): number {\n\t\t// Anchored at midnight and then moved by the minutes FIELD, so the\n\t\t// result is the wall-clock reading asked for whatever the day's length.\n\t\tconst anchored = new Date(year, month0, day, 0, 0, 0, 0);\n\t\tanchored.setMinutes(minutesPastMidnight);\n\t\treturn anchored.getTime();\n\t}\n\n\taddDays(epochMs: number, days: number): number {\n\t\tconst date = new Date(epochMs);\n\t\tdate.setDate(date.getDate() + days);\n\t\treturn date.getTime();\n\t}\n\n\taddMonths(epochMs: number, months: number): number {\n\t\tconst date = new Date(epochMs);\n\t\tconst dayOfMonth = date.getDate();\n\t\t// Parked on the 1st before the month field moves: `setMonth()` keeps\n\t\t// the day number, so a 31st aimed at a 30-day month would overflow\n\t\t// into the month after it. Clamping afterwards is what keeps the month\n\t\t// the caller asked for.\n\t\tdate.setDate(1);\n\t\tdate.setMonth(date.getMonth() + months);\n\t\tdate.setDate(Math.min(dayOfMonth, daysInMonth(date.getFullYear(), date.getMonth())));\n\t\treturn date.getTime();\n\t}\n\n\tutcOffsetMinutes(epochMs: number): number {\n\t\t// `getTimezoneOffset()` is (UTC minus local), so its sign is inverted\n\t\t// relative to the \"+HH:MM ahead of UTC\" reading every caller wants.\n\t\t// Subtracted from zero rather than negated, so a zero offset is 0 and\n\t\t// not -0, which a second backend could not be expected to reproduce.\n\t\treturn 0 - new Date(epochMs).getTimezoneOffset();\n\t}\n\n\tparseIso8601(text: string): number {\n\t\treturn new Date(text).getTime();\n\t}\n\n\tformatLongDate(epochMs: number, locale: string): string {\n\t\treturn new Date(epochMs).toLocaleDateString(locale, { weekday: \"long\", year: \"numeric\", month: \"long\", day: \"numeric\" });\n\t}\n\n\tformatTimeOfDay(epochMs: number, locale: string): string {\n\t\treturn new Date(epochMs).toLocaleTimeString(locale);\n\t}\n\n\tzoneOffsetMinutes(zone: string, epochMs: number): number {\n\t\t// The `Intl` round trip: read the instant as the zone's wall-clock\n\t\t// fields, re-read those fields as if they were UTC, and the difference\n\t\t// from the instant is the zone's offset then, daylight saving included.\n\t\tconst f = zonedFields(zone, epochMs);\n\t\t// `|| 0` folds the -0 a negative sub-minute difference rounds to.\n\t\treturn Math.round((utcMs(f.year, f.month0, f.day, f.hour, f.minute, f.second) - epochMs) / 60000) || 0;\n\t}\n\n\tfieldsInZone(zone: string, epochMs: number): ZonedFields {\n\t\treturn zonedFields(zone, epochMs);\n\t}\n\n\tformatTimeInZone(zone: string, epochMs: number): string {\n\t\treturn timeInZone(zone, epochMs);\n\t}\n\n\tformatDateInZone(zone: string, epochMs: number): string {\n\t\treturn dateInZone(zone, epochMs);\n\t}\n}\n\n/**\n * The one `Date` backend, shared by every engine that configures no other.\n *\n * Stateless, so sharing is safe: it holds no zone of its own and reads the\n * process's. It is also what the sites with no engine in hand use (the\n * normaliser rules that fuse a literal, `days in <period>`, the stocks and\n * historical-currency date phrases, and `formatValue`), which is why an\n * engine's own backend is the default here rather than a second copy.\n */\nexport const DATE_CALENDAR: CalendarBackend = new DateCalendar();\n\n/**\n * The backend a plugin function or converter should compute with: the one\n * on its execution context, or the `Date` backend when the handler was\n * called with no context (a direct call from a test, or an `as` converter\n * invoked outside the VM).\n *\n * @param context - The execution context the handler received, if any.\n * @returns The engine's backend when the context carries one, else {@link DATE_CALENDAR}.\n */\nexport function calendarOf(context?: { readonly calendar?: CalendarBackend }): CalendarBackend {\n\treturn context?.calendar ?? DATE_CALENDAR;\n}\n\n/**\n * The `Date` backend, computing in a named IANA zone instead of the host\n * process's.\n *\n * Every zone-free answer is inherited unchanged from {@link DateCalendar}:\n * `now()` is still the clock, `parseIso8601` still reads the two ECMAScript\n * spellings, and the four named-zone methods already took the zone as an\n * argument. What changes is what \"local\" means, which is exactly the set of\n * questions {@link CalendarBackend} says depends on a zone: which day an\n * instant falls on, what a wall-clock reading names, what a day or a month\n * later is, and what the offset from UTC is.\n *\n * Those are answered through `Intl`, the same data the base class already\n * reads named zones with, so the accuracy is the same and nothing new is\n * bundled. The one place it is a simplification is a wall clock that a\n * daylight-saving transition made ambiguous or non-existent (01:30 on a\n * spring-forward morning): {@link zonedWallClockToUtcMs} resolves it one way,\n * and a `Temporal` backend's `disambiguation: 'compatible'` may resolve it an\n * hour differently.\n */\n/**\n * An ISO 8601 date-time with a time of day and NO offset and no `Z`: the one\n * spelling whose instant depends on which zone reads it. Anchored at both\n * ends, so a date-only string and anything carrying an offset fall through to\n * the base class untouched.\n */\nconst ISO_LOCAL_DATE_TIME = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d+))?)?$/;\n\nclass ZonedDateCalendar extends DateCalendar {\n\t/**\n\t * @param namedZone - An IANA zone name `Intl` accepts.\n\t */\n\tconstructor(private readonly namedZone: string) {\n\t\tsuper();\n\t}\n\n\tzone(): string {\n\t\treturn this.namedZone;\n\t}\n\n\tfields(epochMs: number): CalendarFields {\n\t\tconst f = zonedFields(this.namedZone, epochMs);\n\t\t// `zonedFields` answers no weekday and no millisecond: the weekday is a\n\t\t// pure function of the zoned date (`Gregorian.dayNumber`, counting from a\n\t\t// Thursday), and the millisecond is the instant's own, which no zone\n\t\t// offset in use is fractional enough to move.\n\t\tconst weekday = (((dayNumber(f.year, f.month0, f.day) + 4) % 7) + 7) % 7;\n\t\treturn {\n\t\t\tyear: f.year, month0: f.month0, day: f.day, weekday,\n\t\t\thour: f.hour, minute: f.minute, second: f.second,\n\t\t\tmillisecond: ((epochMs % 1000) + 1000) % 1000,\n\t\t};\n\t}\n\n\tlocalMidnight(year: number, month0: number, day: number): number {\n\t\treturn zonedWallClockToUtcMs(year, month0, day, 0, 0, this.namedZone, this);\n\t}\n\n\tlocalWallClock(year: number, month0: number, day: number, minutesPastMidnight: number): number {\n\t\t// The minutes go in as the MINUTE field, not as elapsed time, so a\n\t\t// reading of 540 is 09:00 on that date even on a 23-hour day. `Date.UTC`\n\t\t// rolls a minute field past 59 into the hour, which is what makes one\n\t\t// argument enough.\n\t\treturn zonedWallClockToUtcMs(year, month0, day, 0, minutesPastMidnight, this.namedZone, this);\n\t}\n\n\taddDays(epochMs: number, days: number): number {\n\t\tconst f = zonedFields(this.namedZone, epochMs);\n\t\treturn this.reanchor(f, f.day + days, epochMs);\n\t}\n\n\taddMonths(epochMs: number, months: number): number {\n\t\tconst f = zonedFields(this.namedZone, epochMs);\n\t\tconst target = new Date(Date.UTC(f.year, f.month0 + months, 1));\n\t\tconst clampedDay = Math.min(f.day, daysInMonth(target.getUTCFullYear(), target.getUTCMonth()));\n\t\treturn zonedWallClockToUtcMs(\n\t\t\ttarget.getUTCFullYear(), target.getUTCMonth(), clampedDay,\n\t\t\tf.hour, f.minute, this.namedZone, this,\n\t\t) + f.second * 1000 + (((epochMs % 1000) + 1000) % 1000);\n\t}\n\n\tutcOffsetMinutes(epochMs: number): number {\n\t\treturn this.zoneOffsetMinutes(this.namedZone, epochMs);\n\t}\n\n\tparseIso8601(text: string): number {\n\t\t// The one reading in that contract that depends on a zone: a date-time\n\t\t// with no offset and no `Z` is LOCAL time, and local here is the named\n\t\t// zone. Without this the backend contradicted itself, computing\n\t\t// `2026-04-03` at New York midnight while reading `2026-04-03T09:30` as\n\t\t// half past nine in the host process's zone. It is also what the\n\t\t// `Temporal` backend already does (`TemporalCalendar.parseIso8601`\n\t\t// resolves a bare wall clock in its own zone), so the two agree.\n\t\t//\n\t\t// Everything else is the base class byte for byte: a date-only string is\n\t\t// still UTC midnight and an explicit offset is still subtracted, both\n\t\t// frozen by the interface's contract.\n\t\tconst matched = ISO_LOCAL_DATE_TIME.exec(text.trim());\n\t\tif (matched === null) return super.parseIso8601(text);\n\t\tconst [, year, month, day, hour, minute, second, fraction] = matched;\n\t\tconst millisecond = fraction === undefined ? 0 : Number(fraction.slice(0, 3).padEnd(3, \"0\"));\n\t\treturn zonedWallClockToUtcMs(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute), this.namedZone, this)\n\t\t\t+ (second === undefined ? 0 : Number(second)) * 1000 + millisecond;\n\t}\n\n\tformatLongDate(epochMs: number, locale: string): string {\n\t\treturn longDateInZone(this.namedZone, epochMs, locale);\n\t}\n\n\tformatTimeOfDay(epochMs: number, locale: string): string {\n\t\treturn timeOfDayInZone(this.namedZone, epochMs, locale);\n\t}\n\n\t/** Rebuild an instant on a (possibly overflowed) day, holding its wall clock down to the millisecond. */\n\tprivate reanchor(f: ZonedFields, day: number, epochMs: number): number {\n\t\treturn zonedWallClockToUtcMs(f.year, f.month0, day, f.hour, f.minute, this.namedZone, this)\n\t\t\t+ f.second * 1000 + (((epochMs % 1000) + 1000) % 1000);\n\t}\n}\n\n/**\n * A `Date` backend that computes in a named time zone rather than the host\n * process's.\n *\n * This is how a host pins the zone the engine reads dates in, and it is the\n * only knob for it: the zone belongs to the calendar backend, which already\n * owns what \"local\" means, so there is deliberately no `date.zone` config\n * field to drift against it.\n *\n * ```ts\n * import { createEngine, dateCalendarInZone } from \"solve-engine\";\n * const engine = createEngine({ calendar: dateCalendarInZone(\"Asia/Tokyo\") });\n * ```\n *\n * It ships on the `Date` backend on purpose. `Temporal` is undefined on Node\n * 24 and in Safari, so \"pass a `Temporal` backend\" would put the zone out of\n * reach for most hosts today; `Temporal` stays an accuracy upgrade for the\n * ambiguous wall clocks around a daylight-saving transition, never a\n * prerequisite for naming a zone at all.\n *\n * @param zone - An IANA zone name, e.g. `\"Asia/Tokyo\"`.\n * @returns A backend whose local zone is that one.\n * @throws A `DATE_ZONE_UNKNOWN` config error when this runtime's `Intl` does\n * not know the zone. Refused here rather than per line, because a backend\n * that cannot compute in the zone it was asked for must not quietly answer\n * in another one.\n */\nexport function dateCalendarInZone(zone: string): CalendarBackend {\n\tif (!isSupportedZone(zone)) {\n\t\tthrow ErrorFactory.config(\n\t\t\tDatetimeErrorCodes.DATE_ZONE_UNKNOWN,\n\t\t\t`dateCalendarInZone(\"${zone}\") is not a time zone this runtime knows.`,\n\t\t);\n\t}\n\treturn new ZonedDateCalendar(zone);\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var chunkE4HAKNBQ_cjs=require('./chunk-E4HAKNBQ.cjs'),
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
'use strict';var chunkE4HAKNBQ_cjs=require('./chunk-E4HAKNBQ.cjs'),chunk6SYU4MH7_cjs=require('./chunk-6SYU4MH7.cjs');var s=class{now(){return Date.now()}fields(t){let e=new Date(t);return {year:e.getFullYear(),month0:e.getMonth(),day:e.getDate(),weekday:e.getDay(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds()}}localMidnight(t,e,n){return new Date(t,e,n).getTime()}localWallClock(t,e,n,r){let a=new Date(t,e,n,0,0,0,0);return a.setMinutes(r),a.getTime()}addDays(t,e){let n=new Date(t);return n.setDate(n.getDate()+e),n.getTime()}addMonths(t,e){let n=new Date(t),r=n.getDate();return n.setDate(1),n.setMonth(n.getMonth()+e),n.setDate(Math.min(r,chunkE4HAKNBQ_cjs.b(n.getFullYear(),n.getMonth()))),n.getTime()}utcOffsetMinutes(t){return 0-new Date(t).getTimezoneOffset()}parseIso8601(t){return new Date(t).getTime()}formatLongDate(t,e){return new Date(t).toLocaleDateString(e,{weekday:"long",year:"numeric",month:"long",day:"numeric"})}formatTimeOfDay(t,e){return new Date(t).toLocaleTimeString(e)}zoneOffsetMinutes(t,e){let n=chunkE4HAKNBQ_cjs.l(t,e);return Math.round((chunkE4HAKNBQ_cjs.a(n.year,n.month0,n.day,n.hour,n.minute,n.second)-e)/6e4)||0}fieldsInZone(t,e){return chunkE4HAKNBQ_cjs.l(t,e)}formatTimeInZone(t,e){return chunkE4HAKNBQ_cjs.m(t,e)}formatDateInZone(t,e){return chunkE4HAKNBQ_cjs.n(t,e)}},k=new s;function L(o){return o?.calendar??k}var O=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?$/,l=class extends s{constructor(e){super();this.namedZone=e;}zone(){return this.namedZone}fields(e){let n=chunkE4HAKNBQ_cjs.l(this.namedZone,e),r=((chunkE4HAKNBQ_cjs.c(n.year,n.month0,n.day)+4)%7+7)%7;return {year:n.year,month0:n.month0,day:n.day,weekday:r,hour:n.hour,minute:n.minute,second:n.second,millisecond:(e%1e3+1e3)%1e3}}localMidnight(e,n,r){return chunkE4HAKNBQ_cjs.j(e,n,r,0,0,this.namedZone,this)}localWallClock(e,n,r,a){return chunkE4HAKNBQ_cjs.j(e,n,r,0,a,this.namedZone,this)}addDays(e,n){let r=chunkE4HAKNBQ_cjs.l(this.namedZone,e);return this.reanchor(r,r.day+n,e)}addMonths(e,n){let r=chunkE4HAKNBQ_cjs.l(this.namedZone,e),a=new Date(Date.UTC(r.year,r.month0+n,1)),i=Math.min(r.day,chunkE4HAKNBQ_cjs.b(a.getUTCFullYear(),a.getUTCMonth()));return chunkE4HAKNBQ_cjs.j(a.getUTCFullYear(),a.getUTCMonth(),i,r.hour,r.minute,this.namedZone,this)+r.second*1e3+(e%1e3+1e3)%1e3}utcOffsetMinutes(e){return this.zoneOffsetMinutes(this.namedZone,e)}parseIso8601(e){let n=O.exec(e.trim());if(n===null)return super.parseIso8601(e);let[,r,a,i,w,p,c,b]=n,I=b===void 0?0:Number(b.slice(0,3).padEnd(3,"0"));return chunkE4HAKNBQ_cjs.j(Number(r),Number(a)-1,Number(i),Number(w),Number(p),this.namedZone,this)+(c===void 0?0:Number(c))*1e3+I}formatLongDate(e,n){return chunkE4HAKNBQ_cjs.o(this.namedZone,e,n)}formatTimeOfDay(e,n){return chunkE4HAKNBQ_cjs.p(this.namedZone,e,n)}reanchor(e,n,r){return chunkE4HAKNBQ_cjs.j(e.year,e.month0,n,e.hour,e.minute,this.namedZone,this)+e.second*1e3+(r%1e3+1e3)%1e3}};function U(o){if(!chunkE4HAKNBQ_cjs.k(o))throw chunk6SYU4MH7_cjs.c.config(chunk6SYU4MH7_cjs.s.DATE_ZONE_UNKNOWN,`dateCalendarInZone("${o}") is not a time zone this runtime knows.`);return new l(o)}exports.a=s;exports.b=k;exports.c=L;exports.d=U;//# sourceMappingURL=chunk-EQNKDTMX.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-EQNKDTMX.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/calendar/DateCalendar.ts"],"names":["DateCalendar","epochMs","d","year","month0","day","minutesPastMidnight","anchored","days","date","months","dayOfMonth","daysInMonth","text","locale","zone","f","zonedFields","utcMs","timeInZone","dateInZone","DATE_CALENDAR","calendarOf","context","ISO_LOCAL_DATE_TIME","ZonedDateCalendar","namedZone","weekday","dayNumber","zonedWallClockToUtcMs","target","clampedDay","matched","month","hour","minute","second","fraction","millisecond","longDateInZone","timeOfDayInZone","dateCalendarInZone","isSupportedZone","ErrorFactory","DatetimeErrorCodes"],"mappings":"qHA0BO,IAAMA,EAAN,KAA8C,CACpD,GAAA,EAAc,CACb,OAAO,IAAA,CAAK,GAAA,EACb,CAEA,OAAOC,CAAAA,CAAiC,CACvC,IAAMC,CAAAA,CAAI,IAAI,IAAA,CAAKD,CAAO,CAAA,CAC1B,OAAO,CACN,IAAA,CAAMC,CAAAA,CAAE,WAAA,EAAY,CACpB,OAAQA,CAAAA,CAAE,QAAA,EAAS,CACnB,GAAA,CAAKA,EAAE,OAAA,EAAQ,CACf,QAASA,CAAAA,CAAE,MAAA,GACX,IAAA,CAAMA,CAAAA,CAAE,QAAA,EAAS,CACjB,OAAQA,CAAAA,CAAE,UAAA,EAAW,CACrB,MAAA,CAAQA,EAAE,UAAA,EAAW,CACrB,WAAA,CAAaA,CAAAA,CAAE,iBAChB,CACD,CAEA,aAAA,CAAcC,EAAcC,CAAAA,CAAgBC,CAAAA,CAAqB,CAChE,OAAO,IAAI,IAAA,CAAKF,CAA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,CAAK,CAAA,CAAI,CAAA,CAAG,MAAA,CAAO5B,CAAG,EAAG,MAAA,CAAO6B,CAAI,CAAA,CAAG,MAAA,CAAOC,CAAM,CAAA,CAAG,IAAA,CAAK,UAAW,IAAI,CAAA,CAAA,CACzHC,IAAW,MAAA,CAAY,CAAA,CAAI,MAAA,CAAOA,CAAM,GAAK,GAAA,CAAOE,CACzD,CAEA,cAAA,CAAerC,EAAiBa,CAAAA,CAAwB,CACvD,OAAOyB,mBAAAA,CAAe,KAAK,SAAA,CAAWtC,CAAAA,CAASa,CAAM,CACtD,CAEA,eAAA,CAAgBb,CAAAA,CAAiBa,CAAAA,CAAwB,CACxD,OAAO0B,mBAAAA,CAAgB,IAAA,CAAK,SAAA,CAAWvC,CAAAA,CAASa,CAAM,CACvD,CAGQ,QAAA,CAASE,CAAAA,CAAgBX,EAAaJ,CAAAA,CAAyB,CACtE,OAAO4B,mBAAAA,CAAsBb,CAAAA,CAAE,KAAMA,CAAAA,CAAE,MAAA,CAAQX,CAAAA,CAAKW,CAAAA,CAAE,KAAMA,CAAAA,CAAE,MAAA,CAAQ,IAAA,CAAK,SAAA,CAAW,IAAI,CAAA,CACvFA,CAAAA,CAAE,MAAA,CAAS,GAAA,CAAA,CAAUf,EAAU,GAAA,CAAQ,GAAA,EAAQ,GACnD,CACD,CAAA,CA6BO,SAASwC,CAAAA,CAAmB1B,CAAAA,CAA+B,CACjE,GAAI,CAAC2B,mBAAAA,CAAgB3B,CAAI,CAAA,CACxB,MAAM4B,oBAAa,MAAA,CAClBC,mBAAAA,CAAmB,iBAAA,CACnB,CAAA,oBAAA,EAAuB7B,CAAI,CAAA,yCAAA,CAC5B,CAAA,CAED,OAAO,IAAIU,CAAAA,CAAkBV,CAAI,CAClC","file":"chunk-A764BY7L.cjs","sourcesContent":["import { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\nimport { DatetimeErrorCodes } from \"@solve-js/errors/ErrorCode\";\nimport type { CalendarBackend, CalendarFields, ZonedFields } from \"./CalendarBackend\";\nimport { dayNumber, daysInMonth, utcMs } from \"./Gregorian\";\nimport { dateInZone, isSupportedZone, longDateInZone, timeInZone, timeOfDayInZone, zonedFields, zonedWallClockToUtcMs } from \"./IntlZone\";\n\n/**\n * The default {@link CalendarBackend}: the JavaScript `Date` object, read in\n * the host process's time zone, with `Intl.DateTimeFormat` for named zones.\n *\n * This is the calendar code the engine has always run, moved behind the\n * interface method by method rather than rewritten, so a host that configures\n * nothing sees the same instants and the same strings it did before the\n * backend existed. Where `Date` has a quirk (a two-digit year in a\n * constructor maps to the 1900s, an out-of-range instant answers `NaN`), the\n * quirk is kept here deliberately: the point of this backend is to be the\n * behaviour the `Temporal` backend is measured against, not to improve on it.\n *\n * It stays the default because it is the one calendar every supported runtime\n * has. `Temporal` ships unflagged in Node 26 and in current Chrome, Firefox\n * and Deno, but not in Safari or in the Node 22 and 24 the engine supports,\n * and the smallest polyfill adds about twenty kilobytes gzipped to a bundle\n * that a host doing plain arithmetic never needs. A host that wants\n * `Temporal` opts in through the engine's `calendar` option with the backend\n * from `solve-engine/temporal`, and pays for it only then.\n */\nexport class DateCalendar implements CalendarBackend {\n\tnow(): number {\n\t\treturn Date.now();\n\t}\n\n\tfields(epochMs: number): CalendarFields {\n\t\tconst d = new Date(epochMs);\n\t\treturn {\n\t\t\tyear: d.getFullYear(),\n\t\t\tmonth0: d.getMonth(),\n\t\t\tday: d.getDate(),\n\t\t\tweekday: d.getDay(),\n\t\t\thour: d.getHours(),\n\t\t\tminute: d.getMinutes(),\n\t\t\tsecond: d.getSeconds(),\n\t\t\tmillisecond: d.getMilliseconds(),\n\t\t};\n\t}\n\n\tlocalMidnight(year: number, month0: number, day: number): number {\n\t\treturn new Date(year, month0, day).getTime();\n\t}\n\n\tlocalWallClock(year: number, month0: number, day: number, minutesPastMidnight: number): number {\n\t\t// Anchored at midnight and then moved by the minutes FIELD, so the\n\t\t// result is the wall-clock reading asked for whatever the day's length.\n\t\tconst anchored = new Date(year, month0, day, 0, 0, 0, 0);\n\t\tanchored.setMinutes(minutesPastMidnight);\n\t\treturn anchored.getTime();\n\t}\n\n\taddDays(epochMs: number, days: number): number {\n\t\tconst date = new Date(epochMs);\n\t\tdate.setDate(date.getDate() + days);\n\t\treturn date.getTime();\n\t}\n\n\taddMonths(epochMs: number, months: number): number {\n\t\tconst date = new Date(epochMs);\n\t\tconst dayOfMonth = date.getDate();\n\t\t// Parked on the 1st before the month field moves: `setMonth()` keeps\n\t\t// the day number, so a 31st aimed at a 30-day month would overflow\n\t\t// into the month after it. Clamping afterwards is what keeps the month\n\t\t// the caller asked for.\n\t\tdate.setDate(1);\n\t\tdate.setMonth(date.getMonth() + months);\n\t\tdate.setDate(Math.min(dayOfMonth, daysInMonth(date.getFullYear(), date.getMonth())));\n\t\treturn date.getTime();\n\t}\n\n\tutcOffsetMinutes(epochMs: number): number {\n\t\t// `getTimezoneOffset()` is (UTC minus local), so its sign is inverted\n\t\t// relative to the \"+HH:MM ahead of UTC\" reading every caller wants.\n\t\t// Subtracted from zero rather than negated, so a zero offset is 0 and\n\t\t// not -0, which a second backend could not be expected to reproduce.\n\t\treturn 0 - new Date(epochMs).getTimezoneOffset();\n\t}\n\n\tparseIso8601(text: string): number {\n\t\treturn new Date(text).getTime();\n\t}\n\n\tformatLongDate(epochMs: number, locale: string): string {\n\t\treturn new Date(epochMs).toLocaleDateString(locale, { weekday: \"long\", year: \"numeric\", month: \"long\", day: \"numeric\" });\n\t}\n\n\tformatTimeOfDay(epochMs: number, locale: string): string {\n\t\treturn new Date(epochMs).toLocaleTimeString(locale);\n\t}\n\n\tzoneOffsetMinutes(zone: string, epochMs: number): number {\n\t\t// The `Intl` round trip: read the instant as the zone's wall-clock\n\t\t// fields, re-read those fields as if they were UTC, and the difference\n\t\t// from the instant is the zone's offset then, daylight saving included.\n\t\tconst f = zonedFields(zone, epochMs);\n\t\t// `|| 0` folds the -0 a negative sub-minute difference rounds to.\n\t\treturn Math.round((utcMs(f.year, f.month0, f.day, f.hour, f.minute, f.second) - epochMs) / 60000) || 0;\n\t}\n\n\tfieldsInZone(zone: string, epochMs: number): ZonedFields {\n\t\treturn zonedFields(zone, epochMs);\n\t}\n\n\tformatTimeInZone(zone: string, epochMs: number): string {\n\t\treturn timeInZone(zone, epochMs);\n\t}\n\n\tformatDateInZone(zone: string, epochMs: number): string {\n\t\treturn dateInZone(zone, epochMs);\n\t}\n}\n\n/**\n * The one `Date` backend, shared by every engine that configures no other.\n *\n * Stateless, so sharing is safe: it holds no zone of its own and reads the\n * process's. It is also what the sites with no engine in hand use (the\n * normaliser rules that fuse a literal, `days in <period>`, the stocks and\n * historical-currency date phrases, and `formatValue`), which is why an\n * engine's own backend is the default here rather than a second copy.\n */\nexport const DATE_CALENDAR: CalendarBackend = new DateCalendar();\n\n/**\n * The backend a plugin function or converter should compute with: the one\n * on its execution context, or the `Date` backend when the handler was\n * called with no context (a direct call from a test, or an `as` converter\n * invoked outside the VM).\n *\n * @param context - The execution context the handler received, if any.\n * @returns The engine's backend when the context carries one, else {@link DATE_CALENDAR}.\n */\nexport function calendarOf(context?: { readonly calendar?: CalendarBackend }): CalendarBackend {\n\treturn context?.calendar ?? DATE_CALENDAR;\n}\n\n/**\n * The `Date` backend, computing in a named IANA zone instead of the host\n * process's.\n *\n * Every zone-free answer is inherited unchanged from {@link DateCalendar}:\n * `now()` is still the clock, `parseIso8601` still reads the two ECMAScript\n * spellings, and the four named-zone methods already took the zone as an\n * argument. What changes is what \"local\" means, which is exactly the set of\n * questions {@link CalendarBackend} says depends on a zone: which day an\n * instant falls on, what a wall-clock reading names, what a day or a month\n * later is, and what the offset from UTC is.\n *\n * Those are answered through `Intl`, the same data the base class already\n * reads named zones with, so the accuracy is the same and nothing new is\n * bundled. The one place it is a simplification is a wall clock that a\n * daylight-saving transition made ambiguous or non-existent (01:30 on a\n * spring-forward morning): {@link zonedWallClockToUtcMs} resolves it one way,\n * and a `Temporal` backend's `disambiguation: 'compatible'` may resolve it an\n * hour differently.\n */\n/**\n * An ISO 8601 date-time with a time of day and NO offset and no `Z`: the one\n * spelling whose instant depends on which zone reads it. Anchored at both\n * ends, so a date-only string and anything carrying an offset fall through to\n * the base class untouched.\n */\nconst ISO_LOCAL_DATE_TIME = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d+))?)?$/;\n\nclass ZonedDateCalendar extends DateCalendar {\n\t/**\n\t * @param namedZone - An IANA zone name `Intl` accepts.\n\t */\n\tconstructor(private readonly namedZone: string) {\n\t\tsuper();\n\t}\n\n\tzone(): string {\n\t\treturn this.namedZone;\n\t}\n\n\tfields(epochMs: number): CalendarFields {\n\t\tconst f = zonedFields(this.namedZone, epochMs);\n\t\t// `zonedFields` answers no weekday and no millisecond: the weekday is a\n\t\t// pure function of the zoned date (`Gregorian.dayNumber`, counting from a\n\t\t// Thursday), and the millisecond is the instant's own, which no zone\n\t\t// offset in use is fractional enough to move.\n\t\tconst weekday = (((dayNumber(f.year, f.month0, f.day) + 4) % 7) + 7) % 7;\n\t\treturn {\n\t\t\tyear: f.year, month0: f.month0, day: f.day, weekday,\n\t\t\thour: f.hour, minute: f.minute, second: f.second,\n\t\t\tmillisecond: ((epochMs % 1000) + 1000) % 1000,\n\t\t};\n\t}\n\n\tlocalMidnight(year: number, month0: number, day: number): number {\n\t\treturn zonedWallClockToUtcMs(year, month0, day, 0, 0, this.namedZone, this);\n\t}\n\n\tlocalWallClock(year: number, month0: number, day: number, minutesPastMidnight: number): number {\n\t\t// The minutes go in as the MINUTE field, not as elapsed time, so a\n\t\t// reading of 540 is 09:00 on that date even on a 23-hour day. `Date.UTC`\n\t\t// rolls a minute field past 59 into the hour, which is what makes one\n\t\t// argument enough.\n\t\treturn zonedWallClockToUtcMs(year, month0, day, 0, minutesPastMidnight, this.namedZone, this);\n\t}\n\n\taddDays(epochMs: number, days: number): number {\n\t\tconst f = zonedFields(this.namedZone, epochMs);\n\t\treturn this.reanchor(f, f.day + days, epochMs);\n\t}\n\n\taddMonths(epochMs: number, months: number): number {\n\t\tconst f = zonedFields(this.namedZone, epochMs);\n\t\tconst target = new Date(Date.UTC(f.year, f.month0 + months, 1));\n\t\tconst clampedDay = Math.min(f.day, daysInMonth(target.getUTCFullYear(), target.getUTCMonth()));\n\t\treturn zonedWallClockToUtcMs(\n\t\t\ttarget.getUTCFullYear(), target.getUTCMonth(), clampedDay,\n\t\t\tf.hour, f.minute, this.namedZone, this,\n\t\t) + f.second * 1000 + (((epochMs % 1000) + 1000) % 1000);\n\t}\n\n\tutcOffsetMinutes(epochMs: number): number {\n\t\treturn this.zoneOffsetMinutes(this.namedZone, epochMs);\n\t}\n\n\tparseIso8601(text: string): number {\n\t\t// The one reading in that contract that depends on a zone: a date-time\n\t\t// with no offset and no `Z` is LOCAL time, and local here is the named\n\t\t// zone. Without this the backend contradicted itself, computing\n\t\t// `2026-04-03` at New York midnight while reading `2026-04-03T09:30` as\n\t\t// half past nine in the host process's zone. It is also what the\n\t\t// `Temporal` backend already does (`TemporalCalendar.parseIso8601`\n\t\t// resolves a bare wall clock in its own zone), so the two agree.\n\t\t//\n\t\t// Everything else is the base class byte for byte: a date-only string is\n\t\t// still UTC midnight and an explicit offset is still subtracted, both\n\t\t// frozen by the interface's contract.\n\t\tconst matched = ISO_LOCAL_DATE_TIME.exec(text.trim());\n\t\tif (matched === null) return super.parseIso8601(text);\n\t\tconst [, year, month, day, hour, minute, second, fraction] = matched;\n\t\tconst millisecond = fraction === undefined ? 0 : Number(fraction.slice(0, 3).padEnd(3, \"0\"));\n\t\treturn zonedWallClockToUtcMs(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute), this.namedZone, this)\n\t\t\t+ (second === undefined ? 0 : Number(second)) * 1000 + millisecond;\n\t}\n\n\tformatLongDate(epochMs: number, locale: string): string {\n\t\treturn longDateInZone(this.namedZone, epochMs, locale);\n\t}\n\n\tformatTimeOfDay(epochMs: number, locale: string): string {\n\t\treturn timeOfDayInZone(this.namedZone, epochMs, locale);\n\t}\n\n\t/** Rebuild an instant on a (possibly overflowed) day, holding its wall clock down to the millisecond. */\n\tprivate reanchor(f: ZonedFields, day: number, epochMs: number): number {\n\t\treturn zonedWallClockToUtcMs(f.year, f.month0, day, f.hour, f.minute, this.namedZone, this)\n\t\t\t+ f.second * 1000 + (((epochMs % 1000) + 1000) % 1000);\n\t}\n}\n\n/**\n * A `Date` backend that computes in a named time zone rather than the host\n * process's.\n *\n * This is how a host pins the zone the engine reads dates in, and it is the\n * only knob for it: the zone belongs to the calendar backend, which already\n * owns what \"local\" means, so there is deliberately no `date.zone` config\n * field to drift against it.\n *\n * ```ts\n * import { createEngine, dateCalendarInZone } from \"solve-engine\";\n * const engine = createEngine({ calendar: dateCalendarInZone(\"Asia/Tokyo\") });\n * ```\n *\n * It ships on the `Date` backend on purpose. `Temporal` is undefined on Node\n * 24 and in Safari, so \"pass a `Temporal` backend\" would put the zone out of\n * reach for most hosts today; `Temporal` stays an accuracy upgrade for the\n * ambiguous wall clocks around a daylight-saving transition, never a\n * prerequisite for naming a zone at all.\n *\n * @param zone - An IANA zone name, e.g. `\"Asia/Tokyo\"`.\n * @returns A backend whose local zone is that one.\n * @throws A `DATE_ZONE_UNKNOWN` config error when this runtime's `Intl` does\n * not know the zone. Refused here rather than per line, because a backend\n * that cannot compute in the zone it was asked for must not quietly answer\n * in another one.\n */\nexport function dateCalendarInZone(zone: string): CalendarBackend {\n\tif (!isSupportedZone(zone)) {\n\t\tthrow ErrorFactory.config(\n\t\t\tDatetimeErrorCodes.DATE_ZONE_UNKNOWN,\n\t\t\t`dateCalendarInZone(\"${zone}\") is not a time zone this runtime knows.`,\n\t\t);\n\t}\n\treturn new ZonedDateCalendar(zone);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/calendar/DateCalendar.ts"],"names":["DateCalendar","epochMs","d","year","month0","day","minutesPastMidnight","anchored","days","date","months","dayOfMonth","daysInMonth","text","locale","zone","f","zonedFields","utcMs","timeInZone","dateInZone","DATE_CALENDAR","calendarOf","context","ISO_LOCAL_DATE_TIME","ZonedDateCalendar","namedZone","weekday","dayNumber","zonedWallClockToUtcMs","target","clampedDay","matched","month","hour","minute","second","fraction","millisecond","longDateInZone","timeOfDayInZone","dateCalendarInZone","isSupportedZone","ErrorFactory","DatetimeErrorCodes"],"mappings":"qHA0BO,IAAMA,EAAN,KAA8C,CACpD,GAAA,EAAc,CACb,OAAO,IAAA,CAAK,GAAA,EACb,CAEA,OAAOC,CAAAA,CAAiC,CACvC,IAAMC,CAAAA,CAAI,IAAI,IAAA,CAAKD,CAAO,CAAA,CAC1B,OAAO,CACN,IAAA,CAAMC,CAAAA,CAAE,WAAA,EAAY,CACpB,OAAQA,CAAAA,CAAE,QAAA,EAAS,CACnB,GAAA,CAAKA,EAAE,OAAA,EAAQ,CACf,QAASA,CAAAA,CAAE,MAAA,GACX,IAAA,CAAMA,CAAAA,CAAE,QAAA,EAAS,CACjB,OAAQA,CAAAA,CAAE,UAAA,EAAW,CACrB,MAAA,CAAQA,EAAE,UAAA,EAAW,CACrB,WAAA,CAAaA,CAAAA,CAAE,iBAChB,CACD,CAEA,aAAA,CAAcC,EAAcC,CAAAA,CAAgBC,CAAAA,CAAqB,CAChE,OAAO,IAAI,IAAA,CAAKF,CAAAA,CAAMC,CAAAA,CAAQC,CAAG,EAAE,OAAA,EACpC,CAEA,cAAA,CAAeF,EAAcC,CAAAA,CAAgBC,CAAAA,CAAaC,EAAqC,CAG9F,IAAMC,EAAW,IAAI,IAAA,CAAKJ,CAAAA,CAAMC,CAAAA,CAAQC,EAAK,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAC,EACvD,OAAAE,CAAAA,CAAS,UAAA,CAAWD,CAAmB,EAChCC,CAAAA,CAAS,OAAA,EACjB,CAEA,QAAQN,CAAAA,CAAiBO,CAAAA,CAAsB,CAC9C,IAAMC,EAAO,IAAI,IAAA,CAAKR,CAAO,CAAA,CAC7B,OAAAQ,CAAAA,CAAK,OAAA,CAAQ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AK,SAAA,CAAWvC,CAAAA,CAASa,CAAM,CACvD,CAGQ,QAAA,CAASE,CAAAA,CAAgBX,EAAaJ,CAAAA,CAAyB,CACtE,OAAO4B,mBAAAA,CAAsBb,CAAAA,CAAE,KAAMA,CAAAA,CAAE,MAAA,CAAQX,CAAAA,CAAKW,CAAAA,CAAE,KAAMA,CAAAA,CAAE,MAAA,CAAQ,IAAA,CAAK,SAAA,CAAW,IAAI,CAAA,CACvFA,CAAAA,CAAE,MAAA,CAAS,GAAA,CAAA,CAAUf,EAAU,GAAA,CAAQ,GAAA,EAAQ,GACnD,CACD,CAAA,CA6BO,SAASwC,CAAAA,CAAmB1B,CAAAA,CAA+B,CACjE,GAAI,CAAC2B,mBAAAA,CAAgB3B,CAAI,CAAA,CACxB,MAAM4B,oBAAa,MAAA,CAClBC,mBAAAA,CAAmB,iBAAA,CACnB,CAAA,oBAAA,EAAuB7B,CAAI,CAAA,yCAAA,CAC5B,CAAA,CAED,OAAO,IAAIU,CAAAA,CAAkBV,CAAI,CAClC","file":"chunk-EQNKDTMX.cjs","sourcesContent":["import { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\nimport { DatetimeErrorCodes } from \"@solve-js/errors/ErrorCode\";\nimport type { CalendarBackend, CalendarFields, ZonedFields } from \"./CalendarBackend\";\nimport { dayNumber, daysInMonth, utcMs } from \"./Gregorian\";\nimport { dateInZone, isSupportedZone, longDateInZone, timeInZone, timeOfDayInZone, zonedFields, zonedWallClockToUtcMs } from \"./IntlZone\";\n\n/**\n * The default {@link CalendarBackend}: the JavaScript `Date` object, read in\n * the host process's time zone, with `Intl.DateTimeFormat` for named zones.\n *\n * This is the calendar code the engine has always run, moved behind the\n * interface method by method rather than rewritten, so a host that configures\n * nothing sees the same instants and the same strings it did before the\n * backend existed. Where `Date` has a quirk (a two-digit year in a\n * constructor maps to the 1900s, an out-of-range instant answers `NaN`), the\n * quirk is kept here deliberately: the point of this backend is to be the\n * behaviour the `Temporal` backend is measured against, not to improve on it.\n *\n * It stays the default because it is the one calendar every supported runtime\n * has. `Temporal` ships unflagged in Node 26 and in current Chrome, Firefox\n * and Deno, but not in Safari or in the Node 22 and 24 the engine supports,\n * and the smallest polyfill adds about twenty kilobytes gzipped to a bundle\n * that a host doing plain arithmetic never needs. A host that wants\n * `Temporal` opts in through the engine's `calendar` option with the backend\n * from `solve-engine/temporal`, and pays for it only then.\n */\nexport class DateCalendar implements CalendarBackend {\n\tnow(): number {\n\t\treturn Date.now();\n\t}\n\n\tfields(epochMs: number): CalendarFields {\n\t\tconst d = new Date(epochMs);\n\t\treturn {\n\t\t\tyear: d.getFullYear(),\n\t\t\tmonth0: d.getMonth(),\n\t\t\tday: d.getDate(),\n\t\t\tweekday: d.getDay(),\n\t\t\thour: d.getHours(),\n\t\t\tminute: d.getMinutes(),\n\t\t\tsecond: d.getSeconds(),\n\t\t\tmillisecond: d.getMilliseconds(),\n\t\t};\n\t}\n\n\tlocalMidnight(year: number, month0: number, day: number): number {\n\t\treturn new Date(year, month0, day).getTime();\n\t}\n\n\tlocalWallClock(year: number, month0: number, day: number, minutesPastMidnight: number): number {\n\t\t// Anchored at midnight and then moved by the minutes FIELD, so the\n\t\t// result is the wall-clock reading asked for whatever the day's length.\n\t\tconst anchored = new Date(year, month0, day, 0, 0, 0, 0);\n\t\tanchored.setMinutes(minutesPastMidnight);\n\t\treturn anchored.getTime();\n\t}\n\n\taddDays(epochMs: number, days: number): number {\n\t\tconst date = new Date(epochMs);\n\t\tdate.setDate(date.getDate() + days);\n\t\treturn date.getTime();\n\t}\n\n\taddMonths(epochMs: number, months: number): number {\n\t\tconst date = new Date(epochMs);\n\t\tconst dayOfMonth = date.getDate();\n\t\t// Parked on the 1st before the month field moves: `setMonth()` keeps\n\t\t// the day number, so a 31st aimed at a 30-day month would overflow\n\t\t// into the month after it. Clamping afterwards is what keeps the month\n\t\t// the caller asked for.\n\t\tdate.setDate(1);\n\t\tdate.setMonth(date.getMonth() + months);\n\t\tdate.setDate(Math.min(dayOfMonth, daysInMonth(date.getFullYear(), date.getMonth())));\n\t\treturn date.getTime();\n\t}\n\n\tutcOffsetMinutes(epochMs: number): number {\n\t\t// `getTimezoneOffset()` is (UTC minus local), so its sign is inverted\n\t\t// relative to the \"+HH:MM ahead of UTC\" reading every caller wants.\n\t\t// Subtracted from zero rather than negated, so a zero offset is 0 and\n\t\t// not -0, which a second backend could not be expected to reproduce.\n\t\treturn 0 - new Date(epochMs).getTimezoneOffset();\n\t}\n\n\tparseIso8601(text: string): number {\n\t\treturn new Date(text).getTime();\n\t}\n\n\tformatLongDate(epochMs: number, locale: string): string {\n\t\treturn new Date(epochMs).toLocaleDateString(locale, { weekday: \"long\", year: \"numeric\", month: \"long\", day: \"numeric\" });\n\t}\n\n\tformatTimeOfDay(epochMs: number, locale: string): string {\n\t\treturn new Date(epochMs).toLocaleTimeString(locale);\n\t}\n\n\tzoneOffsetMinutes(zone: string, epochMs: number): number {\n\t\t// The `Intl` round trip: read the instant as the zone's wall-clock\n\t\t// fields, re-read those fields as if they were UTC, and the difference\n\t\t// from the instant is the zone's offset then, daylight saving included.\n\t\tconst f = zonedFields(zone, epochMs);\n\t\t// `|| 0` folds the -0 a negative sub-minute difference rounds to.\n\t\treturn Math.round((utcMs(f.year, f.month0, f.day, f.hour, f.minute, f.second) - epochMs) / 60000) || 0;\n\t}\n\n\tfieldsInZone(zone: string, epochMs: number): ZonedFields {\n\t\treturn zonedFields(zone, epochMs);\n\t}\n\n\tformatTimeInZone(zone: string, epochMs: number): string {\n\t\treturn timeInZone(zone, epochMs);\n\t}\n\n\tformatDateInZone(zone: string, epochMs: number): string {\n\t\treturn dateInZone(zone, epochMs);\n\t}\n}\n\n/**\n * The one `Date` backend, shared by every engine that configures no other.\n *\n * Stateless, so sharing is safe: it holds no zone of its own and reads the\n * process's. It is also what the sites with no engine in hand use (the\n * normaliser rules that fuse a literal, `days in <period>`, the stocks and\n * historical-currency date phrases, and `formatValue`), which is why an\n * engine's own backend is the default here rather than a second copy.\n */\nexport const DATE_CALENDAR: CalendarBackend = new DateCalendar();\n\n/**\n * The backend a plugin function or converter should compute with: the one\n * on its execution context, or the `Date` backend when the handler was\n * called with no context (a direct call from a test, or an `as` converter\n * invoked outside the VM).\n *\n * @param context - The execution context the handler received, if any.\n * @returns The engine's backend when the context carries one, else {@link DATE_CALENDAR}.\n */\nexport function calendarOf(context?: { readonly calendar?: CalendarBackend }): CalendarBackend {\n\treturn context?.calendar ?? DATE_CALENDAR;\n}\n\n/**\n * The `Date` backend, computing in a named IANA zone instead of the host\n * process's.\n *\n * Every zone-free answer is inherited unchanged from {@link DateCalendar}:\n * `now()` is still the clock, `parseIso8601` still reads the two ECMAScript\n * spellings, and the four named-zone methods already took the zone as an\n * argument. What changes is what \"local\" means, which is exactly the set of\n * questions {@link CalendarBackend} says depends on a zone: which day an\n * instant falls on, what a wall-clock reading names, what a day or a month\n * later is, and what the offset from UTC is.\n *\n * Those are answered through `Intl`, the same data the base class already\n * reads named zones with, so the accuracy is the same and nothing new is\n * bundled. The one place it is a simplification is a wall clock that a\n * daylight-saving transition made ambiguous or non-existent (01:30 on a\n * spring-forward morning): {@link zonedWallClockToUtcMs} resolves it one way,\n * and a `Temporal` backend's `disambiguation: 'compatible'` may resolve it an\n * hour differently.\n */\n/**\n * An ISO 8601 date-time with a time of day and NO offset and no `Z`: the one\n * spelling whose instant depends on which zone reads it. Anchored at both\n * ends, so a date-only string and anything carrying an offset fall through to\n * the base class untouched.\n */\nconst ISO_LOCAL_DATE_TIME = /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d+))?)?$/;\n\nclass ZonedDateCalendar extends DateCalendar {\n\t/**\n\t * @param namedZone - An IANA zone name `Intl` accepts.\n\t */\n\tconstructor(private readonly namedZone: string) {\n\t\tsuper();\n\t}\n\n\tzone(): string {\n\t\treturn this.namedZone;\n\t}\n\n\tfields(epochMs: number): CalendarFields {\n\t\tconst f = zonedFields(this.namedZone, epochMs);\n\t\t// `zonedFields` answers no weekday and no millisecond: the weekday is a\n\t\t// pure function of the zoned date (`Gregorian.dayNumber`, counting from a\n\t\t// Thursday), and the millisecond is the instant's own, which no zone\n\t\t// offset in use is fractional enough to move.\n\t\tconst weekday = (((dayNumber(f.year, f.month0, f.day) + 4) % 7) + 7) % 7;\n\t\treturn {\n\t\t\tyear: f.year, month0: f.month0, day: f.day, weekday,\n\t\t\thour: f.hour, minute: f.minute, second: f.second,\n\t\t\tmillisecond: ((epochMs % 1000) + 1000) % 1000,\n\t\t};\n\t}\n\n\tlocalMidnight(year: number, month0: number, day: number): number {\n\t\treturn zonedWallClockToUtcMs(year, month0, day, 0, 0, this.namedZone, this);\n\t}\n\n\tlocalWallClock(year: number, month0: number, day: number, minutesPastMidnight: number): number {\n\t\t// The minutes go in as the MINUTE field, not as elapsed time, so a\n\t\t// reading of 540 is 09:00 on that date even on a 23-hour day. `Date.UTC`\n\t\t// rolls a minute field past 59 into the hour, which is what makes one\n\t\t// argument enough.\n\t\treturn zonedWallClockToUtcMs(year, month0, day, 0, minutesPastMidnight, this.namedZone, this);\n\t}\n\n\taddDays(epochMs: number, days: number): number {\n\t\tconst f = zonedFields(this.namedZone, epochMs);\n\t\treturn this.reanchor(f, f.day + days, epochMs);\n\t}\n\n\taddMonths(epochMs: number, months: number): number {\n\t\tconst f = zonedFields(this.namedZone, epochMs);\n\t\tconst target = new Date(Date.UTC(f.year, f.month0 + months, 1));\n\t\tconst clampedDay = Math.min(f.day, daysInMonth(target.getUTCFullYear(), target.getUTCMonth()));\n\t\treturn zonedWallClockToUtcMs(\n\t\t\ttarget.getUTCFullYear(), target.getUTCMonth(), clampedDay,\n\t\t\tf.hour, f.minute, this.namedZone, this,\n\t\t) + f.second * 1000 + (((epochMs % 1000) + 1000) % 1000);\n\t}\n\n\tutcOffsetMinutes(epochMs: number): number {\n\t\treturn this.zoneOffsetMinutes(this.namedZone, epochMs);\n\t}\n\n\tparseIso8601(text: string): number {\n\t\t// The one reading in that contract that depends on a zone: a date-time\n\t\t// with no offset and no `Z` is LOCAL time, and local here is the named\n\t\t// zone. Without this the backend contradicted itself, computing\n\t\t// `2026-04-03` at New York midnight while reading `2026-04-03T09:30` as\n\t\t// half past nine in the host process's zone. It is also what the\n\t\t// `Temporal` backend already does (`TemporalCalendar.parseIso8601`\n\t\t// resolves a bare wall clock in its own zone), so the two agree.\n\t\t//\n\t\t// Everything else is the base class byte for byte: a date-only string is\n\t\t// still UTC midnight and an explicit offset is still subtracted, both\n\t\t// frozen by the interface's contract.\n\t\tconst matched = ISO_LOCAL_DATE_TIME.exec(text.trim());\n\t\tif (matched === null) return super.parseIso8601(text);\n\t\tconst [, year, month, day, hour, minute, second, fraction] = matched;\n\t\tconst millisecond = fraction === undefined ? 0 : Number(fraction.slice(0, 3).padEnd(3, \"0\"));\n\t\treturn zonedWallClockToUtcMs(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute), this.namedZone, this)\n\t\t\t+ (second === undefined ? 0 : Number(second)) * 1000 + millisecond;\n\t}\n\n\tformatLongDate(epochMs: number, locale: string): string {\n\t\treturn longDateInZone(this.namedZone, epochMs, locale);\n\t}\n\n\tformatTimeOfDay(epochMs: number, locale: string): string {\n\t\treturn timeOfDayInZone(this.namedZone, epochMs, locale);\n\t}\n\n\t/** Rebuild an instant on a (possibly overflowed) day, holding its wall clock down to the millisecond. */\n\tprivate reanchor(f: ZonedFields, day: number, epochMs: number): number {\n\t\treturn zonedWallClockToUtcMs(f.year, f.month0, day, f.hour, f.minute, this.namedZone, this)\n\t\t\t+ f.second * 1000 + (((epochMs % 1000) + 1000) % 1000);\n\t}\n}\n\n/**\n * A `Date` backend that computes in a named time zone rather than the host\n * process's.\n *\n * This is how a host pins the zone the engine reads dates in, and it is the\n * only knob for it: the zone belongs to the calendar backend, which already\n * owns what \"local\" means, so there is deliberately no `date.zone` config\n * field to drift against it.\n *\n * ```ts\n * import { createEngine, dateCalendarInZone } from \"solve-engine\";\n * const engine = createEngine({ calendar: dateCalendarInZone(\"Asia/Tokyo\") });\n * ```\n *\n * It ships on the `Date` backend on purpose. `Temporal` is undefined on Node\n * 24 and in Safari, so \"pass a `Temporal` backend\" would put the zone out of\n * reach for most hosts today; `Temporal` stays an accuracy upgrade for the\n * ambiguous wall clocks around a daylight-saving transition, never a\n * prerequisite for naming a zone at all.\n *\n * @param zone - An IANA zone name, e.g. `\"Asia/Tokyo\"`.\n * @returns A backend whose local zone is that one.\n * @throws A `DATE_ZONE_UNKNOWN` config error when this runtime's `Intl` does\n * not know the zone. Refused here rather than per line, because a backend\n * that cannot compute in the zone it was asked for must not quietly answer\n * in another one.\n */\nexport function dateCalendarInZone(zone: string): CalendarBackend {\n\tif (!isSupportedZone(zone)) {\n\t\tthrow ErrorFactory.config(\n\t\t\tDatetimeErrorCodes.DATE_ZONE_UNKNOWN,\n\t\t\t`dateCalendarInZone(\"${zone}\") is not a time zone this runtime knows.`,\n\t\t);\n\t}\n\treturn new ZonedDateCalendar(zone);\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkOBZJKZ2F_cjs=require('./chunk-OBZJKZ2F.cjs'),chunkSF5QVUEI_cjs=require('./chunk-SF5QVUEI.cjs'),chunkWFT3XUSH_cjs=require('./chunk-WFT3XUSH.cjs'),chunkEQNKDTMX_cjs=require('./chunk-EQNKDTMX.cjs'),chunkS3SPDK6N_cjs=require('./chunk-S3SPDK6N.cjs'),chunkPHWIO4P3_cjs=require('./chunk-PHWIO4P3.cjs'),chunkEZKR44MA_cjs=require('./chunk-EZKR44MA.cjs'),chunk6SYU4MH7_cjs=require('./chunk-6SYU4MH7.cjs');function Xt(e,t){let n=t===2?chunkWFT3XUSH_cjs.L:chunkWFT3XUSH_cjs.M,o=n(e.n),r=n(e.d);return o===null||r===null?null:{n:o,d:r}}function Zt(e,t){let n=chunkWFT3XUSH_cjs.y(e),o=new Map;for(let[r,i]of n){if(i%t!==0)return null;o.set(r,i/t);}return chunkWFT3XUSH_cjs.x(o)}function Wn(e,t){let n=chunkWFT3XUSH_cjs.y(e);for(let[o,r]of chunkWFT3XUSH_cjs.y(t))n.set(o,(n.get(o)??0)+r);return chunkWFT3XUSH_cjs.x(n)}function Ht(e,t){let n=chunkWFT3XUSH_cjs.y(e);for(let[o,r]of chunkWFT3XUSH_cjs.y(t)){let i=(n.get(o)??0)-r;i<=0?n.delete(o):n.set(o,i);}return chunkWFT3XUSH_cjs.x(n)}function Qn(e,t){let n=chunkWFT3XUSH_cjs.y(e),o=new Map;for(let[r,i]of chunkWFT3XUSH_cjs.y(t)){let a=n.get(r);a!==void 0&&o.set(r,Math.min(a,i));}return chunkWFT3XUSH_cjs.x(o)}function zn(e){let t=new Set;for(let n of e)for(let o of chunkWFT3XUSH_cjs.y(n).keys())t.add(o);return [...t].sort()}function Q(e){let t=new Map;for(let n of e)t.set(n.key,n.coefficient);return chunkWFT3XUSH_cjs.E({terms:t,vars:zn(e.map(n=>n.key))})}function We(e){let t=e[0];for(let n=1;n<e.length;n++)t={kind:"mul",left:t,right:e[n]};return t}function Jn(e){return [...e.terms].map(([n,o])=>({key:n,coefficient:o})).sort((n,o)=>chunkWFT3XUSH_cjs.D(n.key,o.key,e.vars))}function zt(e){if(e.vars.length<2)return null;let t=Jn(e);return t.length===2?eo(t[0],t[1]):t.length===3?to(t):t.length===4?no(t):null}function eo(e,t){let n=e.coefficient.n>0n,o=t.coefficient.n>0n;if(!n)return null;let r=Qe(e,t,2);if(r!==null&&!o)return We([Q([r.a,Te(r.b)]),Q([r.a,r.b])]);let i=Qe(e,t,3);if(i===null)return null;let a=Q(o?[i.a,i.b]:[i.a,Te(i.b)]),u=o?Te(Ve(i.a,i.b)):Ve(i.a,i.b);return We([a,Q([Wt(i.a),u,Wt(i.b)])])}function Qe(e,t,n){let o=t.coefficient.n<0n?chunkWFT3XUSH_cjs.j(t.coefficient):t.coefficient,r=Xt(e.coefficient,n),i=Xt(o,n);if(r===null||i===null)return null;let a=Zt(e.key,n),u=Zt(t.key,n);return a===null||u===null?null:{a:{key:a,coefficient:r},b:{key:u,coefficient:i}}}function Te(e){return {key:e.key,coefficient:chunkWFT3XUSH_cjs.j(e.coefficient)}}function Ve(e,t){return {key:Wn(e.key,t.key),coefficient:chunkWFT3XUSH_cjs.h(e.coefficient,t.coefficient)}}function Wt(e){return Ve(e,e)}function to(e){let[t,n,o]=e;if(t.coefficient.n<0n||o.coefficient.n<0n)return null;let r=Qe(t,o,2);if(r===null)return null;let i=Ve(r.a,r.b);if(i.key!==n.key)return null;let a=chunkWFT3XUSH_cjs.h(i.coefficient,{n:2n,d:1n}),u=n.coefficient.n<0n,l=u?chunkWFT3XUSH_cjs.j(n.coefficient):n.coefficient;return chunkWFT3XUSH_cjs.m(chunkWFT3XUSH_cjs.i(l,a))?{kind:"pow",base:Q([r.a,u?Te(r.b):r.b]),exponent:chunkWFT3XUSH_cjs.p(2)}:null}function no(e){let t=[[[0,1],[2,3]],[[0,2],[1,3]],[[0,3],[1,2]]];for(let n of t){let o=Qt(e[n[0][0]],e[n[0][1]]),r=Qt(e[n[1][0]],e[n[1][1]]);if(!(o===null||r===null)&&oo(o.cofactor,r.cofactor))return We([Q([o.common,r.common]),Q(o.cofactor)])}return null}function Qt(e,t){let n=Qn(e.key,t.key),o={key:n,coefficient:e.coefficient},r=[{key:Ht(e.key,n),coefficient:{n:1n,d:1n}},{key:Ht(t.key,n),coefficient:chunkWFT3XUSH_cjs.i(t.coefficient,e.coefficient)}];return r[0].key===r[1].key?null:{common:o,cofactor:r}}function oo(e,t){return e.length!==t.length?false:e.every((n,o)=>n.key===t[o].key&&n.coefficient.n===t[o].coefficient.n&&n.coefficient.d===t[o].coefficient.d)}var ro=12,we=4096;function Oe(e,t){let n=e<0n?-e:e,o=t<0n?-t:t;for(;o!==0n;){let r=n%o;n=o,o=r;}return n}function en(e,t){return e===0n||t===0n?0n:e/Oe(e,t)*t}function Jt(e){let t=e<0n?-e:e;if(t===0n)return null;let n=[];for(let o=1n;o*o<=t;o++){if(t%o!==0n)continue;n.push(o);let r=t/o;if(r!==o&&n.push(r),n.length>we)return null}return n}function tn(e,t){let n=chunkWFT3XUSH_cjs.a;for(let o of e)n=chunkWFT3XUSH_cjs.f(chunkWFT3XUSH_cjs.h(n,t),o);return n}function io(e,t){let n=[e[0]];for(let o=1;o<e.length-1;o++)n.push(chunkWFT3XUSH_cjs.f(e[o],chunkWFT3XUSH_cjs.h(n[o-1],t)));return n}function ue(e){if(e.length<2)return [];let t=1n;for(let s of e)t=en(t,s.d);let n=e.map(s=>s.n*t/s.d),o=n[0],r=n[n.length-1];if(r===0n)return [];let i=Jt(r),a=Jt(o);if(i===null||a===null)throw chunk6SYU4MH7_cjs.c.execution("SYMBOLIC_FACTOR_LIMIT_EXCEEDED","This polynomial's coefficients have too many divisors to search for rational roots.",{limit:we});if(i.length*a.length>we)throw chunk6SYU4MH7_cjs.c.execution("SYMBOLIC_FACTOR_LIMIT_EXCEEDED","This polynomial has too many candidate rational roots to test.",{limit:we});let u=[],l=new Set;for(let s of i)for(let p of a)for(let h of [1n,-1n]){let x={n:h*s/Oe(s,p),d:p/Oe(s,p)},T=`${x.n}/${x.d}`;l.has(T)||(l.add(T),chunkWFT3XUSH_cjs.l(tn(e,x))&&u.push(x));}return u}function ao(e,t){return chunkWFT3XUSH_cjs.l(t)?chunkWFT3XUSH_cjs.q(e):t.n>0n?{kind:"sub",left:chunkWFT3XUSH_cjs.q(e),right:chunkWFT3XUSH_cjs.p(t)}:{kind:"add",left:chunkWFT3XUSH_cjs.q(e),right:chunkWFT3XUSH_cjs.p(chunkWFT3XUSH_cjs.j(t))}}function uo(e,t){let n=e.length-1,o=new Map;return e.forEach((r,i)=>{if(chunkWFT3XUSH_cjs.l(r))return;let a=n-i;o.set(a===0?"":a===1?t:`${t}^${a}`,r);}),chunkWFT3XUSH_cjs.E({terms:o,vars:o.size>0?[t]:[]})}function Je(e,t){let n=[],o=[...e],r=ue(o);for(;r.length>0&&o.length>2;){for(let a of r){let u=0;for(;o.length>1&&chunkWFT3XUSH_cjs.l(tn(o,a));)o=io(o,a),u++;u>0&&n.push({base:ao(t,a),power:u});}r=o.length>2?ue(o):[];}return o.length-1>=1?(n.push({base:uo(o,t),power:1}),{content:chunkWFT3XUSH_cjs.b,factors:n}):{content:o.length===1?o[0]:chunkWFT3XUSH_cjs.b,factors:n}}function lo(e){let t=[];chunkWFT3XUSH_cjs.m(e.content)||t.push(chunkWFT3XUSH_cjs.p(e.content));for(let o of e.factors)t.push(o.power===1?o.base:chunkWFT3XUSH_cjs.r(o.base,chunkWFT3XUSH_cjs.p({n:BigInt(o.power),d:1n})));if(t.length===0)return chunkWFT3XUSH_cjs.p(chunkWFT3XUSH_cjs.b);let n=t[0];for(let o=1;o<t.length;o++)n={kind:"mul",left:n,right:t[o]};return n}function so(e){let t=0n,n=1n;for(let o of e.terms.values())t=Oe(t,o.n),n=en(n,o.d);return t===0n?chunkWFT3XUSH_cjs.b:{n:t,d:n}}function co(e){let t=new Map;for(let r of e.vars){let i=1/0;for(let a of e.terms.keys()){let u=mo(a,r);u<i&&(i=u);}i>0&&i!==1/0&&t.set(r,i);}if(t.size===0)return {monomial:t,reduced:e};let n=new Map;for(let[r,i]of e.terms){let a=ze(r);for(let[u,l]of t)a.set(u,(a.get(u)??0)-l);n.set(fo(a),i);}let o=new Set;for(let r of n.keys())for(let i of ze(r).keys())o.add(i);return {monomial:t,reduced:{terms:n,vars:[...o].sort()}}}function mo(e,t){return ze(e).get(t)??0}function ze(e){let t=new Map;if(e==="")return t;for(let n of e.split("*")){let o=n.indexOf("^");o===-1?t.set(n,1):t.set(n.slice(0,o),Number(n.slice(o+1)));}return t}function fo(e){return [...e.keys()].filter(n=>(e.get(n)??0)>0).sort().map(n=>e.get(n)===1?n:`${n}^${e.get(n)}`).join("*")}function po(e){let t=[...e.keys()].sort(),n=null;for(let o of t){let r=e.get(o),i=r===1?chunkWFT3XUSH_cjs.q(o):chunkWFT3XUSH_cjs.r(chunkWFT3XUSH_cjs.q(o),chunkWFT3XUSH_cjs.p({n:BigInt(r),d:1n}));n=n===null?i:{kind:"mul",left:n,right:i};}return n}function nn(e){let t=chunkWFT3XUSH_cjs.C(e);if(t===null||t.terms.size===0||chunkWFT3XUSH_cjs.z(t)>ro||t.vars.length===0)return e;let n=so(t),o=chunkWFT3XUSH_cjs.m(n)?t:bo(t,chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.b,n)),{monomial:r,reduced:i}=co(o),a=po(r),u=chunkWFT3XUSH_cjs.A(i);if(u===null){let te=zt(i);return te!==null?yo(n,a,te):ho(n,a,i)??e}let l=[...chunkWFT3XUSH_cjs.B(i,u)].reverse(),s=Je(l,u),p=chunkWFT3XUSH_cjs.h(n,s.content);if(s.factors.length<=1&&(s.factors[0]?.power??1)===1&&a===null&&chunkWFT3XUSH_cjs.m(p))return e;let x=[];chunkWFT3XUSH_cjs.m(p)||x.push(chunkWFT3XUSH_cjs.p(p)),a!==null&&x.push(a),x.push(lo({content:chunkWFT3XUSH_cjs.b,factors:s.factors}));let T=x[0];for(let te=1;te<x.length;te++)T={kind:"mul",left:T,right:x[te]};return T}function bo(e,t){let n=new Map;for(let[o,r]of e.terms)n.set(o,chunkWFT3XUSH_cjs.h(r,t));return {terms:n,vars:e.vars}}function yo(e,t,n){let o=[];chunkWFT3XUSH_cjs.m(e)||o.push(chunkWFT3XUSH_cjs.p(e)),t!==null&&o.push(t),o.push(n);let r=o[0];for(let i=1;i<o.length;i++)r={kind:"mul",left:r,right:o[i]};return r}function ho(e,t,n){if(t===null&&chunkWFT3XUSH_cjs.m(e))return null;let o=[];chunkWFT3XUSH_cjs.m(e)||o.push(chunkWFT3XUSH_cjs.p(e)),t!==null&&o.push(t),o.push(chunkWFT3XUSH_cjs.E(n));let r=o[0];for(let i=1;i<o.length;i++)r={kind:"mul",left:r,right:o[i]};return r}var _={n:2n,d:1n},B={n:3n,d:1n},be={n:4n,d:1n};function No(e,t,n,o){let r=chunkWFT3XUSH_cjs.j(chunkWFT3XUSH_cjs.i(t,chunkWFT3XUSH_cjs.h(B,e))),i=chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.g(chunkWFT3XUSH_cjs.h(B,chunkWFT3XUSH_cjs.h(e,n)),chunkWFT3XUSH_cjs.h(t,t)),chunkWFT3XUSH_cjs.h(B,chunkWFT3XUSH_cjs.h(e,e))),a=chunkWFT3XUSH_cjs.h(_,chunkWFT3XUSH_cjs.h(t,chunkWFT3XUSH_cjs.h(t,t))),u=chunkWFT3XUSH_cjs.h({n:9n,d:1n},chunkWFT3XUSH_cjs.h(e,chunkWFT3XUSH_cjs.h(t,n))),l=chunkWFT3XUSH_cjs.h({n:27n,d:1n},chunkWFT3XUSH_cjs.h(chunkWFT3XUSH_cjs.h(e,e),o)),s=chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.f(chunkWFT3XUSH_cjs.g(a,u),l),chunkWFT3XUSH_cjs.h({n:27n,d:1n},chunkWFT3XUSH_cjs.h(e,chunkWFT3XUSH_cjs.h(e,e))));return {p:i,q:s,shift:r}}function rn(e,t,n,o){let{p:r,q:i,shift:a}=No(e,t,n,o),u=chunkWFT3XUSH_cjs.j(chunkWFT3XUSH_cjs.f(chunkWFT3XUSH_cjs.h(be,chunkWFT3XUSH_cjs.h(r,chunkWFT3XUSH_cjs.h(r,r))),chunkWFT3XUSH_cjs.h({n:27n,d:1n},chunkWFT3XUSH_cjs.h(i,i))));return chunkWFT3XUSH_cjs.k(u,chunkWFT3XUSH_cjs.a)>0?{exact:[],approximate:Ao(r,i,a)}:chunkWFT3XUSH_cjs.l(u)?{exact:go(r,i,a),approximate:[]}:{exact:Ro(r,i,a),approximate:[]}}function go(e,t,n){if(chunkWFT3XUSH_cjs.l(e))return [chunkWFT3XUSH_cjs.p(n)];let o=chunkWFT3XUSH_cjs.f(chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.h(B,t),e),n),r=chunkWFT3XUSH_cjs.f(chunkWFT3XUSH_cjs.j(chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.h(B,t),chunkWFT3XUSH_cjs.h(_,e))),n);return [o,r].sort(chunkWFT3XUSH_cjs.k).map(chunkWFT3XUSH_cjs.p)}function Ro(e,t,n){let o=chunkWFT3XUSH_cjs.j(chunkWFT3XUSH_cjs.i(t,_)),r=chunkWFT3XUSH_cjs.f(chunkWFT3XUSH_cjs.h(chunkWFT3XUSH_cjs.i(t,_),chunkWFT3XUSH_cjs.i(t,_)),chunkWFT3XUSH_cjs.h(chunkWFT3XUSH_cjs.i(e,B),chunkWFT3XUSH_cjs.h(chunkWFT3XUSH_cjs.i(e,B),chunkWFT3XUSH_cjs.i(e,B)))),i=chunkWFT3XUSH_cjs.O(r),a={kind:"call",name:"cbrt",args:[{kind:"add",left:chunkWFT3XUSH_cjs.p(o),right:i}]},u={kind:"call",name:"cbrt",args:[{kind:"sub",left:chunkWFT3XUSH_cjs.p(o),right:i}]},l={kind:"add",left:a,right:u},s={kind:"sub",left:a,right:u},p={kind:"add",left:chunkWFT3XUSH_cjs.p(n),right:{kind:"div",left:{kind:"neg",operand:l},right:chunkWFT3XUSH_cjs.p(_)}},h={kind:"mul",left:{kind:"div",left:{kind:"mul",left:s,right:chunkWFT3XUSH_cjs.O(B)},right:chunkWFT3XUSH_cjs.p(_)},right:chunkWFT3XUSH_cjs.w(chunkWFT3XUSH_cjs.n)};return [{kind:"add",left:chunkWFT3XUSH_cjs.p(n),right:l},{kind:"sub",left:p,right:h},{kind:"add",left:p,right:h}]}function Ao(e,t,n){let o=chunkWFT3XUSH_cjs.e(e),r=chunkWFT3XUSH_cjs.e(t),i=chunkWFT3XUSH_cjs.e(n),a=2*Math.sqrt(-o/3),u=3*r/(2*o)*Math.sqrt(-3/o),l=Math.acos(Math.min(1,Math.max(-1,u)))/3;return [0,1,2].map(s=>a*Math.cos(l-2*Math.PI*s/3)+i).sort((s,p)=>s-p)}function xo(e,t,n,o){let r=chunkWFT3XUSH_cjs.j(chunkWFT3XUSH_cjs.i(e,be)),i=chunkWFT3XUSH_cjs.h(e,e),a=chunkWFT3XUSH_cjs.g(t,chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.h(B,i),{n:8n,d:1n})),u=chunkWFT3XUSH_cjs.f(chunkWFT3XUSH_cjs.g(n,chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.h(e,t),_)),chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.h(i,e),{n:8n,d:1n})),l=chunkWFT3XUSH_cjs.g(chunkWFT3XUSH_cjs.f(chunkWFT3XUSH_cjs.g(o,chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.h(e,n),be)),chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.h(i,t),{n:16n,d:1n})),chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.h(B,chunkWFT3XUSH_cjs.h(i,i)),{n:256n,d:1n}));return {p:a,q:u,r:l,shift:r}}function an(e,t,n,o,r,i){let a=T=>chunkWFT3XUSH_cjs.i(T,e),{p:u,q:l,r:s,shift:p}=xo(a(t),a(n),a(o),a(r)),h=chunkWFT3XUSH_cjs.l(l)?Mo(u,s):ko(u,l,s,i);if(h===null)return null;let x=chunkWFT3XUSH_cjs.l(p)?h:h.map(T=>({kind:"add",left:chunkWFT3XUSH_cjs.p(p),right:T}));return {exact:vo(x),approximate:[]}}function vo(e){let t=new Set,n=[];for(let o of e){let r=chunkWFT3XUSH_cjs.t(chunkWFT3XUSH_cjs.Q(o));t.has(r)||(t.add(r),n.push(o));}return n}function Mo(e,t){let n=chunkWFT3XUSH_cjs.g(chunkWFT3XUSH_cjs.h(e,e),chunkWFT3XUSH_cjs.h(be,t));if(chunkWFT3XUSH_cjs.k(n,chunkWFT3XUSH_cjs.a)<0)return So(e,t);let o=chunkWFT3XUSH_cjs.N(n);return o!==null?Io(chunkWFT3XUSH_cjs.j(e),o,chunkWFT3XUSH_cjs.l(n)):Eo(e,t,n)}function Io(e,t,n){let o=n?[chunkWFT3XUSH_cjs.i(e,_)]:[chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.f(e,t),_),chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.g(e,t),_)],r=[];for(let i of o){if(chunkWFT3XUSH_cjs.l(i)){r.push(chunkWFT3XUSH_cjs.p(chunkWFT3XUSH_cjs.a));continue}let a=chunkWFT3XUSH_cjs.P(i);r.push({kind:"neg",operand:a},a);}return r}function Eo(e,t,n){let o=chunkWFT3XUSH_cjs.p(chunkWFT3XUSH_cjs.j(e)),r=chunkWFT3XUSH_cjs.O(n),i=chunkWFT3XUSH_cjs.k(e,chunkWFT3XUSH_cjs.a)<=0,a=[{node:et({kind:"add",left:o,right:r}),positive:i||chunkWFT3XUSH_cjs.k(t,chunkWFT3XUSH_cjs.a)<=0},{node:et({kind:"sub",left:o,right:r}),positive:i&&chunkWFT3XUSH_cjs.k(t,chunkWFT3XUSH_cjs.a)>=0}],u=[];for(let{node:l,positive:s}of a){let h={kind:"call",name:"sqrt",args:[s?l:{kind:"neg",operand:l}]},x=s?h:{kind:"mul",left:h,right:chunkWFT3XUSH_cjs.w(chunkWFT3XUSH_cjs.n)};u.push({kind:"neg",operand:x},x);}return u}function et(e){return {kind:"div",left:e,right:chunkWFT3XUSH_cjs.p(_)}}function So(e,t){let n=chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.j(e),_),o=chunkWFT3XUSH_cjs.N(t),r=o===null?on(chunkWFT3XUSH_cjs.O(t),n):chunkWFT3XUSH_cjs.O(chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.f(o,n),_)),a={kind:"mul",left:o===null?on(chunkWFT3XUSH_cjs.O(t),chunkWFT3XUSH_cjs.j(n)):chunkWFT3XUSH_cjs.O(chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.g(o,n),_)),right:chunkWFT3XUSH_cjs.w(chunkWFT3XUSH_cjs.n)},u={kind:"add",left:r,right:a},l={kind:"sub",left:r,right:a};return [{kind:"neg",operand:u},{kind:"neg",operand:l},l,u]}function on(e,t){let n=t.n>=0n?{kind:"add",left:e,right:chunkWFT3XUSH_cjs.p(t)}:{kind:"sub",left:e,right:chunkWFT3XUSH_cjs.p(chunkWFT3XUSH_cjs.j(t))};return {kind:"call",name:"sqrt",args:[et(n)]}}function ko(e,t,n,o){let r=[{n:1n,d:1n},chunkWFT3XUSH_cjs.h(_,e),chunkWFT3XUSH_cjs.g(chunkWFT3XUSH_cjs.h(e,e),chunkWFT3XUSH_cjs.h(be,n)),chunkWFT3XUSH_cjs.j(chunkWFT3XUSH_cjs.h(t,t))];for(let i of ue(r)){if(chunkWFT3XUSH_cjs.k(i,chunkWFT3XUSH_cjs.a)<=0)continue;let a=chunkWFT3XUSH_cjs.N(i);if(a===null)continue;let u=chunkWFT3XUSH_cjs.f(e,i),l=chunkWFT3XUSH_cjs.i(t,a),s=chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.g(u,l),_),p=chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.f(u,l),_),h={n:1n,d:1n};return [...o(h,a,s),...o(h,chunkWFT3XUSH_cjs.j(a),p)]}return null}var _o=200,To=1e-14,Vo=1e-10,wo=1e-10,un=1e-9,Oo=1e-8,Co=4;function ye(e,t){return {re:e.re-t.re,im:e.im-t.im}}function Do(e,t){return {re:e.re*t.re-e.im*t.im,im:e.re*t.im+e.im*t.re}}function sn(e,t){if(Math.abs(t.re)>=Math.abs(t.im)){let r=t.im/t.re,i=t.re+t.im*r;return {re:(e.re+e.im*r)/i,im:(e.im-e.re*r)/i}}let n=t.re/t.im,o=t.re*n+t.im;return {re:(e.re*n+e.im)/o,im:(e.im*n-e.re)/o}}function K(e){return Math.hypot(e.re,e.im)}function Ce(e,t){let n=0,o=0;for(let r of e){let i=n*t.re-o*t.im+r;o=n*t.im+o*t.re,n=i;}return {re:n,im:o}}function Po(e,t){let n=K(t),o=0;for(let r of e)o=o*n+Math.abs(r);return o}function Lo(e){let t=e.length-1,n=[];for(let o=0;o<t;o++)n.push(e[o]*(t-o));return n}function Fo(e){let t=[...e].reverse(),o=[...chunkWFT3XUSH_cjs.K(t)].reverse().map(chunkWFT3XUSH_cjs.e);return o.some(r=>!Number.isFinite(r))?null:o}function Uo(e){let t=e.length-1,n=0;for(let a=1;a<e.length;a++)n=Math.max(n,Math.abs(e[a]));let o=1+n,r=-e[1]/t,i=[];for(let a=0;a<t;a++){let u=2*Math.PI*a/t+Math.PI/(2*t);i.push({re:r+o*Math.cos(u),im:o*Math.sin(u)});}return i}function $o(e){let t=e.length-1,n=Uo(e);for(let o=0;o<_o;o++){let r=0,i=1;for(let a=0;a<t;a++){let u={re:1,im:0};for(let s=0;s<t;s++)a!==s&&(u=Do(u,ye(n[a],n[s])));if(u.re===0&&u.im===0){n[a]={re:n[a].re+1e-6*(a+1),im:n[a].im+1e-6};continue}let l=sn(Ce(e,n[a]),u);if(!Number.isFinite(l.re)||!Number.isFinite(l.im))return null;n[a]=ye(n[a],l),r=Math.max(r,K(l)),i=Math.max(i,K(n[a]));}if(r<=To*i)return n}return null}function ln(e,t,n){let o=n;for(let r=0;r<Co;r++){let i=Ce(t,o);if(i.re===0&&i.im===0)break;let a=ye(o,sn(Ce(e,o),i));if(!Number.isFinite(a.re)||!Number.isFinite(a.im))break;o=a;}return o}function Bo(e,t,n){let o=Math.max(1,K(n));if(n.im!==0&&Math.abs(n.im)<=un*o){let r=ln(e,t,{re:n.re,im:0});if(tt(e,r))return {re:r.re,im:0}}if(n.re!==0&&Math.abs(n.re)<=un*o){let r=ln(e,t,{re:0,im:n.im});if(tt(e,r))return {re:0,im:r.im}}return n}function tt(e,t){return !Number.isFinite(t.re)||!Number.isFinite(t.im)?false:K(Ce(e,t))<=Vo*Po(e,t)}function qo(e){let t=[...e],n=t.map(o=>o.im===0);for(let o=0;o<t.length;o++){if(n[o])continue;let r={re:t[o].re,im:-t[o].im},i=-1,a=Number.POSITIVE_INFINITY;for(let p=o+1;p<t.length;p++){if(n[p])continue;let h=K(ye(t[p],r));h<a&&(a=h,i=p);}if(i===-1||a>Oo*Math.max(1,K(t[o])))continue;let u=(t[o].re+t[i].re)/2,l=(Math.abs(t[o].im)+Math.abs(t[i].im))/2,s=t[o].im<0?-1:1;t[o]={re:u,im:s*l},t[i]={re:u,im:-s*l},n[o]=true,n[i]=true;}return t}function Yo(e){for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++){let o=Math.max(1,K(e[t]),K(e[n]));if(K(ye(e[t],e[n]))<=wo*o)return false}return true}function cn(e){let t=Fo(e);if(t===null)return null;if(t.length<2)return [];let n=$o(t);if(n===null)return null;let o=Lo(t),r=qo(n).map(i=>Bo(t,o,i));for(let i of r)if(!tt(t,i))return null;return Yo(r)?[...r].sort((i,a)=>i.re-a.re||i.im-a.im):null}var mn=8;function Go(e,t){let n=chunkWFT3XUSH_cjs.a;for(let o of e)n=chunkWFT3XUSH_cjs.f(chunkWFT3XUSH_cjs.h(n,t),o);return n}function jo(e,t){let n=[e[0]];for(let o=1;o<e.length-1;o++)n.push(chunkWFT3XUSH_cjs.f(e[o],chunkWFT3XUSH_cjs.h(n[o-1],t)));return n}function fn(e,t,n){let o=chunkWFT3XUSH_cjs.g(chunkWFT3XUSH_cjs.h(t,t),chunkWFT3XUSH_cjs.h(Zo(),chunkWFT3XUSH_cjs.h(e,n))),r=chunkWFT3XUSH_cjs.h(Xo(),e);if(chunkWFT3XUSH_cjs.k(o,chunkWFT3XUSH_cjs.a)<0)return Ko(chunkWFT3XUSH_cjs.j(t),o,r);if(chunkWFT3XUSH_cjs.l(o))return [chunkWFT3XUSH_cjs.p(chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.j(t),r))];let i=chunkWFT3XUSH_cjs.L(o.n),a=chunkWFT3XUSH_cjs.L(o.d);if(i!==null&&a!==null){let h={n:i,d:a},x=chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.f(chunkWFT3XUSH_cjs.j(t),h),r),T=chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.g(chunkWFT3XUSH_cjs.j(t),h),r);return chunkWFT3XUSH_cjs.k(T,x)<=0?[chunkWFT3XUSH_cjs.p(T),chunkWFT3XUSH_cjs.p(x)]:[chunkWFT3XUSH_cjs.p(x),chunkWFT3XUSH_cjs.p(T)]}let u=chunkWFT3XUSH_cjs.O(o),l=chunkWFT3XUSH_cjs.k(r,chunkWFT3XUSH_cjs.a)>0,s={kind:"div",left:{kind:"sub",left:chunkWFT3XUSH_cjs.p(chunkWFT3XUSH_cjs.j(t)),right:u},right:chunkWFT3XUSH_cjs.p(r)},p={kind:"div",left:{kind:"add",left:chunkWFT3XUSH_cjs.p(chunkWFT3XUSH_cjs.j(t)),right:u},right:chunkWFT3XUSH_cjs.p(r)};return l?[s,p]:[p,s]}function Ko(e,t,n){let o=chunkWFT3XUSH_cjs.j(t),r=chunkWFT3XUSH_cjs.L(o.n),i=chunkWFT3XUSH_cjs.L(o.d);if(r!==null&&i!==null){let s=chunkWFT3XUSH_cjs.i({n:r,d:i},n),p=chunkWFT3XUSH_cjs.i(e,n);return [chunkWFT3XUSH_cjs.w(chunkWFT3XUSH_cjs.o(p,chunkWFT3XUSH_cjs.j(s))),chunkWFT3XUSH_cjs.w(chunkWFT3XUSH_cjs.o(p,s))]}let a=chunkWFT3XUSH_cjs.i(e,n),u=chunkWFT3XUSH_cjs.i(o,chunkWFT3XUSH_cjs.h(n,n)),l={kind:"mul",left:chunkWFT3XUSH_cjs.O(u),right:chunkWFT3XUSH_cjs.w(chunkWFT3XUSH_cjs.n)};return chunkWFT3XUSH_cjs.l(a)?[{kind:"neg",operand:l},l]:[{kind:"sub",left:chunkWFT3XUSH_cjs.p(a),right:l},{kind:"add",left:chunkWFT3XUSH_cjs.p(a),right:l}]}function Xo(){return {n:2n,d:1n}}function Zo(){return {n:4n,d:1n}}function Ho(e){return {re:e,im:0}}function dn(e,t,n){let o=chunkWFT3XUSH_cjs.C({kind:"sub",left:e,right:t});if(o===null)return {kind:"unsupported",reason:"this is not a polynomial equation (it divides by an unknown, or calls a function of one)"};let r=o.vars.filter(u=>u!==n),i=chunkWFT3XUSH_cjs.z(o,n);if(r.length>0)return i!==1?{kind:"unsupported",reason:`solving for "${n}" needs the equation to be linear in it when other unknowns (${r.join(", ")}) are present`}:Wo(o,n);if(i===0)return o.terms.size===0?{kind:"identity"}:{kind:"contradiction"};if(i>mn)return {kind:"unsupported",reason:`degree ${i} is above the supported maximum of ${mn}`};let a=[...chunkWFT3XUSH_cjs.B(o,n)].reverse();return Jo(a)}function Wo(e,t){let n=new Map,o=new Map;for(let[u,l]of e.terms){let s=u.split("*").filter(h=>h.length>0),p=s.indexOf(t);p===-1?o.set(u,l):(s.splice(p,1),n.set(s.join("*"),l));}let r=u=>{let l=new Set;for(let s of u.keys())for(let p of s.split("*"))p.length>0&&l.add(p.split("^")[0]);return [...l].sort()},i=chunkWFT3XUSH_cjs.E({terms:n,vars:r(n)});return {kind:"roots",exact:[{kind:"div",left:{kind:"neg",operand:chunkWFT3XUSH_cjs.E({terms:o,vars:r(o)})},right:i}],approximate:[]}}function Qo(e){return e.length===4?rn(e[0],e[1],e[2],e[3]):e.length===5?an(e[0],e[1],e[2],e[3],e[4],fn):null}function zo(e){let t=[],n=[...e],o=0;for(;n.length>1&&chunkWFT3XUSH_cjs.l(n[n.length-1]);)n=n.slice(0,-1),o++;for(o>0&&t.push(chunkWFT3XUSH_cjs.a);n.length>1;){let r=ue(n);if(r.length===0)break;for(let i of r){let a=0;for(;n.length>1&&chunkWFT3XUSH_cjs.l(Go(n,i));)n=jo(n,i),a++;a>0&&t.push(i);}}return {roots:t.sort(chunkWFT3XUSH_cjs.k),remaining:n}}function Jo(e){let{roots:t,remaining:n}=zo(e),o=t.map(chunkWFT3XUSH_cjs.p),r=[],i=n.length-1,a=e.length-n.length;if(i<=0)return le(o,r,a,0,"");if(i===1)return o.push(chunkWFT3XUSH_cjs.p(chunkWFT3XUSH_cjs.i(chunkWFT3XUSH_cjs.j(n[1]),n[0]))),le(o,r,a+1,0,"");if(i===2)return o.push(...fn(n[0],n[1],n[2])),le(o,r,a+2,0,"");let u=Qo(n);if(u!==null)return o.push(...u.exact),r.push(...u.approximate.map(Ho)),le(o,r,a+i,0,"");let l=cn(n);return l!==null?(r.push(...l),le(o,r,a+i,0,"")):le(o,r,a,i,`a degree-${i} factor of it has no exact solution here and the numerical method did not converge on that factor`)}function le(e,t,n,o,r){let i=e.length+t.length,a=n>=1&&(i<1||i>n);return o>0||a?{kind:"incomplete",exact:e,approximate:t,missing:a?Math.max(1,n+o-i):o,reason:a?`${i} root${i===1?"":"s"} were produced for a degree-${n+o} equation, which does not add up`:r}:{kind:"roots",exact:e,approximate:t}}var pn={0:"sqrt",1:"abs",2:"sin",3:"cos",4:"tan",5:"log",6:"ceil",7:"floor",8:"round",11:"asin",12:"acos",13:"atan",14:"atan2",15:"sinh",16:"cosh",17:"tanh",18:"asinh",19:"acosh",20:"atanh",21:"cbrt",23:"expm1",24:"exp",26:"hypot",28:"log10",29:"log1p",30:"log2",33:"sign",34:"trunc",35:"degtorad",36:"radtodeg",61:"root",62:"fact"},er=31,ki=new Set([67,68,69,70,71,72,73,74,75,76,77,78,79]);function V(e){if(e.type===9)return e.value;if(e.type===13||e.type===12)return null;let t=e.toNumber();return Number.isFinite(t)?chunkWFT3XUSH_cjs.p(chunkWFT3XUSH_cjs.d(t)):null}function w(e){let t=chunkWFT3XUSH_cjs.Q(e);return t.kind==="const"?chunkS3SPDK6N_cjs.n(chunkWFT3XUSH_cjs.e(t.value)):chunkS3SPDK6N_cjs.K(t)}function De(e){return chunkS3SPDK6N_cjs.P("SYMBOLIC_UNSUPPORTED_FUNCTION",`"${e}" cannot be applied to an expression that still contains an unknown.`)}function _i(e,t){let n=V(e),o=V(t);return n===null||o===null?De("^"):w(chunkWFT3XUSH_cjs.r(n,o))}function Ti(e){let t=V(e);return t===null?De("-"):w({kind:"neg",operand:t})}function Vi(e,t){let n=[];for(let r of t){let i=chunkS3SPDK6N_cjs.Q(r);if(i)return i;let a=V(r);if(a===null)return De(pn[e]??`builtin ${e}`);n.push(a);}if(e===er&&n.length===2)return w(chunkWFT3XUSH_cjs.r(n[0],n[1]));let o=pn[e];return o===void 0?De(`builtin ${e}`):w(chunkWFT3XUSH_cjs.s(o,n))}function tr(e){let t=w(e);return t.type===0&&!Number.isInteger(t.toNumber())?chunkS3SPDK6N_cjs.K(e):t}function nr(e){return e.im===0?chunkS3SPDK6N_cjs.n(e.re):chunkS3SPDK6N_cjs.K(chunkWFT3XUSH_cjs.w(chunkWFT3XUSH_cjs.o(chunkWFT3XUSH_cjs.d(e.re),chunkWFT3XUSH_cjs.d(e.im))))}function or(e){switch(e.kind){case "identity":return chunkS3SPDK6N_cjs.t("true for every value");case "contradiction":return chunkS3SPDK6N_cjs.t("no solution");case "unsupported":return chunkS3SPDK6N_cjs.P("SYMBOLIC_SOLVE_UNSUPPORTED",`Cannot solve this equation: ${e.reason}.`);case "incomplete":{let t=e.exact.length+e.approximate.length;return chunkS3SPDK6N_cjs.P("SYMBOLIC_SOLVE_INCOMPLETE",`Only ${t} of this equation's ${t+e.missing} roots could be found: ${e.reason}.`)}case "roots":{let t=e.exact.map(tr);for(let n of e.approximate)t.push(nr(n));return t.length===0?chunkS3SPDK6N_cjs.t("no solution"):t.length===1?t[0]:chunkS3SPDK6N_cjs.C(1,t.length,t.map(n=>n.type===9?n.value:n.toNumber()))}}}function yn(e,t,n){let o=V(e),r=V(t);return o===null||r===null?chunkS3SPDK6N_cjs.P("SYMBOLIC_NONFINITE_OPERAND","An equation side has no exact value to solve with."):or(dn(o,r,n))}function he(e,t){if(e.type===6&&t.type===6){if(e.unit===t.unit)return {lv:e.toNumber(),rv:t.toNumber(),unit:e.unit,sameMeasure:true};let n=chunkPHWIO4P3_cjs.c(e.unit),o=chunkPHWIO4P3_cjs.c(t.unit),r=chunkSF5QVUEI_cjs.c.isCurrency(e.unit)&&chunkSF5QVUEI_cjs.c.isCurrency(t.unit);if(n&&n===o){let i=chunkPHWIO4P3_cjs.e(t.toNumber(),t.unit,e.unit);return {lv:e.toNumber(),rv:i,unit:e.unit,sameMeasure:true}}if(r){let i=chunkSF5QVUEI_cjs.c.convertSync(t.toNumber(),t.unit,e.unit);if(i!==null)return {lv:e.toNumber(),rv:i,unit:e.unit,sameMeasure:true}}return {lv:e.toNumber(),rv:t.toNumber(),unit:void 0,sameMeasure:false}}return e.type===6?{lv:e.toNumber(),rv:t.toNumber(),unit:e.unit,sameMeasure:true}:t.type===6?{lv:e.toNumber(),rv:t.toNumber(),unit:t.unit,sameMeasure:true}:{lv:e.toNumber(),rv:t.toNumber(),unit:void 0,sameMeasure:true}}var rr=1e-12;function ir(e,t,n){let o=0;return Number.isFinite(e)&&Math.abs(e)>o&&(o=Math.abs(e)),Number.isFinite(t)&&Math.abs(t)>o&&(o=Math.abs(t)),Number.isFinite(n)&&Math.abs(n)>o&&(o=Math.abs(n)),o}function qi(e,t){let{lv:n,rv:o,sameMeasure:r}=he(e,t);if(!r)return {lv:n,rv:o,equal:false,sameMeasure:false};if(e.type===6&&t.type===6&&e.unit!==void 0&&e.unit===t.unit&&e.exact!==void 0&&t.exact!==void 0&&chunkSF5QVUEI_cjs.c.isCurrency(e.unit))return {lv:n,rv:o,equal:chunkWFT3XUSH_cjs.qa(e.exact,t.exact)===0,sameMeasure:true};if(n===o)return {lv:n,rv:o,equal:true,sameMeasure:true};if(!Number.isFinite(n)||!Number.isFinite(o))return {lv:n,rv:o,equal:false,sameMeasure:true};let i=ir(n,o,t.toNumber());return {lv:n,rv:o,equal:Math.abs(n-o)<=i*rr,sameMeasure:true}}var ar={time:"duration",luminousIntensity:"luminous intensity"},ur=new Set(["money","data"]),lr={add:"added",sub:"subtracted",mul:"multiplied",div:"divided"};function Pe(e){if(chunkSF5QVUEI_cjs.c.isCurrency(e))return "money";let t=chunkPHWIO4P3_cjs.c(e);if(t!==void 0)return ar[t]??t}function hn(e){return ur.has(e)?e:/^[aeiou]/.test(e)?`an ${e}`:`a ${e}`}function Fe(e,t,n){let o=e===void 0?void 0:Pe(e),r=t===void 0?void 0:Pe(t);if(o!==void 0&&r!==void 0&&o!==r)return `${o} and ${r} cannot be ${n}`}function sr(e){return e!==void 0?lr[e]??"combined":"combined"}function Yi(e,t){let n=Pe(e),o=Pe(t);if(n!==void 0&&o!==void 0&&n!==o)return `${hn(n)} cannot be converted to ${hn(o)}`}function Gi(e,t){let n=e.type===6?e.unit:void 0,o=t.type===6?t.unit:void 0,r=Fe(n,o,"compared");return chunkS3SPDK6N_cjs.P("INCOMPATIBLE_UNITS",r??`Cannot compare incompatible units: ${n??"?"} and ${o??"?"}`)}function Nn(e){if(e.type===2)return e.value;let t=e.toNumber();if(!Number.isInteger(t)){let n=Number.isNaN(t)?"NaN":String(t);throw chunk6SYU4MH7_cjs.c.execution("BIGINT_INEXACT_OPERAND",`A whole-number (n) value can only be combined with another whole number, and ${n} is not one`,{operand:n})}return BigInt(t)}function ji(){return chunk6SYU4MH7_cjs.c.execution("BIGINT_DIVISION_BY_ZERO","Division by zero: a whole-number (n) division is exact integer division, which has no answer at zero, unlike 1 / 0 which is Infinity")}function Ki(e,t){let n=gn(e),o=gn(t);return n===null||o===null?null:n<o?-1:n>o?1:0}function gn(e){if(e.type===2)return e.value;let t=e.toNumber();return Number.isInteger(t)?BigInt(t):null}function nt(e,t){return Number.isFinite(t)?Math.pow(e,t):e===1||e===-1&&!Number.isNaN(t)?1:Math.pow(e,t)}function Rn(e){return e.exact!==void 0?e.exact:chunkWFT3XUSH_cjs.ha(e.toNumber())}function cr(e,t,n){let o=e.type===6&&e.unit!==void 0&&e.exact!==void 0&&chunkSF5QVUEI_cjs.c.isCurrency(e.unit),r=t.type===6&&t.unit!==void 0&&t.exact!==void 0&&chunkSF5QVUEI_cjs.c.isCurrency(t.unit);if(!o&&!r)return null;let i,a,u;if(o&&r){if(e.unit!==t.unit||n==="div")return null;i=e.exact,a=t.exact,u=e.unit;}else if(o&&t.type!==6)i=e.exact,u=e.unit,a=Rn(t);else if(r&&e.type!==6)a=t.exact,u=t.unit,i=Rn(e);else return null;if(i===null||a===null)return null;let l;switch(n){case "add":l=chunkWFT3XUSH_cjs.ja(i,a);break;case "sub":l=chunkWFT3XUSH_cjs.ka(i,a);break;case "mul":l=chunkWFT3XUSH_cjs.la(i,a);break;case "div":if(chunkWFT3XUSH_cjs.na(a))return null;l=chunkWFT3XUSH_cjs.pa(i,a);break}return chunkS3SPDK6N_cjs.v(chunkWFT3XUSH_cjs.ra(l),u,l)}function Le(e){return e.rational!==void 0?e.rational:(e.type===0||e.type===1)&&typeof e.value=="number"&&Number.isInteger(e.value)?chunkWFT3XUSH_cjs.c(BigInt(e.value)):null}function Xi(e,t,n){let o=Le(e);if(o===null)return null;let r=Le(t);if(r===null||n==="div"&&chunkWFT3XUSH_cjs.l(r))return null;let i;try{switch(n){case "add":i=chunkWFT3XUSH_cjs.f(o,r);break;case "sub":i=chunkWFT3XUSH_cjs.g(o,r);break;case "mul":i=chunkWFT3XUSH_cjs.h(o,r);break;case "div":i=chunkWFT3XUSH_cjs.i(o,r);break}}catch{return null}return chunkS3SPDK6N_cjs.p(chunkWFT3XUSH_cjs.e(i),i)}function Zi(e,t,n){if(e.type!==0||t.type!==0)return null;let o=e.value,r=t.value,i=e.uncertainty??0,a=t.uncertainty??0,u,l;switch(n){case "add":u=o+r,l=Math.hypot(i,a);break;case "sub":u=o-r,l=Math.hypot(i,a);break;case "mul":u=o*r,l=Math.hypot(r*i,o*a);break;case "div":u=o/r,l=Math.hypot(i/r,o*a/(r*r));break}return chunkS3SPDK6N_cjs.q(u,l)}function Hi(e,t){let n=Le(e);if(n===null)return null;let o=Le(t);return o===null?null:chunkWFT3XUSH_cjs.k(n,o)}function Wi(e,t,n,o,r){if(e.type===13)return e;if(t.type===13)return t;if(e.type===12)return e;if(t.type===12)return t;if(r&&(e.type===9||t.type===9)){let i=V(e),a=V(t);return i===null||a===null?chunkS3SPDK6N_cjs.P("SYMBOLIC_NONFINITE_OPERAND","A symbolic expression cannot combine with a value that has no exact number (NaN or infinity)."):chunkS3SPDK6N_cjs.K(chunkWFT3XUSH_cjs.Q({kind:r,left:i,right:a}))}if(e.type===0&&t.type===0)return chunkS3SPDK6N_cjs.n(n(e.value,t.value));if(e.type===2||t.type===2){let i=Nn(e),a=Nn(t);return o?chunkS3SPDK6N_cjs.s(o(i,a)):chunkS3SPDK6N_cjs.s(i+a)}if(e.type===6||t.type===6){if(r){let s=cr(e,t,r);if(s)return s}let{lv:i,rv:a,unit:u,sameMeasure:l}=he(e,t);if(!l){let s=e.type===6?e.unit:void 0,p=t.type===6?t.unit:void 0,h=Fe(s,p,sr(r));return chunkS3SPDK6N_cjs.P("INCOMPATIBLE_UNITS",h??`Cannot combine incompatible units: ${s??"?"} and ${p??"?"}`)}return chunkS3SPDK6N_cjs.u(n(i,a),u)}if(e.type===7&&t.type===7){let i=e.value,a=t.value;if(!chunkWFT3XUSH_cjs.V(i,a))return chunkS3SPDK6N_cjs.P("DIMENSION_MISMATCH",`Cannot combine matrices of different shapes: ${i.rows}x${i.cols} and ${a.rows}x${a.cols}`);let u=new Array(i.data.length);for(let l=0;l<i.data.length;l++)u[l]=n(i.data[l],a.data[l]);return chunkS3SPDK6N_cjs.C(i.rows,i.cols,u)}if(e.type===7){let i=e.value,a=t.toNumber(),u=i.data.map(l=>n(l,a));return chunkS3SPDK6N_cjs.C(i.rows,i.cols,u)}if(t.type===7){let i=t.value,a=e.toNumber(),u=i.data.map(l=>n(a,l));return chunkS3SPDK6N_cjs.C(i.rows,i.cols,u)}return chunkS3SPDK6N_cjs.n(n(e.toNumber(),t.toNumber()))}var An=254,xn=200,Ne=class{constructor(){this.handlers=new Map;this.nextOpcode=xn+1;}register(t){this.handlers.set(t.opcode,t.handler);}unregister(t){this.handlers.delete(t);}get(t){return this.handlers.get(t)}has(t){return this.handlers.has(t)}allocateOpcode(){if(this.nextOpcode>An)throw chunk6SYU4MH7_cjs.c.config("OPCODE_POOL_EXHAUSTED",`OpRegistry: dynamic opcode pool exhausted (max ${An-xn} allocations).`);return this.nextOpcode++}},Ji=new Ne;var Mn=chunkWFT3XUSH_cjs.ga(1);function ge(e,t){return chunkSF5QVUEI_cjs.c.isCurrency(t)?e.exact??chunkWFT3XUSH_cjs.ha(e.toNumber()):null}function ot(e){if(!Number.isFinite(e))return null;if(Number.isInteger(e))return chunkWFT3XUSH_cjs.ga(BigInt(e));let t=String(e);return /^-?\d+\.\d+$/.test(t)?chunkWFT3XUSH_cjs.ia(t):null}function In(e,t,n){let o=ge(e,n),r=ot(t);if(o!==null&&r!==null){let i=chunkWFT3XUSH_cjs.la(o,r);return chunkS3SPDK6N_cjs.v(chunkWFT3XUSH_cjs.ra(i),n,i)}return chunkS3SPDK6N_cjs.u(e.toNumber()*t,n)}function En(e,t,n,o){let r=ge(e,t),i=ot(n);if(r!==null&&i!==null){let a=chunkWFT3XUSH_cjs.ja(Mn,o===1?i:chunkWFT3XUSH_cjs.ma(i)),u=chunkWFT3XUSH_cjs.la(r,a);return chunkS3SPDK6N_cjs.v(chunkWFT3XUSH_cjs.ra(u),t,u)}return chunkS3SPDK6N_cjs.u(e.toNumber()*(1+o*n),t)}function Sn(e){let t=ot(e);return t===null?null:chunkWFT3XUSH_cjs.ja(Mn,t)}function kn(e,t,n){let o=ge(e,t),r=Sn(n);if(o===null||r===null||chunkWFT3XUSH_cjs.na(r))return null;let i=chunkWFT3XUSH_cjs.pa(o,r);return chunkS3SPDK6N_cjs.v(chunkWFT3XUSH_cjs.ra(i),t,i)}function _n(e,t,n){let o=ge(e,t),r=Sn(n);if(o===null||r===null||chunkWFT3XUSH_cjs.na(r))return null;let i=chunkWFT3XUSH_cjs.ka(o,chunkWFT3XUSH_cjs.pa(o,r));return chunkS3SPDK6N_cjs.v(chunkWFT3XUSH_cjs.ra(i),t,i)}function Tn(e,t){let n=e.unit,o=n!==void 0&&chunkSF5QVUEI_cjs.c.isCurrency(n)?mr(e,n):null;if(o===null)return {unit:n,shares:[{value:e.toNumber()/t,count:t}]};let r=BigInt(t),i=o/r,a=o-i*r,u=Number(a<0n?-a:a),l=o<0n?-1n:1n,s=vn(i,t-u);return u===0?{unit:n,shares:[s]}:{unit:n,shares:[s,vn(i+l,u)]}}function vn(e,t){let n=chunkWFT3XUSH_cjs.fa(e,2);return {value:chunkWFT3XUSH_cjs.ra(n),exact:n,count:t}}function mr(e,t){let n=ge(e,t);return n===null?null:chunkWFT3XUSH_cjs.oa(n,2).coef}var fr=12;function Vn(e,t){if(e.length===0||t.length===0)return [];let n=new Array(e.length+t.length-1).fill(chunkWFT3XUSH_cjs.a);return e.forEach((o,r)=>{t.forEach((i,a)=>{n[r+a]=chunkWFT3XUSH_cjs.f(n[r+a],chunkWFT3XUSH_cjs.h(o,i));});}),n}function dr(e,t){let n=[chunkWFT3XUSH_cjs.b];for(let o=0;o<t;o++)n=Vn(n,e);return n}function rt(e,t){return e.map(n=>chunkWFT3XUSH_cjs.i(n,t))}function pr(e,t){let n=[],o=0;for(;o<e.length&&chunkWFT3XUSH_cjs.l(e[o]);)o++;o>0&&n.push({base:[chunkWFT3XUSH_cjs.a,chunkWFT3XUSH_cjs.b],power:o});let r=e.slice(o);if(r.length>1){let i=Je([...r].reverse(),t);for(let a of i.factors){let u=chunkWFT3XUSH_cjs.C(a.base);if(u===null)return null;n.push({base:[...chunkWFT3XUSH_cjs.B(u,t)],power:a.power});}}return n.length>0?n:null}function br(e){let t=[];return e.forEach((n,o)=>{let r=n.base.length-1;for(let i=1;i<=n.power;i++)for(let a=0;a<r;a++)t.push({factor:o,power:i,degree:a});}),t}function yr(e,t,n){let o=dr(t[e.factor].base,e.power),{quotient:r,remainder:i}=chunkWFT3XUSH_cjs.H(n,o);if(!chunkWFT3XUSH_cjs.G(i))return null;let a=new Array(e.degree).fill(chunkWFT3XUSH_cjs.a);return a.push(chunkWFT3XUSH_cjs.b),Vn(r,a)}function hr(e,t){let n=t.length;for(let o=0;o<n;o++){let r=-1;for(let i=o;i<n;i++)if(!chunkWFT3XUSH_cjs.l(e[i][o])){r=i;break}if(r===-1)return null;[e[o],e[r]]=[e[r],e[o]],[t[o],t[r]]=[t[r],t[o]];for(let i=0;i<n;i++){if(i===o||chunkWFT3XUSH_cjs.l(e[i][o]))continue;let a=chunkWFT3XUSH_cjs.i(e[i][o],e[o][o]);for(let u=o;u<n;u++)e[i][u]=chunkWFT3XUSH_cjs.g(e[i][u],chunkWFT3XUSH_cjs.h(a,e[o][u]));t[i]=chunkWFT3XUSH_cjs.g(t[i],chunkWFT3XUSH_cjs.h(a,t[o]));}}return t.map((o,r)=>chunkWFT3XUSH_cjs.i(o,e[r][r]))}function it(e,t,n){if(t.length<2||t.length-1>fr)return null;let o=chunkWFT3XUSH_cjs.I(e,t),r=o.length>1?chunkWFT3XUSH_cjs.H(e,o).quotient:[...e],i=o.length>1?chunkWFT3XUSH_cjs.H(t,o).quotient:[...t];if(i.length===1)return {polynomial:rt(r,i[0]),terms:[]};if(i.length===0)return null;let a=i[i.length-1],u=rt(i,a),l=rt(r,a),{quotient:s,remainder:p}=chunkWFT3XUSH_cjs.H(l,u);if(chunkWFT3XUSH_cjs.G(p))return {polynomial:s,terms:[]};let h=pr(u,n);if(h===null)return null;let x=Nr(h,u,p);return x===null?null:{polynomial:s,terms:x}}function Nr(e,t,n){let o=br(e),r=t.length-1;if(o.length!==r)return null;let i=[];for(let s of o){let p=yr(s,e,t);if(p===null)return null;i.push(p);}let a=[];for(let s=0;s<r;s++)a.push(i.map(p=>p[s]??chunkWFT3XUSH_cjs.a));let u=[];for(let s=0;s<r;s++)u.push(n[s]??chunkWFT3XUSH_cjs.a);let l=hr(a,u);return l===null?null:gr(o,l,e)}function gr(e,t,n){let o=new Map;e.forEach((i,a)=>{let u=`${i.factor}:${i.power}`,l=o.get(u)??[];l[i.degree]=t[a],o.set(u,l);});let r=[];for(let[i,a]of o){let[u,l]=i.split(":").map(Number),s=[...a].map(p=>p??chunkWFT3XUSH_cjs.a);s.every(chunkWFT3XUSH_cjs.l)||r.push({numerator:s,base:n[u].base,power:l});}return r}function Re(e,t){let n=new Map;return e.forEach((o,r)=>{chunkWFT3XUSH_cjs.l(o)||n.set(r===0?"":r===1?t:`${t}^${r}`,o);}),n.size===0?chunkWFT3XUSH_cjs.p(chunkWFT3XUSH_cjs.a):chunkWFT3XUSH_cjs.E({terms:n,vars:e.length>1?[t]:[]})}function wn(e){let t=at(e);if(t===null)return e;let n=it(t.numerator,t.denominator,t.variable);if(n===null||n.terms.length===0)return e;let o=n.polynomial.length>0?Re(n.polynomial,t.variable):null;for(let r of n.terms){let i=Re(r.base,t.variable),a=r.power===1?i:chunkWFT3XUSH_cjs.r(i,chunkWFT3XUSH_cjs.p({n:BigInt(r.power),d:1n})),u=Rr(r.numerator),l=u?r.numerator.map(p=>chunkWFT3XUSH_cjs.j(p)):r.numerator,s={kind:"div",left:Re(l,t.variable),right:a};o===null?o=u?{kind:"neg",operand:s}:s:o={kind:u?"sub":"add",left:o,right:s};}return o===null?e:chunkWFT3XUSH_cjs.Q(o)}function Rr(e){return e.some(t=>t.n<0n)&&e.every(t=>t.n<=0n)}function at(e){if(e.kind!=="div")return null;let t=chunkWFT3XUSH_cjs.C(e.left),n=chunkWFT3XUSH_cjs.C(e.right);if(t===null||n===null)return null;let o=chunkWFT3XUSH_cjs.A(n);return o===null||t.vars.some(r=>r!==o)?null:{numerator:chunkWFT3XUSH_cjs.B(t,o),denominator:chunkWFT3XUSH_cjs.B(n,o),variable:o}}var ut=16;function On(){return chunkWFT3XUSH_cjs.p(chunkWFT3XUSH_cjs.a)}function X(){return chunkWFT3XUSH_cjs.p(chunkWFT3XUSH_cjs.b)}function Ar(e,t){switch(e){case "sin":return chunkWFT3XUSH_cjs.s("cos",[t]);case "cos":return {kind:"neg",operand:chunkWFT3XUSH_cjs.s("sin",[t])};case "tan":return {kind:"div",left:X(),right:chunkWFT3XUSH_cjs.r(chunkWFT3XUSH_cjs.s("cos",[t]),chunkWFT3XUSH_cjs.p(2))};case "exp":return chunkWFT3XUSH_cjs.s("exp",[t]);case "log":return {kind:"div",left:X(),right:t};case "sqrt":return {kind:"div",left:X(),right:{kind:"mul",left:chunkWFT3XUSH_cjs.p(2),right:chunkWFT3XUSH_cjs.s("sqrt",[t])}};case "asin":return {kind:"div",left:X(),right:chunkWFT3XUSH_cjs.s("sqrt",[Cn(t)])};case "acos":return {kind:"neg",operand:{kind:"div",left:X(),right:chunkWFT3XUSH_cjs.s("sqrt",[Cn(t)])}};case "atan":return {kind:"div",left:X(),right:xr(t)};case "sinh":return chunkWFT3XUSH_cjs.s("cosh",[t]);case "cosh":return chunkWFT3XUSH_cjs.s("sinh",[t]);case "tanh":return {kind:"div",left:X(),right:chunkWFT3XUSH_cjs.r(chunkWFT3XUSH_cjs.s("cosh",[t]),chunkWFT3XUSH_cjs.p(2))};case "abs":return chunkWFT3XUSH_cjs.s("sign",[t]);default:return null}}function Cn(e){return {kind:"sub",left:X(),right:chunkWFT3XUSH_cjs.r(e,chunkWFT3XUSH_cjs.p(2))}}function xr(e){return {kind:"add",left:X(),right:chunkWFT3XUSH_cjs.r(e,chunkWFT3XUSH_cjs.p(2))}}function Ae(e,t,n=1){if(n<0||!Number.isInteger(n))throw chunk6SYU4MH7_cjs.c.execution("SYMBOLIC_DERIVATIVE_ORDER_LIMIT","A derivative order must be a whole number, at least zero.");if(n>ut)throw chunk6SYU4MH7_cjs.c.execution("SYMBOLIC_DERIVATIVE_ORDER_LIMIT",`A derivative order above ${ut} is not supported.`,{limit:ut});let o=chunkWFT3XUSH_cjs.Q(e);for(let r=0;r<n;r++)o=chunkWFT3XUSH_cjs.Q(P(o,t));return o}function P(e,t){switch(e.kind){case "const":case "complex":return On();case "var":return e.name===t?X():On();case "add":return {kind:"add",left:P(e.left,t),right:P(e.right,t)};case "sub":return {kind:"sub",left:P(e.left,t),right:P(e.right,t)};case "neg":return {kind:"neg",operand:P(e.operand,t)};case "mul":return {kind:"add",left:{kind:"mul",left:P(e.left,t),right:e.right},right:{kind:"mul",left:e.left,right:P(e.right,t)}};case "div":return {kind:"div",left:{kind:"sub",left:{kind:"mul",left:P(e.left,t),right:e.right},right:{kind:"mul",left:e.left,right:P(e.right,t)}},right:chunkWFT3XUSH_cjs.r(e.right,chunkWFT3XUSH_cjs.p(2))};case "pow":return vr(e,t);case "call":{if(e.args.length!==1)return lt(e,t);let n=Ar(e.name,e.args[0]);return n===null?lt(e,t):{kind:"mul",left:n,right:P(e.args[0],t)}}}}function vr(e,t){if(e.exponent.kind==="const"){let n=chunkWFT3XUSH_cjs.p(chunkWFT3XUSH_cjs.g(e.exponent.value,chunkWFT3XUSH_cjs.b));return {kind:"mul",left:{kind:"mul",left:e.exponent,right:chunkWFT3XUSH_cjs.r(e.base,n)},right:P(e.base,t)}}return e.base.kind==="const"&&e.base.value.n>0n?{kind:"mul",left:{kind:"mul",left:e,right:chunkWFT3XUSH_cjs.s("log",[e.base])},right:P(e.exponent,t)}:lt(e,t)}function lt(e,t){return chunkWFT3XUSH_cjs.s("der",[e,chunkWFT3XUSH_cjs.q(t)])}function Dn(e,t){let n=chunkWFT3XUSH_cjs.C(e);if(n===null||n.vars.filter(u=>u!==t).length>0||chunkWFT3XUSH_cjs.z(n,t)>1)return null;let r=chunkWFT3XUSH_cjs.B(n,t),i=r[0]??{n:0n,d:1n},a=r[1]??{n:0n,d:1n};return chunkWFT3XUSH_cjs.l(a)?null:{slope:a,intercept:i}}function Mr(e,t){let n=chunkWFT3XUSH_cjs.C(e);if(n===null)return null;let o=n.vars.filter(a=>a!==t);if(o.length>0)return {ok:false,reason:`it involves more than one unknown (${o.join(", ")})`};let r=chunkWFT3XUSH_cjs.B(n,t),i=chunkWFT3XUSH_cjs.p(0);return r.forEach((a,u)=>{if(chunkWFT3XUSH_cjs.l(a))return;let l=u+1,s=chunkWFT3XUSH_cjs.i(a,{n:BigInt(l),d:1n}),p={kind:"mul",left:chunkWFT3XUSH_cjs.p(s),right:l===1?chunkWFT3XUSH_cjs.q(t):chunkWFT3XUSH_cjs.r(chunkWFT3XUSH_cjs.q(t),chunkWFT3XUSH_cjs.p(l))};i={kind:"add",left:i,right:p};}),{ok:true,value:chunkWFT3XUSH_cjs.Q(i)}}function Ir(e,t){if(e.kind!=="call"||e.args.length!==1)return null;let n=Dn(e.args[0],t);if(n===null)return null;let o=e.args[0],r=i=>chunkWFT3XUSH_cjs.Q({kind:"div",left:i,right:chunkWFT3XUSH_cjs.p(n.slope)});switch(e.name){case "exp":return {ok:true,value:r(chunkWFT3XUSH_cjs.s("exp",[o]))};case "sin":return {ok:true,value:r({kind:"neg",operand:chunkWFT3XUSH_cjs.s("cos",[o])})};case "cos":return {ok:true,value:r(chunkWFT3XUSH_cjs.s("sin",[o]))};case "log":return {ok:true,value:r({kind:"sub",left:{kind:"mul",left:o,right:chunkWFT3XUSH_cjs.s("log",[o])},right:o})};default:return null}}function Er(e,t){if(e.kind!=="div"||e.left.kind!=="const"||!st(e.left.value))return null;let n=Dn(e.right,t);if(n!==null)return {ok:true,value:chunkWFT3XUSH_cjs.Q({kind:"div",left:chunkWFT3XUSH_cjs.s("log",[e.right]),right:chunkWFT3XUSH_cjs.p(n.slope)})};let o=chunkWFT3XUSH_cjs.C(e.right);if(o!==null&&o.vars.length===1&&o.vars[0]===t){let r=chunkWFT3XUSH_cjs.B(o,t);if(r.length===3&&st(r[0])&&chunkWFT3XUSH_cjs.l(r[1])&&st(r[2]))return {ok:true,value:chunkWFT3XUSH_cjs.s("atan",[chunkWFT3XUSH_cjs.q(t)])}}return null}function st(e){return e.n===1n&&e.d===1n}function Sr(e,t){let n=at(e);if(n===null||n.variable!==t)return null;let o=it(n.numerator,n.denominator,t);if(o===null)return null;let r=o.polynomial.length>0?Tr(o.polynomial,t):chunkWFT3XUSH_cjs.p(0);for(let i of o.terms){let a=kr(i,t);if(a===null)return {ok:false,reason:"its denominator has a repeated irreducible quadratic factor, which needs a reduction formula this does not have"};r={kind:"add",left:r,right:a};}return {ok:true,value:chunkWFT3XUSH_cjs.Q(r)}}function kr(e,t){let n=e.base.length-1,o=Re(e.base,t);if(n===1){let r=e.numerator[0]??chunkWFT3XUSH_cjs.a;if(e.power===1)return {kind:"mul",left:chunkWFT3XUSH_cjs.p(r),right:chunkWFT3XUSH_cjs.s("log",[o])};let i=e.power-1,a=chunkWFT3XUSH_cjs.i(r,{n:BigInt(-i),d:1n});return {kind:"div",left:chunkWFT3XUSH_cjs.p(a),right:chunkWFT3XUSH_cjs.r(o,chunkWFT3XUSH_cjs.p({n:BigInt(i),d:1n}))}}return n!==2||e.power!==1?null:_r(e,t,o)}function _r(e,t,n){let o=e.numerator[0]??chunkWFT3XUSH_cjs.a,r=e.numerator[1]??chunkWFT3XUSH_cjs.a,[i,a]=e.base,u={n:1n,d:2n},l=chunkWFT3XUSH_cjs.h(a,u),s={kind:"mul",left:chunkWFT3XUSH_cjs.p(chunkWFT3XUSH_cjs.h(r,u)),right:chunkWFT3XUSH_cjs.s("log",[n])},p=chunkWFT3XUSH_cjs.g(o,chunkWFT3XUSH_cjs.h(r,l));if(chunkWFT3XUSH_cjs.l(p))return s;let h=chunkWFT3XUSH_cjs.O(chunkWFT3XUSH_cjs.g(i,chunkWFT3XUSH_cjs.h(l,l))),x={kind:"add",left:chunkWFT3XUSH_cjs.q(t),right:chunkWFT3XUSH_cjs.p(l)},T={kind:"mul",left:{kind:"div",left:chunkWFT3XUSH_cjs.p(p),right:h},right:chunkWFT3XUSH_cjs.s("atan",[{kind:"div",left:x,right:h}])};return chunkWFT3XUSH_cjs.l(r)?T:{kind:"add",left:s,right:T}}function Tr(e,t){let n=chunkWFT3XUSH_cjs.p(0);return e.forEach((o,r)=>{if(chunkWFT3XUSH_cjs.l(o))return;let i=r+1,a=chunkWFT3XUSH_cjs.i(o,{n:BigInt(i),d:1n}),u={kind:"mul",left:chunkWFT3XUSH_cjs.p(a),right:i===1?chunkWFT3XUSH_cjs.q(t):chunkWFT3XUSH_cjs.r(chunkWFT3XUSH_cjs.q(t),chunkWFT3XUSH_cjs.p(i))};n={kind:"add",left:n,right:u};}),n}function xe(e,t){let n=chunkWFT3XUSH_cjs.Q(e);if(!chunkWFT3XUSH_cjs.u(n).has(t))return {ok:true,value:chunkWFT3XUSH_cjs.Q({kind:"mul",left:n,right:chunkWFT3XUSH_cjs.q(t)})};let o=Mr(n,t);if(o!==null)return o;let r=Ir(n,t);if(r!==null)return r;let i=Er(n,t);if(i!==null)return i;let a=Sr(n,t);if(a!==null)return a;if(n.kind==="add"||n.kind==="sub"){let u=xe(n.left,t);if(!u.ok)return u;let l=xe(n.right,t);return l.ok?{ok:true,value:chunkWFT3XUSH_cjs.Q({kind:n.kind,left:u.value,right:l.value})}:l}if(n.kind==="mul"&&n.left.kind==="const"){let u=xe(n.right,t);return u.ok?{ok:true,value:chunkWFT3XUSH_cjs.Q({kind:"mul",left:n.left,right:u.value})}:u}return {ok:false,reason:"no elementary antiderivative is known for this expression"}}var ct=16;function Pn(e,t,n,o){if(o<0||!Number.isInteger(o)||o>ct)throw chunk6SYU4MH7_cjs.c.execution("SYMBOLIC_TAYLOR_DEGREE_LIMIT",`A Taylor degree must be a whole number from 0 to ${ct}.`,{limit:ct});let r=chunkWFT3XUSH_cjs.p(n),i=1n,a=chunkWFT3XUSH_cjs.p(chunkWFT3XUSH_cjs.a);for(let u=0;u<=o;u++){u>0&&(i*=BigInt(u));let l=Ae(e,t,u),s=chunkWFT3XUSH_cjs.Q(chunkWFT3XUSH_cjs.v(l,t,r));if(s.kind!=="const")throw chunk6SYU4MH7_cjs.c.execution("SYMBOLIC_TAYLOR_INEXACT",`The derivative of order ${u} does not reduce to an exact number at the expansion point, so this series cannot be computed exactly.`,{order:u});let p=chunkWFT3XUSH_cjs.i(s.value,{n:i,d:1n});if(chunkWFT3XUSH_cjs.l(p))continue;let h=chunkWFT3XUSH_cjs.l(n)?chunkWFT3XUSH_cjs.q(t):{kind:"sub",left:chunkWFT3XUSH_cjs.q(t),right:r},x=u===0?chunkWFT3XUSH_cjs.p(1):u===1?h:chunkWFT3XUSH_cjs.r(h,chunkWFT3XUSH_cjs.p(u));a={kind:"add",left:a,right:{kind:"mul",left:chunkWFT3XUSH_cjs.p(p),right:x}};}return chunkWFT3XUSH_cjs.Q(a)}function Ln(e,t){return e.map(n=>t.map(o=>Ae(n,o)))}function Vr(){let e=globalThis.Temporal;return e??void 0}function Fn(e){if(e!==void 0&&typeof e!="string")return e;if(e==="date")return chunkEQNKDTMX_cjs.b;let t=Vr();if(e==="temporal"){if(t===void 0)throw chunk6SYU4MH7_cjs.c.config("CALENDAR_TEMPORAL_UNAVAILABLE",'calendar: "temporal" was asked for, but this runtime has no Temporal. Node ships it from 26 (24 behind --harmony-temporal), and Chrome, Edge, Firefox and Opera ship it; Safari does not. Pass a polyfill-backed backend from "solve-engine/temporal", or use calendar: "auto" to compute on Date where Temporal is absent.');return chunkOBZJKZ2F_cjs.b(t)}return t===void 0?chunkEQNKDTMX_cjs.b:chunkOBZJKZ2F_cjs.b(t)}function wr(e={}){return {pluginFunctions:{},opRegistry:new Ne,pluginFunctionOwners:{},networkEnabled:e.networkEnabled??true,calendar:Fn(e.calendar)}}var Un=wr();var Or={1970:38.8,1971:40.5,1972:41.8,1973:44.4,1974:49.3,1975:53.8,1976:56.9,1977:60.6,1978:65.2,1979:72.6,1980:82.4,1981:90.9,1982:96.5,1983:99.6,1984:103.9,1985:107.6,1986:109.6,1987:113.6,1988:118.3,1989:124,1990:130.7,1991:136.2,1992:140.3,1993:144.5,1994:148.2,1995:152.4,1996:156.9,1997:160.5,1998:163,1999:166.6,2e3:172.2,2001:177.1,2002:179.9,2003:184,2004:188.9,2005:195.3,2006:201.6,2007:207.3,2008:215.3,2009:214.5,2010:218.1,2011:224.9,2012:229.6,2013:233,2014:236.7,2015:237,2016:240,2017:245.1,2018:251.1,2019:255.7,2020:258.8,2021:271,2022:292.7,2023:304.7,2024:313.7,2025:322.2,2026:332.7},Bn=1970,qn=2026;function $n(e){return Or[Math.trunc(e)]}function mt(e,t){let n=$n(e),o=$n(t);if(!(n===void 0||o===void 0||n===0))return o/n}function Fa(e,t,n){let o=mt(t,n);if(o!==void 0)return e*o}function Cr(e){let t=Math.abs(e);return t<60?chunkS3SPDK6N_cjs.u(e,"s"):t<3600?chunkS3SPDK6N_cjs.u(e/60,"min"):t<86400?chunkS3SPDK6N_cjs.u(e/3600,"h"):chunkS3SPDK6N_cjs.u(e/86400,"d")}var Dr=0;function ft(e){if(e.type===6&&e.unit!==void 0){let t=chunkEZKR44MA_cjs.a[e.unit.toLowerCase()];if(t!==void 0&&t[0]===Dr)return e.toNumber()*t[1]}return e.toNumber()}function Pr(e,t){if(t===1)return e;let n=`${e}s`;return chunkEZKR44MA_cjs.a[n.toLowerCase()]===void 0?e:n}function Yn(e,t){let n,o=false;for(let r of e){if(Number.isNaN(r.toNumber())){o=true;continue}if(n===void 0){n=r;continue}let{lv:i,rv:a,sameMeasure:u}=he(n,r);if(!u){let l=n.type===6?n.unit:void 0,s=r.type===6?r.unit:void 0,p=Fe(l,s,"compared");return chunkS3SPDK6N_cjs.P("INCOMPATIBLE_UNITS",p??`Cannot compare incompatible units: ${l??"?"} and ${s??"?"}`)}(t?a>i:a<i)&&(n=r);}return o?chunkS3SPDK6N_cjs.n(NaN):n===void 0?chunkS3SPDK6N_cjs.n(t?-1/0:1/0):n.type===6?n:chunkS3SPDK6N_cjs.n(n.toNumber())}function Ue(e,t){return e.type===6&&e.unit!==void 0?chunkS3SPDK6N_cjs.u(t,e.unit):chunkS3SPDK6N_cjs.n(t)}function Gn(e,t){let n=Number.isFinite(t)?Math.min(100,Math.max(0,Math.trunc(t))):0;if(e.exact!==void 0){let a=chunkWFT3XUSH_cjs.oa(e.exact,n);return $e(e,chunkWFT3XUSH_cjs.ra(a),n,a)}let o=e.toNumber();if(!Number.isFinite(o))return $e(e,o,n);let r=Math.pow(10,n),i=o*r;return !Number.isFinite(i)||Math.abs(i)>Number.MAX_SAFE_INTEGER?$e(e,o,n):$e(e,Math.round(i)/r,n)}function $e(e,t,n,o){let r=e.type===6&&e.unit!==void 0?chunkS3SPDK6N_cjs.u(t,e.unit):chunkS3SPDK6N_cjs.n(t);return r.decimalPlaces=n,o!==void 0&&(r.exact=o),r}function jn(e,t,n){if(Number.isFinite(e)&&Number.isFinite(t))return null;let o=Number.isFinite(e)?t:e;return chunkS3SPDK6N_cjs.P("INVALID_INTEGER_OPERAND",`${n} needs two whole numbers, and ${Number.isNaN(o)?"one of them has no value":"one of them is infinite"}`)}function Kn(e,t){let n=e,o=t;for(;o!==0;){let r=o;o=n%o,n=r;}return n}function Lr(e){let t=e.length;if(t===0)return 0;let n=e.reduce((o,r)=>o+r,0)/t;return e.reduce((o,r)=>o+(r-n)*(r-n),0)}function Be(e,t){let n=e.length;if(n===0)return 0;let o=t?n-1:n;return o<=0?0:Lr(e)/o}var uu={0:e=>{let t=e[0].toNumber();return t>=0?chunkS3SPDK6N_cjs.n(Math.sqrt(t)):w(chunkWFT3XUSH_cjs.s("sqrt",[chunkWFT3XUSH_cjs.p(t)]))},1:e=>e[0].type===7?chunkWFT3XUSH_cjs.ca(e[0].value):Ue(e[0],Math.abs(e[0].toNumber())),2:e=>chunkS3SPDK6N_cjs.n(Math.sin(ft(e[0]))),3:e=>chunkS3SPDK6N_cjs.n(Math.cos(ft(e[0]))),4:e=>chunkS3SPDK6N_cjs.n(Math.tan(ft(e[0]))),5:e=>chunkS3SPDK6N_cjs.n(Math.log(e[0].toNumber())),6:e=>Ue(e[0],Math.ceil(e[0].toNumber())),7:e=>Ue(e[0],Math.floor(e[0].toNumber())),8:e=>e.length>=2?Gn(e[0],e[1].toNumber()):Ue(e[0],Math.round(e[0].toNumber())),9:e=>Yn(e,false),10:e=>Yn(e,true),11:e=>chunkS3SPDK6N_cjs.n(Math.asin(e[0].toNumber())),12:e=>chunkS3SPDK6N_cjs.n(Math.acos(e[0].toNumber())),13:e=>chunkS3SPDK6N_cjs.n(Math.atan(e[0].toNumber())),14:e=>chunkS3SPDK6N_cjs.n(Math.atan2(e[0].toNumber(),e[1].toNumber())),15:e=>chunkS3SPDK6N_cjs.n(Math.sinh(e[0].toNumber())),16:e=>chunkS3SPDK6N_cjs.n(Math.cosh(e[0].toNumber())),17:e=>chunkS3SPDK6N_cjs.n(Math.tanh(e[0].toNumber())),18:e=>chunkS3SPDK6N_cjs.n(Math.asinh(e[0].toNumber())),19:e=>chunkS3SPDK6N_cjs.n(Math.acosh(e[0].toNumber())),20:e=>chunkS3SPDK6N_cjs.n(Math.atanh(e[0].toNumber())),21:e=>chunkS3SPDK6N_cjs.n(Math.cbrt(e[0].toNumber())),22:e=>chunkS3SPDK6N_cjs.n(Math.clz32(e[0].toNumber())),23:e=>chunkS3SPDK6N_cjs.n(Math.expm1(e[0].toNumber())),24:e=>chunkS3SPDK6N_cjs.n(Math.exp(e[0].toNumber())),25:e=>chunkS3SPDK6N_cjs.n(Math.fround(e[0].toNumber())),26:e=>chunkS3SPDK6N_cjs.n(Math.hypot(...e.map(t=>t.toNumber()))),27:e=>chunkS3SPDK6N_cjs.n(Math.imul(e[0].toNumber(),e[1].toNumber())),28:e=>chunkS3SPDK6N_cjs.n(Math.log10(e[0].toNumber())),29:e=>chunkS3SPDK6N_cjs.n(Math.log1p(e[0].toNumber())),30:e=>chunkS3SPDK6N_cjs.n(Math.log2(e[0].toNumber())),31:e=>e[0].type===7?e[1].type!==0?chunkS3SPDK6N_cjs.P("MATRIX_POWER_UNSUPPORTED",`pow: a matrix's exponent must be a whole number, as in "pow([1,2;3,4], 2)".`):chunkWFT3XUSH_cjs.$(e[0].value,e[1].value):e[1].type===7?chunkS3SPDK6N_cjs.P("MATRIX_POWER_UNSUPPORTED",'pow: a matrix may only be the base, as in "pow([1,2;3,4], 2)".'):chunkS3SPDK6N_cjs.n(nt(e[0].toNumber(),e[1].toNumber())),32:()=>chunkS3SPDK6N_cjs.n(Math.random()),33:e=>chunkS3SPDK6N_cjs.n(Math.sign(e[0].toNumber())),34:e=>chunkS3SPDK6N_cjs.n(Math.trunc(e[0].toNumber())),35:e=>chunkS3SPDK6N_cjs.n(e[0].toNumber()*Math.PI/180),36:e=>chunkS3SPDK6N_cjs.n(e[0].toNumber()*180/Math.PI),37:e=>{let t=e[0].toNumber(),n=e[1].toNumber();return t>n?chunkS3SPDK6N_cjs.P("INVALID_RANGE",`roll: invalid range, ${t} is greater than ${n}`):chunkS3SPDK6N_cjs.n(Math.floor(Math.random()*(n-t+1))+t)},38:e=>{let t=Math.trunc(Math.abs(e[0].toNumber())),n=Math.trunc(Math.abs(e[1].toNumber())),o=jn(t,n,"gcd");return o||chunkS3SPDK6N_cjs.n(Kn(t,n))},39:e=>{let t=Math.trunc(Math.abs(e[0].toNumber())),n=Math.trunc(Math.abs(e[1].toNumber())),o=jn(t,n,"lcm");return o||(t===0||n===0?chunkS3SPDK6N_cjs.n(0):chunkS3SPDK6N_cjs.n(t/Kn(t,n)*n))},40:e=>{let t=Math.trunc(e[0].toNumber()),n=Math.trunc(e[1].toNumber());if(t<0||n<0||n>t)return chunkS3SPDK6N_cjs.P("INVALID_RANGE",`permutation: invalid n=${t}, r=${n} (require 0 <= r <= n)`);let o=1;for(let r=0;r<n;r++)if(o*=t-r,!Number.isFinite(o))return chunkS3SPDK6N_cjs.P("PERMUTATION_OVERFLOW",`permutation: P(${t}, ${n}) exceeds the maximum representable double (it passed it after ${r+1} of ${n} factors)`);return chunkS3SPDK6N_cjs.n(o)},41:e=>{let t=Math.trunc(e[0].toNumber()),n=Math.trunc(e[1].toNumber());if(t<0||n<0||n>t)return chunkS3SPDK6N_cjs.P("INVALID_RANGE",`combination: invalid n=${t}, r=${n} (require 0 <= r <= n)`);let o=Math.min(n,t-n),r=1;for(let i=0;i<o;i++)if(r=r*(t-i)/(i+1),!Number.isFinite(r))return chunkS3SPDK6N_cjs.P("COMBINATION_OVERFLOW",`combination: C(${t}, ${n}) exceeds the maximum representable double (it passed it after ${i+1} of ${o} steps)`);return chunkS3SPDK6N_cjs.n(Math.round(r))},42:e=>{if(e.length===0)return chunkS3SPDK6N_cjs.n(0);let t=e.reduce((n,o)=>n+o.toNumber(),0);return chunkS3SPDK6N_cjs.n(t/e.length)},43:e=>{if(e.length===0)return chunkS3SPDK6N_cjs.n(0);let t=e.map(o=>o.toNumber()).sort((o,r)=>o-r),n=Math.floor(t.length/2);return chunkS3SPDK6N_cjs.n(t.length%2===0?(t[n-1]+t[n])/2:t[n])},44:e=>chunkS3SPDK6N_cjs.n(e.reduce((t,n)=>t+n.toNumber(),0)),45:e=>chunkS3SPDK6N_cjs.n(e.length),46:e=>{let[t,n,o]=e,{lv:r,rv:i}=he(t,n);if(r===0)return chunkS3SPDK6N_cjs.P("PROPORTION_DIVIDE_BY_ZERO",`Cannot compute proportion: "${t.value}" is zero`);let a=o.toNumber()*(i/r);return o.type===6?chunkS3SPDK6N_cjs.u(a,o.unit):chunkS3SPDK6N_cjs.n(a)},47:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber();return n>o?chunkS3SPDK6N_cjs.P("INVALID_RANGE",`clamp: invalid range, ${n} is greater than ${o}`):chunkS3SPDK6N_cjs.n(Math.min(Math.max(t,n),o))},48:e=>chunkS3SPDK6N_cjs.r(e[0].toNumber()),49:e=>chunkS3SPDK6N_cjs.r(e[0].toNumber(),"bin"),50:e=>chunkS3SPDK6N_cjs.n(Math.trunc(e[0].toNumber())),51:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber();if(1+n<=0)return chunkS3SPDK6N_cjs.P("INVALID_RATE",`compoundInterest: rate ${n} makes (1 + rate) non-positive`);let r=t*Math.pow(1+n,o);return e[0].type===6?chunkS3SPDK6N_cjs.u(r,e[0].unit):chunkS3SPDK6N_cjs.n(r)},52:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber();if(1+n<=0)return chunkS3SPDK6N_cjs.P("INVALID_RATE",`interestEarned: rate ${n} makes (1 + rate) non-positive`);let r=t*(Math.pow(1+n,o)-1);return e[0].type===6?chunkS3SPDK6N_cjs.u(r,e[0].unit):chunkS3SPDK6N_cjs.n(r)},53:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber();return t<=0||n<=0?chunkS3SPDK6N_cjs.P("INVALID_RANGE","compoundInterestRate: principal and futureValue must both be positive"):o<=0?chunkS3SPDK6N_cjs.P("INVALID_RANGE","compoundInterestRate: years must be greater than 0"):chunkS3SPDK6N_cjs.n(Math.pow(n/t,1/o)-1)},54:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber();return t<=0||n<=0?chunkS3SPDK6N_cjs.P("INVALID_RANGE","compoundInterestYears: principal and futureValue must both be positive"):1+o<=0||o===0?chunkS3SPDK6N_cjs.P("INVALID_RATE",`compoundInterestYears: rate ${o} is not usable (must be > -1 and not 0)`):chunkS3SPDK6N_cjs.n(Math.log(n/t)/Math.log(1+o))},55:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber(),r=e[3].toNumber();if(t<=0)return chunkS3SPDK6N_cjs.P("INVALID_RANGE","loanRepayment: principal must be positive");if(o<=0)return chunkS3SPDK6N_cjs.P("INVALID_RANGE","loanRepayment: years must be positive");if(n<0)return chunkS3SPDK6N_cjs.P("INVALID_RATE","loanRepayment: rate must not be negative");if(r<0)return chunkS3SPDK6N_cjs.P("INVALID_RANGE","loanRepayment: periodsPerYear must not be negative");let{totalRepayment:i}=bt(t,n,o),a=r===0?i:i/(o*r);return e[0].type===6?chunkS3SPDK6N_cjs.u(a,e[0].unit):chunkS3SPDK6N_cjs.n(a)},56:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber(),r=e[3].toNumber();if(t<=0)return chunkS3SPDK6N_cjs.P("INVALID_RANGE","loanInterest: principal must be positive");if(o<=0)return chunkS3SPDK6N_cjs.P("INVALID_RANGE","loanInterest: years must be positive");if(n<0)return chunkS3SPDK6N_cjs.P("INVALID_RATE","loanInterest: rate must not be negative");if(r<0)return chunkS3SPDK6N_cjs.P("INVALID_RANGE","loanInterest: periodsPerYear must not be negative");let{totalInterest:i}=bt(t,n,o),a=r===0?i:i/(o*r);return e[0].type===6?chunkS3SPDK6N_cjs.u(a,e[0].unit):chunkS3SPDK6N_cjs.n(a)},57:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber();if(t<=0)return chunkS3SPDK6N_cjs.P("INVALID_RANGE","monthlyPayment: principal must be positive");if(o<=0)return chunkS3SPDK6N_cjs.P("INVALID_RANGE","monthlyPayment: years must be positive");if(n<0)return chunkS3SPDK6N_cjs.P("INVALID_RATE","monthlyPayment: rate must not be negative");let{monthlyPayment:r}=bt(t,n,o);return e[0].type===6?chunkS3SPDK6N_cjs.u(r,e[0].unit):chunkS3SPDK6N_cjs.n(r)},58:e=>{let t=e[0].toNumber(),n=e[1].toNumber();return e[0].type===6?En(e[0],e[0].unit,n,1):chunkS3SPDK6N_cjs.n(t*(1+n))},59:e=>{let t=e[0].toNumber(),n=e[1].toNumber();return 1+n<=0?chunkS3SPDK6N_cjs.P("INVALID_RATE",`taxRemove: rate ${n} makes (1 + rate) non-positive`):e[0].type===6?kn(e[0],e[0].unit,n)??chunkS3SPDK6N_cjs.u(t/(1+n),e[0].unit):chunkS3SPDK6N_cjs.n(t/(1+n))},60:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber(),r=mt(n,o);if(r===void 0)return chunkS3SPDK6N_cjs.P("INFLATION_YEAR_OUT_OF_RANGE",`inflationAdjust: fromYear ${n} or toYear ${o} is outside the bundled CPI table's range (${Bn}-${qn})`);let i=t*r;return e[0].type===6?chunkS3SPDK6N_cjs.u(i,e[0].unit):chunkS3SPDK6N_cjs.n(i)},61:e=>{let t=e[0].toNumber(),n=e[1].toNumber();return chunkS3SPDK6N_cjs.n(nt(n,1/t))},62:e=>{let t=e[0].toNumber();if(!Number.isInteger(t)||t<0)return chunkS3SPDK6N_cjs.P("INVALID_FACTORIAL_INPUT",`fact: ${t} is not a non-negative integer`);if(t>170)return chunkS3SPDK6N_cjs.P("FACTORIAL_OVERFLOW",`fact: ${t}! exceeds the maximum representable double (170! is the largest finite factorial)`);let n=1;for(let o=2;o<=t;o++)n*=o;return chunkS3SPDK6N_cjs.n(n)},63:e=>e[0].type===7?chunkWFT3XUSH_cjs.ba(e[0].value):e[0],64:e=>e[0].type===7?chunkWFT3XUSH_cjs.ca(e[0].value):chunkS3SPDK6N_cjs.n(e[0].toNumber()),65:e=>e[0].type===7?chunkWFT3XUSH_cjs.da(e[0].value):chunkS3SPDK6N_cjs.n(1/e[0].toNumber()),66:e=>{let[t,n]=e;if(t.type===0&&n.type===0)return chunkS3SPDK6N_cjs.n(t.toNumber()*n.toNumber());let o=r=>r.type===7?r.value:{rows:1,cols:1,data:[r.toNumber()],hasSymbolic:false};return chunkWFT3XUSH_cjs._(o(t),o(n))},67:e=>{let[t]=e;return t.type!==9?t:w(chunkWFT3XUSH_cjs.F(t.value))},68:e=>{let[t]=e;return t.type!==9?t:w(nn(t.value))},69:e=>{let[t,n,o]=e;return o?.type!==3?chunkS3SPDK6N_cjs.P("SOLVE_REQUIRES_VARIABLE_NAME","solve's second argument must be the name of the unknown."):yn(t,n,o.value)},70:e=>{let[t,n,o]=e,r=pt(n,"der");if(typeof r!="string")return r;let i=V(t);return i===null?chunkS3SPDK6N_cjs.P("SYMBOLIC_NONFINITE_OPERAND","der needs an expression with an exact value."):w(Ae(i,r,o?.toNumber()??1))},71:e=>{let[t,n]=e,o=pt(n,"integral");if(typeof o!="string")return o;let r=V(t);if(r===null)return chunkS3SPDK6N_cjs.P("SYMBOLIC_NONFINITE_OPERAND","integral needs an expression with an exact value.");let i=xe(r,o);return i.ok?w(i.value):chunkS3SPDK6N_cjs.P("SYMBOLIC_INTEGRAL_UNSUPPORTED",`Cannot integrate this: ${i.reason}.`)},72:e=>{let[t,n,o,r]=e,i=pt(n,"taylor");if(typeof i!="string")return i;let a=V(t),u=V(o);return a===null||u===null||u.kind!=="const"?chunkS3SPDK6N_cjs.P("SYMBOLIC_NONFINITE_OPERAND","taylor needs an expression and an exact expansion point."):w(Pn(a,i,u.value,r.toNumber()))},73:e=>{let t=[];for(let a of e){let u=V(a);if(u===null)return chunkS3SPDK6N_cjs.P("SYMBOLIC_NONFINITE_OPERAND","jacobian needs expressions with exact values.");t.push(u);}let n=new Set;for(let a of t)for(let u of chunkWFT3XUSH_cjs.u(a))n.add(u);let o=[...n].sort();if(o.length===0)return chunkS3SPDK6N_cjs.P("SYMBOLIC_JACOBIAN_NO_VARIABLES","jacobian needs at least one unknown to differentiate against.");let r=Ln(t,o),i=[];for(let a of r)for(let u of a)i.push(chunkWFT3XUSH_cjs.W(u));return chunkS3SPDK6N_cjs.C(r.length,o.length,chunkWFT3XUSH_cjs.Y(r.length,o.length,i))},74:e=>w(chunkWFT3XUSH_cjs.w(chunkWFT3XUSH_cjs.o(chunkWFT3XUSH_cjs.a,chunkWFT3XUSH_cjs.d(e[0].toNumber())))),75:e=>dt("conj",e[0]),76:e=>dt("re",e[0]),77:e=>dt("im",e[0]),78:e=>{let t=e[0];return t.type!==9?t:w(chunkWFT3XUSH_cjs.J(t.value))},79:e=>{let t=e[0];return t.type!==9?t:w(wn(t.value))},85:e=>{let t=e[0].toNumber(),n=e[1].toNumber();if(1+n<=0)return chunkS3SPDK6N_cjs.P("INVALID_RATE",`taxIn: rate ${n} makes (1 + rate) non-positive`);let o=t-t/(1+n);return e[0].type===6?_n(e[0],e[0].unit,n)??chunkS3SPDK6N_cjs.u(o,e[0].unit):chunkS3SPDK6N_cjs.n(o)},86:e=>{let t=e[0].toNumber(),n=e[1].toNumber();return e[0].type===6?In(e[0],n,e[0].unit):chunkS3SPDK6N_cjs.n(t*n)},87:e=>chunkS3SPDK6N_cjs.n(Math.sin(e[0].toNumber()*Math.PI/180)),88:e=>chunkS3SPDK6N_cjs.n(Math.cos(e[0].toNumber()*Math.PI/180)),89:e=>chunkS3SPDK6N_cjs.n(Math.tan(e[0].toNumber()*Math.PI/180)),90:e=>chunkS3SPDK6N_cjs.n(Math.asin(e[0].toNumber())*180/Math.PI),91:e=>chunkS3SPDK6N_cjs.n(Math.acos(e[0].toNumber())*180/Math.PI),92:e=>chunkS3SPDK6N_cjs.n(Math.atan(e[0].toNumber())*180/Math.PI),93:e=>chunkS3SPDK6N_cjs.u(e[0].toNumber(),"days"),94:e=>{let t=typeof e[1]?.value=="string"?e[1].value:void 0,n=typeof e[2]?.value=="string"?e[2].value:void 0;if(t===void 0||n===void 0)return chunkS3SPDK6N_cjs.P("UNKNOWN_UNIT",'both units have to be named, as in "12.5 minutes in minutes and seconds"');let o=chunkEZKR44MA_cjs.a[t.toLowerCase()],r=chunkEZKR44MA_cjs.a[n.toLowerCase()];if(o===void 0||r===void 0)return chunkS3SPDK6N_cjs.P("UNKNOWN_UNIT",`${t} and ${n}: one of these is not a unit`);if(o[0]!==r[0])return chunkS3SPDK6N_cjs.P("INCOMPATIBLE_UNITS",`${t} and ${n} measure different things`);if(r[1]>=o[1])return chunkS3SPDK6N_cjs.P("INCOMPATIBLE_UNITS",`${t} and ${n}: name the larger unit first`);let i=e[0],a=i.type===6&&i.unit!==void 0?chunkEZKR44MA_cjs.a[i.unit.toLowerCase()]:void 0,u=i.toNumber()*(a?.[1]??o[1]),l=Math.floor(u/o[1]),s=Math.round((u-l*o[1])/r[1]*1e3)/1e3;return chunkS3SPDK6N_cjs.t(`${l} ${t} ${s} ${n}`)},95:e=>{let t=e[0],n=String(e[1].value),o=t.type===6&&t.unit!==void 0?t.unit:"";return o.includes("/")?chunkS3SPDK6N_cjs.P("INVALID_RATE_UNIT",`${o}/${n}: that is already a rate`):chunkS3SPDK6N_cjs.u(t.toNumber(),`${o}/${n}`)},96:e=>{let t=e[0],n=e[1];if(n.type===6&&t.type===6&&chunkPHWIO4P3_cjs.i(n.unit)){let s=chunkPHWIO4P3_cjs.j(t.toNumber(),t.unit,n.toNumber(),n.unit);if(s!==null)return Cr(s)}if(n.type!==6||n.unit===void 0||!n.unit.includes("/"))return chunkS3SPDK6N_cjs.P("INVALID_RATE",'at: the right-hand side has to be a rate, as in "$30/hour"');let o=n.unit.indexOf("/"),r=n.unit.slice(0,o),i=n.unit.slice(o+1),a=t.type===6?t.unit:void 0,u=chunkEZKR44MA_cjs.a[i.toLowerCase()],l=a===void 0?void 0:chunkEZKR44MA_cjs.a[a.toLowerCase()];if(l!==void 0&&u!==void 0&&l[0]===u[0]){let p=t.toNumber()*l[1]/u[1]*n.toNumber();return r===""?chunkS3SPDK6N_cjs.n(p):chunkS3SPDK6N_cjs.u(p,r)}if(a!==void 0&&a===r){let s=t.toNumber()/n.toNumber();return chunkS3SPDK6N_cjs.u(s,Pr(i,s))}if(a===void 0){let s=t.toNumber()*n.toNumber();return r===""?chunkS3SPDK6N_cjs.n(s):chunkS3SPDK6N_cjs.u(s,r)}return chunkS3SPDK6N_cjs.P("INCOMPATIBLE_UNITS",`at: ${a} matches neither side of ${n.unit}`)},80:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber(),r=e[3].toNumber();if(r<=0)return chunkS3SPDK6N_cjs.P("INVALID_RATE",`compounding: ${r} periods per year is not a period`);if(1+n/r<=0)return chunkS3SPDK6N_cjs.P("INVALID_RATE",`compounding: rate ${n} makes each period non-positive`);let i=t*Math.pow(1+n/r,r*o);return e[0].type===6?chunkS3SPDK6N_cjs.u(i,e[0].unit):chunkS3SPDK6N_cjs.n(i)},81:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber(),r=e[3].toNumber();if(r<=0||1+n/r<=0)return chunkS3SPDK6N_cjs.P("INVALID_RATE",`compounding: rate ${n} over ${r} periods per year is not usable`);let i=t*(Math.pow(1+n/r,r*o)-1);return e[0].type===6?chunkS3SPDK6N_cjs.u(i,e[0].unit):chunkS3SPDK6N_cjs.n(i)},82:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber();if(1+n<=0)return chunkS3SPDK6N_cjs.P("INVALID_RATE",`presentValue: rate ${n} makes (1 + rate) non-positive`);let r=t/Math.pow(1+n,o);return e[0].type===6?chunkS3SPDK6N_cjs.u(r,e[0].unit):chunkS3SPDK6N_cjs.n(r)},83:e=>{let t=e[0].toNumber(),n=e[1].toNumber();return t===0?chunkS3SPDK6N_cjs.P("INVALID_RATE","roi: nothing was invested, so there is no return on it"):chunkS3SPDK6N_cjs.n((n-t)/t)},84:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber();return t<=0?chunkS3SPDK6N_cjs.P("INVALID_RATE","annual return: the amount invested must be positive"):o<=0?chunkS3SPDK6N_cjs.P("INVALID_RATE","annual return: the period must be longer than zero"):n<=0?chunkS3SPDK6N_cjs.P("INVALID_RATE","annual return: nothing was returned, so there is no annual rate"):chunkS3SPDK6N_cjs.N(Math.pow(n/t,1/o)-1)},97:e=>Gn(e[0],e[1].toNumber()),98:e=>{let t=e[1].toNumber();return !Number.isInteger(t)||t<1?chunkS3SPDK6N_cjs.P("INVALID_RANGE",`split: the number of shares must be a whole number of at least 1, not ${e[1].toNumber()}.`):chunkS3SPDK6N_cjs.H(Tn(e[0],t))},99:e=>{let t=e[0].toNumber(),n=Fr(e[1]),o=e[2].toNumber();if(n===null)return chunkS3SPDK6N_cjs.P("INVALID_RANGE",'savings goal: the duration must be in months or years, e.g. "in 2 years".');if(t<=0)return chunkS3SPDK6N_cjs.P("INVALID_RANGE","savings goal: the target must be positive.");if(n<=0)return chunkS3SPDK6N_cjs.P("INVALID_RANGE","savings goal: the duration must be positive.");if(o<0)return chunkS3SPDK6N_cjs.P("INVALID_RATE","savings goal: the rate must not be negative.");let r=Ur(t,o/12,n);return e[0].type===6?chunkS3SPDK6N_cjs.u(r,e[0].unit):chunkS3SPDK6N_cjs.n(r)},100:e=>{let t=e[0].toNumber(),n=e[1].toNumber(),o=e[2].toNumber(),r=e[3].toNumber(),i=typeof e[4]?.value=="string"?e[4].value:"periods";if(t<=0)return chunkS3SPDK6N_cjs.P("INVALID_RANGE","savings goal: the target must be positive.");if(n<=0)return chunkS3SPDK6N_cjs.P("INVALID_RANGE","savings goal: the contribution must be positive.");if(r<0)return chunkS3SPDK6N_cjs.P("INVALID_RATE","savings goal: the rate must not be negative.");let a=$r(t,n,r/o);return chunkS3SPDK6N_cjs.u(a,i)},101:e=>chunkS3SPDK6N_cjs.n(Math.sqrt(Be(e.map(t=>t.toNumber()),false))),102:e=>chunkS3SPDK6N_cjs.n(Math.sqrt(Be(e.map(t=>t.toNumber()),true))),103:e=>chunkS3SPDK6N_cjs.n(Be(e.map(t=>t.toNumber()),false)),104:e=>chunkS3SPDK6N_cjs.n(Be(e.map(t=>t.toNumber()),true)),105:e=>{if(e.length===0)return chunkS3SPDK6N_cjs.n(0);let t=e.map(n=>n.toNumber());return chunkS3SPDK6N_cjs.n(Math.max(...t)-Math.min(...t))},106:e=>{if(e.length===0)return chunkS3SPDK6N_cjs.n(0);let t=new Map,n=e[0].toNumber(),o=0;for(let r of e){let i=r.toNumber(),a=(t.get(i)??0)+1;t.set(i,a),a>o&&(o=a,n=i);}return chunkS3SPDK6N_cjs.n(n)},107:e=>{let t=0,n=0;for(let o=0;o+1<e.length;o+=2){let r=e[o].toNumber(),i=e[o+1].toNumber();t+=r*i,n+=i;}return n===0?chunkS3SPDK6N_cjs.P("WEIGHTED_AVERAGE_ZERO_WEIGHT","weighted average: the weights sum to zero, so there is nothing to divide by"):chunkS3SPDK6N_cjs.n(t/n)}};function Fr(e){if(e.type!==6)return null;let t=e.unit;return t==="months"||t==="month"?e.toNumber():t==="years"||t==="year"?e.toNumber()*12:null}function Ur(e,t,n){return t===0?e/n:e*t/(Math.pow(1+t,n)-1)}function $r(e,t,n){let o=n===0?e/t:Math.log(1+e*n/t)/Math.log(1+n);return Math.ceil(o-1e-9)}function dt(e,t){let n=V(t);return n===null?chunkS3SPDK6N_cjs.P("SYMBOLIC_NONFINITE_OPERAND",e+" needs a value with an exact number."):w(chunkWFT3XUSH_cjs.s(e,[n]))}function pt(e,t){return e?.type!==3?chunkS3SPDK6N_cjs.P("SYMBOLIC_REQUIRES_VARIABLE_NAME",`${t} needs the name of an unknown.`):e.value}function bt(e,t,n){let o=n*12,r=t/12,i=r===0?e/o:e*r/(1-Math.pow(1+r,-o)),a=i*o,u=a-e;return {monthlyPayment:i,totalRepayment:a,totalInterest:u}}var lu=Un.pluginFunctions,Xn=65535,Zn=0;function Br(){if(Zn>Xn)throw chunk6SYU4MH7_cjs.c.config("PLUGIN_FUNCTION_INDEX_POOL_EXHAUSTED",`allocatePluginFunctionIndex: pool exhausted (max ${Xn+1} allocations).`);return Zn++}var Hn=new Map;function su(e){let t=Hn.get(e);return t===void 0&&(t=Br(),Hn.set(e,t)),t}var yt=new Map;function cu(e,t){let n=e.toLowerCase(),o=yt.get(n);o&&o!==t&&console.warn(`[asConverterRegistry] Converter name "${n}" is already registered \u2014 overwriting.`),yt.set(n,t);}function mu(e){yt.delete(e.toLowerCase());}var qe=class qe{constructor(){this.values=new Map;this.listeners=new Set;this.notifyDepth=0;}get(t){return this.values.get(t)}has(t){return this.values.has(t)}set(t,n){let o=this.values.get(t);this.values.set(t,n),!(o!==void 0&&qr(o,n))&&this.notify(t,n);}notify(t,n){if(!(this.notifyDepth>=qe.MAX_NOTIFY_DEPTH)){this.notifyDepth++;try{for(let o of this.listeners)o(t,n);}finally{this.notifyDepth--;}}}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t);}}clear(){this.values.clear(),this.listeners.clear(),this.notifyDepth=0;}};qe.MAX_NOTIFY_DEPTH=64;var ht=qe;function qr(e,t){if(e.type!==t.type||e.unit!==t.unit||(e.timedOut??false)!==(t.timedOut??false))return false;let n=e.value,o=t.value;if(Array.isArray(n)||Array.isArray(o)){if(!Array.isArray(n)||!Array.isArray(o)||n.length!==o.length)return false;for(let r=0;r<n.length;r++)if(!Object.is(n[r],o[r]))return false;return true}return Object.is(n,o)}var du=new ht;function pu(e){return `global:${e}`}var Yr={sydney:"Australia/Sydney",melbourne:"Australia/Melbourne",brisbane:"Australia/Brisbane",perth:"Australia/Perth",adelaide:"Australia/Adelaide",canberra:"Australia/Sydney",auckland:"Pacific/Auckland",wellington:"Pacific/Auckland",fiji:"Pacific/Fiji",chicago:"America/Chicago",seattle:"America/Los_Angeles",denver:"America/Denver",phoenix:"America/Phoenix",toronto:"America/Toronto",montreal:"America/Toronto",vancouver:"America/Vancouver",ottawa:"America/Toronto",honolulu:"Pacific/Honolulu",anchorage:"America/Anchorage",miami:"America/New_York",boston:"America/New_York",atlanta:"America/New_York",dallas:"America/Chicago",houston:"America/Chicago",lima:"America/Lima",bogota:"America/Bogota",caracas:"America/Caracas",santiago:"America/Santiago",montevideo:"America/Montevideo",quito:"America/Guayaquil",london:"Europe/London",paris:"Europe/Paris",berlin:"Europe/Berlin",madrid:"Europe/Madrid",rome:"Europe/Rome",amsterdam:"Europe/Amsterdam",dublin:"Europe/Dublin",lisbon:"Europe/Lisbon",vienna:"Europe/Vienna",zurich:"Europe/Zurich",geneva:"Europe/Zurich",moscow:"Europe/Moscow",istanbul:"Europe/Istanbul",athens:"Europe/Athens",stockholm:"Europe/Stockholm",oslo:"Europe/Oslo",helsinki:"Europe/Helsinki",warsaw:"Europe/Warsaw",prague:"Europe/Prague",budapest:"Europe/Budapest",brussels:"Europe/Brussels",copenhagen:"Europe/Copenhagen",reykjavik:"Atlantic/Reykjavik",kiev:"Europe/Kyiv",kyiv:"Europe/Kyiv",tokyo:"Asia/Tokyo",osaka:"Asia/Tokyo",beijing:"Asia/Shanghai",shanghai:"Asia/Shanghai",seoul:"Asia/Seoul",singapore:"Asia/Singapore",bangkok:"Asia/Bangkok",jakarta:"Asia/Jakarta",manila:"Asia/Manila",mumbai:"Asia/Kolkata",delhi:"Asia/Kolkata",bangalore:"Asia/Kolkata",dubai:"Asia/Dubai",abudhabi:"Asia/Dubai",karachi:"Asia/Karachi",dhaka:"Asia/Dhaka",hanoi:"Asia/Ho_Chi_Minh",taipei:"Asia/Taipei",islamabad:"Asia/Karachi",riyadh:"Asia/Riyadh",telaviv:"Asia/Jerusalem",jerusalem:"Asia/Jerusalem",cairo:"Africa/Cairo",lagos:"Africa/Lagos",nairobi:"Africa/Nairobi",johannesburg:"Africa/Johannesburg",casablanca:"Africa/Casablanca",accra:"Africa/Accra",tunis:"Africa/Tunis",addisababa:"Africa/Addis_Ababa",france:"Europe/Paris",germany:"Europe/Berlin",spain:"Europe/Madrid",italy:"Europe/Rome",japan:"Asia/Tokyo",china:"Asia/Shanghai",india:"Asia/Kolkata",brazil:"America/Sao_Paulo",russia:"Europe/Moscow",australia:"Australia/Sydney",canada:"America/Toronto",mexico:"America/Mexico_City",uk:"Europe/London",usa:"America/New_York",ireland:"Europe/Dublin",netherlands:"Europe/Amsterdam",sweden:"Europe/Stockholm",norway:"Europe/Oslo",poland:"Europe/Warsaw",turkey:"Europe/Istanbul",egypt:"Africa/Cairo",nigeria:"Africa/Lagos"},Gr={"new york":"America/New_York","los angeles":"America/Los_Angeles","san francisco":"America/Los_Angeles","las vegas":"America/Los_Angeles","mexico city":"America/Mexico_City","hong kong":"Asia/Hong_Kong","kuala lumpur":"Asia/Kuala_Lumpur","sao paulo":"America/Sao_Paulo","buenos aires":"America/Argentina/Buenos_Aires","rio de janeiro":"America/Sao_Paulo","cape town":"Africa/Johannesburg","new delhi":"Asia/Kolkata","united kingdom":"Europe/London","united states":"America/New_York","south africa":"Africa/Johannesburg"},jr={pst:"America/Los_Angeles",pdt:"America/Los_Angeles",est:"America/New_York",edt:"America/New_York",cst:"America/Chicago",cdt:"America/Chicago",mst:"America/Denver",mdt:"America/Denver",hst:"Pacific/Honolulu",bst:"Europe/London",cet:"Europe/Paris",cest:"Europe/Paris",jst:"Asia/Tokyo",ist:"Asia/Kolkata",aest:"Australia/Sydney",aedt:"Australia/Sydney"},Kr={...Yr,...Gr,...jr};function yu(e){let t=e.trim().toLowerCase();return t==="utc"||t==="gmt"?"UTC":Kr[t]??null}exports.A=qn;exports.B=Fa;exports.C=uu;exports.D=lu;exports.E=Br;exports.F=su;exports.G=yt;exports.H=cu;exports.I=mu;exports.J=du;exports.K=pu;exports.L=Gr;exports.M=Kr;exports.N=yu;exports.a=ge;exports.b=In;exports.c=En;exports.d=dn;exports.e=ki;exports.f=_i;exports.g=Ti;exports.h=Vi;exports.i=yn;exports.j=he;exports.k=qi;exports.l=Yi;exports.m=Gi;exports.n=Nn;exports.o=ji;exports.p=Ki;exports.q=nt;exports.r=Xi;exports.s=Zi;exports.t=Hi;exports.u=Wi;exports.v=Ne;exports.w=Ji;exports.x=wr;exports.y=Un;exports.z=Bn;//# sourceMappingURL=chunk-FESR6PZI.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-FESR6PZI.cjs.map
|