df-script 1.4.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/LICENSE +21 -0
- package/README.md +269 -0
- package/dist/api.d.ts +39 -0
- package/dist/api.js +18 -0
- package/dist/bundle.min.js +1 -0
- package/dist/columnExpressions/ColumnExpr.d.ts +368 -0
- package/dist/columnExpressions/ColumnExpr.js +23 -0
- package/dist/columnExpressions/ExprBase.d.ts +24 -0
- package/dist/columnExpressions/ExprBase.js +133 -0
- package/dist/columnExpressions/constants.d.ts +2 -0
- package/dist/columnExpressions/constants.js +5 -0
- package/dist/columnExpressions/functions/all.d.ts +5 -0
- package/dist/columnExpressions/functions/all.js +11 -0
- package/dist/columnExpressions/functions/coalesce.d.ts +3 -0
- package/dist/columnExpressions/functions/coalesce.js +40 -0
- package/dist/columnExpressions/functions/exclude.d.ts +5 -0
- package/dist/columnExpressions/functions/exclude.js +13 -0
- package/dist/columnExpressions/functions/lit.d.ts +5 -0
- package/dist/columnExpressions/functions/lit.js +22 -0
- package/dist/columnExpressions/functions/when.d.ts +24 -0
- package/dist/columnExpressions/functions/when.js +81 -0
- package/dist/columnExpressions/index.d.ts +19 -0
- package/dist/columnExpressions/index.js +81 -0
- package/dist/columnExpressions/mixins/AggregationExpr.d.ts +50 -0
- package/dist/columnExpressions/mixins/AggregationExpr.js +172 -0
- package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +67 -0
- package/dist/columnExpressions/mixins/ArithmeticExpr.js +143 -0
- package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +60 -0
- package/dist/columnExpressions/mixins/ComparisonExpr.js +389 -0
- package/dist/columnExpressions/mixins/ListExpr.d.ts +63 -0
- package/dist/columnExpressions/mixins/ListExpr.js +248 -0
- package/dist/columnExpressions/mixins/LogicalExpr.d.ts +33 -0
- package/dist/columnExpressions/mixins/LogicalExpr.js +54 -0
- package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +31 -0
- package/dist/columnExpressions/mixins/ManipulationExpr.js +35 -0
- package/dist/columnExpressions/mixins/StringExpr.d.ts +79 -0
- package/dist/columnExpressions/mixins/StringExpr.js +249 -0
- package/dist/columnExpressions/mixins/TemporalExpr.d.ts +69 -0
- package/dist/columnExpressions/mixins/TemporalExpr.js +127 -0
- package/dist/columnExpressions/mixins/WindowExpr.d.ts +50 -0
- package/dist/columnExpressions/mixins/WindowExpr.js +281 -0
- package/dist/columnExpressions/types.d.ts +7 -0
- package/dist/columnExpressions/types.js +2 -0
- package/dist/dataframe/constants.d.ts +1 -0
- package/dist/dataframe/constants.js +4 -0
- package/dist/dataframe/dataframe.d.ts +42 -0
- package/dist/dataframe/dataframe.js +749 -0
- package/dist/dataframe/grouped/grouped.d.ts +15 -0
- package/dist/dataframe/grouped/grouped.js +113 -0
- package/dist/dataframe/index.d.ts +4 -0
- package/dist/dataframe/index.js +20 -0
- package/dist/dataframe/types.d.ts +33 -0
- package/dist/dataframe/types.js +2 -0
- package/dist/dataframe/utils.d.ts +11 -0
- package/dist/dataframe/utils.js +215 -0
- package/dist/datatypes/DataType.d.ts +40 -0
- package/dist/datatypes/DataType.js +47 -0
- package/dist/datatypes/index.d.ts +29 -0
- package/dist/datatypes/index.js +46 -0
- package/dist/datatypes/types/Binary.d.ts +9 -0
- package/dist/datatypes/types/Binary.js +18 -0
- package/dist/datatypes/types/Boolean.d.ts +9 -0
- package/dist/datatypes/types/Boolean.js +19 -0
- package/dist/datatypes/types/Date.d.ts +8 -0
- package/dist/datatypes/types/Date.js +21 -0
- package/dist/datatypes/types/Datetime.d.ts +8 -0
- package/dist/datatypes/types/Datetime.js +17 -0
- package/dist/datatypes/types/Decimal.d.ts +10 -0
- package/dist/datatypes/types/Decimal.js +28 -0
- package/dist/datatypes/types/Duration.d.ts +8 -0
- package/dist/datatypes/types/Duration.js +17 -0
- package/dist/datatypes/types/Float32.d.ts +8 -0
- package/dist/datatypes/types/Float32.js +17 -0
- package/dist/datatypes/types/Float64.d.ts +8 -0
- package/dist/datatypes/types/Float64.js +17 -0
- package/dist/datatypes/types/Int16.d.ts +8 -0
- package/dist/datatypes/types/Int16.js +17 -0
- package/dist/datatypes/types/Int32.d.ts +8 -0
- package/dist/datatypes/types/Int32.js +17 -0
- package/dist/datatypes/types/Int64.d.ts +8 -0
- package/dist/datatypes/types/Int64.js +17 -0
- package/dist/datatypes/types/Int8.d.ts +8 -0
- package/dist/datatypes/types/Int8.js +17 -0
- package/dist/datatypes/types/List.d.ts +10 -0
- package/dist/datatypes/types/List.js +31 -0
- package/dist/datatypes/types/Null.d.ts +9 -0
- package/dist/datatypes/types/Null.js +17 -0
- package/dist/datatypes/types/Object.d.ts +9 -0
- package/dist/datatypes/types/Object.js +17 -0
- package/dist/datatypes/types/Struct.d.ts +14 -0
- package/dist/datatypes/types/Struct.js +39 -0
- package/dist/datatypes/types/Time.d.ts +8 -0
- package/dist/datatypes/types/Time.js +29 -0
- package/dist/datatypes/types/UInt16.d.ts +8 -0
- package/dist/datatypes/types/UInt16.js +17 -0
- package/dist/datatypes/types/UInt32.d.ts +8 -0
- package/dist/datatypes/types/UInt32.js +17 -0
- package/dist/datatypes/types/UInt64.d.ts +8 -0
- package/dist/datatypes/types/UInt64.js +17 -0
- package/dist/datatypes/types/UInt8.d.ts +8 -0
- package/dist/datatypes/types/UInt8.js +17 -0
- package/dist/datatypes/types/Utf8.d.ts +10 -0
- package/dist/datatypes/types/Utf8.js +20 -0
- package/dist/datatypes/types.d.ts +172 -0
- package/dist/datatypes/types.js +286 -0
- package/dist/exceptions/index.d.ts +13 -0
- package/dist/exceptions/index.js +43 -0
- package/dist/exceptions/utils.d.ts +2 -0
- package/dist/exceptions/utils.js +9 -0
- package/dist/functions/concat.d.ts +4 -0
- package/dist/functions/concat.js +248 -0
- package/dist/functions/index.d.ts +1 -0
- package/dist/functions/index.js +17 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1 -0
- package/dist/types.d.ts +47 -0
- package/dist/types.js +2 -0
- package/dist/utils/boolean.d.ts +1 -0
- package/dist/utils/boolean.js +18 -0
- package/dist/utils/date.d.ts +57 -0
- package/dist/utils/date.js +349 -0
- package/dist/utils/guards.d.ts +14 -0
- package/dist/utils/guards.js +143 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +21 -0
- package/dist/utils/json.d.ts +2 -0
- package/dist/utils/json.js +33 -0
- package/dist/utils/list.d.ts +23 -0
- package/dist/utils/list.js +128 -0
- package/dist/utils/number.d.ts +86 -0
- package/dist/utils/number.js +223 -0
- package/dist/utils/string.d.ts +52 -0
- package/dist/utils/string.js +120 -0
- package/package.json +34 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeToDataFrames = normalizeToDataFrames;
|
|
4
|
+
exports.concat = concat;
|
|
5
|
+
const dataframe_1 = require("../dataframe/dataframe");
|
|
6
|
+
const datatypes_1 = require("../datatypes");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
const exceptions_1 = require("../exceptions");
|
|
9
|
+
function normalizeToDataFrames(item, context, index) {
|
|
10
|
+
if (item == null) {
|
|
11
|
+
throw new exceptions_1.DataFrameError(`Invalid input to ${context} at index ${index}: item cannot be null or undefined.`);
|
|
12
|
+
}
|
|
13
|
+
if (item instanceof dataframe_1.DataFrame) {
|
|
14
|
+
return [item];
|
|
15
|
+
}
|
|
16
|
+
if ((0, utils_1.isPlainObj)(item)) {
|
|
17
|
+
return [new dataframe_1.DataFrame(item)];
|
|
18
|
+
}
|
|
19
|
+
if ((0, utils_1.isArrayOrTypedArray)(item)) {
|
|
20
|
+
if ((0, utils_1.isArrayOfType)(item, dataframe_1.DataFrame, { mode: "every" })) {
|
|
21
|
+
return item;
|
|
22
|
+
}
|
|
23
|
+
if ((0, utils_1.isArrayOfType)(item, "plainObject", { mode: "every" })) {
|
|
24
|
+
return [new dataframe_1.DataFrame(item)];
|
|
25
|
+
}
|
|
26
|
+
const anyDF = (0, utils_1.isArrayOfType)(item, dataframe_1.DataFrame, { mode: "some" });
|
|
27
|
+
for (let j = 0; j < item.length; j++) {
|
|
28
|
+
if (anyDF ? !(item[j] instanceof dataframe_1.DataFrame) : !(0, utils_1.isPlainObj)(item[j])) {
|
|
29
|
+
throw new exceptions_1.DataFrameError(anyDF
|
|
30
|
+
? `Invalid input to ${context} at index ${index}, sub-index ${j}: nested array must contain only DataFrame instances.`
|
|
31
|
+
: `Invalid input to ${context} at index ${index}, row ${j}: rows must be plain objects.`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
throw new exceptions_1.DataFrameError(`Invalid input to ${context} at index ${index}: expected DataFrame, row array, or column dictionary.`);
|
|
36
|
+
}
|
|
37
|
+
function concat(rawItems, options = {}) {
|
|
38
|
+
if (rawItems == null) {
|
|
39
|
+
throw new exceptions_1.DataFrameError("Invalid input to concat: rawItems cannot be null or undefined.");
|
|
40
|
+
}
|
|
41
|
+
const itemsArray = Array.isArray(rawItems) ? rawItems : [rawItems];
|
|
42
|
+
const items = [];
|
|
43
|
+
for (let i = 0; i < itemsArray.length; i++) {
|
|
44
|
+
items.push(...normalizeToDataFrames(itemsArray[i], "concat", i));
|
|
45
|
+
}
|
|
46
|
+
const { how = 'vertical' } = options;
|
|
47
|
+
const strict = options.horizontal?.strict ?? true;
|
|
48
|
+
if (items.length === 0)
|
|
49
|
+
return new dataframe_1.DataFrame({}, {}, 0);
|
|
50
|
+
if (items.length === 1 && how !== 'horizontal')
|
|
51
|
+
return items[0];
|
|
52
|
+
switch (how) {
|
|
53
|
+
case 'vertical': {
|
|
54
|
+
const validItems = [];
|
|
55
|
+
for (let i = 0; i < items.length; i++) {
|
|
56
|
+
if (items[i].height > 0) {
|
|
57
|
+
validItems.push(items[i]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (validItems.length === 0)
|
|
61
|
+
return new dataframe_1.DataFrame({}, {}, 0);
|
|
62
|
+
const firstDF = validItems[0];
|
|
63
|
+
const firstKeys = Object.keys(firstDF._columns);
|
|
64
|
+
for (let i = 0; i < items.length; i++) {
|
|
65
|
+
const currentDF = items[i];
|
|
66
|
+
if (currentDF.height === 0)
|
|
67
|
+
continue;
|
|
68
|
+
const currentKeys = Object.keys(currentDF._columns);
|
|
69
|
+
if (firstKeys.length !== currentKeys.length) {
|
|
70
|
+
throw new exceptions_1.DataFrameError(`[Strict Vertical] Column count mismatch at index ${i}.`);
|
|
71
|
+
}
|
|
72
|
+
for (let j = 0; j < firstKeys.length; j++) {
|
|
73
|
+
if (firstKeys[j] !== currentKeys[j]) {
|
|
74
|
+
throw new exceptions_1.DataFrameError(`[Strict Vertical] Schema mismatch at position ${j} in DF ${i}. ` +
|
|
75
|
+
`Expected column "${firstKeys[j]}", but found "${currentKeys[j]}".`);
|
|
76
|
+
}
|
|
77
|
+
const typeA = firstDF.schema[firstKeys[j]];
|
|
78
|
+
const typeB = currentDF.schema[firstKeys[j]];
|
|
79
|
+
if (typeA && typeB && !typeA.equals(typeB)) {
|
|
80
|
+
throw new exceptions_1.SchemaError(`[Strict Type Check] Schema type mismatch for column "${firstKeys[j]}": expected ${typeA.name}, found ${typeB.name}.`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
let newHeight = 0;
|
|
85
|
+
for (const item of items) {
|
|
86
|
+
newHeight += item.height;
|
|
87
|
+
}
|
|
88
|
+
const outSchema = items.find(df => df.height > 0)?.schema || items[0]?.schema || {};
|
|
89
|
+
const newColumns = {};
|
|
90
|
+
for (const key of firstKeys) {
|
|
91
|
+
const type = outSchema[key];
|
|
92
|
+
let hasNulls = false;
|
|
93
|
+
for (const item of items) {
|
|
94
|
+
const colArr = item._columns[key];
|
|
95
|
+
if (!colArr) {
|
|
96
|
+
hasNulls = true;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
if (!(0, utils_1.isTypedArray)(colArr)) {
|
|
100
|
+
for (let i = 0; i < colArr.length; i++) {
|
|
101
|
+
if (colArr[i] == null) {
|
|
102
|
+
hasNulls = true;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (hasNulls)
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
let dest = type && type.allocate ? type.allocate(newHeight) : new Array(newHeight).fill(null);
|
|
111
|
+
if (hasNulls && (0, utils_1.isTypedArray)(dest)) {
|
|
112
|
+
dest = new Array(newHeight).fill(null);
|
|
113
|
+
}
|
|
114
|
+
newColumns[key] = dest;
|
|
115
|
+
}
|
|
116
|
+
let offset = 0;
|
|
117
|
+
for (const item of items) {
|
|
118
|
+
const h = item.height;
|
|
119
|
+
if (h === 0)
|
|
120
|
+
continue;
|
|
121
|
+
for (const key of firstKeys) {
|
|
122
|
+
const colArr = item._columns[key] || new Array(h).fill(null);
|
|
123
|
+
const dest = newColumns[key];
|
|
124
|
+
if ((0, utils_1.isTypedArray)(dest) && (0, utils_1.isTypedArray)(colArr)) {
|
|
125
|
+
dest.set(colArr, offset);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
const destArr = dest;
|
|
129
|
+
for (let i = 0; i < h; i++) {
|
|
130
|
+
destArr[offset + i] = colArr[i];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
offset += h;
|
|
135
|
+
}
|
|
136
|
+
return new dataframe_1.DataFrame(newColumns, outSchema, newHeight);
|
|
137
|
+
}
|
|
138
|
+
case 'horizontal': {
|
|
139
|
+
let maxHeight = items[0].height;
|
|
140
|
+
for (let i = 1; i < items.length; i++) {
|
|
141
|
+
if (items[i].height > maxHeight) {
|
|
142
|
+
maxHeight = items[i].height;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const allColNames = new Set();
|
|
146
|
+
for (let idx = 0; idx < items.length; idx++) {
|
|
147
|
+
const df = items[idx];
|
|
148
|
+
if (strict && df.height !== maxHeight) {
|
|
149
|
+
throw new exceptions_1.DataFrameError(`[Horizontal] Row count mismatch at index ${idx}. Expected ${maxHeight}, got ${df.height}. Set strict=false to allow padding.`);
|
|
150
|
+
}
|
|
151
|
+
for (const key of Object.keys(df._columns)) {
|
|
152
|
+
if (allColNames.has(key)) {
|
|
153
|
+
throw new exceptions_1.DataFrameError(`[Horizontal] Duplicate column name "${key}" detected. Horizontal concat requires unique names.`);
|
|
154
|
+
}
|
|
155
|
+
allColNames.add(key);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const newColumns = {};
|
|
159
|
+
const outSchema = {};
|
|
160
|
+
for (const df of items) {
|
|
161
|
+
const h = df.height;
|
|
162
|
+
Object.assign(outSchema, df.schema);
|
|
163
|
+
for (const [key, col] of Object.entries(df._columns)) {
|
|
164
|
+
if (h === maxHeight) {
|
|
165
|
+
newColumns[key] = (0, utils_1.isTypedArray)(col) ? Array.from(col) : col;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
const padded = new Array(maxHeight);
|
|
169
|
+
for (let i = 0; i < h; i++) {
|
|
170
|
+
padded[i] = col[i];
|
|
171
|
+
}
|
|
172
|
+
for (let i = h; i < maxHeight; i++) {
|
|
173
|
+
padded[i] = null;
|
|
174
|
+
}
|
|
175
|
+
newColumns[key] = padded;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return new dataframe_1.DataFrame(newColumns, outSchema, maxHeight);
|
|
180
|
+
}
|
|
181
|
+
case 'diagonal': {
|
|
182
|
+
const allColumnsSet = new Set();
|
|
183
|
+
for (const df of items) {
|
|
184
|
+
for (const key of Object.keys(df._columns)) {
|
|
185
|
+
allColumnsSet.add(key);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const allColumns = Array.from(allColumnsSet);
|
|
189
|
+
let newHeight = 0;
|
|
190
|
+
for (let i = 0; i < items.length; i++) {
|
|
191
|
+
newHeight += items[i].height;
|
|
192
|
+
}
|
|
193
|
+
const outSchema = {};
|
|
194
|
+
for (const key of allColumns) {
|
|
195
|
+
let colType = null;
|
|
196
|
+
for (const item of items) {
|
|
197
|
+
const itemType = item.schema[key];
|
|
198
|
+
if (itemType) {
|
|
199
|
+
if (colType === null) {
|
|
200
|
+
colType = itemType;
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
if (!colType.equals(itemType)) {
|
|
204
|
+
throw new exceptions_1.SchemaError(`[Strict Type Check] Schema type mismatch for column "${key}": expected ${colType.name}, found ${itemType.name}.`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
outSchema[key] = colType || datatypes_1.DataTypeRegistry.Utf8;
|
|
210
|
+
}
|
|
211
|
+
const newColumns = {};
|
|
212
|
+
for (let j = 0; j < allColumns.length; j++) {
|
|
213
|
+
newColumns[allColumns[j]] = new Array(newHeight).fill(null);
|
|
214
|
+
}
|
|
215
|
+
let offset = 0;
|
|
216
|
+
for (let i = 0; i < items.length; i++) {
|
|
217
|
+
const df = items[i];
|
|
218
|
+
const h = df.height;
|
|
219
|
+
if (h === 0)
|
|
220
|
+
continue;
|
|
221
|
+
for (let j = 0; j < allColumns.length; j++) {
|
|
222
|
+
const col = allColumns[j];
|
|
223
|
+
const dest = newColumns[col];
|
|
224
|
+
const src = df._columns[col];
|
|
225
|
+
if (src !== undefined) {
|
|
226
|
+
if ((0, utils_1.isTypedArray)(src) && (0, utils_1.isTypedArray)(dest)) {
|
|
227
|
+
dest.set(src, offset);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
const destArr = dest;
|
|
231
|
+
for (let k = 0; k < h; k++) {
|
|
232
|
+
destArr[offset + k] = src[k];
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
const destArr = dest;
|
|
238
|
+
for (let k = 0; k < h; k++) {
|
|
239
|
+
destArr[offset + k] = null;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
offset += h;
|
|
244
|
+
}
|
|
245
|
+
return new dataframe_1.DataFrame(newColumns, outSchema, newHeight);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./concat";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./concat"), exports);
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var oe=Object.defineProperty;var bn=Object.getOwnPropertyDescriptor;var wn=Object.getOwnPropertyNames;var _n=Object.prototype.hasOwnProperty;var Tn=(s,t)=>{for(var e in t)oe(s,e,{get:t[e],enumerable:!0})},Dn=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of wn(t))!_n.call(s,r)&&r!==e&&oe(s,r,{get:()=>t[r],enumerable:!(n=bn(t,r))||n.enumerable});return s};var An=s=>Dn(oe({},"__esModule",{value:!0}),s);var Rn={};Tn(Rn,{$tbl:()=>On,ALL_COLUMNS_MARKER:()=>B,AggregationExpr:()=>pe,ArithmeticExpr:()=>fe,Binary:()=>Le,BinaryType:()=>Yt,Boolean:()=>Fe,BooleanType:()=>Gt,ColumnExpr:()=>k,ColumnNotFoundError:()=>wt,ComparisonExpr:()=>me,ComputeError:()=>et,DFScriptError:()=>ct,DataFrame:()=>F,DataFrameError:()=>V,DataType:()=>z,DataTypeRegistry:()=>L,Date:()=>Ve,DateTimeExprNamespace:()=>Ut,DateType:()=>Jt,Datetime:()=>Ke,DatetimeType:()=>Qt,DecimalType:()=>Dt,Duration:()=>Pe,DurationType:()=>ee,ExprBase:()=>bt,Float32:()=>Ue,Float32Type:()=>qt,Float64:()=>Me,Float64Type:()=>Ht,FloatDataType:()=>mt,GroupedData:()=>Ct,Int16:()=>Ie,Int16Type:()=>jt,Int32:()=>Se,Int32Type:()=>Bt,Int64:()=>ke,Int64Type:()=>Vt,Int8:()=>Ce,Int8Type:()=>Lt,IntegerDataType:()=>Tt,LITERAL_MARKER:()=>he,List:()=>We,ListExpr:()=>be,ListExprNamespace:()=>Mt,ListType:()=>ne,LogicalExpr:()=>de,NestedDataType:()=>pt,Null:()=>je,NullType:()=>Zt,NumericDataType:()=>lt,Object:()=>Be,ObjectType:()=>Xt,SchemaError:()=>ht,SignedIntegerType:()=>ot,StringExpr:()=>ye,StringExprNamespace:()=>Rt,Struct:()=>qe,StructType:()=>re,TemporalDataType:()=>at,TemporalExpr:()=>xe,Time:()=>$e,TimeType:()=>te,UInt16:()=>ve,UInt16Type:()=>$t,UInt32:()=>Oe,UInt32Type:()=>Pt,UInt64:()=>Re,UInt64Type:()=>Wt,UInt8:()=>Ee,UInt8Type:()=>Kt,UnsignedIntegerType:()=>it,Utf8:()=>Ne,Utf8Type:()=>zt,When:()=>Nt,WhenThen:()=>_t,WhenThenChain:()=>Ft,WindowExpr:()=>ge,all:()=>_e,assertColumnExists:()=>W,coalesce:()=>De,columnsToRows:()=>Ge,concat:()=>It,derive:()=>g,exclude:()=>Te,gatherColumnsByIndices:()=>At,getRowFromColumns:()=>vn,inferColumnType:()=>nt,kleeneBinary:()=>U,kleeneUnary:()=>w,lit:()=>we,normalizeToDataFrames:()=>xn,resolveColumnSelectors:()=>ft,resolveWindowExpr:()=>se,rowsToColumns:()=>He,when:()=>Ae});module.exports=An(Rn);var Xe=/[,\s_]/g,Cn=/^[+-]?\d+(?:\.\d+)?$/;function rt(s){return typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s)}function Q(s){if(s==null||typeof s=="symbol")return null;if(rt(s))return s;if(typeof s=="boolean")return s?1:0;if(typeof s=="bigint"){let t=Number(s);return rt(t)?t:null}if(s instanceof Date){let t=s.getTime();return rt(t)?t:null}if(typeof s=="string"){let t=s.trim().replace(Xe,"");if(t==="")return null;let e=Number(t);return rt(e)?e:null}return null}function yt(s){let{val:t,min:e,max:n}=s;return t<e?e:t>n?n:t}var Ze=34028234663852886e22,Mn={Float32:{min:-Ze,max:Ze},Float64:{min:-Number.MAX_VALUE,max:Number.MAX_VALUE}};function ie(s,t="Float64"){let e=Q(s);return e===null?null:t==="Float32"?Math.fround(e):e}var Je={Int8:{min:-128,max:127},Int16:{min:-32768,max:32767},Int32:{min:-2147483648,max:2147483647},UInt8:{min:0,max:255},UInt16:{min:0,max:65535},UInt32:{min:0,max:4294967295}},In={Int64:{min:-9223372036854775808n,max:9223372036854775807n},UInt64:{min:0n,max:18446744073709551615n}};function Qe(s,t){if(!rt(s)||!Number.isInteger(s))return!1;if(!t)return!0;let e=typeof t=="string"?Je[t]:t;return s>=e.min&&s<=e.max}function tt(s,t="Int32",e={}){let n=Q(s);if(n===null)return null;let r=n;switch(e.coerce||"truncate"){case"round":r=Math.round(r);break;case"floor":r=Math.floor(r);break;case"ceil":r=Math.ceil(r);break;case"truncate":r=Math.trunc(r);break}let i=typeof t=="string"?Je[t]:t;return yt({val:r,min:i.min,max:i.max})}function ae(s,t="Int64"){if(s==null||typeof s=="symbol")return null;let e=null;if(typeof s=="bigint")e=s;else if(typeof s=="boolean")e=s?1n:0n;else if(typeof s=="string"){let r=s.trim().replace(Xe,"");if(r==="")return null;if(Cn.test(r))e=BigInt(r.split(".")[0]);else{let o=Q(s);if(o===null)return null;e=BigInt(Math.trunc(o))}}else{let r=Q(s);if(r===null)return null;e=BigInt(Math.trunc(r))}let n=typeof t=="string"?In[t]:t;return yt({val:e,min:n.min,max:n.max})}function St(s,t={}){let e=Q(s);if(e===null)return null;let{precision:n,scale:r}=t,o=e;if(r!==void 0){let i=Math.pow(10,r);o=Math.round(o*i)/i}if(n!==void 0){let i=r||0,a=n-i;if(a>0){let l=Math.pow(10,a)-Math.pow(10,-i);o=yt({val:o,min:-l,max:l})}}return o}function tn(s){let t=s|0;return function(){let e=t=t+1831565813|0;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}var kt=/^\d{2}:\d{2}/,Et=/(?:Z|[+-]\d{2}(?::?\d{2})?)$/i;var le=1e3,nn=6e4,rn=36e5,dt=864e5,vt=1e3,Ot=1e6;function sn(s,t="ms"){let e=s.getTime();switch(t){case"s":return Math.floor(e/le);case"ms":return e;case"us":return e*vt;case"ns":return e*Ot}}function on(s){let t=s.getUTCFullYear();return Math.floor((t-1)/100)+1}function an(s){let t=new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate())),e=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-e);let n=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-n.getTime())/dt+1)/7)}function ln(s){let t=s.getUTCFullYear();return Math.floor((t-1)/1e3)+1}function ue(s,t,e=1){return new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth()+t,e,0,0,0,0))}function un(s){let t=new Date(Date.UTC(s.getUTCFullYear(),0,1)),e=s.getTime()-t.getTime();return Math.floor(e/dt)+1}function cn(s){return Math.floor(s.getUTCMonth()/3)+1}function hn(s){let t=s instanceof Date?s.getUTCFullYear():s;return t%4===0&&t%100!==0||t%400===0}function G(s){return s instanceof Date&&!Number.isNaN(s.getTime())}function en(s){let t=Math.abs(s);return t>=1e12?s:t<=1e10?s*1e3:s}var Sn=["%ms","%f","%Y","%y","%m","%d","%e","%H","%I","%p","%M","%S","%A","%a","%B","%b","%h","%j","%u","%w","%Z","%z"];function fn(s,t,e){let n=t;n=n.replace(/%%/g,"\0"),n=n.replace(/%F/g,"%Y-%m-%d"),n=n.replace(/%T/g,"%H:%M:%S"),n=n.replace(/%R/g,"%H:%M"),n=n.replace(/%D/g,"%m/%d/%y");let r={get"%Y"(){return String(s.getUTCFullYear())},get"%y"(){return String(s.getUTCFullYear()%100).padStart(2,"0")},get"%m"(){return String(s.getUTCMonth()+1).padStart(2,"0")},get"%d"(){return String(s.getUTCDate()).padStart(2,"0")},get"%e"(){return String(s.getUTCDate()).padStart(2," ")},get"%H"(){return String(s.getUTCHours()).padStart(2,"0")},get"%I"(){return String(s.getUTCHours()%12||12).padStart(2,"0")},get"%p"(){return s.getUTCHours()>=12?"PM":"AM"},get"%M"(){return String(s.getUTCMinutes()).padStart(2,"0")},get"%S"(){return String(s.getUTCSeconds()).padStart(2,"0")},get"%A"(){return s.toLocaleDateString(e,{weekday:"long",timeZone:"UTC"})},get"%a"(){return s.toLocaleDateString(e,{weekday:"short",timeZone:"UTC"})},get"%B"(){return s.toLocaleDateString(e,{month:"long",timeZone:"UTC"})},get"%b"(){return s.toLocaleDateString(e,{month:"short",timeZone:"UTC"})},get"%h"(){return s.toLocaleDateString(e,{month:"short",timeZone:"UTC"})},get"%j"(){let o=new Date(Date.UTC(s.getUTCFullYear(),0,1)),i=s.getTime()-o.getTime(),a=Math.floor(i/dt)+1;return String(a).padStart(3,"0")},get"%u"(){return String(s.getUTCDay()||7)},get"%w"(){return String(s.getUTCDay())},get"%Z"(){return"UTC"},get"%z"(){return"+0000"},get"%ms"(){return String(s.getUTCMilliseconds()).padStart(3,"0")},get"%f"(){return String(s.getUTCMilliseconds()*1e3).padStart(6,"0")}};for(let o of Sn)n.includes(o)&&(n=n.replaceAll(o,r[o]));return n.replace(/\0/g,"%")}function mn(s,t,e=!0){if(typeof s!="string"||typeof t!="string")return null;let n=[],r=1,o="",i=0;for(;i<t.length;){let b=t[i];if(b==="%")if(i+1<t.length){let T=t[i+1];if(T==="%")o+="%",i+=2;else if(t.slice(i,i+3)==="%ms")n.push({name:"ms",index:r++}),o+="(\\d{1,3})",i+=3;else{switch(T){case"Y":n.push({name:"year",index:r++}),o+="(\\d{4})";break;case"y":n.push({name:"year_short",index:r++}),o+="(\\d{2})";break;case"m":n.push({name:"month",index:r++}),o+="(\\d{1,2})";break;case"d":case"e":n.push({name:"day",index:r++}),o+="(\\d{1,2})";break;case"H":case"I":n.push({name:"hour",index:r++}),o+="(\\d{1,2})";break;case"M":n.push({name:"minute",index:r++}),o+="(\\d{1,2})";break;case"S":n.push({name:"second",index:r++}),o+="(\\d{1,2})";break;case"f":n.push({name:"fractional",index:r++}),o+="(\\d{1,6})";break;default:o+=b+T}i+=2}}else o+=b,i++;else"\\^$*+?.()|[]{}".indexOf(b)!==-1?o+="\\"+b:o+=b,i++}let a=new RegExp("^"+o+"$"),l=s.match(a);if(!l){if(e)return null;let b=new Date(s);return G(b)?b:null}let u=1970,c=1,h=1,f=0,m=0,p=0,y=0;for(let b of n){let T=l[b.index],A=parseInt(T,10);switch(b.name){case"year":u=A;break;case"year_short":u=A+(A>=69?1900:2e3);break;case"month":c=A;break;case"day":h=A;break;case"hour":f=A;break;case"minute":m=A;break;case"second":p=A;break;case"ms":y=parseInt(T.padEnd(3,"0").slice(0,3),10);break;case"fractional":y=parseInt(T.padEnd(6,"0").slice(0,3),10);break}}let x=new Date(Date.UTC(u,c-1,h,f,m,p,y));return G(x)?x:null}function X(s){if(s instanceof Date)return G(s)?s:null;if(typeof s=="number"){let t=new Date(en(s));return G(t)?t:null}if(typeof s=="bigint"){let t=new Date(en(Number(s)));return G(t)?t:null}if(typeof s=="string"){let t=s.trim();if(t==="")return null;let e=new Date(t);return G(e)?e:null}return null}function $(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function D(s){return Array.isArray(s)||$(s)}function Y(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}function xt(s){if(!Y(s))return!1;let t=Object.getPrototypeOf(s);return t===null||t===Object.prototype}function pn(s){return typeof s!="function"?!1:/^class\s/.test(Function.prototype.toString.call(s))||s.prototype!==void 0&&s.prototype.constructor===s&&Object.getOwnPropertyDescriptor(s,"prototype")?.writable===!1}function kn(s){if(s==null)return!1;if(s instanceof Uint8Array||typeof s=="string")return!0;if(Array.isArray(s)){let t=s.length;for(let e=0;e<t;e++)if(!Qe(s[e],{min:-128,max:255}))return!1;return!0}return!!$(s)}function gn(s){return kn(s)?s instanceof Uint8Array?s:typeof s=="string"?new TextEncoder().encode(s):ArrayBuffer.isView(s)?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):new Uint8Array(s):null}function st(s){return s==null?[]:Array.isArray(s)?s:$(s)?Array.from(s):[s]}function Z(s,t,{mode:e="every",allowNulls:n=!1,allowEmpty:r=!0}={}){if(!D(s))return!1;let o=s.length;if(o===0)return r?e==="every":!1;let i=a=>a==null?n:typeof t=="function"?pn(t)?a instanceof t:t(a):t==="date"?G(a):t==="object"?Y(a):t==="plainObject"?xt(a):t==="number"?rt(a):typeof a===t;if(e==="every"){for(let a=0;a<o;a++)if(!i(s[a]))return!1;return!0}else{for(let a=0;a<o;a++)if(i(s[a]))return!0;return!1}}function ce(s,t=!1){if(!D(s))return[];let e=Array.from(s);return e.sort((n,r)=>n==null&&r==null?0:n==null?1:r==null?-1:n<r?t?1:-1:n>r?t?-1:1:0),e}var yn={sum:null,count:0,min:null,max:null,mean:null,variance:0,std:0,nullCount:0,len:0,hasNulls:!1,isNumeric:!1};function j(s){if(!D(s))return{...yn};let t=s.length;if(t===0)return{...yn};let e=null,n=null,r=0,o=0,i=0,a=0,l=0;for(let c=0;c<t;c++){let h=s[c];if(h==null){o++;continue}(e==null||h<e)&&(e=h),(n==null||h>n)&&(n=h);let f=Q(h);if(f!==null){i+=f,r++;let m=f-a;a+=m/r;let p=f-a;l+=m*p}}let u=r>1?l/(r-1):0;return{sum:r>0?i:null,count:r,min:e,max:n,mean:r>0?i/r:null,variance:u,std:Math.sqrt(u),nullCount:o,len:t,hasNulls:o>0,isNumeric:r>0&&r===t-o}}function ut(s,t=null,{mode:e="both",returnStringOnNull:n=!1,maxScanStart:r=1,maxScanEnd:o=1,maxMatchesStart:i=1,maxMatchesEnd:a=1,trimFirst:l=!1,stringOptions:{literal:u=!1,caseInsensitive:c=!1}={}}={}){if(s==null)return n?"":null;let h=(d,I="both")=>I==="start"?d.trimStart():I==="end"?d.trimEnd():d.trim(),f=s;if(l&&t!=null&&(f=h(s,e)),t==null){let d=h(f,e);return n||d!==""?d:null}let m=t instanceof RegExp?d=>t.test(d):(()=>{let d=new Set(c?t.toLowerCase():t);return I=>d.has(c?I.toLowerCase():I)})(),p=f.length,y=new Uint8Array(p),A=u&&typeof t=="string"?({isStart:d,limit:I,maxMatches:R})=>{if(p===0||R===0)return;let E=t.length;if(E===0)return;let N=c?f.toLowerCase():f,K=c?t.toLowerCase():t,_=d?0:p-1,C=0,v=0;for(;_>=0&&_<p&&!(R!==null&&R>=0&&C>=R);){let M=d?_:_-E+1;if(!d&&M<0)break;let O=d?N.indexOf(K,M):N.lastIndexOf(K,M);if(O===-1)break;let q=d?O-_:_-(O+E-1);if(v+=q,I!==null&&I>=0&&v>=I)break;for(let H=0;H<E;H++)y[O+H]=1;C++,_=d?O+E:O-1}}:({isStart:d,limit:I,maxMatches:R})=>{if(p===0||R===0)return;let E=d?0:p-1,N=d?p:-1,K=d?1:-1,_=!1,C=0,v=0;for(let M=E;M!==N;M+=K)if(m(f[M])){if(!_){if(I!==null&&I>=0&&v>=I||R!==null&&R>=0&&C>=R)break;_=!0,C++}y[M]=1}else _=!1,v++};(e==="both"||e==="start")&&A({isStart:!0,limit:r,maxMatches:i}),(e==="both"||e==="end")&&A({isStart:!1,limit:o,maxMatches:a});let S="";for(let d=0;d<p;d++)y[d]===0&&(S+=f[d]);return n||S!==""?S:null}var B="*",he="*literal*";var w=s=>t=>{let e=t.length,n=new Array(e);for(let r=0;r<e;r++){let o=t[r];n[r]=o==null?null:s(o)}return n},U=(s,t,e)=>(n,r)=>{let o=n.length,i=s._resolve(t,r,o),a=new Array(o);if(D(i))for(let l=0;l<o;l++){let u=n[l],c=i[l];a[l]=u==null||c==null?null:e(u,c)}else for(let l=0;l<o;l++){let u=n[l];a[l]=u==null||i==null?null:e(u,i)}return a},g=(s,t)=>{let e=s.constructor,n=new e(s.colName||"");return Object.assign(n,s),n.ops=t?[...s.ops,t]:[...s.ops],n},bt=class{ops=[];outputName="";aggFn=null;groupingOpsIndex;partitionOpsIndex;partitionBy=null;_resolve(t,e,n){return t&&typeof t=="object"&&"evaluate"in t?t.isLiteral&&t.ops.length===1?t.literalValue:t.evaluate(e,n):t}alias(t){let e=this.constructor,n=new e(this.colName||"");return Object.assign(n,this),n.outputName=t,n}cast(t){return g(this,e=>{let n=e.length,r=new Array(n);for(let o=0;o<n;o++)r[o]=t.coerce(e[o]);return r})}debug(t){return g(this,e=>(console.log(`[DEBUG] ${t?t+": ":""}`,e),e))}evaluate(t,e){let n=this.colName,r=n&&n!=="*"?t[n]||new Array(e).fill(null):new Array(e).fill(null),o=this.ops,i=o.length;for(let a=0;a<i;a++)r=o[a](r,t);return r}_evaluatePre(t,e,n){let r=this.colName,o=r&&r!=="*"?e[r]||new Array(n).fill(null):new Array(n).fill(null),i=this.ops,a=t!==void 0?t:i.length;for(let l=0;l<a;l++)o=i[l](o,e);return o}_evaluatePost(t,e,n){let r=this.ops,o=t!==void 0?t:r.length,i=e;for(let a=o;a<r.length;a++)i=r[a](i,n);return i}evaluatePrePartition(t,e){return this._evaluatePre(this.partitionOpsIndex,t,e)}evaluatePostPartition(t,e){return this._evaluatePost(this.partitionOpsIndex,t,e)}evaluatePreGrouping(t,e){return this._evaluatePre(this.groupingOpsIndex,t,e)}evaluatePostGrouping(t,e){return this._evaluatePost(this.groupingOpsIndex,t,e)}};var fe=s=>class extends s{abs(){return g(this,w(t=>Math.abs(t)))}acos(){return g(this,w(t=>t<-1||t>1?null:Math.acos(t)))}acosh(){return g(this,w(t=>t<1?null:Math.acosh(t)))}add(t){return g(this,U(this,t,(e,n)=>e+n))}asin(){return g(this,w(t=>t<-1||t>1?null:Math.asin(t)))}asinh(){return g(this,w(Math.asinh))}atan(){return g(this,w(Math.atan))}atanh(){return g(this,w(t=>t<=-1||t>=1?null:Math.atanh(t)))}cbrt(){return g(this,w(Math.cbrt))}ceil(){return g(this,w(Math.ceil))}clip(t=null,e=null){return g(this,w(n=>t!==null&&e!==null?yt({val:n,min:t,max:e}):t!==null?Math.max(n,t):e!==null?Math.min(n,e):n))}cos(){return g(this,w(Math.cos))}cosh(){return g(this,w(Math.cosh))}degrees(){return g(this,w(t=>t*(180/Math.PI)))}div(t){return g(this,U(this,t,(e,n)=>n===0?null:e/n))}exp(){return g(this,w(Math.exp))}expm1(){return g(this,w(Math.expm1))}floor(){return g(this,w(Math.floor))}floordiv(t){return g(this,U(this,t,(e,n)=>n===0?null:Math.floor(e/n)))}hypot(t){return g(this,U(this,t,(e,n)=>Math.hypot(e,n)))}log(t=Math.E){return g(this,w(e=>e<=0?null:t===Math.E?Math.log(e):Math.log(e)/Math.log(t)))}log1p(){return g(this,w(t=>t<=-1?null:Math.log1p(t)))}mod(t){return g(this,U(this,t,(e,n)=>n===0?null:e%n))}mul(t){return g(this,U(this,t,(e,n)=>e*n))}negate(){return g(this,w(t=>-t))}pow(t){return g(this,U(this,t,(e,n)=>Math.pow(e,n)))}radians(){return g(this,w(t=>t*(Math.PI/180)))}rand(t,{min:e=0,max:n=1,integer:r=!1}={}){return g(this,o=>{let i=o.length,a=new Float64Array(i),l=t!==void 0?tn(t):Math.random,u=n-e;for(let c=0;c<i;c++){let h=l();a[c]=r?Math.floor(h*(u+1))+e:h*u+e}return a})}round(t=0){let e=Math.pow(10,t);return g(this,w(n=>Math.round(n*e)/e))}sign(){return g(this,w(Math.sign))}sin(){return g(this,w(Math.sin))}sinh(){return g(this,w(Math.sinh))}sqrt(){return g(this,w(t=>t<0?null:Math.sqrt(t)))}sub(t){return g(this,U(this,t,(e,n)=>e-n))}tan(){return g(this,w(Math.tan))}tanh(){return g(this,w(Math.tanh))}trunc(){return g(this,w(Math.trunc))}};function P(s){return s==null?s:s instanceof Date?`d:${s.getTime()}`:s instanceof Uint8Array?`u:${s.toString()}`:typeof s=="object"||typeof s=="function"?String(s):s}var me=s=>class extends s{between(t,e,n="both"){return g(this,(r,o)=>{let i=r.length,a=this._resolve(t,o,i),l=this._resolve(e,o,i),u=new Array(i),c=D(a),h=D(l);for(let f=0;f<i;f++){let m=r[f],p=c?a[f]:a,y=h?l[f]:l;if(m==null||p==null||y==null)u[f]=null;else{let x=n==="both"||n==="left"?m>=p:m>p,b=n==="both"||n==="right"?m<=y:m<y;u[f]=x&&b}}return u})}eq(t){return g(this,U(this,t,(e,n)=>e===n))}eq_missing(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=new Array(r);if(D(o))for(let a=0;a<r;a++){let l=e[a],u=o[a];l==null&&u==null?i[a]=!0:l==null||u==null?i[a]=!1:i[a]=l===u}else for(let a=0;a<r;a++){let l=e[a];l==null&&o==null?i[a]=!0:l==null||o==null?i[a]=!1:i[a]=l===o}return i})}ge(t){return g(this,U(this,t,(e,n)=>e>=n))}gt(t){return g(this,U(this,t,(e,n)=>e>n))}has_nulls(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(t[e]==null)return!0;return!1})}is_close(t,e={}){let{abs_tol:n=1e-8,rel_tol:r=1e-8,nans_equal:o=!1}=e;return g(this,(i,a)=>{let l=i.length,u=this._resolve(t,a,l),c=D(u),h=new Array(l);for(let f=0;f<l;f++){let m=i[f],p=c?u[f]:u;if(m==null||p==null)h[f]=null;else if(Number.isNaN(m)||Number.isNaN(p))o&&Number.isNaN(m)&&Number.isNaN(p)?h[f]=!0:h[f]=!1;else if(!Number.isFinite(m)||!Number.isFinite(p))h[f]=m===p;else{let y=Math.abs(m-p),x=Math.max(r*Math.max(Math.abs(m),Math.abs(p)),n);h[f]=y<=x}}return h})}is_duplicated(){return g(this,t=>{let e=t.length,n=new Map,r=new Array(e);for(let i=0;i<e;i++){let a=P(t[i]);r[i]=a,n.set(a,(n.get(a)||0)+1)}let o=new Array(e);for(let i=0;i<e;i++)o[i]=(n.get(r[i])||0)>1;return o})}is_empty(t={}){let{ignoreNulls:e=!1}=t;return g(this,w(n=>{if(typeof n=="string")return n.length===0;if(D(n)){if(e){let r=n.length,o=0;for(let i=0;i<r;i++)n[i]!=null&&o++;return o===0}return n.length===0}return null}))}is_finite(){return g(this,w(Number.isFinite))}is_first_distinct(){return g(this,t=>{let e=t.length,n=new Set,r=new Array(e);for(let o=0;o<e;o++){let i=P(t[o]);n.has(i)?r[o]=!1:(n.add(i),r[o]=!0)}return r})}is_in(t){return g(this,(e,n)=>{let r=e.length,o=new Array(r);if(t&&typeof t=="object"&&"evaluate"in t){let i=t.evaluate(n,r);for(let a=0;a<r;a++){let l=e[a];if(l==null)o[a]=null;else{let u=i[a],c=new Set;if(D(u)){let h=u.length;for(let f=0;f<h;f++)c.add(P(u[f]))}else c.add(P(u));o[a]=c.has(P(l))}}}else{let i=D(t)?t:[],a=new Set,l=i.length;for(let u=0;u<l;u++)a.add(P(i[u]));for(let u=0;u<r;u++){let c=e[u];o[u]=c==null?null:a.has(P(c))}}return o})}is_infinite(){return g(this,w(t=>t===1/0||t===-1/0))}is_last_distinct(){return g(this,t=>{let e=t.length,n=new Set,r=new Array(e);for(let o=e-1;o>=0;o--){let i=P(t[o]);n.has(i)?r[o]=!1:(n.add(i),r[o]=!0)}return r})}is_n_distinct(t){return this._deriveAgg(e=>{let n=new Set,r=e.length;for(let o=0;o<r;o++)n.add(P(e[o]));return n.size===t})}is_nan(){return g(this,w(Number.isNaN))}is_not_nan(){return g(this,w(t=>!Number.isNaN(t)))}is_not_null(){return g(this,t=>{let e=t.length,n=new Array(e);for(let r=0;r<e;r++)n[r]=t[r]!=null;return n})}is_null(){return g(this,t=>{let e=t.length,n=new Array(e);for(let r=0;r<e;r++)n[r]=t[r]==null;return n})}is_unique(){return g(this,t=>{let e=t.length,n=new Map,r=new Array(e);for(let i=0;i<e;i++){let a=P(t[i]);r[i]=a,n.set(a,(n.get(a)||0)+1)}let o=new Array(e);for(let i=0;i<e;i++)o[i]=n.get(r[i])===1;return o})}le(t){return g(this,U(this,t,(e,n)=>e<=n))}lt(t){return g(this,U(this,t,(e,n)=>e<n))}ne(t){return g(this,U(this,t,(e,n)=>e!==n))}ne_missing(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=new Array(r);if(D(o))for(let a=0;a<r;a++){let l=e[a],u=o[a];l==null&&u==null?i[a]=!1:l==null||u==null?i[a]=!0:i[a]=l!==u}else for(let a=0;a<r;a++){let l=e[a];l==null&&o==null?i[a]=!1:l==null||o==null?i[a]=!0:i[a]=l!==o}return i})}not_in(t){return g(this,(e,n)=>{let r=e.length,o=new Array(r);if(t&&typeof t=="object"&&"evaluate"in t){let i=t.evaluate(n,r);for(let a=0;a<r;a++){let l=e[a];if(l==null)o[a]=null;else{let u=i[a],c=new Set;if(D(u)){let h=u.length;for(let f=0;f<h;f++)c.add(P(u[f]))}else c.add(P(u));o[a]=!c.has(P(l))}}}else{let i=D(t)?t:[],a=new Set,l=i.length;for(let u=0;u<l;u++)a.add(P(i[u]));for(let u=0;u<r;u++){let c=e[u];o[u]=c==null?null:!a.has(P(c))}}return o})}};function W(s,t,e,n=""){if(!(s in t))throw new wt(s,`${e} "${s}" does not exist${n}`)}var ct=class extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},V=class extends ct{},wt=class extends V{constructor(t,e){super(e||`Column "${t}" does not exist in the DataFrame.`)}},ht=class extends ct{},et=class extends ct{};var pe=s=>class extends s{aggFn=this.aggFn||null;_deriveAgg(t){let e=g(this);return e.aggFn=t,e.groupingOpsIndex=this.ops.length,e.partitionOpsIndex=this.ops.length,e}all(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(!t[e])return!1;return!0})}all_null(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(t[e]!=null)return!1;return!0})}any(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(t[e])return!0;return!1})}any_null(){return this._deriveAgg(t=>{for(let e=0;e<t.length;e++)if(t[e]==null)return!0;return!1})}avg(){return this._deriveAgg(t=>j(t).mean)}count(t={}){return t.includeNulls?this._deriveAgg(e=>e.length):this._deriveAgg(e=>j(e).count)}first(){return this._deriveAgg(t=>t[0]??null)}last(){return this._deriveAgg(t=>t[t.length-1]??null)}max(){return this._deriveAgg(t=>j(t).max)}mean(){return this.avg()}median(){return this._deriveAgg(t=>{if(!Z(t,"number",{allowNulls:!0}))return null;let e=t.length,n=[];for(let i=0;i<e;i++){let a=t[i];a!=null&&n.push(a)}let r=n.length;if(r===0)return null;n.sort((i,a)=>i-a);let o=Math.floor(r/2);return r%2!==0?n[o]:(n[o-1]+n[o])/2})}min(){return this._deriveAgg(t=>j(t).min)}mode(){return this._deriveAgg(t=>{if(!D(t))return null;let e=t.length,n=new Map,r=0;for(let i=0;i<e;i++){let a=t[i];if(a==null)continue;let l=(n.get(a)??0)+1;n.set(a,l),l>r&&(r=l)}if(r===0)return null;let o=[];for(let[i,a]of n.entries())a===r&&o.push(i);return o.length===0?null:(o.sort((i,a)=>i==null&&a==null?0:i==null?1:a==null||i<a?-1:i>a?1:0),o[0])})}n_unique(){return this._deriveAgg(t=>new Set(t).size)}quantile(t){if(t<0||t>1)throw new et("Quantile q must be between 0 and 1");return this._deriveAgg(e=>{let n=[];for(let l=0;l<e.length;l++)e[l]!=null&&n.push(e[l]);let r=n.length;if(!r)return null;n.sort((l,u)=>l-u);let o=(r-1)*t,i=Math.floor(o),a=Math.ceil(o);return i===a?n[i]:n[i]+(o-i)*(n[a]-n[i])})}std(){return this._deriveAgg(t=>j(t).std)}sum(){return this._deriveAgg(t=>j(t).sum)}};var ge=s=>class extends s{partitionBy=this.partitionBy||null;_rolling(t,e){let n=g(this);return n.partitionOpsIndex=this.ops.length,n.groupingOpsIndex=this.ops.length,n.evaluateWindow=function(r,o,i){let a=Math.max(0,i-t+1),l=i+1,u=r.slice(a,l);return e(u)},n}get isWindow(){return this.partitionBy!==null||this.evaluateWindow!==void 0||this.aggFn!==null}cum_count(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=0,a=t?o:0,l=t?n.length-1:o;for(let u=a;u<=l;u++)n[u]!=null&&i++;return i},e}cum_max(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=null,a=t?o:0,l=t?n.length-1:o;for(let u=a;u<=l;u++){let c=n[u];c!=null&&(i===null||c>i)&&(i=c)}return i},e}cum_min(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=null,a=t?o:0,l=t?n.length-1:o;for(let u=a;u<=l;u++){let c=n[u];c!=null&&(i===null||c<i)&&(i=c)}return i},e}cum_prod(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=1,a=!1,l=t?o:0,u=t?n.length-1:o;for(let c=l;c<=u;c++){let h=n[c];h!=null&&(i*=h,a=!0)}return a?i:null},e}cum_sum(t=!1){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=0,a=t?o:0,l=t?n.length-1:o;for(let u=a;u<=l;u++){let c=n[u];c!=null&&(i+=c)}return i},e}dense_rank(){let t=g(this);return t.partitionOpsIndex=this.ops.length,t.groupingOpsIndex=this.ops.length,t.evaluateWindow=function(e,n,r){let o=Array.from(new Set(e)).sort((l,u)=>l-u),i=new Map;for(let l=0;l<o.length;l++)i.set(o[l],l+1);let a=e[r];return i.get(a)??null},t}lag(t=1,e=null){let n=g(this);return n.partitionOpsIndex=this.ops.length,n.groupingOpsIndex=this.ops.length,n.evaluateWindow=function(r,o,i){let a=e;return i-t>=0&&(a=r[i-t]),a},n}lead(t=1,e=null){let n=g(this);return n.partitionOpsIndex=this.ops.length,n.groupingOpsIndex=this.ops.length,n.evaluateWindow=function(r,o,i){let a=e;return i+t<r.length&&(a=r[i+t]),a},n}over(t){let e=g(this),n=Array.isArray(t)?t:[t];return e.partitionBy=n,e}rank(){let t=g(this);return t.partitionOpsIndex=this.ops.length,t.groupingOpsIndex=this.ops.length,t.evaluateWindow=function(e,n,r){let o=[...e].sort((l,u)=>l-u),i=new Map;for(let l=0;l<o.length;l++){let u=o[l];i.has(u)||i.set(u,l+1)}let a=e[r];return i.get(a)??null},t}rolling_max(t){return this._rolling(t,e=>j(e).max)}rolling_mean(t){return this._rolling(t,e=>j(e).mean)}rolling_median(t){return this._rolling(t,e=>{if(!Z(e,"number",{allowNulls:!0}))return null;let n=e.length,r=[];for(let a=0;a<n;a++){let l=e[a];l!=null&&r.push(l)}let o=r.length;if(o===0)return null;r.sort((a,l)=>a-l);let i=Math.floor(o/2);return o%2!==0?r[i]:(r[i-1]+r[i])/2})}rolling_min(t){return this._rolling(t,e=>j(e).min)}rolling_quantile(t,e){return this._rolling(e,n=>{let r=[];for(let u=0;u<n.length;u++)n[u]!=null&&r.push(n[u]);let o=r.length;if(o===0)return null;r.sort((u,c)=>u-c);let i=t*(o-1),a=Math.floor(i),l=Math.ceil(i);return a===l?r[a]:r[a]+(i-a)*(r[l]-r[a])})}rolling_rank(t){let e=g(this);return e.partitionOpsIndex=this.ops.length,e.groupingOpsIndex=this.ops.length,e.evaluateWindow=function(n,r,o){let i=Math.max(0,o-t+1),a=o+1,l=n.slice(i,a),u=n[o];if(u==null)return null;let c=[];for(let m=0;m<l.length;m++)l[m]!=null&&c.push(l[m]);if(c.length===0)return null;let h=[...c].sort((m,p)=>m-p),f=new Map;for(let m=0;m<h.length;m++){let p=h[m];f.has(p)||f.set(p,m+1)}return f.get(u)??null},e}rolling_std(t){return this._rolling(t,e=>j(e).std)}rolling_sum(t){return this._rolling(t,e=>j(e).sum)}row_number(){let t=g(this);return t.partitionOpsIndex=this.ops.length,t.groupingOpsIndex=this.ops.length,t.evaluateWindow=function(e,n,r){return r+1},t.outputName="row_number",t}};var Rt=class{constructor(t){this.expr=t}expr;_deriveString(t){return g(this.expr,w(e=>t(String(e))))}concat(t){return g(this.expr,U(this.expr,t,(e,n)=>String(e)+String(n)))}contains(t){return t==null?g(this.expr,e=>new Array(e.length).fill(null)):this._deriveString(e=>t instanceof RegExp?t.test(e):e.includes(t))}count_matches(t){return t==null?g(this.expr,e=>new Array(e.length).fill(null)):this._deriveString(e=>{if(t instanceof RegExp){let n=t.global?t:new RegExp(t.source,t.flags+"g"),r=e.match(n);return r?r.length:0}else{let n=0,r=e.indexOf(t);for(;r!==-1;)n++,r=e.indexOf(t,r+t.length);return n}})}decode_uri_component(){return this._deriveString(t=>{try{return decodeURIComponent(t)}catch{return t}})}encode_uri_component(){return this._deriveString(t=>{try{return encodeURIComponent(t)}catch{return t}})}ends_with(t){return this._deriveString(e=>e.endsWith(t))}explode(){return this._deriveString(t=>t.split(""))}extract(t,e=0){return t==null?g(this.expr,n=>new Array(n.length).fill(null)):this._deriveString(n=>{let r=n.match(t);return r&&r[e]!==void 0?r[e]:null})}len(){return this.len_chars()}len_bytes(){return this._deriveString(t=>new TextEncoder().encode(t).length)}len_chars(){return this._deriveString(t=>t.length)}lower(){return this._deriveString(t=>t.toLowerCase())}lpad(t,e=" "){return this._deriveString(n=>n.padStart(t,e))}pad_end(t,e=" "){return this.rpad(t,e)}pad_start(t,e=" "){return this.lpad(t,e)}replace(t,e){return t==null?g(this.expr,n=>new Array(n.length).fill(null)):this._deriveString(n=>n.replace(t,e))}replace_all(t,e){return t==null?g(this.expr,n=>new Array(n.length).fill(null)):this._deriveString(n=>{if(t instanceof RegExp){let r=t.global?t:new RegExp(t.source,t.flags+"g");return n.replace(r,e)}return n.replaceAll(t,e)})}reverse(){return this._deriveString(t=>t.split("").reverse().join(""))}rpad(t,e=" "){return this._deriveString(n=>n.padEnd(t,e))}slice(t,e){return this._deriveString(n=>{let r=t<0?n.length+t:t,o=e!==void 0?r+e:void 0;return n.slice(r,o)})}slice_str(t,e){return this.slice(t,e)}split(t){return this._deriveString(e=>e.split(t))}starts_with(t){return this._deriveString(e=>e.startsWith(t))}strip_chars(t,e){return this._deriveString(n=>ut(n,t,{mode:"both",...e}))}strip_chars_end(t,e){return this._deriveString(n=>ut(n,t,{mode:"end",...e}))}strip_chars_start(t,e){return this._deriveString(n=>ut(n,t,{mode:"start",...e}))}strip_prefix(t){return this._deriveString(e=>ut(e,t,{mode:"start",maxScanStart:1,maxMatchesStart:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}strip_suffix(t){return this._deriveString(e=>ut(e,t,{mode:"end",maxScanEnd:1,maxMatchesEnd:1,returnStringOnNull:!0,stringOptions:{literal:!0}}))}strptime(t,e=!0){return this._deriveString(n=>mn(n,t,e))}to_date(){return this._deriveString(t=>{let e=X(t);if(!e)return null;let n=new Date(e);return n.setUTCHours(0,0,0,0),n})}to_datetime(){return this._deriveString(X)}to_decimal(t,e){return this._deriveString(n=>St(n,{precision:t,scale:e}))}to_integer(){return this._deriveString(t=>tt(t))}to_lowercase(){return this.lower()}to_time(){return this._deriveString(t=>{let e=X(t);if(e)return e.toISOString().split("T")[1].slice(0,12);let n=t.trim();if(kt.test(n)){let r=new Date(`1970-01-01T${n}${Et.test(n)?"":"Z"}`);if(G(r))return r.toISOString().split("T")[1].slice(0,12)}return null})}to_titlecase(){return this._deriveString(t=>t.replace(/\b\w/g,e=>e.toUpperCase()))}to_uppercase(){return this.upper()}trim(){return this.strip_chars()}trim_end(){return this.strip_chars_end()}trim_start(){return this.strip_chars_start()}upper(){return this._deriveString(t=>t.toUpperCase())}zfill(t){return this._deriveString(e=>e.padStart(t,"0"))}},ye=s=>class extends s{get str(){return new Rt(this)}};var de=s=>class extends s{and(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=D(o),a=new Array(r);for(let l=0;l<r;l++){let u=e[l],c=i?o[l]:o;u===!1||c===!1?a[l]=!1:u==null||c==null?a[l]=null:a[l]=!0}return a})}not(){return g(this,w(t=>!t))}or(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=D(o),a=new Array(r);for(let l=0;l<r;l++){let u=e[l],c=i?o[l]:o;u===!0||c===!0?a[l]=!0:u==null||c==null?a[l]=null:a[l]=!1}return a})}xor(t){return g(this,U(this,t,(e,n)=>!!e!=!!n))}};var Ut=class{constructor(t){this.expr=t}expr;_deriveDate(t){return g(this.expr,w(e=>{let n=X(e);return n?t(n):null}))}_deriveDuration(t){return g(this.expr,w(e=>typeof e=="number"?t(e):null))}century(){return this._deriveDate(on)}date(){return this._deriveDate(t=>new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())))}datetime(){return this._deriveDate(t=>t)}day(){return this._deriveDate(t=>t.getUTCDate())}epoch(t="ms"){return this._deriveDate(e=>sn(e,t))}hour(){return this._deriveDate(t=>t.getUTCHours())}is_leap_year(){return this._deriveDate(hn)}microsecond(){return this._deriveDate(t=>t.getUTCMilliseconds()*vt)}millennium(){return this._deriveDate(ln)}millisecond(){return this._deriveDate(t=>t.getUTCMilliseconds())}minute(){return this._deriveDate(t=>t.getUTCMinutes())}month(){return this._deriveDate(t=>t.getUTCMonth()+1)}month_end(){return this._deriveDate(t=>ue(t,1,0))}month_start(){return this._deriveDate(t=>ue(t,0,1))}nanosecond(){return this._deriveDate(t=>t.getUTCMilliseconds()*Ot)}ordinal_day(){return this._deriveDate(un)}quarter(){return this._deriveDate(cn)}second(){return this._deriveDate(t=>t.getUTCSeconds())}strftime(t,e){return this._deriveDate(n=>fn(n,t,e))}time(){return this._deriveDate(t=>t.toISOString().split("T")[1].slice(0,12))}timestamp(t="ms"){return this.epoch(t)}to_string(t,e){return this.strftime(t,e)}total_days(){return this._deriveDuration(t=>t/dt)}total_hours(){return this._deriveDuration(t=>t/rn)}total_microseconds(){return this._deriveDuration(t=>t*vt)}total_milliseconds(){return this._deriveDuration(t=>t)}total_minutes(){return this._deriveDuration(t=>t/nn)}total_nanoseconds(){return this._deriveDuration(t=>t*Ot)}total_seconds(){return this._deriveDuration(t=>t/le)}week(){return this._deriveDate(an)}weekday(){return this._deriveDate(t=>t.getUTCDay()||7)}year(){return this._deriveDate(t=>t.getUTCFullYear())}},xe=s=>class extends s{get dt(){return new Ut(this)}};var Mt=class{constructor(t){this.expr=t}expr;_deriveList(t){return g(this.expr,w(e=>D(e)?t(e):null))}all(){return this._deriveList(t=>{let e=Array.from(t);for(let n=0;n<e.length;n++)if(!e[n])return!1;return!0})}any(){return this._deriveList(t=>{let e=Array.from(t);for(let n=0;n<e.length;n++)if(e[n])return!0;return!1})}contains(t){return this._deriveList(e=>Array.from(e).includes(t))}contains_all(t){return this._deriveList(e=>{let n=Array.from(e);for(let r=0;r<t.length;r++)if(!n.includes(t[r]))return!1;return!0})}contains_any(t){return this._deriveList(e=>{let n=Array.from(e);for(let r=0;r<t.length;r++)if(n.includes(t[r]))return!0;return!1})}count_matches(t){return this._deriveList(e=>{let n=Array.from(e),r=0;for(let o of n)o===t&&r++;return r})}drop_nulls(){return this._deriveList(t=>{let e=Array.from(t),n=[];for(let r=0;r<e.length;r++)e[r]!=null&&n.push(e[r]);return n})}first(t=!0){return this.get(0,t)}gather(t,e=!0){let n=Array.isArray(t)?t:[t];return this._deriveList(r=>{let o=r.length,i=new Array(n.length);for(let a=0;a<n.length;a++){let l=n[a],u=r.at(l);if(u===void 0&&!e)throw new et(`Index ${l} is out of bounds for list of length ${o}`);i[a]=u??null}return i})}gather_every(t,e=0){if(t<=0)throw new et("Step size n must be positive");return this._deriveList(n=>{let r=n.length,o=[];for(let i=e;i<r;i+=t)o.push(n[i]);return o})}get(t,e=!0){return this._deriveList(n=>{let r=n.at(t);if(r===void 0&&!e)throw new et(`Index ${t} is out of bounds for list of length ${n.length}`);return r??null})}join(t,{ignoreNulls:e=!1}={}){return this._deriveList(n=>{let r=Array.from(n),o=[];for(let i=0;i<r.length;i++){let a=r[i];a!=null?o.push(String(a)):e||o.push("")}return o.join(t)})}last(t=!0){return this.get(-1,t)}len(){return this.lengths()}lengths(){return this._deriveList(t=>t.length)}max(){return this._deriveList(t=>j(t).max)}mean(){return this._deriveList(t=>{let{sum:e,count:n}=j(t);return e!==null&&n>0?e/n:null})}median(){return this._deriveList(t=>{if(!Z(t,"number",{allowNulls:!0}))return null;let e=t.length,n=[];for(let i=0;i<e;i++){let a=t[i];a!=null&&n.push(a)}let r=n.length;if(r===0)return null;n.sort((i,a)=>i-a);let o=Math.floor(r/2);return r%2!==0?n[o]:(n[o-1]+n[o])/2})}min(){return this._deriveList(t=>j(t).min)}mode(){return this._deriveList(t=>{let e=t.length,n=new Map,r=0;for(let i=0;i<e;i++){let a=t[i];if(a==null)continue;let l=(n.get(a)??0)+1;n.set(a,l),l>r&&(r=l)}if(r===0)return[];let o=[];for(let[i,a]of n.entries())a===r&&o.push(i);return ce(o)})}n_unique(){return this._deriveList(t=>new Set(Array.from(t)).size)}reverse(){return this._deriveList(t=>Array.from(t).reverse())}slice(t,e){return this._deriveList(n=>{let r=Array.from(n),o=t<0?Math.max(0,r.length+t):t,i=e!==void 0?o+e:r.length;return r.slice(o,i)})}sort(t=!1){return this._deriveList(e=>ce(e,t))}sum(){return this._deriveList(t=>j(t).sum)}unique(){return this._deriveList(t=>Array.from(new Set(t)))}},be=s=>class extends s{get list(){return new Mt(this)}};var dn=s=>class extends s{fill_null(t){return g(this,(e,n)=>{let r=e.length,o=this._resolve(t,n,r),i=new Array(r);if(D(o))for(let a=0;a<r;a++){let l=e[a];i[a]=l??o[a]}else for(let a=0;a<r;a++){let l=e[a];i[a]=l??o}return i})}reverse(){return g(this,t=>t.slice().reverse())}};var k=class extends be(xe(de(ye(ge(pe(me(fe(dn(bt))))))))){colName;excludedCols=[];constructor(t){super(),this.colName=String(t),this.outputName=this.colName}};function we(s){let t=new k(he);return t.isLiteral=!0,t.literalValue=s,t.ops.push(e=>{let n=e.length,r=new Array(n);for(let o=0;o<n;o++)r[o]=s;return r}),t}function _e(){return new k("*")}function Te(s){let t=new k("*");return t.excludedCols=Array.isArray(s)?s:[s],t}function De(...s){let t=s.length===1&&Array.isArray(s[0])?s[0]:s,e=new k("*coalesce*");return e.ops.push((n,r)=>{let o=n.length,i=c=>c&&typeof c=="object"&&"evaluate"in c?c.evaluate(r,o):typeof c=="string"?r[c]||new Array(o).fill(null):c,a=t.map(i),l=new Array(o),u=a.length;for(let c=0;c<o;c++){let h=null;for(let f=0;f<u;f++){let m=a[f],p=D(m)?m[c]:m;if(p!=null){h=p;break}}l[c]=h}return l}),e}var Ft=class{predicates;values;constructor(t,e){this.predicates=t,this.values=e}then(t){return new _t(this.predicates,this.values.concat(t))}},Nt=class{predicates;constructor(t){this.predicates=[t]}then(t){return new _t(this.predicates,[t])}},_t=class s extends k{predicates;values;otherwiseValue;constructor(t,e,n=null){super(typeof t=="string"?t:"*when*"),this.predicates=Array.isArray(t)?t:[],this.values=e||[],this.otherwiseValue=n,this.ops.push((r,o)=>{let i=r.length,a=m=>m&&typeof m=="object"&&"evaluate"in m?m.evaluate(o,i):typeof m=="string"&&m in o?o[m]:m,l=this.predicates.map(a),u=this.values.map(a),c=a(this.otherwiseValue),h=new Array(i),f=l.length;for(let m=0;m<i;m++){let p=!1;for(let y=0;y<f;y++)if((D(l[y])?l[y][m]:l[y])===!0){h[m]=D(u[y])?u[y][m]:u[y],p=!0;break}p||(h[m]=D(c)?c[m]:c)}return h})}when(t){return new Ft(this.predicates.concat(t),this.values)}otherwise(t){return new s(this.predicates,this.values,t)}};function Ae(s){return new Nt(s)}function ft(s,t,e){let n=[],r=e?new Set(e):new Set;for(let o of s)if(typeof o=="string")n.push(new k(o));else if(o instanceof k&&o.colName==="*"){let i=new Set(o.excludedCols);for(let a of t)if(!r.has(a)&&!i.has(a)){let l=new k(a);l.ops=[...o.ops],l.aggFn=o.aggFn,l.partitionOpsIndex=o.partitionOpsIndex,l.groupingOpsIndex=o.groupingOpsIndex,l.partitionBy=o.partitionBy,o.evaluateWindow&&(l.evaluateWindow=o.evaluateWindow),o.outputName&&o.outputName!=="*"&&(l.outputName=o.outputName),n.push(l)}}else if(o&&typeof o=="object"&&"evaluate"in o&&!o.colName){for(let i of t)if(!r.has(i)){let a=new k(i);a.ops=[...o.ops],a.aggFn=o.aggFn,a.groupingOpsIndex=o.groupingOpsIndex,a.partitionOpsIndex=o.partitionOpsIndex,n.push(a)}}else n.push(o);return n}var z=class{get isNumeric(){return!1}get isInteger(){return!1}get isFloat(){return!1}get isSigned(){return!1}get isUnsigned(){return!1}get isTemporal(){return!1}get isNested(){return!1}get isBoolean(){return!1}get isString(){return!1}get isUtf8(){return!1}get isObject(){return!1}get isNull(){return!1}get isBinary(){return!1}},lt=class extends z{get isNumeric(){return!0}},Tt=class extends lt{get isInteger(){return!0}},ot=class extends Tt{get isSigned(){return!0}},it=class extends Tt{get isUnsigned(){return!0}},mt=class extends lt{get isFloat(){return!0}},at=class extends z{get isTemporal(){return!0}},pt=class extends z{get isNested(){return!0}};var Lt=class extends ot{name="Int8";coerce(t){return tt(t,"Int8")}equals(t){return t.name==="Int8"}allocate(t){return new Int8Array(t)}},Ce=new Lt,jt=class extends ot{name="Int16";coerce(t){return tt(t,"Int16")}equals(t){return t.name==="Int16"}allocate(t){return new Int16Array(t)}},Ie=new jt,Bt=class extends ot{name="Int32";coerce(t){return tt(t,"Int32")}equals(t){return t.name==="Int32"}allocate(t){return new Int32Array(t)}},Se=new Bt,Vt=class extends ot{name="Int64";coerce(t){return ae(t)}equals(t){return t.name==="Int64"}allocate(t){return new BigInt64Array(t)}},ke=new Vt,Kt=class extends it{name="UInt8";coerce(t){return tt(t,"UInt8")}equals(t){return t.name==="UInt8"}allocate(t){return new Uint8Array(t)}},Ee=new Kt,$t=class extends it{name="UInt16";coerce(t){return tt(t,"UInt16")}equals(t){return t.name==="UInt16"}allocate(t){return new Uint16Array(t)}},ve=new $t,Pt=class extends it{name="UInt32";coerce(t){return tt(t,"UInt32")}equals(t){return t.name==="UInt32"}allocate(t){return new Uint32Array(t)}},Oe=new Pt,Wt=class extends it{name="UInt64";coerce(t){return ae(t,"UInt64")}equals(t){return t.name==="UInt64"}allocate(t){return new BigUint64Array(t)}},Re=new Wt,qt=class extends mt{name="Float32";coerce(t){return ie(t,"Float32")}equals(t){return t.name==="Float32"}allocate(t){return new Float32Array(t)}},Ue=new qt,Ht=class extends mt{name="Float64";coerce(t){return ie(t,"Float64")}equals(t){return t.name==="Float64"}allocate(t){return new Float64Array(t)}},Me=new Ht,Dt=class s extends lt{constructor(e,n){super();this.precision=e;this.scale=n;this.name=e!==void 0&&n!==void 0?`Decimal(${e}, ${n})`:"Decimal"}precision;scale;name;coerce(e){return St(e,{precision:this.precision,scale:this.scale})}equals(e){return e instanceof s&&this.precision===e.precision&&this.scale===e.scale}allocate(e){return new Array(e).fill(null)}},Gt=class extends z{name="Boolean";get isBoolean(){return!0}coerce(t){return t==null?null:!!t}equals(t){return t.name==="Boolean"}allocate(t){return new Array(t).fill(null)}},Fe=new Gt,zt=class extends z{name="Utf8";get isString(){return!0}get isUtf8(){return!0}coerce(t){return t==null?null:String(t)}equals(t){return t.name==="Utf8"}allocate(t){return new Array(t).fill(null)}},Ne=new zt,Yt=class extends z{name="Binary";get isBinary(){return!0}coerce(t){return gn(t)}equals(t){return t.name==="Binary"}allocate(t){return new Array(t).fill(null)}},Le=new Yt,Zt=class extends z{name="Null";get isNull(){return!0}coerce(t){return null}equals(t){return t.name==="Null"}allocate(t){return new Array(t).fill(null)}},je=new Zt,Xt=class extends z{name="Object";get isObject(){return!0}coerce(t){return t===void 0?null:t}equals(t){return t.name==="Object"}allocate(t){return new Array(t).fill(null)}},Be=new Xt,Jt=class extends at{name="Date";coerce(t){let e=X(t);return e?(e.setUTCHours(0,0,0,0),e):null}equals(t){return t.name==="Date"}allocate(t){return new Array(t).fill(null)}},Ve=new Jt,Qt=class extends at{name="Datetime";coerce(t){return X(t)}equals(t){return t.name==="Datetime"}allocate(t){return new Array(t).fill(null)}},Ke=new Qt,te=class extends at{name="Time";coerce(t){if(t==null)return null;if(typeof t=="string"){let n=t.trim();if(kt.test(n)){let r=new globalThis.Date(`1970-01-01T${n}${Et.test(n)?"":"Z"}`);if(G(r))return r.toISOString().split("T")[1].slice(0,12)}}let e=X(t);return e?e.toISOString().split("T")[1].slice(0,12):null}equals(t){return t.name==="Time"}allocate(t){return new Array(t).fill(null)}},$e=new te,ee=class extends at{name="Duration";coerce(t){return Q(t)}equals(t){return t.name==="Duration"}allocate(t){return new Array(t).fill(null)}},Pe=new ee,ne=class s extends pt{constructor(e){super();this.innerType=e}innerType;name="List";coerce(e){if(e==null)return null;let n=D(e)?Array.from(e):[e],r=n.length,o=new Array(r);for(let i=0;i<r;i++)o[i]=this.innerType.coerce(n[i]);return o}equals(e){return e instanceof s&&this.innerType.equals(e.innerType)}allocate(e){return new Array(e).fill(null)}},We=s=>new ne(s),re=class s extends pt{constructor(e){super();this.fields=e}fields;name="Struct";coerce(e){if(!Y(e))return null;let n={};for(let[r,o]of globalThis.Object.entries(this.fields))n[r]=o.coerce(e[r]);return n}equals(e){if(!(e instanceof s))return!1;let n=globalThis.Object.keys(this.fields),r=globalThis.Object.keys(e.fields);if(n.length!==r.length)return!1;for(let o of n)if(!e.fields[o]||!this.fields[o].equals(e.fields[o]))return!1;return!0}allocate(e){return new Array(e).fill(null)}},qe=s=>new re(s);var L={Int8:Ce,Int16:Ie,Int32:Se,Int64:ke,UInt8:Ee,UInt16:ve,UInt32:Oe,UInt64:Re,Float32:Ue,Float64:Me,Decimal:(s,t)=>new Dt(s,t),Boolean:Fe,Utf8:Ne,Binary:Le,Date:Ve,Datetime:Ke,Time:$e,Duration:Pe,Object:Be,Null:je,List:We,Struct:qe};function En(s,t,e){let n=new Map,r=e.length,o=new Array(r);for(let i=0;i<r;i++){let a=e[i];typeof a=="string"?(W(a,s,"Partition key"," in the DataFrame."),o[i]=s[a]):o[i]=a.evaluate(s,t)}for(let i=0;i<t;i++){let a=new Array(o.length);for(let c=0;c<o.length;c++){let h=o[c][i];a[c]=h==null?"":String(h)}let l=a.join("\0"),u=n.get(l);u===void 0&&(u=[],n.set(l,u)),u.push(i)}return n}function se(s,t,e){let n=new Array(e);if(e===0)return n;let r=s.partitionBy||[],o=En(t,e,r),i=s.evaluatePrePartition(t,e);for(let a of o.values()){let l=a.length,u=new Array(l);for(let c=0;c<l;c++)u[c]=i[a[c]];if(s.evaluateWindow){for(let c=0;c<l;c++)n[a[c]]=s.evaluateWindow(u,a,c);continue}if(s.aggFn){let c=s.aggFn(u);for(let h=0;h<l;h++)n[a[h]]=c;continue}for(let c=0;c<l;c++)n[a[c]]=i[a[c]]}return s.evaluatePostPartition(n,t)}function He(s){if(!Array.isArray(s)||s.length===0)return{columns:{},height:0};let t=s.length,e=new Set;for(let o=0;o<t;o++){let i=s[o];if(Y(i)){let a=Object.keys(i);for(let l=0;l<a.length;l++)e.add(a[l])}}let n=Array.from(e),r={};for(let o=0;o<n.length;o++)r[n[o]]=new Array(t);for(let o=0;o<t;o++){let i=s[o]||{};for(let a=0;a<n.length;a++){let l=n[a],u=i[l];r[l][o]=u===void 0?null:u}}return{columns:r,height:t}}function Ge(s,t){let e=Object.keys(s),n=new Array(t);for(let r=0;r<t;r++){let o={};for(let i=0;i<e.length;i++){let a=e[i],l=s[a][r];o[a]=l===void 0?null:l}n[r]=o}return n}function vn(s,t,e){let n={};for(let r=0;r<e.length;r++){let o=e[r],i=s[o][t];n[o]=i===void 0?null:i}return n}function nt(s){if(s.length===0)return L.Utf8;let t=!0,e=!0,n=!0,r=!0,o=!0,i=!0,a=!1,l=!1,u=[];for(let c=0;c<s.length;c++){let h=s[c];if(h!=null){if(l=!0,!Array.isArray(h))i=!1;else for(let f=0;f<h.length;f++)u.push(h[f]);h instanceof Date&&(a=!0),typeof h!="boolean"&&(t=!1),typeof h!="bigint"&&(r=!1),typeof h!="number"?(n=!1,e=!1):Number.isInteger(h)||(e=!1),!(h instanceof Date)&&(typeof h!="string"||isNaN(Date.parse(h)))&&(o=!1)}}if(!l)return L.Utf8;if(i){let c=nt(u);return L.List(c)}if(t)return L.Boolean;if(r)return L.Int64;if(n&&!e)return L.Float64;if(n&&e){let c=!0;for(let h=0;h<s.length;h++){let f=s[h];if(f!=null&&(f<-2147483648||f>2147483647)){c=!1;break}}return c?L.Int32:L.Float64}return o&&a?L.Datetime:L.Utf8}function At(s,t){let e=Object.keys(s),n=e.length,r=t.length,o={};for(let i=0;i<n;i++){let a=e[i],l=s[a],u=new Array(r);for(let c=0;c<r;c++)u[c]=l[t[c]];o[a]=u}return o}var Ct=class{groups;keys;allKeys;parentColumns;parentHeight;parentSchema;constructor(t,e,n,r,o,i){this.groups=t,this.keys=e,this.allKeys=n,this.parentColumns=r,this.parentHeight=o,this.parentSchema=i}to_dataframe(){let t=this.keys.length,e=new Array(t);for(let a=0;a<t;a++)e[a]=String(this.keys[a]);let n=this.groups.size,r={};for(let a=0;a<e.length;a++)r[e[a]]=new Array(n);let o=0;for(let a of this.groups.values()){if(a.length===0)continue;let l=a[0];for(let u=0;u<e.length;u++){let c=e[u],h=this.parentColumns[c][l];r[c][o]=h===void 0?null:h}o++}let i={};for(let a of e)i[a]=this.parentSchema[a];return new F(r,i,o)}agg(...t){let e=this.allKeys.length,n=new Array(e);for(let h=0;h<e;h++)n[h]=String(this.allKeys[h]);let r=this.keys.length,o=new Array(r);for(let h=0;h<r;h++)o[h]=String(this.keys[h]);let i=ft(t.flat(),n,o),a=this.groups.size,l={};for(let h=0;h<o.length;h++)l[o[h]]=new Array(a);let u=0;for(let h of this.groups.values()){if(h.length===0)continue;let f=h[0];for(let m=0;m<o.length;m++){let p=o[m],y=this.parentColumns[p][f];l[p][u]=y===void 0?null:y}u++}for(let h=0;h<i.length;h++){let f=i[h],m=f.outputName||f.colName||"*";if(!f.aggFn){l[m]=f.evaluate(l,a);continue}let p=f.evaluatePreGrouping(this.parentColumns,this.parentHeight),y=new Array(a),x=0;for(let b of this.groups.values()){if(b.length===0)continue;let T=new Array(b.length);for(let A=0;A<b.length;A++)T[A]=p[b[A]];y[x]=f.aggFn(T),x++}l[m]=f.evaluatePostGrouping(y,l)}let c={};for(let h of o)c[h]=this.parentSchema[h];for(let h of i){let f=h.outputName||h.colName||"*";c[f]=nt(l[f])}return new F(l,c,u)}};function xn(s,t,e){if(s==null)throw new V(`Invalid input to ${t} at index ${e}: item cannot be null or undefined.`);if(s instanceof F)return[s];if(xt(s))return[new F(s)];if(D(s)){if(Z(s,F,{mode:"every"}))return s;if(Z(s,"plainObject",{mode:"every"}))return[new F(s)];let n=Z(s,F,{mode:"some"});for(let r=0;r<s.length;r++)if(n?!(s[r]instanceof F):!xt(s[r]))throw new V(n?`Invalid input to ${t} at index ${e}, sub-index ${r}: nested array must contain only DataFrame instances.`:`Invalid input to ${t} at index ${e}, row ${r}: rows must be plain objects.`)}throw new V(`Invalid input to ${t} at index ${e}: expected DataFrame, row array, or column dictionary.`)}function It(s,t={}){if(s==null)throw new V("Invalid input to concat: rawItems cannot be null or undefined.");let e=Array.isArray(s)?s:[s],n=[];for(let i=0;i<e.length;i++)n.push(...xn(e[i],"concat",i));let{how:r="vertical"}=t,o=t.horizontal?.strict??!0;if(n.length===0)return new F({},{},0);if(n.length===1&&r!=="horizontal")return n[0];switch(r){case"vertical":{let i=[];for(let m=0;m<n.length;m++)n[m].height>0&&i.push(n[m]);if(i.length===0)return new F({},{},0);let a=i[0],l=Object.keys(a._columns);for(let m=0;m<n.length;m++){let p=n[m];if(p.height===0)continue;let y=Object.keys(p._columns);if(l.length!==y.length)throw new V(`[Strict Vertical] Column count mismatch at index ${m}.`);for(let x=0;x<l.length;x++){if(l[x]!==y[x])throw new V(`[Strict Vertical] Schema mismatch at position ${x} in DF ${m}. Expected column "${l[x]}", but found "${y[x]}".`);let b=a.schema[l[x]],T=p.schema[l[x]];if(b&&T&&!b.equals(T))throw new ht(`[Strict Type Check] Schema type mismatch for column "${l[x]}": expected ${b.name}, found ${T.name}.`)}}let u=0;for(let m of n)u+=m.height;let c=n.find(m=>m.height>0)?.schema||n[0]?.schema||{},h={};for(let m of l){let p=c[m],y=!1;for(let b of n){let T=b._columns[m];if(!T){y=!0;break}if(!$(T)){for(let A=0;A<T.length;A++)if(T[A]==null){y=!0;break}}if(y)break}let x=p&&p.allocate?p.allocate(u):new Array(u).fill(null);y&&$(x)&&(x=new Array(u).fill(null)),h[m]=x}let f=0;for(let m of n){let p=m.height;if(p!==0){for(let y of l){let x=m._columns[y]||new Array(p).fill(null),b=h[y];if($(b)&&$(x))b.set(x,f);else{let T=b;for(let A=0;A<p;A++)T[f+A]=x[A]}}f+=p}}return new F(h,c,u)}case"horizontal":{let i=n[0].height;for(let c=1;c<n.length;c++)n[c].height>i&&(i=n[c].height);let a=new Set;for(let c=0;c<n.length;c++){let h=n[c];if(o&&h.height!==i)throw new V(`[Horizontal] Row count mismatch at index ${c}. Expected ${i}, got ${h.height}. Set strict=false to allow padding.`);for(let f of Object.keys(h._columns)){if(a.has(f))throw new V(`[Horizontal] Duplicate column name "${f}" detected. Horizontal concat requires unique names.`);a.add(f)}}let l={},u={};for(let c of n){let h=c.height;Object.assign(u,c.schema);for(let[f,m]of Object.entries(c._columns))if(h===i)l[f]=$(m)?Array.from(m):m;else{let p=new Array(i);for(let y=0;y<h;y++)p[y]=m[y];for(let y=h;y<i;y++)p[y]=null;l[f]=p}}return new F(l,u,i)}case"diagonal":{let i=new Set;for(let f of n)for(let m of Object.keys(f._columns))i.add(m);let a=Array.from(i),l=0;for(let f=0;f<n.length;f++)l+=n[f].height;let u={};for(let f of a){let m=null;for(let p of n){let y=p.schema[f];if(y){if(m===null)m=y;else if(!m.equals(y))throw new ht(`[Strict Type Check] Schema type mismatch for column "${f}": expected ${m.name}, found ${y.name}.`)}}u[f]=m||L.Utf8}let c={};for(let f=0;f<a.length;f++)c[a[f]]=new Array(l).fill(null);let h=0;for(let f=0;f<n.length;f++){let m=n[f],p=m.height;if(p!==0){for(let y=0;y<a.length;y++){let x=a[y],b=c[x],T=m._columns[x];if(T!==void 0)if($(T)&&$(b))b.set(T,h);else{let A=b;for(let S=0;S<p;S++)A[h+S]=T[S]}else{let A=b;for(let S=0;S<p;S++)A[h+S]=null}}h+=p}}return new F(c,u,l)}}}var F=class s{_columns;_height;_schema={};constructor(t,e,n){if(Array.isArray(t)){let{columns:r,height:o}=He(t);this._columns=r,this._height=o,e?this.applySchema(e):this.inferSchema();return}if(Y(t)){let r=-1;for(let[o,i]of Object.entries(t)){let a=D(i)?i.length:0;if(r===-1)r=a;else if(a!==r)throw new V(`Column height mismatch: Column "${o}" has length ${a}, but previous columns have length ${r}`)}this._columns=t,this._height=n!==void 0?n:r===-1?0:r,e?this.applySchema(e):this.inferSchema();return}this._columns={},this._height=0,e?this.applySchema(e):this._schema={}}inferSchema(){let t={},e=Object.keys(this._columns);for(let n of e)t[n]=nt(this._columns[n]);this._schema=t}applySchema(t){this._schema=t;let e=Object.keys(t),n={};for(let r of e){let o=t[r],i=this._columns[r],a=o.allocate?o.allocate(this._height):new Array(this._height).fill(null);if(!i){this._height>0&&$(a)&&(a=new Array(this._height).fill(null)),n[r]=a;continue}let l=!1,u=new Array(this._height);for(let c=0;c<this._height;c++){let h=o.coerce(i[c]);u[c]=h,h==null&&(l=!0)}l&&$(a)&&(a=new Array(this._height));for(let c=0;c<this._height;c++)a[c]=u[c];n[r]=a}this._columns=n}getSchema(){return this._schema}to_dicts(){return Ge(this._columns,this._height)}to_dict(){return{...this._columns}}get columns(){return Object.keys(this._columns)}concat(t,e={}){let n=Z(t,s,{mode:"every",allowEmpty:!1})?t:[t];return It([this,...n],e)}drop(...t){let e=new Set(t.flat()),n={},r={};for(let o of Object.keys(this._columns))e.has(o)||(n[o]=this._columns[o],r[o]=this._schema[o]);return new s(n,r,this._height)}get dtypes(){let t=Object.keys(this._columns),e=t.length,n=new Array(e);for(let r=0;r<e;r++)n[r]=this._schema[t[r]];return n}filter(...t){if(this._height===0)return new s({},this._schema,0);let e=this._height,n=Object.keys(this._columns),r=n.length,o=[],i=[];for(let f of t)typeof f=="function"?i.push(f):o.push(f.evaluate(this._columns,e));let a=[],l=0,u=null;if(i.length>0){let f=this._columns;u={};for(let m=0;m<r;m++){let p=n[m],y=f[p];Object.defineProperty(u,p,{get(){let x=y[l];return x===void 0?null:x},enumerable:!0,configurable:!0})}}for(let f=0;f<e;f++){let m=!0;for(let p=0;p<o.length;p++)if(!o[p][f]){m=!1;break}if(m){if(u){l=f;for(let p=0;p<i.length;p++)if(!i[p](u)){m=!1;break}}m&&a.push(f)}}let c=At(this._columns,a),h=a.length;return new s(c,this._schema,h)}groupby(t){let e=st(t),n=new Map,r=this._height,o=e.length,i=new Array(o);for(let c=0;c<o;c++)i[c]=String(e[c]);for(let c=0;c<i.length;c++)W(i[c],this._columns,"Grouping key");let a=o===1?i[0]:null,l=a?this._columns[a]:null;for(let c=0;c<r;c++){let h;if(a){let m=l[c];h=m==null?"":String(m)}else{let m=new Array(o);for(let p=0;p<o;p++){let y=this._columns[i[p]][c];m[p]=y==null?"":String(y)}h=m.join("\0")}let f=n.get(h);f===void 0&&n.set(h,f=[]),f.push(c)}let u=Object.keys(this._columns);return new Ct(n,e,u,this._columns,this._height,this._schema)}head(t=10){return this.limit(t,{offset:0,from:"start"})}get height(){return this._height}hstack(t,e={}){return this.concat(t,{how:"horizontal",horizontal:e})}join(t){let{other:e,on:n,how:r="inner",suffixes:o=["","_right"]}=t,i=st(n);for(let _ of i){let C=String(_);W(C,this._columns,"Join key"," in the left DataFrame."),W(C,e._columns,"Join key"," in the right DataFrame.")}let[a,l]=o,u=Object.keys(this._columns),c=Object.keys(e._columns),h=new Set(i),f=u.length,m=c.length,p=(_,C)=>{let v=i.length;if(v===1){let O=_[i[0]][C];return O==null?null:String(O)}let M=new Array(v);for(let O=0;O<v;O++){let q=_[i[O]][C];if(q==null)return null;M[O]=String(q)}return M.join("\0")},y=new Map,x=e._height,b=e._columns;for(let _=0;_<x;_++){let C=p(b,_);if(C===null)continue;let v=y.get(C);v===void 0&&(v=[],y.set(C,v)),v.push(_)}let T=this._height,A=this._columns,S=[],d=[],I=r==="outer"||r==="right",R=I?new Set:null;for(let _=0;_<T;_++){let C=p(A,_),v=C===null?void 0:y.get(C);if(v===void 0)(r==="left"||r==="outer")&&(S.push(_),d.push(null));else for(let M=0;M<v.length;M++){let O=v[M];I&&R.add(O),S.push(_),d.push(O)}}if(I)for(let _=0;_<x;_++)R.has(_)||(S.push(-1),d.push(_));let E=S.length,N={},K={};for(let _=0;_<f;_++){let C=u[_],v=C in e._columns&&!h.has(C)?`${C}${a}`:C,M=this._columns[C],O=h.has(C),q=new Array(E);if(O){let H=e._columns[C];for(let J=0;J<E;J++){let ze=S[J];if(ze!==-1)q[J]=M[ze];else{let Ye=d[J];q[J]=Ye!==null?H[Ye]:null}}}else for(let H=0;H<E;H++){let J=S[H];q[H]=J!==-1?M[J]:null}N[v]=q,this._schema[C]&&(K[v]=this._schema[C])}for(let _=0;_<m;_++){let C=c[_];if(!h.has(C)){let v=C in this._columns?`${C}${l}`:C,M=e._columns[C],O=new Array(E);for(let q=0;q<E;q++){let H=d[q];O[q]=H!==null?M[H]:null}N[v]=O,e._schema[C]&&(K[v]=e._schema[C])}}return new s(N,K,E)}limit(t,e={}){let{offset:n=0,from:r="start"}=e,o=this._height,i=isNaN(t)?0:Math.max(Math.floor(t),0),a=isNaN(n)?0:Math.max(Math.floor(n),0);if(i===0||o===0||a>=o){let f={},m={};for(let p of Object.keys(this._columns))f[p]=[],m[p]=this._schema[p];return new s(f,m,0)}let l=0,u=0;r==="end"?(u=Math.max(o-a,0),l=Math.max(u-i,0)):(u=Math.min(a+i,o),l=a);let c=Math.max(u-l,0),h={};for(let f of Object.keys(this._columns))h[f]=this._columns[f].slice(l,u);return new s(h,this._schema,c)}pivot(t){if(this._height===0)return new s({},{},0);let{index:e,columns:n,values:r}=t,o=st(e),i=o.length,a=new Array(i);for(let d=0;d<i;d++)a[d]=String(o[d]);let l=String(n),u=String(r);for(let d of a)W(d,this._columns,"Pivot index key"," in the DataFrame.");W(l,this._columns,"Pivot column key"),W(u,this._columns,"Pivot values key"," in the DataFrame.");let c=new Map,h=new Set,f=this._height,m=this._columns[l],p=this._columns[u];for(let d=0;d<f;d++){let I=new Array(i);for(let K=0;K<i;K++){let _=this._columns[a[K]][d];I[K]=_==null?"":String(_)}let R=I.join("\0"),E=String(m[d]);h.add(E);let N=c.get(R);N===void 0&&(N={firstIdx:d,indices:[]},c.set(R,N)),N.indices.push(d)}let y=c.size,x={},b={};for(let d=0;d<i;d++){let I=a[d];x[I]=new Array(y),this._schema[I]&&(b[I]=this._schema[I])}let T=Array.from(h),A=this._schema[u]||L.Utf8;for(let d=0;d<T.length;d++){let I=T[d];x[I]=new Array(y).fill(null),b[I]=A}let S=0;for(let d of c.values()){let I=d.firstIdx;for(let E=0;E<i;E++){let N=a[E];x[N][S]=this._columns[N][I]}let R=d.indices;for(let E=0;E<R.length;E++){let N=R[E],K=String(m[N]);x[K][S]=p[N]}S++}return new s(x,b,y)}rename(t){let e=t||{},n={},r={},o=Object.keys(this._columns);for(let a of o){let l=e[a]||a;n[l]=this._columns[a],r[l]=this._schema[a]}if(Object.keys(n).length<o.length)throw new V("Rename collision: Multiple columns mapped to the same output name.");return new s(n,r,this._height)}reverse(){if(this._height===0)return this;let t={},e=Object.keys(this._columns),n=e.length;for(let r=0;r<n;r++){let o=e[r];t[o]=this._columns[o].slice().reverse()}return new s(t,this._schema,this._height)}get schema(){return this._schema}select(...t){let e=this._normalizeArgs(t),n=Object.keys(this._columns),r=ft(e,n),o={},i={};for(let a of r){let l=a.outputName||a.colName||"*";if(l in o)throw new V(`Duplicate column selection: "${l}" is selected multiple times.`);o[l]=a.isWindow?se(a,this._columns,this._height):a.evaluate(this._columns,this._height);let u=a.colName||l,c=a instanceof k&&a.ops.length===0&&!a.isWindow&&!a.aggFn;i[l]=c&&this._schema[u]?this._schema[u]:nt(o[l])}return new s(o,i,this._height)}get shape(){return[this.height,this.width]}slice(t,e){let n=this._height,r=t<0?Math.max(n+t,0):Math.min(t,n),o=e===void 0?n:e<0?Math.max(n+e,0):Math.min(e,n),i=Math.max(o-r,0);return this.limit(i,{offset:r})}sort(t){if(!t||!t.by||this._height===0)return this;let{by:e,descending:n=!1,nullsLast:r=!0,custom:o}=t,i=st(e);for(let p=0;p<i.length;p++){let y=i[p];typeof y=="string"&&W(y,this._columns,"Sort key")}let a=Array.isArray(n)?n:new Array(i.length).fill(n),l=i.length,u=new Array(l);for(let p=0;p<l;p++){let y=i[p],x=a[p]?-1:1,b=o&&typeof y=="string"?o[y]:null,T=y?.evaluate?y.evaluate(this._columns,this._height):this._columns[y]||new Array(this._height).fill(null);u[p]={values:T,isDesc:x,customComp:b}}let c=u.length,h=r?1:-1,f=new Array(this._height);for(let p=0;p<this._height;p++)f[p]=p;f.sort((p,y)=>{for(let x=0;x<c;x++){let{values:b,isDesc:T,customComp:A}=u[x],S=b[p],d=b[y];if(A){let R=A(S,d);if(R!==0)return R*T;continue}if(S==null||d==null){if(S===d)continue;return(S==null?1:-1)*h}if(S===d)continue;return(S<d?-1:1)*T}return 0});let m=At(this._columns,f);return new s(m,this._schema,this._height)}tail(t=10){return this.limit(t,{offset:0,from:"end"})}to_list(t){if(this._height===0)return[];let e=t&&typeof t!="string"&&"evaluate"in t,n;if(e)n=t.evaluate(this._columns,this._height);else{let r=t;if(r==null)return new Array(this._height).fill(null);W(r,this._columns,"Column"),n=this._columns[r]}return Array.isArray(n)?n:Array.from(n)}unique(t){if(this._height===0)return new s({},this._schema,0);let e=st(t),n=e.length===0?Object.keys(this._columns):e.map(String);for(let h of n)W(h,this._columns,"Unique column key");let r=new Set,o=[],i=n.length,a=this._height,l=i===1?this._columns[n[0]]:null;for(let h=0;h<a;h++){let f;if(l){let m=l[h];f=m==null?"":String(m)}else{let m=new Array(i);for(let p=0;p<i;p++){let y=this._columns[n[p]][h];m[p]=y==null?"":String(y)}f=m.join("\0")}r.has(f)||(r.add(f),o.push(h))}let u=At(this._columns,o),c=o.length;return new s(u,this._schema,c)}unpivot(t){let{idVars:e,valueVars:n,varName:r="variable",valueName:o="value"}=t,i=st(e).map(String),a=st(n).map(String),l=i.length,u=a.length;for(let p of i)W(p,this._columns,"Unpivot id variable key");for(let p of a)W(p,this._columns,"Unpivot value variable key");let c=this._height*u,h={};for(let p=0;p<l;p++)h[i[p]]=new Array(c);h[r]=new Array(c),h[o]=new Array(c);let f=0;for(let p=0;p<this._height;p++)for(let y=0;y<u;y++){let x=a[y];for(let b=0;b<l;b++){let T=i[b];h[T][f]=this._columns[T][p]}h[r][f]=x,h[o][f]=this._columns[x][p],f++}let m={};for(let p of i)m[p]=this._schema[p];return m[r]=L.Utf8,m[o]=nt(h[o]),new s(h,m,c)}vstack(t){return this.concat(t,{how:"vertical"})}get width(){return Object.keys(this._columns).length}_normalizeArgs(t){let e=t.flat(),n=[];for(let r of e)if(typeof r=="string")n.push(new k(r));else if(Y(r)&&"evaluate"in r)n.push(r);else if(Y(r))for(let[o,i]of Object.entries(r))if(Y(i)&&"evaluate"in i)n.push(i.alias(o));else{let a=new k(o);a.evaluate=(l,u)=>new Array(u).fill(i),n.push(a)}return n}with_columns(...t){let e=this._normalizeArgs(t),n=Object.keys(this._columns),r=ft(e,n),o=r.length,i={...this._columns},a={...this._schema};for(let l=0;l<o;l++){let u=r[l],c=u.outputName||u.colName||"*";u.isWindow?i[c]=se(u,this._columns,this._height):i[c]=u.evaluate(this._columns,this._height);let h=u.colName||c;u instanceof k&&u.ops.length===0&&!u.isWindow&&!u.aggFn&&this._schema[h]?a[c]=this._schema[h]:a[c]=nt(i[c])}return new s(i,a,this._height)}};var On={data:(s,t)=>new F(s,t),col:s=>new k(s),all:_e,exclude:Te,coalesce:De,concat:It,lit:we,when:Ae,DataType:L};0&&(module.exports={$tbl,ALL_COLUMNS_MARKER,AggregationExpr,ArithmeticExpr,Binary,BinaryType,Boolean,BooleanType,ColumnExpr,ColumnNotFoundError,ComparisonExpr,ComputeError,DFScriptError,DataFrame,DataFrameError,DataType,DataTypeRegistry,Date,DateTimeExprNamespace,DateType,Datetime,DatetimeType,DecimalType,Duration,DurationType,ExprBase,Float32,Float32Type,Float64,Float64Type,FloatDataType,GroupedData,Int16,Int16Type,Int32,Int32Type,Int64,Int64Type,Int8,Int8Type,IntegerDataType,LITERAL_MARKER,List,ListExpr,ListExprNamespace,ListType,LogicalExpr,NestedDataType,Null,NullType,NumericDataType,Object,ObjectType,SchemaError,SignedIntegerType,StringExpr,StringExprNamespace,Struct,StructType,TemporalDataType,TemporalExpr,Time,TimeType,UInt16,UInt16Type,UInt32,UInt32Type,UInt64,UInt64Type,UInt8,UInt8Type,UnsignedIntegerType,Utf8,Utf8Type,When,WhenThen,WhenThenChain,WindowExpr,all,assertColumnExists,coalesce,columnsToRows,concat,derive,exclude,gatherColumnsByIndices,getRowFromColumns,inferColumnType,kleeneBinary,kleeneUnary,lit,normalizeToDataFrames,resolveColumnSelectors,resolveWindowExpr,rowsToColumns,when});
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { DataFrame } from "./dataframe/dataframe";
|
|
2
|
+
export type RowRecord = Record<string, any>;
|
|
3
|
+
export type ColumnData<T = any> = ArrayLike<T> & Iterable<T>;
|
|
4
|
+
export type ColumnDict = Record<string, ColumnData>;
|
|
5
|
+
export type DataFrameColumns<T extends RowRecord> = {
|
|
6
|
+
[K in keyof T]: ColumnData<T[K]>;
|
|
7
|
+
};
|
|
8
|
+
export type Scalar = string | number | boolean | bigint | Date | null | undefined;
|
|
9
|
+
export type AggFn<V, R = any> = (values: V[]) => R;
|
|
10
|
+
export type OpFn = (vals: ColumnData, columns: ColumnDict) => ColumnData;
|
|
11
|
+
export interface IExpr {
|
|
12
|
+
ops: OpFn[];
|
|
13
|
+
colName?: string;
|
|
14
|
+
outputName?: string;
|
|
15
|
+
isLiteral?: boolean;
|
|
16
|
+
literalValue?: any;
|
|
17
|
+
aggFn?: AggFn<any> | null;
|
|
18
|
+
groupingOpsIndex?: number;
|
|
19
|
+
partitionOpsIndex?: number;
|
|
20
|
+
partitionBy?: (string | IExpr)[] | null;
|
|
21
|
+
windowOp?: {
|
|
22
|
+
type: string;
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
} | null;
|
|
25
|
+
isWindow?: boolean;
|
|
26
|
+
alias(name: string): this;
|
|
27
|
+
cast(dataType: any): this;
|
|
28
|
+
_resolve(val: any, columns: ColumnDict, height: number): ColumnData | any;
|
|
29
|
+
evaluate(columns: ColumnDict, height: number): ColumnData;
|
|
30
|
+
evaluatePreGrouping(columns: ColumnDict, height: number): ColumnData;
|
|
31
|
+
evaluatePostGrouping(aggregatedArray: any[], columns: ColumnDict): ColumnData;
|
|
32
|
+
evaluatePrePartition(columns: ColumnDict, height: number): ColumnData;
|
|
33
|
+
evaluatePostPartition(aggregatedArray: any[], columns: ColumnDict): ColumnData;
|
|
34
|
+
evaluateWindow?(groupPreValues: any[], partitionIndices: number[], currentIndex: number): any;
|
|
35
|
+
debug(label?: string): this;
|
|
36
|
+
}
|
|
37
|
+
export type TimeUnit = "s" | "ms" | "us" | "ns";
|
|
38
|
+
/** Concatenation Configuration */
|
|
39
|
+
export type ConcatHow = "vertical" | "horizontal" | "diagonal";
|
|
40
|
+
export interface HorizontalConcatOptions {
|
|
41
|
+
strict?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface ConcatOptions {
|
|
44
|
+
how?: ConcatHow;
|
|
45
|
+
horizontal?: HorizontalConcatOptions;
|
|
46
|
+
}
|
|
47
|
+
export type ConcatItem = DataFrame<any> | ColumnDict | RowRecord[];
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function tryParseBoolean(v: unknown): boolean | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tryParseBoolean = tryParseBoolean;
|
|
4
|
+
const boolMap = {
|
|
5
|
+
true: true, "1": true, yes: true, y: true, on: true,
|
|
6
|
+
false: false, "0": false, no: false, n: false, off: false
|
|
7
|
+
};
|
|
8
|
+
function tryParseBoolean(v) {
|
|
9
|
+
if (typeof v === "boolean")
|
|
10
|
+
return v;
|
|
11
|
+
if (v === 1)
|
|
12
|
+
return true;
|
|
13
|
+
if (v === 0)
|
|
14
|
+
return false;
|
|
15
|
+
if (typeof v !== "string")
|
|
16
|
+
return undefined;
|
|
17
|
+
return boolMap[v.trim().toLowerCase()];
|
|
18
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { TimeUnit } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Matches string values beginning with standard hour-and-minute formatting.
|
|
4
|
+
* Examples:
|
|
5
|
+
* - "12:34" (matches "12:34")
|
|
6
|
+
* - "10:37:16.123" (matches "10:37")
|
|
7
|
+
* - "2026-05-25" (does not match)
|
|
8
|
+
*/
|
|
9
|
+
export declare const TIME_PREFIX_REGEX: RegExp;
|
|
10
|
+
/**
|
|
11
|
+
* Matches timezone offset indicators at the end of a string.
|
|
12
|
+
* Examples:
|
|
13
|
+
* - "12:34:56Z" (matches "Z")
|
|
14
|
+
* - "12:34:56+02:00" (matches "+02:00")
|
|
15
|
+
* - "12:34:56-0500" (matches "-0500")
|
|
16
|
+
* - "12:34:56-05" (matches "-05")
|
|
17
|
+
* - "12:34:56" (does not match)
|
|
18
|
+
*/
|
|
19
|
+
export declare const ZONE_OFFSET_REGEX: RegExp;
|
|
20
|
+
/**
|
|
21
|
+
* Matches only UTC offset indicators at the end of a string.
|
|
22
|
+
* Examples:
|
|
23
|
+
* - "12:34:56Z" (matches "Z")
|
|
24
|
+
* - "12:34:56+00:00" (matches "+00:00")
|
|
25
|
+
* - "12:34:56-0000" (matches "-0000")
|
|
26
|
+
* - "12:34:56+02:00" (does not match)
|
|
27
|
+
*/
|
|
28
|
+
export declare const UTC_INDICATOR_REGEX: RegExp;
|
|
29
|
+
export declare const MS_PER_SECOND = 1000;
|
|
30
|
+
export declare const MS_PER_MINUTE = 60000;
|
|
31
|
+
export declare const MS_PER_HOUR = 3600000;
|
|
32
|
+
export declare const MS_PER_DAY = 86400000;
|
|
33
|
+
export declare const US_PER_MS = 1000;
|
|
34
|
+
export declare const NS_PER_MS = 1000000;
|
|
35
|
+
export interface UtcOffsetResult {
|
|
36
|
+
timeZoneTime: Date;
|
|
37
|
+
utcTime: Date;
|
|
38
|
+
offset: number;
|
|
39
|
+
formatted: string;
|
|
40
|
+
}
|
|
41
|
+
export declare function toEpoch(d: Date, unit?: TimeUnit): number;
|
|
42
|
+
export declare function getCentury(d: Date): number;
|
|
43
|
+
export declare function getISOWeek(d: Date): number;
|
|
44
|
+
export declare function getMillennium(d: Date): number;
|
|
45
|
+
export declare function getMonthOffset(d: Date, monthOffset: number, day?: number): Date;
|
|
46
|
+
export declare function getOrdinalDay(d: Date): number;
|
|
47
|
+
export declare function getQuarter(d: Date): number;
|
|
48
|
+
export declare function getUtcOffset(timeZone: string): UtcOffsetResult;
|
|
49
|
+
export declare function isLeapYear(yOrDate: number | Date): boolean;
|
|
50
|
+
export declare function isUtcString(timestamp: string | null | undefined): boolean;
|
|
51
|
+
export declare function isValidDate(v: unknown): v is string | number | bigint | Date;
|
|
52
|
+
export declare function isValidDateObj(d: unknown): d is Date;
|
|
53
|
+
export declare function normalizeEpochToMs(n: number): number;
|
|
54
|
+
export declare const STRFTIME_DIRECTIVES: readonly ["%ms", "%f", "%Y", "%y", "%m", "%d", "%e", "%H", "%I", "%p", "%M", "%S", "%A", "%a", "%B", "%b", "%h", "%j", "%u", "%w", "%Z", "%z"];
|
|
55
|
+
export declare function strftime(d: Date, format: string, locale?: string): string;
|
|
56
|
+
export declare function strptime(str: string, format: string, strict?: boolean): Date | null;
|
|
57
|
+
export declare function toValidDate(input: unknown): Date | null;
|