@bino-bi/bn-template-engine 1.0.0-next.52 → 1.0.0-next.53
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-0d8eade3.entry.js +1 -0
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +90 -40
- package/dist/cjs/bn-template-engine.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/bn-chart-structure/bn-chart-structure-renderer/bn-chart-structure-renderer.js +26 -0
- package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +3 -2
- package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +12 -2
- package/dist/collection/components/bn-chart-structure/utils/elements/Bar.js +16 -2
- package/dist/collection/components/bn-chart-structure/utils/elements/Label.js +2 -5
- package/dist/collection/components/bn-chart-structure/utils/helper/ElementPositions.js +5 -0
- package/dist/collection/components/bn-chart-structure/utils/model/StructureChartComponentConfig.js +5 -0
- package/dist/collection/components/bn-context/bn-context.js +45 -30
- package/dist/components/bn-chart-structure-renderer.js +1 -1
- package/dist/components/bn-chart-structure.js +1 -1
- package/dist/components/bn-context.js +1 -1
- package/dist/components/p-9a9XB5Y8.js +1 -0
- package/dist/esm/bn-annotation-layer_30.entry.js +90 -40
- package/dist/esm/bn-template-engine.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/bn-chart-structure/bn-chart-structure-renderer/bn-chart-structure-renderer.d.ts +2 -0
- package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +3 -0
- package/dist/types/components/bn-chart-structure/utils/elements/Bar.d.ts +2 -0
- package/dist/types/components/bn-chart-structure/utils/helper/ElementPositions.d.ts +2 -0
- package/dist/types/components/bn-chart-structure/utils/model/StructureChartComponentConfig.d.ts +2 -0
- package/dist/types/components/bn-context/bn-context.d.ts +4 -4
- package/dist/types/components.d.ts +6 -2
- package/package.json +1 -1
- package/dist/bn-template-engine/p-4d99f1bb.entry.js +0 -1
- package/dist/components/p-iJP2X4dc.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as t,H as i,h as s,d as h,t as e}from"./p-BnmylmXF.js";import{S as n,F as r,a as o,P as a}from"./p-CSJCkHEL.js";import{C as l,A as c,g as u,e as d}from"./p-DguYWLBj.js";import{D as f,b as v}from"./p-keKnrAVS.js";import{c as p,O as m,a as g}from"./p-BBdzTx8V.js";import{S as b}from"./p-CeE4_3wQ.js";import{r as w,F as S,C as P,V as y}from"./p-Zz3fAPcH.js";import{g as x,a as L,I as M}from"./p-4q8nRcWC.js";import{d as k,l as T,S as N}from"./p-DHX92KDP.js";import{N as C,r as $}from"./p-fCjsrD7I.js";import{s as O,c as A,a as E,l as _,b as R,d as W,M as B}from"./p-BTnRaHPb.js";import{I as D,a as j,s as X}from"./p-D0v9GMIf.js";import{d as G,S as V,g as Y}from"./p-6242qMx1.js";import{e as z,r as H}from"./p-ClruFZD_.js";import{S as F}from"./p-Do-IGHJk.js";import{w as U}from"./p-BrQCbmG0.js";import{S as I}from"./p-CJ0-xdfZ.js";import{A as K}from"./p-DsC0ew4j.js";class Z{constructor(t,i,s,h,e,n,r,o,a=!1,l=null){this.categoryPosition={x:0,y:0},this.spacings={scenarioOffset:0,markerOffset:0,scenarioLabelToBar:0,labelToBar:0,labelToAxis:0,needleWidth:0,needleHeadWidth:0,barWidth:0,varianceAxisLineWidth:0,axisLineWidth:0,auxiliaryLineWidth:0,scenarioLineWidth:0,markerWidth:0,categoryWidth:0,axisTickLength:0},this.categoriesBoxOffset={width:0,height:0},this.padding=t,this.scaleFactors=i,this.fontSize=s,this.axisPosition={x:0,y:0},this.numberOfColumns=h,this.leftSideLengthSync=e,this.topSideLabelHeight=n>0?this.fontSize:0,this.hasStackedHeaders=a,this.rows=l,this.leftSideLabelLength=this.calculateSideLabelLength(n,r,o),this.calculateSpacings(),this.calculateCategoryPosition(),this.calculateAxisPosition()}getBarPositionX(){return this.axisPosition.x}getBarCenterPositionY(t){if(this.rows&&t<this.rows.start.length){const i=this.rows.start[t]+this.rows.weight[t]/2;return this.getAxisPositionY()+this.spacings.scenarioOffset+i*this.spacings.categoryWidth}return this.categoryPosition.y+this.spacings.scenarioOffset+t*this.spacings.categoryWidth}isNameBelowBar(){var t;return!!(null===(t=this.rows)||void 0===t?void 0:t.nameBelowBar)}getRowTopPositionY(t){const i=this.rows&&t<this.rows.start.length?this.rows.start[t]:t;return this.getAxisPositionY()+this.spacings.scenarioOffset+i*this.spacings.categoryWidth}getBarWidthAt(t){return this.spacings.barWidth*(this.rows&&t<this.rows.weight.length?this.rows.weight[t]:1)}getBarPositionY(t,i){return i?this.getBarCenterPositionY(t):this.getBarCenterPositionY(t)-this.spacings.scenarioOffset}getCategoryPositionX(t){let i=this.spacings.labelToAxis;return t&&(i=-this.spacings.labelToAxis),this.getAxisPositionX()+i}getAxisTitlePositionX(){return this.axisPosition.x}getAxisTitlePositionY(){return this.axisPosition.y-this.spacings.labelToAxis-this.getTopLabelOverhang()}getStackedHeaderPositionY(){return this.getBarCenterPositionY(0)-.5*this.getBarWidthAt(0)-this.spacings.scenarioLabelToBar}getNeedleWidth(){return this.spacings.needleWidth}getAxisPositionX(){return this.leftSideLabelLength+this.padding.left+this.spacings.labelToAxis}getAxisPositionY(){return this.padding.top+this.getAxisTitleOffset()}loadCategoriesBox(t){this.categoriesBoxOffset=t,this.calculateAxisPosition()}addOffsetByNegativeDataPoints(t,i,s,h){null!=t&&null!=t.value&&t.value<0&&(s&&t.isClipped()?this.axisPosition.x+=Math.abs(t.getClippedValue()*t.pixelPerUnit):this.axisPosition.x+=Math.abs(t.value*t.pixelPerUnit),this.axisPosition.x+=i,this.axisPosition.x+=this.spacings.labelToBar),this.axisPosition.x<h/2&&(this.axisPosition.x=h/2+this.spacings.labelToBar)}getLabelPositionX(t){let i=this.spacings.labelToBar;return t<0&&(i*=-1),this.axisPosition.x+t+i}getLabelPositionY(t){return this.axisPosition.y+t+this.spacings.labelToBar}getCategoryToAxisSpaceing(){return this.spacings.labelToAxis}getCategoryToTopSpaceing(){return this.spacings.scenarioOffset}getCategoryToBottomSpaceing(){return this.spacings.scenarioOffset}getAxisEndPositionY(){const t=this.rows?this.rows.total:this.numberOfColumns;return this.getAxisPositionY()+(t+.5)*this.spacings.categoryWidth}getScenarioLabelPositionOffsetY(t){var i;if(t){const t=.5*this.getBarWidth()+this.spacings.scenarioLabelToBar;return(null===(i=this.rows)||void 0===i?void 0:i.nameBelowBar)?t:Math.max(t,this.spacings.categoryWidth-this.spacings.scenarioOffset+this.spacings.labelToAxis)}return-(.5*this.getBarWidth()+this.spacings.scenarioLabelToBar)}getBarWidth(){return this.spacings.barWidth}getMarkerPositionY(t,i){return i?this.getBarCenterPositionY(t)-this.spacings.markerOffset-.5*this.getBarWidth():this.getBarCenterPositionY(t)+this.spacings.markerOffset+.5*this.getBarWidth()}getMarkerPositionX(){return this.getBarPositionX()}getMarkerScenarioLabelPositionOffsetY(t){return t?-(.5*this.spacings.markerWidth+this.spacings.scenarioLabelToBar):this.spacings.scenarioLabelToBar+.5*this.spacings.markerWidth}getAxisEndPositionX(){return this.getAxisPositionX()}calculateSpacings(){this.spacings={scenarioOffset:this.fontSize*this.scaleFactors.scenarioOffset,markerOffset:this.fontSize*this.scaleFactors.markerOffset,scenarioLabelToBar:this.fontSize*this.scaleFactors.scenarioLabelToBar,labelToBar:this.fontSize*this.scaleFactors.labelToBar,labelToAxis:this.fontSize*this.scaleFactors.labelToAxis,needleWidth:this.fontSize*this.scaleFactors.needleWidth,needleHeadWidth:this.fontSize*this.scaleFactors.needleHeadWidth,barWidth:this.fontSize*this.scaleFactors.barWidth,varianceAxisLineWidth:this.fontSize*this.scaleFactors.varianceAxisLineWidth,axisLineWidth:this.fontSize*this.scaleFactors.axisLineWidth,auxiliaryLineWidth:this.fontSize*this.scaleFactors.auxiliaryLineWidth,scenarioLineWidth:this.fontSize*this.scaleFactors.scenarioLineWidth,markerWidth:this.fontSize*this.scaleFactors.markerWidth,categoryWidth:this.fontSize*this.scaleFactors.categoryWidth,axisTickLength:this.fontSize*this.scaleFactors.axisTickLength}}calculateCategoryPosition(){this.categoryPosition={x:this.padding.left,y:this.getAxisPositionY()+.5*this.spacings.categoryWidth}}calculateAxisPosition(){this.axisPosition={x:this.getAxisPositionX(),y:this.getAxisPositionY()}}recalculatePositions(){this.calculateCategoryPosition(),this.calculateAxisPosition()}getAxisTitleOffset(){return this.topSideLabelHeight+this.spacings.labelToAxis+this.getTopLabelOverhang()}getTopLabelOverhang(){return this.hasStackedHeaders?this.getStackedHeaderOverhang():this.getTopScenarioLabelOverhang()}getStackedHeaderOverhang(){return Math.max(0,this.fontSize+this.spacings.scenarioLabelToBar+.5*this.spacings.barWidth-(.5*this.spacings.categoryWidth+this.spacings.scenarioOffset))}getTopScenarioLabelOverhang(){return Math.max(0,this.fontSize+.5*this.spacings.barWidth+this.spacings.scenarioLabelToBar-.5*this.spacings.categoryWidth,this.fontSize+.5*this.spacings.markerWidth+this.spacings.scenarioLabelToBar+this.spacings.markerOffset+.5*this.spacings.barWidth-(.5*this.spacings.categoryWidth+this.spacings.scenarioOffset))}calculateSideLabelLength(t,i,s){if(this.leftSideLengthSync)return this.leftSideLengthSync;const h=t/2;let e=i;return h>e&&(e=h),s>e&&(e=s),e}}class Q{constructor(t){this.top=t.top,this.bottom=t.bottom,this.left=t.left,this.right=t.right}addBoxTopLeft(t){return this.top+=t.height|this.top,this.left+=t.width|this.top,this}}class q{constructor(t){const i=1*t,s=.7*t;this.bgOffset=(i-s)/2,this.markerUp={top:s/2+",0",left:"0,"+s,right:s+","+s},this.markerUpBackground={top:i/2+",0",left:"0,"+i,right:i+","+i},this.markerDown={bottom:s/2+","+s,left:"0,0",right:s+",0"},this.markerDownBackground={bottom:i/2+","+i,left:"0,0",right:i+",0"}}upMarkerPatternStrings(){return{background:this.markerUpBackground.left+" "+this.markerUpBackground.right+" "+this.markerUpBackground.top+" "+this.markerUpBackground.left,foreground:this.markerUp.left+" "+this.markerUp.right+" "+this.markerUp.top+" "+this.markerUp.left,bgOffset:this.bgOffset}}downMarkerPatternStrings(){return{background:this.markerDownBackground.left+" "+this.markerDownBackground.right+" "+this.markerDownBackground.bottom+" "+this.markerDownBackground.left,foreground:this.markerDown.left+" "+this.markerDown.right+" "+this.markerDown.bottom+" "+this.markerDown.left,bgOffset:this.bgOffset}}createPatternMapForStructureBar(){const t=new Map;return t.set("marker-up",this.upMarkerPatternStrings()),t.set("marker-down",this.downMarkerPatternStrings()),t}}class J{constructor(t){this.container=new n,this.pattern=this.createFCPattern(this.container.group(),t),this.styles=t;let i=10;null!=t&&null!=t.fontStyles&&t.fontStyles.size&&(i=t.fontStyles.size),this.bgOffset=(1*i-.7*i)/2}createFCPattern(t,i){const s=i;return t.pattern(10,10,(function(t){t.rect(10,10).fill(s.barStyles.fc.fill),t.line(0,5,5,0).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"}),t.line(5,10,10,5).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"})})).id("pattern-structure-fc")}getFCPolygonPattern(){return{background:"",foreground:"",bgOffset:0,pattern:this.pattern}}toString(){return this.container.svg()}}var tt,it,st,ht,et;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(tt||(tt={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(it||(it={}));class nt{constructor(t,i){this.data=t,this.scenarios=i,this.variances=[],this.title="",this.hideCategories=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.sortOrder=new p(new F).default(),this.level=c.CATEGORY,this.filter="",this.measureScale=new b,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.stackConfig=null,this.sums="none",this.sumTitle="",this.scenarioLabelTop=!1,this.hideScenarioName=!1,this.referenceLine=null,this.italicCategories=[]}}class rt{constructor(t,i,s,h,e,n,r){this.dataRowAdapter=t,this.orderAdapter=i,this.stringAdapter=s,this.dataFormatDigitsAdapter=h,this.db=e,this.fromExpr=n,this.onQueryError=r}adapt(t){const i=K.adaptArray(t.data,this.dataRowAdapter),s=K.adaptArray(t.scenarios,this.stringAdapter),h=new nt(i,s);return l.isArray(t.variances)&&(h.variances=K.adaptArray(t.variances,this.stringAdapter)),l.isString(t.title)&&(h.title=t.title),l.isBoolean(t.hideCategories)&&(h.hideCategories=t.hideCategories),l.isNumber(t.pixelPerUnit)&&(h.pixelPerUnit=t.pixelPerUnit),l.isNumber(t.pixelPerPercentage)&&(h.pixelPerPercentage=t.pixelPerPercentage),l.isNumber(t.limit)&&(h.limit=t.limit),l.isExisting(t.sortOrder)&&(h.sortOrder=this.orderAdapter.adapt(t.sortOrder)),l.isExisting(t.level)&&(h.level=t.level),l.isString(t.filter)&&(h.filter=t.filter.trim()),l.isExisting(t.measureScale)&&(h.measureScale=f.calculateMeasureScale(this.db,this.fromExpr,h.scenarios,t.measureScale,this.onQueryError)),l.isString(t.measureUnit)&&(h.measureUnit=t.measureUnit),l.isBoolean(t.showMeasureScale)&&(h.showMeasureScale=t.showMeasureScale),l.isExisting(t.dataFormatDigits)&&(h.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),l.isExisting(t.stackConfig)&&(h.stackConfig=t.stackConfig),l.isString(t.sums)&&["groups","total","all"].includes(t.sums)&&(h.sums=t.sums),l.isString(t.sumTitle)&&(h.sumTitle=t.sumTitle),l.isBoolean(t.scenarioLabelTop)&&(h.scenarioLabelTop=t.scenarioLabelTop),l.isBoolean(t.hideScenarioName)&&(h.hideScenarioName=t.hideScenarioName),l.isExisting(t.referenceLine)&&(h.referenceLine=t.referenceLine),l.isArray(t.italicCategories)&&(h.italicCategories=K.adaptArray(t.italicCategories,this.stringAdapter)),h}default(){return new nt([],[])}}class ot{constructor(t,i,s,h){this.value=t,this.scenario=i,this.pixelPerUnit=s||1;const e="string"==typeof h?w(h,null,!0):h;this.variance="neg"===e||e===st.NEG?st.NEG:"pos"===e||e===st.POS?st.POS:st.NEU}isEmpty(){return null==this.value||null==this.scenario}getScaledUnit(){return null==this.value?0:this.value*this.pixelPerUnit}getScaledPercentUnit(){return null==this.value?0:Math.abs(this.value)>1.45?this.value>=0?1.45*this.pixelPerUnit:-1.45*this.pixelPerUnit:this.value*this.pixelPerUnit}getVarianceStyle(){return null==this.value||this.value>=0?this.variance:st.NEU===this.variance?st.NEU:st.POS===this.variance?st.NEG:st.POS}isClipped(){return null!=this.value&&Math.abs(this.value)>1.45}getClippedValue(){return 145}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}class at{constructor(){this.operation="+"}addRowGroup(t,i){this.rowGroup=t,this.rowGroupIndex=i}addCategory(t,i){this.category=t,this.categoryIndex=i}addSubCategory(t,i){this.subCategory=t,this.subCategoryIndex=i}addColumnGroup(t,i){this.columnGroup=t,this.columnGroupIndex=i}addSubColumnGroup(t,i){this.columnSubGroup=t,this.columnSubGroupIndex=i}}class lt{constructor(){}adapt(t){const i=new at;return l.isOperator(t.operation)&&(i.operation=t.operation),l.isNumber(t.rowGroupIndex)&&l.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),l.isNumber(t.categoryIndex)&&l.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),l.isNumber(t.subCategoryIndex)&&l.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),l.isNumber(t.columnGroupIndex)&&l.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),l.isNumber(t.columnSubGroupIndex)&&l.isString(t.columnSubGroup)&&i.addSubColumnGroup(t.columnSubGroup,t.columnSubGroupIndex),this.setActualValues(t,i),this.setPlanValues(t,i),this.setPreviousPeriodValues(t,i),this.setForecastValues(t,i),i}default(){return new at}setActualValues(t,i){l.isNumber(t.ac1)&&(i.ac1=t.ac1),l.isNumber(t.ac2)&&(i.ac2=t.ac2),l.isNumber(t.ac3)&&(i.ac3=t.ac3),l.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){l.isNumber(t.pl1)&&(i.pl1=t.pl1),l.isNumber(t.pl2)&&(i.pl2=t.pl2),l.isNumber(t.pl3)&&(i.pl3=t.pl3),l.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){l.isNumber(t.pp1)&&(i.pp1=t.pp1),l.isNumber(t.pp2)&&(i.pp2=t.pp2),l.isNumber(t.pp3)&&(i.pp3=t.pp3),l.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){l.isNumber(t.fc1)&&(i.fc1=t.fc1),l.isNumber(t.fc2)&&(i.fc2=t.fc2),l.isNumber(t.fc3)&&(i.fc3=t.fc3),l.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class ct{constructor(t,i,s,h,e,n){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=h,this.varianceStyles=e,this.padding=n,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"],this.locale="de"}}class ut{constructor(t,i,s,h,e){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=h,this.paddingadapter=e}adapt(t){const i=new ct(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return l.isExisting(t)&&(l.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),l.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),l.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),l.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),l.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),l.isExisting(t.padding)&&(i.padding=this.paddingadapter.adapt(t.padding)),Array.isArray(t.stackColors)&&t.stackColors.length>0&&(i.stackColors=t.stackColors),i.pattern=new q(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new ct(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}class dt{constructor(){this.scenarioOffset=.3,this.scenarioLabelToBar=.1,this.labelToBar=.3,this.labelToAxis=.3,this.needleWidth=.3,this.needleHeadWidth=.6,this.barWidth=1.2,this.varianceAxisLineWidth=.3,this.axisLineWidth=.1,this.auxiliaryLineWidth=.1,this.scenarioLineWidth=.2,this.markerWidth=.7,this.markerOffset=0,this.categoryWidth=1.9,this.axisTickLength=.3}}class ft{adapt(t){const i=new dt;return l.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),l.isNumber(t.scenarioLabelToBar)&&(i.scenarioLabelToBar=t.scenarioLabelToBar),l.isNumber(t.labelToBar)&&(i.labelToBar=t.labelToBar),l.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),l.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),l.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),l.isNumber(t.barWidth)&&(i.barWidth=t.barWidth),l.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),l.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),l.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),l.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),l.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),l.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),l.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),l.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new dt}}!function(t){t.AC1="ac1",t.PP1="pp1",t.FC1="fc1",t.PL1="pl1",t.AC2="ac2",t.PP2="pp2",t.FC2="fc2",t.PL2="pl2",t.AC3="ac3",t.PP3="pp3",t.FC3="fc3",t.PL3="pl3",t.AC4="ac4",t.PP4="pp4",t.FC4="fc4",t.PL4="pl4",t.POS="pos",t.NEG="neg",t.NEU="neu"}(st||(st={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(ht||(ht={})),function(t){t[t.Left=0]="Left",t[t.Center=1]="Center",t[t.Right=2]="Right",t[t.Top=3]="Top",t[t.Bottom=4]="Bottom"}(et||(et={}));class vt{constructor(t,i,s,h,e,n,r,o){this.group=null,this.segmentFillColor=null,this.maxWidth=null,this.bold=!1,this.italic=!1,this.ID_SCENARIOLABEL="Label",this.CSS_CATEGORIES="categories",this.pointPart="label",this.x=i,this.y=s,this.value=e,null!=t&&(this.group=t.group().id(this.createElementID(t.toString(),h))),this.styles=n,this.isVarianceLabel=!1,this.isRelativeLabel=!1,this.verticalHookLocation=r||et.Top,this.horizontalHookLocation=o||et.Left}setToVarianceLabel(){return this.isVarianceLabel=!0,this}setToRelativeVarianceLabel(){return this.isVarianceLabel=!0,this.isRelativeLabel=!0,this}setSegmentFill(t){return this.segmentFillColor=t,this}setEmphasis(t,i){return this.bold=t,this.italic=i,this}setMaxWidth(t){return this.maxWidth=t,this}setPoint(t,i="label"){return this.pointKey=t,this.pointPart=i,this}updateGroup(t){return this.group=t,this}createElementID(t,i){return t+"_"+i+"_"+this.ID_SCENARIOLABEL}draw(t={percent:2,decimal:1},i=new b){var s;if(this.isEmpty())return this;const h=this.group;let e;const n=this.styles.fontStyles.background||"#ffffff";let r="";if(!1===Number.isNaN(Number(this.value))){let s=t.percent,h=t.percent,n=1,o="percent";!1===this.isRelativeLabel&&(s=t.decimal,h=t.decimal,n=i.value,o="decimal"),e=S.number(Number(this.value),o,s,h,n,this.styles.locale);const a=S.number(0,o,s,h,n,this.styles.locale);this.isVarianceLabel&&Number(this.value)>0&&e!==a&&(r="+")}else e=""+this.value;const o=h.text(r+e);this.bold&&o.font({weight:"bold"}),this.italic&&o.font({style:"italic"}),o.move(this.x,this.y);const a=o.bbox(),l=a.w,c=a.h;if(null!=this.maxWidth&&l>this.maxWidth)return null===(s=this.group)||void 0===s||s.remove(),this.group=null,this;let u="start";return this.horizontalHookLocation===et.Right?(u="end",o.move(o.x()-o.length(),o.y())):this.horizontalHookLocation===et.Center&&(u="middle",o.move(o.x()-o.length()/2,o.y())),this.verticalHookLocation===et.Center?o.move(o.x(),o.y()-c/2):this.verticalHookLocation===et.Bottom&&o.move(o.x(),o.y()-c),o.font({anchor:u}),null!=this.segmentFillColor?o.fill(x(this.segmentFillColor)):null==h||h.rect(l,.9*c).stroke(n).fill(n).opacity(.7).move(o.x(),o.y()+.1*c).insertBefore(o),this.pointKey&&(null==h||h.attr(k(this.pointKey,this.pointPart))),this}isEmpty(){return null==this.value||""===this.value}setPos(t,i){return this.x=t,this.y=i,this}}class pt{constructor(t,i,s,h){this.height=0,this.ID_AXIS="axis",this.ID_AXIS_TITLE="axis-title",this.CSS_AXIS_TITLE="categories",this.scenarioType=t.scenarioType,this.labelText=t.labelText||null,this.position=i,this.style=h,this.label=new vt(s,this.position.getAxisTitlePositionX(),this.position.getAxisTitlePositionY(),this.ID_AXIS_TITLE,this.labelText,this.style,et.Bottom,et.Center),this.svgGroup=s.group().id(this.ID_AXIS)}draw(){return this.labelText&&this.label.draw(),this.svgGroup.line(this.position.getAxisPositionX(),this.position.getAxisPositionY(),this.position.getAxisEndPositionX(),this.position.getAxisEndPositionY()).addClass(this.ID_AXIS+"-"+this.convertScenarioType()),this.height=this.svgGroup.height(),this}convertScenarioType(){return void 0===this.scenarioType||null==this.scenarioType?"default":`${this.scenarioType}`.slice(0,2)}}class mt{constructor(t,i,s,h,e,n,r,o=null){if(this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.scenarioLabel=null,this.barGroup=null,this.isVarianceBar=!1,this.overflowConfig=null,this.isOverflowing=!1,this.overdriveWidth=0,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=h,this.isPrimaryBar=e,this.position=t,this.barStyles=i.barStyles,this.overflowConfig=o,this.scenarioGroup=n,this.styles=i,null!=n&&(this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT)),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0;let i=et.Left;s.value<0&&(i=et.Right),this.dimensions=this.createDimensions(t,s,h,e),this.label=new vt(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,et.Center,i).setPoint(s.key),this.scenarioLabel=this.getScenarioLabel(r)}}setAsVariance(){var t;return this.isVarianceBar=!0,null===(t=this.label)||void 0===t||t.setToVarianceLabel(),this}isRelativeVariance(){var t;return this.isVarianceBar=!0,null===(t=this.label)||void 0===t||t.setToRelativeVarianceLabel(),this}emphasize(){var t;return null===(t=this.label)||void 0===t||t.setEmphasis(!0,!1),this}updateLabelGroup(t){var i;return this.isEmpty()||null==t||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1},i=new b){var s,h,e;if(this.isEmpty()||null==this.dataPoint.getScenario())return this;let n=this.barStyles.getSVGStyle(this.dataPoint.getScenario());this.isVarianceBar&&(n=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()));const r=this.convertToSVGStyle(n,"stroke");let o=this.convertToSVGStyle(n,"fill");const a=this.barStyles.getSVGStyle(this.dataPoint.getScenario()).fillpattern;if(null!=a){const t=this.styles.pattern.get(a);null!=t&&(o=t.pattern)}null===(s=this.scenarioGroup)||void 0===s||s.attr(k(this.dataPoint.key)),null===(h=this.barGroup)||void 0===h||h.attr(k(this.dataPoint.key,"element")),this.isVarianceBar||null===(e=this.barGroup)||void 0===e||e.attr("data-bn-value",this.dataPoint.value),null!=this.barGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(o,r):this.barGroup.rect(this.dimensions.barLength,this.position.getBarWidth()).fill(o).stroke(r).cy(this.dimensions.yPos).x(this.dimensions.xPos)),this.drawBarDataLabel(t,i),this.drawScenarioLabel()}drawOverdriveBar(t,i){if(!this.barGroup||!this.overflowConfig)return;const s=this.position.getBarPositionX(),h=this.position.getBarWidth(),e=this.dimensions.barLength,{breakGap:n}=this.overflowConfig;this.dataPoint.getScaledUnit()<0?(this.barGroup.rect(e,h).fill(t).stroke(i).x(s-e).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,h).fill(t).stroke(i).x(s-e-n-this.overdriveWidth).cy(this.dimensions.yPos),this.drawBreakIndicator(s-e-n,n)):(this.barGroup.rect(e,h).fill(t).stroke(i).x(s).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,h).fill(t).stroke(i).x(s+e+n).cy(this.dimensions.yPos),this.drawBreakIndicator(s+e,n))}drawBreakIndicator(t,i){if(!this.barGroup)return;const s=this.position.getBarWidth(),h=this.dimensions.yPos-s/2,e=t+i/2,n=.35*i,r=s/3;let o=`M ${e-n} ${h}`;for(let t=0;t<3;t++)o+=` L ${e-n-.3*i} ${h+r*(t+.5)} L ${e-n} ${h+r*(t+1)}`;let a=`M ${e+n} ${h}`;for(let t=0;t<3;t++)a+=` L ${e+n+.3*i} ${h+r*(t+.5)} L ${e+n} ${h+r*(t+1)}`;this.barGroup.rect(i,s+2).fill("#ffffff").stroke("none").x(t).cy(this.dimensions.yPos),this.barGroup.path(o).fill("none").stroke({color:"#000000",width:1}),this.barGroup.path(a).fill("none").stroke({color:"#000000",width:1})}createDimensions(t,i,s,h){const e=i.getScaledUnit(),n=Math.abs(e);if(this.overflowConfig&&n>0){const r="ac"===i.getScenario()?this.overflowConfig.cutWidth:this.overflowConfig.cutWidth-this.overflowConfig.scenarioCutOffset;if(n>r){this.isOverflowing=!0;const{breakGap:i,overdriveZoneWidth:o,maxOverflow:a}=this.overflowConfig;this.overdriveWidth=a>0?(n-r)/a*o:0;const l=r+i+this.overdriveWidth;return e<0?{clipped:!1,barLength:r,xPos:t.getBarPositionX()-r,yPos:t.getBarPositionY(s,h),labelXPos:t.getLabelPositionX(-l),scenarioLabelXPos:t.getBarPositionX()-.5*r,scenarioLabelYPos:t.getBarPositionY(s,h)+t.getScenarioLabelPositionOffsetY(h)}:{clipped:!1,barLength:r,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,h),labelXPos:t.getLabelPositionX(l),scenarioLabelXPos:t.getBarPositionX()+.5*r,scenarioLabelYPos:t.getBarPositionY(s,h)+t.getScenarioLabelPositionOffsetY(h)}}}return e<0?{clipped:!1,barLength:n,xPos:t.getBarPositionX()+e,yPos:t.getBarPositionY(s,h),labelXPos:this.position.getLabelPositionX(e),scenarioLabelXPos:this.position.getBarPositionX()-.5*n,scenarioLabelYPos:this.position.getBarPositionY(s,h)+this.position.getScenarioLabelPositionOffsetY(h)}:{clipped:!1,barLength:e,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,h),labelXPos:this.position.getLabelPositionX(e),scenarioLabelXPos:this.position.getBarPositionX()+.5*n,scenarioLabelYPos:this.position.getBarPositionY(s,h)+this.position.getScenarioLabelPositionOffsetY(h)}}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){if(null!=this.scenarioLabel&&!this.scenarioLabel.isEmpty()&&!this.isVarianceBar){let t=this.dimensions.scenarioLabelXPos;if(this.nameBesideAxis()){const i=this.dataPoint.getScaledUnit()<0?-1:1;t=this.position.getBarPositionX()+i*this.position.spacings.labelToAxis}this.scenarioLabel.setPos(t,this.dimensions.scenarioLabelYPos).draw()}}nameBesideAxis(){return this.isPrimaryBar&&this.position.isNameBelowBar()}drawBarDataLabel(t,i=new b){var s;this.isPrimaryBar&&(null===(s=this.label)||void 0===s||s.draw(t,i))}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getScenarioLabel(t){if(this.isPrimaryBar){let i=et.Center;return this.nameBesideAxis()&&(i=this.dataPoint.getScaledUnit()<0?et.Right:et.Left),new vt(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,et.Top,i)}return new vt(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,et.Bottom,et.Center)}}class gt{constructor(t,i,s,h,e,n,r,o,a){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.FALLBACK_COLOUR="#000000",this.scenarioLabel=null,this._defaultMarkerPattern=null,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.position=t,this.markerGroup=i||null,this.markerPattern=s||this._defaultMarkerPattern,this.styles=e,this.barStyles=e?e.barStyles:null,this.scenario=h,!0!==(null==n?void 0:n.isEmpty())&&(this.hasData=!0,this.pointKey=n.key,this.dimensions=this.createMarkerDimensions(n,r,a),this.scenarioLabel=this.getScenarioLabel(o,e,a))}createMarkerDimensions(t,i,s){return t.getScaledUnit()<0?{clipped:!1,labelXPos:0,barLength:Math.abs(t.getScaledUnit()),xPos:this.position.getMarkerPositionX()-Math.abs(t.getScaledUnit()),yPos:this.position.getMarkerPositionY(i,s),scenarioLabelXPos:this.position.getMarkerPositionX()-Math.abs(t.getScaledUnit()),scenarioLabelYPos:this.position.getMarkerPositionY(i,s)+this.position.getMarkerScenarioLabelPositionOffsetY(s)}:{clipped:!1,labelXPos:0,barLength:t.getScaledUnit(),xPos:this.position.getMarkerPositionX()+t.getScaledUnit(),yPos:this.position.getMarkerPositionY(i,s),scenarioLabelXPos:this.position.getMarkerPositionX()+t.getScaledUnit(),scenarioLabelYPos:this.position.getMarkerPositionY(i,s)+this.position.getMarkerScenarioLabelPositionOffsetY(s)}}getScenarioLabel(t,i,s){return null==this.markerGroup?null:new vt(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,s?et.Bottom:et.Top,et.Center)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}draw(){if(this.isEmpty())return this;const t=this.convertToSVGStyle(this.barStyles[this.getScenario()],"stroke");let i=this.convertToSVGStyle(this.barStyles[this.getScenario()],"fill");const s=this.barStyles[this.getScenario()];if(null!=s&&s.fillpattern){const t=this.styles.pattern.get(s.fillpattern);null!=t&&(i=t.pattern)}return this.markerGroup.attr(k(this.pointKey)),this.markerGroup.polygon(this.markerPattern.background).fill("#ffffff").cy(this.dimensions.yPos).cx(this.dimensions.xPos),this.markerGroup.polygon(this.markerPattern.foreground).fill(i).stroke(t).cy(this.dimensions.yPos).cx(this.dimensions.xPos).attr(k(this.pointKey,"element")),null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(),this}isEmpty(){return!1===this.hasData}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}class bt{constructor(t,i,s,h,e){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=h,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=e,this.styles=i,this.barGroup=e.group().id(e.toString()+"_"+this.ID_RECT);const n=void 0===(null==s?void 0:s.value)&&null!=(null==s?void 0:s.scenario);if(!0!==(null==s?void 0:s.isEmpty())&&null!=s.value||n){this.hasData=!0,this.dimensions=this.createDimensions(t,s,h);let i=et.Left;s.value<0&&(i=et.Right),this.label=new vt(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,n?C:s.value,this.styles,et.Center,i),this.label.setToRelativeVarianceLabel().setPoint(s.key)}}emphasize(){var t;return null===(t=this.label)||void 0===t||t.setEmphasis(!0,!1),this}updateLabelGroup(t){var i;return this.isEmpty()||null==t||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1}){var i,s,h;if(void 0===(null===(i=this.dataPoint)||void 0===i?void 0:i.value))return null===(s=this.label)||void 0===s||s.draw(t),this;if(this.isEmpty())return this;if(null==this.dimensions)return this;this.scenarioGroup.attr(k(this.dataPoint.key)),this.barGroup.attr(k(this.dataPoint.key,"element"));const e=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()),n=e.stroke;let r=e.fill;const o=this.barStyles[this.dataPoint.getScenario()];if(null!=o&&o.fillpattern){const t=this.styles.pattern.get(o.fillpattern);null!=t&&null!=t.pattern&&(r=t.pattern)}this.drawNeedleHead(r,n),this.barGroup.rect(this.dimensions.barLength,this.position.getNeedleWidth()).fill(r).stroke(n).cy(this.dimensions.yPos).x(this.dimensions.xPos),null===(h=this.label)||void 0===h||h.draw(t)}createDimensions(t,i,s){return i.getScaledPercentUnit()<0?{barLength:Math.abs(i.getScaledPercentUnit()),xPos:t.getBarPositionX()+i.getScaledPercentUnit(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()-this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}:{barLength:i.getScaledPercentUnit(),xPos:t.getBarPositionX(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()+this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}}drawNeedleHead(t,i){if(null===this.dimensions)return;const s=this.styles.varianceStyles.needleHeadColour,h=this.styles.varianceStyles.needleHeadColour;if(this.dimensions.clipped){let s="13,0 4,-5 4,5 13,0 8,0 0,-5 0,5 8,0";null!=this.dataPoint.value&&this.dataPoint.value<0&&(s="0,0 9,-5 9,5 0,0 5,0 13,-5 13,5 5,0"),this.barGroup.polygon(s).fill(t).cx(this.getHeadXPosition()).cy(this.dimensions.yPos).fill(t).stroke(i)}else this.barGroup.rect(2*this.position.getNeedleWidth(),2*this.position.getNeedleWidth()).cx(this.getHeadXPosition()).cy(this.dimensions.yPos).fill(s).stroke(h)}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getHeadXPosition(){let t=this.dimensions.xPos;return null!=this.dataPoint.value&&this.dataPoint.value>0&&(t+=this.dimensions.barLength),t}}class wt{constructor(t,i,s,h,e,n,r,o,a,l,c,u={}){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=h,this.segment=e,this.segmentIndex=r,this.stackMode=o,this.stack=a,this.options=u,this.group=c,this.barGroup=c.group().id(`stacked_bar_${h}_seg_${r}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new b){var s;if(!this.hasData||!Number.isFinite(this.dataPoint.value))return;const h=this.dataPoint.value,e=this.dataPoint.pixelPerUnit,n=this.position.getBarPositionX(),r=this.position.getBarWidthAt(this.index),o=Math.abs(this.segment.end-this.segment.start)*e,a=n+Math.min(this.segment.start,this.segment.end)*e,l=this.position.getBarPositionY(this.index,!0),c=this.styles.stackColors,d=c[this.segmentIndex%c.length],f={color:d},v={color:d,width:.5};this.barGroup.attr(k(this.dataPoint.key,"element")),this.barGroup.attr("data-bn-value",h),this.barGroup.rect(Math.max(o,.5),r).fill(f).stroke(v).cy(l).x(a);const p=o-Math.min(6,.375*this.styles.fontStyles.size),{bold:m=!1,italic:g=!1}=this.options,w=this.stackMode===u.RELATIVE&&null!==(s=this.options.label)&&void 0!==s?s:"share";if(p>0){const s=a+o/2;if(this.stackMode!==u.RELATIVE&&this.stackMode!==u.ABSOLUTE_RELATIVE||"value"===w)new vt(this.group,s,l,"STACK_SEG",h,this.styles,et.Center,et.Center).setSegmentFill(d).setEmphasis(m,g).setMaxWidth(p).setPoint(this.dataPoint.key).draw(t,i);else{const i="plain-share"===w?S.number(100*this.segment.share,"decimal",t.percent,t.percent,1,this.styles.locale):S.number(this.segment.share,"percent",t.percent,t.percent,1,this.styles.locale);new vt(this.group,s,l,"STACK_SEG",i,this.styles,et.Center,et.Center).setSegmentFill(d).setEmphasis(m,g).setMaxWidth(p).setPoint(this.dataPoint.key).draw()}}}drawTotalLabel(t={percent:2,decimal:1},i=new b,s){var h,e;if(this.stackMode===u.RELATIVE&&!this.options.total)return;const n=this.stack.total<0,r=this.position.getLabelPositionX((n?0-this.stack.negative:this.stack.positive)*this.dataPoint.pixelPerUnit),o=this.position.getBarPositionY(this.index,!0);new vt(this.group,r,o,"STACK_TOTAL",this.stack.total,this.styles,et.Center,n?et.Right:et.Left).setEmphasis(null!==(h=this.options.bold)&&void 0!==h&&h,null!==(e=this.options.italic)&&void 0!==e&&e).setPoint(s,"total").draw(t,i)}}class St{constructor(t,i,s,h,e){this.overflowConfig=null,this.i18n=e;const n=i.group().id("Scenario1"),r=i.group().id("Scenario2").insertBefore(n);this.svgGroups={parent:i,scenario1:n,scenario2:r,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=h}setOverflowConfig(t){this.overflowConfig=t}isLastDataPoint(t){return this.elementCnt-1===t}isFirsttDataPoint(t){return 0===t}createPrimaryBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new mt(this.position,this.styles,t,i,!0,r,a,this.overflowConfig).updateLabelGroup(o)}createVarianceBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new mt(this.position,this.styles,t,i,!0,r,a,this.overflowConfig).updateLabelGroup(o).setAsVariance()}createRelativeVarianceBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);return new bt(this.position,this.styles,t,i,r).updateLabelGroup(o)}createSecondaryBar(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario2)||void 0===h?void 0:h.group().id(""+i);let n=null;return this.isFirsttDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new mt(this.position,this.styles,t,i,!1,e,n,this.overflowConfig)}createPrimaryMarker(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario3)||void 0===h?void 0:h.group().id(""+i),n=this.styles.pattern.get("marker-down")||{foreground:"0,0 1,0 1,1 0,1",background:"0,0 1,0 1,1 0,1",bgOffset:0};let r=null;return this.isFirstDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new gt(this.position,e,n,t.scenario,this.styles,t,i,r,!0)}createSecondaryMarker(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario4)||void 0===h?void 0:h.group().id(""+i),n=this.styles.pattern.get("marker-up")||{foreground:"0,0 1,0 1,1 0,1",background:"0,0 1,0 1,1 0,1",bgOffset:0};let r=null;return this.isLastDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new gt(this.position,e,n,t.scenario,this.styles,t,i,r,!1)}isFirstDataPoint(t){return 0===t}}class Pt{constructor(t,i,s,h,e){this.dataModel=[],this.variancesDataModel=[],this.title="",this.configTitle="",this.configVariances=[],this.smallestDataPointValue=new ot(0,st.AC1,1,st.NEU),this.highestDataPointValue=new ot(0,st.AC1,1,st.NEU),this.smallestVarianceDataPointValue=new ot(0,st.AC1,1,st.NEU),this.highestVarianceDataPointValue=new ot(0,st.AC1,1,st.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.level=c.CATEGORY,this.hideCategories=!1,this.axisScenario=st.AC1,this.CSS_CATEGORIES="categories",this.state=tt.DIRTY,this.titleLength=0,this.leftSideOffsetForHorizontalSync=0,this.limit=0,this.measureScale=new b,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.scenarioPropOrder=[],this.overflowConfig=null,this.stackSides=O([]),this.stackLabelClearance={left:0,right:0},this.fromExpr="",this.rowCount=0,this.sums="none",this.sumTitle="",this.scenarioLabelTop=!1,this.hideScenarioName=!1,this.referenceLine=null,this.italicCategories=[],this.db=i,this.tableName=s,this.ruleSet=t||new D,this.i18n=this.createI18n(new Map),this.styles=e,this.setConfig(h),this.position=this.createElementPosition()}updatePosition(){this.position=this.createElementPosition()}createElementPosition(){this.titleLength=this.calculateTitleLength(0);let t=this.calculateLeftSideWidth(this.getVarianceType());const i=this.calculateCategoryWidth();return this.titleLength>t&&(t=this.titleLength),new Z(new Q(this.styles.padding),this.styles.scaleFactors,this.styles.fontStyles.size,this.dataModel.length,this.leftSideOffsetForHorizontalSync,this.titleLength,t,i,!!this.stackConfig&&0===this.variancesDataModel.length||this.scenarioLabelTop,this.rowLayout())}setStyles(t){this.styles=t}setRuleSet(t){this.ruleSet=t||new D}setConfig(t){var i,s;this.state=tt.DIRTY,this.scenarioPropOrder=[...t.scenarios];const h=this.sortScenariosbyVisualisationRules(t.scenarios);this.hideCategories=t.hideCategories||!1,this.limit=t.limit,this.pixelPerUnit=t.pixelPerUnit||1,this.pixelPerPercentage=t.pixelPerPercentage||100,this.setSource(t.filter),this.level=t.level,this.sums=t.sums,this.sumTitle=t.sumTitle,this.scenarioLabelTop=t.scenarioLabelTop,this.hideScenarioName=t.hideScenarioName,this.referenceLine=t.referenceLine,this.italicCategories=t.italicCategories,this.dataModel=this.populateModel(h,t.level,t.sortOrder),t.stackConfig&&t.stackConfig.by!==d.SCENARIOS&&this.populateDimensionStackSegments(h,t.stackConfig,t.level),this.addSumRows(h);for(const t of this.dataModel)for(const s of[t.scenario1,t.scenario2,t.scenario3,t.scenario4])null==s.value||Number.isNaN(s.value)||(s.key=Object.assign(Object.assign({},T(this.level,t.category)),{scenario:null!==(i=s.scenario)&&void 0!==i?i:void 0}));this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.configTitle=t.title,this.configVariances=null!==(s=null==t?void 0:t.variances)&&void 0!==s?s:[],this.updateTitle();const e=this.dataModel.filter((t=>!t.sum));this.smallestDataPointValue=this.findSmallestDataPointValue(e),this.smallestVarianceDataPointValue=this.findSmallestDataPointValue(this.variancesDataModel),this.highestDataPointValue=this.findHighestDataPointValue(e),this.highestVarianceDataPointValue=this.findHighestDataPointValue(this.variancesDataModel),this.axisScenario=this.setAxisScenario(t.variances),this.measureScale=t.measureScale,this.measureUnit=t.measureUnit,this.dataFormatDigits=t.dataFormatDigits,this.stackConfig=t.stackConfig,this.measureStacks(),this.updatePosition()}sortScenariosbyVisualisationRules(t){const i=this;return[...t].sort(((t,s)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(s))).reverse()}setI18n(t){this.i18n=this.createI18n(t),this.updateTitle()}updateTitle(){var t;this.title=this.configTitle||S.translateScenarioLabel(null===(t=this.configVariances)||void 0===t?void 0:t.toString(),this.i18n)}createI18n(t){this.state=tt.DIRTY;const i=new Map([["SEPARATOR_WS",", "],["in","in"],["ORDER_asc","↑"],["ORDER_desc","↓"],["ac1","AC"],["pp1","PY"],["fc1","FC"],["pl1","PL"],["ac2","AC2"],["pp2","PY2"],["fc2","FC2"],["pl2","PL2"],["ac3","AC3"],["pp3","PY3"],["fc3","FC3"],["pl3","PL3"],["ac4","AC4"],["pp4","PY4"],["fc4","FC4"],["pl4","PL4"],["category"," "],["operation"," "],["thereof","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"]]);return new Map([...i,...t])}setSource(t){var i,s;if(this.state=tt.DIRTY,this.queryError=void 0,this.fromExpr=G(this.db,this.tableName,t),this.fromExpr)try{const t=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(s=null===(i=t[0])||void 0===i?void 0:i.cnt)&&void 0!==s?s:0}catch(t){this.rowCount=0,this.failQuery(t)}else this.rowCount=0}getQueryError(){return this.queryError}failQuery(t){var i;null!==(i=this.queryError)&&void 0!==i||(this.queryError=z(t))}getUnitBarExtent(){var t,i,s,h;const e=this.isStacked(),n=this.getVarianceType(),r=n!==it.NONE,o=r?this.highestVarianceDataPointValue:this.highestDataPointValue,a=r?this.smallestVarianceDataPointValue:this.smallestDataPointValue;return A({fixedDomain:e?this.stackSides.positive+this.stackSides.negative:void 0,relativeVariance:n===it.RELATIVE,maxPositive:Math.max(null!==(t=null==o?void 0:o.value)&&void 0!==t?t:0,e||r?0:null!==(s=null===(i=this.referenceLine)||void 0===i?void 0:i.value)&&void 0!==s?s:0),minNegative:null!==(h=null==a?void 0:a.value)&&void 0!==h?h:0})}getPercentBarExtent(){var t,i,s,h;return E({relativeVariance:this.getVarianceType()===it.RELATIVE,maxPositive:null!==(i=null===(t=this.highestVarianceDataPointValue)||void 0===t?void 0:t.value)&&void 0!==i?i:0,minNegative:null!==(h=null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&void 0!==h?h:0})}getAllocatedCanvasWidth(){const t=this.position.getAxisPositionX(),i=this.calculateRightSideWidth(this.getVarianceType());let s=t+i+ +this.styles.padding.left+this.styles.padding.right;return i<this.titleLength/2&&(s+=this.titleLength/2),t<this.titleLength/2&&(s+=this.titleLength/2),s}getAllocatedCanvasHeight(){return this.position.getAxisEndPositionY()+this.position.spacings.labelToAxis+this.position.fontSize+(this.hasPercentMark()?.8*this.position.fontSize:0)+this.styles.padding.bottom}patternToString(){return"<svg></svg>"}layout(){this.draw(new n)}toString(){const t=new n;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.svg()}applyFontToContainer(t){t.attr({"font-size":this.styles.fontStyles.size,"font-family":this.styles.fontStyles.family})}draw(t){this.cleanSVGforRedraw(t),this.applyFontToContainer(t),this.state===tt.DIRTY&&(this.state=tt.UP_TO_DATE),this.variancesDataModel&&this.variancesDataModel.length>0?(this.drawVarianceScenario(this.variancesDataModel,t),this.drawAxisAndLabels(this.variancesDataModel,t)):null!=this.stackConfig?(this.drawStackedScenarios(this.dataModel,t),this.drawStackedHeaders(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t,!0),this.drawPercentMark(t)):(this.drawScenarios(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t)),0===this.variancesDataModel.length&&this.drawReferenceLine(t)}setPattern(t,i){this.styles.pattern.set(t,i)}calculateTitleLength(t){const i=P(this.title.length>7?this.title:"_______",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;return i<t?t:i/2}getFooter(){return 1===this.measureScale.value&&""===this.measureUnit?" ":S.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}scenarioStyles(){const t=j(this.styles.barStyles,this.ruleSet);return t===this.styles.barStyles?this.styles:Object.assign(Object.create(Object.getPrototypeOf(this.styles)),this.styles,{barStyles:t})}setAxisScenario(t){let i=st.AC1;if(null!=t&&t.length>0){const s=new y(t.toString());s.isValid&&(i=X(this.ruleSet.getScenarioColorIndex(s.delta))+s.delta.slice(2))}return null===i&&(i=st.AC1),i}populateModel(t,i,s){if(0===this.rowCount||!this.fromExpr)return[];const h=[],e=this.createOrderStr(i,s),n=this.createSelectString(i,s),r=this.createGroupByStr(i,s);let o;try{o=this.db.exec(`SELECT ${n} ${t.length>0?","+t.map((t=>`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`)).join(","):""}\n FROM ${this.fromExpr}\n GROUP BY ${r}\n ORDER BY ${e}`)}catch(t){return this.failQuery(t),[]}return this.detectNaNCells(t,o),this.createDataRows(this.limit>0?o.slice(0,this.limit):o,h,t),this.crateRESTRow(o,t,h),h}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new y(t);!0===s.isValid?0!==i[s.base+"_cnt"]&&0!==i[s.delta+"_cnt"]||(i[t]=Number.NaN):0===i[t+"_cnt"]&&(i[t]=Number.NaN)})),i)))}crateRESTRow(t,i,s){if(this.limit<=0||this.limit>=t.length)return;const h=[];this.createDataRows(t.slice(this.limit),h,i);const e=(t,i)=>Number.isFinite(i)?(Number.isFinite(t)?t:0)+i:t,n=h.reduce((function(t,s){return{id:t.id,category:t.category,type:t.type,scenario1:new ot(e(t.scenario1.value,s.scenario1.value),i[0],t.scenario1.pixelPerUnit,st.NEU),scenario2:new ot(e(t.scenario2.value,s.scenario2.value),i[1],t.scenario2.pixelPerUnit,st.NEU),scenario3:new ot(e(t.scenario3.value,s.scenario3.value),i[2],t.scenario3.pixelPerUnit,st.NEU),scenario4:new ot(e(t.scenario4.value,s.scenario4.value),i[3],t.scenario4.pixelPerUnit,st.NEU)}}),{id:9999,category:"REST",type:it.NONE,scenario1:new ot(NaN,i[0],this.pixelPerUnit,st.NEU),scenario2:new ot(NaN,i[1],this.pixelPerUnit,st.NEU),scenario3:new ot(NaN,i[2],this.pixelPerUnit,st.NEU),scenario4:new ot(NaN,i[3],this.pixelPerUnit,st.NEU)});s.push(n)}createDataRows(t,i,s){t.forEach(((t,h)=>{i.push({id:h,category:t.category,type:it.NONE,scenario1:new ot(t[s[0]],s[0],this.pixelPerUnit,st.NEU),scenario2:new ot(t[s[1]],s[1],this.pixelPerUnit,st.NEU),scenario3:new ot(t[s[2]],s[2],this.pixelPerUnit,st.NEU),scenario4:new ot(t[s[3]],s[3],this.pixelPerUnit,st.NEU)})}))}createOrderStr(t,i){let s=`${t.toLowerCase()}`;return i.hierarchy.length>=1&&(s=i.hierarchy.map((t=>`${t} ${i.direction}`)).toString()),s}createSelectString(t,i){return t===c.CATEGORY&&i.hierarchy.includes(m.CATEGORYINDEX)?`${m.CATEGORYINDEX}, ${c.CATEGORY} as category`:t===c.ROWGROUP&&i.hierarchy.includes(m.ROWGROUPINDEX)?`${m.ROWGROUPINDEX}, ${c.ROWGROUP} as category`:t===c.SUBCATEGORY&&i.hierarchy.includes(m.SUBCATEGORYINDEX)?`${m.SUBCATEGORYINDEX}, ${c.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===c.CATEGORY&&i.hierarchy.includes(m.CATEGORYINDEX)?`${m.CATEGORYINDEX}, ${c.CATEGORY}`:t===c.ROWGROUP&&i.hierarchy.includes(m.ROWGROUPINDEX)?`${m.ROWGROUPINDEX}, ${c.ROWGROUP}`:t===c.SUBCATEGORY&&i.hierarchy.includes(m.SUBCATEGORYINDEX)?`${m.SUBCATEGORYINDEX}, ${c.SUBCATEGORY}`:`${t.toString()}`}calculateCategoryWidth(){if(this.hideCategories)return 5;let t=0;for(const i of this.dataModel){const s=P(i.category,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"});s.width>t&&(t=s.width)}return 1.1125*t}findSmallestDataPointValue(t){let i=new ot(0,"default",this.pixelPerUnit,null);for(const s of t)for(const t of[s.scenario1,s.scenario2,s.scenario3,s.scenario4])null!=t&&null!=i.value&&t.value<i.value&&(i=t);return i}findHighestDataPointValue(t){let i=new ot(0,"default",this.pixelPerUnit,null);for(const s of t)for(const t of[s.scenario1,s.scenario2,s.scenario3,s.scenario4])null!=t&&null!=i.value&&t.value>i.value&&(i=t);return i}stackGroups(t){if(!this.stackConfig)return[];const i=this.stackConfig.by===d.SCENARIOS;let s=[];for(const h of i?["scenario1","scenario2","scenario3","scenario4"]:["scenario1"]){const i=t[h];i&&!i.isEmpty()&&null!=i.value&&s.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0===s.length)return[];const h=this.stackConfig.mode===u.RELATIVE?1:0,e=(t,i)=>({prefix:t,segments:i,layout:_(i.map((t=>t.value)),h),hasValue:i.some((t=>Number.isFinite(t.value)))});if(i){this.sortSegmentsByPropOrder(s);const t=new Map;for(const i of s){const s=L(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}if(t.size>1){const i=[];for(const s of M)t.has(s)&&(i.push(e(s,t.get(s))),t.delete(s));for(const[s,h]of t)i.push(e(s,h));return i}}else t.stackSegments&&t.stackSegments.length>0&&(s=t.stackSegments.map((t=>({value:t.value,scenario:t.label,dataPoint:t.dataPoint}))));const n=t=>Number.isFinite(t.value)?t.value:0;return"asc"===this.stackConfig.order?s.sort(((t,i)=>n(t)-n(i))):"desc"===this.stackConfig.order&&s.sort(((t,i)=>n(i)-n(t))),[e("",s)]}measureStacks(){const t=[];this.stackLabelClearance={left:0,right:0};for(const i of this.dataModel){const{flipped:s,clearance:h}=this.stackLabelPlace(i),e=this.drawnStackLayouts(i),n=s?"right":"left";this.stackLabelClearance[n]=Math.max(this.stackLabelClearance[n],h),t.push(...e)}this.stackSides=O(t)}stackLabelPlace(t){const i=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;return R(this.drawnStackLayouts(t),(t=>{var s;return(null===(s=this.stackConfig)||void 0===s?void 0:s.mode)===u.RELATIVE&&"value"!==this.stackConfig.labels?0:(i+this.calculateTotalLabelWidth(t.total))/this.pixelPerUnit}))}drawnStackLayouts(t){return this.isTextSum(t)?[]:this.stackGroups(t).filter((t=>t.hasValue)).map((t=>t.layout))}calculateTotalLabelWidth(t){const i=this.dataFormatDigits.decimal;return P(S.number(t,"decimal",i,i,this.measureScale.value,this.styles.locale),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width}isStacked(){return null!=this.stackConfig&&this.stackSides.positive+this.stackSides.negative>0}populateVarianceModel(t,i){const s=[];if(0===t.length)return s;let h=null;null!=i&&i.length>0&&(h=i[0]);for(const e in t){const n=new y(t[e]);if(n.isValid){const r=this.mapScenarios(n,h),o=n.direction;let a=this.pixelPerUnit;"dr"===n.type&&(a=this.pixelPerPercentage);for(const h in i){const l=new ot(this.calculateVariance(n,i[h],r),n.base,a,o);null===l.value||Number.isNaN(l.value)||(l.key=Object.assign(Object.assign({},T(this.level,i[h].category)),{scenario:t[e]})),s.push({id:Number(h),category:i[h].category,type:"dr"===n.type?it.RELATIVE:it.ABSOLUTE,scenario1:l,scenario2:new ot(null,null,null,null),scenario3:new ot(null,null,null,null),scenario4:new ot(null,null,null,null),sum:i[h].sum})}}}return s}calculateVariance(t,i,s){const h=s.get(t.base),e=s.get(t.delta);return null==h||null==e?null:t.type===it.RELATIVE?$(i[h].value-i[e].value,i[e].value):i[h].value-i[e].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((h=>{i[h].scenario===t.delta?s.set(t.delta,h):i[h].scenario===t.base&&s.set(t.base,h)})),s}calculateTextBoxWidth(t){return P(S.number(t,"decimal",1,0,1,this.styles.locale),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width}calculatePercentageTextBoxWidth(t){let i=0;const s=this.dataFormatDigits.percent,h=t=>S.number(t,"percent",s,s,1,this.styles.locale);return t>0&&h(t)!==h(0)&&(i+=P("+",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width),i+=P(" %",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,P(S.number(t,"decimal",1,1,1,this.styles.locale),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width+i+i}cleanSVGforRedraw(t){t.clear()}drawAxisAndLabels(t,i,s=!1){const h=i.group().id("AxisAndDateLables");let e=!1;this.hideCategories||t.forEach(((t,i)=>{var n;t.type===it.RELATIVE&&(e=!0);let r=et.Right,o=!0,a=0;if(s){const i=this.stackLabelPlace(t);o=!i.flipped,a=i.clearance*this.pixelPerUnit*(i.flipped?1:-1)}else t.scenario1.value<0&&!this.hasSumNumbers(this.dataModel[i])&&(o=!1);o||(r=et.Left),new vt(h,this.position.getCategoryPositionX(o)+a,this.position.getBarCenterPositionY(i),"",this.i18n.get(t.category)||t.category,this.styles,et.Center,r).setEmphasis(!!(null===(n=this.dataModel[i])||void 0===n?void 0:n.sum),this.isItalic(t.category)).draw()})),t.forEach(((t,i)=>{const s=this.dataModel[i];if(!(null==s?void 0:s.sum))return;const e=this.position.getBarCenterPositionY(i)-this.position.spacings.categoryWidth/2,n=this.hideCategories?this.position.getAxisPositionX():this.styles.padding.left;h.line(n,e,this.position.getAxisPositionX()+this.sumRowExtent(s),e).stroke({color:"#000000",width:Math.max(.5,this.position.spacings.axisLineWidth/2)}).addClass("sum-line")})),new pt({scenarioType:this.axisScenario,labelText:this.title,isRelative:e},this.position,h,this.styles).draw()}drawScenarios(t,i){const s=i.group().id("Scenarios");let h=-1;t.forEach(((t,i)=>{t.sum||(h=i)}));const e=new St(this.position,s,this.scenarioStyles(),this.scenarioLabelTop?0:h+1,this.i18n);e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.sum?this.drawSumValue(t,i,s):(e.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),e.createSecondaryBar(t.scenario2,i).draw(),e.createPrimaryMarker(t.scenario3,i).draw(),e.createSecondaryMarker(t.scenario4,i).draw())}));const n=t.find((t=>!t.sum));if(this.scenarioLabelTop&&n&&!n.scenario1.isEmpty()&&null!=n.scenario1.scenario){const t=n.scenario1.scenario;new vt(s,this.position.getBarPositionX()+this.position.spacings.labelToAxis,this.position.getStackedHeaderPositionY(),"SCENARIO_HEADER",this.i18n.get(t)||t,this.styles,et.Bottom,et.Left).draw()}}sumPoints(t){const i=[t.scenario1,t.scenario2,t.scenario3,t.scenario4].filter((t=>null!=t&&!t.isEmpty()&&Number.isFinite(t.value))),s=this.scenarioPropOrder,h=t=>{const i=s.indexOf(t.scenario);return-1===i?s.length:i};return i.sort(((t,i)=>h(t)-h(i)))}hasSumNumbers(t){return!!(null==t?void 0:t.sum)&&0===this.variancesDataModel.length&&!this.stackConfig&&this.sumPoints(t).length>1}sumValuesWidth(t){const i=this.styles.fontStyles.size,s=i*this.styles.scaleFactors.labelToBar,h=this.sumPoints(t);if(0===h.length)return 0;const e=h.map((t=>this.boldWidth(this.sumText(t.value))));return 1===h.length?s+e[0]:s+e.reduce(((t,s)=>t+.9*i+s),0)+(h.length-1)*i*1.4}drawSumValue(t,i,s){const h=this.sumPoints(t);if(0===h.length)return;const e=this.styles.fontStyles.size,n=this.position.getBarCenterPositionY(i),r=s.group().id(`sum_${i}`),o=(t,i,s)=>{new vt(r,i,n,`SUM_${t.scenario}`,t.value,this.styles,et.Center,s).setEmphasis(!0,!1).setPoint(t.key).draw(this.dataFormatDigits,this.measureScale)};if(1===h.length){const t=h[0].value<0;return void o(h[0],this.position.getLabelPositionX(t?-1e-6:0),t?et.Right:et.Left)}const a=.6*e,l=this.scenarioStyles().barStyles;let c=this.position.getLabelPositionX(0);for(const t of h){const i=l.getSVGStyle(t.getScenario());r.rect(a,a).fill({color:(null==i?void 0:i.fill)||"#000000"}).stroke({color:(null==i?void 0:i.stroke)||"#000000",width:1}).cy(n).x(c),o(t,c+a+.3*e,et.Left),c+=.9*e+this.boldWidth(this.sumText(t.value))+1.4*e}}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),h=new St(this.position,s,this.scenarioStyles(),t.length,this.i18n);return h.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{if(t.type===it.RELATIVE){const s=h.createRelativeVarianceBar(t.scenario1,i);t.sum&&s.emphasize(),s.draw(this.dataFormatDigits)}else{const s=h.createVarianceBar(t.scenario1,i);t.sum&&s.emphasize(),s.draw(this.dataFormatDigits,this.measureScale)}})),s}sortSegmentsByPropOrder(t){if(0===this.scenarioPropOrder.length)return;const i=this.scenarioPropOrder;t.sort(((t,s)=>{const h=i.indexOf(t.scenario),e=i.indexOf(s.scenario);return(-1===h?i.length:h)-(-1===e?i.length:e)}))}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),h=this.stackConfig.by===d.SCENARIOS,e=this.stackConfig.mode===u.RELATIVE&&"value"===this.stackConfig.labels,n=e?"value":this.stackConfig.percentMark?"plain-share":"share";t.forEach(((t,i)=>{const r=this.stackGroups(t);if(this.isTextSum(t))return void this.drawSumText(t,i,s);const o={label:n,total:e,bold:!!t.sum,italic:this.isItalic(t.category)};r.forEach(((e,n)=>{let a=null;e.segments.forEach(((t,l)=>{const c=new wt(this.position,this.styles,t.dataPoint,i,e.layout.segments[l],t.scenario,r.length>1?r.length-1-n:l,this.stackConfig.mode,e.layout,h,s,o);c.draw(this.dataFormatDigits,this.measureScale),a=c})),a&&e.hasValue&&a.drawTotalLabel(this.dataFormatDigits,this.measureScale,Object.assign(Object.assign({},T(this.level,t.category)),{scenario:r.length>1?e.prefix:void 0}))}))}))}drawStackedHeaders(t,i){var s;if(!this.stackConfig||0===t.length)return;const h=null!==(s=t.find((t=>!this.isTextSum(t))))&&void 0!==s?s:t[0];if(this.stackConfig.by!==d.SCENARIOS&&(!h.stackSegments||0===h.stackSegments.length))return;const e=this.stackGroups(h);if(0===e.length)return;const n=i.group().id("StackedHeaders"),r=this.position.getBarPositionX(),o=this.position.getStackedHeaderPositionY(),a=(t,i)=>{new vt(n,t,o,"STACK_HEADER",i,this.styles,et.Bottom,et.Center).draw()};if(e.length>1)return void e.forEach((t=>{a(r+(t.layout.positive-t.layout.negative)/2*t.segments[0].dataPoint.pixelPerUnit,this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase())}));const[l]=e;this.stackConfig.totalTitle&&(this.stackConfig.mode!==u.RELATIVE||"value"===this.stackConfig.labels)&&new vt(n,this.position.getLabelPositionX(l.layout.positive*this.pixelPerUnit),o,"STACK_TOTAL_HEADER",this.stackConfig.totalTitle,this.styles,et.Bottom,et.Left).draw(),l.segments.forEach(((t,i)=>{const{start:s,end:h}=l.layout.segments[i];a(r+(s+h)/2*t.dataPoint.pixelPerUnit,this.i18n.get(t.scenario)||t.scenario)}))}getVarianceType(){return this.variancesDataModel.length>0?this.variancesDataModel[0].type:it.NONE}calculateLeftSideWidth(t){var i,s,h;let e=0;const n=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(it.NONE===t&&this.isStacked())this.stackSides.negative>0&&(e=this.stackSides.negative*this.pixelPerUnit,this.stackSides.minTotal<0&&(e+=n+this.calculateTotalLabelWidth(this.stackSides.minTotal))),this.stackLabelClearance.left>0&&(e=Math.max(e,this.stackLabelClearance.left*this.pixelPerUnit+this.calculateCategoryWidth()));else if(it.NONE===t&&null!=(null===(i=this.smallestDataPointValue)||void 0===i?void 0:i.value)&&this.smallestDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestDataPointValue.value);e=Math.abs(this.smallestDataPointValue.getScaledUnit())+n+t}else if(it.RELATIVE===t&&null!=(null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculatePercentageTextBoxWidth(this.smallestVarianceDataPointValue.value);e=Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit())+n+t}else if(it.ABSOLUTE===t&&null!=(null===(h=this.smallestVarianceDataPointValue)||void 0===h?void 0:h.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value);e=Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())+n+t}return e<=this.titleLength?this.titleLength:e}calculateRightSideWidth(t){var i,s,h,e,n,r;if(this.isStacked()){const t=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar,e=this.calculateTextBoxWidth(this.stackSides.maxTotal);let n=this.stackSides.positive*this.pixelPerUnit+t+e;if(this.stackSides.minTotal<0&&(n=Math.max(n,this.stackLabelClearance.right*this.pixelPerUnit+this.position.getCategoryToAxisSpaceing()+this.calculateCategoryWidth())),null===(i=this.stackConfig)||void 0===i?void 0:i.totalTitle){const i=P(this.stackConfig.totalTitle,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;n=Math.max(n,this.stackSides.positive*this.pixelPerUnit+t+i)}return Math.max(n,this.titleLength,null!==(h=null===(s=this.sumColumns())||void 0===s?void 0:s.width)&&void 0!==h?h:0,this.referenceLineExtent())}let o=0;const a=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(it.NONE===t&&null!=(null===(e=this.highestDataPointValue)||void 0===e?void 0:e.value)&&this.highestDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestDataPointValue.value);o=Math.abs(this.highestDataPointValue.getScaledUnit())+a+t}else if(it.RELATIVE===t&&null!=(null===(n=this.highestVarianceDataPointValue)||void 0===n?void 0:n.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculatePercentageTextBoxWidth(this.highestVarianceDataPointValue.value);o=Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit())+a+t}else if(it.ABSOLUTE===t&&null!=(null===(r=this.highestVarianceDataPointValue)||void 0===r?void 0:r.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value);o=Math.abs(this.highestVarianceDataPointValue.getScaledUnit())+a+t}o=Math.max(o,this.referenceLineExtent());for(const i of this.dataModel)i.sum&&it.NONE===t&&(o=Math.max(o,this.sumRowExtent(i)));return o<=this.titleLength?this.titleLength:o}populateDimensionStackSegments(t,i,s){var h;if(0===this.rowCount||!this.fromExpr||0===t.length)return;const e={[c.ROWGROUP]:"category",[c.ROWGROUPINDEX]:"category",[c.CATEGORY]:"subCategory",[c.CATEGORYINDEX]:"subCategory"}[s];if(!e)return;const n=s.toString(),r=t[0];let o;try{o=this.db.exec(`SELECT [${n}] as displayGroup, [${e}] as stackLabel, MIN([${e}Index]) as stackIndex, SUM([${r}] * transformOperator(operation)) as stackValue FROM ${this.fromExpr} GROUP BY [${n}], [${e}]`)}catch(t){return void this.failQuery(t)}const a=new Map;for(const t of o){if(null==t.stackValue||null==t.stackLabel)continue;const i=t.stackLabel,s=Number.isFinite(Number(t.stackIndex))&&null!=t.stackIndex?Number(t.stackIndex):NaN,h=a.get(i);(void 0===h||Number.isNaN(h)&&!Number.isNaN(s)||s<h)&&a.set(i,s)}const l=[...a.keys()];[...a.values()].every((t=>!Number.isNaN(t)))&&l.sort(((t,i)=>a.get(t)-a.get(i)));const u=new Map;for(const t of o){const i=t.displayGroup;u.has(i)||u.set(i,new Map),null!=t.stackValue&&null!=t.stackLabel&&u.get(i).set(t.stackLabel,t.stackValue)}const d=new Set(this.dataModel.map((t=>t.category))),f=new Map;for(const[t,i]of u)if(!d.has(t))for(const[t,s]of i)f.set(t,(null!==(h=f.get(t))&&void 0!==h?h:0)+s);for(const t of this.dataModel){const i=9999!==t.id||u.has(t.category)?u.get(t.category):f,s=i&&i.size>0?l.map((t=>{var s;return{label:t,value:null!==(s=i.get(t))&&void 0!==s?s:NaN}})):void 0;t.stackSegments=s&&s.length>0?s.map((i=>{const s=new ot(i.value,r,this.pixelPerUnit,st.NEU);return s.key=Object.assign(Object.assign({},T(this.level,t.category)),{[e]:i.label,scenario:r}),{label:i.label,value:i.value,dataPoint:s}})):[]}}isTextSum(t){return!!t.sum&&!!this.stackConfig&&this.stackConfig.mode!==u.RELATIVE}isItalic(t){return this.italicCategories.includes(t)}hasPercentMark(){var t;return!!(null===(t=this.stackConfig)||void 0===t?void 0:t.percentMark)&&this.stackConfig.mode===u.RELATIVE&&0===this.variancesDataModel.length&&this.isStacked()}addSumRows(t){if("none"===this.sums||0===this.dataModel.length)return;const i=(t,i)=>Number.isFinite(i)?(Number.isFinite(t)?t:0)+i:t,s=(s,h,e)=>{var n,r;const o=(h,e)=>new ot(void 0===t[e]?void 0:s.reduce(((t,s)=>i(t,s[h].value)),NaN),t[e],this.pixelPerUnit,st.NEU),a={id:1e4+this.dataModel.length,category:h,type:it.NONE,scenario1:o("scenario1",0),scenario2:o("scenario2",1),scenario3:o("scenario3",2),scenario4:o("scenario4",3),sum:e};if(s.some((t=>t.stackSegments))){const h=new Map;for(const t of s)for(const s of null!==(n=t.stackSegments)&&void 0!==n?n:[])h.set(s.label,i(null!==(r=h.get(s.label))&&void 0!==r?r:NaN,s.value));a.stackSegments=[...h].map((([i,s])=>({label:i,value:s,dataPoint:new ot(s,t[0],this.pixelPerUnit,st.NEU)})))}return a},h=this.dataModel,e=[],n="total"===this.sums?new Map:this.rowGroups();if(n.size>0){const t=[...new Set([...n.values()].sort(((t,i)=>t.index-i.index)).map((t=>t.name)))];for(const i of t){const t=h.filter((t=>{var s;return(null===(s=n.get(t.category))||void 0===s?void 0:s.name)===i}));if(0===t.length)continue;const r=s(t,i,"group");r.gapAfter=!0,e.push(...t,r)}e.push(...h.filter((t=>!n.has(t.category))))}else e.push(...h);"total"!==this.sums&&"all"!==this.sums||e.push(s(h,this.sumTitle||"SUM_TOTAL","total")),this.dataModel=e}rowGroups(){const t=new Map;if(this.level!==c.CATEGORY&&this.level!==c.CATEGORYINDEX)return t;let i;try{i=this.db.exec(`SELECT [category] as category, [rowGroup] as rowGroup, MIN([rowGroupIndex]) as rowGroupIndex FROM ${this.fromExpr} GROUP BY [category], [rowGroup]`)}catch(i){return this.failQuery(i),t}const s=new Map;return i.forEach(((i,h)=>{var e;if(null==i.rowGroup||""===i.rowGroup)return;const n=String(i.rowGroup),r=Number(i.rowGroupIndex),o=null!=i.rowGroupIndex&&Number.isFinite(r)?r:null!==(e=s.get(n))&&void 0!==e?e:h;s.has(n)||s.set(n,o),t.set(String(i.category),{name:n,index:Math.min(o,s.get(n))})})),t}rowLayout(){var t;const i=this.dataModel,s="total"===(null===(t=this.stackConfig)||void 0===t?void 0:t.thickness),h=i.reduce(((t,i,s)=>i.sum?t:s),-1),e=!this.stackConfig&&!this.scenarioLabelTop&&!this.hideScenarioName&&h>=0&&h<i.length-1;if(!s&&!e&&!i.some((t=>t.gapAfter)))return null;const n=i.map((t=>{if(!s||t.sum)return null;const i=this.stackGroups(t),h=i[i.length-1];return h?Math.abs(h.layout.total):0})),r=this.rowWeights(n),o=[],a=[];let l=0;return i.forEach(((t,s)=>{const n=r[s];o.push(l),a.push(n),l+=n+(t.gapAfter&&s<i.length-1?.5:0)+(e&&s===h?1:0)})),{start:o,weight:a,total:l,nameBelowBar:e}}rowWeights(t){const i=Math.min(1,1/this.styles.scaleFactors.categoryWidth),s=t.map((t=>null===t?1:0)),h=new Set(t.flatMap(((t,i)=>null===t?[]:[i])));let e=h.size;for(;;){const n=[...h].reduce(((i,s)=>i+t[s]),0);if(n<=0){h.forEach((t=>s[t]=e/h.size));break}const r=[...h].filter((s=>t[s]/n*e<i));if(0===r.length||r.length===h.size){h.forEach((i=>s[i]=t[i]/n*e));break}for(const t of r)s[t]=i,e-=i,h.delete(t)}return s}boldWidth(t){return P(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:"bold"}).width}sumText(t){const i=this.dataFormatDigits.decimal;return S.number(t,"decimal",i,i,this.measureScale.value,this.styles.locale)}sumColumns(){const t=this.dataModel.filter((t=>this.isTextSum(t)));if(0===t.length)return null;const i=this.styles.fontStyles.size,s=.6*i,h=.3*i,e=1.4*i,n=[];let r=0;for(const i of t){const t=this.stackGroups(i),s=t[t.length-1];s&&(s.segments.forEach(((t,i)=>{var s;const h=Number.isFinite(t.value)?this.boldWidth(this.sumText(t.value)):0;n[i]=Math.max(null!==(s=n[i])&&void 0!==s?s:0,h)})),r=Math.max(r,this.boldWidth(this.sumText(s.layout.total))))}const o=[];let a=.3*i;for(const t of n.length>1?n:[])o.push(a),a+=s+h+t+e;return{x:o,totalX:a,width:a+r,key:s,keyGap:h}}drawSumText(t,i,s){const h=this.sumColumns(),e=this.stackGroups(t),n=e[e.length-1];if(!h||!n)return;const r=this.position.getBarPositionX(),o=this.position.getBarCenterPositionY(i),a=this.styles.stackColors,l=s.group().id(`stacked_sum_${i}`);n.segments.forEach(((t,i)=>{if(!Number.isFinite(t.value)||void 0===h.x[i])return;const s=r+h.x[i];l.rect(h.key,h.key).fill({color:a[i%a.length]}).cy(o).x(s),new vt(l,s+h.key+h.keyGap,o,`SUM_SEG_${i}`,t.value,this.styles,et.Center,et.Left).setEmphasis(!0,!1).setPoint(t.dataPoint.key).draw(this.dataFormatDigits,this.measureScale)})),new vt(l,r+h.totalX,o,"SUM_TOTAL",n.layout.total,this.styles,et.Center,et.Left).setEmphasis(!0,!1).setPoint(T(this.level,t.category),"total").draw(this.dataFormatDigits,this.measureScale)}sumRowExtent(t){var i,s,h;const e=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(this.variancesDataModel.length>0)return 0;if(this.isTextSum(t))return null!==(s=null===(i=this.sumColumns())||void 0===i?void 0:i.width)&&void 0!==s?s:0;if(this.stackConfig){const i="value"===this.stackConfig.labels?e+this.boldWidth(this.sumText(null!==(h=t.scenario1.value)&&void 0!==h?h:0)):0;return this.stackSides.positive*this.pixelPerUnit+i}return this.sumValuesWidth(t)}referenceLineOffset(){var t;const i=this.referenceLine;return!i||!Number.isFinite(i.value)||this.variancesDataModel.length>0?null:((null===(t=this.stackConfig)||void 0===t?void 0:t.mode)===u.RELATIVE?i.value/100:i.value)*this.pixelPerUnit}referenceLineExtent(){var t;const i=this.referenceLineOffset();if(null===i||i<=0)return 0;const s=(null===(t=this.referenceLine)||void 0===t?void 0:t.label)?P(this.referenceLine.label,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width:0;return i+Math.max(s/2,.25*this.styles.fontStyles.size)}drawPercentMark(t){if(!this.hasPercentMark())return;const i=t.group().id("PercentMark"),s=this.styles.fontStyles.size,h=this.position.getBarPositionX()+this.stackSides.positive*this.pixelPerUnit,e=this.position.getAxisPositionY(),n=this.position.getAxisEndPositionY(),r=n+.15*s,o=r+.5*s;i.line(h,e,h,n).stroke({color:"#000000",width:this.position.spacings.axisLineWidth}),i.polygon(`${h},${r} ${h-.25*s},${o} ${h+.25*s},${o}`).fill("#000000"),new vt(i,h,o+.1*s,"PERCENT_MARK","100%",this.styles,et.Top,et.Center).setEmphasis(!0,!1).draw()}drawReferenceLine(t){const i=this.referenceLine,s=this.referenceLineOffset();if(!i||null===s||0===this.dataModel.length)return;const h=t.group().id("ReferenceLine"),e=this.styles.fontStyles.size,n=`var(--bn-annotation-color, ${V["bn-annotation"].color})`,r=this.position.getBarPositionX()+s,o=this.position.getStackedHeaderPositionY()-(this.stackConfig||this.scenarioLabelTop?1.1*e:0),a=t=>{var s,h;if(t.sum)return!1;if(!this.stackConfig)return(null!==(s=t.scenario1.value)&&void 0!==s?s:0)>=i.value;const e=null===(h=this.stackGroups(t)[0])||void 0===h?void 0:h.layout.segments[0];return null!=e&&e.end*this.pixelPerUnit>=r-this.position.getBarPositionX()};let l=this.dataModel.findIndex((t=>!a(t)))-1;l<0&&(l=this.dataModel.reduce(((t,i,s)=>i.sum?t:s),0));const c=this.position.getBarCenterPositionY(l)+this.position.getBarWidthAt(l)/2;h.line(r,o,r,c).attr("style",`stroke: ${n}; stroke-width: ${Math.max(1,this.position.spacings.axisLineWidth)}px`),h.polygon(`${r},${o+.5*e} ${r-.25*e},${o} ${r+.25*e},${o}`).attr("style",`fill: ${n}`),i.label&&h.plain(i.label).attr({x:r,y:o-.3*e,"text-anchor":"middle"}).attr("style",`fill: ${n}`)}hasNoData(){return 0===this.dataModel.length}setAvailableWidth(t){if(this.pixelPerUnit<=0||t<=0)this.overflowConfig=null;else if(null==this.stackConfig){if(this.overflowConfig=this.calculateOverflowConfig(t),this.overflowConfig){const{cutWidth:t,overdriveZoneWidth:i,breakGap:s}=this.overflowConfig,h=t+i+s;this.variancesDataModel&&this.variancesDataModel.length>0?(this.highestVarianceDataPointValue.getScaledUnit()>t&&(this.highestVarianceDataPointValue=new ot(h,this.highestVarianceDataPointValue.scenario,1,this.highestVarianceDataPointValue.variance)),null!=this.smallestVarianceDataPointValue.value&&Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())>t&&(this.smallestVarianceDataPointValue=new ot(-h,this.smallestVarianceDataPointValue.scenario,1,this.smallestVarianceDataPointValue.variance))):(this.highestDataPointValue.getScaledUnit()>t&&(this.highestDataPointValue=new ot(h,this.highestDataPointValue.scenario,1,this.highestDataPointValue.variance)),null!=this.smallestDataPointValue.value&&Math.abs(this.smallestDataPointValue.getScaledUnit())>t&&(this.smallestDataPointValue=new ot(-h,this.smallestDataPointValue.scenario,1,this.smallestDataPointValue.variance))),this.updatePosition()}}else this.overflowConfig=null}calculateOverflowConfig(t){const i=this.variancesDataModel&&this.variancesDataModel.length>0;if(this.getVarianceType()===it.RELATIVE)return null;const s=i?this.highestVarianceDataPointValue:this.highestDataPointValue,h=i?this.smallestVarianceDataPointValue:this.smallestDataPointValue,e=s.getScaledUnit(),n=null!=h.value?Math.abs(h.getScaledUnit()):0,r=Math.max(e,n);if(r<=0)return null;const o=this.styles.fontStyles.size,a=o*this.styles.scaleFactors.labelToBar,l=1.5*o,c=.3*o,u=.8*o,d=t-this.position.getAxisPositionX()-this.styles.padding.left-this.styles.padding.right-a-this.calculateTextBoxWidth(s.value||0)-l-c;if(d<=u)return null;const f=d-u;return r<=f?null:{cutWidth:d,overdriveZoneWidth:l,breakGap:c,maxOverflow:r-f,scenarioCutOffset:u}}}const yt=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.chartTitle="",this.scenarios=[],this.variances=[],this.hideCategories=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.i18n=new Map,this.order={hierarchy:[],direction:g.ASC},this.level=c.CATEGORY,this.filter="",this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.sums="none",this.sumTitle="",this.scenarioLabelTop=!1,this.hideScenarioName=!1,this.referenceLine=null,this.italicCategories=[],this.parentDimensions={width:0,height:0},U(this)}getDb(){return this.stores||(this.stores=Y(this.element)),this.stores.db.db}render(){var t,i,e,n;if(void 0===this.chart||void 0!==this.queryError)return s(h,null);if(this.chart.hasNoData()){const i=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return s(h,{class:"no-data"},s("div",{class:"empty-state"},i))}return s(h,null,s("div",{innerHTML:null===(i=this.pattern)||void 0===i?void 0:i.toString(),class:"hidePatternContainer",style:{width:"0",height:"0",overflow:"hidden"}}),s("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(e=this.chart)||void 0===e?void 0:e.getFooter()),s("div",{innerHTML:null===(n=this.chart)||void 0===n?void 0:n.toString()}))}syncQueryError(){var t,i;this.queryError=null!==(t=this.measureScaleError)&&void 0!==t?t:null===(i=this.chart)||void 0===i?void 0:i.getQueryError(),H(this.errors,this.queryError)}async componentWillLoad(){var t;const i=this.getDb(),s=this.prepareConfig(),h=this.prepareStyle();this.chart=new Pt(new D(this.ruleSetConfig),i,this.tableName,s,h),this.chart.setI18n(this.i18n);const e=s.pixelPerUnit<=0;this.autoFitScaling(s,h),this.chart.setAvailableWidth(e?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new J(this.chart.styles),this.chart.setPattern("hatched",this.pattern.getFCPolygonPattern()),this.syncQueryError()}async componentWillUpdate(){var t;if(null==this.chart)return;const i=this.prepareConfig(),s=this.prepareStyle();this.chart.setI18n(this.i18n),this.chart.setStyles(s),this.chart.setRuleSet(new D(this.ruleSetConfig)),this.chart.setConfig(i);const h=i.pixelPerUnit<=0;this.autoFitScaling(i,s),this.chart.setAvailableWidth(h?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new J(this.chart.styles),this.chart.setPattern("hatched",this.pattern.getFCPolygonPattern()),this.syncQueryError()}autoFitScaling(t,i){var s;const h=t.pixelPerUnit<=0,e=t.pixelPerPercentage<=0;if(!h&&!e)return;const n=()=>{var i;null===(i=this.reportAutoScaling)||void 0===i||i.call(this,{unit:h?t.pixelPerUnit:void 0,percentage:e?t.pixelPerPercentage:void 0})},r=null===(s=this.parentDimensions)||void 0===s?void 0:s.width,o=this.getDb(),a=()=>{this.chart=new Pt(new D(this.ruleSetConfig),o,this.tableName,t,i),this.chart.setI18n(this.i18n)},l=()=>(this.chart.layout(),this.chart.getAllocatedCanvasWidth());if(!r||r<=0)return h&&(t.pixelPerUnit=1),e&&(t.pixelPerPercentage=50),a(),void n();h&&(t.pixelPerUnit=1),e&&(t.pixelPerPercentage=1),a();let c=l();if(c<=0)return void n();const u=Math.max(B,.9*r/c);let d=!1,f=!1,v=null;for(let i=0;i<=3;i++){const i=W({target:r,measured:c,unitExtent:h?this.chart.getUnitBarExtent():0,pctExtent:e?this.chart.getPercentBarExtent():0,currentPpu:t.pixelPerUnit,currentPpp:t.pixelPerPercentage});if(void 0===i.ppu&&void 0===i.ppp)break;if(h&&void 0!==i.ppu&&(t.pixelPerUnit=i.ppu,d=!0),e&&void 0!==i.ppp&&(t.pixelPerPercentage=i.ppp,f=!0),a(),c=l(),c<=r+.5&&(v={ppu:t.pixelPerUnit,ppp:t.pixelPerPercentage},c>=.98*r))break}let p=!1;if(h&&!d&&(t.pixelPerUnit=u,p=!0),e&&!f&&(t.pixelPerPercentage=u,p=!0),c>r+.5){if(v)d&&(t.pixelPerUnit=v.ppu),f&&(t.pixelPerPercentage=v.ppp);else{const i=r/c;h&&(t.pixelPerUnit=Math.max(B,t.pixelPerUnit*i)),e&&(t.pixelPerPercentage=Math.max(B,t.pixelPerPercentage*i))}p=!0}p&&a(),n()}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){const t=this.getDb(),i=G(t,this.tableName,this.filter);return this.measureScaleError=void 0,new rt(new lt,new p(new F),new F,new v,t,i,(t=>{this.measureScaleError=z(t)})).adapt({scenarios:this.scenarios,variances:this.variances,title:this.chartTitle,hideCategories:this.hideCategories,pixelPerUnit:this.pixelPerUnit,pixelPerPercentage:this.pixelPerPercentage,level:this.level,limit:this.limit,sortOrder:this.order,filter:this.filter,measureScale:this.measureScale,measureUnit:this.measureUnit,showMeasureScale:this.showMeasureScale,dataFormatDigits:this.dataFormatDigits,stackConfig:this.stackConfig,sums:this.sums,sumTitle:this.sumTitle,scenarioLabelTop:this.scenarioLabelTop,hideScenarioName:this.hideScenarioName,referenceLine:this.referenceLine,italicCategories:this.italicCategories})}prepareStyle(){var t,i;const s=new ut(new ft,new r,new o(new N),new I(new N),new a).adapt(this.styles);return s.locale=(null===(i=null===(t=Y(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}get element(){return this}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-renderer",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],chartTitle:[1,"chart-title"],scenarios:[16],variances:[16],hideCategories:[4,"hide-categories"],pixelPerUnit:[2,"pixel-per-unit"],pixelPerPercentage:[2,"pixel-per-percentage"],reportAutoScaling:[16],errors:[16],limit:[2],styles:[1040],i18n:[1040],order:[16],level:[1],filter:[1],measureScale:[1,"measure-scale"],measureUnit:[1,"measure-unit"],showMeasureScale:[4,"show-measure-scale"],dataFormatDigits:[16],stackConfig:[16],sums:[1],sumTitle:[1,"sum-title"],scenarioLabelTop:[4,"scenario-label-top"],hideScenarioName:[4,"hide-scenario-name"],referenceLine:[16],italicCategories:[16],parentDimensions:[16],ruleSetConfig:[16]}]);function xt(){"undefined"!=typeof customElements&&["bn-chart-structure-renderer"].forEach((t=>{"bn-chart-structure-renderer"===t&&(customElements.get(e(t))||customElements.define(e(t),yt))}))}export{yt as B,xt as d}
|
|
@@ -15584,6 +15584,7 @@ const Chart$1 = class Chart {
|
|
|
15584
15584
|
}
|
|
15585
15585
|
catch (_a) {
|
|
15586
15586
|
this.errors.remove("WARN_stack_dimensions_scenarios");
|
|
15587
|
+
this.errors.remove("WARN_stack_thickness_variances");
|
|
15587
15588
|
return null;
|
|
15588
15589
|
}
|
|
15589
15590
|
}
|
|
@@ -15661,7 +15662,7 @@ const Chart$1 = class Chart {
|
|
|
15661
15662
|
const scenarios = this.hidesScenarios() ? variancesScenarios([localScenarioString]) : this.prepareScenarios();
|
|
15662
15663
|
// Dimension stacking uses only the first scenario. Only the base chart draws a stack, a variance needs both of its scenarios
|
|
15663
15664
|
const effectiveScenarios = isBase && (stackConfig === null || stackConfig === void 0 ? void 0 : stackConfig.by) === StackBy.DIMENSIONS ? scenarios.slice(0, 1) : scenarios;
|
|
15664
|
-
return (h("bn-chart-structure-renderer", { 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, 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(idx), stackConfig: stackConfig, sums: ["groups", "total", "all"].includes(this.sums) ? this.sums : "none", sumTitle: this.sumTitle, scenarioLabelTop: this.scenarioLabelPosition === "top", referenceLine: isBase ? this.prepareReferenceLine() : null, italicCategories: (_a = this.prepareItalicCategories()) !== null && _a !== void 0 ? _a : [], dataFormatDigits: { percent: this.dataFormatDigitsPercent, decimal: this.dataFormatDigitsDecimal }, parentDimensions: this.prepareDimension(), ruleSetConfig: this.ruleSetConfig() }));
|
|
15665
|
+
return (h("bn-chart-structure-renderer", { 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, 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(idx), stackConfig: stackConfig, sums: ["groups", "total", "all"].includes(this.sums) ? this.sums : "none", sumTitle: this.sumTitle, scenarioLabelTop: this.scenarioLabelPosition === "top", hideScenarioName: this.hidesScenarios(), referenceLine: isBase ? this.prepareReferenceLine() : null, italicCategories: (_a = this.prepareItalicCategories()) !== null && _a !== void 0 ? _a : [], dataFormatDigits: { percent: this.dataFormatDigitsPercent, decimal: this.dataFormatDigitsDecimal }, parentDimensions: this.prepareDimension(), ruleSetConfig: this.ruleSetConfig() }));
|
|
15665
15666
|
}
|
|
15666
15667
|
/**
|
|
15667
15668
|
* The line this chart wants to be aligned on, in CSS px from the host's
|
|
@@ -15791,7 +15792,7 @@ const Chart$1 = class Chart {
|
|
|
15791
15792
|
this.errors.remove("WARN_scenarios_none");
|
|
15792
15793
|
}
|
|
15793
15794
|
const fontStyles = this.getFontStyles();
|
|
15794
|
-
return (h(Host, { key: '
|
|
15795
|
+
return (h(Host, { key: '02236359d67ec2095ac560152cc6feaa8661834a', style: fontStyles }, h("div", { key: '5eb4e74f27fb0c4c5ffd286ee266ceb51eae68bf', class: "container" }, scenariosArray.map(this.chartTemplate))));
|
|
15795
15796
|
}
|
|
15796
15797
|
get element() { return getElement(this); }
|
|
15797
15798
|
static get watchers() { return {
|
|
@@ -15917,6 +15918,11 @@ let ElementPositions$1 = class ElementPositions {
|
|
|
15917
15918
|
}
|
|
15918
15919
|
return this.categoryPosition.y + this.spacings.scenarioOffset + index * this.spacings.categoryWidth;
|
|
15919
15920
|
}
|
|
15921
|
+
/** A sum row follows the last bar, so the name of the scenario stands right below that bar. */
|
|
15922
|
+
isNameBelowBar() {
|
|
15923
|
+
var _a;
|
|
15924
|
+
return !!((_a = this.rows) === null || _a === void 0 ? void 0 : _a.nameBelowBar);
|
|
15925
|
+
}
|
|
15920
15926
|
/** Upper edge of the room of a row. */
|
|
15921
15927
|
getRowTopPositionY(index) {
|
|
15922
15928
|
const start = this.rows && index < this.rows.start.length ? this.rows.start[index] : index;
|
|
@@ -16403,6 +16409,8 @@ class StructureChartComponentConfig {
|
|
|
16403
16409
|
this.sumTitle = "";
|
|
16404
16410
|
/** The name of the scenario stands above the first bar and not below the last one. */
|
|
16405
16411
|
this.scenarioLabelTop = false;
|
|
16412
|
+
/** No chart draws the name of the scenario: the component shows variances only. */
|
|
16413
|
+
this.hideScenarioName = false;
|
|
16406
16414
|
this.referenceLine = null;
|
|
16407
16415
|
/** Values of the level column whose row is printed in italics. */
|
|
16408
16416
|
this.italicCategories = [];
|
|
@@ -16478,6 +16486,9 @@ class StructureChartComponentConfigAdapter {
|
|
|
16478
16486
|
if (CompareUtil.isBoolean(data.scenarioLabelTop)) {
|
|
16479
16487
|
config.scenarioLabelTop = data.scenarioLabelTop;
|
|
16480
16488
|
}
|
|
16489
|
+
if (CompareUtil.isBoolean(data.hideScenarioName)) {
|
|
16490
|
+
config.hideScenarioName = data.hideScenarioName;
|
|
16491
|
+
}
|
|
16481
16492
|
if (CompareUtil.isExisting(data.referenceLine)) {
|
|
16482
16493
|
config.referenceLine = data.referenceLine;
|
|
16483
16494
|
}
|
|
@@ -17015,7 +17026,6 @@ class Label {
|
|
|
17015
17026
|
let valueStr;
|
|
17016
17027
|
const background = this.styles.fontStyles.background || "#ffffff";
|
|
17017
17028
|
let prefix = "";
|
|
17018
|
-
let labelAnchor = "start";
|
|
17019
17029
|
if (Number.isNaN(Number(this.value)) === false) {
|
|
17020
17030
|
let digits = dataFormatDigits.percent;
|
|
17021
17031
|
let digitsMin = dataFormatDigits.percent;
|
|
@@ -17029,9 +17039,6 @@ class Label {
|
|
|
17029
17039
|
type = "decimal";
|
|
17030
17040
|
}
|
|
17031
17041
|
valueStr = Formatter.number(Number(value), type, digits, digitsMin, scale, this.styles.locale);
|
|
17032
|
-
if (Number(this.value) < 0) {
|
|
17033
|
-
labelAnchor = "end";
|
|
17034
|
-
}
|
|
17035
17042
|
// a value that rounds to zero prints without a sign
|
|
17036
17043
|
const zeroStr = Formatter.number(0, type, digits, digitsMin, scale, this.styles.locale);
|
|
17037
17044
|
if (this.isVarianceLabel && Number(this.value) > 0 && valueStr !== zeroStr) {
|
|
@@ -17040,7 +17047,6 @@ class Label {
|
|
|
17040
17047
|
}
|
|
17041
17048
|
else {
|
|
17042
17049
|
valueStr = "" + this.value;
|
|
17043
|
-
labelAnchor = "start";
|
|
17044
17050
|
}
|
|
17045
17051
|
// @ts-ignore
|
|
17046
17052
|
const text = label.text(prefix + valueStr);
|
|
@@ -17059,6 +17065,8 @@ class Label {
|
|
|
17059
17065
|
this.group = null;
|
|
17060
17066
|
return this;
|
|
17061
17067
|
}
|
|
17068
|
+
// the hook says where the text is anchored: at its right, its middle or its left
|
|
17069
|
+
let labelAnchor = "start";
|
|
17062
17070
|
if (this.horizontalHookLocation === HookLocation.Right) {
|
|
17063
17071
|
labelAnchor = "end";
|
|
17064
17072
|
text.move(text.x() - text.length(), text.y());
|
|
@@ -17417,9 +17425,19 @@ class Bar {
|
|
|
17417
17425
|
}
|
|
17418
17426
|
drawScenarioLabel() {
|
|
17419
17427
|
if (this.scenarioLabel != null && !this.scenarioLabel.isEmpty() && !this.isVarianceBar) {
|
|
17420
|
-
this.
|
|
17428
|
+
let x = this.dimensions.scenarioLabelXPos;
|
|
17429
|
+
if (this.nameBesideAxis()) {
|
|
17430
|
+
// a short bar would put the name on the axis line, which runs on to the sum row
|
|
17431
|
+
const side = this.dataPoint.getScaledUnit() < 0 ? -1 : 1;
|
|
17432
|
+
x = this.position.getBarPositionX() + side * this.position.spacings.labelToAxis;
|
|
17433
|
+
}
|
|
17434
|
+
this.scenarioLabel.setPos(x, this.dimensions.scenarioLabelYPos).draw();
|
|
17421
17435
|
}
|
|
17422
17436
|
}
|
|
17437
|
+
/** The name of the scenario starts at the axis and is not centred on the bar. */
|
|
17438
|
+
nameBesideAxis() {
|
|
17439
|
+
return this.isPrimaryBar && this.position.isNameBelowBar();
|
|
17440
|
+
}
|
|
17423
17441
|
drawBarDataLabel(dataFormatDigits, measureScale = new SiPrefix()) {
|
|
17424
17442
|
var _a;
|
|
17425
17443
|
if (this.isPrimaryBar) {
|
|
@@ -17431,7 +17449,11 @@ class Bar {
|
|
|
17431
17449
|
}
|
|
17432
17450
|
getScenarioLabel(barLabel) {
|
|
17433
17451
|
if (this.isPrimaryBar) {
|
|
17434
|
-
|
|
17452
|
+
let hook = HookLocation.Center;
|
|
17453
|
+
if (this.nameBesideAxis()) {
|
|
17454
|
+
hook = this.dataPoint.getScaledUnit() < 0 ? HookLocation.Right : HookLocation.Left;
|
|
17455
|
+
}
|
|
17456
|
+
return new Label(this.scenarioGroup, -1, -1, this.ID_SCENARIO_PREFIX, barLabel, this.styles, HookLocation.Top, hook);
|
|
17435
17457
|
}
|
|
17436
17458
|
return new Label(this.scenarioGroup, -1, -1, this.ID_SCENARIO_PREFIX, barLabel, this.styles, HookLocation.Bottom, HookLocation.Center);
|
|
17437
17459
|
}
|
|
@@ -18128,6 +18150,7 @@ class StructureChart {
|
|
|
18128
18150
|
this.sums = "none";
|
|
18129
18151
|
this.sumTitle = "";
|
|
18130
18152
|
this.scenarioLabelTop = false;
|
|
18153
|
+
this.hideScenarioName = false;
|
|
18131
18154
|
this.referenceLine = null;
|
|
18132
18155
|
this.italicCategories = [];
|
|
18133
18156
|
this.db = db;
|
|
@@ -18170,6 +18193,7 @@ class StructureChart {
|
|
|
18170
18193
|
this.sums = config.sums;
|
|
18171
18194
|
this.sumTitle = config.sumTitle;
|
|
18172
18195
|
this.scenarioLabelTop = config.scenarioLabelTop;
|
|
18196
|
+
this.hideScenarioName = config.hideScenarioName;
|
|
18173
18197
|
this.referenceLine = config.referenceLine;
|
|
18174
18198
|
this.italicCategories = config.italicCategories;
|
|
18175
18199
|
this.dataModel = this.populateModel(scenarios, config.level, config.sortOrder);
|
|
@@ -18874,7 +18898,7 @@ class StructureChart {
|
|
|
18874
18898
|
isPositive = !side.flipped;
|
|
18875
18899
|
clearance = side.clearance * this.pixelPerUnit * (side.flipped ? 1 : -1);
|
|
18876
18900
|
}
|
|
18877
|
-
else if (elements["scenario1"].value < 0) {
|
|
18901
|
+
else if (elements["scenario1"].value < 0 && !this.hasSumNumbers(this.dataModel[index])) {
|
|
18878
18902
|
isPositive = false;
|
|
18879
18903
|
}
|
|
18880
18904
|
if (!isPositive) {
|
|
@@ -18946,6 +18970,10 @@ class StructureChart {
|
|
|
18946
18970
|
};
|
|
18947
18971
|
return points.sort((a, b) => place(a) - place(b));
|
|
18948
18972
|
}
|
|
18973
|
+
/** A sum row of the base chart that prints several numbers right of the axis: its title stays left of it. */
|
|
18974
|
+
hasSumNumbers(row) {
|
|
18975
|
+
return !!(row === null || row === void 0 ? void 0 : row.sum) && this.variancesDataModel.length === 0 && !this.stackConfig && this.sumPoints(row).length > 1;
|
|
18976
|
+
}
|
|
18949
18977
|
/** How wide the numbers of a sum row of a chart with plain bars are, from the axis on. */
|
|
18950
18978
|
sumValuesWidth(row) {
|
|
18951
18979
|
const font = this.styles.fontStyles.size;
|
|
@@ -19413,7 +19441,11 @@ class StructureChart {
|
|
|
19413
19441
|
const byTotal = ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.thickness) === "total";
|
|
19414
19442
|
// the name of the scenario stands below the last bar: it needs room when a sum row follows
|
|
19415
19443
|
const lastBar = rows.reduce((last, row, index) => (row.sum ? last : index), -1);
|
|
19416
|
-
const nameBelow = !this.stackConfig &&
|
|
19444
|
+
const nameBelow = !this.stackConfig &&
|
|
19445
|
+
!this.scenarioLabelTop &&
|
|
19446
|
+
!this.hideScenarioName &&
|
|
19447
|
+
lastBar >= 0 &&
|
|
19448
|
+
lastBar < rows.length - 1;
|
|
19417
19449
|
if (!byTotal && !nameBelow && !rows.some((row) => row.gapAfter))
|
|
19418
19450
|
return null;
|
|
19419
19451
|
const totals = rows.map((row) => {
|
|
@@ -19788,6 +19820,8 @@ const BnChartStructureRenderer = class {
|
|
|
19788
19820
|
/** @internal */
|
|
19789
19821
|
this.scenarioLabelTop = false;
|
|
19790
19822
|
/** @internal */
|
|
19823
|
+
this.hideScenarioName = false;
|
|
19824
|
+
/** @internal */
|
|
19791
19825
|
this.referenceLine = null;
|
|
19792
19826
|
/** @internal */
|
|
19793
19827
|
this.italicCategories = [];
|
|
@@ -20032,6 +20066,7 @@ const BnChartStructureRenderer = class {
|
|
|
20032
20066
|
sums: this.sums,
|
|
20033
20067
|
sumTitle: this.sumTitle,
|
|
20034
20068
|
scenarioLabelTop: this.scenarioLabelTop,
|
|
20069
|
+
hideScenarioName: this.hideScenarioName,
|
|
20035
20070
|
referenceLine: this.referenceLine,
|
|
20036
20071
|
italicCategories: this.italicCategories,
|
|
20037
20072
|
});
|
|
@@ -26279,6 +26314,29 @@ const bnContextCss = () => `:host{display:block}`;
|
|
|
26279
26314
|
|
|
26280
26315
|
/** The elements that write what `getNotation()` reads. */
|
|
26281
26316
|
const NOTATION_SOURCE_SELECTOR = "bn-component-style, bn-scaling-group";
|
|
26317
|
+
/** The contexts on the page, in the order they connected. */
|
|
26318
|
+
const separatorSources = new Map();
|
|
26319
|
+
const NAMED_SEPARATORS = { "thin-space": "\u2009", space: "\u00a0", none: "" };
|
|
26320
|
+
/**
|
|
26321
|
+
* Sets the group separator of the page: the one of the last connected context that
|
|
26322
|
+
* declares one, else the one of the locale. The numbers on the page are drawn with
|
|
26323
|
+
* the old separator, so every context draws again, but `connecting`: it has drawn nothing yet.
|
|
26324
|
+
*/
|
|
26325
|
+
function syncGroupSeparator(connecting) {
|
|
26326
|
+
var _a;
|
|
26327
|
+
let declared = "";
|
|
26328
|
+
for (const source of separatorSources.values()) {
|
|
26329
|
+
declared = source.separator() || declared;
|
|
26330
|
+
}
|
|
26331
|
+
const separator = declared ? ((_a = NAMED_SEPARATORS[declared]) !== null && _a !== void 0 ? _a : declared) : null;
|
|
26332
|
+
if (separator === Formatter.groupSeparator)
|
|
26333
|
+
return;
|
|
26334
|
+
Formatter.groupSeparator = separator;
|
|
26335
|
+
for (const [context, source] of separatorSources) {
|
|
26336
|
+
if (context !== connecting)
|
|
26337
|
+
source.redraw();
|
|
26338
|
+
}
|
|
26339
|
+
}
|
|
26282
26340
|
/** Attributes that change the paper size, the orientation or the number of a page. */
|
|
26283
26341
|
const PAGE_ATTRIBUTES = [
|
|
26284
26342
|
"format",
|
|
@@ -26313,37 +26371,22 @@ const Context = class {
|
|
|
26313
26371
|
/**
|
|
26314
26372
|
* Group separator of every number in the document, in place of the one of
|
|
26315
26373
|
* the locale: `thin-space`, `space`, `none`, or the separator itself. It
|
|
26316
|
-
* holds for the whole page, also for a context that does not set it.
|
|
26374
|
+
* holds for the whole page, also for a context that does not set it. With
|
|
26375
|
+
* several contexts the last one that declares a separator wins.
|
|
26317
26376
|
*
|
|
26318
26377
|
* @default "" (the separator of the locale)
|
|
26319
26378
|
* @example group-separator="thin-space"
|
|
26320
26379
|
*/
|
|
26321
26380
|
this.groupSeparator = "";
|
|
26322
|
-
this.
|
|
26381
|
+
this.wasConnected = false;
|
|
26323
26382
|
/** The page numbers this context wrote. A number that is not in here was set by the author and is left alone. */
|
|
26324
26383
|
this.assignedPageNumbers = new WeakMap();
|
|
26325
26384
|
this.notationSubscriptions = [];
|
|
26326
26385
|
withComponentStatus(this);
|
|
26327
26386
|
this.errors = withHasError(this);
|
|
26328
26387
|
}
|
|
26329
|
-
watchGroupSeparator(
|
|
26330
|
-
|
|
26331
|
-
const before = Formatter.groupSeparator;
|
|
26332
|
-
this.setGroupSeparator(newValue);
|
|
26333
|
-
// the numbers are drawn with the old separator: what follows the locale draws again
|
|
26334
|
-
const state = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.context.state;
|
|
26335
|
-
if (state && Formatter.groupSeparator !== before) {
|
|
26336
|
-
const locale = state.locale;
|
|
26337
|
-
state.locale = "";
|
|
26338
|
-
state.locale = locale;
|
|
26339
|
-
}
|
|
26340
|
-
}
|
|
26341
|
-
setGroupSeparator(newValue) {
|
|
26342
|
-
var _a;
|
|
26343
|
-
const named = { "thin-space": "\u2009", space: "\u00a0", none: "" };
|
|
26344
|
-
// no value: the separator of the locale
|
|
26345
|
-
Formatter.groupSeparator = newValue ? ((_a = named[newValue]) !== null && _a !== void 0 ? _a : newValue) : null;
|
|
26346
|
-
this.setsGroupSeparator = !!newValue;
|
|
26388
|
+
watchGroupSeparator() {
|
|
26389
|
+
syncGroupSeparator();
|
|
26347
26390
|
}
|
|
26348
26391
|
setLocale(newValue) {
|
|
26349
26392
|
this.stores.context.state.locale = newValue;
|
|
@@ -26356,9 +26399,18 @@ const Context = class {
|
|
|
26356
26399
|
if (this.locale) {
|
|
26357
26400
|
this.stores.context.state.locale = this.locale;
|
|
26358
26401
|
}
|
|
26359
|
-
|
|
26360
|
-
|
|
26361
|
-
|
|
26402
|
+
separatorSources.set(this, {
|
|
26403
|
+
separator: () => { var _a; return (_a = this.groupSeparator) !== null && _a !== void 0 ? _a : ""; },
|
|
26404
|
+
redraw: () => {
|
|
26405
|
+
const state = this.stores.context.state;
|
|
26406
|
+
const locale = state.locale;
|
|
26407
|
+
state.locale = "";
|
|
26408
|
+
state.locale = locale;
|
|
26409
|
+
},
|
|
26410
|
+
});
|
|
26411
|
+
// a context that comes back to the page has drawn its numbers before
|
|
26412
|
+
syncGroupSeparator(this.wasConnected ? undefined : this);
|
|
26413
|
+
this.wasConnected = true;
|
|
26362
26414
|
// a removed scaling group is a "set" too: its entry is set to undefined
|
|
26363
26415
|
const notify = () => this.bnNotationChange.emit();
|
|
26364
26416
|
this.notationSubscriptions = [
|
|
@@ -26377,11 +26429,9 @@ const Context = class {
|
|
|
26377
26429
|
}
|
|
26378
26430
|
disconnectedCallback() {
|
|
26379
26431
|
var _a, _b;
|
|
26380
|
-
//
|
|
26381
|
-
|
|
26382
|
-
|
|
26383
|
-
this.setsGroupSeparator = false;
|
|
26384
|
-
}
|
|
26432
|
+
// the separator of this context no longer holds, the one of another context may
|
|
26433
|
+
separatorSources.delete(this);
|
|
26434
|
+
syncGroupSeparator();
|
|
26385
26435
|
this.notationSubscriptions.forEach((unsubscribe) => unsubscribe());
|
|
26386
26436
|
this.notationSubscriptions = [];
|
|
26387
26437
|
(_a = this.pageObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
@@ -26534,7 +26584,7 @@ const Context = class {
|
|
|
26534
26584
|
componentWillUpdate() { }
|
|
26535
26585
|
componentDidUpdate() { }
|
|
26536
26586
|
render() {
|
|
26537
|
-
return (h(Host, { key: '
|
|
26587
|
+
return (h(Host, { key: '835bf8fe0cf78440c000ce996495c5c5c0cbbd07' }, h("slot", { key: '395cbc8fdbb4f6e765d36a93a7547272e5ec7def' })));
|
|
26538
26588
|
}
|
|
26539
26589
|
get element() { return getElement(this); }
|
|
26540
26590
|
static get watchers() { return {
|