@bino-bi/bn-template-engine 1.0.0-next.23 → 1.0.0-next.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/index.esm.js +1 -0
  3. package/dist/bn-template-engine/{p-68aa61cc.entry.js → p-03304284.entry.js} +1 -1
  4. package/dist/bn-template-engine/p-0b2e1661.entry.js +1 -0
  5. package/dist/bn-template-engine/{p-d7c670ec.entry.js → p-0fb02c57.entry.js} +1 -1
  6. package/dist/bn-template-engine/p-2fbc2d50.entry.js +1 -0
  7. package/dist/bn-template-engine/p-36f1c5f9.entry.js +1 -0
  8. package/dist/bn-template-engine/p-4419db8f.entry.js +1 -0
  9. package/dist/bn-template-engine/p-45508f1b.entry.js +1 -0
  10. package/dist/bn-template-engine/p-5d7a3a77.entry.js +1 -0
  11. package/dist/bn-template-engine/p-62cc95b7.entry.js +1 -0
  12. package/dist/bn-template-engine/{p-CbciPY-M.js → p-B5Jd_eCX.js} +1 -1
  13. package/dist/bn-template-engine/{p-DdqXNsKP.js → p-BbmobTg0.js} +1 -1
  14. package/dist/bn-template-engine/p-BcLsoDrW.js +1 -0
  15. package/dist/bn-template-engine/{p-CDo04UEU.js → p-BcaI745G.js} +1 -1
  16. package/dist/bn-template-engine/{p-BVfLus3u.js → p-CG_Bcm6V.js} +1 -1
  17. package/dist/bn-template-engine/{p-BGrnfif3.js → p-CWWWM-XC.js} +1 -1
  18. package/dist/bn-template-engine/{p-CuR4S456.js → p-CsJ84YRk.js} +1 -1
  19. package/dist/bn-template-engine/{p-C7T4DAAW.js → p-D5e8I9Qe.js} +1 -1
  20. package/dist/bn-template-engine/p-DVrDYxlh.js +1 -0
  21. package/dist/bn-template-engine/p-DjPXefnq.js +1 -0
  22. package/dist/bn-template-engine/{p-UtNHLX1j.js → p-EtT29btN.js} +1 -1
  23. package/dist/bn-template-engine/{p-B5x8M8OC.js → p-TuLpbB5O.js} +1 -1
  24. package/dist/bn-template-engine/{p-e4a584a8.entry.js → p-a5867a4c.entry.js} +1 -1
  25. package/dist/bn-template-engine/{p-f12fb09b.entry.js → p-b27009eb.entry.js} +1 -1
  26. package/dist/bn-template-engine/p-e30c7251.entry.js +1 -0
  27. package/dist/bn-template-engine/{p-0a49cf00.entry.js → p-f06c3703.entry.js} +1 -1
  28. package/dist/bn-template-engine/{p-22b8d044.entry.js → p-fcfbb329.entry.js} +1 -1
  29. package/dist/bn-template-engine/{p-Bca5V28_.js → p-qRZrT-U3.js} +1 -1
  30. package/dist/cjs/{AxisConfig-DmP4U3JM.js → AxisConfig-DwiNUyYG.js} +1 -1
  31. package/dist/cjs/{LabelCollisionManager-Cet3WPm0.js → LabelCollisionManager-Bv-xkeXw.js} +7 -4
  32. package/dist/cjs/{Order-DlKLywO_.js → Order-2wRydarc.js} +1 -1
  33. package/dist/cjs/{SVGStyle-D78RaNnj.js → SVGStyle-DoxylrEQ.js} +12 -2
  34. package/dist/cjs/{SVGVariancesStyleGroup-XvNAnYYA.js → SVGVariancesStyleGroup-CiI4GeWe.js} +1 -1
  35. package/dist/cjs/{VarianceMeasure-BfZLlICl.js → VarianceMeasure-CQlSRzlp.js} +1 -1
  36. package/dist/cjs/{XYChartDataRow-B0NNOqxB.js → XYChartDataRow-C2FdL58s.js} +4 -4
  37. package/dist/cjs/bn-asset_21.cjs.entry.js +682 -56
  38. package/dist/cjs/bn-chart-bubble.cjs.entry.js +31 -11
  39. package/dist/cjs/bn-chart-bullet.cjs.entry.js +30 -10
  40. package/dist/cjs/bn-chart-scatter.cjs.entry.js +30 -10
  41. package/dist/cjs/bn-grid.cjs.entry.js +82 -5
  42. package/dist/cjs/bn-image.cjs.entry.js +4 -4
  43. package/dist/cjs/bn-internationalization.cjs.entry.js +1 -1
  44. package/dist/cjs/bn-ruleset.cjs.entry.js +1 -1
  45. package/dist/cjs/bn-template-engine.cjs.js +1 -1
  46. package/dist/cjs/bn-text.cjs.entry.js +5 -5
  47. package/dist/cjs/bn-tree.cjs.entry.js +78 -4
  48. package/dist/cjs/{context-protocol-DeLmu5s2.js → context-protocol-DcTEh1rq.js} +2 -0
  49. package/dist/cjs/diagnostics-CTgbq_Gc.js +107 -0
  50. package/dist/cjs/editor-companion.cjs.entry.js +1 -1
  51. package/dist/cjs/ibcs-chart-bubble.cjs.entry.js +5 -5
  52. package/dist/cjs/ibcs-chart-bullet.cjs.entry.js +5 -5
  53. package/dist/cjs/ibcs-chart-scatter.cjs.entry.js +5 -5
  54. package/dist/cjs/index.cjs.js +15 -0
  55. package/dist/cjs/loader.cjs.js +1 -1
  56. package/dist/cjs/{scaling-JAU6IJnR.js → scaling-Dsb5_NXy.js} +1 -1
  57. package/dist/cjs/svgChartElements-tDA43aYj.js +400 -0
  58. package/dist/cjs/{withScalingGroup-Bu5gatHT.js → withScalingGroup-CFIc5-6s.js} +1 -1
  59. package/dist/cjs/{withStyled-50UepUwV.js → withStyled-D0jLwCib.js} +3 -3
  60. package/dist/collection/collection-manifest.json +1 -1
  61. package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.js +60 -1
  62. package/dist/collection/components/bn-chart-bullet/bn-chart-bullet.js +60 -1
  63. package/dist/collection/components/bn-chart-scatter/bn-chart-scatter.js +60 -1
  64. package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +132 -4
  65. package/dist/collection/components/bn-chart-structure/ibcs-chart-structure.js +2 -2
  66. package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +35 -0
  67. package/dist/collection/components/bn-chart-structure/utils/elements/Label.js +5 -2
  68. package/dist/collection/components/bn-chart-time/bn-chart-time.js +133 -4
  69. package/dist/collection/components/bn-chart-time/ibcs-chart-time.css +0 -4
  70. package/dist/collection/components/bn-chart-time/ibcs-chart-time.js +2 -2
  71. package/dist/collection/components/bn-chart-time/utils/TimeChart.js +62 -15
  72. package/dist/collection/components/bn-chart-time/utils/elements/Label.js +5 -2
  73. package/dist/collection/components/bn-context/bn-context.js +133 -1
  74. package/dist/collection/components/bn-grid/bn-grid.js +129 -1
  75. package/dist/collection/components/bn-table/bn-table.js +139 -1
  76. package/dist/collection/components/bn-table/ibcs-table.js +164 -0
  77. package/dist/collection/components/bn-table/utils/Table.js +21 -7
  78. package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +4 -0
  79. package/dist/collection/components/bn-tree/bn-tree.js +137 -0
  80. package/dist/collection/context/context-protocol.js +1 -1
  81. package/dist/collection/index.js +1 -0
  82. package/dist/collection/utils/layoutState/diagnostics.js +17 -0
  83. package/dist/collection/utils/layoutState/generic.js +37 -0
  84. package/dist/collection/utils/layoutState/geometry.js +44 -0
  85. package/dist/collection/utils/layoutState/identity.js +33 -0
  86. package/dist/collection/utils/layoutState/index.js +6 -0
  87. package/dist/collection/utils/layoutState/svgChartElements.js +200 -0
  88. package/dist/collection/utils/layoutState/types.js +13 -0
  89. package/dist/collection/utils/measurementHost.js +58 -0
  90. package/dist/collection/utils/model/styles/FontStyle.js +10 -0
  91. package/dist/components/LabelCollisionManager.js +1 -1
  92. package/dist/components/bn-chart-bubble.js +1 -1
  93. package/dist/components/bn-chart-bullet.js +1 -1
  94. package/dist/components/bn-chart-scatter.js +1 -1
  95. package/dist/components/bn-chart-structure.js +1 -1
  96. package/dist/components/bn-chart-time.js +1 -1
  97. package/dist/components/bn-context.js +1 -1
  98. package/dist/components/bn-grid.js +1 -1
  99. package/dist/components/bn-internationalization.js +1 -1
  100. package/dist/components/bn-table.js +1 -1
  101. package/dist/components/bn-tree.js +1 -1
  102. package/dist/components/context-protocol.js +1 -1
  103. package/dist/components/diagnostics.js +1 -0
  104. package/dist/components/geometry.js +1 -0
  105. package/dist/components/ibcs-chart-bubble2.js +1 -1
  106. package/dist/components/ibcs-chart-bullet2.js +1 -1
  107. package/dist/components/ibcs-chart-scatter2.js +1 -1
  108. package/dist/components/ibcs-chart-structure2.js +1 -1
  109. package/dist/components/ibcs-chart-time2.js +1 -1
  110. package/dist/components/ibcs-table2.js +1 -1
  111. package/dist/components/index.js +1 -1
  112. package/dist/components/main.js +1 -1
  113. package/dist/components/svgChartElements.js +1 -0
  114. package/dist/components/types.js +1 -0
  115. package/dist/esm/{AxisConfig-Cjy_RANi.js → AxisConfig-KqzWQbML.js} +1 -1
  116. package/dist/esm/{LabelCollisionManager-B_NUM9yq.js → LabelCollisionManager-585bQMtP.js} +7 -4
  117. package/dist/esm/{Order-B-aF6Rwn.js → Order-DZVWjEL_.js} +1 -1
  118. package/dist/esm/{SVGStyle-8FfAtUF-.js → SVGStyle-OrPkzjcb.js} +12 -2
  119. package/dist/esm/{SVGVariancesStyleGroup-DD4mIOjT.js → SVGVariancesStyleGroup-DO5QJfRQ.js} +1 -1
  120. package/dist/esm/{VarianceMeasure-DLOuIIJ7.js → VarianceMeasure-DDjChp8C.js} +1 -1
  121. package/dist/esm/{XYChartDataRow-CKfILBFG.js → XYChartDataRow-Dn83Tqh9.js} +4 -4
  122. package/dist/esm/bn-asset_21.entry.js +675 -49
  123. package/dist/esm/bn-chart-bubble.entry.js +29 -9
  124. package/dist/esm/bn-chart-bullet.entry.js +28 -8
  125. package/dist/esm/bn-chart-scatter.entry.js +28 -8
  126. package/dist/esm/bn-grid.entry.js +82 -5
  127. package/dist/esm/bn-image.entry.js +4 -4
  128. package/dist/esm/bn-internationalization.entry.js +1 -1
  129. package/dist/esm/bn-ruleset.entry.js +1 -1
  130. package/dist/esm/bn-template-engine.js +1 -1
  131. package/dist/esm/bn-text.entry.js +5 -5
  132. package/dist/esm/bn-tree.entry.js +78 -4
  133. package/dist/esm/{context-protocol-BoEL0caI.js → context-protocol-B-vdGKeG.js} +1 -1
  134. package/dist/esm/diagnostics-CiquIw8B.js +99 -0
  135. package/dist/esm/editor-companion.entry.js +1 -1
  136. package/dist/esm/ibcs-chart-bubble.entry.js +5 -5
  137. package/dist/esm/ibcs-chart-bullet.entry.js +5 -5
  138. package/dist/esm/ibcs-chart-scatter.entry.js +5 -5
  139. package/dist/esm/index.js +14 -0
  140. package/dist/esm/loader.js +1 -1
  141. package/dist/esm/{scaling-CxyNpMQM.js → scaling-Dggyeqts.js} +1 -1
  142. package/dist/esm/svgChartElements-B3YClivG.js +395 -0
  143. package/dist/esm/{withScalingGroup-Yv9nGGe1.js → withScalingGroup-DNBSqRC0.js} +1 -1
  144. package/dist/esm/{withStyled-By9Jd-Oy.js → withStyled-DoNsbwS3.js} +3 -3
  145. package/dist/types/components/bn-chart-bubble/bn-chart-bubble.d.ts +10 -0
  146. package/dist/types/components/bn-chart-bullet/bn-chart-bullet.d.ts +10 -0
  147. package/dist/types/components/bn-chart-scatter/bn-chart-scatter.d.ts +10 -0
  148. package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +19 -0
  149. package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +27 -0
  150. package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +19 -0
  151. package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +26 -0
  152. package/dist/types/components/bn-context/bn-context.d.ts +14 -0
  153. package/dist/types/components/bn-grid/bn-grid.d.ts +10 -0
  154. package/dist/types/components/bn-table/bn-table.d.ts +18 -0
  155. package/dist/types/components/bn-table/ibcs-table.d.ts +16 -0
  156. package/dist/types/components/bn-table/utils/Table.d.ts +16 -1
  157. package/dist/types/components/bn-table/utils/factories/tableDataSetFactory.d.ts +2 -0
  158. package/dist/types/components/bn-tree/bn-tree.d.ts +10 -0
  159. package/dist/types/components.d.ts +59 -0
  160. package/dist/types/context/context-protocol.d.ts +5 -0
  161. package/dist/types/index.d.ts +1 -0
  162. package/dist/types/utils/layoutState/diagnostics.d.ts +7 -0
  163. package/dist/types/utils/layoutState/generic.d.ts +14 -0
  164. package/dist/types/utils/layoutState/geometry.d.ts +35 -0
  165. package/dist/types/utils/layoutState/identity.d.ts +22 -0
  166. package/dist/types/utils/layoutState/index.d.ts +6 -0
  167. package/dist/types/utils/layoutState/svgChartElements.d.ts +37 -0
  168. package/dist/types/utils/layoutState/types.d.ts +219 -0
  169. package/dist/types/utils/measurementHost.d.ts +9 -0
  170. package/dist/types/utils/model/styles/FontStyle.d.ts +7 -0
  171. package/package.json +1 -1
  172. package/readme.md +1 -0
  173. package/dist/bn-template-engine/p-251bb53d.entry.js +0 -1
  174. package/dist/bn-template-engine/p-2aed639e.entry.js +0 -1
  175. package/dist/bn-template-engine/p-4616b879.entry.js +0 -1
  176. package/dist/bn-template-engine/p-629edcca.entry.js +0 -1
  177. package/dist/bn-template-engine/p-BcZ5GQZ8.js +0 -1
  178. package/dist/bn-template-engine/p-DWtTjg0f.js +0 -1
  179. package/dist/bn-template-engine/p-aecb5de3.entry.js +0 -1
  180. package/dist/bn-template-engine/p-ba43d46e.entry.js +0 -1
  181. package/dist/bn-template-engine/p-c476e7bb.entry.js +0 -1
  182. package/dist/bn-template-engine/p-f9a721bb.entry.js +0 -1
  183. package/dist/cjs/layoutObserver-CrzQQGpv.js +0 -199
  184. package/dist/esm/layoutObserver-cgIXg2sg.js +0 -196
@@ -2,18 +2,20 @@
2
2
 
3
3
  var index = require('./index-C1Z9vO7z.js');
4
4
  var withHasError = require('./withHasError-BdDmiOXM.js');
5
- var contextProtocol = require('./context-protocol-DeLmu5s2.js');
5
+ var contextProtocol = require('./context-protocol-DcTEh1rq.js');
6
6
  var withBodyObserver = require('./withBodyObserver-DJO98AJ-.js');
7
- var withStyled = require('./withStyled-50UepUwV.js');
8
- var scaling = require('./scaling-JAU6IJnR.js');
9
- var withScalingGroup = require('./withScalingGroup-Bu5gatHT.js');
10
- var layoutObserver = require('./layoutObserver-CrzQQGpv.js');
11
- var VarianceMeasure = require('./VarianceMeasure-BfZLlICl.js');
12
- var Order = require('./Order-DlKLywO_.js');
13
- var SVGStyle = require('./SVGStyle-D78RaNnj.js');
7
+ var withStyled = require('./withStyled-D0jLwCib.js');
8
+ var scaling = require('./scaling-Dsb5_NXy.js');
9
+ var withScalingGroup = require('./withScalingGroup-CFIc5-6s.js');
10
+ var svgChartElements = require('./svgChartElements-tDA43aYj.js');
11
+ var VarianceMeasure = require('./VarianceMeasure-CQlSRzlp.js');
12
+ var Order = require('./Order-2wRydarc.js');
13
+ var index$1 = require('./index.cjs.js');
14
+ var diagnostics = require('./diagnostics-CTgbq_Gc.js');
15
+ var SVGStyle = require('./SVGStyle-DoxylrEQ.js');
14
16
  var sanitizeHtml = require('./sanitizeHtml-LuZr1IMd.js');
15
- var LabelCollisionManager = require('./LabelCollisionManager-Cet3WPm0.js');
16
- var SVGVariancesStyleGroup = require('./SVGVariancesStyleGroup-XvNAnYYA.js');
17
+ var LabelCollisionManager = require('./LabelCollisionManager-Bv-xkeXw.js');
18
+ var SVGVariancesStyleGroup = require('./SVGVariancesStyleGroup-CiI4GeWe.js');
17
19
 
18
20
  const bnAssetCss = () => `:host{display:none}`;
19
21
 
@@ -101,6 +103,39 @@ const Card = class {
101
103
  };
102
104
  Card.style = bnCardCss();
103
105
 
106
+ /**
107
+ * Effective font size of an element in px, resolved from computed style
108
+ * (which reflects `--bn-font-size` scaling). Falls back to the system
109
+ * default where computed style is unavailable (spec tests).
110
+ */
111
+ function readFontSizePx(el) {
112
+ if (typeof getComputedStyle === "function") {
113
+ const parsed = parseFloat(getComputedStyle(el).fontSize);
114
+ if (Number.isFinite(parsed) && parsed > 0)
115
+ return parsed;
116
+ }
117
+ return contextProtocol.SYSTEM_STYLE_DEFAULTS.global.fontSizePx;
118
+ }
119
+ /**
120
+ * Layout state for a visual component without its own `getLayoutState()`:
121
+ * host box, identity, em context and diagnostics — no regions or elements.
122
+ * The caller (`bn-context`) overwrites `id` with its document-order identity.
123
+ */
124
+ function buildGenericState(el, origins) {
125
+ var _a;
126
+ return {
127
+ version: index$1.LAYOUT_STATE_VERSION,
128
+ tag: el.localName,
129
+ id: diagnostics.resolveStandaloneId(el),
130
+ slot: (_a = el.getAttribute("slot")) !== null && _a !== void 0 ? _a : undefined,
131
+ rect: diagnostics.measure(el, origins),
132
+ em: { fontSizePx: readFontSizePx(el), appliedScaleFactor: 1 },
133
+ regions: [],
134
+ metadata: {},
135
+ diagnostics: diagnostics.readDiagnostics(el),
136
+ };
137
+ }
138
+
104
139
  const bnChartStructureCss$1 = () => `:host{display:inline-block;position:relative;overflow:hidden}.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}.warning{font-size:0.8em;font-style:italic}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}`;
105
140
 
106
141
  const Chart$1 = class Chart {
@@ -412,7 +447,12 @@ const Chart$1 = class Chart {
412
447
  * them into a bn-scaling-group.
413
448
  */
414
449
  this.handleAutoScalingReport = (report) => {
415
- var _a, _b;
450
+ var _a, _b, _c, _d, _e, _f;
451
+ // A report only carries the auto-resolved quantities — keep the other one.
452
+ this.lastAutoScalingReport = {
453
+ unit: (_a = report.unit) !== null && _a !== void 0 ? _a : (_b = this.lastAutoScalingReport) === null || _b === void 0 ? void 0 : _b.unit,
454
+ percentage: (_c = report.percentage) !== null && _c !== void 0 ? _c : (_d = this.lastAutoScalingReport) === null || _d === void 0 ? void 0 : _d.percentage,
455
+ };
416
456
  const changed = (next, last) => last === undefined || Math.abs(next - last) > Math.abs(next) * 1e-3;
417
457
  const effFontPx = this.getEffectiveFontPx();
418
458
  if (report.unit !== undefined && report.unit > 0 && this.autoUnitWarningActive) {
@@ -422,7 +462,7 @@ const Chart$1 = class Chart {
422
462
  this.errors.addOrReplace({
423
463
  id: "AUTO_unitScaling",
424
464
  type: "warning",
425
- message: `unit-scaling: ${Chart$1.describeScalingInput(String((_a = this.unitScaling) !== null && _a !== void 0 ? _a : "").trim())}, auto-fitted to 1 em ≈ ${scaling.formatScalingValue(unitsPerEm)} units.`,
465
+ message: `unit-scaling: ${Chart$1.describeScalingInput(String((_e = this.unitScaling) !== null && _e !== void 0 ? _e : "").trim())}, auto-fitted to 1 em ≈ ${scaling.formatScalingValue(unitsPerEm)} units.`,
426
466
  });
427
467
  }
428
468
  }
@@ -433,7 +473,7 @@ const Chart$1 = class Chart {
433
473
  this.errors.addOrReplace({
434
474
  id: "AUTO_percentageScaling",
435
475
  type: "warning",
436
- message: `percentage-scaling: ${Chart$1.describeScalingInput(String((_b = this.percentageScaling) !== null && _b !== void 0 ? _b : "").trim())}, auto-fitted to 1 em ≈ ${scaling.formatScalingValue(ppPerEm)} percentage points.`,
476
+ message: `percentage-scaling: ${Chart$1.describeScalingInput(String((_f = this.percentageScaling) !== null && _f !== void 0 ? _f : "").trim())}, auto-fitted to 1 em ≈ ${scaling.formatScalingValue(ppPerEm)} percentage points.`,
437
477
  });
438
478
  }
439
479
  }
@@ -450,7 +490,7 @@ const Chart$1 = class Chart {
450
490
  this.errors = withHasError.withHasError(this);
451
491
  withScalingGroup.withScalingGroup(this);
452
492
  this.componentStyle = withStyled.withComponentStyle(this);
453
- this.ruleSetConfig = layoutObserver.withRuleSet(this);
493
+ this.ruleSetConfig = svgChartElements.withRuleSet(this);
454
494
  this.t = scaling.withTranslation(this).t;
455
495
  this.resolveInherited = scaling.withInheritedProps(this, [
456
496
  { propName: "scenarios", ancestorAttr: "title-scenarios" },
@@ -546,7 +586,7 @@ const Chart$1 = class Chart {
546
586
  // compared to what auto-scaling last measured — this prevents the
547
587
  // ResizeObserver's initial fire (and content-reflow noise) from
548
588
  // creating an infinite auto-scale loop.
549
- this.layoutObserver = layoutObserver.observeParentResize(this.element, () => {
589
+ this.layoutObserver = svgChartElements.observeParentResize(this.element, () => {
550
590
  if (this._autoScaleGuard)
551
591
  return;
552
592
  const { height } = scaling.getParentDimensions(this.element);
@@ -836,6 +876,7 @@ const Chart$1 = class Chart {
836
876
  },
837
877
  fontStyles: {
838
878
  font: `${scaledFontSize}px ${$["global"]["fontFamily"]}`,
879
+ family: $["global"]["fontFamily"],
839
880
  size: scaledFontSize,
840
881
  color: $["global"]["fontColor"],
841
882
  background: $["global"]["fontBackgroundColor"],
@@ -965,6 +1006,87 @@ const Chart$1 = class Chart {
965
1006
  const effectiveScenarios = (stackConfig === null || stackConfig === void 0 ? void 0 : stackConfig.by) === VarianceMeasure.StackBy.DIMENSIONS ? scenarios.slice(0, 1) : scenarios;
966
1007
  return (index.h("ibcs-chart-structure", { tableName: this.datasetName, dataVersion: this.dataVersion, chartTitle: this.prepareChartTitle(idx), scenarios: effectiveScenarios, variances: [localScenarioString], hideCategories: this.prepareHideCategories(idx), pixelPerUnit: ppu, pixelPerPercentage: ppp, reportAutoScaling: this.handleAutoScalingReport, 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(idx), stackConfig: stackConfig, parentDimensions: this.prepareDimension(), ruleSetConfig: this.ruleSetConfig() }));
967
1008
  }
1009
+ /**
1010
+ * Lazily generates this chart's layout state: host box (context- and
1011
+ * component-relative, CSS px), one `canvas:<segment>` region per rendered
1012
+ * segment (base + variances), metadata (scenarios, bar count), diagnostics
1013
+ * and resolved scaling. With `detail: "full"` every bar, label and axis of
1014
+ * every segment is listed with its geometry.
1015
+ *
1016
+ * @param options - `{ detail: "summary" | "full" }`, default `"summary"`
1017
+ */
1018
+ async getLayoutState(options) {
1019
+ var _a, _b, _c, _d;
1020
+ const detail = (_a = options === null || options === void 0 ? void 0 : options.detail) !== null && _a !== void 0 ? _a : "summary";
1021
+ const origins = diagnostics.originsFor(this.element);
1022
+ const rawFactor = this.getEffectiveScaleFactor();
1023
+ // Auto-scale can be mid-measurement (or unmeasurable in tests) — report a sane factor.
1024
+ const factor = Number.isFinite(rawFactor) && rawFactor > 0 ? rawFactor : 1;
1025
+ const fontSizePx = this.componentStyle(($) => { var _a; return ((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333; }) * factor;
1026
+ const variances = this.prepareVariances();
1027
+ const layout = svgChartElements.collectChartFacadeLayout(this.element, "ibcs-chart-structure", ["base", ...variances], origins, detail);
1028
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1029
+ const firstInner = (_b = this.element.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector("ibcs-chart-structure");
1030
+ const state = {
1031
+ version: index$1.LAYOUT_STATE_VERSION,
1032
+ tag: this.element.localName,
1033
+ id: diagnostics.resolveStandaloneId(this.element),
1034
+ slot: (_c = this.element.getAttribute("slot")) !== null && _c !== void 0 ? _c : undefined,
1035
+ rect: diagnostics.measure(this.element, origins),
1036
+ em: { fontSizePx, appliedScaleFactor: factor },
1037
+ regions: layout.regions,
1038
+ metadata: {
1039
+ title: this.chartTitle || undefined,
1040
+ scenarios: (_d = firstInner === null || firstInner === void 0 ? void 0 : firstInner.scenarios) !== null && _d !== void 0 ? _d : [],
1041
+ variances,
1042
+ barCount: layout.barCount,
1043
+ hasNoData: layout.barCount === 0,
1044
+ },
1045
+ diagnostics: diagnostics.readDiagnostics(this.element),
1046
+ scaling: this.resolveScalingInfo(fontSizePx),
1047
+ };
1048
+ if (layout.elements)
1049
+ state.elements = layout.elements;
1050
+ return state;
1051
+ }
1052
+ /**
1053
+ * Resolved value scaling without re-triggering validation side effects.
1054
+ * The inner chart's scale unit is px per unit / px per 1.0 fraction;
1055
+ * auto-fitted values come from the last inner report.
1056
+ */
1057
+ resolveScalingInfo(effFontPx) {
1058
+ var _a, _b;
1059
+ const info = {};
1060
+ const unit = scaling.resolveScalingValue(this.unitScaling, this.pixelPerUnitGroupMap);
1061
+ if (unit.kind === "value") {
1062
+ info.unitMode = "fixed";
1063
+ info.unitsPerEm = unit.value;
1064
+ info.unitPxPerUnit = effFontPx / unit.value;
1065
+ }
1066
+ else {
1067
+ info.unitMode = "auto";
1068
+ const pxPerUnit = (_a = this.lastAutoScalingReport) === null || _a === void 0 ? void 0 : _a.unit;
1069
+ if (pxPerUnit !== undefined && pxPerUnit > 0) {
1070
+ info.unitPxPerUnit = pxPerUnit;
1071
+ info.unitsPerEm = effFontPx / pxPerUnit;
1072
+ }
1073
+ }
1074
+ const pct = scaling.resolveScalingValue(this.percentageScaling, this.pixelPerUnitGroupMap);
1075
+ if (pct.kind === "value") {
1076
+ info.percentageMode = "fixed";
1077
+ info.percentagePointsPerEm = pct.value;
1078
+ info.percentagePxPerPoint = effFontPx / pct.value;
1079
+ }
1080
+ else {
1081
+ info.percentageMode = "auto";
1082
+ const pxPerFraction = (_b = this.lastAutoScalingReport) === null || _b === void 0 ? void 0 : _b.percentage;
1083
+ if (pxPerFraction !== undefined && pxPerFraction > 0) {
1084
+ info.percentagePxPerPoint = pxPerFraction / 100;
1085
+ info.percentagePointsPerEm = (100 * effFontPx) / pxPerFraction;
1086
+ }
1087
+ }
1088
+ return info;
1089
+ }
968
1090
  getEffectiveScaleFactor() {
969
1091
  const { mode, factor } = scaling.parseScaling(this.scale);
970
1092
  if (mode === "factor")
@@ -998,7 +1120,7 @@ const Chart$1 = class Chart {
998
1120
  scenariosArray = [...scenariosArray, ...variancesArray];
999
1121
  }
1000
1122
  const fontStyles = this.getFontStyles();
1001
- return (index.h(index.Host, { key: '68eb9fbcc6fb712dd06729f13a33c61c2c5c90e6', style: fontStyles }, index.h("div", { key: '9d7c49c1d5e2940dd1a4381a90e08912fef77f33', class: "container" }, scenariosArray.map(this.chartTemplate))));
1123
+ return (index.h(index.Host, { key: '4039c2676dbb48bc14e30092d5f5e7a8c080bd2a', style: fontStyles }, index.h("div", { key: 'c57dbcf301b86f4b22da3142c242008f8f049268', class: "container" }, scenariosArray.map(this.chartTemplate))));
1002
1124
  }
1003
1125
  get element() { return index.getElement(this); }
1004
1126
  static get watchers() { return {
@@ -1516,7 +1638,12 @@ const Chart = class {
1516
1638
  * them into a bn-scaling-group.
1517
1639
  */
1518
1640
  this.handleAutoScalingReport = (report) => {
1519
- var _a, _b;
1641
+ var _a, _b, _c, _d, _e, _f;
1642
+ // A report only carries the auto-resolved quantities — keep the other one.
1643
+ this.lastAutoScalingReport = {
1644
+ unit: (_a = report.unit) !== null && _a !== void 0 ? _a : (_b = this.lastAutoScalingReport) === null || _b === void 0 ? void 0 : _b.unit,
1645
+ percentage: (_c = report.percentage) !== null && _c !== void 0 ? _c : (_d = this.lastAutoScalingReport) === null || _d === void 0 ? void 0 : _d.percentage,
1646
+ };
1520
1647
  const changed = (next, last) => last === undefined || Math.abs(next - last) > Math.abs(next) * 1e-3;
1521
1648
  const effFontPx = this.getEffectiveFontPx();
1522
1649
  if (report.unit !== undefined && report.unit > 0 && this.autoUnitWarningActive) {
@@ -1526,7 +1653,7 @@ const Chart = class {
1526
1653
  this.errors.addOrReplace({
1527
1654
  id: "AUTO_unitScaling",
1528
1655
  type: "warning",
1529
- message: `unit-scaling: ${Chart.describeScalingInput(String((_a = this.unitScaling) !== null && _a !== void 0 ? _a : "").trim())}, auto-fitted to 1 em ≈ ${scaling.formatScalingValue(unitsPerEm)} units.`,
1656
+ message: `unit-scaling: ${Chart.describeScalingInput(String((_e = this.unitScaling) !== null && _e !== void 0 ? _e : "").trim())}, auto-fitted to 1 em ≈ ${scaling.formatScalingValue(unitsPerEm)} units.`,
1530
1657
  });
1531
1658
  }
1532
1659
  }
@@ -1537,7 +1664,7 @@ const Chart = class {
1537
1664
  this.errors.addOrReplace({
1538
1665
  id: "AUTO_percentageScaling",
1539
1666
  type: "warning",
1540
- message: `percentage-scaling: ${Chart.describeScalingInput(String((_b = this.percentageScaling) !== null && _b !== void 0 ? _b : "").trim())}, auto-fitted to 1 em ≈ ${scaling.formatScalingValue(ppPerEm)} percentage points.`,
1667
+ message: `percentage-scaling: ${Chart.describeScalingInput(String((_f = this.percentageScaling) !== null && _f !== void 0 ? _f : "").trim())}, auto-fitted to 1 em ≈ ${scaling.formatScalingValue(ppPerEm)} percentage points.`,
1541
1668
  });
1542
1669
  }
1543
1670
  }
@@ -1554,7 +1681,7 @@ const Chart = class {
1554
1681
  this.errors = withHasError.withHasError(this);
1555
1682
  withScalingGroup.withScalingGroup(this);
1556
1683
  this.componentStyle = withStyled.withComponentStyle(this);
1557
- this.ruleSetConfig = layoutObserver.withRuleSet(this);
1684
+ this.ruleSetConfig = svgChartElements.withRuleSet(this);
1558
1685
  this.t = scaling.withTranslation(this).t;
1559
1686
  this.resolveInherited = scaling.withInheritedProps(this, [
1560
1687
  { propName: "scenarios", ancestorAttr: "title-scenarios" },
@@ -1735,7 +1862,7 @@ const Chart = class {
1735
1862
  }
1736
1863
  componentDidLoad() {
1737
1864
  // Watch for size changes (window resize, card relayout).
1738
- this.layoutObserver = layoutObserver.observeParentResize(this.element, () => {
1865
+ this.layoutObserver = svgChartElements.observeParentResize(this.element, () => {
1739
1866
  if (this._autoScaleGuard)
1740
1867
  return;
1741
1868
  const { width } = scaling.getParentDimensions(this.element);
@@ -2003,6 +2130,7 @@ const Chart = class {
2003
2130
  },
2004
2131
  fontStyles: {
2005
2132
  font: `${scaledFontSize}px ${$["global"]["fontFamily"]}`,
2133
+ family: $["global"]["fontFamily"],
2006
2134
  size: scaledFontSize,
2007
2135
  color: $["global"]["fontColor"],
2008
2136
  background: $["global"]["fontBackgroundColor"],
@@ -2193,6 +2321,88 @@ const Chart = class {
2193
2321
  const effectiveScenarios = (stackConfig === null || stackConfig === void 0 ? void 0 : stackConfig.by) === VarianceMeasure.StackBy.DIMENSIONS ? scenarios.slice(0, 1) : scenarios;
2194
2322
  return (index.h("ibcs-chart-time", { tableName: this.datasetName, dataVersion: this.dataVersion, chartTitle: this.prepareChartTitle(idx), scenarios: effectiveScenarios, variances: [localScenarioString], hideAxisLabels: this.prepareHideAxisLabels(idx), pixelPerUnit: ppu, pixelPerPercentage: ppp, reportAutoScaling: this.handleAutoScalingReport, limit: this.prepareLimit(), leftSideOffsetForHorizontalSync: this.prepareLeftSideOffset(preparedI18n, preparedStyle), styles: preparedStyle, i18n: preparedI18n, order: this.prepareOrder(), level: this.prepareLevel(), dateInterval: this.prepareDateInterval(), intervalSpanLimit: this.prepareIntervalSpanLimit(), axisLabelsMode: this.prepareAxisLabelsMode(), filter: this.prepareFilter(), "measure-scale": this.prepareMeasureScale(), "measure-unit": this.prepareMeasureUnit(), showOverlayAvg: this.prepareAvg(), showOverlayMedian: this.prepareMedian(), showMeasureScale: this.prepareShowMeasureScale(idx), chartMode: this.prepareChartMode(), maxBars: this.prepareMaxBars(), stackConfig: stackConfig, lineFullWidth: this.prepareLineFullWidth(), containerWidth: fullParentWidth, parentDimensions: this.prepareDimension(), ruleSetConfig: this.ruleSetConfig() }));
2195
2323
  }
2324
+ /**
2325
+ * Lazily generates this chart's layout state: host box (context- and
2326
+ * component-relative, CSS px), one `canvas:<segment>` region per rendered
2327
+ * segment (base + variances), metadata (scenarios, bar count), diagnostics
2328
+ * and resolved scaling. With `detail: "full"` every bar, label and axis of
2329
+ * every segment is listed with its geometry.
2330
+ *
2331
+ * @param options - `{ detail: "summary" | "full" }`, default `"summary"`
2332
+ */
2333
+ async getLayoutState(options) {
2334
+ var _a, _b, _c, _d;
2335
+ const detail = (_a = options === null || options === void 0 ? void 0 : options.detail) !== null && _a !== void 0 ? _a : "summary";
2336
+ const origins = diagnostics.originsFor(this.element);
2337
+ const rawFactor = this.getEffectiveScaleFactor();
2338
+ // Auto-scale can be mid-measurement (or unmeasurable in tests) — report a sane factor.
2339
+ const factor = Number.isFinite(rawFactor) && rawFactor > 0 ? rawFactor : 1;
2340
+ const fontSizePx = this.componentStyle(($) => { var _a; return ((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333; }) * factor;
2341
+ const variances = this.prepareVariances();
2342
+ const layout = svgChartElements.collectChartFacadeLayout(this.element, "ibcs-chart-time", ["base", ...variances], origins, detail);
2343
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2344
+ const firstInner = (_b = this.element.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector("ibcs-chart-time");
2345
+ const state = {
2346
+ version: index$1.LAYOUT_STATE_VERSION,
2347
+ tag: this.element.localName,
2348
+ id: diagnostics.resolveStandaloneId(this.element),
2349
+ slot: (_c = this.element.getAttribute("slot")) !== null && _c !== void 0 ? _c : undefined,
2350
+ rect: diagnostics.measure(this.element, origins),
2351
+ em: { fontSizePx, appliedScaleFactor: factor },
2352
+ regions: layout.regions,
2353
+ metadata: {
2354
+ title: this.chartTitle || undefined,
2355
+ scenarios: (_d = firstInner === null || firstInner === void 0 ? void 0 : firstInner.scenarios) !== null && _d !== void 0 ? _d : [],
2356
+ variances,
2357
+ barCount: layout.barCount,
2358
+ chartMode: this.chartMode || undefined,
2359
+ hasNoData: layout.barCount === 0,
2360
+ },
2361
+ diagnostics: diagnostics.readDiagnostics(this.element),
2362
+ scaling: this.resolveScalingInfo(fontSizePx),
2363
+ };
2364
+ if (layout.elements)
2365
+ state.elements = layout.elements;
2366
+ return state;
2367
+ }
2368
+ /**
2369
+ * Resolved value scaling without re-triggering validation side effects.
2370
+ * The inner chart's scale unit is px per unit / px per 1.0 fraction;
2371
+ * auto-fitted values come from the last inner report.
2372
+ */
2373
+ resolveScalingInfo(effFontPx) {
2374
+ var _a, _b;
2375
+ const info = {};
2376
+ const unit = scaling.resolveScalingValue(this.unitScaling, this.pixelPerUnitGroupMap);
2377
+ if (unit.kind === "value") {
2378
+ info.unitMode = "fixed";
2379
+ info.unitsPerEm = unit.value;
2380
+ info.unitPxPerUnit = effFontPx / unit.value;
2381
+ }
2382
+ else {
2383
+ info.unitMode = "auto";
2384
+ const pxPerUnit = (_a = this.lastAutoScalingReport) === null || _a === void 0 ? void 0 : _a.unit;
2385
+ if (pxPerUnit !== undefined && pxPerUnit > 0) {
2386
+ info.unitPxPerUnit = pxPerUnit;
2387
+ info.unitsPerEm = effFontPx / pxPerUnit;
2388
+ }
2389
+ }
2390
+ const pct = scaling.resolveScalingValue(this.percentageScaling, this.pixelPerUnitGroupMap);
2391
+ if (pct.kind === "value") {
2392
+ info.percentageMode = "fixed";
2393
+ info.percentagePointsPerEm = pct.value;
2394
+ info.percentagePxPerPoint = effFontPx / pct.value;
2395
+ }
2396
+ else {
2397
+ info.percentageMode = "auto";
2398
+ const pxPerFraction = (_b = this.lastAutoScalingReport) === null || _b === void 0 ? void 0 : _b.percentage;
2399
+ if (pxPerFraction !== undefined && pxPerFraction > 0) {
2400
+ info.percentagePxPerPoint = pxPerFraction / 100;
2401
+ info.percentagePointsPerEm = (100 * effFontPx) / pxPerFraction;
2402
+ }
2403
+ }
2404
+ return info;
2405
+ }
2196
2406
  getEffectiveScaleFactor() {
2197
2407
  const { mode, factor } = scaling.parseScaling(this.scale);
2198
2408
  if (mode === "factor")
@@ -2226,7 +2436,7 @@ const Chart = class {
2226
2436
  scenariosArray = [...scenariosArray, ...variancesArray];
2227
2437
  }
2228
2438
  const fontStyles = this.getFontStyles();
2229
- return (index.h(index.Host, { key: 'aff5ffed56838af70ca1525204497a708194012e', style: fontStyles }, index.h("div", { key: 'a9e0699c0fdbff19efe787e438ddf2921fac35a4', class: "container" }, scenariosArray.map(this.chartTemplate))));
2439
+ return (index.h(index.Host, { key: '93a5778cad09ee33f54df92f3b3e32d030a734d6', style: fontStyles }, index.h("div", { key: 'b431ad76c90bc3c6e5f6820ba03df574155b0038', class: "container" }, scenariosArray.map(this.chartTemplate))));
2230
2440
  }
2231
2441
  get element() { return index.getElement(this); }
2232
2442
  static get watchers() { return {
@@ -2333,6 +2543,11 @@ ComponentStyle.style = bnComponentStyleCss();
2333
2543
 
2334
2544
  const bnContextCss = () => `:host{display:block}`;
2335
2545
 
2546
+ /** Every visual bn-* component; non-visual producers (bn-dataset, ...) are excluded. */
2547
+ const VISUAL_SELECTOR = "bn-body, bn-card, bn-chart-bubble, bn-chart-bullet, bn-chart-scatter, " +
2548
+ "bn-chart-structure, bn-chart-time, bn-footer, bn-grid, bn-image, " +
2549
+ "bn-layout-card, bn-layout-page, bn-message, bn-page, bn-table, " +
2550
+ "bn-template, bn-text, bn-title, bn-tree";
2336
2551
  const Context = class {
2337
2552
  constructor(hostRef) {
2338
2553
  index.registerInstance(this, hostRef);
@@ -2371,6 +2586,72 @@ const Context = class {
2371
2586
  clearTimeout(this.currentPageUpdate);
2372
2587
  }
2373
2588
  }
2589
+ /**
2590
+ * Lazily generates a JSON-serializable snapshot of the rendered report:
2591
+ * every visual descendant with its position and size (context- and
2592
+ * component-relative, CSS px), render metadata, diagnostics and — with
2593
+ * `detail: "full"` — per-element geometry (bars, labels, axes, cells).
2594
+ *
2595
+ * Nothing is tracked during rendering; each call measures the DOM at that
2596
+ * moment. Call it after the report has settled (e.g. when
2597
+ * `window.componentRegisterIsRenderedResult` is true) for final geometry.
2598
+ *
2599
+ * @param options - `{ detail: "summary" | "full" }`, default `"summary"`
2600
+ */
2601
+ async getLayoutState(options) {
2602
+ var _a, _b;
2603
+ const detail = (_a = options === null || options === void 0 ? void 0 : options.detail) !== null && _a !== void 0 ? _a : "summary";
2604
+ const hosts = Array.from(this.element.querySelectorAll(VISUAL_SELECTOR));
2605
+ await Promise.all(hosts.map((el) => { var _a, _b, _c; return (_c = (_b = (_a = el).componentOnReady) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : Promise.resolve(); }));
2606
+ const contextRect = this.element.getBoundingClientRect();
2607
+ const contextOrigin = { x: contextRect.left, y: contextRect.top };
2608
+ const components = await Promise.all(hosts.map(async (el) => {
2609
+ const hostRect = el.getBoundingClientRect();
2610
+ const origins = { context: contextOrigin, component: { x: hostRect.left, y: hostRect.top } };
2611
+ try {
2612
+ const rich = el;
2613
+ if (typeof rich.getLayoutState === "function") {
2614
+ return await rich.getLayoutState({ detail });
2615
+ }
2616
+ return buildGenericState(el, origins);
2617
+ }
2618
+ catch (e) {
2619
+ let fallback;
2620
+ try {
2621
+ fallback = buildGenericState(el, origins);
2622
+ }
2623
+ catch (_a) {
2624
+ const zero = { x: 0, y: 0, width: 0, height: 0 };
2625
+ fallback = {
2626
+ version: index$1.LAYOUT_STATE_VERSION,
2627
+ tag: el.localName,
2628
+ id: el.localName,
2629
+ rect: { context: Object.assign({}, zero), component: Object.assign({}, zero) },
2630
+ em: { fontSizePx: 0, appliedScaleFactor: 1 },
2631
+ regions: [],
2632
+ metadata: {},
2633
+ diagnostics: [],
2634
+ };
2635
+ }
2636
+ fallback.error = String(e instanceof Error ? e.message : e);
2637
+ return fallback;
2638
+ }
2639
+ }));
2640
+ const ids = diagnostics.assignIds(hosts.map((el) => ({ tag: el.localName, explicitId: diagnostics.resolveOwnIdentity(el) })));
2641
+ components.forEach((state, index) => {
2642
+ state.id = ids[index];
2643
+ });
2644
+ return {
2645
+ version: index$1.LAYOUT_STATE_VERSION,
2646
+ generatedAt: new Date().toISOString(),
2647
+ detail,
2648
+ context: {
2649
+ viewport: diagnostics.toLayoutRect(contextRect),
2650
+ locale: (_b = this.stores) === null || _b === void 0 ? void 0 : _b.context.state.locale,
2651
+ },
2652
+ components,
2653
+ };
2654
+ }
2374
2655
  componentWillLoad() {
2375
2656
  // stencil needs one componenet implementing all lifecycle steps to get mixing working
2376
2657
  }
@@ -2381,7 +2662,7 @@ const Context = class {
2381
2662
  componentWillUpdate() { }
2382
2663
  componentDidUpdate() { }
2383
2664
  render() {
2384
- return (index.h(index.Host, { key: '3c27b95cb769f4871f06453c73faa2a15dd04aa6' }, index.h("slot", { key: '4965ab0122454b1b84d463146e949e432adbd06c' })));
2665
+ return (index.h(index.Host, { key: '005c68f320adbbd5d5269d3fe6f2da6a8096ed98' }, index.h("slot", { key: '7d9fbf3e7a253fe24414cd26274fdffb03b2d5f6' })));
2385
2666
  }
2386
2667
  get element() { return index.getElement(this); }
2387
2668
  static get watchers() { return {
@@ -4779,6 +5060,12 @@ const Table$1 = class Table {
4779
5060
  * can copy them into a bn-scaling-group.
4780
5061
  */
4781
5062
  this.handleAutoScalingReport = (report) => {
5063
+ var _a, _b, _c, _d;
5064
+ // A report only carries the auto-resolved quantities — keep the other one.
5065
+ this.lastAutoScalingReport = {
5066
+ unit: (_a = report.unit) !== null && _a !== void 0 ? _a : (_b = this.lastAutoScalingReport) === null || _b === void 0 ? void 0 : _b.unit,
5067
+ percentage: (_c = report.percentage) !== null && _c !== void 0 ? _c : (_d = this.lastAutoScalingReport) === null || _d === void 0 ? void 0 : _d.percentage,
5068
+ };
4782
5069
  const changed = (next, last) => last === undefined || Math.abs(next - last) > Math.abs(next) * 1e-3;
4783
5070
  if (report.unit !== undefined && report.unit > 0 && this.autoUnitWarningActive) {
4784
5071
  const unitsPerEm = 1 / report.unit;
@@ -4808,7 +5095,7 @@ const Table$1 = class Table {
4808
5095
  this.errors = withHasError.withHasError(this);
4809
5096
  withScalingGroup.withScalingGroup(this);
4810
5097
  this.componentStyle = withStyled.withComponentStyle(this);
4811
- this.ruleSetConfig = layoutObserver.withRuleSet(this);
5098
+ this.ruleSetConfig = svgChartElements.withRuleSet(this);
4812
5099
  scaling.withDataset(this, (name, data) => {
4813
5100
  // Helpers query the shared alasql database directly by name; we just
4814
5101
  // record the active dataset and bump a version counter so Stencil
@@ -5199,7 +5486,7 @@ const Table$1 = class Table {
5199
5486
  componentDidLoad() {
5200
5487
  // Observe the parent container for size changes so auto-scaling
5201
5488
  // reacts to genuine container resizes (window resize, card relayout).
5202
- this.layoutObserver = layoutObserver.observeParentResize(this.element, () => {
5489
+ this.layoutObserver = svgChartElements.observeParentResize(this.element, () => {
5203
5490
  if (this._autoScaleGuard)
5204
5491
  return;
5205
5492
  const { width } = scaling.getParentDimensions(this.element);
@@ -5627,6 +5914,91 @@ const Table$1 = class Table {
5627
5914
  };
5628
5915
  return dataSetStructure;
5629
5916
  }
5917
+ /**
5918
+ * Lazily generates this table's layout state: host box (context- and
5919
+ * component-relative, CSS px), header/body regions, row/column/cell counts,
5920
+ * diagnostics and resolved scaling. With `detail: "full"` every cell is
5921
+ * listed with its geometry, model value, column key and in-cell bar chart.
5922
+ *
5923
+ * @param options - `{ detail: "summary" | "full" }`, default `"summary"`
5924
+ */
5925
+ async getLayoutState(options) {
5926
+ var _a, _b, _c, _d;
5927
+ const detail = (_a = options === null || options === void 0 ? void 0 : options.detail) !== null && _a !== void 0 ? _a : "summary";
5928
+ const origins = diagnostics.originsFor(this.element);
5929
+ const rawFactor = this.getEffectiveScaleFactor();
5930
+ // Auto-scale can be mid-measurement (or unmeasurable in tests) — report a sane factor.
5931
+ const effectiveFactor = Number.isFinite(rawFactor) && rawFactor > 0 ? rawFactor : 1;
5932
+ const fontSizePx = this.componentStyle(($) => { var _a; return ((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333; }) * effectiveFactor;
5933
+ const state = {
5934
+ version: index$1.LAYOUT_STATE_VERSION,
5935
+ tag: this.element.localName,
5936
+ id: diagnostics.resolveStandaloneId(this.element),
5937
+ slot: (_b = this.element.getAttribute("slot")) !== null && _b !== void 0 ? _b : undefined,
5938
+ rect: diagnostics.measure(this.element, origins),
5939
+ em: { fontSizePx, appliedScaleFactor: effectiveFactor },
5940
+ regions: [],
5941
+ metadata: {},
5942
+ diagnostics: diagnostics.readDiagnostics(this.element),
5943
+ scaling: this.resolveScalingInfo(fontSizePx),
5944
+ };
5945
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5946
+ const inner = (_c = this.element.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector("ibcs-table");
5947
+ if (inner) {
5948
+ const scenarios = (_d = inner.scenarios) !== null && _d !== void 0 ? _d : [];
5949
+ state.metadata.scenarios = scenarios.filter((name) => !name.startsWith("d"));
5950
+ state.metadata.variances = scenarios.filter((name) => name.startsWith("d"));
5951
+ if (typeof inner.getLayoutDetail === "function") {
5952
+ const layoutDetail = await inner.getLayoutDetail(origins, detail);
5953
+ state.regions = layoutDetail.regions;
5954
+ state.metadata = Object.assign(Object.assign({}, state.metadata), layoutDetail.metadata);
5955
+ state.diagnostics = [...state.diagnostics, ...layoutDetail.diagnostics];
5956
+ if (layoutDetail.elements)
5957
+ state.elements = layoutDetail.elements;
5958
+ if (layoutDetail.table)
5959
+ state.table = layoutDetail.table;
5960
+ }
5961
+ }
5962
+ return state;
5963
+ }
5964
+ /**
5965
+ * Resolved value scaling without re-triggering validation side effects.
5966
+ * The table's internal scale unit is em per unit / em per percentage point;
5967
+ * auto-fitted values come from the last inner report.
5968
+ */
5969
+ resolveScalingInfo(emPx) {
5970
+ var _a, _b;
5971
+ const info = {};
5972
+ const unit = scaling.resolveScalingValue(this.unitScaling, this.pixelPerUnitGroupMap);
5973
+ if (unit.kind === "value") {
5974
+ info.unitMode = "fixed";
5975
+ info.unitsPerEm = unit.value;
5976
+ info.unitPxPerUnit = emPx / unit.value;
5977
+ }
5978
+ else {
5979
+ info.unitMode = "auto";
5980
+ const emPerUnit = (_a = this.lastAutoScalingReport) === null || _a === void 0 ? void 0 : _a.unit;
5981
+ if (emPerUnit !== undefined && emPerUnit > 0) {
5982
+ info.unitsPerEm = 1 / emPerUnit;
5983
+ info.unitPxPerUnit = emPerUnit * emPx;
5984
+ }
5985
+ }
5986
+ const pct = scaling.resolveScalingValue(this.percentageScaling, this.pixelPerUnitGroupMap);
5987
+ if (pct.kind === "value") {
5988
+ info.percentageMode = "fixed";
5989
+ info.percentagePointsPerEm = pct.value;
5990
+ info.percentagePxPerPoint = emPx / pct.value;
5991
+ }
5992
+ else {
5993
+ info.percentageMode = "auto";
5994
+ const emPerPoint = (_b = this.lastAutoScalingReport) === null || _b === void 0 ? void 0 : _b.percentage;
5995
+ if (emPerPoint !== undefined && emPerPoint > 0) {
5996
+ info.percentagePointsPerEm = 1 / emPerPoint;
5997
+ info.percentagePxPerPoint = emPerPoint * emPx;
5998
+ }
5999
+ }
6000
+ return info;
6001
+ }
5630
6002
  getEffectiveScaleFactor() {
5631
6003
  const { mode, factor } = scaling.parseScaling(this.scale);
5632
6004
  if (mode === "factor")
@@ -5651,7 +6023,7 @@ const Table$1 = class Table {
5651
6023
  render() {
5652
6024
  const fontStyles = this.getFontStyles();
5653
6025
  const effectiveFactor = this.getEffectiveScaleFactor();
5654
- return (index.h(index.Host, { key: '7960f554ac93c0fb6a09cf47f886827fff1aea84', style: fontStyles }, index.h("div", { key: 'e9f328144ab89bbde8c47111f7ce7de7a6c882db' }, index.h("ibcs-table", { key: 'a06695fad28dc30967784006c151abd47d2efd77', tableName: this.datasetName, dataVersion: this.dataVersion, sumTitle: this.prepareSumTitle(), scenarios: this.prepareScenarios(), scenariosDataFormat: this.prepareDataFormat(), grouped: this.prepareGrouped(), limit: this.prepareLimit(), showGroupTitle: this.prepareShowGroupTitle(), thereof: this.prepareThereOf(), partof: this.preparePartOf(), order: this.prepareOrder(), categorythereof: this.prepareColumnThereOf(), attributeColumns: this.prepareAttributes(), type: this.prepareTableType(), categoryWidth: this.prepareCategoryWidth(), dataFormatDigits: this.prepareDataFormatDigits(), i18n: this.prepareI18n(), i18nMode: this.prepareI18nMode(), measureScale: this.prepareMeasureScale(), measureType: this.prepareMeasureType(), measureUnit: this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(), filter: this.prepareFilter(), barColumns: this.prepareBarColumns(), interval: this.prepareInterval(), barColumnMaxWidth: this.prepareBarColumnWidth(), unitScaling: this.prepareUnitScaling(), percentageScaling: this.preparePercentageScaling(), reportAutoScaling: this.handleAutoScalingReport, scaleFactor: effectiveFactor, ruleSetConfig: this.ruleSetConfig(), selectedStyle: this.selectedStyle }))));
6026
+ return (index.h(index.Host, { key: '0581f45b1d4af5a611e295afa924b3564ad4e916', style: fontStyles }, index.h("div", { key: '461dfbb4bbaf75c3aa5df8aad21056dfb01be26c' }, index.h("ibcs-table", { key: 'c17a4104687aee9002144e2800b23b8c99c811a7', tableName: this.datasetName, dataVersion: this.dataVersion, sumTitle: this.prepareSumTitle(), scenarios: this.prepareScenarios(), scenariosDataFormat: this.prepareDataFormat(), grouped: this.prepareGrouped(), limit: this.prepareLimit(), showGroupTitle: this.prepareShowGroupTitle(), thereof: this.prepareThereOf(), partof: this.preparePartOf(), order: this.prepareOrder(), categorythereof: this.prepareColumnThereOf(), attributeColumns: this.prepareAttributes(), type: this.prepareTableType(), categoryWidth: this.prepareCategoryWidth(), dataFormatDigits: this.prepareDataFormatDigits(), i18n: this.prepareI18n(), i18nMode: this.prepareI18nMode(), measureScale: this.prepareMeasureScale(), measureType: this.prepareMeasureType(), measureUnit: this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(), filter: this.prepareFilter(), barColumns: this.prepareBarColumns(), interval: this.prepareInterval(), barColumnMaxWidth: this.prepareBarColumnWidth(), unitScaling: this.prepareUnitScaling(), percentageScaling: this.preparePercentageScaling(), reportAutoScaling: this.handleAutoScalingReport, scaleFactor: effectiveFactor, ruleSetConfig: this.ruleSetConfig(), selectedStyle: this.selectedStyle }))));
5655
6027
  }
5656
6028
  get element() { return index.getElement(this); }
5657
6029
  static get watchers() { return {
@@ -5798,7 +6170,7 @@ const Title$1 = class Title {
5798
6170
  this.t = scaling.withTranslation(this).t;
5799
6171
  this.errors = withHasError.withHasError(this);
5800
6172
  this.componentStyle = withStyled.withComponentStyle(this);
5801
- this.ruleSetConfig = layoutObserver.withRuleSet(this);
6173
+ this.ruleSetConfig = svgChartElements.withRuleSet(this);
5802
6174
  }
5803
6175
  validateScenario(newValue) {
5804
6176
  const errId = "ERR_scenarios";
@@ -7179,8 +7551,11 @@ class Label {
7179
7551
  // @ts-ignore
7180
7552
  const text = label.text(prefix + valueStr);
7181
7553
  text.move(this.x, this.y);
7182
- const boxWidth = text.bbox().w;
7183
- const boxHeight = text.bbox().h;
7554
+ // One bbox() per label, not two: svg.js caches nothing, and on a detached
7555
+ // tree each call clones the subtree into the document to measure it.
7556
+ const box = text.bbox();
7557
+ const boxWidth = box.w;
7558
+ const boxHeight = box.h;
7184
7559
  if (this.maxWidth != null && boxWidth > this.maxWidth) {
7185
7560
  (_a = this.group) === null || _a === void 0 ? void 0 : _a.remove();
7186
7561
  this.group = null;
@@ -8339,6 +8714,17 @@ class StructureChart {
8339
8714
  patternToString() {
8340
8715
  return "<svg></svg>";
8341
8716
  }
8717
+ /**
8718
+ * Runs `draw()` purely for its side effects — it is what finalizes the
8719
+ * positions that `getAllocatedCanvas*()` read.
8720
+ *
8721
+ * The auto-fit solver measures the chart once per iteration and only needs
8722
+ * those numbers, so it calls this instead of {@link toString}: the XML
8723
+ * serialization of a tree that is immediately discarded is pure overhead.
8724
+ */
8725
+ layout() {
8726
+ this.draw(new SVGStyle.Svg());
8727
+ }
8342
8728
  toString() {
8343
8729
  const container = new SVGStyle.Svg();
8344
8730
  this.draw(container);
@@ -8347,8 +8733,32 @@ class StructureChart {
8347
8733
  container.height(this.getAllocatedCanvasHeight());
8348
8734
  return container.svg();
8349
8735
  }
8736
+ /**
8737
+ * Writes the chart's font onto the SVG root as presentation attributes.
8738
+ *
8739
+ * `font-size` and `font-family` are inherited, so a `<text>` with neither of
8740
+ * its own takes whatever its ancestor chain supplies. That chain is not stable
8741
+ * across the places this SVG gets measured: drawn detached, svg.js's `bbox()`
8742
+ * clones the element into a sandbox under `document.body`, where it inherits
8743
+ * the document default — 16px Times — instead of the chart's real font. Every
8744
+ * label was measured ~9% too wide as a result, which over-allocated label
8745
+ * space and pushed labels past the `maxWidth` threshold in {@link Label} that
8746
+ * drops them entirely.
8747
+ *
8748
+ * Setting the font here makes a measurement independent of where it happens.
8749
+ * Stylesheet rules still win over presentation attributes, so this changes
8750
+ * nothing about how the chart renders in place — the CSS and this attribute
8751
+ * resolve to the same value, both being `fontSizePx * effectiveScaleFactor`.
8752
+ */
8753
+ applyFontToContainer(svgContainer) {
8754
+ svgContainer.attr({
8755
+ "font-size": this.styles.fontStyles.size,
8756
+ "font-family": this.styles.fontStyles.family,
8757
+ });
8758
+ }
8350
8759
  draw(svgContainer) {
8351
8760
  this.cleanSVGforRedraw(svgContainer);
8761
+ this.applyFontToContainer(svgContainer);
8352
8762
  if (this.state === FactoryState$2.DIRTY) {
8353
8763
  this.state = FactoryState$2.UP_TO_DATE;
8354
8764
  }
@@ -9320,10 +9730,10 @@ const IbcsChartStructure = class {
9320
9730
  this.chart = new StructureChart(new SVGStyle.IBCSRuleSet(this.ruleSetConfig), db, this.tableName, config, styles);
9321
9731
  this.chart.setI18n(this.i18n);
9322
9732
  };
9323
- // toString() runs draw(), which finalizes positions — an undrawn chart
9733
+ // layout() runs draw(), which finalizes positions — an undrawn chart
9324
9734
  // reports a stale allocated width.
9325
9735
  const measure = () => {
9326
- this.chart.toString();
9736
+ this.chart.layout();
9327
9737
  return this.chart.getAllocatedCanvasWidth();
9328
9738
  };
9329
9739
  if (!targetWidth || targetWidth <= 0) {
@@ -11547,6 +11957,65 @@ class ScenarioFactory {
11547
11957
  }
11548
11958
  }
11549
11959
 
11960
+ /**
11961
+ * Keeps a working SVG attached to the document while it is being drawn, so
11962
+ * svg.js can measure it in place.
11963
+ *
11964
+ * svg.js's `bbox()` calls `getBBox()` on the node; on a **detached** tree that
11965
+ * returns a nulled box, so it falls back to a retry path that deep-clones the
11966
+ * subtree, appends the clone to a hidden sandbox in `document.body`, measures
11967
+ * *that*, and removes it again. Charts are drawn detached and measure heavily
11968
+ * (every label reads its own box), so the retry dominates render cost: one
11969
+ * logical measurement costs two `getBBox()` calls plus a full subtree clone and
11970
+ * two DOM mutations.
11971
+ *
11972
+ * Drawing inside a host that is already in the document makes the first
11973
+ * `getBBox()` succeed, which skips the clone entirely.
11974
+ *
11975
+ * The host is styled exactly like svg.js's own parser sandbox (see
11976
+ * `parser()` in @svgdotjs/svg.js) so the measurement context — and therefore
11977
+ * every measured value — is identical to what the retry path produced.
11978
+ */
11979
+ const HOST_ID = "bn-measurement-host";
11980
+ const HOST_CSS = "opacity:0;position:absolute;left:-100%;top:-100%;overflow:hidden";
11981
+ function getHost() {
11982
+ if (typeof document === "undefined" || !document.body) {
11983
+ return null;
11984
+ }
11985
+ let host = document.getElementById(HOST_ID);
11986
+ if (!host) {
11987
+ host = document.createElement("div");
11988
+ host.id = HOST_ID;
11989
+ host.style.cssText = HOST_CSS;
11990
+ host.setAttribute("aria-hidden", "true");
11991
+ document.body.appendChild(host);
11992
+ }
11993
+ return host;
11994
+ }
11995
+ /**
11996
+ * Runs `drawFn` with `container` temporarily attached to the hidden
11997
+ * measurement host, then detaches it again.
11998
+ *
11999
+ * Falls back to drawing detached when there is no live document (spec runs
12000
+ * under mock-doc), so callers need no environment check of their own.
12001
+ */
12002
+ function drawAttached(container, drawFn) {
12003
+ const host = getHost();
12004
+ if (!host) {
12005
+ drawFn();
12006
+ return;
12007
+ }
12008
+ host.appendChild(container.node);
12009
+ try {
12010
+ drawFn();
12011
+ }
12012
+ finally {
12013
+ if (container.node.parentNode === host) {
12014
+ host.removeChild(container.node);
12015
+ }
12016
+ }
12017
+ }
12018
+
11550
12019
  /** Tracks whether the internal data model needs to be regenerated. */
11551
12020
  var FactoryState$1;
11552
12021
  (function (FactoryState) {
@@ -11875,17 +12344,52 @@ class TimeChart {
11875
12344
  minNegative: this.isOnSameAxisSide() ? 0 : ((_d = (_c = this.smallestVarianceDataPointValue) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 0),
11876
12345
  });
11877
12346
  }
12347
+ /**
12348
+ * Runs `draw()` purely for its side effects — it is what finalizes the
12349
+ * positions and the allocated-area fields that `getAllocatedCanvas*()` read.
12350
+ *
12351
+ * The auto-fit solver measures the chart once per iteration and only needs
12352
+ * those numbers, so it calls this instead of {@link toString}: the XML
12353
+ * serialization of a tree that is immediately discarded is pure overhead.
12354
+ */
12355
+ layout() {
12356
+ const container = new SVGStyle.Svg();
12357
+ drawAttached(container, () => this.draw(container));
12358
+ }
11878
12359
  toString() {
11879
12360
  const container = new SVGStyle.Svg();
11880
- this.draw(container);
12361
+ drawAttached(container, () => this.draw(container));
11881
12362
  container.id("drawCanvas");
11882
12363
  container.width(this.getAllocatedCanvasWidth());
11883
12364
  container.height(this.getAllocatedCanvasHeight());
11884
12365
  container.attr("overflow", "visible");
11885
12366
  return container.svg();
11886
12367
  }
12368
+ /**
12369
+ * Writes the chart's font onto the SVG root as presentation attributes.
12370
+ *
12371
+ * `font-size` and `font-family` are inherited, so a `<text>` with neither of
12372
+ * its own takes whatever its ancestor chain supplies. That chain is not stable
12373
+ * across the places this SVG gets measured: drawn detached, svg.js's `bbox()`
12374
+ * clones the element into a sandbox under `document.body`, where it inherits
12375
+ * the document default — 16px Times — instead of the chart's real font. Every
12376
+ * label was measured ~9% too wide as a result, which over-allocated label
12377
+ * space and pushed labels past the `maxWidth` threshold that drops them.
12378
+ *
12379
+ * Setting the font here makes a measurement independent of where it happens.
12380
+ * Stylesheet rules still win over presentation attributes, so this changes
12381
+ * nothing about how the chart renders in place — the CSS and this attribute
12382
+ * resolve to the same value, both being `fontSizePx * effectiveScaleFactor`.
12383
+ */
12384
+ applyFontToContainer(svgContainer) {
12385
+ svgContainer.attr({
12386
+ "font-size": this.styles.fontStyles.size,
12387
+ "font-family": this.styles.fontStyles.family,
12388
+ });
12389
+ }
11887
12390
  draw(svgContainer) {
11888
12391
  this.cleanSVGforRedraw(svgContainer);
12392
+ this.applyFontToContainer(svgContainer);
11889
12393
  if (this.state === FactoryState$1.DIRTY) {
11890
12394
  this.state = FactoryState$1.UP_TO_DATE;
11891
12395
  }
@@ -12388,9 +12892,12 @@ class TimeChart {
12388
12892
  labelText: this.title,
12389
12893
  isRelative: isRelative,
12390
12894
  }, this.position, axisLabelGroup).draw();
12895
+ // svg.js's width()/height() getters each default to their own bbox() call,
12896
+ // so reading both measures the group twice. Measure once.
12897
+ const axisBox = axisLabelGroup.bbox();
12391
12898
  this.axisCategoryArea = {
12392
- height: axisLabelGroup.height(),
12393
- width: axisLabelGroup.width(),
12899
+ height: axisBox.height,
12900
+ width: axisBox.width,
12394
12901
  };
12395
12902
  }
12396
12903
  drawScenarios(dataModel, svgContainer) {
@@ -12416,9 +12923,10 @@ class TimeChart {
12416
12923
  heightOffset = this.position.dataLabelHeight * 2;
12417
12924
  }
12418
12925
  }
12926
+ const columnBox = columnGroup.bbox();
12419
12927
  this.scenariosArea = {
12420
- height: columnGroup.height() + this.styles.padding.top + this.styles.padding.bottom + heightOffset,
12421
- width: columnGroup.width() + this.position.spacings.columnWidth,
12928
+ height: columnBox.height + this.styles.padding.top + this.styles.padding.bottom + heightOffset,
12929
+ width: columnBox.width + this.position.spacings.columnWidth,
12422
12930
  };
12423
12931
  }
12424
12932
  drawLineScenarios(dataModel, svgContainer) {
@@ -12483,9 +12991,10 @@ class TimeChart {
12483
12991
  // Use getColumnPositionY() (the axis baseline) as the minimum height
12484
12992
  // so that axis date labels drawn below are not cut off.
12485
12993
  const axisY = this.position.getColumnPositionY();
12994
+ const lineBox = lineGroup.bbox();
12486
12995
  this.scenariosArea = {
12487
- height: Math.max(lineGroup.height() + this.styles.padding.top, axisY) + this.styles.padding.bottom,
12488
- width: lineGroup.width() + this.position.spacings.columnWidth,
12996
+ height: Math.max(lineBox.height + this.styles.padding.top, axisY) + this.styles.padding.bottom,
12997
+ width: lineBox.width + this.position.spacings.columnWidth,
12489
12998
  };
12490
12999
  }
12491
13000
  drawAxisAndLabelsForLineChart(dataModel, svgContainer) {
@@ -12536,9 +13045,12 @@ class TimeChart {
12536
13045
  labelText: this.title,
12537
13046
  isRelative: isRelative,
12538
13047
  }, this.position, axisLabelGroup).draw();
13048
+ // svg.js's width()/height() getters each default to their own bbox() call,
13049
+ // so reading both measures the group twice. Measure once.
13050
+ const axisBox = axisLabelGroup.bbox();
12539
13051
  this.axisCategoryArea = {
12540
- height: axisLabelGroup.height(),
12541
- width: axisLabelGroup.width(),
13052
+ height: axisBox.height,
13053
+ width: axisBox.width,
12542
13054
  };
12543
13055
  }
12544
13056
  shouldShowLineChartAxisLabel(dataModel, index) {
@@ -12596,9 +13108,10 @@ class TimeChart {
12596
13108
  scenarioFactory.createVarianceBar(elements["scenario1"], index).draw(this.dataFormatDigits, this.measureScale);
12597
13109
  }
12598
13110
  });
13111
+ const varianceBox = columnGroup.bbox();
12599
13112
  this.scenariosArea = {
12600
- height: columnGroup.height() + this.styles.padding.top + this.styles.padding.bottom,
12601
- width: columnGroup.width() + this.position.spacings.columnWidth,
13113
+ height: varianceBox.height + this.styles.padding.top + this.styles.padding.bottom,
13114
+ width: varianceBox.width + this.position.spacings.columnWidth,
12602
13115
  };
12603
13116
  return columnGroup;
12604
13117
  }
@@ -12706,9 +13219,10 @@ class TimeChart {
12706
13219
  }
12707
13220
  }
12708
13221
  });
13222
+ const stackBox = stackGroup.bbox();
12709
13223
  this.scenariosArea = {
12710
- height: stackGroup.height() + this.styles.padding.top + this.styles.padding.bottom,
12711
- width: stackGroup.width() + this.position.spacings.columnWidth,
13224
+ height: stackBox.height + this.styles.padding.top + this.styles.padding.bottom,
13225
+ width: stackBox.width + this.position.spacings.columnWidth,
12712
13226
  };
12713
13227
  }
12714
13228
  /**
@@ -12888,9 +13402,10 @@ class TimeChart {
12888
13402
  areaFill.draw();
12889
13403
  areaFill.drawBoundaryLine();
12890
13404
  }
13405
+ const areaBox = areaGroup.bbox();
12891
13406
  this.scenariosArea = {
12892
- height: areaGroup.height() + this.styles.padding.top + this.styles.padding.bottom,
12893
- width: areaGroup.width() + this.position.spacings.columnWidth,
13407
+ height: areaBox.height + this.styles.padding.top + this.styles.padding.bottom,
13408
+ width: areaBox.width + this.position.spacings.columnWidth,
12894
13409
  };
12895
13410
  }
12896
13411
  drawOverlayLayer(dataModel, svgContainer) {
@@ -13179,7 +13694,7 @@ class TimeChartComponentConfigAdapter {
13179
13694
  }
13180
13695
  }
13181
13696
 
13182
- const ibcsChartTimeCss = () => `:host{position:relative;display:inline-block}.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-default{stroke:black;stroke-width:0.1em}.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}.hide{opacity:0}.footer{margin:0.2em;font-size:0.6em}.footer-hide{display:none}svg#drawCanvas{display:block}`;
13697
+ const ibcsChartTimeCss = () => `:host{position:relative;display:inline-block}.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-default{stroke:black;stroke-width:0.1em}.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}.hide{opacity:0}.footer{margin:0.2em;font-size:0.6em}.footer-hide{display:none}svg#drawCanvas{display:block}`;
13183
13698
 
13184
13699
  const IbcsChartTime = class {
13185
13700
  constructor(hostRef) {
@@ -13304,10 +13819,10 @@ const IbcsChartTime = class {
13304
13819
  this.chart = new TimeChart(new SVGStyle.IBCSRuleSet(this.ruleSetConfig), this.getDb(), this.tableName, config, styles, availableWidth);
13305
13820
  this.chart.setI18n(this.i18n);
13306
13821
  };
13307
- // toString() runs draw(), which finalizes positions — an undrawn chart
13822
+ // layout() runs draw(), which finalizes positions — an undrawn chart
13308
13823
  // reports a stale allocated height.
13309
13824
  const measure = () => {
13310
- this.chart.toString();
13825
+ this.chart.layout();
13311
13826
  return this.chart.getAllocatedCanvasHeight();
13312
13827
  };
13313
13828
  if (!targetHeight || targetHeight <= 0) {
@@ -15331,6 +15846,10 @@ class TableDataSetFactory {
15331
15846
  this.normalizedHeader = [];
15332
15847
  this.attributesByAlias = new Map();
15333
15848
  }
15849
+ /** Effective column list (category/operation + attributes + scenarios × buckets), set by createHeader(). */
15850
+ getNormalizedHeader() {
15851
+ return this.normalizedHeader;
15852
+ }
15334
15853
  /**
15335
15854
  * Creates Tableheader based on the configured scenarios (in config)
15336
15855
  * the created header is stored in the dataset json
@@ -15824,7 +16343,6 @@ class Table {
15824
16343
  this.config = this.initConfig(config);
15825
16344
  this.i18n = this.initI18n(new Map());
15826
16345
  this.setSource(tableName, config.filter);
15827
- this.state = FactoryState$3.DIRTY;
15828
16346
  }
15829
16347
  /**
15830
16348
  * Init load of translation dictionary map
@@ -15899,8 +16417,22 @@ class Table {
15899
16417
  setConfig(config) {
15900
16418
  this.config = this.initConfig(config);
15901
16419
  }
16420
+ /**
16421
+ * Resolves the dataset (a table or view in the shared alasql database),
16422
+ * caches its row count, and marks the rows stale.
16423
+ *
16424
+ * Deliberately does NOT build header/body rows. The constructor runs before
16425
+ * the component calls {@link setI18n}, so rows built here would carry the
16426
+ * built-in fallback labels and be thrown away by the first `update()` — the
16427
+ * whole N+1 query pass, run twice per render, for a result that was wrong.
16428
+ *
16429
+ * `fromExpr` and `rowCount` must stay eager: `hasNoData()` reads `rowCount`
16430
+ * and the component consults it before any `getHeader()`/`getBody()` call
16431
+ * would trigger the deferred update.
16432
+ */
15902
16433
  setSource(tableName, filter) {
15903
16434
  var _a, _b;
16435
+ this.state = FactoryState$3.DIRTY;
15904
16436
  if (!tableName) {
15905
16437
  this.fromExpr = "";
15906
16438
  this.rowCount = 0;
@@ -15915,12 +16447,6 @@ class Table {
15915
16447
  // Table may not exist yet (e.g. datasource hasn't loaded). Treat as empty.
15916
16448
  this.rowCount = 0;
15917
16449
  }
15918
- this.prepareIntervalBuckets();
15919
- const normalizedScenarios = this.normalizeScenarios(this.config.scenarios, this.config.categoryThereOf, this.config.sortOrder, this.intervalBuckets);
15920
- this.headerRows = this.dataSetFactory.createHeader(this.config.type, normalizedScenarios, this.i18n, this.config.measureScale, this.config.measureUnit, this.config.showMeasureScale, this.config.attributes);
15921
- this.bodyRows =
15922
- this.rowCount === 0 ? [] : this.dataSetFactory.createBodyRows(this.config, this.i18n, this.db, this.fromExpr);
15923
- this.state = FactoryState$3.UP_TO_DATE;
15924
16450
  }
15925
16451
  update() {
15926
16452
  this.prepareIntervalBuckets();
@@ -15944,6 +16470,13 @@ class Table {
15944
16470
  }
15945
16471
  return this.bodyRows;
15946
16472
  }
16473
+ /** Effective column definitions: category/operation + attributes + scenarios × interval buckets. */
16474
+ getColumns() {
16475
+ if (this.state === FactoryState$3.DIRTY) {
16476
+ this.update();
16477
+ }
16478
+ return this.dataSetFactory.getNormalizedHeader();
16479
+ }
15947
16480
  /**
15948
16481
  * Resolves the interval configuration into the concrete bucket list.
15949
16482
  * `auto` is narrowed to a concrete granularity (written back to the config so
@@ -16258,6 +16791,99 @@ const IbcsTable = class {
16258
16791
  this.componentDataFormatDigits = new DataFormatDigits();
16259
16792
  this.componentStyle = withStyled.withComponentStyle(this);
16260
16793
  }
16794
+ /**
16795
+ * Collects the table's layout-state contribution: header/body regions,
16796
+ * counts, and — with `detail: "full"` — per-cell geometry paired with the
16797
+ * table model (values, column keys, in-cell bar charts). Called by the
16798
+ * outer `bn-table`; not for end users.
16799
+ */
16800
+ async getLayoutDetail(origins, detail) {
16801
+ var _a, _b, _c;
16802
+ const result = { regions: [], metadata: {}, diagnostics: [] };
16803
+ const tableEl = (_a = this.element.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("table");
16804
+ result.metadata.hasNoData = (_c = (_b = this.table) === null || _b === void 0 ? void 0 : _b.hasNoData()) !== null && _c !== void 0 ? _c : true;
16805
+ if (!this.table || !tableEl) {
16806
+ return result;
16807
+ }
16808
+ const thead = tableEl.querySelector("thead");
16809
+ const tbody = tableEl.querySelector("tbody");
16810
+ if (thead)
16811
+ result.regions.push({ id: "header", rect: diagnostics.measure(thead, origins) });
16812
+ if (tbody)
16813
+ result.regions.push({ id: "body", rect: diagnostics.measure(tbody, origins) });
16814
+ const headerRows = this.table.getHeader();
16815
+ const bodyRows = this.table.getBody();
16816
+ const columns = this.table.getColumns();
16817
+ result.metadata.headerRowCount = headerRows.length;
16818
+ result.metadata.rowCount = bodyRows.length;
16819
+ result.metadata.columnCount = columns.length;
16820
+ result.metadata.cellCount = bodyRows.reduce((count, row) => count + row.getCells().length, 0);
16821
+ if (detail !== "full") {
16822
+ return result;
16823
+ }
16824
+ const rows = [];
16825
+ const elements = [];
16826
+ const walk = (section, modelRows, container) => {
16827
+ const domRows = container ? Array.from(container.children).filter((child) => child.localName === "tr") : [];
16828
+ modelRows.forEach((row, rowIndex) => {
16829
+ const tr = domRows[rowIndex];
16830
+ if (!tr)
16831
+ return;
16832
+ rows.push({ section, index: rowIndex, type: row.type, rect: diagnostics.measure(tr, origins) });
16833
+ const cells = row.getCells();
16834
+ const domCells = Array.from(tr.children);
16835
+ if (cells.length !== domCells.length) {
16836
+ result.diagnostics.push({
16837
+ id: `LAYOUT_cellPairing_${section}_${rowIndex}`,
16838
+ type: "warning",
16839
+ message: `layout-state: model/DOM cell count mismatch in ${section} row ${rowIndex} (${cells.length} vs ${domCells.length}); cell details skipped for this row.`,
16840
+ });
16841
+ return;
16842
+ }
16843
+ cells.forEach((cell, cellIndex) => {
16844
+ var _a, _b;
16845
+ const domCell = domCells[cellIndex];
16846
+ const entry = {
16847
+ kind: section === "header" ? "headerCell" : "cell",
16848
+ row: rowIndex,
16849
+ column: cell.index,
16850
+ key: cell.key || undefined,
16851
+ colSpan: cell.colSpan,
16852
+ value: (_a = cell.value) !== null && _a !== void 0 ? _a : undefined,
16853
+ text: ((_b = domCell.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || undefined,
16854
+ type: cell.type || undefined,
16855
+ rect: diagnostics.measure(domCell, origins),
16856
+ };
16857
+ const barSvg = domCell.querySelector("svg.cell-bar-chart");
16858
+ if (barSvg) {
16859
+ entry.bar = {
16860
+ variant: barSvg.classList.contains("waterfall-bar")
16861
+ ? "waterfall"
16862
+ : barSvg.classList.contains("relative-variance")
16863
+ ? "relative"
16864
+ : "absolute",
16865
+ rect: diagnostics.measure(barSvg, origins),
16866
+ };
16867
+ }
16868
+ elements.push(entry);
16869
+ });
16870
+ });
16871
+ };
16872
+ walk("header", headerRows, thead);
16873
+ walk("body", bodyRows, tbody);
16874
+ result.elements = elements;
16875
+ result.table = {
16876
+ rows,
16877
+ columns: columns.map((column, index) => ({
16878
+ index,
16879
+ key: column.name,
16880
+ group: column.group,
16881
+ type: column.type,
16882
+ bucket: column.bucket,
16883
+ })),
16884
+ };
16885
+ return result;
16886
+ }
16261
16887
  render() {
16262
16888
  const helper = () => {
16263
16889
  if (this.table === undefined) {