@bino-bi/bn-template-engine 1.0.0-next.57 → 1.0.0-next.59
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/bn-template-engine/bn-template-engine.esm.js +1 -1
- package/dist/bn-template-engine/{p-e7b13801.entry.js → p-bc538e7d.entry.js} +1 -1
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +40 -13
- package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +40 -13
- package/dist/components/bn-chart-structure-renderer.js +1 -1
- package/dist/components/bn-chart-structure.js +1 -1
- package/dist/components/{p-DFkSF8_m.js → p-Q6JHDy4s.js} +1 -1
- package/dist/esm/bn-annotation-layer_30.entry.js +40 -13
- package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +2 -0
- package/package.json +1 -1
|
@@ -19188,6 +19188,28 @@ class StructureChart {
|
|
|
19188
19188
|
drawHeader(axisX + ((start + end) / 2) * seg.dataPoint.pixelPerUnit, this.i18n.get(seg.scenario) || seg.scenario);
|
|
19189
19189
|
});
|
|
19190
19190
|
}
|
|
19191
|
+
/** How far the header of a segment of the first row reaches right of the axis: a name can be wider than its segment. */
|
|
19192
|
+
stackHeaderExtent() {
|
|
19193
|
+
var _a;
|
|
19194
|
+
if (!this.stackConfig || this.dataModel.length === 0)
|
|
19195
|
+
return 0;
|
|
19196
|
+
const firstRow = (_a = this.dataModel.find((row) => !this.isTextSum(row))) !== null && _a !== void 0 ? _a : this.dataModel[0];
|
|
19197
|
+
const groups = this.stackGroups(firstRow);
|
|
19198
|
+
if (groups.length !== 1)
|
|
19199
|
+
return 0;
|
|
19200
|
+
const [group] = groups;
|
|
19201
|
+
let extent = 0;
|
|
19202
|
+
group.segments.forEach((seg, index) => {
|
|
19203
|
+
const { start, end } = group.layout.segments[index];
|
|
19204
|
+
const name = String(this.i18n.get(seg.scenario) || seg.scenario);
|
|
19205
|
+
const width = CalculateSize(name, {
|
|
19206
|
+
font: this.styles.fontStyles.font,
|
|
19207
|
+
fontSize: this.styles.fontStyles.size + "px",
|
|
19208
|
+
}).width;
|
|
19209
|
+
extent = Math.max(extent, ((start + end) / 2) * seg.dataPoint.pixelPerUnit + width / 2);
|
|
19210
|
+
});
|
|
19211
|
+
return extent;
|
|
19212
|
+
}
|
|
19191
19213
|
getVarianceType() {
|
|
19192
19214
|
if (this.variancesDataModel.length > 0) {
|
|
19193
19215
|
return this.variancesDataModel[0].type;
|
|
@@ -19195,14 +19217,15 @@ class StructureChart {
|
|
|
19195
19217
|
return VarianceType$1.NONE;
|
|
19196
19218
|
}
|
|
19197
19219
|
calculateLeftSideWidth(varianceType) {
|
|
19198
|
-
var _a, _b, _c;
|
|
19220
|
+
var _a, _b, _c, _d, _e;
|
|
19199
19221
|
let width = 0;
|
|
19200
19222
|
const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
|
|
19201
19223
|
if (VarianceType$1.NONE === varianceType && this.isStacked()) {
|
|
19202
19224
|
// the negative side with the label of a negative total behind it
|
|
19203
19225
|
if (this.stackSides.negative > 0) {
|
|
19204
19226
|
width = this.stackSides.negative * this.pixelPerUnit;
|
|
19205
|
-
|
|
19227
|
+
const totalDrawn = ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.mode) !== withStyled.StackMode.RELATIVE || ((_b = this.stackConfig) === null || _b === void 0 ? void 0 : _b.labels) === "value";
|
|
19228
|
+
if (this.stackSides.minTotal < 0 && totalDrawn) {
|
|
19206
19229
|
width += labelToBar + this.calculateTotalLabelWidth(this.stackSides.minTotal);
|
|
19207
19230
|
}
|
|
19208
19231
|
}
|
|
@@ -19212,19 +19235,19 @@ class StructureChart {
|
|
|
19212
19235
|
}
|
|
19213
19236
|
}
|
|
19214
19237
|
else if (VarianceType$1.NONE === varianceType &&
|
|
19215
|
-
((
|
|
19238
|
+
((_c = this.smallestDataPointValue) === null || _c === void 0 ? void 0 : _c.value) != null &&
|
|
19216
19239
|
this.smallestDataPointValue.value < 0) {
|
|
19217
19240
|
const sizeLabelValue = this.calculateTextBoxWidth(this.smallestDataPointValue.value);
|
|
19218
19241
|
width = Math.abs(this.smallestDataPointValue.getScaledUnit()) + labelToBar + sizeLabelValue;
|
|
19219
19242
|
}
|
|
19220
19243
|
else if (VarianceType$1.RELATIVE === varianceType &&
|
|
19221
|
-
((
|
|
19244
|
+
((_d = this.smallestVarianceDataPointValue) === null || _d === void 0 ? void 0 : _d.value) != null &&
|
|
19222
19245
|
this.smallestVarianceDataPointValue.value < 0) {
|
|
19223
19246
|
const sizeLabelValue = this.calculatePercentageTextBoxWidth(this.smallestVarianceDataPointValue.value);
|
|
19224
19247
|
width = Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit()) + labelToBar + sizeLabelValue;
|
|
19225
19248
|
}
|
|
19226
19249
|
else if (VarianceType$1.ABSOLUTE === varianceType &&
|
|
19227
|
-
((
|
|
19250
|
+
((_e = this.smallestVarianceDataPointValue) === null || _e === void 0 ? void 0 : _e.value) != null &&
|
|
19228
19251
|
this.smallestVarianceDataPointValue.value < 0) {
|
|
19229
19252
|
const sizeLabelValue = this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value, true);
|
|
19230
19253
|
width = Math.abs(this.smallestVarianceDataPointValue.getScaledUnit()) + labelToBar + sizeLabelValue;
|
|
@@ -19235,43 +19258,47 @@ class StructureChart {
|
|
|
19235
19258
|
return width;
|
|
19236
19259
|
}
|
|
19237
19260
|
calculateRightSideWidth(varianceType) {
|
|
19238
|
-
var _a, _b, _c, _d, _e, _f;
|
|
19261
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
19239
19262
|
// Stacked charts: width based on the positive side of the stacks, not individual max
|
|
19240
19263
|
if (this.isStacked()) {
|
|
19241
19264
|
const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
|
|
19242
|
-
|
|
19243
|
-
|
|
19265
|
+
// a 100 % stack prints no total behind its bars: it needs room for half of the `100%` mark at most
|
|
19266
|
+
const totalDrawn = ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.mode) !== withStyled.StackMode.RELATIVE || ((_b = this.stackConfig) === null || _b === void 0 ? void 0 : _b.labels) === "value";
|
|
19267
|
+
let endRoom = labelToBar + this.calculateTextBoxWidth(this.stackSides.maxTotal);
|
|
19268
|
+
if (!totalDrawn)
|
|
19269
|
+
endRoom = this.hasPercentMark() ? this.boldWidth("100%") / 2 : 0;
|
|
19270
|
+
let width = Math.max(this.stackSides.positive * this.pixelPerUnit + endRoom, this.stackHeaderExtent());
|
|
19244
19271
|
// the category label of a row with a negative total sits right of the axis, behind its positive segments
|
|
19245
19272
|
if (this.stackSides.minTotal < 0) {
|
|
19246
19273
|
width = Math.max(width, this.stackLabelClearance.right * this.pixelPerUnit +
|
|
19247
19274
|
this.position.getCategoryToAxisSpaceing() +
|
|
19248
19275
|
this.calculateCategoryWidth());
|
|
19249
19276
|
}
|
|
19250
|
-
if ((
|
|
19277
|
+
if (((_c = this.stackConfig) === null || _c === void 0 ? void 0 : _c.totalTitle) && totalDrawn) {
|
|
19251
19278
|
const title = CalculateSize(this.stackConfig.totalTitle, {
|
|
19252
19279
|
font: this.styles.fontStyles.font,
|
|
19253
19280
|
fontSize: this.styles.fontStyles.size + "px",
|
|
19254
19281
|
}).width;
|
|
19255
19282
|
width = Math.max(width, this.stackSides.positive * this.pixelPerUnit + labelToBar + title);
|
|
19256
19283
|
}
|
|
19257
|
-
return Math.max(width, this.titleLength, (
|
|
19284
|
+
return Math.max(width, this.titleLength, (_e = (_d = this.sumColumns()) === null || _d === void 0 ? void 0 : _d.width) !== null && _e !== void 0 ? _e : 0, this.referenceLineExtent());
|
|
19258
19285
|
}
|
|
19259
19286
|
let width = 0;
|
|
19260
19287
|
const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
|
|
19261
19288
|
if (VarianceType$1.NONE === varianceType &&
|
|
19262
|
-
((
|
|
19289
|
+
((_f = this.highestDataPointValue) === null || _f === void 0 ? void 0 : _f.value) != null &&
|
|
19263
19290
|
this.highestDataPointValue.value >= 0) {
|
|
19264
19291
|
const sizeLabelValue = this.calculateTextBoxWidth(this.highestDataPointValue.value);
|
|
19265
19292
|
width = Math.abs(this.highestDataPointValue.getScaledUnit()) + labelToBar + sizeLabelValue;
|
|
19266
19293
|
}
|
|
19267
19294
|
else if (VarianceType$1.RELATIVE === varianceType &&
|
|
19268
|
-
((
|
|
19295
|
+
((_g = this.highestVarianceDataPointValue) === null || _g === void 0 ? void 0 : _g.value) != null &&
|
|
19269
19296
|
this.highestVarianceDataPointValue.value >= 0) {
|
|
19270
19297
|
const sizeLabelValue = this.calculatePercentageTextBoxWidth(this.highestVarianceDataPointValue.value);
|
|
19271
19298
|
width = Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit()) + labelToBar + sizeLabelValue;
|
|
19272
19299
|
}
|
|
19273
19300
|
else if (VarianceType$1.ABSOLUTE === varianceType &&
|
|
19274
|
-
((
|
|
19301
|
+
((_h = this.highestVarianceDataPointValue) === null || _h === void 0 ? void 0 : _h.value) != null &&
|
|
19275
19302
|
this.highestVarianceDataPointValue.value >= 0) {
|
|
19276
19303
|
const sizeLabelValue = this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value, true);
|
|
19277
19304
|
width = Math.abs(this.highestVarianceDataPointValue.getScaledUnit()) + labelToBar + sizeLabelValue;
|
|
@@ -1079,6 +1079,28 @@ export class StructureChart {
|
|
|
1079
1079
|
drawHeader(axisX + ((start + end) / 2) * seg.dataPoint.pixelPerUnit, this.i18n.get(seg.scenario) || seg.scenario);
|
|
1080
1080
|
});
|
|
1081
1081
|
}
|
|
1082
|
+
/** How far the header of a segment of the first row reaches right of the axis: a name can be wider than its segment. */
|
|
1083
|
+
stackHeaderExtent() {
|
|
1084
|
+
var _a;
|
|
1085
|
+
if (!this.stackConfig || this.dataModel.length === 0)
|
|
1086
|
+
return 0;
|
|
1087
|
+
const firstRow = (_a = this.dataModel.find((row) => !this.isTextSum(row))) !== null && _a !== void 0 ? _a : this.dataModel[0];
|
|
1088
|
+
const groups = this.stackGroups(firstRow);
|
|
1089
|
+
if (groups.length !== 1)
|
|
1090
|
+
return 0;
|
|
1091
|
+
const [group] = groups;
|
|
1092
|
+
let extent = 0;
|
|
1093
|
+
group.segments.forEach((seg, index) => {
|
|
1094
|
+
const { start, end } = group.layout.segments[index];
|
|
1095
|
+
const name = String(this.i18n.get(seg.scenario) || seg.scenario);
|
|
1096
|
+
const width = CalculateSize(name, {
|
|
1097
|
+
font: this.styles.fontStyles.font,
|
|
1098
|
+
fontSize: this.styles.fontStyles.size + "px",
|
|
1099
|
+
}).width;
|
|
1100
|
+
extent = Math.max(extent, ((start + end) / 2) * seg.dataPoint.pixelPerUnit + width / 2);
|
|
1101
|
+
});
|
|
1102
|
+
return extent;
|
|
1103
|
+
}
|
|
1082
1104
|
getVarianceType() {
|
|
1083
1105
|
if (this.variancesDataModel.length > 0) {
|
|
1084
1106
|
return this.variancesDataModel[0].type;
|
|
@@ -1086,14 +1108,15 @@ export class StructureChart {
|
|
|
1086
1108
|
return VarianceType.NONE;
|
|
1087
1109
|
}
|
|
1088
1110
|
calculateLeftSideWidth(varianceType) {
|
|
1089
|
-
var _a, _b, _c;
|
|
1111
|
+
var _a, _b, _c, _d, _e;
|
|
1090
1112
|
let width = 0;
|
|
1091
1113
|
const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
|
|
1092
1114
|
if (VarianceType.NONE === varianceType && this.isStacked()) {
|
|
1093
1115
|
// the negative side with the label of a negative total behind it
|
|
1094
1116
|
if (this.stackSides.negative > 0) {
|
|
1095
1117
|
width = this.stackSides.negative * this.pixelPerUnit;
|
|
1096
|
-
|
|
1118
|
+
const totalDrawn = ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.mode) !== StackMode.RELATIVE || ((_b = this.stackConfig) === null || _b === void 0 ? void 0 : _b.labels) === "value";
|
|
1119
|
+
if (this.stackSides.minTotal < 0 && totalDrawn) {
|
|
1097
1120
|
width += labelToBar + this.calculateTotalLabelWidth(this.stackSides.minTotal);
|
|
1098
1121
|
}
|
|
1099
1122
|
}
|
|
@@ -1103,19 +1126,19 @@ export class StructureChart {
|
|
|
1103
1126
|
}
|
|
1104
1127
|
}
|
|
1105
1128
|
else if (VarianceType.NONE === varianceType &&
|
|
1106
|
-
((
|
|
1129
|
+
((_c = this.smallestDataPointValue) === null || _c === void 0 ? void 0 : _c.value) != null &&
|
|
1107
1130
|
this.smallestDataPointValue.value < 0) {
|
|
1108
1131
|
const sizeLabelValue = this.calculateTextBoxWidth(this.smallestDataPointValue.value);
|
|
1109
1132
|
width = Math.abs(this.smallestDataPointValue.getScaledUnit()) + labelToBar + sizeLabelValue;
|
|
1110
1133
|
}
|
|
1111
1134
|
else if (VarianceType.RELATIVE === varianceType &&
|
|
1112
|
-
((
|
|
1135
|
+
((_d = this.smallestVarianceDataPointValue) === null || _d === void 0 ? void 0 : _d.value) != null &&
|
|
1113
1136
|
this.smallestVarianceDataPointValue.value < 0) {
|
|
1114
1137
|
const sizeLabelValue = this.calculatePercentageTextBoxWidth(this.smallestVarianceDataPointValue.value);
|
|
1115
1138
|
width = Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit()) + labelToBar + sizeLabelValue;
|
|
1116
1139
|
}
|
|
1117
1140
|
else if (VarianceType.ABSOLUTE === varianceType &&
|
|
1118
|
-
((
|
|
1141
|
+
((_e = this.smallestVarianceDataPointValue) === null || _e === void 0 ? void 0 : _e.value) != null &&
|
|
1119
1142
|
this.smallestVarianceDataPointValue.value < 0) {
|
|
1120
1143
|
const sizeLabelValue = this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value, true);
|
|
1121
1144
|
width = Math.abs(this.smallestVarianceDataPointValue.getScaledUnit()) + labelToBar + sizeLabelValue;
|
|
@@ -1126,43 +1149,47 @@ export class StructureChart {
|
|
|
1126
1149
|
return width;
|
|
1127
1150
|
}
|
|
1128
1151
|
calculateRightSideWidth(varianceType) {
|
|
1129
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1152
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1130
1153
|
// Stacked charts: width based on the positive side of the stacks, not individual max
|
|
1131
1154
|
if (this.isStacked()) {
|
|
1132
1155
|
const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
|
|
1133
|
-
|
|
1134
|
-
|
|
1156
|
+
// a 100 % stack prints no total behind its bars: it needs room for half of the `100%` mark at most
|
|
1157
|
+
const totalDrawn = ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.mode) !== StackMode.RELATIVE || ((_b = this.stackConfig) === null || _b === void 0 ? void 0 : _b.labels) === "value";
|
|
1158
|
+
let endRoom = labelToBar + this.calculateTextBoxWidth(this.stackSides.maxTotal);
|
|
1159
|
+
if (!totalDrawn)
|
|
1160
|
+
endRoom = this.hasPercentMark() ? this.boldWidth("100%") / 2 : 0;
|
|
1161
|
+
let width = Math.max(this.stackSides.positive * this.pixelPerUnit + endRoom, this.stackHeaderExtent());
|
|
1135
1162
|
// the category label of a row with a negative total sits right of the axis, behind its positive segments
|
|
1136
1163
|
if (this.stackSides.minTotal < 0) {
|
|
1137
1164
|
width = Math.max(width, this.stackLabelClearance.right * this.pixelPerUnit +
|
|
1138
1165
|
this.position.getCategoryToAxisSpaceing() +
|
|
1139
1166
|
this.calculateCategoryWidth());
|
|
1140
1167
|
}
|
|
1141
|
-
if ((
|
|
1168
|
+
if (((_c = this.stackConfig) === null || _c === void 0 ? void 0 : _c.totalTitle) && totalDrawn) {
|
|
1142
1169
|
const title = CalculateSize(this.stackConfig.totalTitle, {
|
|
1143
1170
|
font: this.styles.fontStyles.font,
|
|
1144
1171
|
fontSize: this.styles.fontStyles.size + "px",
|
|
1145
1172
|
}).width;
|
|
1146
1173
|
width = Math.max(width, this.stackSides.positive * this.pixelPerUnit + labelToBar + title);
|
|
1147
1174
|
}
|
|
1148
|
-
return Math.max(width, this.titleLength, (
|
|
1175
|
+
return Math.max(width, this.titleLength, (_e = (_d = this.sumColumns()) === null || _d === void 0 ? void 0 : _d.width) !== null && _e !== void 0 ? _e : 0, this.referenceLineExtent());
|
|
1149
1176
|
}
|
|
1150
1177
|
let width = 0;
|
|
1151
1178
|
const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
|
|
1152
1179
|
if (VarianceType.NONE === varianceType &&
|
|
1153
|
-
((
|
|
1180
|
+
((_f = this.highestDataPointValue) === null || _f === void 0 ? void 0 : _f.value) != null &&
|
|
1154
1181
|
this.highestDataPointValue.value >= 0) {
|
|
1155
1182
|
const sizeLabelValue = this.calculateTextBoxWidth(this.highestDataPointValue.value);
|
|
1156
1183
|
width = Math.abs(this.highestDataPointValue.getScaledUnit()) + labelToBar + sizeLabelValue;
|
|
1157
1184
|
}
|
|
1158
1185
|
else if (VarianceType.RELATIVE === varianceType &&
|
|
1159
|
-
((
|
|
1186
|
+
((_g = this.highestVarianceDataPointValue) === null || _g === void 0 ? void 0 : _g.value) != null &&
|
|
1160
1187
|
this.highestVarianceDataPointValue.value >= 0) {
|
|
1161
1188
|
const sizeLabelValue = this.calculatePercentageTextBoxWidth(this.highestVarianceDataPointValue.value);
|
|
1162
1189
|
width = Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit()) + labelToBar + sizeLabelValue;
|
|
1163
1190
|
}
|
|
1164
1191
|
else if (VarianceType.ABSOLUTE === varianceType &&
|
|
1165
|
-
((
|
|
1192
|
+
((_h = this.highestVarianceDataPointValue) === null || _h === void 0 ? void 0 : _h.value) != null &&
|
|
1166
1193
|
this.highestVarianceDataPointValue.value >= 0) {
|
|
1167
1194
|
const sizeLabelValue = this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value, true);
|
|
1168
1195
|
width = Math.abs(this.highestVarianceDataPointValue.getScaledUnit()) + labelToBar + sizeLabelValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as
|
|
1
|
+
import{B as s,d as o}from"./p-Q6JHDy4s.js";const p=s,r=o;export{p as BnChartStructureRenderer,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as i,w as e,f as s,h as a,d as r,t as n}from"./p-BnmylmXF.js";import{h as o,a as l}from"./p-5LbdDgZ5.js";import{k as c,v as h,a as d,i as u,l as p,b as v,c as m,h as g,m as f,n as b}from"./p-CcfvGlBq.js";import{v as y}from"./p-Zz3fAPcH.js";import{w as S}from"./p-ClFDt6Bk.js";import{w}from"./p-BrQCbmG0.js";import{i as k,w as O,a as _}from"./p-OR6uR6gy.js";import{w as A}from"./p-BPvwrhvq.js";import{w as N}from"./p-CU9CdEBF.js";import{w as x}from"./p-NkLVO7n9.js";import{r as D}from"./p-D0v9GMIf.js";import{w as T}from"./p-CFF7b9FT.js";import{w as L,r as R}from"./p-D32TsLzd.js";import{g as F}from"./p-Dsvjkuy3.js";import{r as C,f as W,p as U}from"./p-Xb6Ilq8u.js";import{o as P}from"./p-B6kka9sT.js";import{A as j,e as M,f as z,g as $}from"./p-DguYWLBj.js";import{a as B,O as E}from"./p-BBdzTx8V.js";import{L as I}from"./p-DY5fMUX8.js";import{o as G,m as H}from"./p-Bmb0YBzz.js";import{r as V,a as J}from"./p-CckAR27O.js";import{a as q}from"./p-CFY-zEXs.js";import{a as X}from"./p-JofGXz75.js";import{s as Y}from"./p-DakXa7Dp.js";import{d as Z}from"./p-DFkSF8_m.js";const Q=t(class t extends i{validateFilter(t){const i="ERR_filter";o(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(k(t)||c(t))return void this.errors.remove(i);const e=h(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(k(t))return void this.errors.remove(i);const e=d(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateUnitScaling(t){const i="WARN_unitScaling";u(t)?this.errors.remove(i):"invalid"===C(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="WARN_percentageScaling";u(t)?this.errors.remove(i):"invalid"===C(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validateLevel(t){const i="WARN_level";u(t)||p(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"level: invalid value(s) '"+t+"' are not supported."})}validateOrderList(t){const i="WARN_order";if(k(t))return void this.errors.remove(i);const e=v(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="WARN_orderDirection";k(t)||u(t)||m(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateLimit(t){const i="WARN_limit";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";f(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateDataFormatDigitsDecimal(t){this.validateDigits("dataFormatDigitsDecimal",t)}validateDataFormatDigitsPercent(t){this.validateDigits("dataFormatDigitsPercent",t)}validateDigits(t,i){const e="WARN_"+t;!g(i)||Number(i)<0||Number(i)>100?this.errors.addOrReplace({id:e,type:"warning",message:t+": invalid value '"+i+"' is not supported."}):this.errors.remove(e)}validateSums(t){this.warnUnless("sums",["none","groups","total","all"].includes(t),t)}validateScenarioLabelPosition(t){this.warnUnless("scenarioLabelPosition",["bottom","top"].includes(t),t)}validateReferenceLine(t){this.warnUnless("referenceLine",u(t)||null!==this.prepareReferenceLine(),t)}validateItalicCategories(t){this.warnUnless("italicCategories",u(t)||null!==this.prepareItalicCategories(),t)}warnUnless(t,i,e){const s="WARN_"+t;i?this.errors.remove(s):this.errors.addOrReplace({id:s,type:"warning",message:t+": invalid value '"+e+"' is not supported."})}prepareReferenceLine(){if(u(this.referenceLine))return null;try{const t=JSON.parse(this.referenceLine);return"number"==typeof(null==t?void 0:t.value)&&Number.isFinite(t.value)?{value:t.value,label:"string"==typeof t.label?t.label:void 0}:null}catch(t){return null}}prepareItalicCategories(){if(u(this.italicCategories))return[];try{const t=JSON.parse(this.italicCategories);return Array.isArray(t)&&t.every((t=>"string"==typeof t))?t:null}catch(t){return null}}validateStack(t){const i="WARN_stack",e=b(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:e.join("; ")}):this.errors.remove(i)}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("WARN_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"WARN_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("WARN_scale")}constructor(i){super(),!1!==i&&this.__registerHost(),this.__attachShadow(),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this._lastScaledParentHeight=0,this.chartTitle="",this.filter="",this.limit=0,this.showCategories=!0,this.measureScale="greatest",this.showMeasureScale=!1,this.measureUnit="",this.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.sums="none",this.sumTitle="",this.valueSuffix="",this.scenarioLabelPosition="bottom",this.referenceLine="",this.italicCategories="",this.stack="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=i=>{var e,s,a,r,n,o;this.lastAutoScalingReport={unit:null!==(e=i.unit)&&void 0!==e?e:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(a=i.percentage)&&void 0!==a?a:null===(r=this.lastAutoScalingReport)||void 0===r?void 0:r.percentage};const l=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),c=this.getEffectiveFontPx();if(void 0!==i.unit&&i.unit>0&&this.autoUnitWarningActive){const e=c/i.unit;l(e,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=e,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(((null!==(n=this.unitScaling)&&void 0!==n?n:"")+"").trim())}, auto-fitted to 1 em ≈ ${W(e)} units.`}))}if(void 0!==i.percentage&&i.percentage>0&&this.autoPctWarningActive){const e=100*c/i.percentage;l(e,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=e,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(((null!==(o=this.percentageScaling)&&void 0!==o?o:"")+"").trim())}, auto-fitted to 1 em ≈ ${W(e)} percentage points.`}))}},N(this),w(this),S(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=L(this),A(this),this.componentStyle=x(this),this.ruleSetConfig=T(this),this.t=O(this).t,this.resolveInherited=_(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}],this.errors)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDataFormatDigitsPercent(this.dataFormatDigitsPercent),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateMeasureScale(this.measureScale),this.validateStack(this.stack),this.validateSums(this.sums),this.validateScenarioLabelPosition(this.scenarioLabelPosition),this.validateReferenceLine(this.referenceLine),this.validateItalicCategories(this.italicCategories),this.validateScaling(this.scale)}componentDidRender(){Y(this.element,"bn-chart-structure-renderer");const{mode:t}=U(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{height:s}=F(i);if(s<=0)return void this.checkOverflow();this._lastScaledParentHeight=s;const a=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollHeight,n=this.appliedScaleFactor;if(r<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,n*(s-1)/r);Math.abs(o-n)<.01||(i.style.setProperty("--bn-font-size",a*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=P(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=F(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,s(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=F(this.element);this._lastScaledParentHeight=t,s(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}measureContentWidth(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-structure-renderer");let e=0,s=!1;return null==i||i.forEach((t=>{var i,a,r;const n=parseFloat(null!==(r=null===(a=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===a?void 0:a.getAttribute("width"))&&void 0!==r?r:"");Number.isNaN(n)||(e+=n,s=!0)})),s?Math.max(Math.floor(e),this.element.scrollWidth):this.element.scrollWidth}checkOverflow(){const t=F(this.element),i=this.measureContentWidth(),e=this.element.scrollHeight,s=t.width>0&&i>t.width+1,a=t.height>0&&e>t.height+1;if(!s&&!a)return void R(this.errors,null);const r=this.prepareVariances().some((t=>t.startsWith("dr"))),n="value"===C(this.unitScaling,this.pixelPerUnitGroupMap).kind,o=r&&"value"===C(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:l}=U(this.scale),c="auto"!==l&&"empty"!==l,h=[];s&&n&&h.push("unit-scaling"),s&&o&&h.push("percentage-scaling"),a&&c&&h.push("scale");const d=[];s&&d.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),a&&d.push(`height (${Math.round(e)}px > ${Math.round(t.height)}px)`),R(this.errors,`Chart exceeds available ${d.join(" and ")}. `+(h.length>0?`Adjust ${h.join(" / ")} or set to "auto".`:"Content does not fit even at minimum auto scaling; enlarge the container."),h.length>0)}prepareDimension(){const t=F(this.element),i=Math.max(1,this.prepareSegments().length);return this.canvasWidthSegmented=t.width/i,{width:this.canvasWidthSegmented,height:t.height}}prepareScenarios(){var t,i,e,s;const a=this.resolveInherited("scenarios",this.scenarios);if(a.inherited)return this.errors.remove("AUTO_scenarios"),a.value.split(",").map((t=>t.trim()));if(c(a.value))return this.errors.remove("AUTO_scenarios"),[];const r="auto"===(null===(t=a.value)||void 0===t?void 0:t.trim().toLowerCase());return u(a.value)||r?(null===(e=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===e?void 0:e.length)>0?(r||a.unresolved?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(s=a.value)||void 0===s?void 0:s.split(",").map((t=>t.trim())))}prepareVariances(){const t=this.resolveInherited("variances",this.variances).value;return u(t)?[]:null==t?void 0:t.split(",").map((t=>t.trim()))}hidesScenarios(){const t=this.resolveInherited("scenarios",this.scenarios);return!t.inherited&&c(t.value)}prepareSegments(){return this.hidesScenarios()?this.prepareVariances():["",...this.prepareVariances()]}prepareHideCategories(t){return t>=1||!this.showCategories}prepareI18n(){const t=l,i=new Map(["no-data","REST"].map((t=>[t,this.t(".".concat(t))]))),e=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...i.entries(),...D(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const i=C(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/i.value):"auto"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const i=C(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/i.value):"auto"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}prepareLevel(){var t,i,e;const s="auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase());return u(this.level)||s?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?(s?this.errors.remove("AUTO_level"):this.errors.addOrReplace({id:"AUTO_level",type:"warning",message:"level: not set, auto-detected: "+this.datasetMeta.suggestedLevel}),j[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),j[null===(e=this.level)||void 0===e?void 0:e.toUpperCase()])}prepareOrder(){var t;const i=this.resolveInherited("order",this.order),e=i.value,s=this.resolveInherited("orderDirection",this.orderDirection).value,a="auto"===(null==e?void 0:e.trim().toLowerCase());let r;return u(e)||a?(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)?(a||i.unresolved?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:"order: not set, auto-detected: "+this.datasetMeta.suggestedOrder}),r=this.datasetMeta.suggestedOrder):r=e:(this.errors.remove("AUTO_order"),r=e),{hierarchy:null==r?void 0:r.split(",").map((t=>E[null==t?void 0:t.toUpperCase()])),direction:B[null==s?void 0:s.toUpperCase()]}}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const e=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-structure"].scaleFactors.scenarioOffset,scenarioLabelToBar:i["bn-chart-structure"].scaleFactors.scenarioLabelToBar,labelToBar:i["bn-chart-structure"].scaleFactors.labelToBar,labelToAxis:i["bn-chart-structure"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-structure"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-structure"].scaleFactors.needleHeadWidth,barWidth:i["bn-chart-structure"].scaleFactors.barWidth,varianceAxisLineWidth:i["bn-chart-structure"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-structure"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-structure"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-structure"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-structure"].scaleFactors.markerWidth,markerOffset:i["bn-chart-structure"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-structure"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-structure"].scaleFactors.axisTickLength},fontStyles:{font:`${e}px ${i.global.fontFamily}`,family:i.global.fontFamily,size:e,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-structure"].axisStyles,barStyles:i["bn-chart-structure"].barStyles,varianceStyles:i["bn-chart-structure"].varianceStyles,stackColors:i["bn-chart-structure"].stackColors,titleBold:i["bn-chart-structure"].titleBold,padding:i["bn-chart-structure"].padding,pattern:null}}))}prepareChartTitle(t){return t>=1||this.hidesScenarios()?"":this.chartTitle}prepareStackConfig(){if(u(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),this.errors.remove("WARN_stack_thickness_variances"),null;try{const t=JSON.parse(this.stack),i=t.by,e="WARN_stack_dimensions_scenarios";if(i===M.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:e,type:"warning",message:`stack by dimensions: only the first scenario "${t[0]}" is used, the rest (${t.slice(1).join(", ")}) are discarded.`}):this.errors.remove(e)}else this.errors.remove(e);const s="total"===t.thickness,a=s&&this.prepareVariances().length>0;return a?this.errors.addOrReplace({id:"WARN_stack_thickness_variances",type:"warning",message:"stack thickness total: not used together with variances, the rows keep one height."}):this.errors.remove("WARN_stack_thickness_variances"),{by:i,mode:t.mode||$.ABSOLUTE,order:t.order||z.DATASET,percentMark:!0===t.percentMark,labels:"value"===t.labels?"value":"share",thickness:s&&!a?"total":"equal",totalTitle:"string"==typeof t.totalTitle?t.totalTitle:void 0}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),this.errors.remove("WARN_stack_thickness_variances"),null}}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareLimit(){return Math.floor(Number(this.limit)||0)}getDataStructure(){return{IStructureChartDataRow:{operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return u(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}chartTemplate(t,i){var e;const s=this.preparePixelPerUnit(),r=this.preparePixelPerPercentage(),n=this.prepareStackConfig(),o=""===t,l=this.hidesScenarios()?y([t]):this.prepareScenarios(),c=o&&(null==n?void 0:n.by)===M.DIMENSIONS?l.slice(0,1):l;return a("bn-chart-structure-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(i),scenarios:c,variances:[t],hideCategories:this.prepareHideCategories(i),pixelPerUnit:s,pixelPerPercentage:r,reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,limit:this.prepareLimit(),styles:this.prepareStyle(),i18n:this.prepareI18n(),order:this.prepareOrder(),level:this.prepareLevel(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(i),stackConfig:n,sums:["groups","total","all"].includes(this.sums)?this.sums:"none",sumTitle:this.sumTitle,valueSuffix:this.valueSuffix,scenarioLabelTop:"top"===this.scenarioLabelPosition,hideScenarioName:this.hidesScenarios(),referenceLine:o?this.prepareReferenceLine():null,italicCategories:null!==(e=this.prepareItalicCategories())&&void 0!==e?e:[],dataFormatDigits:{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal},parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}async getBaseline(){return X(this.element,"bn-chart-structure-renderer")}async getLayoutState(t){var i,e,s,a;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",n=G(this.element),o=this.getEffectiveScaleFactor(),l=Number.isFinite(o)&&o>0?o:1,c=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*l,h=this.prepareVariances(),d=q(this.element,"bn-chart-structure-renderer",this.prepareSegments().map((t=>t||"base")),n,r),u=null===(e=this.element.shadowRoot)||void 0===e?void 0:e.querySelector("bn-chart-structure-renderer"),p={version:I,tag:this.element.localName,id:J(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:H(this.element,n),em:{fontSizePx:c,appliedScaleFactor:l},regions:d.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(a=null==u?void 0:u.scenarios)&&void 0!==a?a:[],variances:h,barCount:d.barCount,hasNoData:0===d.barCount},diagnostics:V(this.element),scaling:this.resolveScalingInfo(c),baseline:d.baseline};return d.elements&&(p.elements=d.elements),p}resolveScalingInfo(t){var i,e;const s={},a=C(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===a.kind)s.unitMode="fixed",s.unitsPerEm=a.value,s.unitPxPerUnit=t/a.value;else{s.unitMode="auto";const e=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==e&&e>0&&(s.unitPxPerUnit=e,s.unitsPerEm=t/e)}const r=C(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)s.percentageMode="fixed",s.percentagePointsPerEm=r.value,s.percentagePxPerPoint=t/r.value;else{s.percentageMode="auto";const i=null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.percentage;void 0!==i&&i>0&&(s.percentagePxPerPoint=i/100,s.percentagePointsPerEm=100*t/i)}return s}getEffectiveScaleFactor(){const{mode:t,factor:i}=U(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,s,a,r;const n=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=i.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(a=i.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.prepareSegments();0===t.length?this.errors.addOrReplace({id:"WARN_scenarios_none",type:"warning",message:"scenarios: none needs at least one variance, the chart is empty."}):this.errors.remove("WARN_scenarios_none");const i=this.getFontStyles();return a(r,{key:"132c843c3a3b2a3780acf89370b6a6eb75c10170",style:i},a("div",{key:"84a2f28b516bfc71ca8145158cc48d9dcbcb46c4",class:"container"},t.map(this.chartTemplate)))}get element(){return this}static get watchers(){return{filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDataFormatDigitsPercent:0}],sums:[{validateSums:0}],scenarioLabelPosition:[{validateScenarioLabelPosition:0}],referenceLine:[{validateReferenceLine:0}],italicCategories:[{validateItalicCategories:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}'}},[1,"bn-chart-structure",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],chartTitle:[1,"chart-title"],ruleset:[513],filter:[1],scenarios:[1],variances:[1],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],level:[1],order:[1],orderDirection:[1,"order-direction"],limit:[2],showCategories:[4,"show-categories"],measureScale:[1,"measure-scale"],showMeasureScale:[4,"show-measure-scale"],measureUnit:[1,"measure-unit"],dataFormatDigitsDecimal:[2,"data-format-digits-decimal"],dataFormatDigitsPercent:[2,"data-format-digits-percent"],sums:[1],sumTitle:[1,"sum-title"],valueSuffix:[1,"value-suffix"],scenarioLabelPosition:[1,"scenario-label-position"],referenceLine:[1,"reference-line"],italicCategories:[1,"italic-categories"],stack:[1],scale:[1],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDataFormatDigitsPercent:0}],sums:[{validateSums:0}],scenarioLabelPosition:[{validateScenarioLabelPosition:0}],referenceLine:[{validateReferenceLine:0}],italicCategories:[{validateItalicCategories:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}]),K=Q,tt=function(){"undefined"!=typeof customElements&&["bn-chart-structure","bn-chart-structure-renderer"].forEach((t=>{switch(t){case"bn-chart-structure":customElements.get(n(t))||customElements.define(n(t),Q);break;case"bn-chart-structure-renderer":customElements.get(n(t))||Z()}}))};export{K as BnChartStructure,tt as defineCustomElement}
|
|
1
|
+
import{p as t,H as i,w as e,f as s,h as a,d as r,t as n}from"./p-BnmylmXF.js";import{h as o,a as l}from"./p-5LbdDgZ5.js";import{k as c,v as h,a as d,i as u,l as p,b as v,c as m,h as g,m as f,n as b}from"./p-CcfvGlBq.js";import{v as y}from"./p-Zz3fAPcH.js";import{w as S}from"./p-ClFDt6Bk.js";import{w}from"./p-BrQCbmG0.js";import{i as k,w as O,a as A}from"./p-OR6uR6gy.js";import{w as _}from"./p-BPvwrhvq.js";import{w as N}from"./p-CU9CdEBF.js";import{w as x}from"./p-NkLVO7n9.js";import{r as D}from"./p-D0v9GMIf.js";import{w as T}from"./p-CFF7b9FT.js";import{w as L,r as R}from"./p-D32TsLzd.js";import{g as C}from"./p-Dsvjkuy3.js";import{r as W,f as F,p as U}from"./p-Xb6Ilq8u.js";import{o as P}from"./p-B6kka9sT.js";import{A as j,e as M,f as z,g as $}from"./p-DguYWLBj.js";import{a as B,O as E}from"./p-BBdzTx8V.js";import{L as I}from"./p-DY5fMUX8.js";import{o as G,m as H}from"./p-Bmb0YBzz.js";import{r as J,a as V}from"./p-CckAR27O.js";import{a as q}from"./p-CFY-zEXs.js";import{a as X}from"./p-JofGXz75.js";import{s as Y}from"./p-DakXa7Dp.js";import{d as Z}from"./p-Q6JHDy4s.js";const Q=t(class t extends i{validateFilter(t){const i="ERR_filter";o(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(k(t)||c(t))return void this.errors.remove(i);const e=h(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(k(t))return void this.errors.remove(i);const e=d(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateUnitScaling(t){const i="WARN_unitScaling";u(t)?this.errors.remove(i):"invalid"===W(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="WARN_percentageScaling";u(t)?this.errors.remove(i):"invalid"===W(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validateLevel(t){const i="WARN_level";u(t)||p(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"level: invalid value(s) '"+t+"' are not supported."})}validateOrderList(t){const i="WARN_order";if(k(t))return void this.errors.remove(i);const e=v(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="WARN_orderDirection";k(t)||u(t)||m(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateLimit(t){const i="WARN_limit";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";f(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateDataFormatDigitsDecimal(t){this.validateDigits("dataFormatDigitsDecimal",t)}validateDataFormatDigitsPercent(t){this.validateDigits("dataFormatDigitsPercent",t)}validateDigits(t,i){const e="WARN_"+t;!g(i)||Number(i)<0||Number(i)>100?this.errors.addOrReplace({id:e,type:"warning",message:t+": invalid value '"+i+"' is not supported."}):this.errors.remove(e)}validateSums(t){this.warnUnless("sums",["none","groups","total","all"].includes(t),t)}validateScenarioLabelPosition(t){this.warnUnless("scenarioLabelPosition",["bottom","top"].includes(t),t)}validateReferenceLine(t){this.warnUnless("referenceLine",u(t)||null!==this.prepareReferenceLine(),t)}validateItalicCategories(t){this.warnUnless("italicCategories",u(t)||null!==this.prepareItalicCategories(),t)}warnUnless(t,i,e){const s="WARN_"+t;i?this.errors.remove(s):this.errors.addOrReplace({id:s,type:"warning",message:t+": invalid value '"+e+"' is not supported."})}prepareReferenceLine(){if(u(this.referenceLine))return null;try{const t=JSON.parse(this.referenceLine);return"number"==typeof(null==t?void 0:t.value)&&Number.isFinite(t.value)?{value:t.value,label:"string"==typeof t.label?t.label:void 0}:null}catch(t){return null}}prepareItalicCategories(){if(u(this.italicCategories))return[];try{const t=JSON.parse(this.italicCategories);return Array.isArray(t)&&t.every((t=>"string"==typeof t))?t:null}catch(t){return null}}validateStack(t){const i="WARN_stack",e=b(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:e.join("; ")}):this.errors.remove(i)}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("WARN_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"WARN_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("WARN_scale")}constructor(i){super(),!1!==i&&this.__registerHost(),this.__attachShadow(),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this._lastScaledParentHeight=0,this.chartTitle="",this.filter="",this.limit=0,this.showCategories=!0,this.measureScale="greatest",this.showMeasureScale=!1,this.measureUnit="",this.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.sums="none",this.sumTitle="",this.valueSuffix="",this.scenarioLabelPosition="bottom",this.referenceLine="",this.italicCategories="",this.stack="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=i=>{var e,s,a,r,n,o;this.lastAutoScalingReport={unit:null!==(e=i.unit)&&void 0!==e?e:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(a=i.percentage)&&void 0!==a?a:null===(r=this.lastAutoScalingReport)||void 0===r?void 0:r.percentage};const l=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),c=this.getEffectiveFontPx();if(void 0!==i.unit&&i.unit>0&&this.autoUnitWarningActive){const e=c/i.unit;l(e,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=e,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(((null!==(n=this.unitScaling)&&void 0!==n?n:"")+"").trim())}, auto-fitted to 1 em ≈ ${F(e)} units.`}))}if(void 0!==i.percentage&&i.percentage>0&&this.autoPctWarningActive){const e=100*c/i.percentage;l(e,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=e,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(((null!==(o=this.percentageScaling)&&void 0!==o?o:"")+"").trim())}, auto-fitted to 1 em ≈ ${F(e)} percentage points.`}))}},N(this),w(this),S(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=L(this),_(this),this.componentStyle=x(this),this.ruleSetConfig=T(this),this.t=O(this).t,this.resolveInherited=A(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}],this.errors)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDataFormatDigitsPercent(this.dataFormatDigitsPercent),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateMeasureScale(this.measureScale),this.validateStack(this.stack),this.validateSums(this.sums),this.validateScenarioLabelPosition(this.scenarioLabelPosition),this.validateReferenceLine(this.referenceLine),this.validateItalicCategories(this.italicCategories),this.validateScaling(this.scale)}componentDidRender(){Y(this.element,"bn-chart-structure-renderer");const{mode:t}=U(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{height:s}=C(i);if(s<=0)return void this.checkOverflow();this._lastScaledParentHeight=s;const a=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollHeight,n=this.appliedScaleFactor;if(r<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,n*(s-1)/r);Math.abs(o-n)<.01||(i.style.setProperty("--bn-font-size",a*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=P(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=C(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,s(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=C(this.element);this._lastScaledParentHeight=t,s(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}measureContentWidth(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-structure-renderer");let e=0,s=!1;return null==i||i.forEach((t=>{var i,a,r;const n=parseFloat(null!==(r=null===(a=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===a?void 0:a.getAttribute("width"))&&void 0!==r?r:"");Number.isNaN(n)||(e+=n,s=!0)})),s?Math.max(Math.floor(e),this.element.scrollWidth):this.element.scrollWidth}checkOverflow(){const t=C(this.element),i=this.measureContentWidth(),e=this.element.scrollHeight,s=t.width>0&&i>t.width+1,a=t.height>0&&e>t.height+1;if(!s&&!a)return void R(this.errors,null);const r=this.prepareVariances().some((t=>t.startsWith("dr"))),n="value"===W(this.unitScaling,this.pixelPerUnitGroupMap).kind,o=r&&"value"===W(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:l}=U(this.scale),c="auto"!==l&&"empty"!==l,h=[];s&&n&&h.push("unit-scaling"),s&&o&&h.push("percentage-scaling"),a&&c&&h.push("scale");const d=[];s&&d.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),a&&d.push(`height (${Math.round(e)}px > ${Math.round(t.height)}px)`),R(this.errors,`Chart exceeds available ${d.join(" and ")}. `+(h.length>0?`Adjust ${h.join(" / ")} or set to "auto".`:"Content does not fit even at minimum auto scaling; enlarge the container."),h.length>0)}prepareDimension(){const t=C(this.element),i=Math.max(1,this.prepareSegments().length);return this.canvasWidthSegmented=t.width/i,{width:this.canvasWidthSegmented,height:t.height}}prepareScenarios(){var t,i,e,s;const a=this.resolveInherited("scenarios",this.scenarios);if(a.inherited)return this.errors.remove("AUTO_scenarios"),a.value.split(",").map((t=>t.trim()));if(c(a.value))return this.errors.remove("AUTO_scenarios"),[];const r="auto"===(null===(t=a.value)||void 0===t?void 0:t.trim().toLowerCase());return u(a.value)||r?(null===(e=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===e?void 0:e.length)>0?(r||a.unresolved?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(s=a.value)||void 0===s?void 0:s.split(",").map((t=>t.trim())))}prepareVariances(){const t=this.resolveInherited("variances",this.variances).value;return u(t)?[]:null==t?void 0:t.split(",").map((t=>t.trim()))}hidesScenarios(){const t=this.resolveInherited("scenarios",this.scenarios);return!t.inherited&&c(t.value)}prepareSegments(){return this.hidesScenarios()?this.prepareVariances():["",...this.prepareVariances()]}prepareHideCategories(t){return t>=1||!this.showCategories}prepareI18n(){const t=l,i=new Map(["no-data","REST"].map((t=>[t,this.t(".".concat(t))]))),e=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...i.entries(),...D(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const i=W(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/i.value):"auto"===i.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const i=W(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/i.value):"auto"===i.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${t.describeScalingInput(i.raw)}, auto-calculated to fit available space.`}),0)}prepareLevel(){var t,i,e;const s="auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase());return u(this.level)||s?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?(s?this.errors.remove("AUTO_level"):this.errors.addOrReplace({id:"AUTO_level",type:"warning",message:"level: not set, auto-detected: "+this.datasetMeta.suggestedLevel}),j[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),j[null===(e=this.level)||void 0===e?void 0:e.toUpperCase()])}prepareOrder(){var t;const i=this.resolveInherited("order",this.order),e=i.value,s=this.resolveInherited("orderDirection",this.orderDirection).value,a="auto"===(null==e?void 0:e.trim().toLowerCase());let r;return u(e)||a?(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)?(a||i.unresolved?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:"order: not set, auto-detected: "+this.datasetMeta.suggestedOrder}),r=this.datasetMeta.suggestedOrder):r=e:(this.errors.remove("AUTO_order"),r=e),{hierarchy:null==r?void 0:r.split(",").map((t=>E[null==t?void 0:t.toUpperCase()])),direction:B[null==s?void 0:s.toUpperCase()]}}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const e=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-structure"].scaleFactors.scenarioOffset,scenarioLabelToBar:i["bn-chart-structure"].scaleFactors.scenarioLabelToBar,labelToBar:i["bn-chart-structure"].scaleFactors.labelToBar,labelToAxis:i["bn-chart-structure"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-structure"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-structure"].scaleFactors.needleHeadWidth,barWidth:i["bn-chart-structure"].scaleFactors.barWidth,varianceAxisLineWidth:i["bn-chart-structure"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-structure"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-structure"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-structure"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-structure"].scaleFactors.markerWidth,markerOffset:i["bn-chart-structure"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-structure"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-structure"].scaleFactors.axisTickLength},fontStyles:{font:`${e}px ${i.global.fontFamily}`,family:i.global.fontFamily,size:e,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-structure"].axisStyles,barStyles:i["bn-chart-structure"].barStyles,varianceStyles:i["bn-chart-structure"].varianceStyles,stackColors:i["bn-chart-structure"].stackColors,titleBold:i["bn-chart-structure"].titleBold,padding:i["bn-chart-structure"].padding,pattern:null}}))}prepareChartTitle(t){return t>=1||this.hidesScenarios()?"":this.chartTitle}prepareStackConfig(){if(u(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),this.errors.remove("WARN_stack_thickness_variances"),null;try{const t=JSON.parse(this.stack),i=t.by,e="WARN_stack_dimensions_scenarios";if(i===M.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:e,type:"warning",message:`stack by dimensions: only the first scenario "${t[0]}" is used, the rest (${t.slice(1).join(", ")}) are discarded.`}):this.errors.remove(e)}else this.errors.remove(e);const s="total"===t.thickness,a=s&&this.prepareVariances().length>0;return a?this.errors.addOrReplace({id:"WARN_stack_thickness_variances",type:"warning",message:"stack thickness total: not used together with variances, the rows keep one height."}):this.errors.remove("WARN_stack_thickness_variances"),{by:i,mode:t.mode||$.ABSOLUTE,order:t.order||z.DATASET,percentMark:!0===t.percentMark,labels:"value"===t.labels?"value":"share",thickness:s&&!a?"total":"equal",totalTitle:"string"==typeof t.totalTitle?t.totalTitle:void 0}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),this.errors.remove("WARN_stack_thickness_variances"),null}}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareLimit(){return Math.floor(Number(this.limit)||0)}getDataStructure(){return{IStructureChartDataRow:{operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return u(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}chartTemplate(t,i){var e;const s=this.preparePixelPerUnit(),r=this.preparePixelPerPercentage(),n=this.prepareStackConfig(),o=""===t,l=this.hidesScenarios()?y([t]):this.prepareScenarios(),c=o&&(null==n?void 0:n.by)===M.DIMENSIONS?l.slice(0,1):l;return a("bn-chart-structure-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(i),scenarios:c,variances:[t],hideCategories:this.prepareHideCategories(i),pixelPerUnit:s,pixelPerPercentage:r,reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,limit:this.prepareLimit(),styles:this.prepareStyle(),i18n:this.prepareI18n(),order:this.prepareOrder(),level:this.prepareLevel(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(i),stackConfig:n,sums:["groups","total","all"].includes(this.sums)?this.sums:"none",sumTitle:this.sumTitle,valueSuffix:this.valueSuffix,scenarioLabelTop:"top"===this.scenarioLabelPosition,hideScenarioName:this.hidesScenarios(),referenceLine:o?this.prepareReferenceLine():null,italicCategories:null!==(e=this.prepareItalicCategories())&&void 0!==e?e:[],dataFormatDigits:{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal},parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}async getBaseline(){return X(this.element,"bn-chart-structure-renderer")}async getLayoutState(t){var i,e,s,a;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",n=G(this.element),o=this.getEffectiveScaleFactor(),l=Number.isFinite(o)&&o>0?o:1,c=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*l,h=this.prepareVariances(),d=q(this.element,"bn-chart-structure-renderer",this.prepareSegments().map((t=>t||"base")),n,r),u=null===(e=this.element.shadowRoot)||void 0===e?void 0:e.querySelector("bn-chart-structure-renderer"),p={version:I,tag:this.element.localName,id:V(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:H(this.element,n),em:{fontSizePx:c,appliedScaleFactor:l},regions:d.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(a=null==u?void 0:u.scenarios)&&void 0!==a?a:[],variances:h,barCount:d.barCount,hasNoData:0===d.barCount},diagnostics:J(this.element),scaling:this.resolveScalingInfo(c),baseline:d.baseline};return d.elements&&(p.elements=d.elements),p}resolveScalingInfo(t){var i,e;const s={},a=W(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===a.kind)s.unitMode="fixed",s.unitsPerEm=a.value,s.unitPxPerUnit=t/a.value;else{s.unitMode="auto";const e=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==e&&e>0&&(s.unitPxPerUnit=e,s.unitsPerEm=t/e)}const r=W(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)s.percentageMode="fixed",s.percentagePointsPerEm=r.value,s.percentagePxPerPoint=t/r.value;else{s.percentageMode="auto";const i=null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.percentage;void 0!==i&&i>0&&(s.percentagePxPerPoint=i/100,s.percentagePointsPerEm=100*t/i)}return s}getEffectiveScaleFactor(){const{mode:t,factor:i}=U(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,s,a,r;const n=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=i.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(a=i.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.prepareSegments();0===t.length?this.errors.addOrReplace({id:"WARN_scenarios_none",type:"warning",message:"scenarios: none needs at least one variance, the chart is empty."}):this.errors.remove("WARN_scenarios_none");const i=this.getFontStyles();return a(r,{key:"132c843c3a3b2a3780acf89370b6a6eb75c10170",style:i},a("div",{key:"84a2f28b516bfc71ca8145158cc48d9dcbcb46c4",class:"container"},t.map(this.chartTemplate)))}get element(){return this}static get watchers(){return{filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDataFormatDigitsPercent:0}],sums:[{validateSums:0}],scenarioLabelPosition:[{validateScenarioLabelPosition:0}],referenceLine:[{validateReferenceLine:0}],italicCategories:[{validateItalicCategories:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}'}},[1,"bn-chart-structure",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],chartTitle:[1,"chart-title"],ruleset:[513],filter:[1],scenarios:[1],variances:[1],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],level:[1],order:[1],orderDirection:[1,"order-direction"],limit:[2],showCategories:[4,"show-categories"],measureScale:[1,"measure-scale"],showMeasureScale:[4,"show-measure-scale"],measureUnit:[1,"measure-unit"],dataFormatDigitsDecimal:[2,"data-format-digits-decimal"],dataFormatDigitsPercent:[2,"data-format-digits-percent"],sums:[1],sumTitle:[1,"sum-title"],valueSuffix:[1,"value-suffix"],scenarioLabelPosition:[1,"scenario-label-position"],referenceLine:[1,"reference-line"],italicCategories:[1,"italic-categories"],stack:[1],scale:[1],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDataFormatDigitsPercent:0}],sums:[{validateSums:0}],scenarioLabelPosition:[{validateScenarioLabelPosition:0}],referenceLine:[{validateReferenceLine:0}],italicCategories:[{validateItalicCategories:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}]),K=Q,tt=function(){"undefined"!=typeof customElements&&["bn-chart-structure","bn-chart-structure-renderer"].forEach((t=>{switch(t){case"bn-chart-structure":customElements.get(n(t))||customElements.define(n(t),Q);break;case"bn-chart-structure-renderer":customElements.get(n(t))||Z()}}))};export{K as BnChartStructure,tt as defineCustomElement}
|