@gridsheet/functions 3.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/dist/index.d.ts +5 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +332 -0
  4. package/dist/information/index.d.ts +4 -0
  5. package/dist/information/index.d.ts.map +1 -0
  6. package/dist/information/isblank.d.ts +9 -0
  7. package/dist/information/isblank.d.ts.map +1 -0
  8. package/dist/information/isdate.d.ts +9 -0
  9. package/dist/information/isdate.d.ts.map +1 -0
  10. package/dist/information/isemail.d.ts +9 -0
  11. package/dist/information/isemail.d.ts.map +1 -0
  12. package/dist/information/iserr.d.ts +9 -0
  13. package/dist/information/iserr.d.ts.map +1 -0
  14. package/dist/information/iserror.d.ts +9 -0
  15. package/dist/information/iserror.d.ts.map +1 -0
  16. package/dist/information/isformula.d.ts +9 -0
  17. package/dist/information/isformula.d.ts.map +1 -0
  18. package/dist/information/islogical.d.ts +9 -0
  19. package/dist/information/islogical.d.ts.map +1 -0
  20. package/dist/information/isna.d.ts +9 -0
  21. package/dist/information/isna.d.ts.map +1 -0
  22. package/dist/information/isnontext.d.ts +9 -0
  23. package/dist/information/isnontext.d.ts.map +1 -0
  24. package/dist/information/isref.d.ts +9 -0
  25. package/dist/information/isref.d.ts.map +1 -0
  26. package/dist/information/istext.d.ts +9 -0
  27. package/dist/information/istext.d.ts.map +1 -0
  28. package/dist/information/n.d.ts +9 -0
  29. package/dist/information/n.d.ts.map +1 -0
  30. package/dist/information/na.d.ts +9 -0
  31. package/dist/information/na.d.ts.map +1 -0
  32. package/dist/information/sheets.d.ts +9 -0
  33. package/dist/information/sheets.d.ts.map +1 -0
  34. package/dist/logical/ifna.d.ts +10 -0
  35. package/dist/logical/ifna.d.ts.map +1 -0
  36. package/dist/logical/ifs.d.ts +11 -0
  37. package/dist/logical/ifs.d.ts.map +1 -0
  38. package/dist/logical/index.d.ts +4 -0
  39. package/dist/logical/index.d.ts.map +1 -0
  40. package/dist/logical/xor.d.ts +9 -0
  41. package/dist/logical/xor.d.ts.map +1 -0
  42. package/dist/lookup/column.d.ts +12 -0
  43. package/dist/lookup/column.d.ts.map +1 -0
  44. package/dist/lookup/columns.d.ts +9 -0
  45. package/dist/lookup/columns.d.ts.map +1 -0
  46. package/dist/lookup/hlookup.d.ts +10 -0
  47. package/dist/lookup/hlookup.d.ts.map +1 -0
  48. package/dist/lookup/index.d.ts +4 -0
  49. package/dist/lookup/index.d.ts.map +1 -0
  50. package/dist/lookup/index.js +377 -0
  51. package/dist/lookup/indexFn.d.ts +10 -0
  52. package/dist/lookup/indexFn.d.ts.map +1 -0
  53. package/dist/lookup/match.d.ts +10 -0
  54. package/dist/lookup/match.d.ts.map +1 -0
  55. package/dist/lookup/row.d.ts +12 -0
  56. package/dist/lookup/row.d.ts.map +1 -0
  57. package/dist/lookup/rows.d.ts +9 -0
  58. package/dist/lookup/rows.d.ts.map +1 -0
  59. package/dist/lookup/sheet.d.ts +9 -0
  60. package/dist/lookup/sheet.d.ts.map +1 -0
  61. package/dist/lookup/vlookup.d.ts +10 -0
  62. package/dist/lookup/vlookup.d.ts.map +1 -0
  63. package/dist/math/__matrix_base.d.ts +15 -0
  64. package/dist/math/__matrix_base.d.ts.map +1 -0
  65. package/dist/math/acos.d.ts +9 -0
  66. package/dist/math/acos.d.ts.map +1 -0
  67. package/dist/math/asin.d.ts +9 -0
  68. package/dist/math/asin.d.ts.map +1 -0
  69. package/dist/math/atan.d.ts +9 -0
  70. package/dist/math/atan.d.ts.map +1 -0
  71. package/dist/math/atan2.d.ts +9 -0
  72. package/dist/math/atan2.d.ts.map +1 -0
  73. package/dist/math/base.d.ts +10 -0
  74. package/dist/math/base.d.ts.map +1 -0
  75. package/dist/math/cos.d.ts +9 -0
  76. package/dist/math/cos.d.ts.map +1 -0
  77. package/dist/math/countif.d.ts +9 -0
  78. package/dist/math/countif.d.ts.map +1 -0
  79. package/dist/math/countifs.d.ts +10 -0
  80. package/dist/math/countifs.d.ts.map +1 -0
  81. package/dist/math/even.d.ts +9 -0
  82. package/dist/math/even.d.ts.map +1 -0
  83. package/dist/math/exp.d.ts +10 -0
  84. package/dist/math/exp.d.ts.map +1 -0
  85. package/dist/math/fact.d.ts +9 -0
  86. package/dist/math/fact.d.ts.map +1 -0
  87. package/dist/math/index.d.ts +4 -0
  88. package/dist/math/index.d.ts.map +1 -0
  89. package/dist/math/index.js +1019 -0
  90. package/dist/math/int.d.ts +9 -0
  91. package/dist/math/int.d.ts.map +1 -0
  92. package/dist/math/iseven.d.ts +9 -0
  93. package/dist/math/iseven.d.ts.map +1 -0
  94. package/dist/math/isodd.d.ts +9 -0
  95. package/dist/math/isodd.d.ts.map +1 -0
  96. package/dist/math/lcm.d.ts +10 -0
  97. package/dist/math/lcm.d.ts.map +1 -0
  98. package/dist/math/ln.d.ts +9 -0
  99. package/dist/math/ln.d.ts.map +1 -0
  100. package/dist/math/log.d.ts +9 -0
  101. package/dist/math/log.d.ts.map +1 -0
  102. package/dist/math/log10.d.ts +9 -0
  103. package/dist/math/log10.d.ts.map +1 -0
  104. package/dist/math/mdeterm.d.ts +11 -0
  105. package/dist/math/mdeterm.d.ts.map +1 -0
  106. package/dist/math/minverse.d.ts +12 -0
  107. package/dist/math/minverse.d.ts.map +1 -0
  108. package/dist/math/mmult.d.ts +11 -0
  109. package/dist/math/mmult.d.ts.map +1 -0
  110. package/dist/math/mod.d.ts +10 -0
  111. package/dist/math/mod.d.ts.map +1 -0
  112. package/dist/math/odd.d.ts +9 -0
  113. package/dist/math/odd.d.ts.map +1 -0
  114. package/dist/math/pi.d.ts +9 -0
  115. package/dist/math/pi.d.ts.map +1 -0
  116. package/dist/math/product.d.ts +10 -0
  117. package/dist/math/product.d.ts.map +1 -0
  118. package/dist/math/radians.d.ts +9 -0
  119. package/dist/math/radians.d.ts.map +1 -0
  120. package/dist/math/rand.d.ts +9 -0
  121. package/dist/math/rand.d.ts.map +1 -0
  122. package/dist/math/round.d.ts +9 -0
  123. package/dist/math/round.d.ts.map +1 -0
  124. package/dist/math/rounddown.d.ts +9 -0
  125. package/dist/math/rounddown.d.ts.map +1 -0
  126. package/dist/math/roundup.d.ts +9 -0
  127. package/dist/math/roundup.d.ts.map +1 -0
  128. package/dist/math/sequence.d.ts +11 -0
  129. package/dist/math/sequence.d.ts.map +1 -0
  130. package/dist/math/sign.d.ts +9 -0
  131. package/dist/math/sign.d.ts.map +1 -0
  132. package/dist/math/sin.d.ts +9 -0
  133. package/dist/math/sin.d.ts.map +1 -0
  134. package/dist/math/sqrt.d.ts +9 -0
  135. package/dist/math/sqrt.d.ts.map +1 -0
  136. package/dist/math/sumif.d.ts +9 -0
  137. package/dist/math/sumif.d.ts.map +1 -0
  138. package/dist/math/sumifs.d.ts +10 -0
  139. package/dist/math/sumifs.d.ts.map +1 -0
  140. package/dist/math/sumproduct.d.ts +10 -0
  141. package/dist/math/sumproduct.d.ts.map +1 -0
  142. package/dist/math/sumsq.d.ts +9 -0
  143. package/dist/math/sumsq.d.ts.map +1 -0
  144. package/dist/math/tan.d.ts +9 -0
  145. package/dist/math/tan.d.ts.map +1 -0
  146. package/dist/math/transpose.d.ts +11 -0
  147. package/dist/math/transpose.d.ts.map +1 -0
  148. package/dist/math/trunc.d.ts +9 -0
  149. package/dist/math/trunc.d.ts.map +1 -0
  150. package/dist/math/unaryPercent.d.ts +9 -0
  151. package/dist/math/unaryPercent.d.ts.map +1 -0
  152. package/dist/math/uplus.d.ts +9 -0
  153. package/dist/math/uplus.d.ts.map +1 -0
  154. package/dist/statistics/averageif.d.ts +9 -0
  155. package/dist/statistics/averageif.d.ts.map +1 -0
  156. package/dist/statistics/averageifs.d.ts +10 -0
  157. package/dist/statistics/averageifs.d.ts.map +1 -0
  158. package/dist/statistics/correl.d.ts +10 -0
  159. package/dist/statistics/correl.d.ts.map +1 -0
  160. package/dist/statistics/covariance_s.d.ts +10 -0
  161. package/dist/statistics/covariance_s.d.ts.map +1 -0
  162. package/dist/statistics/index.d.ts +4 -0
  163. package/dist/statistics/index.d.ts.map +1 -0
  164. package/dist/statistics/index.js +663 -0
  165. package/dist/statistics/median.d.ts +10 -0
  166. package/dist/statistics/median.d.ts.map +1 -0
  167. package/dist/statistics/mode_sngl.d.ts +10 -0
  168. package/dist/statistics/mode_sngl.d.ts.map +1 -0
  169. package/dist/statistics/percentile_inc.d.ts +10 -0
  170. package/dist/statistics/percentile_inc.d.ts.map +1 -0
  171. package/dist/statistics/quartile_inc.d.ts +10 -0
  172. package/dist/statistics/quartile_inc.d.ts.map +1 -0
  173. package/dist/statistics/rank_eq.d.ts +10 -0
  174. package/dist/statistics/rank_eq.d.ts.map +1 -0
  175. package/dist/statistics/rsq.d.ts +10 -0
  176. package/dist/statistics/rsq.d.ts.map +1 -0
  177. package/dist/statistics/stdev_p.d.ts +10 -0
  178. package/dist/statistics/stdev_p.d.ts.map +1 -0
  179. package/dist/statistics/stdev_s.d.ts +10 -0
  180. package/dist/statistics/stdev_s.d.ts.map +1 -0
  181. package/dist/statistics/t_test.d.ts +10 -0
  182. package/dist/statistics/t_test.d.ts.map +1 -0
  183. package/dist/statistics/var_p.d.ts +10 -0
  184. package/dist/statistics/var_p.d.ts.map +1 -0
  185. package/dist/statistics/var_s.d.ts +10 -0
  186. package/dist/statistics/var_s.d.ts.map +1 -0
  187. package/dist/text/char.d.ts +9 -0
  188. package/dist/text/char.d.ts.map +1 -0
  189. package/dist/text/clean.d.ts +9 -0
  190. package/dist/text/clean.d.ts.map +1 -0
  191. package/dist/text/concatenate.d.ts +9 -0
  192. package/dist/text/concatenate.d.ts.map +1 -0
  193. package/dist/text/exact.d.ts +9 -0
  194. package/dist/text/exact.d.ts.map +1 -0
  195. package/dist/text/index.d.ts +4 -0
  196. package/dist/text/index.d.ts.map +1 -0
  197. package/dist/text/index.js +261 -0
  198. package/dist/text/join.d.ts +10 -0
  199. package/dist/text/join.d.ts.map +1 -0
  200. package/dist/text/lenb.d.ts +9 -0
  201. package/dist/text/lenb.d.ts.map +1 -0
  202. package/dist/text/lower.d.ts +9 -0
  203. package/dist/text/lower.d.ts.map +1 -0
  204. package/dist/text/proper.d.ts +9 -0
  205. package/dist/text/proper.d.ts.map +1 -0
  206. package/dist/text/replace.d.ts +10 -0
  207. package/dist/text/replace.d.ts.map +1 -0
  208. package/dist/text/rept.d.ts +10 -0
  209. package/dist/text/rept.d.ts.map +1 -0
  210. package/dist/text/trim.d.ts +9 -0
  211. package/dist/text/trim.d.ts.map +1 -0
  212. package/dist/text/unichar.d.ts +9 -0
  213. package/dist/text/unichar.d.ts.map +1 -0
  214. package/dist/text/unicode.d.ts +9 -0
  215. package/dist/text/unicode.d.ts.map +1 -0
  216. package/dist/text/upper.d.ts +9 -0
  217. package/dist/text/upper.d.ts.map +1 -0
  218. package/dist/time/__utils.d.ts +6 -0
  219. package/dist/time/__utils.d.ts.map +1 -0
  220. package/dist/time/date.d.ts +9 -0
  221. package/dist/time/date.d.ts.map +1 -0
  222. package/dist/time/day.d.ts +9 -0
  223. package/dist/time/day.d.ts.map +1 -0
  224. package/dist/time/days.d.ts +9 -0
  225. package/dist/time/days.d.ts.map +1 -0
  226. package/dist/time/hour.d.ts +9 -0
  227. package/dist/time/hour.d.ts.map +1 -0
  228. package/dist/time/index.d.ts +4 -0
  229. package/dist/time/index.d.ts.map +1 -0
  230. package/dist/time/index.js +212 -0
  231. package/dist/time/minute.d.ts +9 -0
  232. package/dist/time/minute.d.ts.map +1 -0
  233. package/dist/time/month.d.ts +9 -0
  234. package/dist/time/month.d.ts.map +1 -0
  235. package/dist/time/second.d.ts +9 -0
  236. package/dist/time/second.d.ts.map +1 -0
  237. package/dist/time/time.d.ts +9 -0
  238. package/dist/time/time.d.ts.map +1 -0
  239. package/dist/time/today.d.ts +9 -0
  240. package/dist/time/today.d.ts.map +1 -0
  241. package/dist/time/workday.d.ts +9 -0
  242. package/dist/time/workday.d.ts.map +1 -0
  243. package/dist/time/year.d.ts +9 -0
  244. package/dist/time/year.d.ts.map +1 -0
  245. package/dist/types.d.ts +2 -0
  246. package/dist/types.d.ts.map +1 -0
  247. package/package.json +86 -0
@@ -0,0 +1,1019 @@
1
+ import { BaseFunction as o, FormulaError as u, ensureNumber as h, Table as f, solveTable as v, conditionArg as g, ensureString as b, eachMatrix as l, stripTable as w, check as y, createBooleanMask as M } from "@gridsheet/react-core";
2
+ const T = "Returns the result of the modulo operation.";
3
+ class A extends o {
4
+ constructor() {
5
+ super(...arguments), this.example = "MOD(10, 4)", this.description = T, this.defs = [
6
+ {
7
+ name: "dividend",
8
+ description: "A number that will be divided by divisor.",
9
+ acceptedTypes: ["number"]
10
+ },
11
+ { name: "divisor", description: "A number that will divide a dividend.", acceptedTypes: ["number"] }
12
+ ], this.category = "math";
13
+ }
14
+ validate(e) {
15
+ if (e.length !== 2)
16
+ throw new u("#N/A", "Number of arguments for MOD is incorrect.");
17
+ const t = e.map((n) => h(n));
18
+ if (t[1] === 0)
19
+ throw new u("#DIV/0!", "The second argument must be non-zero.");
20
+ return t;
21
+ }
22
+ main(e, t) {
23
+ return (e % t + t) % t;
24
+ }
25
+ }
26
+ const N = "Returns the positive square root of a positive number.";
27
+ class R extends o {
28
+ constructor() {
29
+ super(...arguments), this.example = "SQRT(9)", this.description = N, this.defs = [
30
+ {
31
+ name: "value",
32
+ description: "A number for which the positive square root is to be found.",
33
+ acceptedTypes: ["number"]
34
+ }
35
+ ], this.category = "math";
36
+ }
37
+ main(e) {
38
+ if (e < 0)
39
+ throw new u("NUM!", "First argument must be positive.");
40
+ return Math.sqrt(e);
41
+ }
42
+ }
43
+ const F = "Returns the product of a series of numbers.";
44
+ class S extends o {
45
+ constructor() {
46
+ super(...arguments), this.example = "PRODUCT(2,3,4)", this.description = F, this.defs = [
47
+ {
48
+ name: "value",
49
+ description: "Numbers or ranges to multiply.",
50
+ takesMatrix: !0,
51
+ acceptedTypes: ["number", "matrix"],
52
+ variadic: !0
53
+ }
54
+ ], this.category = "math";
55
+ }
56
+ validate(e) {
57
+ const t = [];
58
+ return e.forEach((n) => {
59
+ if (n instanceof f) {
60
+ t.push(
61
+ ...v({ table: n }).reduce((r, s) => r.concat(s)).filter((r) => typeof r == "number")
62
+ );
63
+ return;
64
+ }
65
+ t.push(h(n));
66
+ }), t;
67
+ }
68
+ main(...e) {
69
+ return e.reduce((t, n) => t * n);
70
+ }
71
+ }
72
+ const U = "Round a number to the specified number of decimal places according to standard rules.";
73
+ class E extends o {
74
+ constructor() {
75
+ super(...arguments), this.example = "ROUND(99.44,1)", this.description = U, this.defs = [
76
+ {
77
+ name: "value",
78
+ description: "A number to be rounded.",
79
+ acceptedTypes: ["number"]
80
+ },
81
+ {
82
+ name: "digit",
83
+ description: "The number of decimal places after rounding.",
84
+ acceptedTypes: ["number"],
85
+ optional: !0
86
+ }
87
+ ], this.category = "math";
88
+ }
89
+ main(e, t = 0) {
90
+ const n = Math.pow(10, t);
91
+ return Math.round(e * n) / n;
92
+ }
93
+ }
94
+ const $ = "Round down a number to the specified number of decimal places according to standard rules.";
95
+ class q extends o {
96
+ constructor() {
97
+ super(...arguments), this.example = "ROUNDDOWN(99.44,1)", this.description = $, this.defs = [
98
+ {
99
+ name: "value",
100
+ description: "A number to be rounded down.",
101
+ acceptedTypes: ["number"]
102
+ },
103
+ {
104
+ name: "digit",
105
+ description: "The number of decimal places after rounding.",
106
+ acceptedTypes: ["number"],
107
+ optional: !0
108
+ }
109
+ ], this.category = "math";
110
+ }
111
+ main(e, t = 0) {
112
+ const n = Math.pow(10, t);
113
+ return Math.floor(e * n) / n;
114
+ }
115
+ }
116
+ const C = "Round up a number to the specified number of decimal places according to standard rules.";
117
+ class I extends o {
118
+ constructor() {
119
+ super(...arguments), this.example = "ROUNDUP(99.44,1)", this.description = C, this.defs = [
120
+ {
121
+ name: "value",
122
+ description: "A number to be rounded up.",
123
+ acceptedTypes: ["number"]
124
+ },
125
+ {
126
+ name: "digit",
127
+ description: "The number of decimal places after rounding.",
128
+ acceptedTypes: ["number"],
129
+ optional: !0
130
+ }
131
+ ], this.category = "math";
132
+ }
133
+ main(e, t = 0) {
134
+ const n = Math.pow(10, t);
135
+ return Math.ceil(e * n) / n;
136
+ }
137
+ }
138
+ const k = "Returns the logarithm of a number whose base is the specified number.";
139
+ class D extends o {
140
+ constructor() {
141
+ super(...arguments), this.example = "LOG(128, 2)", this.description = k, this.defs = [
142
+ {
143
+ name: "value",
144
+ description: "The value for the logarithm of the specified number as base.",
145
+ acceptedTypes: ["number"]
146
+ },
147
+ { name: "base", description: "An exponent to power the base.", acceptedTypes: ["number"] }
148
+ ], this.category = "math";
149
+ }
150
+ main(e, t) {
151
+ if (e <= 0)
152
+ throw new u("NUM!", "value must be greater than 0");
153
+ if (t <= 1)
154
+ throw new u("NUM!", "base must be greater than 1");
155
+ return Math.log2(e) / Math.log2(t);
156
+ }
157
+ }
158
+ const O = "Returns the logarithm of 10";
159
+ class L extends o {
160
+ constructor() {
161
+ super(...arguments), this.example = "LOG10(100)", this.description = O, this.defs = [
162
+ {
163
+ name: "value",
164
+ description: "The value for the logarithm of 10",
165
+ acceptedTypes: ["number"]
166
+ }
167
+ ], this.category = "math";
168
+ }
169
+ main(e) {
170
+ if (e <= 0)
171
+ throw new u("NUM!", "value must be greater than 0");
172
+ return Math.log10(e);
173
+ }
174
+ }
175
+ const P = "Returns the logarithm of e";
176
+ class V extends o {
177
+ constructor() {
178
+ super(...arguments), this.example = "LN(100)", this.description = P, this.defs = [
179
+ {
180
+ name: "value",
181
+ description: "The value for the logarithm of e",
182
+ acceptedTypes: ["number"]
183
+ }
184
+ ], this.category = "math";
185
+ }
186
+ main(e) {
187
+ if (e <= 0)
188
+ throw new u("NUM!", "value must be greater than 0");
189
+ return Math.log(e);
190
+ }
191
+ }
192
+ const B = "Returns the power of a number whose base is the Euler number e.";
193
+ class _ extends o {
194
+ constructor() {
195
+ super(...arguments), this.example = "EXP(2)", this.description = B, this.defs = [
196
+ {
197
+ name: "exponent",
198
+ description: "It is an exponent of power with e as the base.",
199
+ acceptedTypes: ["number"]
200
+ }
201
+ ], this.category = "math";
202
+ }
203
+ validate(e) {
204
+ if (e.length !== 1)
205
+ throw new u("#N/A", "Number of arguments for EXP is incorrect.");
206
+ return [h(e[0])];
207
+ }
208
+ main(e) {
209
+ return Math.exp(e);
210
+ }
211
+ }
212
+ const z = "Returns the value of Pi.";
213
+ class j extends o {
214
+ constructor() {
215
+ super(...arguments), this.example = "PI()", this.description = z, this.defs = [], this.category = "math";
216
+ }
217
+ main() {
218
+ return Math.PI;
219
+ }
220
+ }
221
+ const G = "Converts an angle value in degrees to radians.";
222
+ class Q extends o {
223
+ constructor() {
224
+ super(...arguments), this.example = "RADIANS(180)", this.description = G, this.defs = [
225
+ {
226
+ name: "angle",
227
+ description: "An angle in degrees that you want to convert to radians.",
228
+ acceptedTypes: ["number"]
229
+ }
230
+ ], this.category = "math";
231
+ }
232
+ main(e) {
233
+ return e / 180 * Math.PI;
234
+ }
235
+ }
236
+ const X = "Returns the sin of the angle specified in radians.";
237
+ class W extends o {
238
+ constructor() {
239
+ super(...arguments), this.example = "SIN(PI()/2)", this.description = X, this.defs = [
240
+ {
241
+ name: "angle",
242
+ description: "An angle in radians, at which you want the sin.",
243
+ acceptedTypes: ["number"]
244
+ }
245
+ ], this.category = "math";
246
+ }
247
+ main(e) {
248
+ return Math.sin(e);
249
+ }
250
+ }
251
+ const Y = "Returns the cos of the angle specified in radians.";
252
+ class H extends o {
253
+ constructor() {
254
+ super(...arguments), this.example = "COS(PI())", this.description = Y, this.defs = [
255
+ {
256
+ name: "angle",
257
+ description: "An angle in radians, at which you want the cos.",
258
+ acceptedTypes: ["number"]
259
+ }
260
+ ], this.category = "math";
261
+ }
262
+ main(e) {
263
+ return Math.cos(e);
264
+ }
265
+ }
266
+ const J = "Returns the tan of the angle specified in radians.";
267
+ class K extends o {
268
+ constructor() {
269
+ super(...arguments), this.example = "TAN(PI()/4)", this.description = J, this.defs = [
270
+ {
271
+ name: "angle",
272
+ description: "An angle in radians, at which you want the tan.",
273
+ acceptedTypes: ["number"]
274
+ }
275
+ ], this.category = "math";
276
+ }
277
+ main(e) {
278
+ return Math.tan(e);
279
+ }
280
+ }
281
+ const Z = "Returns the inverse sin of the value in radians.";
282
+ class ee extends o {
283
+ constructor() {
284
+ super(...arguments), this.example = "ASIN(1)", this.description = Z, this.defs = [
285
+ {
286
+ name: "value",
287
+ description: "A value for the inverse sin between -1 and 1.",
288
+ acceptedTypes: ["number"]
289
+ }
290
+ ], this.category = "math";
291
+ }
292
+ main(e) {
293
+ if (-1 > e || e > 1)
294
+ throw new u("#NUM!", "value must be between -1 and 1");
295
+ return Math.asin(e);
296
+ }
297
+ }
298
+ const te = "Returns the inverse cos of the value in radians.";
299
+ class ne extends o {
300
+ constructor() {
301
+ super(...arguments), this.example = "ACOS(0)", this.description = te, this.defs = [
302
+ {
303
+ name: "value",
304
+ description: "A value for the inverse cos between -1 and 1.",
305
+ acceptedTypes: ["number"]
306
+ }
307
+ ], this.category = "math";
308
+ }
309
+ main(e) {
310
+ if (-1 > e || e > 1)
311
+ throw new u("#NUM!", "value must be between -1 and 1");
312
+ return Math.acos(e);
313
+ }
314
+ }
315
+ const se = "Returns the inverse tan of the value in radians.";
316
+ class re extends o {
317
+ constructor() {
318
+ super(...arguments), this.example = "ATAN(1)", this.description = se, this.defs = [
319
+ {
320
+ name: "value",
321
+ description: "A value for the inverse tan.",
322
+ acceptedTypes: ["number"]
323
+ }
324
+ ], this.category = "math";
325
+ }
326
+ main(e) {
327
+ return Math.atan(e);
328
+ }
329
+ }
330
+ const ie = "Returns the angle in radians between the x-axis and a line passing from the origin through a given coordinate point (x, y).";
331
+ class ae extends o {
332
+ constructor() {
333
+ super(...arguments), this.example = "ATAN2(4,3)", this.description = ie, this.defs = [
334
+ {
335
+ name: "x",
336
+ description: "x of the point.",
337
+ acceptedTypes: ["number"]
338
+ },
339
+ {
340
+ name: "y",
341
+ description: "y of the point.",
342
+ acceptedTypes: ["number"]
343
+ }
344
+ ], this.category = "math";
345
+ }
346
+ main(e, t) {
347
+ return Math.atan2(e, t);
348
+ }
349
+ }
350
+ const oe = "Returns a random number between 0 and 1.";
351
+ class ce extends o {
352
+ constructor() {
353
+ super(...arguments), this.example = "RAND()", this.description = oe, this.defs = [], this.category = "math";
354
+ }
355
+ main() {
356
+ return Math.random();
357
+ }
358
+ }
359
+ const ue = "Returns a value interpreted as a percentage, i.e. divides the number by 100.";
360
+ class me extends o {
361
+ constructor() {
362
+ super(...arguments), this.example = "UNARY_PERCENT(50)", this.description = ue, this.defs = [
363
+ {
364
+ name: "value",
365
+ description: "A number to be divided by 100.",
366
+ acceptedTypes: ["number"]
367
+ }
368
+ ], this.category = "math";
369
+ }
370
+ main(e) {
371
+ return e / 100;
372
+ }
373
+ }
374
+ const de = "Returns the number with its sign unchanged (unary plus).";
375
+ class he extends o {
376
+ constructor() {
377
+ super(...arguments), this.example = "UPLUS(4)", this.description = de, this.defs = [
378
+ {
379
+ name: "value",
380
+ description: "A number to return as-is.",
381
+ acceptedTypes: ["number"]
382
+ }
383
+ ], this.category = "math";
384
+ }
385
+ main(e) {
386
+ return e;
387
+ }
388
+ }
389
+ const pe = "Returns the sum of a series of cells.";
390
+ class le extends o {
391
+ constructor() {
392
+ super(...arguments), this.example = 'SUMIF(A1:A10,">20")', this.description = pe, this.defs = [
393
+ { name: "range", description: "A condition range.", takesMatrix: !0, acceptedTypes: ["matrix"] },
394
+ g,
395
+ {
396
+ name: "sum_range",
397
+ description: "A range to be summarized.",
398
+ takesMatrix: !0,
399
+ acceptedTypes: ["matrix"],
400
+ optional: !0
401
+ }
402
+ ], this.category = "math";
403
+ }
404
+ main(e, t, n) {
405
+ const r = b(t), s = [], a = [];
406
+ l(
407
+ e,
408
+ (c) => {
409
+ s.push(c);
410
+ },
411
+ this.at
412
+ ), n && l(
413
+ n,
414
+ (c) => {
415
+ a.push(c);
416
+ },
417
+ this.at
418
+ );
419
+ let m = 0;
420
+ return s.forEach((c, d) => {
421
+ const p = w({ value: (n ? a[d] : c) ?? 0 });
422
+ typeof p == "number" && y(c, r) && (m += p);
423
+ }), m;
424
+ }
425
+ }
426
+ const fe = "Returns the sum of a range depending on multiple criteria.";
427
+ class ge extends o {
428
+ constructor() {
429
+ super(...arguments), this.example = 'SUMIFS(A1:A10, B1:B10, ">20")', this.description = fe, this.defs = [
430
+ { name: "sum_range", description: "The range to be summed.", takesMatrix: !0, acceptedTypes: ["matrix"] },
431
+ {
432
+ name: "range",
433
+ description: "First condition range.",
434
+ takesMatrix: !0,
435
+ acceptedTypes: ["matrix"],
436
+ variadic: !0
437
+ },
438
+ { ...g, name: "condition", variadic: !0 }
439
+ ], this.category = "math";
440
+ }
441
+ validate(e) {
442
+ const t = super.validate(e);
443
+ if ((t.length - 1) % 2 !== 0)
444
+ throw new u("#N/A", "SUMIFS requires sum_range and at least one range/condition pair.");
445
+ if (!(t[0] instanceof f))
446
+ throw new u("#VALUE!", "First argument of SUMIFS must be a range.");
447
+ const n = t[0].getNumRows(), r = t[0].getNumCols(), s = [], a = [];
448
+ for (let d = 1; d < t.length; d += 2) {
449
+ if (!(t[d] instanceof f))
450
+ throw new u("#VALUE!", `Argument ${d + 1} of SUMIFS must be a range.`);
451
+ if (t[d].getNumRows() !== n || t[d].getNumCols() !== r)
452
+ throw new u("#VALUE!", "Array arguments to SUMIFS are of different size.");
453
+ s.push(t[d]), a.push(b(t[d + 1]));
454
+ }
455
+ const m = t[0], c = M(s, a, this.at);
456
+ return [m, c];
457
+ }
458
+ main(e, t) {
459
+ let n = 0;
460
+ return l(
461
+ e,
462
+ (r, s) => {
463
+ if (s && t[s.y][s.x]) {
464
+ const a = w({ value: r ?? 0 });
465
+ typeof a == "number" && (n += a);
466
+ }
467
+ },
468
+ this.at
469
+ ), n;
470
+ }
471
+ }
472
+ const xe = "Returns the count of a series of cells.";
473
+ class be extends o {
474
+ constructor() {
475
+ super(...arguments), this.example = 'COUNTIF(A1:A10,">20")', this.description = xe, this.defs = [
476
+ { name: "range", description: "Target range.", takesMatrix: !0, acceptedTypes: ["matrix"] },
477
+ { ...g }
478
+ ], this.category = "math";
479
+ }
480
+ main(e, t) {
481
+ const n = b(t);
482
+ let r = 0;
483
+ return l(
484
+ e,
485
+ (s) => {
486
+ y(s, n) && r++;
487
+ },
488
+ this.at
489
+ ), r;
490
+ }
491
+ }
492
+ const we = "Returns the count of a range depending on multiple criteria.";
493
+ class ye extends o {
494
+ constructor() {
495
+ super(...arguments), this.example = 'COUNTIFS(A1:A10, ">20", B1:B10, "<5")', this.description = we, this.defs = [
496
+ { name: "range1", description: "First condition range.", takesMatrix: !0, acceptedTypes: ["matrix"] },
497
+ { ...g, name: "condition1" },
498
+ {
499
+ name: "range2",
500
+ description: "Additional condition range.",
501
+ takesMatrix: !0,
502
+ acceptedTypes: ["matrix"],
503
+ optional: !0,
504
+ variadic: !0
505
+ },
506
+ { ...g, name: "condition2", optional: !0, variadic: !0 }
507
+ ], this.category = "math";
508
+ }
509
+ validate(e) {
510
+ const t = super.validate(e);
511
+ if (t.length % 2 !== 0)
512
+ throw new u("#N/A", "COUNTIFS requires at least one range/condition pair.");
513
+ const n = t[0] instanceof f ? t[0] : null;
514
+ let r = 0, s = 0;
515
+ n && (r = n.getNumRows(), s = n.getNumCols());
516
+ const a = [], m = [];
517
+ for (let d = 0; d < t.length; d += 2) {
518
+ if (!(t[d] instanceof f))
519
+ throw new u("#VALUE!", `Argument ${d + 1} of COUNTIFS must be a range.`);
520
+ if (t[d].getNumRows() !== r || t[d].getNumCols() !== s)
521
+ throw new u("#VALUE!", "Array arguments to COUNTIFS are of different size.");
522
+ a.push(t[d]), m.push(b(t[d + 1]));
523
+ }
524
+ return [M(a, m, this.at)];
525
+ }
526
+ main(e) {
527
+ let t = 0;
528
+ for (const n of e)
529
+ for (const r of n)
530
+ r && t++;
531
+ return t;
532
+ }
533
+ }
534
+ const Me = "Returns the factorial of a number.";
535
+ class ve extends o {
536
+ constructor() {
537
+ super(...arguments), this.example = "FACT(5)", this.description = Me, this.defs = [
538
+ {
539
+ name: "value",
540
+ description: "A non-negative integer whose factorial will be returned.",
541
+ acceptedTypes: ["number"]
542
+ }
543
+ ], this.category = "math";
544
+ }
545
+ main(e) {
546
+ if (e < 0)
547
+ throw new u("#NUM!", "FACT requires a non-negative integer.");
548
+ let t = 1;
549
+ for (let n = 2; n <= Math.floor(e); n++)
550
+ t *= n;
551
+ return t;
552
+ }
553
+ }
554
+ const Te = "Rounds a number down to the nearest integer that is less than or equal to it.";
555
+ class Ae extends o {
556
+ constructor() {
557
+ super(...arguments), this.example = "INT(8.9)", this.description = Te, this.defs = [
558
+ { name: "value", description: "The value to round down to the nearest integer.", acceptedTypes: ["number"] }
559
+ ], this.category = "math";
560
+ }
561
+ main(e) {
562
+ return Math.floor(e);
563
+ }
564
+ }
565
+ const Ne = "Returns TRUE if the value is even.";
566
+ class Re extends o {
567
+ constructor() {
568
+ super(...arguments), this.example = "ISEVEN(4)", this.description = Ne, this.defs = [
569
+ { name: "value", description: "The value to check for being even.", acceptedTypes: ["number"] }
570
+ ], this.category = "math";
571
+ }
572
+ main(e) {
573
+ return Math.floor(Math.abs(e)) % 2 === 0;
574
+ }
575
+ }
576
+ const Fe = "Returns TRUE if the value is odd.";
577
+ class Se extends o {
578
+ constructor() {
579
+ super(...arguments), this.example = "ISODD(3)", this.description = Fe, this.defs = [
580
+ { name: "value", description: "The value to check for being odd.", acceptedTypes: ["number"] }
581
+ ], this.category = "math";
582
+ }
583
+ main(e) {
584
+ return Math.floor(Math.abs(e)) % 2 !== 0;
585
+ }
586
+ }
587
+ function Ue(i, e) {
588
+ for (i = Math.abs(Math.floor(i)), e = Math.abs(Math.floor(e)); e; )
589
+ [i, e] = [e, i % e];
590
+ return i;
591
+ }
592
+ const Ee = "Returns the least common multiple of one or more integers.";
593
+ class $e extends o {
594
+ constructor() {
595
+ super(...arguments), this.example = "LCM(4, 6)", this.description = Ee, this.defs = [
596
+ { name: "value", description: "Integers (must be >= 1).", acceptedTypes: ["number"], variadic: !0 }
597
+ ], this.category = "math";
598
+ }
599
+ validate(e) {
600
+ if (e.length === 0)
601
+ throw new u("#N/A", "LCM requires at least one argument.");
602
+ return e.map((t) => {
603
+ const n = Math.floor(h(t));
604
+ if (n < 1)
605
+ throw new u("#NUM!", "LCM arguments must be >= 1.");
606
+ return n;
607
+ });
608
+ }
609
+ main(...e) {
610
+ return e.reduce((t, n) => t * n / Ue(t, n), 1);
611
+ }
612
+ }
613
+ const qe = "Rounds a number up to the nearest odd integer.";
614
+ class Ce extends o {
615
+ constructor() {
616
+ super(...arguments), this.example = "ODD(2.3)", this.description = qe, this.defs = [
617
+ { name: "value", description: "The value to round up to the nearest odd integer.", acceptedTypes: ["number"] }
618
+ ], this.category = "math";
619
+ }
620
+ main(e) {
621
+ if (e === 0)
622
+ return 1;
623
+ const t = e > 0 ? 1 : -1;
624
+ let n = Math.ceil(Math.abs(e));
625
+ return n % 2 === 0 && n++, t * n;
626
+ }
627
+ }
628
+ const Ie = "Rounds a number up to the nearest even integer.";
629
+ class ke extends o {
630
+ constructor() {
631
+ super(...arguments), this.example = "EVEN(3.1)", this.description = Ie, this.defs = [
632
+ { name: "value", description: "The value to round up to the nearest even integer.", acceptedTypes: ["number"] }
633
+ ], this.category = "math";
634
+ }
635
+ main(e) {
636
+ if (e === 0)
637
+ return 0;
638
+ const t = e > 0 ? 1 : -1;
639
+ let n = Math.ceil(Math.abs(e));
640
+ return n % 2 !== 0 && n++, t * n;
641
+ }
642
+ }
643
+ const De = "Returns -1 if the value is negative, 1 if positive, and 0 if zero.";
644
+ class Oe extends o {
645
+ constructor() {
646
+ super(...arguments), this.example = "SIGN(-3)", this.description = De, this.defs = [
647
+ { name: "value", description: "The number to check the sign of.", acceptedTypes: ["number"] }
648
+ ], this.category = "math";
649
+ }
650
+ main(e) {
651
+ return e > 0 ? 1 : e < 0 ? -1 : 0;
652
+ }
653
+ }
654
+ const Le = "Returns the sum of the squares of a series of numbers or cells.";
655
+ class Pe extends o {
656
+ constructor() {
657
+ super(...arguments), this.example = "SUMSQ(A1:A10, 3)", this.description = Le, this.defs = [
658
+ {
659
+ name: "value",
660
+ description: "Numbers or ranges to square and sum.",
661
+ takesMatrix: !0,
662
+ acceptedTypes: ["number", "matrix"],
663
+ variadic: !0
664
+ }
665
+ ], this.category = "math";
666
+ }
667
+ main(...e) {
668
+ let t = 0;
669
+ for (const n of e)
670
+ l(
671
+ n,
672
+ (r) => {
673
+ const s = h(r, { ignore: !0 });
674
+ t += s * s;
675
+ },
676
+ this.at
677
+ );
678
+ return t;
679
+ }
680
+ }
681
+ const Ve = "Truncates a number to a certain number of significant digits by omitting less significant digits.";
682
+ class Be extends o {
683
+ constructor() {
684
+ super(...arguments), this.example = "TRUNC(3.14159, 2)", this.description = Ve, this.defs = [
685
+ { name: "value", description: "The number to truncate.", acceptedTypes: ["number"] },
686
+ {
687
+ name: "places",
688
+ description: "The number of significant digits to keep. Defaults to 0.",
689
+ acceptedTypes: ["number"],
690
+ optional: !0
691
+ }
692
+ ], this.category = "math";
693
+ }
694
+ main(e, t = 0) {
695
+ const n = Math.floor(t), r = Math.pow(10, n);
696
+ return (e >= 0 ? Math.floor : Math.ceil)(e * r) / r;
697
+ }
698
+ }
699
+ const _e = "Converts a number into a text representation in another base, e.g. base 2 for binary.";
700
+ class ze extends o {
701
+ constructor() {
702
+ super(...arguments), this.example = "BASE(255, 16)", this.description = _e, this.defs = [
703
+ { name: "value", description: "A non-negative integer to convert.", acceptedTypes: ["number"] },
704
+ { name: "base", description: "The base (radix) to convert into, between 2 and 36.", acceptedTypes: ["number"] },
705
+ {
706
+ name: "min_length",
707
+ description: "Minimum length of the result string (zero-padded).",
708
+ acceptedTypes: ["number"],
709
+ optional: !0
710
+ }
711
+ ], this.category = "math";
712
+ }
713
+ validate(e) {
714
+ if (e.length < 2 || e.length > 3)
715
+ throw new u("#N/A", "Number of arguments for BASE is incorrect.");
716
+ if (e[0] = Math.floor(h(e[0])), e[1] = Math.floor(h(e[1])), e[0] < 0)
717
+ throw new u("#NUM!", "BASE requires a non-negative integer as value.");
718
+ if (e[1] < 2 || e[1] > 36)
719
+ throw new u("#NUM!", "BASE requires a base between 2 and 36.");
720
+ if (e[2] != null && (e[2] = Math.floor(h(e[2])), e[2] < 0))
721
+ throw new u("#NUM!", "BASE min_length must be non-negative.");
722
+ return e;
723
+ }
724
+ main(e, t, n) {
725
+ const r = e.toString(t).toUpperCase();
726
+ return n != null && r.length < n ? r.padStart(n, "0") : r;
727
+ }
728
+ }
729
+ const je = `Generates a sequence of numbers in a 2D array.
730
+ Returns a rows × cols array starting at start, incrementing by step.`;
731
+ class Ge extends o {
732
+ constructor() {
733
+ super(...arguments), this.autoSpilling = !0, this.example = "SEQUENCE(4, 3, 1, 1)", this.description = je, this.defs = [
734
+ {
735
+ name: "rows",
736
+ description: "The number of rows to return.",
737
+ acceptedTypes: ["number"]
738
+ },
739
+ {
740
+ name: "columns",
741
+ description: "The number of columns to return. Defaults to 1.",
742
+ optional: !0,
743
+ acceptedTypes: ["number"]
744
+ },
745
+ {
746
+ name: "start",
747
+ description: "The starting value of the sequence. Defaults to 1.",
748
+ optional: !0,
749
+ acceptedTypes: ["number"]
750
+ },
751
+ {
752
+ name: "step",
753
+ description: "The increment between each value. Defaults to 1.",
754
+ optional: !0,
755
+ acceptedTypes: ["number"]
756
+ }
757
+ ], this.category = "math";
758
+ }
759
+ validate(e) {
760
+ if (e.length < 1 || e.length > 4)
761
+ throw new u("#N/A", "Number of arguments for SEQUENCE is incorrect.");
762
+ if (e[0] = Math.floor(h(e[0])), e[0] < 1)
763
+ throw new u("#VALUE!", "rows must be at least 1.");
764
+ if (e.length >= 2 && (e[1] = Math.floor(h(e[1])), e[1] < 1))
765
+ throw new u("#VALUE!", "columns must be at least 1.");
766
+ return e.length >= 3 && (e[2] = h(e[2])), e.length >= 4 && (e[3] = h(e[3])), e;
767
+ }
768
+ main(e, t = 1, n = 1, r = 1) {
769
+ const s = [];
770
+ let a = n;
771
+ for (let m = 0; m < e; m++) {
772
+ const c = [];
773
+ for (let d = 0; d < t; d++)
774
+ c.push(a), a += r;
775
+ s.push(c);
776
+ }
777
+ return s;
778
+ }
779
+ }
780
+ class x extends o {
781
+ constructor() {
782
+ super(...arguments), this.category = "math";
783
+ }
784
+ /** Convert a matrix argument to a 2D number array using eachMatrix. */
785
+ extractNumberMatrix(e, t) {
786
+ const n = [];
787
+ if (l(
788
+ e,
789
+ (r, { y: s, x: a }) => {
790
+ n[s] || (n[s] = []), n[s][a] = h(r);
791
+ },
792
+ this.at
793
+ ), n.length === 0)
794
+ throw new u("#VALUE!", `${t} must be a non-empty matrix.`);
795
+ return n;
796
+ }
797
+ /** Require the matrix to be square. Throws if not. */
798
+ requireSquare(e, t) {
799
+ const n = e.length;
800
+ if (e.some((r) => r.length !== n))
801
+ throw new u("#VALUE!", `${t} requires a square matrix.`);
802
+ }
803
+ }
804
+ const Qe = `Returns the matrix product of two matrices.
805
+ The number of columns in matrix1 must equal the number of rows in matrix2.`;
806
+ class Xe extends x {
807
+ constructor() {
808
+ super(...arguments), this.autoSpilling = !0, this.example = "MMULT(A1:B2, C1:D2)", this.description = Qe, this.defs = [
809
+ { name: "matrix1", description: "First matrix.", takesMatrix: !0, acceptedTypes: ["matrix"] },
810
+ { name: "matrix2", description: "Second matrix.", takesMatrix: !0, acceptedTypes: ["matrix"] }
811
+ ];
812
+ }
813
+ validate(e) {
814
+ if (e.length !== 2)
815
+ throw new u("#N/A", "MMULT requires exactly 2 arguments.");
816
+ const t = this.extractNumberMatrix(e[0], "matrix1"), n = this.extractNumberMatrix(e[1], "matrix2"), r = t[0].length, s = n.length;
817
+ if (r !== s)
818
+ throw new u(
819
+ "#VALUE!",
820
+ `MMULT: number of columns in matrix1 (${r}) must equal number of rows in matrix2 (${s}).`
821
+ );
822
+ return [t, n];
823
+ }
824
+ main(e, t) {
825
+ const n = e.length, r = e[0].length, s = t[0].length, a = [];
826
+ for (let m = 0; m < n; m++) {
827
+ a[m] = [];
828
+ for (let c = 0; c < s; c++) {
829
+ let d = 0;
830
+ for (let p = 0; p < r; p++)
831
+ d += e[m][p] * t[p][c];
832
+ a[m][c] = d;
833
+ }
834
+ }
835
+ return a;
836
+ }
837
+ }
838
+ const We = `Returns the transpose of a matrix.
839
+ Rows and columns of the input array are swapped.`;
840
+ class Ye extends x {
841
+ constructor() {
842
+ super(...arguments), this.autoSpilling = !0, this.example = "TRANSPOSE(A1:C3)", this.description = We, this.defs = [
843
+ { name: "matrix", description: "The matrix to transpose.", takesMatrix: !0, acceptedTypes: ["matrix"] }
844
+ ];
845
+ }
846
+ validate(e) {
847
+ if (e.length !== 1)
848
+ throw new u("#N/A", "TRANSPOSE requires exactly 1 argument.");
849
+ return [this.extractNumberMatrix(e[0], "matrix")];
850
+ }
851
+ main(e) {
852
+ const t = e.length, n = e[0].length, r = [];
853
+ for (let s = 0; s < n; s++) {
854
+ r[s] = [];
855
+ for (let a = 0; a < t; a++)
856
+ r[s][a] = e[a][s];
857
+ }
858
+ return r;
859
+ }
860
+ }
861
+ const He = `Returns the inverse of a square matrix.
862
+ The matrix must be square and non-singular (determinant ≠ 0).`;
863
+ class Je extends x {
864
+ constructor() {
865
+ super(...arguments), this.autoSpilling = !0, this.example = "MINVERSE(A1:C3)", this.description = He, this.defs = [
866
+ { name: "matrix", description: "A square numeric matrix.", takesMatrix: !0, acceptedTypes: ["matrix"] }
867
+ ];
868
+ }
869
+ validate(e) {
870
+ if (e.length !== 1)
871
+ throw new u("#N/A", "MINVERSE requires exactly 1 argument.");
872
+ const t = this.extractNumberMatrix(e[0], "matrix");
873
+ this.requireSquare(t, "MINVERSE");
874
+ const n = this.invertMatrix(t);
875
+ if (n === null)
876
+ throw new u("#NUM!", "MINVERSE: matrix is singular and cannot be inverted.");
877
+ return [n];
878
+ }
879
+ main(e) {
880
+ return e;
881
+ }
882
+ invertMatrix(e) {
883
+ const t = e.length, n = e.map((r, s) => [...r, ...Array.from({ length: t }, (a, m) => s === m ? 1 : 0)]);
884
+ for (let r = 0; r < t; r++) {
885
+ let s = -1, a = 0;
886
+ for (let c = r; c < t; c++)
887
+ Math.abs(n[c][r]) > a && (a = Math.abs(n[c][r]), s = c);
888
+ if (s === -1 || Math.abs(n[s][r]) < 1e-10)
889
+ return null;
890
+ [n[r], n[s]] = [n[s], n[r]];
891
+ const m = n[r][r];
892
+ for (let c = 0; c < 2 * t; c++)
893
+ n[r][c] /= m;
894
+ for (let c = 0; c < t; c++) {
895
+ if (c === r)
896
+ continue;
897
+ const d = n[c][r];
898
+ for (let p = 0; p < 2 * t; p++)
899
+ n[c][p] -= d * n[r][p];
900
+ }
901
+ }
902
+ return n.map((r) => r.slice(t));
903
+ }
904
+ }
905
+ const Ke = "Returns the determinant of a square matrix.";
906
+ class Ze extends x {
907
+ constructor() {
908
+ super(...arguments), this.example = "MDETERM(A1:C3)", this.description = Ke, this.defs = [
909
+ { name: "matrix", description: "A square numeric matrix.", takesMatrix: !0, acceptedTypes: ["matrix"] }
910
+ ];
911
+ }
912
+ validate(e) {
913
+ if (e.length !== 1)
914
+ throw new u("#N/A", "MDETERM requires exactly 1 argument.");
915
+ const t = this.extractNumberMatrix(e[0], "matrix");
916
+ return this.requireSquare(t, "MDETERM"), [t];
917
+ }
918
+ main(e) {
919
+ return this.determinant(e);
920
+ }
921
+ determinant(e) {
922
+ const t = e.length, n = e.map((s) => [...s]);
923
+ let r = 1;
924
+ for (let s = 0; s < t; s++) {
925
+ let a = s;
926
+ for (let m = s + 1; m < t; m++)
927
+ Math.abs(n[m][s]) > Math.abs(n[a][s]) && (a = m);
928
+ if (a !== s && ([n[s], n[a]] = [n[a], n[s]], r *= -1), Math.abs(n[s][s]) < 1e-10)
929
+ return 0;
930
+ r *= n[s][s];
931
+ for (let m = s + 1; m < t; m++) {
932
+ const c = n[m][s] / n[s][s];
933
+ for (let d = s; d < t; d++)
934
+ n[m][d] -= c * n[s][d];
935
+ }
936
+ }
937
+ return r;
938
+ }
939
+ }
940
+ const et = `Returns the sum of the products of corresponding array elements.
941
+ All arrays must have the same dimensions.`;
942
+ class tt extends x {
943
+ constructor() {
944
+ super(...arguments), this.example = "SUMPRODUCT(A1:A3, B1:B3)", this.description = et, this.defs = [
945
+ { name: "array1", description: "First array.", takesMatrix: !0, acceptedTypes: ["matrix"] },
946
+ { name: "array2", description: "Additional arrays.", takesMatrix: !0, acceptedTypes: ["matrix"], variadic: !0 }
947
+ ];
948
+ }
949
+ validate(e) {
950
+ if (e.length < 1)
951
+ throw new u("#N/A", "SUMPRODUCT requires at least 1 argument.");
952
+ const t = e.map((s, a) => this.extractNumberMatrix(s, `array${a + 1}`)), n = t[0].length, r = t[0][0].length;
953
+ for (let s = 1; s < t.length; s++)
954
+ if (t[s].length !== n || t[s][0].length !== r)
955
+ throw new u("#VALUE!", "SUMPRODUCT: all arrays must have the same dimensions.");
956
+ return [t];
957
+ }
958
+ main(e) {
959
+ const t = e[0].length, n = e[0][0].length;
960
+ let r = 0;
961
+ for (let s = 0; s < t; s++)
962
+ for (let a = 0; a < n; a++) {
963
+ let m = 1;
964
+ for (const c of e)
965
+ m *= c[s][a];
966
+ r += m;
967
+ }
968
+ return r;
969
+ }
970
+ }
971
+ const st = {
972
+ mod: A,
973
+ sqrt: R,
974
+ product: S,
975
+ round: E,
976
+ rounddown: q,
977
+ roundup: I,
978
+ log: D,
979
+ log10: L,
980
+ ln: V,
981
+ exp: _,
982
+ pi: j,
983
+ radians: Q,
984
+ sin: W,
985
+ cos: H,
986
+ tan: K,
987
+ asin: ee,
988
+ acos: ne,
989
+ atan: re,
990
+ atan2: ae,
991
+ rand: ce,
992
+ unary_percent: me,
993
+ uplus: he,
994
+ sumif: le,
995
+ sumifs: ge,
996
+ countif: be,
997
+ countifs: ye,
998
+ fact: ve,
999
+ int: Ae,
1000
+ iseven: Re,
1001
+ isodd: Se,
1002
+ lcm: $e,
1003
+ odd: Ce,
1004
+ even: ke,
1005
+ sign: Oe,
1006
+ sumsq: Pe,
1007
+ trunc: Be,
1008
+ base: ze,
1009
+ sequence: Ge,
1010
+ mmult: Xe,
1011
+ transpose: Ye,
1012
+ minverse: Je,
1013
+ mdeterm: Ze,
1014
+ sumproduct: tt
1015
+ };
1016
+ export {
1017
+ st as default,
1018
+ st as mathFunctions
1019
+ };