ooxml-core 1.14.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PptxHandler-3A7VEXVK.cjs +13 -0
- package/dist/PptxHandler-7POULDRL.mjs +4 -0
- package/dist/{PptxHandler-KNBFECUE.mjs → PptxHandler-M35YFCUC.mjs} +2 -2
- package/dist/PresentationBuilder-C7NPM7OQ.mjs +4 -0
- package/dist/{PresentationBuilder-II7C4A3R.cjs → PresentationBuilder-XVRTITYR.cjs} +6 -5
- package/dist/{PresentationBuilder-5DCCFHWJ.mjs → PresentationBuilder-Y6DJK6H2.mjs} +2 -2
- package/dist/automation/index.cjs +1198 -1095
- package/dist/automation/index.mjs +1198 -1095
- package/dist/chunk-5W2QL4SB.cjs +244 -0
- package/dist/{chunk-TQE7FFNT.cjs → chunk-AHRFBMLK.cjs} +4070 -2015
- package/dist/{chunk-2D4IFQ5M.mjs → chunk-B37EVUMG.mjs} +1 -1
- package/dist/{chunk-4WZLFUUA.mjs → chunk-C2Y6SZDN.mjs} +934 -200
- package/dist/chunk-CA7KCNL3.mjs +236 -0
- package/dist/{chunk-BSUIDT6K.cjs → chunk-DWRJ62KP.cjs} +1 -0
- package/dist/{chunk-TNNXOW2O.mjs → chunk-KOX5Y5E5.mjs} +1 -1
- package/dist/{chunk-54ASP65T.mjs → chunk-LM6VBPQJ.mjs} +416 -15
- package/dist/{chunk-PC4MTLG4.cjs → chunk-OA5V3JJC.cjs} +8 -8
- package/dist/{chunk-ORH32TO3.mjs → chunk-OKGQ2X7D.mjs} +3092 -1037
- package/dist/{chunk-X7MGZQ6C.cjs → chunk-UGWY72WC.cjs} +396 -254
- package/dist/{chunk-XGXIS4PN.mjs → chunk-WBCV52YV.mjs} +3077 -1027
- package/dist/{chunk-2EBMHIGJ.mjs → chunk-WEFFRYXN.mjs} +379 -242
- package/dist/{chunk-AXF2FC4D.mjs → chunk-WSRCLCMB.mjs} +1 -0
- package/dist/{chunk-LMMP67YN.mjs → chunk-XCJRUBGJ.mjs} +1 -1
- package/dist/geometry/index.cjs +259 -0
- package/dist/geometry/index.d.ts +1 -0
- package/dist/geometry/index.d.ts.map +1 -1
- package/dist/geometry/index.mjs +255 -1
- package/dist/geometry/shape-gallery-catalog.d.ts +32 -0
- package/dist/geometry/shape-gallery-catalog.d.ts.map +1 -0
- package/dist/index.cjs +371 -112
- package/dist/index.mjs +371 -112
- package/dist/pptx/automation/index.cjs +4523 -1957
- package/dist/pptx/automation/index.d.ts +4 -4
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/chunks/{elements-tK7xnWeS.d.ts → elements-iUzpAeqR.d.ts} +232 -2
- package/dist/pptx/chunks/elements-iUzpAeqR.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-DS9Y4Ne3.d.ts → index-BWHNCVNC.d.ts} +1673 -1534
- package/dist/pptx/chunks/index-BWHNCVNC.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-BSpNQuvz.d.ts → index-CiyTR6mm.d.ts} +201 -5
- package/dist/pptx/chunks/index-CiyTR6mm.d.ts.map +1 -0
- package/dist/pptx/chunks/{text-operations-BdD_UQ11.d.ts → text-operations-CfLVZ7DK.d.ts} +81 -3
- package/dist/pptx/chunks/text-operations-CfLVZ7DK.d.ts.map +1 -0
- package/dist/pptx/cli/index.cjs +4465 -1899
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.cjs +52 -1
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/editor/render/collaboration-live-patch-target.cjs +4 -4
- package/dist/pptx/editor/render/collaboration-live-patch-target.mjs +2 -2
- package/dist/pptx/editor/render/collaboration-reconcile.cjs +7 -7
- package/dist/pptx/editor/render/collaboration-reconcile.mjs +2 -2
- package/dist/pptx/editor/render/collaboration-sync.cjs +14 -14
- package/dist/pptx/editor/render/collaboration-sync.d.ts.map +1 -1
- package/dist/pptx/editor/render/collaboration-sync.mjs +1 -1
- package/dist/pptx/editor/render/find-replace.cjs +15 -14
- package/dist/pptx/editor/render/find-replace.d.ts +2 -2
- package/dist/pptx/editor/render/find-replace.mjs +2 -1
- package/dist/pptx/editor/render/slide-operations.cjs +9 -8
- package/dist/pptx/editor/render/slide-operations.mjs +3 -2
- package/dist/pptx/editor/render/slide-size-rescale.cjs +3 -3
- package/dist/pptx/editor/render/slide-size-rescale.d.ts +1 -1
- package/dist/pptx/editor/render/slide-size-rescale.d.ts.map +1 -1
- package/dist/pptx/editor/render/slide-size-rescale.mjs +3 -3
- package/dist/pptx/editor/render/text-runs-style-patch.d.ts +1 -1
- package/dist/pptx/editor/render/text-style-scope.d.ts +1 -1
- package/dist/pptx/index.cjs +5656 -2290
- package/dist/pptx/index.d.ts +5 -5
- package/dist/pptx/index.mjs +5 -5
- package/dist/teams/ics.d.ts.map +1 -1
- package/dist/teams/index.cjs +631 -635
- package/dist/teams/index.d.ts +1 -0
- package/dist/teams/index.d.ts.map +1 -1
- package/dist/teams/index.mjs +616 -636
- package/dist/teams/meetings.d.ts +11 -1
- package/dist/teams/meetings.d.ts.map +1 -1
- package/dist/teams/recurrence-calendar.d.ts +41 -0
- package/dist/teams/recurrence-calendar.d.ts.map +1 -0
- package/dist/teams/recurrence.d.ts +1 -1
- package/dist/teams/recurrence.d.ts.map +1 -1
- package/dist/teams/server-session.d.ts +19 -0
- package/dist/teams/server-session.d.ts.map +1 -1
- package/dist/xlsx/edit/pivots.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +1137 -1027
- package/dist/xlsx/index.mjs +1136 -1028
- package/dist/xlsx/load/index.cjs +593 -652
- package/dist/xlsx/load/index.mjs +593 -652
- package/dist/xlsx/model-pivots.d.ts +64 -4
- package/dist/xlsx/model-pivots.d.ts.map +1 -1
- package/dist/xlsx/pivot/aggregate.d.ts +6 -3
- package/dist/xlsx/pivot/aggregate.d.ts.map +1 -1
- package/dist/xlsx/pivot/axes.d.ts +5 -0
- package/dist/xlsx/pivot/axes.d.ts.map +1 -1
- package/dist/xlsx/pivot/captions-locales.d.ts +3 -0
- package/dist/xlsx/pivot/captions-locales.d.ts.map +1 -0
- package/dist/xlsx/pivot/captions-read.d.ts +14 -0
- package/dist/xlsx/pivot/captions-read.d.ts.map +1 -0
- package/dist/xlsx/pivot/captions.d.ts +26 -0
- package/dist/xlsx/pivot/captions.d.ts.map +1 -0
- package/dist/xlsx/pivot/columns.d.ts +9 -3
- package/dist/xlsx/pivot/columns.d.ts.map +1 -1
- package/dist/xlsx/pivot/data.d.ts +3 -2
- package/dist/xlsx/pivot/data.d.ts.map +1 -1
- package/dist/xlsx/pivot/date-axes.d.ts +1 -1
- package/dist/xlsx/pivot/date-axes.d.ts.map +1 -1
- package/dist/xlsx/pivot/date-group-read.d.ts.map +1 -1
- package/dist/xlsx/pivot/date-groups.d.ts +8 -3
- package/dist/xlsx/pivot/date-groups.d.ts.map +1 -1
- package/dist/xlsx/pivot/index.d.ts +2 -1
- package/dist/xlsx/pivot/index.d.ts.map +1 -1
- package/dist/xlsx/pivot/item-labels.d.ts +12 -0
- package/dist/xlsx/pivot/item-labels.d.ts.map +1 -0
- package/dist/xlsx/pivot/item-names-read.d.ts +8 -0
- package/dist/xlsx/pivot/item-names-read.d.ts.map +1 -0
- package/dist/xlsx/pivot/measures.d.ts +2 -8
- package/dist/xlsx/pivot/measures.d.ts.map +1 -1
- package/dist/xlsx/pivot/nested.d.ts +4 -2
- package/dist/xlsx/pivot/nested.d.ts.map +1 -1
- package/dist/xlsx/pivot/page-filter-admission.d.ts.map +1 -1
- package/dist/xlsx/pivot/page-filter.d.ts +1 -1
- package/dist/xlsx/pivot/page-filter.d.ts.map +1 -1
- package/dist/xlsx/pivot/read.d.ts.map +1 -1
- package/dist/xlsx/pivot/subtotals.d.ts +6 -1
- package/dist/xlsx/pivot/subtotals.d.ts.map +1 -1
- package/dist/xlsx/pivot/table-xml.d.ts.map +1 -1
- package/dist/xlsx/pivot/values-axis.d.ts +7 -4
- package/dist/xlsx/pivot/values-axis.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
- package/dist/xlsx/ui/commands/i18n/pivots.d.ts.map +1 -1
- package/dist/xlsx/ui/index.cjs +1002 -1136
- package/dist/xlsx/ui/index.mjs +1002 -1136
- package/package.json +1 -1
- package/dist/PptxHandler-5YP75BPO.cjs +0 -12
- package/dist/PptxHandler-GT5Q66TG.mjs +0 -3
- package/dist/PresentationBuilder-CVM6LJ7L.mjs +0 -3
- package/dist/pptx/chunks/elements-tK7xnWeS.d.ts.map +0 -1
- package/dist/pptx/chunks/index-BSpNQuvz.d.ts.map +0 -1
- package/dist/pptx/chunks/index-DS9Y4Ne3.d.ts.map +0 -1
- package/dist/pptx/chunks/text-operations-BdD_UQ11.d.ts.map +0 -1
- package/dist/xlsx/pivot/hierarchy-first.d.ts +0 -21
- package/dist/xlsx/pivot/hierarchy-first.d.ts.map +0 -1
- package/dist/xlsx/pivot/hierarchy.d.ts +0 -8
- package/dist/xlsx/pivot/hierarchy.d.ts.map +0 -1
package/dist/teams/index.mjs
CHANGED
|
@@ -262,7 +262,7 @@ var init_namespaces = __esm({
|
|
|
262
262
|
};
|
|
263
263
|
}
|
|
264
264
|
});
|
|
265
|
-
function checkXmlLimits(xml,
|
|
265
|
+
function checkXmlLimits(xml, label2, limits = {}) {
|
|
266
266
|
const maxDepth = limits.maxDepth ?? DEFAULT_XML_LIMITS.maxDepth;
|
|
267
267
|
const maxNodes = limits.maxNodes ?? DEFAULT_XML_LIMITS.maxNodes;
|
|
268
268
|
let depth = 0;
|
|
@@ -275,16 +275,16 @@ function checkXmlLimits(xml, label5, limits = {}) {
|
|
|
275
275
|
continue;
|
|
276
276
|
}
|
|
277
277
|
nodes++;
|
|
278
|
-
if (nodes > maxNodes) throw new Error(`${
|
|
278
|
+
if (nodes > maxNodes) throw new Error(`${label2} XML exceeds the limit of ${maxNodes} elements`);
|
|
279
279
|
if (!selfClosing && ++depth > maxDepth)
|
|
280
|
-
throw new Error(`${
|
|
280
|
+
throw new Error(`${label2} XML exceeds the nesting depth limit of ${maxDepth}`);
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
function parseXml(xml, options = {}) {
|
|
284
|
-
const
|
|
284
|
+
const label2 = options.label ?? "OOXML";
|
|
285
285
|
if (/<!DOCTYPE|<!ENTITY/i.test(xml))
|
|
286
|
-
throw new Error(`${
|
|
287
|
-
checkXmlLimits(xml,
|
|
286
|
+
throw new Error(`${label2} XML with DTD or entity declarations is not supported`);
|
|
287
|
+
checkXmlLimits(xml, label2, options.limits);
|
|
288
288
|
let parseError = "";
|
|
289
289
|
let parsed;
|
|
290
290
|
try {
|
|
@@ -295,12 +295,12 @@ function parseXml(xml, options = {}) {
|
|
|
295
295
|
}).parseFromString(xml, "application/xml");
|
|
296
296
|
} catch (error) {
|
|
297
297
|
throw new Error(
|
|
298
|
-
`Invalid ${
|
|
298
|
+
`Invalid ${label2} XML: ${error instanceof Error ? error.message : String(error)}`,
|
|
299
299
|
{ cause: error }
|
|
300
300
|
);
|
|
301
301
|
}
|
|
302
302
|
if (parseError || !parsed.documentElement)
|
|
303
|
-
throw new Error(`Invalid ${
|
|
303
|
+
throw new Error(`Invalid ${label2} XML: ${parseError || "missing root element"}`);
|
|
304
304
|
return parsed;
|
|
305
305
|
}
|
|
306
306
|
function named(element2, local, ns, lenient = true) {
|
|
@@ -944,19 +944,19 @@ var init_opc = __esm({
|
|
|
944
944
|
|
|
945
945
|
// xlsx/address.ts
|
|
946
946
|
function columnLabel(col) {
|
|
947
|
-
let
|
|
947
|
+
let label2 = "";
|
|
948
948
|
let n = col + 1;
|
|
949
949
|
while (n > 0) {
|
|
950
950
|
const rem = (n - 1) % 26;
|
|
951
|
-
|
|
951
|
+
label2 = String.fromCharCode(65 + rem) + label2;
|
|
952
952
|
n = Math.floor((n - 1) / 26);
|
|
953
953
|
}
|
|
954
|
-
return
|
|
954
|
+
return label2;
|
|
955
955
|
}
|
|
956
|
-
function columnIndex(
|
|
957
|
-
if (!/^[A-Za-z]{1,3}$/.test(
|
|
956
|
+
function columnIndex(label2) {
|
|
957
|
+
if (!/^[A-Za-z]{1,3}$/.test(label2)) return -1;
|
|
958
958
|
let n = 0;
|
|
959
|
-
for (const ch of
|
|
959
|
+
for (const ch of label2.toUpperCase()) n = n * 26 + (ch.charCodeAt(0) - 64);
|
|
960
960
|
return n - 1;
|
|
961
961
|
}
|
|
962
962
|
function parseAddress(ref) {
|
|
@@ -1439,8 +1439,8 @@ function attributeReader(element2) {
|
|
|
1439
1439
|
if (direct !== null) return direct;
|
|
1440
1440
|
const attributes = element2.attributes;
|
|
1441
1441
|
for (let index2 = 0; index2 < attributes.length; index2++) {
|
|
1442
|
-
const
|
|
1443
|
-
if (
|
|
1442
|
+
const candidate2 = attributes.item(index2);
|
|
1443
|
+
if (candidate2 && candidate2.localName === name2) return candidate2.value;
|
|
1444
1444
|
}
|
|
1445
1445
|
return void 0;
|
|
1446
1446
|
};
|
|
@@ -2631,10 +2631,10 @@ function titleXml(context, title) {
|
|
|
2631
2631
|
function labelOptionsXml(context, options) {
|
|
2632
2632
|
return numberFormatXml(options.numberFormat) + shapePropertiesXml(context, options.spPr) + textBodyXml(context, options.txPr) + valXml("dLblPos", options.position) + valXml("showLegendKey", options.showLegendKey) + valXml("showVal", options.showValue) + valXml("showCatName", options.showCategoryName) + valXml("showSerName", options.showSeriesName) + valXml("showPercent", options.showPercent) + valXml("showBubbleSize", options.showBubbleSize) + (options.separator === void 0 ? "" : textElement("separator", options.separator));
|
|
2633
2633
|
}
|
|
2634
|
-
function labelXml(context,
|
|
2634
|
+
function labelXml(context, label2) {
|
|
2635
2635
|
return elementXml(
|
|
2636
2636
|
"dLbl",
|
|
2637
|
-
valXml("idx",
|
|
2637
|
+
valXml("idx", label2.index) + valXml("delete", label2.deleted) + layoutXml(context, label2.layout) + chartTextXml(context, label2.tx, false) + labelOptionsXml(context, label2) + raw(context, label2.extLst)
|
|
2638
2638
|
);
|
|
2639
2639
|
}
|
|
2640
2640
|
function dataLabelsXml(context, labels) {
|
|
@@ -2642,7 +2642,7 @@ function dataLabelsXml(context, labels) {
|
|
|
2642
2642
|
const leaderLines = labels.leaderLines ? elementXml("leaderLines", shapePropertiesXml(context, labels.leaderLines.spPr)) : "";
|
|
2643
2643
|
return elementXml(
|
|
2644
2644
|
"dLbls",
|
|
2645
|
-
labels.labels.map((
|
|
2645
|
+
labels.labels.map((label2) => labelXml(context, label2)).join("") + valXml("delete", labels.deleted) + labelOptionsXml(context, labels) + valXml("showLeaderLines", labels.showLeaderLines) + leaderLines + raw(context, labels.extLst)
|
|
2646
2646
|
);
|
|
2647
2647
|
}
|
|
2648
2648
|
var textElement, dataSourceXml;
|
|
@@ -2673,12 +2673,12 @@ function dataTableXml(context, table2) {
|
|
|
2673
2673
|
}
|
|
2674
2674
|
function displayUnitsXml(context, units) {
|
|
2675
2675
|
if (!units) return "";
|
|
2676
|
-
const
|
|
2676
|
+
const label2 = units.label;
|
|
2677
2677
|
return elementXml(
|
|
2678
2678
|
"dispUnits",
|
|
2679
|
-
valXml("custUnit", units.customUnit) + (units.customUnit === void 0 ? valXml("builtInUnit", units.builtInUnit) : "") + (
|
|
2679
|
+
valXml("custUnit", units.customUnit) + (units.customUnit === void 0 ? valXml("builtInUnit", units.builtInUnit) : "") + (label2 ? elementXml(
|
|
2680
2680
|
"dispUnitsLbl",
|
|
2681
|
-
layoutXml(context,
|
|
2681
|
+
layoutXml(context, label2.layout) + chartTextXml(context, label2.tx, false) + shapePropertiesXml(context, label2.spPr) + textBodyXml(context, label2.txPr)
|
|
2682
2682
|
) : "") + raw(context, units.extLst)
|
|
2683
2683
|
);
|
|
2684
2684
|
}
|
|
@@ -2889,10 +2889,10 @@ function parseDisplayUnits(context, element2) {
|
|
|
2889
2889
|
if (!element2) return void 0;
|
|
2890
2890
|
reportUnmodelled(context, element2, DISPLAY_UNITS);
|
|
2891
2891
|
const labelElement = cChild(element2, "dispUnitsLbl");
|
|
2892
|
-
let
|
|
2892
|
+
let label2;
|
|
2893
2893
|
if (labelElement) {
|
|
2894
2894
|
reportUnmodelled(context, labelElement, DISPLAY_UNITS_LABEL);
|
|
2895
|
-
|
|
2895
|
+
label2 = assignDefined(
|
|
2896
2896
|
{},
|
|
2897
2897
|
{
|
|
2898
2898
|
layout: manualLayout(labelElement),
|
|
@@ -2907,7 +2907,7 @@ function parseDisplayUnits(context, element2) {
|
|
|
2907
2907
|
{
|
|
2908
2908
|
builtInUnit: cVal(element2, "builtInUnit"),
|
|
2909
2909
|
customUnit: cNumber(context, element2, "custUnit"),
|
|
2910
|
-
label:
|
|
2910
|
+
label: label2,
|
|
2911
2911
|
extLst: extensionList(element2)
|
|
2912
2912
|
}
|
|
2913
2913
|
);
|
|
@@ -3430,11 +3430,11 @@ var init_write_axes = __esm({
|
|
|
3430
3430
|
});
|
|
3431
3431
|
|
|
3432
3432
|
// chart/write-analysis.ts
|
|
3433
|
-
function trendlineLabelXml(context,
|
|
3434
|
-
if (!
|
|
3433
|
+
function trendlineLabelXml(context, label2) {
|
|
3434
|
+
if (!label2) return "";
|
|
3435
3435
|
return elementXml(
|
|
3436
3436
|
"trendlineLbl",
|
|
3437
|
-
layoutXml(context,
|
|
3437
|
+
layoutXml(context, label2.layout) + chartTextXml(context, label2.tx, false) + numberFormatXml(label2.numberFormat) + shapePropertiesXml(context, label2.spPr) + textBodyXml(context, label2.txPr) + raw(context, label2.extLst)
|
|
3438
3438
|
);
|
|
3439
3439
|
}
|
|
3440
3440
|
function trendlineXml(context, trendline) {
|
|
@@ -7633,7 +7633,7 @@ function serialSeconds(serial) {
|
|
|
7633
7633
|
const rounded = rest > 0.5 || rest === 0.5 && whole % 2 === 1 ? whole + 1 : whole;
|
|
7634
7634
|
return rounded % 86400;
|
|
7635
7635
|
}
|
|
7636
|
-
function
|
|
7636
|
+
function daysInMonth2(year, month) {
|
|
7637
7637
|
return new Date(Date.UTC(year, month, 0)).getUTCDate();
|
|
7638
7638
|
}
|
|
7639
7639
|
function localDateToSerial(date, date1904 = date1904Mode) {
|
|
@@ -8608,14 +8608,14 @@ function unique(args, ctx) {
|
|
|
8608
8608
|
const byCol = args.length > 1 && args[1] !== null && toBool(ctx.toScalar(args[1] ?? null));
|
|
8609
8609
|
const once = args.length > 2 && args[2] !== null && toBool(ctx.toScalar(args[2] ?? null));
|
|
8610
8610
|
if (byCol) m = transpose(m);
|
|
8611
|
-
const
|
|
8611
|
+
const keyOf3 = (row2) => JSON.stringify(
|
|
8612
8612
|
row2.map(
|
|
8613
8613
|
(v) => isError(v) ? `#${v.error}` : typeof v === "string" ? `s${v.toLowerCase()}` : v
|
|
8614
8614
|
)
|
|
8615
8615
|
);
|
|
8616
8616
|
const counts = /* @__PURE__ */ new Map();
|
|
8617
8617
|
for (const row2 of m.data) {
|
|
8618
|
-
const key =
|
|
8618
|
+
const key = keyOf3(row2);
|
|
8619
8619
|
const entry3 = counts.get(key);
|
|
8620
8620
|
if (entry3) entry3.count++;
|
|
8621
8621
|
else counts.set(key, { row: row2, count: 1 });
|
|
@@ -9145,7 +9145,7 @@ function addMonths(serial, months, ctx, endOfMonth) {
|
|
|
9145
9145
|
const total2 = year * 12 + (month - 1) + Math.trunc(months);
|
|
9146
9146
|
const y = Math.floor(total2 / 12);
|
|
9147
9147
|
const m = total2 % 12 + 1;
|
|
9148
|
-
const d = endOfMonth ?
|
|
9148
|
+
const d = endOfMonth ? daysInMonth2(y, m) : Math.min(day, daysInMonth2(y, m));
|
|
9149
9149
|
const out = ymdToSerial(y, m, d, ctx.date1904);
|
|
9150
9150
|
return out === void 0 ? fail(ERR.NUM) : out;
|
|
9151
9151
|
}
|
|
@@ -9212,7 +9212,7 @@ function datedif(start, end, unit, ctx) {
|
|
|
9212
9212
|
if (b.day >= a2.day) return b.day - a2.day;
|
|
9213
9213
|
const pm = b.month === 1 ? 12 : b.month - 1;
|
|
9214
9214
|
const py = b.month === 1 ? b.year - 1 : b.year;
|
|
9215
|
-
return
|
|
9215
|
+
return daysInMonth2(py, pm) - a2.day + b.day;
|
|
9216
9216
|
}
|
|
9217
9217
|
case "YD": {
|
|
9218
9218
|
let y = b.year;
|
|
@@ -9236,7 +9236,7 @@ function days360(start, end, european, ctx) {
|
|
|
9236
9236
|
if (d1 === 31) d1 = 30;
|
|
9237
9237
|
if (d2 === 31) d2 = 30;
|
|
9238
9238
|
} else {
|
|
9239
|
-
const lastFeb = (y, m, d) => m === 2 && d ===
|
|
9239
|
+
const lastFeb = (y, m, d) => m === 2 && d === daysInMonth2(y, 2);
|
|
9240
9240
|
if (lastFeb(a2.year, a2.month, d1)) d1 = 30;
|
|
9241
9241
|
if (d1 === 31) d1 = 30;
|
|
9242
9242
|
if (d2 === 31 && d1 >= 30) d2 = 30;
|
|
@@ -9244,7 +9244,7 @@ function days360(start, end, european, ctx) {
|
|
|
9244
9244
|
return (b.year - a2.year) * 360 + (b.month - a2.month) * 30 + (d2 - d1);
|
|
9245
9245
|
}
|
|
9246
9246
|
function yearFrac30(a2, b) {
|
|
9247
|
-
const lastFeb = (d) => d.month === 2 && d.day ===
|
|
9247
|
+
const lastFeb = (d) => d.month === 2 && d.day === daysInMonth2(d.year, 2);
|
|
9248
9248
|
let d1 = a2.day;
|
|
9249
9249
|
let d2 = b.day;
|
|
9250
9250
|
if (d1 === 31 && d2 === 31) {
|
|
@@ -10250,7 +10250,7 @@ function couponFacts(settlement, maturity, frequency2, basis, ctx) {
|
|
|
10250
10250
|
checkSecurity(s, m, frequency2, basis);
|
|
10251
10251
|
const months = 12 / frequency2;
|
|
10252
10252
|
const { year, month, day } = serialToYmd(m, ctx.date1904);
|
|
10253
|
-
const monthEnd = day ===
|
|
10253
|
+
const monthEnd = day === daysInMonth2(year, month);
|
|
10254
10254
|
let count2 = 0;
|
|
10255
10255
|
let next = m;
|
|
10256
10256
|
let previous = addMonths(m, -months, ctx, monthEnd);
|
|
@@ -10423,7 +10423,7 @@ function duration(bond, yld) {
|
|
|
10423
10423
|
function quasiPeriods(anchor, from, to, frequency2, ctx) {
|
|
10424
10424
|
const months = 12 / frequency2;
|
|
10425
10425
|
const { year, month, day } = serialToYmd(anchor, ctx.date1904);
|
|
10426
|
-
const monthEnd = day ===
|
|
10426
|
+
const monthEnd = day === daysInMonth2(year, month);
|
|
10427
10427
|
const at = (k) => addMonths(anchor, k * months, ctx, monthEnd);
|
|
10428
10428
|
let back = 0;
|
|
10429
10429
|
while (at(back) > from) back -= 1;
|
|
@@ -10677,7 +10677,7 @@ function oddFirstPrice(s, yld, ctx) {
|
|
|
10677
10677
|
);
|
|
10678
10678
|
const toFirst = quasi.fraction(settlement, firstCoupon);
|
|
10679
10679
|
const { year, month, day } = serialToYmd(firstCoupon, ctx.date1904);
|
|
10680
|
-
const monthEnd = day ===
|
|
10680
|
+
const monthEnd = day === daysInMonth2(year, month);
|
|
10681
10681
|
let n = 1;
|
|
10682
10682
|
while (addMonths(firstCoupon, n * months, ctx, monthEnd) < maturity) n += 1;
|
|
10683
10683
|
n += 1;
|
|
@@ -11888,9 +11888,9 @@ var init_logical = __esm({
|
|
|
11888
11888
|
if (isError(target)) return target;
|
|
11889
11889
|
let i = 1;
|
|
11890
11890
|
for (; i + 1 < args.length; i += 2) {
|
|
11891
|
-
const
|
|
11892
|
-
if (isError(
|
|
11893
|
-
if (typeof
|
|
11891
|
+
const candidate2 = ctx.toScalar(deref(ctx, args[i].get()));
|
|
11892
|
+
if (isError(candidate2)) return candidate2;
|
|
11893
|
+
if (typeof candidate2 === typeof target && compareScalars(candidate2, target) === 0) {
|
|
11894
11894
|
return args[i + 1].get();
|
|
11895
11895
|
}
|
|
11896
11896
|
}
|
|
@@ -16582,6 +16582,13 @@ var init_sparkline_ranges = __esm({
|
|
|
16582
16582
|
});
|
|
16583
16583
|
|
|
16584
16584
|
// xlsx/pivot/axes.ts
|
|
16585
|
+
function pivotValuesIndex(pivot) {
|
|
16586
|
+
if (pivot.valuesAxis !== "rows") return -1;
|
|
16587
|
+
const count2 = pivotRowFields(pivot).length;
|
|
16588
|
+
const at = pivot.valuesPosition;
|
|
16589
|
+
if (typeof at === "number") return Math.min(Math.max(Math.trunc(at), 0), count2);
|
|
16590
|
+
return at === "first" ? 0 : at === "between" ? Math.min(1, count2) : count2;
|
|
16591
|
+
}
|
|
16585
16592
|
var pivotRowFields, pivotColumnFields;
|
|
16586
16593
|
var init_axes = __esm({
|
|
16587
16594
|
"xlsx/pivot/axes.ts"() {
|
|
@@ -16597,6 +16604,55 @@ var init_axes = __esm({
|
|
|
16597
16604
|
}
|
|
16598
16605
|
});
|
|
16599
16606
|
|
|
16607
|
+
// xlsx/pivot/captions.ts
|
|
16608
|
+
function pivotCaptions(pivot) {
|
|
16609
|
+
const own = pivot.captions;
|
|
16610
|
+
if (!own) return ENGLISH_PIVOT_CAPTIONS;
|
|
16611
|
+
return {
|
|
16612
|
+
...ENGLISH_PIVOT_CAPTIONS,
|
|
16613
|
+
...Object.fromEntries(Object.entries(own).filter(([, value]) => typeof value === "string")),
|
|
16614
|
+
functions: { ...ENGLISH_PIVOT_CAPTIONS.functions, ...own.functions },
|
|
16615
|
+
aggregates: { ...ENGLISH_PIVOT_CAPTIONS.aggregates, ...own.aggregates }
|
|
16616
|
+
};
|
|
16617
|
+
}
|
|
16618
|
+
var FUNCTIONS, aggregateNames, ENGLISH_PIVOT_CAPTIONS, fillCaption;
|
|
16619
|
+
var init_captions = __esm({
|
|
16620
|
+
"xlsx/pivot/captions.ts"() {
|
|
16621
|
+
FUNCTIONS = {
|
|
16622
|
+
sum: "Sum",
|
|
16623
|
+
count: "Count",
|
|
16624
|
+
average: "Average",
|
|
16625
|
+
max: "Max",
|
|
16626
|
+
min: "Min",
|
|
16627
|
+
product: "Product",
|
|
16628
|
+
countNums: "Count",
|
|
16629
|
+
stdDev: "StdDev",
|
|
16630
|
+
stdDevp: "StdDevp",
|
|
16631
|
+
var: "Var",
|
|
16632
|
+
varp: "Varp"
|
|
16633
|
+
};
|
|
16634
|
+
aggregateNames = () => Object.fromEntries(
|
|
16635
|
+
Object.keys(FUNCTIONS).map((fn) => [
|
|
16636
|
+
fn,
|
|
16637
|
+
`${fn[0].toUpperCase()}${fn.slice(1)} of {0}`
|
|
16638
|
+
])
|
|
16639
|
+
);
|
|
16640
|
+
ENGLISH_PIVOT_CAPTIONS = {
|
|
16641
|
+
rowLabels: "Row Labels",
|
|
16642
|
+
columnLabels: "Column Labels",
|
|
16643
|
+
grandTotal: "Grand Total",
|
|
16644
|
+
values: "Values",
|
|
16645
|
+
all: "(All)",
|
|
16646
|
+
blank: "(blank)",
|
|
16647
|
+
subtotal: "{0} Total",
|
|
16648
|
+
measureTotal: "Total {0}",
|
|
16649
|
+
functions: FUNCTIONS,
|
|
16650
|
+
aggregates: aggregateNames()
|
|
16651
|
+
};
|
|
16652
|
+
fillCaption = (template, ...args) => template.replace(/\{(\d)\}/g, (_match, at) => args[Number(at)] ?? "");
|
|
16653
|
+
}
|
|
16654
|
+
});
|
|
16655
|
+
|
|
16600
16656
|
// xlsx/pivot/date-groups.ts
|
|
16601
16657
|
function dateGroupRange(group, serials) {
|
|
16602
16658
|
let min = Infinity;
|
|
@@ -16614,7 +16670,7 @@ function dateGroupRange(group, serials) {
|
|
|
16614
16670
|
function dayBuckets(range, days) {
|
|
16615
16671
|
return Math.max(1, Math.ceil((Math.floor(range.end) - Math.floor(range.start) + 1) / days));
|
|
16616
16672
|
}
|
|
16617
|
-
function
|
|
16673
|
+
function englishDateUnitLabels(unit, range, days, date1904) {
|
|
16618
16674
|
const labels = [`<${isoDay(range.start, date1904)}`];
|
|
16619
16675
|
if (unit === "seconds" || unit === "minutes")
|
|
16620
16676
|
for (let i = 0; i < 60; i++) labels.push(`:${pad5(i)}`);
|
|
@@ -16643,6 +16699,11 @@ function dateUnitLabels(unit, range, days, date1904) {
|
|
|
16643
16699
|
labels.push(`>${isoDay(range.end, date1904)}`);
|
|
16644
16700
|
return labels;
|
|
16645
16701
|
}
|
|
16702
|
+
function dateUnitLabels(unit, range, days, date1904, group) {
|
|
16703
|
+
const english = englishDateUnitLabels(unit, range, days, date1904);
|
|
16704
|
+
const localized = group?.localized?.[unit]?.labels;
|
|
16705
|
+
return localized?.length === english.length ? localized : english;
|
|
16706
|
+
}
|
|
16646
16707
|
function dateUnitIndex(unit, range, days, date1904, serial, count2) {
|
|
16647
16708
|
if (serial < range.start) return 0;
|
|
16648
16709
|
if (serial > range.end) return count2 - 1;
|
|
@@ -16666,7 +16727,7 @@ function derivedDateFields(pivot) {
|
|
|
16666
16727
|
for (const group of pivot.dateGroups ?? [])
|
|
16667
16728
|
for (const unit of dateGroupUnits(group))
|
|
16668
16729
|
derived.push({
|
|
16669
|
-
name: dateGroupFieldName(unit, group.field),
|
|
16730
|
+
name: dateGroupFieldName(unit, group.field, group),
|
|
16670
16731
|
unit,
|
|
16671
16732
|
group,
|
|
16672
16733
|
index: databaseFields + derived.length
|
|
@@ -16677,7 +16738,7 @@ function countDerived(pivot) {
|
|
|
16677
16738
|
let count2 = 0;
|
|
16678
16739
|
for (const group of pivot.dateGroups ?? [])
|
|
16679
16740
|
for (const unit of dateGroupUnits(group))
|
|
16680
|
-
if (pivot.fields.includes(dateGroupFieldName(unit, group.field))) count2++;
|
|
16741
|
+
if (pivot.fields.includes(dateGroupFieldName(unit, group.field, group))) count2++;
|
|
16681
16742
|
return count2;
|
|
16682
16743
|
}
|
|
16683
16744
|
function resolveDateGroups(pivot) {
|
|
@@ -16689,11 +16750,11 @@ function resolveDateGroups(pivot) {
|
|
|
16689
16750
|
});
|
|
16690
16751
|
}
|
|
16691
16752
|
function derivedDateLabels(pivot, name2) {
|
|
16692
|
-
const entry3 = derivedDateFields(pivot).find((
|
|
16753
|
+
const entry3 = derivedDateFields(pivot).find((candidate2) => candidate2.name === name2);
|
|
16693
16754
|
if (!entry3) return void 0;
|
|
16694
16755
|
const [group] = resolveDateGroups({ ...pivot, dateGroups: [entry3.group] });
|
|
16695
16756
|
const range = { start: group.start, end: group.end };
|
|
16696
|
-
return dateUnitLabels(entry3.unit, range, dateGroupDays(group), pivot.date1904 ?? false);
|
|
16757
|
+
return dateUnitLabels(entry3.unit, range, dateGroupDays(group), pivot.date1904 ?? false, group);
|
|
16697
16758
|
}
|
|
16698
16759
|
function validateDateGroups(pivot) {
|
|
16699
16760
|
const groups = pivot.dateGroups;
|
|
@@ -16709,18 +16770,16 @@ function validateDateGroups(pivot) {
|
|
|
16709
16770
|
seen.add(group.field);
|
|
16710
16771
|
if (!(pivot.dateFields ?? []).includes(group.field))
|
|
16711
16772
|
throw new Error("Only fields that contain dates can be grouped by date.");
|
|
16712
|
-
if (pivot.pageFilter || pivot.dateFilter)
|
|
16713
|
-
throw new Error("Date groups cannot be combined with report filters or timelines.");
|
|
16714
16773
|
const serials = pivot.records.map((record) => record[index2]);
|
|
16715
16774
|
if (!serials.length || serials.some((v) => typeof v !== "number" || !Number.isFinite(v)))
|
|
16716
16775
|
throw new Error("Only fields that contain dates can be grouped by date.");
|
|
16717
16776
|
const range = dateGroupRange(group, serials);
|
|
16718
16777
|
if (range.start >= range.end) throw new Error("The date group must end after it starts.");
|
|
16719
16778
|
for (const unit of dateGroupUnits(group)) {
|
|
16720
|
-
const name2 = dateGroupFieldName(unit, group.field);
|
|
16779
|
+
const name2 = dateGroupFieldName(unit, group.field, group);
|
|
16721
16780
|
if (pivot.fields.includes(name2))
|
|
16722
16781
|
throw new Error("A source field already has the name of a date group field.");
|
|
16723
|
-
if (dateUnitLabels(unit, range, dateGroupDays(group), pivot.date1904 ?? false).length > MAX_ITEMS)
|
|
16782
|
+
if (dateUnitLabels(unit, range, dateGroupDays(group), pivot.date1904 ?? false, group).length > MAX_ITEMS)
|
|
16724
16783
|
throw new Error("The date group has too many items.");
|
|
16725
16784
|
}
|
|
16726
16785
|
}
|
|
@@ -16734,7 +16793,7 @@ function expandDateGroups(pivot) {
|
|
|
16734
16793
|
const tables = derived.map((entry3) => {
|
|
16735
16794
|
const range = { start: entry3.group.start, end: entry3.group.end };
|
|
16736
16795
|
const days = dateGroupDays(entry3.group);
|
|
16737
|
-
const labels = dateUnitLabels(entry3.unit, range, days, date1904);
|
|
16796
|
+
const labels = dateUnitLabels(entry3.unit, range, days, date1904, entry3.group);
|
|
16738
16797
|
return {
|
|
16739
16798
|
base: pivot.fields.indexOf(entry3.group.field),
|
|
16740
16799
|
labels,
|
|
@@ -16780,7 +16839,7 @@ var init_date_groups = __esm({
|
|
|
16780
16839
|
MAX_ITEMS = 1e4;
|
|
16781
16840
|
pad5 = (value, width = 2) => String(value).padStart(width, "0");
|
|
16782
16841
|
dateGroupUnits = (group) => PIVOT_DATE_UNITS.filter((unit) => group.by.includes(unit));
|
|
16783
|
-
dateGroupFieldName = (unit, field) => `${UNIT_TITLES[unit]} (${field})`;
|
|
16842
|
+
dateGroupFieldName = (unit, field, group) => group?.localized?.[unit]?.name ?? `${UNIT_TITLES[unit]} (${field})`;
|
|
16784
16843
|
dateGroupDays = (group) => group.by.length === 1 && group.by[0] === "days" ? group.days ?? 1 : 1;
|
|
16785
16844
|
isoDay = (serial, date1904) => {
|
|
16786
16845
|
const { year, month, day } = serialToYmd(serial, date1904);
|
|
@@ -16878,15 +16937,13 @@ function fieldSubtotalFunctions(pivot, field) {
|
|
|
16878
16937
|
if (entry3) return PIVOT_SUBTOTAL_ORDER.filter((fn) => entry3.functions.includes(fn));
|
|
16879
16938
|
return field === pivot.rowField && pivot.subtotals === false ? [] : "auto";
|
|
16880
16939
|
}
|
|
16881
|
-
function validateFieldSubtotals(pivot,
|
|
16940
|
+
function validateFieldSubtotals(pivot, axisFields) {
|
|
16882
16941
|
const entries = pivot.fieldSubtotals;
|
|
16883
16942
|
if (entries === void 0) return;
|
|
16884
16943
|
if (!Array.isArray(entries)) throw new Error("Choose valid field subtotals.");
|
|
16885
|
-
if (entries.length && pivot.valuesAxis === "rows")
|
|
16886
|
-
throw new Error("Field subtotals require Values on columns.");
|
|
16887
16944
|
const seen = /* @__PURE__ */ new Set();
|
|
16888
16945
|
for (const entry3 of entries) {
|
|
16889
|
-
if (!entry3 || typeof entry3 !== "object" || !
|
|
16946
|
+
if (!entry3 || typeof entry3 !== "object" || !axisFields.includes(entry3.field) || seen.has(entry3.field) || !Array.isArray(entry3.functions) || entry3.functions.some((fn) => !PIVOT_AGGREGATES.includes(fn)) || new Set(entry3.functions).size !== entry3.functions.length)
|
|
16890
16947
|
throw new Error("Choose valid field subtotals.");
|
|
16891
16948
|
seen.add(entry3.field);
|
|
16892
16949
|
}
|
|
@@ -16991,6 +17048,24 @@ var init_item_filters = __esm({
|
|
|
16991
17048
|
}
|
|
16992
17049
|
});
|
|
16993
17050
|
|
|
17051
|
+
// xlsx/pivot/item-labels.ts
|
|
17052
|
+
function pivotItemLabeler(pivot) {
|
|
17053
|
+
const blank = pivotCaptions(pivot).blank;
|
|
17054
|
+
const names2 = pivot.itemNames?.length ? new Map(pivot.itemNames.map((entry3) => [keyOf(entry3.field, entry3.item), entry3.name])) : void 0;
|
|
17055
|
+
return (field, value) => names2?.get(keyOf(field, value)) ?? (value === null || value === "" ? blank : pivotItemLabel(value));
|
|
17056
|
+
}
|
|
17057
|
+
var keyOf, pivotItemName;
|
|
17058
|
+
var init_item_labels = __esm({
|
|
17059
|
+
"xlsx/pivot/item-labels.ts"() {
|
|
17060
|
+
init_captions();
|
|
17061
|
+
init_data();
|
|
17062
|
+
keyOf = (field, item) => `${field}\0${pivotValueKey(item)}`;
|
|
17063
|
+
pivotItemName = (pivot, field, item) => pivot.itemNames?.find(
|
|
17064
|
+
(entry3) => entry3.field === field && pivotValueKey(entry3.item) === pivotValueKey(item)
|
|
17065
|
+
)?.name;
|
|
17066
|
+
}
|
|
17067
|
+
});
|
|
17068
|
+
|
|
16994
17069
|
// xlsx/pivot/page-filter.ts
|
|
16995
17070
|
function validatePivotPageFilter(pivot) {
|
|
16996
17071
|
const filter2 = pivot.pageFilter;
|
|
@@ -17002,23 +17077,24 @@ function validatePivotPageFilter(pivot) {
|
|
|
17002
17077
|
pivot.columnField,
|
|
17003
17078
|
pivot.valueField,
|
|
17004
17079
|
...extras.map((v) => v?.field)
|
|
17005
|
-
].includes(filter2.field)
|
|
17006
|
-
throw new Error("Report filters require
|
|
17080
|
+
].includes(filter2.field))
|
|
17081
|
+
throw new Error("Report filters require a separate source field.");
|
|
17007
17082
|
if (filter2.item !== void 0 && !(filter2.item === null || typeof filter2.item === "string" || typeof filter2.item === "boolean" || typeof filter2.item === "number" && Number.isFinite(filter2.item) || isCellError(filter2.item) && isErrorCode(filter2.item.error) && Object.keys(filter2.item).length === 1))
|
|
17008
17083
|
throw new Error("Choose a cached literal report filter item.");
|
|
17009
17084
|
}
|
|
17010
17085
|
function pivotPageProjection(pivot) {
|
|
17011
|
-
|
|
17086
|
+
const groups = pivot.dateGroups?.length ? { ...pivot, dateGroups: resolveDateGroups(pivot) } : pivot;
|
|
17087
|
+
return applyPivotGroups(applyPivotItemFilters(pagedProjection(groups)));
|
|
17012
17088
|
}
|
|
17013
17089
|
function pagedProjection(pivot) {
|
|
17014
17090
|
const filter2 = pivot.pageFilter;
|
|
17015
17091
|
if (!filter2) return pivot;
|
|
17016
17092
|
const labels = /* @__PURE__ */ new Map();
|
|
17017
17093
|
for (const item of pivotItems(pivot, filter2.field)) {
|
|
17018
|
-
const
|
|
17019
|
-
if (
|
|
17094
|
+
const label2 = String(pivotItemLabel(item)).toLowerCase(), key2 = pivotValueKey(item);
|
|
17095
|
+
if (label2 === "(all)" || labels.has(label2) && labels.get(label2) !== key2)
|
|
17020
17096
|
throw new Error("Ambiguous report filter item captions are preserved.");
|
|
17021
|
-
labels.set(
|
|
17097
|
+
labels.set(label2, key2);
|
|
17022
17098
|
}
|
|
17023
17099
|
if (filter2.item === void 0) return pivot;
|
|
17024
17100
|
const index2 = pivot.fields.indexOf(filter2.field), key = pivotValueKey(filter2.item);
|
|
@@ -17036,7 +17112,7 @@ function prependPivotPage(grid, pivot) {
|
|
|
17036
17112
|
values: [
|
|
17037
17113
|
[
|
|
17038
17114
|
pivot.pageFilter.field,
|
|
17039
|
-
pivot.pageFilter.item === void 0 ?
|
|
17115
|
+
pivot.pageFilter.item === void 0 ? pivotCaptions(pivot).all : pivotItemLabeler(pivot)(pivot.pageFilter.field, pivot.pageFilter.item),
|
|
17040
17116
|
...Array(width - 2).fill(null)
|
|
17041
17117
|
],
|
|
17042
17118
|
Array(width).fill(null),
|
|
@@ -17051,6 +17127,9 @@ var init_page_filter = __esm({
|
|
|
17051
17127
|
"xlsx/pivot/page-filter.ts"() {
|
|
17052
17128
|
init_model();
|
|
17053
17129
|
init_data();
|
|
17130
|
+
init_item_labels();
|
|
17131
|
+
init_captions();
|
|
17132
|
+
init_date_groups();
|
|
17054
17133
|
init_groups();
|
|
17055
17134
|
init_item_filters();
|
|
17056
17135
|
}
|
|
@@ -17092,13 +17171,9 @@ function validatePivotFields(pivot) {
|
|
|
17092
17171
|
const columns = pivotColumnFields(pivot);
|
|
17093
17172
|
if (pivot.moreColumnFields !== void 0 && (!Array.isArray(pivot.moreColumnFields) || pivot.moreColumnFields.length > 0 && !pivot.columnField || pivot.moreColumnFields.length > 62 || pivot.moreColumnFields.some((name2) => typeof name2 !== "string")))
|
|
17094
17173
|
throw new Error("Choose valid PivotTable column fields.");
|
|
17095
|
-
if (pivot.valuesAxis === "rows" && rows.length > 2)
|
|
17096
|
-
throw new Error("Values on rows support at most two row fields.");
|
|
17097
|
-
if (pivot.valuesAxis === "rows" && columns.length > 1)
|
|
17098
|
-
throw new Error("Values on rows support one column field.");
|
|
17099
17174
|
if (pivot.pageFilter && columns.length > 1)
|
|
17100
17175
|
throw new Error("Report filters support one column field.");
|
|
17101
|
-
validateFieldSubtotals(pivot, rows);
|
|
17176
|
+
validateFieldSubtotals(pivot, [...rows, ...columns]);
|
|
17102
17177
|
const axisNames = pivotAxisFieldNames(pivot);
|
|
17103
17178
|
if ((pivot.dateGroups ?? []).some(
|
|
17104
17179
|
(group) => [...rows, ...columns].some((name2) => name2 === group.field)
|
|
@@ -17107,13 +17182,14 @@ function validatePivotFields(pivot) {
|
|
|
17107
17182
|
const extras = pivot.additionalValues ?? [];
|
|
17108
17183
|
if (pivot.valuesAxis !== void 0 && !["columns", "rows"].includes(pivot.valuesAxis))
|
|
17109
17184
|
throw new Error("Choose a valid Values axis.");
|
|
17110
|
-
|
|
17185
|
+
const position = pivot.valuesPosition;
|
|
17186
|
+
if (position !== void 0 && !["last", "between", "first"].includes(position) && !(typeof position === "number" && Number.isInteger(position) && position >= 0))
|
|
17111
17187
|
throw new Error("Choose a valid Values position.");
|
|
17112
|
-
if (
|
|
17188
|
+
if (position !== void 0 && position !== "last" && (pivot.valuesAxis !== "rows" || position === "between" && !pivot.secondRowField || typeof position === "number" && position > rows.length))
|
|
17113
17189
|
throw new Error("Values before or between fields require two row fields and Values on rows.");
|
|
17114
17190
|
if (pivot.valuesAxis === "rows" && (!Array.isArray(extras) || !extras.length))
|
|
17115
17191
|
throw new Error("Values on rows require multiple measures.");
|
|
17116
|
-
if (extras.length > 0 && pivot.sourceXml && parseXml(pivot.sourceXml).documentElement.getAttribute("dataCaption") !==
|
|
17192
|
+
if (extras.length > 0 && pivot.sourceXml && parseXml(pivot.sourceXml).documentElement.getAttribute("dataCaption") !== pivotCaptions(pivot).values)
|
|
17117
17193
|
throw new Error("This PivotTable uses unsupported Values header captions.");
|
|
17118
17194
|
if (!Array.isArray(extras) || extras.length > 15 || extras.some(
|
|
17119
17195
|
(measure) => !measure || !pivot.fields.includes(measure.field) || !PIVOT_AGGREGATES.includes(measure.aggregate) || typeof measure.caption !== "string" || !measure.caption.trim() || measure.caption.length > 255 || pivot.fields.some((field) => field.toLowerCase() === measure.caption.toLowerCase())
|
|
@@ -17132,6 +17208,7 @@ var init_data = __esm({
|
|
|
17132
17208
|
init_model();
|
|
17133
17209
|
init_xml2();
|
|
17134
17210
|
init_axes();
|
|
17211
|
+
init_captions();
|
|
17135
17212
|
init_date_groups();
|
|
17136
17213
|
init_groups();
|
|
17137
17214
|
init_subtotals();
|
|
@@ -17180,24 +17257,7 @@ function aggregateValues(records, field, type) {
|
|
|
17180
17257
|
const sum3 = numbers3.reduce((total2, value) => total2 + value, 0);
|
|
17181
17258
|
return type === "average" ? sum3 / numbers3.length : sum3;
|
|
17182
17259
|
}
|
|
17183
|
-
|
|
17184
|
-
return {
|
|
17185
|
-
rows: (pivot.columnField ? 2 : 1) + (pivot.pageFilter ? 2 : 0),
|
|
17186
|
-
width: rowLabels + (pivot.columnField ? columnItems + 1 : 1)
|
|
17187
|
-
};
|
|
17188
|
-
}
|
|
17189
|
-
function pivotHeaders(pivot, columns, labels, label5) {
|
|
17190
|
-
const rowLabels = pivot.layout === "compact" ? ["Row Labels"] : pivot.valuesPosition === "first" ? ["Values", ...labels] : pivot.valuesPosition === "between" ? [labels[0], "Values", labels[1]] : [...labels, "Values"];
|
|
17191
|
-
return pivot.columnField ? [
|
|
17192
|
-
[
|
|
17193
|
-
...rowLabels.map(() => null),
|
|
17194
|
-
pivot.layout === "compact" ? "Column Labels" : pivot.columnField,
|
|
17195
|
-
...columns.map(() => null)
|
|
17196
|
-
],
|
|
17197
|
-
[...rowLabels, ...columns.map(label5), "Grand Total"]
|
|
17198
|
-
] : [[...rowLabels, null]];
|
|
17199
|
-
}
|
|
17200
|
-
var pivotMeasures, DIV0, pivotMeasureNumber, pivotNumbers;
|
|
17260
|
+
var pivotMeasures, DIV0, pivotMeasureNumber;
|
|
17201
17261
|
var init_measures = __esm({
|
|
17202
17262
|
"xlsx/pivot/measures.ts"() {
|
|
17203
17263
|
init_model();
|
|
@@ -17207,277 +17267,6 @@ var init_measures = __esm({
|
|
|
17207
17267
|
];
|
|
17208
17268
|
DIV0 = { error: "#DIV/0!" };
|
|
17209
17269
|
pivotMeasureNumber = (pivot, records, measure) => aggregateValues(records, pivot.fields.indexOf(measure.field), measure.aggregate);
|
|
17210
|
-
pivotNumbers = (pivot, records) => pivotMeasures(pivot).map((measure) => pivotMeasureNumber(pivot, records, measure));
|
|
17211
|
-
}
|
|
17212
|
-
});
|
|
17213
|
-
|
|
17214
|
-
// xlsx/pivot/hierarchy-first.ts
|
|
17215
|
-
function appendFirstPivotValues(pivot, context) {
|
|
17216
|
-
const {
|
|
17217
|
-
rowItems,
|
|
17218
|
-
secondRowItems,
|
|
17219
|
-
columnItems,
|
|
17220
|
-
children: children2,
|
|
17221
|
-
innerIndices,
|
|
17222
|
-
groups,
|
|
17223
|
-
details,
|
|
17224
|
-
buckets,
|
|
17225
|
-
width,
|
|
17226
|
-
rowLabels,
|
|
17227
|
-
top,
|
|
17228
|
-
bottom,
|
|
17229
|
-
append
|
|
17230
|
-
} = context;
|
|
17231
|
-
const compact = pivot.layout === "compact";
|
|
17232
|
-
const tabular = !pivot.layout || pivot.layout === "tabular";
|
|
17233
|
-
const blank = () => Array(width - rowLabels).fill(null);
|
|
17234
|
-
pivotMeasures(pivot).forEach((measure, m) => {
|
|
17235
|
-
const numbers3 = (keys, records) => [
|
|
17236
|
-
...columnItems.map(
|
|
17237
|
-
(column2) => pivotMeasureNumber(
|
|
17238
|
-
pivot,
|
|
17239
|
-
buckets.get(JSON.stringify([...keys, pivotValueKey(column2)])) ?? [],
|
|
17240
|
-
measure
|
|
17241
|
-
)
|
|
17242
|
-
),
|
|
17243
|
-
pivotMeasureNumber(pivot, records, measure)
|
|
17244
|
-
];
|
|
17245
|
-
if (!tabular)
|
|
17246
|
-
append([measure.caption, ...Array(rowLabels - 1).fill(null)], blank(), {
|
|
17247
|
-
indices: [m],
|
|
17248
|
-
measure: m
|
|
17249
|
-
});
|
|
17250
|
-
let first2 = true;
|
|
17251
|
-
rowItems.forEach((outer, outerIndex) => {
|
|
17252
|
-
const key = pivotValueKey(outer);
|
|
17253
|
-
const group = groups.get(key) ?? [];
|
|
17254
|
-
if (!tabular)
|
|
17255
|
-
append(
|
|
17256
|
-
compact ? [pivotItemLabel(outer)] : [null, pivotItemLabel(outer), null],
|
|
17257
|
-
top ? numbers3([key], group) : blank(),
|
|
17258
|
-
{ indices: [m, outerIndex], measure: m },
|
|
17259
|
-
compact ? 1 : 0
|
|
17260
|
-
);
|
|
17261
|
-
const innerKeys = [...children2.get(key)].sort(
|
|
17262
|
-
(a2, b) => innerIndices.get(a2) - innerIndices.get(b)
|
|
17263
|
-
);
|
|
17264
|
-
innerKeys.forEach((innerKey, child3) => {
|
|
17265
|
-
const innerIndex = innerIndices.get(innerKey);
|
|
17266
|
-
append(
|
|
17267
|
-
compact ? [pivotItemLabel(secondRowItems[innerIndex])] : [
|
|
17268
|
-
tabular && first2 ? measure.caption : null,
|
|
17269
|
-
pivot.repeatLabels || tabular && child3 === 0 ? pivotItemLabel(outer) : null,
|
|
17270
|
-
pivotItemLabel(secondRowItems[innerIndex])
|
|
17271
|
-
],
|
|
17272
|
-
numbers3([key, innerKey], details.get(JSON.stringify([key, innerKey]))),
|
|
17273
|
-
{ indices: [m, outerIndex, innerIndex], measure: m },
|
|
17274
|
-
compact ? 2 : 0
|
|
17275
|
-
);
|
|
17276
|
-
first2 = false;
|
|
17277
|
-
});
|
|
17278
|
-
if (bottom)
|
|
17279
|
-
append(
|
|
17280
|
-
compact ? [`${String(pivotItemLabel(outer))} Total`] : [null, `${String(pivotItemLabel(outer))} Total`, null],
|
|
17281
|
-
numbers3([key], group),
|
|
17282
|
-
{ indices: [m, outerIndex], measure: m, type: "default" },
|
|
17283
|
-
compact ? 1 : 0
|
|
17284
|
-
);
|
|
17285
|
-
});
|
|
17286
|
-
});
|
|
17287
|
-
}
|
|
17288
|
-
var init_hierarchy_first = __esm({
|
|
17289
|
-
"xlsx/pivot/hierarchy-first.ts"() {
|
|
17290
|
-
init_data();
|
|
17291
|
-
init_measures();
|
|
17292
|
-
}
|
|
17293
|
-
});
|
|
17294
|
-
|
|
17295
|
-
// xlsx/pivot/hierarchy.ts
|
|
17296
|
-
function hierarchicalPivotGrid(pivot) {
|
|
17297
|
-
const rowItems = pivotItems(pivot, pivot.rowField);
|
|
17298
|
-
const secondRowItems = pivotItems(pivot, pivot.secondRowField);
|
|
17299
|
-
const columnItems = pivot.columnField ? pivotItems(pivot, pivot.columnField) : [];
|
|
17300
|
-
const outerField = pivot.fields.indexOf(pivot.rowField);
|
|
17301
|
-
const innerField = pivot.fields.indexOf(pivot.secondRowField);
|
|
17302
|
-
const columnField = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
17303
|
-
const layout2 = pivot.layout ?? "tabular";
|
|
17304
|
-
const compact = layout2 === "compact";
|
|
17305
|
-
const firstValues = pivot.valuesPosition === "first";
|
|
17306
|
-
const between = pivot.valuesPosition === "between";
|
|
17307
|
-
const measures = pivotMeasures(pivot);
|
|
17308
|
-
const top = firstValues && layout2 !== "tabular" && pivot.subtotals !== false && (pivot.subtotalPosition ?? "top") === "top";
|
|
17309
|
-
const bottom = pivot.subtotals !== false && !top;
|
|
17310
|
-
const rowLabelColumns = compact ? 1 : 3;
|
|
17311
|
-
const groups = /* @__PURE__ */ new Map();
|
|
17312
|
-
const details = /* @__PURE__ */ new Map();
|
|
17313
|
-
const children2 = /* @__PURE__ */ new Map();
|
|
17314
|
-
const innerIndices = new Map(secondRowItems.map((item, index2) => [pivotValueKey(item), index2]));
|
|
17315
|
-
const buckets = /* @__PURE__ */ new Map();
|
|
17316
|
-
const collect = (map, key, record) => {
|
|
17317
|
-
const list = map.get(key);
|
|
17318
|
-
if (list) list.push(record);
|
|
17319
|
-
else map.set(key, [record]);
|
|
17320
|
-
};
|
|
17321
|
-
for (const record of pivot.records) {
|
|
17322
|
-
const outer = pivotValueKey(record[outerField] ?? null);
|
|
17323
|
-
const inner = pivotValueKey(record[innerField] ?? null);
|
|
17324
|
-
collect(groups, outer, record);
|
|
17325
|
-
collect(details, JSON.stringify([outer, inner]), record);
|
|
17326
|
-
if (!children2.has(outer)) children2.set(outer, /* @__PURE__ */ new Set());
|
|
17327
|
-
children2.get(outer).add(inner);
|
|
17328
|
-
if (pivot.columnField) {
|
|
17329
|
-
const column2 = pivotValueKey(record[columnField] ?? null);
|
|
17330
|
-
for (const key of [[], [outer], [outer, inner]])
|
|
17331
|
-
collect(buckets, JSON.stringify([...key, column2]), record);
|
|
17332
|
-
}
|
|
17333
|
-
}
|
|
17334
|
-
const dimensions = pivotHeaderDimensions(pivot, columnItems.length, rowLabelColumns);
|
|
17335
|
-
const rows = (details.size + rowItems.length * Number(bottom) + 1) * measures.length + rowItems.length * Number(layout2 !== "tabular") * (firstValues ? measures.length : 1) + (firstValues ? measures.length : between ? rowItems.length * measures.length : details.size) * Number(layout2 !== "tabular") + dimensions.rows;
|
|
17336
|
-
if (rows * dimensions.width > 1e6) throw new Error("The PivotTable result is too large.");
|
|
17337
|
-
const labels = compact ? ["Row Labels"] : [pivot.rowField, pivot.secondRowField];
|
|
17338
|
-
const values2 = pivotHeaders(pivot, columnItems, labels, label2);
|
|
17339
|
-
const firstDataRow = values2.length;
|
|
17340
|
-
const indents = values2.map(() => 0);
|
|
17341
|
-
const rowEntries = [];
|
|
17342
|
-
const append = (labels2, numbers4, entry3, indent = 0) => {
|
|
17343
|
-
values2.push([...labels2, ...numbers4]);
|
|
17344
|
-
rowEntries.push(entry3);
|
|
17345
|
-
indents.push(indent);
|
|
17346
|
-
};
|
|
17347
|
-
const bands = (keys, records) => [
|
|
17348
|
-
...columnItems.map(
|
|
17349
|
-
(column2) => pivotNumbers(pivot, buckets.get(JSON.stringify([...keys, pivotValueKey(column2)])) ?? [])
|
|
17350
|
-
),
|
|
17351
|
-
pivotNumbers(pivot, records)
|
|
17352
|
-
];
|
|
17353
|
-
const numbers3 = (keys, records) => bands(keys, records).flat();
|
|
17354
|
-
const appendMeasures = (labels2, keys, records, indices, type) => {
|
|
17355
|
-
const values3 = bands(keys, records);
|
|
17356
|
-
measures.forEach(
|
|
17357
|
-
(measure, m) => append(
|
|
17358
|
-
type ? [
|
|
17359
|
-
`${type === "grand" ? "Total" : String(labels2[0])} ${measure.caption}`,
|
|
17360
|
-
...Array(rowLabelColumns - 1).fill(null)
|
|
17361
|
-
] : compact ? [measure.caption] : [
|
|
17362
|
-
...labels2.map(
|
|
17363
|
-
(label5) => layout2 === "tabular" && m === 0 || pivot.repeatLabels ? label5 : null
|
|
17364
|
-
),
|
|
17365
|
-
measure.caption
|
|
17366
|
-
],
|
|
17367
|
-
values3.map((band) => band[m] ?? null),
|
|
17368
|
-
{ indices: type ? indices : [...indices, m], measure: m, ...type ? { type } : {} },
|
|
17369
|
-
compact && !type ? 2 : 0
|
|
17370
|
-
)
|
|
17371
|
-
);
|
|
17372
|
-
};
|
|
17373
|
-
if (firstValues)
|
|
17374
|
-
appendFirstPivotValues(pivot, {
|
|
17375
|
-
rowItems,
|
|
17376
|
-
secondRowItems,
|
|
17377
|
-
columnItems,
|
|
17378
|
-
children: children2,
|
|
17379
|
-
innerIndices,
|
|
17380
|
-
groups,
|
|
17381
|
-
details,
|
|
17382
|
-
buckets,
|
|
17383
|
-
width: dimensions.width,
|
|
17384
|
-
rowLabels: rowLabelColumns,
|
|
17385
|
-
top,
|
|
17386
|
-
bottom,
|
|
17387
|
-
append
|
|
17388
|
-
});
|
|
17389
|
-
else
|
|
17390
|
-
rowItems.forEach((outer, outerIndex) => {
|
|
17391
|
-
const key = pivotValueKey(outer);
|
|
17392
|
-
if (layout2 !== "tabular")
|
|
17393
|
-
append(
|
|
17394
|
-
[label2(outer), ...Array(rowLabelColumns - 1).fill(null)],
|
|
17395
|
-
top ? numbers3([key], groups.get(key) ?? []) : Array(dimensions.width - rowLabelColumns).fill(null),
|
|
17396
|
-
{ indices: [outerIndex] }
|
|
17397
|
-
);
|
|
17398
|
-
let first2 = true;
|
|
17399
|
-
const innerKeys = [...children2.get(key)].sort(
|
|
17400
|
-
(a2, b) => innerIndices.get(a2) - innerIndices.get(b)
|
|
17401
|
-
);
|
|
17402
|
-
if (between)
|
|
17403
|
-
measures.forEach((measure, m) => {
|
|
17404
|
-
if (layout2 !== "tabular")
|
|
17405
|
-
append(
|
|
17406
|
-
compact ? [measure.caption] : [pivot.repeatLabels ? label2(outer) : null, measure.caption, null],
|
|
17407
|
-
Array(dimensions.width - rowLabelColumns).fill(null),
|
|
17408
|
-
{ indices: [outerIndex, m], measure: m },
|
|
17409
|
-
compact ? 1 : 0
|
|
17410
|
-
);
|
|
17411
|
-
innerKeys.forEach((innerKey, child3) => {
|
|
17412
|
-
const innerIndex = innerIndices.get(innerKey);
|
|
17413
|
-
const keys = [key, innerKey];
|
|
17414
|
-
const records = details.get(JSON.stringify(keys));
|
|
17415
|
-
append(
|
|
17416
|
-
compact ? [label2(secondRowItems[innerIndex])] : [
|
|
17417
|
-
pivot.repeatLabels || layout2 === "tabular" && m === 0 && child3 === 0 ? label2(outer) : null,
|
|
17418
|
-
layout2 === "tabular" && child3 === 0 ? measure.caption : null,
|
|
17419
|
-
label2(secondRowItems[innerIndex])
|
|
17420
|
-
],
|
|
17421
|
-
[
|
|
17422
|
-
...columnItems.map(
|
|
17423
|
-
(column2) => pivotMeasureNumber(
|
|
17424
|
-
pivot,
|
|
17425
|
-
buckets.get(JSON.stringify([...keys, pivotValueKey(column2)])) ?? [],
|
|
17426
|
-
measure
|
|
17427
|
-
)
|
|
17428
|
-
),
|
|
17429
|
-
pivotMeasureNumber(pivot, records, measure)
|
|
17430
|
-
],
|
|
17431
|
-
{ indices: [outerIndex, m, innerIndex], measure: m },
|
|
17432
|
-
compact ? 2 : 0
|
|
17433
|
-
);
|
|
17434
|
-
});
|
|
17435
|
-
});
|
|
17436
|
-
else
|
|
17437
|
-
innerKeys.forEach((innerKey) => {
|
|
17438
|
-
const innerIndex = innerIndices.get(innerKey);
|
|
17439
|
-
const inner = secondRowItems[innerIndex];
|
|
17440
|
-
const keys = [key, innerKey];
|
|
17441
|
-
const records = details.get(JSON.stringify(keys));
|
|
17442
|
-
if (!records) return;
|
|
17443
|
-
if (layout2 !== "tabular")
|
|
17444
|
-
append(
|
|
17445
|
-
compact ? [label2(inner)] : [pivot.repeatLabels ? label2(outer) : null, label2(inner), null],
|
|
17446
|
-
Array(dimensions.width - rowLabelColumns).fill(null),
|
|
17447
|
-
{ indices: [outerIndex, innerIndex] },
|
|
17448
|
-
compact ? 1 : 0
|
|
17449
|
-
);
|
|
17450
|
-
appendMeasures(
|
|
17451
|
-
[pivot.repeatLabels || first2 ? label2(outer) : null, label2(inner)],
|
|
17452
|
-
keys,
|
|
17453
|
-
records,
|
|
17454
|
-
[outerIndex, innerIndex]
|
|
17455
|
-
);
|
|
17456
|
-
first2 = false;
|
|
17457
|
-
});
|
|
17458
|
-
if (bottom)
|
|
17459
|
-
appendMeasures([label2(outer)], [key], groups.get(key) ?? [], [outerIndex], "default");
|
|
17460
|
-
});
|
|
17461
|
-
appendMeasures([], [], pivot.records, [0], "grand");
|
|
17462
|
-
return {
|
|
17463
|
-
values: values2,
|
|
17464
|
-
rowItems,
|
|
17465
|
-
secondRowItems,
|
|
17466
|
-
columnItems,
|
|
17467
|
-
rowEntries,
|
|
17468
|
-
firstDataRow,
|
|
17469
|
-
rowLabelColumns,
|
|
17470
|
-
indents,
|
|
17471
|
-
firstHeaderRow: 1
|
|
17472
|
-
};
|
|
17473
|
-
}
|
|
17474
|
-
var label2;
|
|
17475
|
-
var init_hierarchy = __esm({
|
|
17476
|
-
"xlsx/pivot/hierarchy.ts"() {
|
|
17477
|
-
init_data();
|
|
17478
|
-
init_hierarchy_first();
|
|
17479
|
-
init_measures();
|
|
17480
|
-
label2 = pivotItemLabel;
|
|
17481
17270
|
}
|
|
17482
17271
|
});
|
|
17483
17272
|
|
|
@@ -17486,6 +17275,7 @@ function pivotColumnEntries(pivot) {
|
|
|
17486
17275
|
const names2 = pivotColumnFields(pivot);
|
|
17487
17276
|
const items = names2.map((name2) => pivotItems(pivot, name2));
|
|
17488
17277
|
const entries = [];
|
|
17278
|
+
const functions = names2.map((name2) => fieldSubtotalFunctions(pivot, name2));
|
|
17489
17279
|
if (names2.length) {
|
|
17490
17280
|
const order = items.map(
|
|
17491
17281
|
(list) => new Map(list.map((item, index2) => [pivotValueKey(item), index2]))
|
|
@@ -17520,7 +17310,9 @@ function pivotColumnEntries(pivot) {
|
|
|
17520
17310
|
if (level === names2.length - 1) entries.push({ kind: "leaf", ...entry3 });
|
|
17521
17311
|
else {
|
|
17522
17312
|
visit(child3[1], level + 1, here.path, here.values, here.keys);
|
|
17523
|
-
|
|
17313
|
+
const own = functions[level];
|
|
17314
|
+
if (own === "auto") entries.push({ kind: "subtotal", ...entry3 });
|
|
17315
|
+
else for (const fn of own) entries.push({ kind: "subtotal", ...entry3, fn });
|
|
17524
17316
|
}
|
|
17525
17317
|
}
|
|
17526
17318
|
};
|
|
@@ -17529,26 +17321,31 @@ function pivotColumnEntries(pivot) {
|
|
|
17529
17321
|
entries.push({ kind: "grand", path: [], key: "", values: [] });
|
|
17530
17322
|
return { names: names2, items, entries };
|
|
17531
17323
|
}
|
|
17532
|
-
function pivotColumnDimensions(pivot, columns, labelColumns) {
|
|
17533
|
-
const measures = 1 + (pivot.additionalValues?.length ?? 0);
|
|
17324
|
+
function pivotColumnDimensions(pivot, columns, labelColumns, valuesOnRows = false) {
|
|
17325
|
+
const measures = valuesOnRows ? 1 : 1 + (pivot.additionalValues?.length ?? 0);
|
|
17534
17326
|
const levels = columns.names.length;
|
|
17535
17327
|
return {
|
|
17536
17328
|
rows: (levels ? levels + 1 + Number(measures > 1) : 1) + (pivot.pageFilter ? 2 : 0),
|
|
17537
17329
|
width: labelColumns + (levels ? columns.entries.length : 1) * measures
|
|
17538
17330
|
};
|
|
17539
17331
|
}
|
|
17540
|
-
function pivotColumnHeaders(pivot, columns, rowLabels) {
|
|
17541
|
-
const measures = pivotMeasures(pivot);
|
|
17332
|
+
function pivotColumnHeaders(pivot, columns, rowLabels, valuesOnRows = false) {
|
|
17333
|
+
const measures = valuesOnRows ? pivotMeasures(pivot).slice(0, 1) : pivotMeasures(pivot);
|
|
17542
17334
|
const count2 = measures.length;
|
|
17543
17335
|
const levels = columns.names.length;
|
|
17544
|
-
if (!levels)
|
|
17336
|
+
if (!levels)
|
|
17337
|
+
return [
|
|
17338
|
+
[...rowLabels, ...valuesOnRows ? [null] : measures.map((measure) => measure.caption)]
|
|
17339
|
+
];
|
|
17545
17340
|
const compact = pivot.layout === "compact";
|
|
17546
17341
|
const labelColumns = rowLabels.length;
|
|
17547
17342
|
const width = labelColumns + columns.entries.length * count2;
|
|
17548
17343
|
const rows = levels + 1 + Number(count2 > 1);
|
|
17549
17344
|
const grid = Array.from({ length: rows }, () => Array(width).fill(null));
|
|
17550
|
-
if (count2 === 1) grid[0][0] = pivot.valueCaption;
|
|
17551
|
-
const
|
|
17345
|
+
if (count2 === 1 && !valuesOnRows) grid[0][0] = pivot.valueCaption;
|
|
17346
|
+
const caps = pivotCaptions(pivot);
|
|
17347
|
+
const labelOf = pivotItemLabeler(pivot);
|
|
17348
|
+
const titles = compact ? [caps.columnLabels] : [...columns.names, ...count2 > 1 ? [caps.values] : []];
|
|
17552
17349
|
titles.forEach((title, i) => {
|
|
17553
17350
|
grid[0][labelColumns + i] = title;
|
|
17554
17351
|
});
|
|
@@ -17561,16 +17358,17 @@ function pivotColumnHeaders(pivot, columns, rowLabels) {
|
|
|
17561
17358
|
if (entry3.kind === "leaf") {
|
|
17562
17359
|
entry3.path.forEach((_index, level) => {
|
|
17563
17360
|
const continued = entry3.path.slice(0, level + 1).every((p, i) => p === previous[i]);
|
|
17564
|
-
if (!continued) grid[1 + level][at] =
|
|
17361
|
+
if (!continued) grid[1 + level][at] = labelOf(columns.names[level], entry3.values[level]);
|
|
17565
17362
|
});
|
|
17566
17363
|
previous = entry3.path;
|
|
17567
17364
|
if (count2 > 1) measures.forEach((measure, m) => grid[rows - 1][at + m] = measure.caption);
|
|
17568
17365
|
return;
|
|
17569
17366
|
}
|
|
17570
17367
|
const row2 = entry3.kind === "grand" ? 1 : entry3.path.length;
|
|
17571
|
-
const name2 = entry3.kind === "grand" ? "" : String(
|
|
17368
|
+
const name2 = entry3.kind === "grand" ? "" : String(labelOf(columns.names[entry3.path.length - 1], entry3.values.at(-1)));
|
|
17572
17369
|
measures.forEach((measure, m) => {
|
|
17573
|
-
|
|
17370
|
+
const custom = entry3.fn ? caps.functions[entry3.fn] : void 0;
|
|
17371
|
+
grid[row2][at + m] = custom ? count2 === 1 ? `${name2} ${custom}` : `${name2} ${custom} of ${measure.field}` : count2 === 1 ? entry3.kind === "grand" ? caps.grandTotal : fillCaption(caps.subtotal, name2) : entry3.kind === "grand" ? fillCaption(caps.measureTotal, measure.caption) : `${name2} ${measure.caption}`;
|
|
17574
17372
|
});
|
|
17575
17373
|
});
|
|
17576
17374
|
return grid;
|
|
@@ -17595,20 +17393,22 @@ function pivotColumnItemsXml(entries, measures, remap) {
|
|
|
17595
17393
|
const prefix = sharedPrefix(path2, previous);
|
|
17596
17394
|
const xs = path2.slice(prefix).map((index2) => `<x${attrs({ v: index2 || void 0 })}/>`);
|
|
17597
17395
|
out.push(
|
|
17598
|
-
`<i${attrs({ t: entry3.kind === "subtotal" ? "default" : void 0, r: prefix || void 0, i: m || void 0 })}>${xs.join("")}</i>`
|
|
17396
|
+
`<i${attrs({ t: entry3.kind === "subtotal" ? entry3.fn ? PIVOT_SUBTOTALS[entry3.fn].item : "default" : void 0, r: prefix || void 0, i: m || void 0 })}>${xs.join("")}</i>`
|
|
17599
17397
|
);
|
|
17600
17398
|
previous = path2;
|
|
17601
17399
|
}
|
|
17602
17400
|
return `<colItems count="${out.length}">${out.join("")}</colItems>`;
|
|
17603
17401
|
}
|
|
17604
|
-
var SEPARATOR,
|
|
17402
|
+
var SEPARATOR, columnKey, recordColumnKeys;
|
|
17605
17403
|
var init_columns = __esm({
|
|
17606
17404
|
"xlsx/pivot/columns.ts"() {
|
|
17607
17405
|
init_xml_out();
|
|
17608
17406
|
init_data();
|
|
17407
|
+
init_item_labels();
|
|
17408
|
+
init_captions();
|
|
17609
17409
|
init_measures();
|
|
17410
|
+
init_subtotals();
|
|
17610
17411
|
SEPARATOR = "";
|
|
17611
|
-
label3 = pivotItemLabel;
|
|
17612
17412
|
columnKey = (keys, depth) => keys.slice(0, depth).join(SEPARATOR);
|
|
17613
17413
|
recordColumnKeys = (record, indices) => indices.map((index2) => pivotValueKey(record[index2] ?? null));
|
|
17614
17414
|
}
|
|
@@ -17618,6 +17418,10 @@ var init_columns = __esm({
|
|
|
17618
17418
|
function nestedPivotGrid(pivot) {
|
|
17619
17419
|
const names2 = pivotRowFields(pivot);
|
|
17620
17420
|
const depth = names2.length;
|
|
17421
|
+
const valuesAt = pivotValuesIndex(pivot);
|
|
17422
|
+
const onRows = valuesAt >= 0;
|
|
17423
|
+
const levels = depth + (onRows ? 1 : 0);
|
|
17424
|
+
const fieldOf = (level) => !onRows || level < valuesAt ? level : level === valuesAt ? -1 : level - 1;
|
|
17621
17425
|
const axisItems = names2.map((name2) => pivotItems(pivot, name2));
|
|
17622
17426
|
const itemIndices = axisItems.map(
|
|
17623
17427
|
(items) => new Map(items.map((item, index2) => [pivotValueKey(item), index2]))
|
|
@@ -17629,125 +17433,170 @@ function nestedPivotGrid(pivot) {
|
|
|
17629
17433
|
const compact = layout2 === "compact";
|
|
17630
17434
|
const tabular = layout2 === "tabular";
|
|
17631
17435
|
const above = !tabular && (pivot.subtotalPosition ?? "top") === "top";
|
|
17632
|
-
const labelColumns = compact ? 1 :
|
|
17436
|
+
const labelColumns = compact ? 1 : levels;
|
|
17633
17437
|
const measures = pivotMeasures(pivot);
|
|
17438
|
+
const functions = names2.map((name2) => fieldSubtotalFunctions(pivot, name2));
|
|
17439
|
+
const caps = pivotCaptions(pivot);
|
|
17440
|
+
const labelOf = pivotItemLabeler(pivot);
|
|
17634
17441
|
const root = node(0, null);
|
|
17635
17442
|
for (const record of pivot.records) {
|
|
17636
17443
|
const keys = recordColumnKeys(record, columnFields);
|
|
17637
17444
|
let current = root;
|
|
17638
|
-
for (let
|
|
17639
|
-
if (
|
|
17640
|
-
const value = record[fieldIndices[
|
|
17445
|
+
for (let field = -1; field < depth; field++) {
|
|
17446
|
+
if (field >= 0) {
|
|
17447
|
+
const value = record[fieldIndices[field]] ?? null;
|
|
17641
17448
|
const key = pivotValueKey(value);
|
|
17642
17449
|
let child3 = current.children.get(key);
|
|
17643
17450
|
if (!child3) {
|
|
17644
|
-
child3 = node(itemIndices[
|
|
17451
|
+
child3 = node(itemIndices[field].get(key), value);
|
|
17645
17452
|
current.children.set(key, child3);
|
|
17646
17453
|
}
|
|
17647
17454
|
current = child3;
|
|
17648
17455
|
}
|
|
17649
17456
|
current.records.push(record);
|
|
17650
|
-
for (let
|
|
17651
|
-
const key = columnKey(keys,
|
|
17457
|
+
for (let width2 = 1; width2 <= keys.length; width2++) {
|
|
17458
|
+
const key = columnKey(keys, width2);
|
|
17652
17459
|
const list = current.columns.get(key);
|
|
17653
17460
|
if (list) list.push(record);
|
|
17654
17461
|
else current.columns.set(key, [record]);
|
|
17655
17462
|
}
|
|
17656
17463
|
}
|
|
17657
17464
|
}
|
|
17658
|
-
const dimensions = pivotColumnDimensions(pivot, columns, labelColumns);
|
|
17659
|
-
const
|
|
17660
|
-
|
|
17661
|
-
|
|
17662
|
-
|
|
17663
|
-
rows++;
|
|
17664
|
-
if (level < depth - 1) {
|
|
17665
|
-
const f = functions[level];
|
|
17666
|
-
rows += f === "auto" ? 1 : f.length;
|
|
17667
|
-
count2(child3, level + 1);
|
|
17668
|
-
}
|
|
17669
|
-
}
|
|
17670
|
-
};
|
|
17671
|
-
count2(root, 0);
|
|
17672
|
-
if ((rows + dimensions.rows) * dimensions.width > MAX_CELLS)
|
|
17673
|
-
throw new Error("The PivotTable result is too large.");
|
|
17674
|
-
const values2 = pivotColumnHeaders(pivot, columns, compact ? ["Row Labels"] : names2);
|
|
17675
|
-
const firstDataRow = values2.length;
|
|
17676
|
-
const indents = values2.map(() => 0);
|
|
17465
|
+
const dimensions = pivotColumnDimensions(pivot, columns, labelColumns, onRows);
|
|
17466
|
+
const rowTitles = names2.map((name2) => name2);
|
|
17467
|
+
if (onRows) rowTitles.splice(valuesAt, 0, caps.values);
|
|
17468
|
+
let values2 = [];
|
|
17469
|
+
let indents = [];
|
|
17677
17470
|
const rowEntries = [];
|
|
17678
|
-
|
|
17679
|
-
|
|
17680
|
-
|
|
17681
|
-
);
|
|
17682
|
-
const
|
|
17683
|
-
|
|
17684
|
-
|
|
17685
|
-
(
|
|
17686
|
-
|
|
17687
|
-
|
|
17471
|
+
let counting = true;
|
|
17472
|
+
let rowCount = 0;
|
|
17473
|
+
const width = dimensions.width - labelColumns;
|
|
17474
|
+
const blanks = () => Array(width).fill(null);
|
|
17475
|
+
const cells2 = (group, rowFn, measure) => columns.entries.flatMap((entry3) => {
|
|
17476
|
+
const records = entry3.kind === "grand" ? group.records : group.columns.get(entry3.key) ?? [];
|
|
17477
|
+
const picked = measure === void 0 ? measures : [measures[measure]];
|
|
17478
|
+
if (rowFn && entry3.fn && rowFn !== entry3.fn) return picked.map(() => null);
|
|
17479
|
+
const fn = rowFn ?? entry3.fn;
|
|
17480
|
+
return picked.map(
|
|
17481
|
+
(one2) => fn ? aggregateValues(records, pivot.fields.indexOf(one2.field), fn) : pivotMeasureNumber(pivot, records, one2)
|
|
17482
|
+
);
|
|
17483
|
+
});
|
|
17484
|
+
const labelCells = (path2, shown, level, text2) => {
|
|
17688
17485
|
if (compact) return [text2];
|
|
17689
|
-
const
|
|
17690
|
-
path2.forEach((value,
|
|
17691
|
-
if (shown[
|
|
17486
|
+
const row2 = Array(levels).fill(null);
|
|
17487
|
+
path2.labels.forEach((value, at) => {
|
|
17488
|
+
if (shown[at]) row2[at] = value;
|
|
17692
17489
|
});
|
|
17693
|
-
|
|
17694
|
-
return
|
|
17490
|
+
row2[level] = text2;
|
|
17491
|
+
return row2;
|
|
17695
17492
|
};
|
|
17696
|
-
const push = (
|
|
17697
|
-
|
|
17493
|
+
const push = (indent, build2) => {
|
|
17494
|
+
if (counting) {
|
|
17495
|
+
if ((++rowCount + dimensions.rows) * dimensions.width > MAX_CELLS)
|
|
17496
|
+
throw new Error("The PivotTable result is too large.");
|
|
17497
|
+
return;
|
|
17498
|
+
}
|
|
17499
|
+
const [cells3, numbers3, entry3] = build2();
|
|
17500
|
+
values2.push([...cells3, ...numbers3]);
|
|
17698
17501
|
rowEntries.push(entry3);
|
|
17699
17502
|
indents.push(compact ? indent : 0);
|
|
17700
17503
|
};
|
|
17701
|
-
const
|
|
17702
|
-
|
|
17703
|
-
|
|
17704
|
-
|
|
17504
|
+
const entryOf = (indices, measure, type) => ({
|
|
17505
|
+
indices,
|
|
17506
|
+
...measure !== void 0 ? { measure } : {},
|
|
17507
|
+
...type ? { type } : {}
|
|
17508
|
+
});
|
|
17509
|
+
const walk = (level, group, measure, path2) => {
|
|
17510
|
+
const field = fieldOf(level);
|
|
17511
|
+
const last = level === levels - 1;
|
|
17512
|
+
const repeated = Array.from(
|
|
17513
|
+
{ length: level },
|
|
17514
|
+
(_v, k) => !!pivot.repeatLabels && fieldOf(k) >= 0
|
|
17515
|
+
);
|
|
17516
|
+
const leafShown = (firsts) => repeated.map((repeat, k) => repeat || tabular && firsts.slice(k + 1).every(Boolean));
|
|
17517
|
+
if (field < 0) {
|
|
17518
|
+
measures.forEach((one2, m) => {
|
|
17519
|
+
const here = {
|
|
17520
|
+
labels: [...path2.labels, one2.caption],
|
|
17521
|
+
indices: [...path2.indices, m],
|
|
17522
|
+
firsts: [...path2.firsts, m === 0]
|
|
17523
|
+
};
|
|
17524
|
+
if (last)
|
|
17525
|
+
return push(level, () => [
|
|
17526
|
+
labelCells(path2, leafShown(here.firsts), level, one2.caption),
|
|
17527
|
+
cells2(group, void 0, m),
|
|
17528
|
+
entryOf(here.indices, m)
|
|
17529
|
+
]);
|
|
17530
|
+
if (!tabular)
|
|
17531
|
+
push(level, () => [
|
|
17532
|
+
labelCells(path2, repeated, level, one2.caption),
|
|
17533
|
+
blanks(),
|
|
17534
|
+
entryOf(here.indices, m)
|
|
17535
|
+
]);
|
|
17536
|
+
walk(level + 1, group, m, here);
|
|
17537
|
+
});
|
|
17538
|
+
return;
|
|
17539
|
+
}
|
|
17540
|
+
const own = functions[field];
|
|
17541
|
+
const valuesAbove = !onRows || valuesAt < level;
|
|
17542
|
+
const showsValue = above && own === "auto" && valuesAbove;
|
|
17543
|
+
const children2 = [...group.children.values()].sort((a2, b) => a2.index - b.index);
|
|
17705
17544
|
children2.forEach((child3, position) => {
|
|
17706
|
-
const here =
|
|
17707
|
-
|
|
17708
|
-
|
|
17709
|
-
|
|
17710
|
-
|
|
17711
|
-
|
|
17712
|
-
|
|
17713
|
-
)
|
|
17714
|
-
|
|
17715
|
-
|
|
17716
|
-
|
|
17545
|
+
const here = {
|
|
17546
|
+
labels: [...path2.labels, labelOf(names2[field], child3.value)],
|
|
17547
|
+
indices: [...path2.indices, child3.index],
|
|
17548
|
+
firsts: [...path2.firsts, position === 0]
|
|
17549
|
+
};
|
|
17550
|
+
const text2 = labelOf(names2[field], child3.value);
|
|
17551
|
+
if (last)
|
|
17552
|
+
return push(level, () => [
|
|
17553
|
+
labelCells(path2, leafShown(here.firsts), level, text2),
|
|
17554
|
+
cells2(child3, void 0, measure),
|
|
17555
|
+
entryOf(here.indices, measure)
|
|
17556
|
+
]);
|
|
17717
17557
|
if (!tabular)
|
|
17718
|
-
push(
|
|
17719
|
-
labelCells(path2, repeated,
|
|
17720
|
-
|
|
17721
|
-
|
|
17722
|
-
|
|
17723
|
-
|
|
17724
|
-
|
|
17725
|
-
const caption = String(
|
|
17558
|
+
push(level, () => [
|
|
17559
|
+
labelCells(path2, repeated, level, text2),
|
|
17560
|
+
showsValue ? cells2(child3, void 0, measure) : blanks(),
|
|
17561
|
+
entryOf(here.indices, measure)
|
|
17562
|
+
]);
|
|
17563
|
+
walk(level + 1, child3, measure, here);
|
|
17564
|
+
if (field === depth - 1) return;
|
|
17565
|
+
const caption = String(text2);
|
|
17566
|
+
const subtotal = (title, fn, one2) => push(level, () => [
|
|
17567
|
+
labelCells(path2, repeated, level, title),
|
|
17568
|
+
cells2(child3, fn, one2),
|
|
17569
|
+
entryOf(here.indices, one2, fn ?? "default")
|
|
17570
|
+
]);
|
|
17726
17571
|
if (own === "auto") {
|
|
17727
|
-
if (
|
|
17728
|
-
|
|
17729
|
-
|
|
17730
|
-
numbers3(child3),
|
|
17731
|
-
{ indices: at, type: "default" },
|
|
17732
|
-
level
|
|
17733
|
-
);
|
|
17572
|
+
if (showsValue) return;
|
|
17573
|
+
if (valuesAbove) subtotal(fillCaption(caps.subtotal, caption), void 0, measure);
|
|
17574
|
+
else measures.forEach((one2, m) => subtotal(`${caption} ${one2.caption}`, void 0, m));
|
|
17734
17575
|
} else
|
|
17735
17576
|
for (const fn of own)
|
|
17736
|
-
|
|
17737
|
-
|
|
17738
|
-
|
|
17739
|
-
|
|
17740
|
-
|
|
17741
|
-
);
|
|
17577
|
+
if (valuesAbove) subtotal(`${caption} ${caps.functions[fn]}`, fn, measure);
|
|
17578
|
+
else
|
|
17579
|
+
measures.forEach(
|
|
17580
|
+
(one2, m) => subtotal(`${caption} ${caps.functions[fn]} of ${one2.field}`, fn, m)
|
|
17581
|
+
);
|
|
17742
17582
|
});
|
|
17743
17583
|
};
|
|
17744
|
-
|
|
17745
|
-
|
|
17746
|
-
|
|
17747
|
-
|
|
17748
|
-
|
|
17749
|
-
|
|
17750
|
-
|
|
17584
|
+
const grand = (text2, measure) => push(0, () => [
|
|
17585
|
+
compact ? [text2] : [text2, ...Array(levels - 1).fill(null)],
|
|
17586
|
+
cells2(root, void 0, measure),
|
|
17587
|
+
entryOf([0], measure, "grand")
|
|
17588
|
+
]);
|
|
17589
|
+
const build = () => {
|
|
17590
|
+
walk(0, root, void 0, { labels: [], indices: [], firsts: [] });
|
|
17591
|
+
if (onRows) measures.forEach((one2, m) => grand(fillCaption(caps.measureTotal, one2.caption), m));
|
|
17592
|
+
else grand(caps.grandTotal);
|
|
17593
|
+
};
|
|
17594
|
+
build();
|
|
17595
|
+
counting = false;
|
|
17596
|
+
values2 = pivotColumnHeaders(pivot, columns, compact ? [caps.rowLabels] : rowTitles, onRows);
|
|
17597
|
+
const firstDataRow = values2.length;
|
|
17598
|
+
indents = values2.map(() => 0);
|
|
17599
|
+
build();
|
|
17751
17600
|
return {
|
|
17752
17601
|
values: values2,
|
|
17753
17602
|
rowItems: axisItems[0],
|
|
@@ -17759,17 +17608,20 @@ function nestedPivotGrid(pivot) {
|
|
|
17759
17608
|
rowEntries,
|
|
17760
17609
|
firstDataRow,
|
|
17761
17610
|
rowLabelColumns: labelColumns,
|
|
17762
|
-
indents
|
|
17611
|
+
indents,
|
|
17612
|
+
...onRows ? { firstHeaderRow: 1 } : {}
|
|
17763
17613
|
};
|
|
17764
17614
|
}
|
|
17765
|
-
var
|
|
17615
|
+
var MAX_CELLS, node;
|
|
17766
17616
|
var init_nested = __esm({
|
|
17767
17617
|
"xlsx/pivot/nested.ts"() {
|
|
17768
17618
|
init_data();
|
|
17619
|
+
init_item_labels();
|
|
17620
|
+
init_axes();
|
|
17769
17621
|
init_columns();
|
|
17770
17622
|
init_measures();
|
|
17623
|
+
init_captions();
|
|
17771
17624
|
init_subtotals();
|
|
17772
|
-
label4 = pivotItemLabel;
|
|
17773
17625
|
MAX_CELLS = 1e6;
|
|
17774
17626
|
node = (index2, value) => ({
|
|
17775
17627
|
index: index2,
|
|
@@ -17784,98 +17636,7 @@ var init_nested = __esm({
|
|
|
17784
17636
|
// xlsx/pivot/aggregate.ts
|
|
17785
17637
|
function pivotGrid(pivot) {
|
|
17786
17638
|
validatePivotFields(pivot);
|
|
17787
|
-
return prependPivotPage(
|
|
17788
|
-
}
|
|
17789
|
-
function pivotDataGrid(pivot) {
|
|
17790
|
-
if (pivot.valuesAxis !== "rows") return nestedPivotGrid(pivot);
|
|
17791
|
-
if (pivot.secondRowField) return hierarchicalPivotGrid(pivot);
|
|
17792
|
-
const rowItems = pivotItems(pivot, pivot.rowField);
|
|
17793
|
-
const columnItems = pivot.columnField ? pivotItems(pivot, pivot.columnField) : [];
|
|
17794
|
-
const compact = pivot.layout === "compact";
|
|
17795
|
-
const headings = pivot.layout !== void 0 && pivot.layout !== "tabular";
|
|
17796
|
-
const dimensions = pivotHeaderDimensions(pivot, columnItems.length, compact ? 1 : 2);
|
|
17797
|
-
const dataRows = (rowItems.length + 1) * (1 + (pivot.additionalValues?.length ?? 0)) + (headings ? rowItems.length : 0);
|
|
17798
|
-
if ((dataRows + dimensions.rows) * dimensions.width > 1e6)
|
|
17799
|
-
throw new Error("The PivotTable result is too large.");
|
|
17800
|
-
const label5 = pivotItemLabel;
|
|
17801
|
-
const values2 = pivotHeaders(pivot, columnItems, [compact ? "Row Labels" : pivot.rowField], label5);
|
|
17802
|
-
const rowField = pivot.fields.indexOf(pivot.rowField);
|
|
17803
|
-
const colField = pivot.columnField ? pivot.fields.indexOf(pivot.columnField) : -1;
|
|
17804
|
-
const groups = /* @__PURE__ */ new Map();
|
|
17805
|
-
const cells2 = /* @__PURE__ */ new Map();
|
|
17806
|
-
const columns = /* @__PURE__ */ new Map();
|
|
17807
|
-
const collect = (map, key, record) => {
|
|
17808
|
-
const found = map.get(key);
|
|
17809
|
-
if (found) found.push(record);
|
|
17810
|
-
else map.set(key, [record]);
|
|
17811
|
-
};
|
|
17812
|
-
for (const record of pivot.records) {
|
|
17813
|
-
const key = pivotValueKey(record[rowField] ?? null);
|
|
17814
|
-
collect(groups, key, record);
|
|
17815
|
-
if (pivot.columnField) {
|
|
17816
|
-
const col = pivotValueKey(record[colField] ?? null);
|
|
17817
|
-
collect(columns, col, record);
|
|
17818
|
-
collect(cells2, JSON.stringify([key, col]), record);
|
|
17819
|
-
}
|
|
17820
|
-
}
|
|
17821
|
-
const firstDataRow = values2.length;
|
|
17822
|
-
const measures = pivotMeasures(pivot);
|
|
17823
|
-
const rowEntries = [];
|
|
17824
|
-
const indents = values2.map(() => 0);
|
|
17825
|
-
const append = (caption, bands, index2, grand = false) => {
|
|
17826
|
-
measures.forEach((measure, m) => {
|
|
17827
|
-
values2.push([
|
|
17828
|
-
...compact ? [grand ? `Total ${measure.caption}` : measure.caption] : [
|
|
17829
|
-
grand ? `Total ${measure.caption}` : pivot.repeatLabels || !headings && m === 0 ? caption : null,
|
|
17830
|
-
grand ? null : measure.caption
|
|
17831
|
-
],
|
|
17832
|
-
...bands.map((band) => band[m] ?? null)
|
|
17833
|
-
]);
|
|
17834
|
-
indents.push(compact && !grand ? 1 : 0);
|
|
17835
|
-
rowEntries.push({
|
|
17836
|
-
indices: grand ? [0] : [index2, m],
|
|
17837
|
-
measure: m,
|
|
17838
|
-
...grand ? { type: "grand" } : {}
|
|
17839
|
-
});
|
|
17840
|
-
});
|
|
17841
|
-
};
|
|
17842
|
-
rowItems.forEach((item, index2) => {
|
|
17843
|
-
const key = pivotValueKey(item);
|
|
17844
|
-
if (headings) {
|
|
17845
|
-
values2.push([label5(item), ...Array(dimensions.width - 1).fill(null)]);
|
|
17846
|
-
rowEntries.push({ indices: [index2] });
|
|
17847
|
-
indents.push(0);
|
|
17848
|
-
}
|
|
17849
|
-
append(
|
|
17850
|
-
label5(item),
|
|
17851
|
-
[
|
|
17852
|
-
...columnItems.map(
|
|
17853
|
-
(col) => pivotNumbers(pivot, cells2.get(JSON.stringify([key, pivotValueKey(col)])) ?? [])
|
|
17854
|
-
),
|
|
17855
|
-
pivotNumbers(pivot, groups.get(key) ?? [])
|
|
17856
|
-
],
|
|
17857
|
-
index2
|
|
17858
|
-
);
|
|
17859
|
-
});
|
|
17860
|
-
append(
|
|
17861
|
-
"Grand Total",
|
|
17862
|
-
[
|
|
17863
|
-
...columnItems.map((col) => pivotNumbers(pivot, columns.get(pivotValueKey(col)) ?? [])),
|
|
17864
|
-
pivotNumbers(pivot, pivot.records)
|
|
17865
|
-
],
|
|
17866
|
-
0,
|
|
17867
|
-
true
|
|
17868
|
-
);
|
|
17869
|
-
return {
|
|
17870
|
-
values: values2,
|
|
17871
|
-
rowItems,
|
|
17872
|
-
columnItems,
|
|
17873
|
-
firstDataRow,
|
|
17874
|
-
rowLabelColumns: compact ? 1 : 2,
|
|
17875
|
-
indents,
|
|
17876
|
-
firstHeaderRow: 1,
|
|
17877
|
-
rowEntries
|
|
17878
|
-
};
|
|
17639
|
+
return prependPivotPage(nestedPivotGrid(pivotPageProjection(pivot)), pivot);
|
|
17879
17640
|
}
|
|
17880
17641
|
function pivotTableAt(sheet, at) {
|
|
17881
17642
|
return sheet.pivotTables?.find((pivot) => rangeContains(pivot.location, at));
|
|
@@ -17885,9 +17646,7 @@ var init_aggregate = __esm({
|
|
|
17885
17646
|
init_address();
|
|
17886
17647
|
init_data();
|
|
17887
17648
|
init_page_filter();
|
|
17888
|
-
init_hierarchy();
|
|
17889
17649
|
init_nested();
|
|
17890
|
-
init_measures();
|
|
17891
17650
|
}
|
|
17892
17651
|
});
|
|
17893
17652
|
|
|
@@ -18042,7 +17801,7 @@ function groupby(args, ctx) {
|
|
|
18042
17801
|
if (rows.length === 0) fail(ERR.CALC);
|
|
18043
17802
|
const groups = /* @__PURE__ */ new Map();
|
|
18044
17803
|
for (const r of rows) {
|
|
18045
|
-
const key =
|
|
17804
|
+
const key = keyOf2(keysM.data[r]);
|
|
18046
17805
|
const found = groups.get(key);
|
|
18047
17806
|
if (found) found.push(r);
|
|
18048
17807
|
else groups.set(key, [r]);
|
|
@@ -18109,8 +17868,8 @@ function pivotby(args, ctx) {
|
|
|
18109
17868
|
const colKeys = /* @__PURE__ */ new Map();
|
|
18110
17869
|
for (const r of used) {
|
|
18111
17870
|
for (const [map, key] of [
|
|
18112
|
-
[rowKeys,
|
|
18113
|
-
[colKeys,
|
|
17871
|
+
[rowKeys, keyOf2(rowsM.data[r])],
|
|
17872
|
+
[colKeys, keyOf2(colsM.data[r])]
|
|
18114
17873
|
]) {
|
|
18115
17874
|
const found = map.get(key);
|
|
18116
17875
|
if (found) found.push(r);
|
|
@@ -18170,7 +17929,7 @@ function pivotby(args, ctx) {
|
|
|
18170
17929
|
];
|
|
18171
17930
|
return new Matrix([header, ...lines]);
|
|
18172
17931
|
}
|
|
18173
|
-
var column, optional,
|
|
17932
|
+
var column, optional, keyOf2, plain2, lazy, GROUPBY_FUNCTIONS;
|
|
18174
17933
|
var init_groupby = __esm({
|
|
18175
17934
|
"xlsx/formula/functions/groupby.ts"() {
|
|
18176
17935
|
init_coerce();
|
|
@@ -18181,7 +17940,7 @@ var init_groupby = __esm({
|
|
|
18181
17940
|
const arg = args[i];
|
|
18182
17941
|
return arg && arg.node.type !== "missing" ? arg.get() : void 0;
|
|
18183
17942
|
};
|
|
18184
|
-
|
|
17943
|
+
keyOf2 = (values2) => JSON.stringify(values2);
|
|
18185
17944
|
plain2 = (v) => v === void 0 || isError(v) ? null : v;
|
|
18186
17945
|
lazy = (name2, syntax, description, minArgs, maxArgs, fn) => ({
|
|
18187
17946
|
name: name2,
|
|
@@ -20958,7 +20717,7 @@ var init_layout = __esm({
|
|
|
20958
20717
|
});
|
|
20959
20718
|
|
|
20960
20719
|
// diagram/hierarchy/index.ts
|
|
20961
|
-
var
|
|
20720
|
+
var init_hierarchy = __esm({
|
|
20962
20721
|
"diagram/hierarchy/index.ts"() {
|
|
20963
20722
|
}
|
|
20964
20723
|
});
|
|
@@ -21336,9 +21095,9 @@ var init_gradient_preset_data = __esm({
|
|
|
21336
21095
|
var init_gradient_presets = __esm({
|
|
21337
21096
|
"drawingml/gradient-presets.ts"() {
|
|
21338
21097
|
init_gradient_preset_data();
|
|
21339
|
-
OFFICE_GRADIENT_PRESET_DATA.map(([
|
|
21098
|
+
OFFICE_GRADIENT_PRESET_DATA.map(([label2], index2) => ({
|
|
21340
21099
|
id: index2 + 1,
|
|
21341
|
-
label:
|
|
21100
|
+
label: label2
|
|
21342
21101
|
}));
|
|
21343
21102
|
}
|
|
21344
21103
|
});
|
|
@@ -21361,7 +21120,7 @@ var init_diagram = __esm({
|
|
|
21361
21120
|
init_types3();
|
|
21362
21121
|
init_engine();
|
|
21363
21122
|
init_layout();
|
|
21364
|
-
|
|
21123
|
+
init_hierarchy();
|
|
21365
21124
|
init_attributes();
|
|
21366
21125
|
init_layout_category();
|
|
21367
21126
|
init_relationships2();
|
|
@@ -21595,8 +21354,8 @@ function parseTable(xml, partName) {
|
|
|
21595
21354
|
if (id !== void 0 && Number.isInteger(id) && id >= 0) column2.sourceId = id;
|
|
21596
21355
|
const fn = att(node2, "totalsRowFunction");
|
|
21597
21356
|
if (fn && fn !== "none") column2.totalsRowFunction = fn;
|
|
21598
|
-
const
|
|
21599
|
-
if (
|
|
21357
|
+
const label2 = att(node2, "totalsRowLabel");
|
|
21358
|
+
if (label2 !== void 0) column2.totalsRowLabel = label2;
|
|
21600
21359
|
const calculated = xFirst(node2, "calculatedColumnFormula");
|
|
21601
21360
|
if (calculated) column2.calculatedColumnFormula = stripFuturePrefixes(xText(calculated));
|
|
21602
21361
|
return column2;
|
|
@@ -22984,15 +22743,15 @@ function derivedFields(pivot, date1904) {
|
|
|
22984
22743
|
function derivedFieldXml(pivot, entry3, date1904) {
|
|
22985
22744
|
const range = { start: entry3.group.start, end: entry3.group.end };
|
|
22986
22745
|
const days = dateGroupDays(entry3.group);
|
|
22987
|
-
const labels = dateUnitLabels(entry3.unit, range, days, date1904);
|
|
22746
|
+
const labels = dateUnitLabels(entry3.unit, range, days, date1904, entry3.group);
|
|
22988
22747
|
const base = pivot.fields.indexOf(entry3.group.field);
|
|
22989
|
-
return `<cacheField${attrs({ name: encodeEscapes(entry3.name), numFmtId: 0, databaseField: false })}><fieldGroup base="${base}"><rangePr${attrs({ autoStart: entry3.autoStart ? void 0 : false, autoEnd: entry3.autoEnd ? void 0 : false, groupBy: entry3.unit, startDate: serialToIso(range.start, date1904), endDate: serialToIso(range.end, date1904), groupInterval: days > 1 ? days : void 0 })}/><groupItems count="${labels.length}">${labels.map((
|
|
22748
|
+
return `<cacheField${attrs({ name: encodeEscapes(entry3.name), numFmtId: 0, databaseField: false })}><fieldGroup base="${base}"><rangePr${attrs({ autoStart: entry3.autoStart ? void 0 : false, autoEnd: entry3.autoEnd ? void 0 : false, groupBy: entry3.unit, startDate: serialToIso(range.start, date1904), endDate: serialToIso(range.end, date1904), groupInterval: days > 1 ? days : void 0 })}/><groupItems count="${labels.length}">${labels.map((label2) => `<s v="${escapeAttr3(label2)}"/>`).join("")}</groupItems></fieldGroup></cacheField>`;
|
|
22990
22749
|
}
|
|
22991
22750
|
function groupXml2(pivot, name2, index2) {
|
|
22992
22751
|
const group = groupOf(pivot, name2);
|
|
22993
22752
|
if (!group) return "";
|
|
22994
22753
|
const labels = numberGroupLabels(group);
|
|
22995
|
-
return `<fieldGroup base="${index2}"><rangePr autoStart="0" autoEnd="0" startNum="${group.start}" endNum="${group.end}" groupInterval="${group.by}"/><groupItems count="${labels.length}">${labels.map((
|
|
22754
|
+
return `<fieldGroup base="${index2}"><rangePr autoStart="0" autoEnd="0" startNum="${group.start}" endNum="${group.end}" groupInterval="${group.by}"/><groupItems count="${labels.length}">${labels.map((label2) => `<s v="${escapeAttr3(label2)}"/>`).join("")}</groupItems></fieldGroup>`;
|
|
22996
22755
|
}
|
|
22997
22756
|
function slicerExt(pivot) {
|
|
22998
22757
|
if (pivot.slicerCacheId === void 0) return "";
|
|
@@ -23025,6 +22784,7 @@ function remapPivotRowEntries(entries, axes2) {
|
|
|
23025
22784
|
(entry3) => entry3.type === "grand" ? entry3 : {
|
|
23026
22785
|
...entry3,
|
|
23027
22786
|
indices: entry3.indices.map((item, axis) => {
|
|
22787
|
+
if (axes2[axis] === null) return item;
|
|
23028
22788
|
const index2 = axes2[axis]?.[item];
|
|
23029
22789
|
if (index2 === void 0) throw new Error("Invalid report row axis item");
|
|
23030
22790
|
return index2;
|
|
@@ -23052,8 +22812,6 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
23052
22812
|
const pivot = expandDateGroups(source2);
|
|
23053
22813
|
const rowNames = pivotRowFields(pivot);
|
|
23054
22814
|
const rowIdx = rowNames.map((name2) => pivot.fields.indexOf(name2));
|
|
23055
|
-
const row2 = rowIdx[0];
|
|
23056
|
-
const second = rowIdx[1] ?? -1;
|
|
23057
22815
|
const page = pivot.pageFilter ? pivot.fields.indexOf(pivot.pageFilter.field) : -1;
|
|
23058
22816
|
const pageItems = page >= 0 ? pivotItems(pivot, pivot.pageFilter.field) : [];
|
|
23059
22817
|
const filtered2 = filteredFields(pivot);
|
|
@@ -23081,7 +22839,10 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
23081
22839
|
const columnIndicesFull = columnNames.map(
|
|
23082
22840
|
(_name, k) => itemIndices(visibleColumns[k], columnItemsFull[k])
|
|
23083
22841
|
);
|
|
23084
|
-
const
|
|
22842
|
+
const valuesAt = pivotValuesIndex(pivot);
|
|
22843
|
+
const levelAxes = [...rowIndicesFull];
|
|
22844
|
+
if (valuesAt >= 0) levelAxes.splice(valuesAt, 0, null);
|
|
22845
|
+
const rowEntries = anyFull && grid.rowEntries ? remapPivotRowEntries(grid.rowEntries, levelAxes) : grid.rowEntries;
|
|
23085
22846
|
const pageOffset = page >= 0 ? 2 : 0;
|
|
23086
22847
|
const col = columnIdx[0] ?? -1;
|
|
23087
22848
|
const measures = pivotMeasures(pivot);
|
|
@@ -23090,13 +22851,17 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
23090
22851
|
const compact = pivot.layout === "compact";
|
|
23091
22852
|
const outline = pivot.layout === "compact" || pivot.layout === "outline";
|
|
23092
22853
|
const top = (pivot.subtotalPosition ?? (outline ? "top" : "bottom")) === "top";
|
|
22854
|
+
const named2 = (field, item) => {
|
|
22855
|
+
const text2 = pivotItemName(pivot, field, item);
|
|
22856
|
+
return text2 === void 0 ? "" : attrs({ n: encodeEscapes(text2) });
|
|
22857
|
+
};
|
|
23093
22858
|
const fields = pivot.fields.map((name2, index2) => {
|
|
23094
22859
|
const isDate = pivot.dateFields?.includes(name2) ?? false;
|
|
23095
22860
|
const at = rowIdx.indexOf(index2);
|
|
23096
22861
|
const colAt = columnIdx.indexOf(index2);
|
|
23097
22862
|
const items2 = index2 === page ? pageItems : at >= 0 ? rowItemsFull[at] : colAt >= 0 ? columnItemsFull[colAt] : groupLabelsOf(pivot, name2) ?? (filtered2.has(name2) || isDate ? pivotItems(pivot, name2) : void 0);
|
|
23098
22863
|
const hidden = hiddenItemKeys(pivot, name2);
|
|
23099
|
-
const functions = at >= 0 ? fieldSubtotalFunctions(pivot, name2) : "auto";
|
|
22864
|
+
const functions = at >= 0 || colAt >= 0 ? fieldSubtotalFunctions(pivot, name2) : "auto";
|
|
23100
22865
|
const automatic = functions === "auto";
|
|
23101
22866
|
const custom = automatic ? [] : functions;
|
|
23102
22867
|
const repeated = pivot.repeatLabels && at >= 0 ? `<extLst><ext uri="{2946ED86-A175-432a-8AC1-64E0C546D7DE}"><x14:pivotField xmlns:x14="${X14}" fillDownLabels="1"/></ext></extLst>` : "";
|
|
@@ -23104,37 +22869,27 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
23104
22869
|
custom.map((fn) => [PIVOT_SUBTOTALS[fn].attr, true])
|
|
23105
22870
|
);
|
|
23106
22871
|
const entries = automatic ? '<item t="default"/>' : custom.map((fn) => `<item t="${PIVOT_SUBTOTALS[fn].item}"/>`).join("");
|
|
23107
|
-
return `<pivotField${attrs({ axis: index2 === page ? "axisPage" : at >= 0 ? "axisRow" : colAt >= 0 ? "axisCol" : void 0, dataField: measures.some((measure) => pivot.fields.indexOf(measure.field) === index2) ? true : void 0, compact, outline, showAll: false, subtotalTop: at >= 0 ? top : void 0, numFmtId: isDate ? 14 : void 0, defaultSubtotal: automatic ? void 0 : false, ...flags })}>${items2 ? `<items count="${items2.length + (automatic ? 1 : custom.length)}">${items2.map((item) => `<item${hidden.has(pivotValueKey(item)) ? ' h="1"' : ""} x="${itemX(index2, item)}"/>`).join("")}${entries}</items>` : ""}${repeated}</pivotField>`;
|
|
22872
|
+
return `<pivotField${attrs({ axis: index2 === page ? "axisPage" : at >= 0 ? "axisRow" : colAt >= 0 ? "axisCol" : void 0, dataField: measures.some((measure) => pivot.fields.indexOf(measure.field) === index2) ? true : void 0, compact, outline, showAll: false, subtotalTop: at >= 0 ? top : void 0, numFmtId: isDate ? 14 : void 0, defaultSubtotal: automatic ? void 0 : false, ...flags })}>${items2 ? `<items count="${items2.length + (automatic ? 1 : custom.length)}">${items2.map((item) => `<item${hidden.has(pivotValueKey(item)) ? ' h="1"' : ""}${named2(name2, item)} x="${itemX(index2, item)}"/>`).join("")}${entries}</items>` : ""}${repeated}</pivotField>`;
|
|
23108
22873
|
}).join("");
|
|
23109
22874
|
const items = (count2, indices) => Array.from({ length: count2 }, (_v, i) => `<i><x v="${indices?.[i] ?? i}"/></i>`).join("") + '<i t="grand"><x/></i>';
|
|
23110
22875
|
const header = grid.firstHeaderRow !== void 0 ? grid.firstHeaderRow - pageOffset : col >= 0 ? 1 : grid.firstDataRow - pageOffset - 1;
|
|
23111
|
-
const rowIndices =
|
|
22876
|
+
const rowIndices = [...rowIdx];
|
|
22877
|
+
if (valuesAt >= 0) rowIndices.splice(valuesAt, 0, -2);
|
|
23112
22878
|
let previous = [];
|
|
23113
22879
|
const rowItems = rowEntries?.map((entry3) => {
|
|
23114
22880
|
let prefix = 0;
|
|
23115
22881
|
const type = entry3.type === void 0 || entry3.type === "default" || entry3.type === "grand" ? entry3.type : PIVOT_SUBTOTALS[entry3.type].item;
|
|
23116
|
-
if (
|
|
23117
|
-
|
|
23118
|
-
else if (!entry3.type)
|
|
23119
|
-
while (prefix < entry3.indices.length - 1 && entry3.indices[prefix] === previous[prefix])
|
|
23120
|
-
prefix++;
|
|
23121
|
-
previous = entry3.type && !(entry3.type === "default" && pivot.valuesPosition === "first") ? [] : entry3.indices;
|
|
23122
|
-
} else {
|
|
23123
|
-
if (entry3.type !== "grand") prefix = sharedPrefix(entry3.indices, previous);
|
|
23124
|
-
previous = entry3.type === "grand" ? [] : entry3.indices;
|
|
23125
|
-
}
|
|
22882
|
+
if (entry3.type !== "grand") prefix = sharedPrefix(entry3.indices, previous);
|
|
22883
|
+
previous = entry3.type === "grand" ? [] : entry3.indices;
|
|
23126
22884
|
return `<i${attrs({ t: type, r: prefix || void 0, i: entry3.measure || void 0 })}>${entry3.indices.slice(prefix).map((index2) => `<x${attrs({ v: index2 || void 0 })}/>`).join("")}</i>`;
|
|
23127
22885
|
}).join("") ?? items(grid.rowItems.length, rowIndicesFull[0]);
|
|
23128
22886
|
let body = `<location${attrs({ ref: formatRange({ ...pivot.location, start: { ...pivot.location.start, row: pivot.location.start.row + pageOffset } }), firstHeaderRow: header, firstDataRow: grid.firstDataRow - pageOffset, rowPageCount: page >= 0 ? 1 : void 0, colPageCount: page >= 0 ? 1 : void 0, firstDataCol: grid.rowLabelColumns ?? 1 })}/><pivotFields count="${pivot.fields.length}">${fields}</pivotFields><rowFields count="${rowIndices.length}">${rowIndices.map((index2) => `<field x="${index2}"/>`).join("")}</rowFields><rowItems count="${grid.rowEntries?.length ?? grid.rowItems.length + 1}">${rowItems}</rowItems>`;
|
|
23129
|
-
if (
|
|
23130
|
-
const fieldsOnColumns = [...columnIdx, ...multiple ? [-2] : []];
|
|
23131
|
-
body += `<colFields count="${fieldsOnColumns.length}">${fieldsOnColumns.map((index2) => `<field x="${index2}"/>`).join("")}</colFields>${pivotColumnItemsXml(grid.columnEntries, measures.length, (level, index2) => columnIndicesFull[level][index2])}`;
|
|
22887
|
+
if (col >= 0 && grid.columnEntries) {
|
|
22888
|
+
const fieldsOnColumns = [...columnIdx, ...multiple && !rowsAxis ? [-2] : []];
|
|
22889
|
+
body += `<colFields count="${fieldsOnColumns.length}">${fieldsOnColumns.map((index2) => `<field x="${index2}"/>`).join("")}</colFields>${pivotColumnItemsXml(grid.columnEntries, rowsAxis ? 1 : measures.length, (level, index2) => columnIndicesFull[level][index2])}`;
|
|
23132
22890
|
} else if (multiple && !rowsAxis)
|
|
23133
22891
|
body += `<colFields count="1"><field x="-2"/></colFields>${pivotValueAxisItems(measures.length)}`;
|
|
23134
|
-
else
|
|
23135
|
-
body += `<colFields count="1"><field x="${col}"/></colFields><colItems count="${grid.columnItems.length + 1}">${items(grid.columnItems.length, columnIndicesFull[0])}</colItems>`;
|
|
23136
|
-
else
|
|
23137
|
-
body += rowsAxis ? '<colItems count="1"><i/></colItems>' : page >= 0 ? '<colItems count="1"><i/></colItems>' : '<colItems count="1"><i><x/></i></colItems>';
|
|
22892
|
+
else body += '<colItems count="1"><i/></colItems>';
|
|
23138
22893
|
if (page >= 0)
|
|
23139
22894
|
body += `<pageFields count="1"><pageField${attrs({ fld: page, hier: -1, item: pivot.pageFilter.item !== void 0 ? pageItems.findIndex((item) => pivotValueKey(item) === pivotValueKey(pivot.pageFilter.item)) : void 0 })}/></pageFields>`;
|
|
23140
22895
|
body += `<dataFields count="${measures.length}">${measures.map((measure) => `<dataField${attrs({ name: encodeEscapes(measure.caption), fld: pivot.fields.indexOf(measure.field), subtotal: measure.aggregate, baseField: 0, baseItem: 0 })}/>`).join("")}</dataFields>`;
|
|
@@ -23144,9 +22899,17 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
23144
22899
|
const root = doc.documentElement;
|
|
23145
22900
|
root.setAttribute("name", pivot.name);
|
|
23146
22901
|
root.setAttribute("cacheId", String(cacheId));
|
|
22902
|
+
const caps = pivotCaptions(pivot);
|
|
22903
|
+
root.setAttribute("dataCaption", caps.values);
|
|
22904
|
+
for (const [attribute2, key] of [
|
|
22905
|
+
["rowHeaderCaption", "rowLabels"],
|
|
22906
|
+
["colHeaderCaption", "columnLabels"],
|
|
22907
|
+
["grandTotalCaption", "grandTotal"]
|
|
22908
|
+
])
|
|
22909
|
+
if (caps[key] !== ENGLISH_PIVOT_CAPTIONS[key] || root.hasAttribute(attribute2))
|
|
22910
|
+
root.setAttribute(attribute2, caps[key]);
|
|
23147
22911
|
root.setAttribute("dataOnRows", rowsAxis ? "1" : "0");
|
|
23148
|
-
if (rowsAxis &&
|
|
23149
|
-
root.setAttribute("dataPosition", pivot.valuesPosition === "first" ? "0" : "1");
|
|
22912
|
+
if (rowsAxis && valuesAt < rowIdx.length) root.setAttribute("dataPosition", String(valuesAt));
|
|
23150
22913
|
else root.removeAttribute("dataPosition");
|
|
23151
22914
|
root.setAttribute("compact", compact ? "1" : "0");
|
|
23152
22915
|
root.setAttribute("compactData", compact ? "1" : "0");
|
|
@@ -23212,13 +22975,15 @@ function pivotTableXml(source2, cacheId, cache3) {
|
|
|
23212
22975
|
}
|
|
23213
22976
|
function dateFilterXml(pivot, filter2) {
|
|
23214
22977
|
const x15 = "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main";
|
|
23215
|
-
|
|
22978
|
+
const id = Number(/<filter [^>]*\bid="(\d+)"/.exec(pivot.sourceXml ?? "")?.[1] ?? 1);
|
|
22979
|
+
return `<filters count="1"><filter${attrs({ fld: pivot.fields.indexOf(filter2.field), type: "dateBetween", evalOrder: -1, id, name: filter2.field })}><autoFilter ref="A1"><filterColumn colId="0"><customFilters and="1"><customFilter operator="greaterThanOrEqual" val="${Math.floor(filter2.start)}"/><customFilter operator="lessThanOrEqual" val="${Math.floor(filter2.end)}"/></customFilters></filterColumn></autoFilter><extLst><ext uri="{0605FD5F-26C8-4aeb-8148-2DB25E43C511}" xmlns:x15="${x15}"><x15:pivotFilter useWholeDay="1"/></ext></extLst></filter></filters>`;
|
|
23216
22980
|
}
|
|
23217
22981
|
var X14;
|
|
23218
22982
|
var init_table_xml = __esm({
|
|
23219
22983
|
"xlsx/pivot/table-xml.ts"() {
|
|
23220
22984
|
init_xml2();
|
|
23221
22985
|
init_data();
|
|
22986
|
+
init_axes();
|
|
23222
22987
|
init_columns();
|
|
23223
22988
|
init_date_groups();
|
|
23224
22989
|
init_groups();
|
|
@@ -23226,6 +22991,8 @@ var init_table_xml = __esm({
|
|
|
23226
22991
|
init_address();
|
|
23227
22992
|
init_xml_out();
|
|
23228
22993
|
init_aggregate();
|
|
22994
|
+
init_captions();
|
|
22995
|
+
init_item_labels();
|
|
23229
22996
|
init_measures();
|
|
23230
22997
|
init_subtotals();
|
|
23231
22998
|
init_values_axis();
|
|
@@ -24072,8 +23839,8 @@ function sanitizeMentionTarget(raw2) {
|
|
|
24072
23839
|
}
|
|
24073
23840
|
function resolveMentions(text2, candidates) {
|
|
24074
23841
|
const targets = [];
|
|
24075
|
-
for (const
|
|
24076
|
-
const clean = sanitizeMentionTarget(
|
|
23842
|
+
for (const candidate2 of candidates) {
|
|
23843
|
+
const clean = sanitizeMentionTarget(candidate2);
|
|
24077
23844
|
if (clean) targets.push(clean);
|
|
24078
23845
|
}
|
|
24079
23846
|
if (targets.length === 0) return [];
|
|
@@ -24434,8 +24201,8 @@ function createPeer(selfId, peerId, factory, createStream, config, tracks, callb
|
|
|
24434
24201
|
callbacks.onStream(stream);
|
|
24435
24202
|
}
|
|
24436
24203
|
};
|
|
24437
|
-
pc.onicecandidate = ({ candidate }) => {
|
|
24438
|
-
if (
|
|
24204
|
+
pc.onicecandidate = ({ candidate: candidate2 }) => {
|
|
24205
|
+
if (candidate2) callbacks.sendCandidate(candidate2);
|
|
24439
24206
|
};
|
|
24440
24207
|
pc.onconnectionstatechange = () => {
|
|
24441
24208
|
callbacks.onConnection(pc.connectionState);
|
|
@@ -24477,9 +24244,9 @@ function createPeer(selfId, peerId, factory, createStream, config, tracks, callb
|
|
|
24477
24244
|
fail2(error);
|
|
24478
24245
|
}
|
|
24479
24246
|
},
|
|
24480
|
-
async receiveCandidate(
|
|
24247
|
+
async receiveCandidate(candidate2) {
|
|
24481
24248
|
try {
|
|
24482
|
-
await pc.addIceCandidate(
|
|
24249
|
+
await pc.addIceCandidate(candidate2);
|
|
24483
24250
|
} catch (error) {
|
|
24484
24251
|
if (!ignoreOffer) fail2(error);
|
|
24485
24252
|
}
|
|
@@ -24592,7 +24359,7 @@ function createCallSession(options) {
|
|
|
24592
24359
|
{ audio: local.audio, video: videoTrack() },
|
|
24593
24360
|
{
|
|
24594
24361
|
sendDescription: (description) => send({ type: "description", from: self.id, to: id, description }),
|
|
24595
|
-
sendCandidate: (
|
|
24362
|
+
sendCandidate: (candidate2) => send({ type: "candidate", from: self.id, to: id, candidate: candidate2 }),
|
|
24596
24363
|
onStream: (stream) => {
|
|
24597
24364
|
remote.stream = stream;
|
|
24598
24365
|
publish();
|
|
@@ -25117,11 +24884,86 @@ function minuteOfDay(ms, zone) {
|
|
|
25117
24884
|
return p.hour * 60 + p.minute;
|
|
25118
24885
|
}
|
|
25119
24886
|
|
|
24887
|
+
// teams/recurrence-calendar.ts
|
|
24888
|
+
var WEEKDAY_ORDINALS = [1, 2, 3, 4, -1];
|
|
24889
|
+
var MAX_MONTH_STEPS = 24e3;
|
|
24890
|
+
var MAX_YEAR_STEPS = 6e3;
|
|
24891
|
+
var isCalendarRepeat = (repeat) => repeat === "monthly" || repeat === "yearly";
|
|
24892
|
+
var daysInMonth = (year, month) => new Date(Date.UTC(year, month, 0)).getUTCDate();
|
|
24893
|
+
var ordinalOfDay = (day) => day > 28 ? -1 : Math.ceil(day / 7);
|
|
24894
|
+
function dayMatchesOrdinal(year, month, day, ordinal) {
|
|
24895
|
+
return ordinal === -1 ? day + 7 > daysInMonth(year, month) : Math.ceil(day / 7) === ordinal && ordinal >= 1 && ordinal <= 4;
|
|
24896
|
+
}
|
|
24897
|
+
function nthWeekdayOfMonth(year, month, weekday2, ordinal) {
|
|
24898
|
+
const first2 = new Date(Date.UTC(year, month - 1, 1)).getUTCDay();
|
|
24899
|
+
if (ordinal === -1) {
|
|
24900
|
+
const length = daysInMonth(year, month);
|
|
24901
|
+
const lastWeekday = (first2 + length - 1) % 7;
|
|
24902
|
+
return length - (lastWeekday - weekday2 + 7) % 7;
|
|
24903
|
+
}
|
|
24904
|
+
return 1 + (weekday2 - first2 + 7) % 7 + (ordinal - 1) * 7;
|
|
24905
|
+
}
|
|
24906
|
+
function anchorOf(meeting) {
|
|
24907
|
+
const p = zonedParts(meeting.start, meeting.zone);
|
|
24908
|
+
const weekday2 = new Date(Date.UTC(p.year, p.month - 1, p.day)).getUTCDay();
|
|
24909
|
+
const ordinal = meeting.ordinal !== void 0 && WEEKDAY_ORDINALS.includes(meeting.ordinal) ? meeting.ordinal : ordinalOfDay(p.day);
|
|
24910
|
+
return { ...p, weekday: weekday2, ordinal, byWeekday: meeting.monthlyBy === "weekday" };
|
|
24911
|
+
}
|
|
24912
|
+
function candidate(a2, yearly, j) {
|
|
24913
|
+
if (j === 0) return { year: a2.year, month: a2.month, day: a2.day };
|
|
24914
|
+
if (yearly) {
|
|
24915
|
+
const year2 = a2.year + j;
|
|
24916
|
+
return a2.day <= daysInMonth(year2, a2.month) ? { year: year2, month: a2.month, day: a2.day } : null;
|
|
24917
|
+
}
|
|
24918
|
+
const total2 = a2.year * 12 + (a2.month - 1) + j;
|
|
24919
|
+
const year = Math.floor(total2 / 12);
|
|
24920
|
+
const month = total2 % 12 + 1;
|
|
24921
|
+
if (a2.byWeekday)
|
|
24922
|
+
return { year, month, day: nthWeekdayOfMonth(year, month, a2.weekday, a2.ordinal) };
|
|
24923
|
+
return a2.day <= daysInMonth(year, month) ? { year, month, day: a2.day } : null;
|
|
24924
|
+
}
|
|
24925
|
+
function* calendarSlots(meeting) {
|
|
24926
|
+
const a2 = anchorOf(meeting);
|
|
24927
|
+
const yearly = meeting.repeat === "yearly";
|
|
24928
|
+
let index2 = 0;
|
|
24929
|
+
for (let j = 0; j < (yearly ? MAX_YEAR_STEPS : MAX_MONTH_STEPS); j++) {
|
|
24930
|
+
const d = candidate(a2, yearly, j);
|
|
24931
|
+
if (d) yield { index: index2++, ...d };
|
|
24932
|
+
}
|
|
24933
|
+
}
|
|
24934
|
+
function slotStart(meeting, slot) {
|
|
24935
|
+
const p = zonedParts(meeting.start, meeting.zone);
|
|
24936
|
+
return zonedToUtc({ ...slot, hour: p.hour, minute: p.minute, second: p.second }, meeting.zone);
|
|
24937
|
+
}
|
|
24938
|
+
function slotAt(meeting, index2) {
|
|
24939
|
+
for (const slot of calendarSlots(meeting)) if (slot.index === index2) return slot;
|
|
24940
|
+
return null;
|
|
24941
|
+
}
|
|
24942
|
+
function slotStarting(meeting, start) {
|
|
24943
|
+
const p = zonedParts(start, meeting.zone);
|
|
24944
|
+
for (const slot of calendarSlots(meeting)) {
|
|
24945
|
+
if (slot.year > p.year || slot.year === p.year && slot.month > p.month) return null;
|
|
24946
|
+
if (slot.year === p.year && slot.month === p.month && slot.day === p.day)
|
|
24947
|
+
return slotStart(meeting, slot) === start ? slot : null;
|
|
24948
|
+
}
|
|
24949
|
+
return null;
|
|
24950
|
+
}
|
|
24951
|
+
function repeatChoices(start, zone) {
|
|
24952
|
+
const p = zonedParts(start, zone);
|
|
24953
|
+
const weekday2 = new Date(Date.UTC(p.year, p.month - 1, p.day)).getUTCDay();
|
|
24954
|
+
const ordinals = WEEKDAY_ORDINALS.filter((o) => dayMatchesOrdinal(p.year, p.month, p.day, o));
|
|
24955
|
+
return { month: p.month, day: p.day, weekday: weekday2, ordinals };
|
|
24956
|
+
}
|
|
24957
|
+
|
|
25120
24958
|
// teams/recurrence.ts
|
|
25121
24959
|
var MAX_RECURRENCE_COUNT = 999;
|
|
25122
24960
|
var stepDays = (meeting) => meeting.repeat === "daily" ? 1 : 7;
|
|
25123
24961
|
function seriesStart(meeting, index2) {
|
|
25124
24962
|
if (index2 === 0 || meeting.repeat === "none") return meeting.start;
|
|
24963
|
+
if (isCalendarRepeat(meeting.repeat)) {
|
|
24964
|
+
const slot = slotAt(meeting, index2);
|
|
24965
|
+
return slot ? slotStart(meeting, slot) : Number.POSITIVE_INFINITY;
|
|
24966
|
+
}
|
|
25125
24967
|
const anchor = zonedParts(meeting.start, meeting.zone);
|
|
25126
24968
|
return zonedToUtc({ ...anchor, day: anchor.day + index2 * stepDays(meeting) }, meeting.zone);
|
|
25127
24969
|
}
|
|
@@ -25136,6 +24978,7 @@ function seriesBetween(meeting, from, to, limit2 = 400) {
|
|
|
25136
24978
|
if (to <= from) return [];
|
|
25137
24979
|
if (meeting.repeat === "none")
|
|
25138
24980
|
return meeting.start < to && meeting.end > from ? [{ index: 0, start: meeting.start }] : [];
|
|
24981
|
+
if (isCalendarRepeat(meeting.repeat)) return calendarBetween(meeting, from, to, limit2);
|
|
25139
24982
|
const step = stepDays(meeting) * DAY_MS;
|
|
25140
24983
|
const first2 = Math.max(0, Math.floor((from - meeting.end) / step) - 1);
|
|
25141
24984
|
const last = Math.ceil((to - meeting.start) / step) + 1;
|
|
@@ -25151,8 +24994,28 @@ function seriesBetween(meeting, from, to, limit2 = 400) {
|
|
|
25151
24994
|
}
|
|
25152
24995
|
return out;
|
|
25153
24996
|
}
|
|
24997
|
+
function calendarBetween(meeting, from, to, limit2) {
|
|
24998
|
+
const span2 = meeting.end - meeting.start;
|
|
24999
|
+
const time2 = zonedParts(meeting.start, meeting.zone);
|
|
25000
|
+
const out = [];
|
|
25001
|
+
for (const slot of calendarSlots(meeting)) {
|
|
25002
|
+
if (meeting.count !== void 0 && slot.index >= meeting.count) break;
|
|
25003
|
+
const wall = Date.UTC(slot.year, slot.month - 1, slot.day, time2.hour, time2.minute);
|
|
25004
|
+
if (wall - DAY_MS >= to || out.length >= limit2) break;
|
|
25005
|
+
if (wall + span2 + DAY_MS <= from) continue;
|
|
25006
|
+
const start = slot.index === 0 ? meeting.start : slotStart(meeting, slot);
|
|
25007
|
+
if (meeting.until !== void 0 && start > meeting.until) break;
|
|
25008
|
+
if (start < to && start + span2 > from) out.push({ index: slot.index, start });
|
|
25009
|
+
}
|
|
25010
|
+
return out;
|
|
25011
|
+
}
|
|
25154
25012
|
function seriesIndexOf(meeting, start) {
|
|
25155
25013
|
if (meeting.repeat === "none") return start === meeting.start ? 0 : null;
|
|
25014
|
+
if (isCalendarRepeat(meeting.repeat)) {
|
|
25015
|
+
if (start === meeting.start) return 0;
|
|
25016
|
+
const slot = slotStarting(meeting, start);
|
|
25017
|
+
return slot && withinSeries(meeting, slot.index, start) ? slot.index : null;
|
|
25018
|
+
}
|
|
25156
25019
|
const guess = Math.round((start - meeting.start) / (stepDays(meeting) * DAY_MS));
|
|
25157
25020
|
for (const k of [guess, guess - 1, guess + 1])
|
|
25158
25021
|
if (k >= 0 && seriesStart(meeting, k) === start && withinSeries(meeting, k, start)) return k;
|
|
@@ -26446,14 +26309,23 @@ function alarm(title) {
|
|
|
26446
26309
|
"END:VALARM"
|
|
26447
26310
|
];
|
|
26448
26311
|
}
|
|
26312
|
+
var BYDAY = ["SU", "MO", "TU", "WE", "TH", "FR", "SA"];
|
|
26313
|
+
function calendarParts(meeting) {
|
|
26314
|
+
if (meeting.repeat !== "monthly" && meeting.repeat !== "yearly") return "";
|
|
26315
|
+
const p = zonedParts(meeting.start, meeting.zone);
|
|
26316
|
+
if (meeting.repeat === "yearly") return `;BYMONTH=${p.month};BYMONTHDAY=${p.day}`;
|
|
26317
|
+
if (meeting.monthlyBy !== "weekday") return `;BYMONTHDAY=${p.day}`;
|
|
26318
|
+
const weekday2 = new Date(Date.UTC(p.year, p.month - 1, p.day)).getUTCDay();
|
|
26319
|
+
return `;BYDAY=${meeting.ordinal ?? ordinalOfDay(p.day)}${BYDAY[weekday2]}`;
|
|
26320
|
+
}
|
|
26449
26321
|
function recurrenceRule(meeting) {
|
|
26450
26322
|
if (meeting.repeat === "none") return [];
|
|
26451
|
-
const freq = meeting.repeat
|
|
26323
|
+
const freq = meeting.repeat.toUpperCase();
|
|
26452
26324
|
const end = meeting.count !== void 0 ? `;COUNT=${meeting.count}` : meeting.until !== void 0 ? `;UNTIL=${icsUtc(meeting.until)}` : "";
|
|
26453
26325
|
const utc = UTC_ZONES.has(meeting.zone);
|
|
26454
26326
|
const exdates = (meeting.exceptions ?? []).filter((e) => e.cancelled).map((e) => utc ? icsUtc(e.originalStart) : icsLocal(e.originalStart, meeting.zone));
|
|
26455
26327
|
return [
|
|
26456
|
-
`RRULE:FREQ=${freq}${end}`,
|
|
26328
|
+
`RRULE:FREQ=${freq}${calendarParts(meeting)}${end}`,
|
|
26457
26329
|
...exdates.length ? [utc ? `EXDATE:${exdates.join(",")}` : `EXDATE;TZID=${meeting.zone}:${exdates.join(",")}`] : []
|
|
26458
26330
|
];
|
|
26459
26331
|
}
|
|
@@ -26568,13 +26440,32 @@ function exceptionValue(patch, previous) {
|
|
|
26568
26440
|
}
|
|
26569
26441
|
|
|
26570
26442
|
// teams/meetings.ts
|
|
26571
|
-
var MEETING_REPEATS = [
|
|
26443
|
+
var MEETING_REPEATS = [
|
|
26444
|
+
"none",
|
|
26445
|
+
"daily",
|
|
26446
|
+
"weekly",
|
|
26447
|
+
"monthly",
|
|
26448
|
+
"yearly"
|
|
26449
|
+
];
|
|
26572
26450
|
var MAX_MEETING_TITLE = 120;
|
|
26573
26451
|
var MAX_MEETING_DESCRIPTION = 2e3;
|
|
26574
26452
|
var MAX_MEETING_HOURS = 24;
|
|
26575
26453
|
var MEETINGS = "teams:meetings";
|
|
26576
26454
|
var SAFE_ID = /^[\w-]{1,64}$/u;
|
|
26577
26455
|
var finiteTime = (v) => typeof v === "number" && Number.isFinite(v) && v > 0 && v < 864e13 ? Math.floor(v) : null;
|
|
26456
|
+
function readPattern(kind, by, ordinal, start, zone) {
|
|
26457
|
+
if (kind !== "monthly" || by !== "weekday") return {};
|
|
26458
|
+
const p = zonedParts(start, zone);
|
|
26459
|
+
const fits = typeof ordinal === "number" && WEEKDAY_ORDINALS.includes(ordinal) && dayMatchesOrdinal(p.year, p.month, p.day, ordinal);
|
|
26460
|
+
return { monthlyBy: "weekday", ordinal: fits ? ordinal : ordinalOfDay(p.day) };
|
|
26461
|
+
}
|
|
26462
|
+
function withOrdinal(input, repeat, by, current, start, zone) {
|
|
26463
|
+
if (repeat !== "monthly" || by !== "weekday") return input;
|
|
26464
|
+
const p = zonedParts(start, zone);
|
|
26465
|
+
const fits = (o) => o !== void 0 && WEEKDAY_ORDINALS.includes(o) && dayMatchesOrdinal(p.year, p.month, p.day, o);
|
|
26466
|
+
if (input.ordinal !== void 0) return fits(input.ordinal) ? input : null;
|
|
26467
|
+
return { ...input, ordinal: fits(current) ? current : ordinalOfDay(p.day) };
|
|
26468
|
+
}
|
|
26578
26469
|
function readMeeting(id, raw2) {
|
|
26579
26470
|
if (!(raw2 instanceof Y.Map) || !SAFE_ID.test(id)) return null;
|
|
26580
26471
|
const start = finiteTime(raw2.get("start"));
|
|
@@ -26593,16 +26484,19 @@ function readMeeting(id, raw2) {
|
|
|
26593
26484
|
const until = finiteTime(raw2.get("until"));
|
|
26594
26485
|
const total2 = typeof count2 === "number" && Number.isInteger(count2) && count2 >= 1 ? Math.min(count2, MAX_RECURRENCE_COUNT) : null;
|
|
26595
26486
|
const exceptions = kind === "none" ? [] : readExceptions(raw2.get("exceptions"));
|
|
26487
|
+
const zoneId = isValidZone(zone) ? zone : "UTC";
|
|
26488
|
+
const pattern = readPattern(kind, raw2.get("monthlyBy"), raw2.get("ordinal"), start, zoneId);
|
|
26596
26489
|
return {
|
|
26597
26490
|
id,
|
|
26598
26491
|
title,
|
|
26599
26492
|
description: sanitizeMessageText(raw2.get("description")).slice(0, MAX_MEETING_DESCRIPTION),
|
|
26600
26493
|
organizerId,
|
|
26601
26494
|
organizerName: sanitizeChannelName(raw2.get("organizerName")) || "Unknown",
|
|
26602
|
-
zone:
|
|
26495
|
+
zone: zoneId,
|
|
26603
26496
|
start,
|
|
26604
26497
|
end,
|
|
26605
26498
|
repeat: kind,
|
|
26499
|
+
...pattern,
|
|
26606
26500
|
...kind === "none" ? {} : total2 !== null ? { count: total2 } : until !== null ? { until } : {},
|
|
26607
26501
|
...exceptions.length ? { exceptions } : {},
|
|
26608
26502
|
attendees: sanitizeMembers(raw2.get("attendees")),
|
|
@@ -26625,6 +26519,12 @@ function createMeetingStore(doc, user, now = Date.now) {
|
|
|
26625
26519
|
if (input.end !== void 0) row2.set("end", input.end);
|
|
26626
26520
|
if (input.repeat !== void 0 && MEETING_REPEATS.includes(input.repeat))
|
|
26627
26521
|
row2.set("repeat", input.repeat);
|
|
26522
|
+
if (input.monthlyBy !== void 0) {
|
|
26523
|
+
if (input.monthlyBy === "weekday" || input.monthlyBy === "date")
|
|
26524
|
+
row2.set("monthlyBy", input.monthlyBy);
|
|
26525
|
+
}
|
|
26526
|
+
if (input.ordinal !== void 0 && WEEKDAY_ORDINALS.includes(input.ordinal))
|
|
26527
|
+
row2.set("ordinal", input.ordinal);
|
|
26628
26528
|
if (input.count !== void 0) {
|
|
26629
26529
|
if (input.count === null) row2.delete("count");
|
|
26630
26530
|
else {
|
|
@@ -26668,6 +26568,10 @@ function createMeetingStore(doc, user, now = Date.now) {
|
|
|
26668
26568
|
const end = finiteTime(input.end);
|
|
26669
26569
|
if (!sanitizeChannelName(input.title) || start === null || end === null) return null;
|
|
26670
26570
|
if (end <= start || end - start > MAX_MEETING_HOURS * 36e5) return null;
|
|
26571
|
+
const zone = isValidZone(input.zone) ? input.zone : localZone();
|
|
26572
|
+
const repeat = input.repeat ?? "none";
|
|
26573
|
+
const checked = withOrdinal(input, repeat, input.monthlyBy, void 0, start, zone);
|
|
26574
|
+
if (!checked) return null;
|
|
26671
26575
|
const id = nextId("t").replace(/[^\w-]/gu, "");
|
|
26672
26576
|
doc.transact(() => {
|
|
26673
26577
|
const row2 = new Y.Map();
|
|
@@ -26675,9 +26579,9 @@ function createMeetingStore(doc, user, now = Date.now) {
|
|
|
26675
26579
|
row2.set("organizerName", user.name);
|
|
26676
26580
|
row2.set("createdAt", now());
|
|
26677
26581
|
row2.set("cancelled", false);
|
|
26678
|
-
row2.set("zone",
|
|
26582
|
+
row2.set("zone", zone);
|
|
26679
26583
|
row2.set("repeat", "none");
|
|
26680
|
-
apply(row2, { ...
|
|
26584
|
+
apply(row2, { ...checked, start, end });
|
|
26681
26585
|
map.set(id, row2);
|
|
26682
26586
|
});
|
|
26683
26587
|
return get(id);
|
|
@@ -26691,10 +26595,16 @@ function createMeetingStore(doc, user, now = Date.now) {
|
|
|
26691
26595
|
if (end <= start || end - start > MAX_MEETING_HOURS * 36e5) return null;
|
|
26692
26596
|
if (patch.title !== void 0 && !sanitizeChannelName(patch.title)) return null;
|
|
26693
26597
|
const repeat = patch.repeat ?? current.repeat;
|
|
26598
|
+
const zone = patch.zone !== void 0 && isValidZone(patch.zone) ? patch.zone : current.zone;
|
|
26599
|
+
const by = patch.monthlyBy ?? current.monthlyBy;
|
|
26600
|
+
const checked = withOrdinal(patch, repeat, by, current.ordinal, start, zone);
|
|
26601
|
+
if (!checked) return null;
|
|
26602
|
+
patch = checked;
|
|
26603
|
+
const sameShape = (by ?? "date") === (current.monthlyBy ?? "date") && (patch.ordinal === void 0 || patch.ordinal === current.ordinal);
|
|
26694
26604
|
if (typeof patch.until === "number" && repeat !== "none" && patch.until < start) return null;
|
|
26695
26605
|
doc.transact(() => {
|
|
26696
26606
|
apply(row2, patch);
|
|
26697
|
-
if (repeat === "none" || start !== current.start || repeat !== current.repeat)
|
|
26607
|
+
if (repeat === "none" || start !== current.start || repeat !== current.repeat || !sameShape)
|
|
26698
26608
|
row2.delete("exceptions");
|
|
26699
26609
|
if (repeat === "none") {
|
|
26700
26610
|
row2.delete("until");
|
|
@@ -27123,31 +27033,101 @@ function trimTrailingSlashes(value) {
|
|
|
27123
27033
|
}
|
|
27124
27034
|
|
|
27125
27035
|
// teams/server-session.ts
|
|
27036
|
+
var TeamsSignInError = class extends Error {
|
|
27037
|
+
reason;
|
|
27038
|
+
retryAfterSec;
|
|
27039
|
+
constructor(reason, message, retryAfterSec) {
|
|
27040
|
+
super(message);
|
|
27041
|
+
this.name = "TeamsSignInError";
|
|
27042
|
+
this.reason = reason;
|
|
27043
|
+
this.retryAfterSec = retryAfterSec;
|
|
27044
|
+
}
|
|
27045
|
+
};
|
|
27126
27046
|
async function requestTeamsSession(config, credentials, options = {}) {
|
|
27127
|
-
const
|
|
27128
|
-
if (
|
|
27129
|
-
|
|
27130
|
-
|
|
27131
|
-
|
|
27132
|
-
|
|
27133
|
-
|
|
27134
|
-
|
|
27135
|
-
|
|
27136
|
-
|
|
27137
|
-
|
|
27138
|
-
|
|
27139
|
-
|
|
27140
|
-
|
|
27141
|
-
|
|
27142
|
-
|
|
27143
|
-
|
|
27144
|
-
|
|
27145
|
-
|
|
27047
|
+
const origin = serverOrigin(config);
|
|
27048
|
+
if (!origin) throw new Error("Configure a server before signing in");
|
|
27049
|
+
let response;
|
|
27050
|
+
try {
|
|
27051
|
+
response = await sessionFetch(options)(`${origin}/auth/session`, {
|
|
27052
|
+
method: "POST",
|
|
27053
|
+
redirect: "error",
|
|
27054
|
+
credentials: "omit",
|
|
27055
|
+
headers: jsonHeaders(config),
|
|
27056
|
+
body: JSON.stringify({
|
|
27057
|
+
user: credentials.userId,
|
|
27058
|
+
...credentials.credential === void 0 ? {} : { credential: credentials.credential }
|
|
27059
|
+
}),
|
|
27060
|
+
...options.signal ? { signal: options.signal } : {}
|
|
27061
|
+
});
|
|
27062
|
+
} catch (error) {
|
|
27063
|
+
if (options.signal?.aborted) throw error;
|
|
27064
|
+
throw new TeamsSignInError("network", "Could not reach the server");
|
|
27065
|
+
}
|
|
27066
|
+
if (!response.ok) {
|
|
27067
|
+
const wait = Number(response.headers.get("Retry-After"));
|
|
27068
|
+
throw new TeamsSignInError(
|
|
27069
|
+
response.status === 429 ? "rate-limited" : response.status === 401 || response.status === 400 ? "credentials" : "server",
|
|
27070
|
+
`Sign-in failed (${response.status})`,
|
|
27071
|
+
response.status === 429 && Number.isFinite(wait) && wait > 0 ? Math.ceil(wait) : void 0
|
|
27072
|
+
);
|
|
27073
|
+
}
|
|
27146
27074
|
const body = await response.json();
|
|
27147
27075
|
if (typeof body.session !== "string" || typeof body.user !== "string" || typeof body.expiresAt !== "number")
|
|
27148
27076
|
throw new Error("Server returned an invalid session");
|
|
27149
27077
|
return { token: body.session, userId: body.user, expiresAt: body.expiresAt };
|
|
27150
27078
|
}
|
|
27079
|
+
function serverOrigin(config) {
|
|
27080
|
+
const base = config.syncUrl ?? config.signalingUrl;
|
|
27081
|
+
if (config.mode !== "server" || !base) return null;
|
|
27082
|
+
const target = new URL(base);
|
|
27083
|
+
target.protocol = target.protocol === "wss:" ? "https:" : "http:";
|
|
27084
|
+
return target.origin;
|
|
27085
|
+
}
|
|
27086
|
+
var sessionFetch = (options) => options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
27087
|
+
var jsonHeaders = (config) => ({
|
|
27088
|
+
"Content-Type": "application/json",
|
|
27089
|
+
...config.token ? { Authorization: `Bearer ${config.token}` } : {}
|
|
27090
|
+
});
|
|
27091
|
+
async function probeTeamsAccounts(config, options = {}) {
|
|
27092
|
+
const origin = serverOrigin(config);
|
|
27093
|
+
if (!origin) return null;
|
|
27094
|
+
try {
|
|
27095
|
+
const response = await sessionFetch(options)(`${origin}/health`, {
|
|
27096
|
+
redirect: "error",
|
|
27097
|
+
credentials: "omit",
|
|
27098
|
+
...options.signal ? { signal: options.signal } : {}
|
|
27099
|
+
});
|
|
27100
|
+
if (!response.ok) return null;
|
|
27101
|
+
const body = await response.json();
|
|
27102
|
+
return typeof body.accounts === "boolean" ? body.accounts : false;
|
|
27103
|
+
} catch {
|
|
27104
|
+
return null;
|
|
27105
|
+
}
|
|
27106
|
+
}
|
|
27107
|
+
async function checkTeamsSession(config, session, options = {}) {
|
|
27108
|
+
return postSession(config, "/auth/check", session, options);
|
|
27109
|
+
}
|
|
27110
|
+
async function signOutTeamsSession(config, session, options = {}) {
|
|
27111
|
+
return postSession(config, "/auth/signout", session, options);
|
|
27112
|
+
}
|
|
27113
|
+
async function postSession(config, path2, session, options) {
|
|
27114
|
+
const origin = serverOrigin(config);
|
|
27115
|
+
if (!origin) return "unreachable";
|
|
27116
|
+
try {
|
|
27117
|
+
const response = await sessionFetch(options)(`${origin}${path2}`, {
|
|
27118
|
+
method: "POST",
|
|
27119
|
+
redirect: "error",
|
|
27120
|
+
credentials: "omit",
|
|
27121
|
+
headers: jsonHeaders(config),
|
|
27122
|
+
body: JSON.stringify({ session }),
|
|
27123
|
+
...options.signal ? { signal: options.signal } : {}
|
|
27124
|
+
});
|
|
27125
|
+
if (response.ok) return "valid";
|
|
27126
|
+
return response.status === 401 ? "rejected" : "unreachable";
|
|
27127
|
+
} catch {
|
|
27128
|
+
return "unreachable";
|
|
27129
|
+
}
|
|
27130
|
+
}
|
|
27151
27131
|
|
|
27152
27132
|
// teams/server-file-storage.ts
|
|
27153
27133
|
async function uploadTeamsServerFile(config, workspaceId, file, options = {}) {
|
|
@@ -28054,12 +28034,12 @@ function parseSignal(input) {
|
|
|
28054
28034
|
case "candidate": {
|
|
28055
28035
|
const c2 = r.candidate;
|
|
28056
28036
|
if (!to || !c2 || typeof c2.candidate !== "string" || c2.candidate.length > 2048) return null;
|
|
28057
|
-
const
|
|
28058
|
-
if (typeof c2.sdpMid === "string" || c2.sdpMid === null)
|
|
28037
|
+
const candidate2 = { candidate: c2.candidate };
|
|
28038
|
+
if (typeof c2.sdpMid === "string" || c2.sdpMid === null) candidate2.sdpMid = c2.sdpMid;
|
|
28059
28039
|
if (typeof c2.sdpMLineIndex === "number" || c2.sdpMLineIndex === null)
|
|
28060
|
-
|
|
28061
|
-
if (typeof c2.usernameFragment === "string")
|
|
28062
|
-
return { type: "candidate", from, to, candidate };
|
|
28040
|
+
candidate2.sdpMLineIndex = c2.sdpMLineIndex;
|
|
28041
|
+
if (typeof c2.usernameFragment === "string") candidate2.usernameFragment = c2.usernameFragment;
|
|
28042
|
+
return { type: "candidate", from, to, candidate: candidate2 };
|
|
28063
28043
|
}
|
|
28064
28044
|
default:
|
|
28065
28045
|
return null;
|
|
@@ -29797,4 +29777,4 @@ function sortFiles(files, field, direction) {
|
|
|
29797
29777
|
});
|
|
29798
29778
|
}
|
|
29799
29779
|
|
|
29800
|
-
export { ACTIVITY_FILTERS, CHAT_MEMBERS_MAP, DAY_MS, DEFAULT_ICE_SERVERS, DEFAULT_IDLE_MINUTES, DEFAULT_NOTIFICATION_SETTINGS, GROUP_MENTIONS, HOUR_MS, IDLE_MINUTE_CHOICES, MAX_ACTIVITY_ITEMS, MAX_ATTACHMENTS, MAX_CHANNEL_NAME_CHARS, MAX_CHANNEL_TOPIC_CHARS, MAX_CHAT_MEMBERS, MAX_MEETING_DESCRIPTION, MAX_MEETING_HOURS, MAX_MEETING_TITLE, MAX_MENTIONS, MAX_MESSAGE_CHARS, MAX_PINNED_MESSAGES, MAX_RECURRENCE_COUNT, MAX_SDP_CHARS, MAX_SHARED_CHAT_CHARS, MAX_SHARED_CHAT_DATA_CHARS, MAX_SHARED_CHAT_TITLE_CHARS, MAX_SIGNAL_CHARS, MAX_STATUS_MESSAGE_CHARS, MEETING_REPEATS, MINUTE_MS, NOTIFICATION_LEVELS, PRESENCE_LABELS, PRESENCE_STATUSES, REMINDER_LEAD_MS, STATUS_DURATIONS, STATUS_DURATION_LABELS, activityPreview, addDays, allFilesOf, applyExpiry, callRoomId, channelThreads, channelViews, chatRoomId, chatTitle, chatViews, contactViews, contentUrl, createBroadcastSignaling, createCallSession, createChatDirectory, createChatRooms, createChatStore, createMeetingStore, createMemorySignalingHub, createNotificationSettings, createPeer, createPinStore, createPresenceController, createRoster, createSharedChat, createSharedChatStore, createSyncTransport, createTabStore, createTeamsClient, createTeamsWorkspace, createWebSocketSignaling, dayKey, defaultPresenceSetting, deriveActivity, describeActivity, detectContentKind, detectOfficeKind, directChatId, effectiveStatus, endpointUrl, expiryFor, filesOf, filterActivity, filterFiles, filterMentionTargets, icsDateTime, icsEscape, icsFileName, icsFold, icsLocal, icsOffset, icsUtc, insertMention, isChatMember, isChatUserId, isIdle, isNotificationLevel, isPresenceStatus, isSharedChatRoomId, isStatusDuration, isValidZone, layoutDay, legacyAvailability, localServerConfig, localZone, markdownBlocks, markdownInline, markdownUrl, meetingCallKey, meetingChatId, meetingToIcs, meetingVisibleTo, memberPresence, mentionDisplayText, mentionQueryAt, mentionSegments, mentionTargetsFor, mentionsUser, minuteOfDay, nextExpiry, normalizeIdleMinutes, occurrenceAt, occurrencesBetween, offsetMinutes, parsePresenceSetting, parseServerConfig, parseSignal, peopleViews, promoteMentions, readContent, remindersDue, requestTeamsSession, resolveMentions, sanitizeAttachment, sanitizeAttachments, sanitizeChannelName, sanitizeChannelTopic, sanitizeEmoji, sanitizeMembers, sanitizeMentionName, sanitizeMentionTarget, sanitizeMentions, sanitizeMessageText, sanitizeStatusMessage, searchMessages, seriesBetween, seriesIndexOf, seriesStart, sharedChatRoomId, shiftAnchor, shortHash, shouldNotify, sortFiles, startOfDay, statusFromWire, tabConversationId, typingNames, uploadTeamsServerFile, viewDays, vtimezoneLines, withinSeries, zoneTransitions, zonedParts, zonedToUtc };
|
|
29780
|
+
export { ACTIVITY_FILTERS, CHAT_MEMBERS_MAP, DAY_MS, DEFAULT_ICE_SERVERS, DEFAULT_IDLE_MINUTES, DEFAULT_NOTIFICATION_SETTINGS, GROUP_MENTIONS, HOUR_MS, IDLE_MINUTE_CHOICES, MAX_ACTIVITY_ITEMS, MAX_ATTACHMENTS, MAX_CHANNEL_NAME_CHARS, MAX_CHANNEL_TOPIC_CHARS, MAX_CHAT_MEMBERS, MAX_MEETING_DESCRIPTION, MAX_MEETING_HOURS, MAX_MEETING_TITLE, MAX_MENTIONS, MAX_MESSAGE_CHARS, MAX_PINNED_MESSAGES, MAX_RECURRENCE_COUNT, MAX_SDP_CHARS, MAX_SHARED_CHAT_CHARS, MAX_SHARED_CHAT_DATA_CHARS, MAX_SHARED_CHAT_TITLE_CHARS, MAX_SIGNAL_CHARS, MAX_STATUS_MESSAGE_CHARS, MEETING_REPEATS, MINUTE_MS, NOTIFICATION_LEVELS, PRESENCE_LABELS, PRESENCE_STATUSES, REMINDER_LEAD_MS, STATUS_DURATIONS, STATUS_DURATION_LABELS, TeamsSignInError, WEEKDAY_ORDINALS, activityPreview, addDays, allFilesOf, applyExpiry, calendarSlots, callRoomId, channelThreads, channelViews, chatRoomId, chatTitle, chatViews, checkTeamsSession, contactViews, contentUrl, createBroadcastSignaling, createCallSession, createChatDirectory, createChatRooms, createChatStore, createMeetingStore, createMemorySignalingHub, createNotificationSettings, createPeer, createPinStore, createPresenceController, createRoster, createSharedChat, createSharedChatStore, createSyncTransport, createTabStore, createTeamsClient, createTeamsWorkspace, createWebSocketSignaling, dayKey, dayMatchesOrdinal, daysInMonth, defaultPresenceSetting, deriveActivity, describeActivity, detectContentKind, detectOfficeKind, directChatId, effectiveStatus, endpointUrl, expiryFor, filesOf, filterActivity, filterFiles, filterMentionTargets, icsDateTime, icsEscape, icsFileName, icsFold, icsLocal, icsOffset, icsUtc, insertMention, isCalendarRepeat, isChatMember, isChatUserId, isIdle, isNotificationLevel, isPresenceStatus, isSharedChatRoomId, isStatusDuration, isValidZone, layoutDay, legacyAvailability, localServerConfig, localZone, markdownBlocks, markdownInline, markdownUrl, meetingCallKey, meetingChatId, meetingToIcs, meetingVisibleTo, memberPresence, mentionDisplayText, mentionQueryAt, mentionSegments, mentionTargetsFor, mentionsUser, minuteOfDay, nextExpiry, normalizeIdleMinutes, nthWeekdayOfMonth, occurrenceAt, occurrencesBetween, offsetMinutes, ordinalOfDay, parsePresenceSetting, parseServerConfig, parseSignal, peopleViews, probeTeamsAccounts, promoteMentions, readContent, remindersDue, repeatChoices, requestTeamsSession, resolveMentions, sanitizeAttachment, sanitizeAttachments, sanitizeChannelName, sanitizeChannelTopic, sanitizeEmoji, sanitizeMembers, sanitizeMentionName, sanitizeMentionTarget, sanitizeMentions, sanitizeMessageText, sanitizeStatusMessage, searchMessages, seriesBetween, seriesIndexOf, seriesStart, serverOrigin, sharedChatRoomId, shiftAnchor, shortHash, shouldNotify, signOutTeamsSession, slotAt, slotStart, slotStarting, sortFiles, startOfDay, statusFromWire, tabConversationId, typingNames, uploadTeamsServerFile, viewDays, vtimezoneLines, withinSeries, zoneTransitions, zonedParts, zonedToUtc };
|