@bino-bi/bn-template-engine 1.0.0-next.24 → 1.0.0-next.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
- package/dist/bn-template-engine/{p-a8eb9ca0.entry.js → p-e30c7251.entry.js} +1 -1
- package/dist/cjs/bn-asset_21.cjs.entry.js +1 -1
- package/dist/collection/components/bn-chart-time/ibcs-chart-time.css +0 -4
- package/dist/components/ibcs-chart-time2.js +1 -1
- package/dist/esm/bn-asset_21.entry.js +1 -1
- package/package.json +1 -1
- package/readme.md +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,h as i,H as s,g as e,d as n,f as r,e as a,F as o}from"./p-C5UYpZUU.js";import{w as h,a as l,r as c}from"./p-DtLI_CzV.js";import{g as d,h as u,a as p,i as f,c as v,D as g,d as m}from"./p-D5e8I9Qe.js";import{w as b}from"./p-CTrNbSXN.js";import{b as w,g as y,h as S,j as $,v as O,d as R,a as M,e as x,k as _,l as E,w as k,i as P,f as T,m as L,n as A,D as C,o as N,p as U,q as D,r as G,s as W,t as F,u as I,x as Y,y as z,z as B,A as H,B as V,C as j,E as X,F as J,G as q,H as Z}from"./p-CsJ84YRk.js";import{i as K,r as Q,b as tt,w as it,a as st,c as et,g as nt,p as rt,d as at}from"./p-EtT29btN.js";import{w as ot}from"./p-BcaI745G.js";import{w as ht,o as lt,a as ct}from"./p-DjPXefnq.js";import{A as dt,f as ut,g as pt,h as ft,c as vt,i as gt,D as mt,I as bt,e as wt,M as yt,B as St,T as $t,C as Ot,R as Rt,S as Mt}from"./p-BbmobTg0.js";import{O as xt,b as _t,A as Et,c as kt}from"./p-B5Jd_eCX.js";import{LAYOUT_STATE_VERSION as Pt}from"./index.esm.js";import{r as Tt,m as Lt,a as At,o as Ct,b as Nt,c as Ut,t as Dt}from"./p-BcLsoDrW.js";import{F as Gt,S as Wt,I as Ft,C as It,V as Yt,a as zt,b as Bt,c as Ht,P as Vt,Q as jt}from"./p-TuLpbB5O.js";import{s as Xt}from"./p-BA48JiHe.js";import{S as Jt,g as qt,a as Zt,I as Kt,b as Qt,H as ti,c as ii,L as si,d as ei}from"./p-DVrDYxlh.js";import{S as ni}from"./p-CWWWM-XC.js";const ri=class{constructor(i){t(this,i),h(this),this.errors=l(this),b(this,(t=>{this.stores||(this.stores=d(this.element));try{const i=t.replace(/\s/g,"");this.stores.assets.set(this.name,i)}catch(i){console.error("Error parsing asset",i,t),this.stores.assets.set(this.name,void 0)}}))}render(){return i(s,{key:"dfec9f90136278bddab194479301aa3fa5bc1e72"})}get element(){return e(this)}};ri.style=":host{display:none}";const ai=class{constructor(i){t(this,i),h(this),this.errors=l(this),this.componentStyle=w(this)}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){return i(s,{key:"f43978af1c6658c6fa165093c3ada6b5f3b5986d",style:this.getFontStyles()},i("slot",{key:"b9c97432089676fc373b1d5ee59573ef5681a5c5"}))}get element(){return e(this)}};ai.style=':host{flex:1;min-height:0;position:relative;overflow:hidden;display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}';const oi=class{constructor(i){t(this,i),h(this),this.errors=l(this),this.componentStyle=w(this)}render(){return i(s,{key:"92bcbc010336d3a542c86e182831bbfddda2aa9b",style:this.prepareStyle()},i("slot",{key:"d836aa5443283df158dcb50345aee0df97f74a6e"}))}prepareStyle(){return{"font-family":this.componentStyle((t=>t.global.fontFamily)),"font-size":`${this.componentStyle((t=>t.global.fontSizePx))}px`,"--bn-font-family":this.componentStyle((t=>t.global.fontFamily))||"'Noto Sans', sans-serif","--bn-font-size":`${this.componentStyle((t=>t.global.fontSizePx))||13.3333}px`,"--bn-font-color":this.componentStyle((t=>t.global.fontColor))||"#000000","--bn-font-background":this.componentStyle((t=>t.global.fontBackgroundColor))||"#ffffff"}}get element(){return e(this)}};function hi(t){if("function"==typeof getComputedStyle){const i=parseFloat(getComputedStyle(t).fontSize);if(Number.isFinite(i)&&i>0)return i}return u.global.fontSizePx}function li(t,i){var s;return{version:Pt,tag:t.localName,id:At(t),slot:null!==(s=t.getAttribute("slot"))&&void 0!==s?s:void 0,rect:Lt(t,i),em:{fontSizePx:hi(t),appliedScaleFactor:1},regions:[],metadata:{},diagnostics:Tt(t)}}oi.style=':host{display:flex;flex-direction:column;justify-content:space-between;flex:1;min-height:0;padding:0.25em;margin:0.5em;background-origin:content-box;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}:host(.border){box-sizing:border-box;-webkit-box-sizing:border-box;border:0.1em solid #ddd}div{color:var(--bn-font-color, black)}';const ci=class{validateScenario(t){const i="ERR_scenarios";if(K(t))return void this.errors.remove(i);const s=y(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances";if(K(t))return void this.errors.remove(i);const s=S(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateUnitScaling(t){const i="ERR_unitScaling";"invalid"===Q(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="ERR_percentageScaling";"invalid"===Q(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validateLevel(t){const i="ERR_level";$(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"level: invalid value(s) '"+t+"' are not supported."})}validateOrderList(t){const i="ERR_order";if(K(t))return void this.errors.remove(i);const s=O(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="ERR_orderDirection";K(t)||R(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateLimit(t){const i="ERR_limit";M(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateShowCategories(t){const i="ERR_showCategories";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showCategories: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateMeasureScale(t){const i="ERR_measureScale";_(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateShowMeasureScale(t){const i="ERR_grouped";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateStack(t){const i="ERR_stack",s=E(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:s.join("; ")}):this.errors.remove(i)}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("ERR_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"ERR_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("ERR_scale")}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this._lastScaledParentHeight=0,this.chartTitle="",this.filter="",this.limit=0,this.showCategories="true",this.measureScale="greatest",this.showMeasureScale="false",this.measureUnit="",this.stack="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=t=>{var i,s,e,n,r,a;this.lastAutoScalingReport={unit:null!==(i=t.unit)&&void 0!==i?i:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(e=t.percentage)&&void 0!==e?e:null===(n=this.lastAutoScalingReport)||void 0===n?void 0:n.percentage};const o=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),h=this.getEffectiveFontPx();if(void 0!==t.unit&&t.unit>0&&this.autoUnitWarningActive){const i=h/t.unit;o(i,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=i,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${ci.describeScalingInput(String(null!==(r=this.unitScaling)&&void 0!==r?r:"").trim())}, auto-fitted to 1 em ≈ ${tt(i)} units.`}))}if(void 0!==t.percentage&&t.percentage>0&&this.autoPctWarningActive){const i=100*h/t.percentage;o(i,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=i,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${ci.describeScalingInput(String(null!==(a=this.percentageScaling)&&void 0!==a?a:"").trim())}, auto-fitted to 1 em ≈ ${tt(i)} percentage points.`}))}},k(this),h(this),it(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=l(this),ot(this),this.componentStyle=w(this),this.ruleSetConfig=ht(this),this.t=st(this).t,this.resolveInherited=et(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}])}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateShowCategories(this.showCategories),this.validateMeasureScale(this.measureScale),this.validateShowMeasureScale(this.showMeasureScale),this.validateStack(this.stack),this.validateScaling(this.scale)}componentDidRender(){const{mode:t}=rt(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{height:s}=nt(i);if(s<=0)return void this.checkOverflow();this._lastScaledParentHeight=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollHeight,a=this.appliedScaleFactor;if(r<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,a*(s-1)/r);Math.abs(o-a)<.01||(i.style.setProperty("--bn-font-size",e*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${o.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,n((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=lt(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=nt(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,r(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=nt(this.element);this._lastScaledParentHeight=t,r(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}measureContentWidth(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("ibcs-chart-structure");let s=0,e=!1;return null==i||i.forEach((t=>{var i,n,r;const a=parseFloat(null!==(r=null===(n=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===n?void 0:n.getAttribute("width"))&&void 0!==r?r:"");Number.isNaN(a)||(s+=a,e=!0)})),e?Math.max(Math.floor(s),this.element.scrollWidth):this.element.scrollWidth}checkOverflow(){const t="WARN_overflow",i=nt(this.element),s=this.measureContentWidth(),e=this.element.scrollHeight,n=i.width>0&&s>i.width+1,r=i.height>0&&e>i.height+1;if(!n&&!r)return void this.errors.remove(t);const a=this.prepareVariances().some((t=>t.startsWith("dr"))),o="value"===Q(this.unitScaling,this.pixelPerUnitGroupMap).kind,h=a&&"value"===Q(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:l}=rt(this.scale),c="auto"!==l&&"empty"!==l,d=[];n&&o&&d.push("unit-scaling"),n&&h&&d.push("percentage-scaling"),r&&c&&d.push("scale");const u=[];n&&u.push(`width (${Math.round(s)}px > ${Math.round(i.width)}px)`),r&&u.push(`height (${Math.round(e)}px > ${Math.round(i.height)}px)`),this.errors.addOrReplace({id:t,type:d.length>0?"error":"warning",message:`Chart exceeds available ${u.join(" and ")}. `+(d.length>0?`Adjust ${d.join(" / ")} or set to "auto".`:"Content does not fit even at minimum auto scaling; enlarge the container.")})}prepareDimension(){const t=nt(this.element),i=this.prepareVariances();return this.canvasWidthSegmented=t.width/(1+i.length),{width:this.canvasWidthSegmented,height:t.height}}prepareScenarios(){var t,i,s,e;const n=this.resolveInherited("scenarios",this.scenarios);if(void 0!==n)return this.errors.remove("AUTO_scenarios"),n.split(",").map((t=>t.trim()));const r="auto"===(null===(t=this.scenarios)||void 0===t?void 0:t.trim().toLowerCase());return P(this.scenarios)||r?(null===(s=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===s?void 0:s.length)>0?(r?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(e=this.scenarios)||void 0===e?void 0:e.split(",").map((t=>t.trim())))}prepareVariances(){var t;const i=this.resolveInherited("variances",this.variances);return void 0!==i?i.split(",").map((t=>t.trim())):P(this.variances)?[]:null===(t=this.variances)||void 0===t?void 0:t.split(",").map((t=>t.trim()))}prepareHideCategories(t){return t>=1||"true"!==this.showCategories}prepareI18n(){const t=p,i=new Map(["no-data","REST"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries()])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const t=Q(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/t.value):"auto"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${ci.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const t=Q(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/t.value):"auto"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${ci.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}prepareLevel(){var t,i,s;const e="auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase());return P(this.level)||e?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?(e?this.errors.remove("AUTO_level"):this.errors.addOrReplace({id:"AUTO_level",type:"warning",message:`level: not set, auto-detected: ${this.datasetMeta.suggestedLevel}`}),dt[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),dt[null===(s=this.level)||void 0===s?void 0:s.toUpperCase()])}prepareOrder(){var t;const i=this.resolveInherited("order",this.order),s=this.resolveInherited("orderDirection",this.orderDirection),e=null!=i?i:this.order,n=null!=s?s:this.orderDirection,r="auto"===(null==e?void 0:e.trim().toLowerCase());let a;return P(e)||r?(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)?(r?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:`order: not set, auto-detected: ${this.datasetMeta.suggestedOrder}`}),a=this.datasetMeta.suggestedOrder):a=e:(this.errors.remove("AUTO_order"),a=e),{hierarchy:null==a?void 0:a.split(",").map((t=>_t[null==t?void 0:t.toUpperCase()])),direction:xt[null==n?void 0:n.toUpperCase()]}}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const s=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-structure"].scaleFactors.scenarioOffset,scenarioLabelToBar:i["bn-chart-structure"].scaleFactors.scenarioLabelToBar,labelToBar:i["bn-chart-structure"].scaleFactors.labelToBar,labelToAxis:i["bn-chart-structure"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-structure"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-structure"].scaleFactors.needleHeadWidth,barWidth:i["bn-chart-structure"].scaleFactors.barWidth,varianceAxisLineWidth:i["bn-chart-structure"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-structure"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-structure"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-structure"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-structure"].scaleFactors.markerWidth,markerOffset:i["bn-chart-structure"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-structure"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-structure"].scaleFactors.axisTickLength},fontStyles:{font:`${s}px ${i.global.fontFamily}`,family:i.global.fontFamily,size:s,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-structure"].axisStyles,barStyles:i["bn-chart-structure"].barStyles,varianceStyles:i["bn-chart-structure"].varianceStyles,padding:i["bn-chart-structure"].padding,pattern:null}}))}prepareChartTitle(t){return t>=1?"":this.chartTitle}prepareStackConfig(){if(P(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const t=JSON.parse(this.stack),i=t.by,s="WARN_stack_dimensions_scenarios";if(i===ut.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:s,type:"warning",message:`stack by dimensions: only the first scenario "${t[0]}" is used, the rest (${t.slice(1).join(", ")}) are discarded.`}):this.errors.remove(s)}else this.errors.remove(s);return{by:i,mode:t.mode||ft.ABSOLUTE,order:t.order||pt.DATASET}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareLimit(){return Math.floor(Number(this.limit)||0)}getDataStructure(){return{IStructureChartDataRow:{operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return P(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&"true"===this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}chartTemplate(t,s){const e=this.preparePixelPerUnit(),n=this.preparePixelPerPercentage(),r=this.prepareStackConfig(),a=this.prepareScenarios(),o=(null==r?void 0:r.by)===ut.DIMENSIONS?a.slice(0,1):a;return i("ibcs-chart-structure",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(s),scenarios:o,variances:[t],hideCategories:this.prepareHideCategories(s),pixelPerUnit:e,pixelPerPercentage:n,reportAutoScaling:this.handleAutoScalingReport,limit:this.prepareLimit(),styles:this.prepareStyle(),i18n:this.prepareI18n(),order:this.prepareOrder(),level:this.prepareLevel(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(s),stackConfig:r,parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}async getLayoutState(t){var i,s,e,n;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",a=Ct(this.element),o=this.getEffectiveScaleFactor(),h=Number.isFinite(o)&&o>0?o:1,l=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*h,c=this.prepareVariances(),d=ct(this.element,"ibcs-chart-structure",["base",...c],a,r),u=null===(s=this.element.shadowRoot)||void 0===s?void 0:s.querySelector("ibcs-chart-structure"),p={version:Pt,tag:this.element.localName,id:At(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:Lt(this.element,a),em:{fontSizePx:l,appliedScaleFactor:h},regions:d.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(n=null==u?void 0:u.scenarios)&&void 0!==n?n:[],variances:c,barCount:d.barCount,hasNoData:0===d.barCount},diagnostics:Tt(this.element),scaling:this.resolveScalingInfo(l)};return d.elements&&(p.elements=d.elements),p}resolveScalingInfo(t){var i,s;const e={},n=Q(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===n.kind)e.unitMode="fixed",e.unitsPerEm=n.value,e.unitPxPerUnit=t/n.value;else{e.unitMode="auto";const s=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==s&&s>0&&(e.unitPxPerUnit=s,e.unitsPerEm=t/s)}const r=Q(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)e.percentageMode="fixed",e.percentagePointsPerEm=r.value,e.percentagePxPerPoint=t/r.value;else{e.percentageMode="auto";const i=null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.percentage;void 0!==i&&i>0&&(e.percentagePxPerPoint=i/100,e.percentagePointsPerEm=100*t/i)}return e}getEffectiveScaleFactor(){const{mode:t,factor:i}=rt(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){const t=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}));return t*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const a=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":a*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){let t=[""];const e=this.prepareVariances();e.length>0&&(t=[...t,...e]);const n=this.getFontStyles();return i(s,{key:"4039c2676dbb48bc14e30092d5f5e7a8c080bd2a",style:n},i("div",{key:"c57dbcf301b86f4b22da3142c242008f8f049268",class:"container"},t.map(this.chartTemplate)))}get element(){return e(this)}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}}};var di;ci.style=':host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}',function(t){t.ROWGROUP="rowGroup",t.ROWGROUPINDEX="rowGroupIndex",t.CATEGORY="category",t.CATEGORYINDEX="categoryIndex",t.SUBCATEGORY="subCategory",t.SUBCATEGORYINDEX="subCategoryIndex"}(di||(di={}));const ui=class{validateScenario(t){const i="ERR_scenarios";if(K(t))return void this.errors.remove(i);const s=y(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances";if(K(t))return void this.errors.remove(i);const s=S(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateLeftSync(t){const i="ERR_syncSpaceLeft";T(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"syncSpaceLeft: invalid value(s) '"+t+"' are not supported."})}validateLimit(t){const i="ERR_limit";M(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateUnitScaling(t){const i="ERR_unitScaling";"invalid"===Q(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="ERR_percentageScaling";"invalid"===Q(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validateLevel(t){const i="ERR_level";$(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"level: invalid value(s) '"+t+"' are not supported."})}validateOrderList(t){const i="ERR_order";if(K(t))return void this.errors.remove(i);const s=O(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="ERR_orderDirection";K(t)||R(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateInterval(t){const i="ERR_dateInterval";L(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateInterval: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateChartMode(t){const i="ERR_chartMode";["bar","line","auto"].includes(null==t?void 0:t.toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"chartMode: invalid value '"+(null==t?void 0:t.toString())+"' is not supported. Valid values are: bar, line, auto."})}validateMaxBars(t){const i="ERR_maxBars";!M(t)||t<1?this.errors.addOrReplace({id:i,type:"warning",message:"maxBars: invalid value '"+(null==t?void 0:t.toString())+"' is not supported. Must be a positive integer."}):this.errors.remove(i)}validateStack(t){const i="ERR_stack",s=E(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:s.join("; ")}):this.errors.remove(i)}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("ERR_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"ERR_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("ERR_scale")}validateAxisLabelsMode(t){const i="ERR_axisLabelsMode";A(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"axisLabelsMode: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateLineFullWidth(t){const i="ERR_lineFullWidth";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"lineFullWidth: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowCategories(t){const i="ERR_showCategories";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showCategories: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateMeasureScale(t){const i="ERR_measureScale";_(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateShowMeasureScale(t){const i="ERR_grouped";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowOverlayAvg(t){const i="ERR_grouped";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showOverlayAvg: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowOverlayMedian(t){const i="ERR_grouped";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showOverlayMedian: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.chartTitle="",this.filter="",this.syncSpaceLeft=-1,this.limit=0,this.chartMode="bar",this.maxBars=28,this.stack="",this.intervalSpanLimit=28,this.lineFullWidth="true",this.showCategories="true",this.measureScale="greatest",this.showMeasureScale="false",this.showOverlayAvg="true",this.showOverlayMedian="false",this.measureUnit="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this._lastObservedWidth=0,this._settleTimer=null,this._lastAppliedHeight=0,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=t=>{var i,s,e,n,r,a;this.lastAutoScalingReport={unit:null!==(i=t.unit)&&void 0!==i?i:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(e=t.percentage)&&void 0!==e?e:null===(n=this.lastAutoScalingReport)||void 0===n?void 0:n.percentage};const o=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),h=this.getEffectiveFontPx();if(void 0!==t.unit&&t.unit>0&&this.autoUnitWarningActive){const i=h/t.unit;o(i,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=i,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${ui.describeScalingInput(String(null!==(r=this.unitScaling)&&void 0!==r?r:"").trim())}, auto-fitted to 1 em ≈ ${tt(i)} units.`}))}if(void 0!==t.percentage&&t.percentage>0&&this.autoPctWarningActive){const i=100*h/t.percentage;o(i,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=i,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${ui.describeScalingInput(String(null!==(a=this.percentageScaling)&&void 0!==a?a:"").trim())}, auto-fitted to 1 em ≈ ${tt(i)} percentage points.`}))}},k(this),h(this),it(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=l(this),ot(this),this.componentStyle=w(this),this.ruleSetConfig=ht(this),this.t=st(this).t,this.resolveInherited=et(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}])}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLimit(this.limit),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateLeftSync(this.syncSpaceLeft),this.validateDateInterval(this.dateInterval),this.validateAxisLabelsMode(this.axisLabelsMode),this.validateLineFullWidth(this.lineFullWidth),this.validateShowCategories(this.showCategories),this.validateMeasureScale(this.measureScale),this.validateShowMeasureScale(this.showMeasureScale),this.validateShowOverlayAvg(this.showOverlayAvg),this.validateShowOverlayMedian(this.showOverlayMedian),this.validateChartMode(this.chartMode),this.validateMaxBars(this.maxBars),this.validateStack(this.stack),this.validateScaling(this.scale)}measureContentWidth(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("ibcs-chart-time");let s=0,e=!1;return null==i||i.forEach((t=>{var i,n,r;const a=parseFloat(null!==(r=null===(n=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===n?void 0:n.getAttribute("width"))&&void 0!==r?r:"");Number.isNaN(a)||(s=Math.max(s,a),e=!0)})),e?Math.max(Math.floor(s),this.element.scrollWidth):this.element.scrollWidth}measureContentHeight(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("ibcs-chart-time");let s=0,e=!1;return null==i||i.forEach((t=>{var i,n,r;const a=parseFloat(null!==(r=null===(n=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===n?void 0:n.getAttribute("height"))&&void 0!==r?r:"");Number.isNaN(a)||(s+=a,e=!0)})),e?Math.max(Math.floor(s),this.element.scrollHeight):this.element.scrollHeight}checkOverflow(){const t="WARN_overflow",i=nt(this.element),s=this.measureContentWidth(),e=this.measureContentHeight(),n=i.width>0&&s>i.width+1,r=i.height>0&&e>i.height+1;if(!n&&!r)return void this.errors.remove(t);const a=this.prepareVariances().some((t=>t.startsWith("dr"))),o="value"===Q(this.unitScaling,this.pixelPerUnitGroupMap).kind,h=a&&"value"===Q(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:l}=rt(this.scale),c="auto"!==l&&"empty"!==l,d=[];r&&o&&d.push("unit-scaling"),r&&h&&d.push("percentage-scaling"),n&&c&&d.push("scale");const u=[];n&&u.push(`width (${Math.round(s)}px > ${Math.round(i.width)}px)`),r&&u.push(`height (${Math.round(e)}px > ${Math.round(i.height)}px)`),this.errors.addOrReplace({id:t,type:d.length>0?"error":"warning",message:`Chart exceeds available ${u.join(" and ")}. `+(d.length>0?`Adjust ${d.join(" / ")} or set to "auto".`:"Content does not fit even at minimum auto scaling; enlarge the container.")})}componentDidRender(){const{mode:t}=rt(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{width:s}=nt(i);if(s<=0)return void this.checkOverflow();this._lastObservedWidth=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollWidth,a=this.appliedScaleFactor;if(r<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,a*(s-1)/r);Math.abs(o-a)<.01||(i.style.setProperty("--bn-font-size",e*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${o.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,n((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=lt(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=nt(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2&&(this._lastObservedWidth=t,r(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=nt(this.element);this._lastObservedWidth=t,r(this)}))})),this.settleParentHeight()}settleParentHeight(){const t=[150,400,1e3,2500],i=()=>{if(this._settleTimer=null,!this.element.isConnected)return;const{height:s}=nt(this.element);s>0&&Math.abs(s-this._lastAppliedHeight)>8&&!this._autoScaleGuard&&r(this);const e=t.shift();void 0!==e&&(this._settleTimer=setTimeout(i,e))};this._settleTimer=setTimeout(i,t.shift())}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null,null!=this._settleTimer&&(clearTimeout(this._settleTimer),this._settleTimer=null)}prepareDimension(){const t=nt(this.element),i=this.prepareScenarios(),s=this.prepareVariances();this.canvasWidthSegmented=t.width/(i.length+s.length||1),this._lastAppliedHeight=t.height;const e=1+s.length,n="true"===this.showMeasureScale?this.getEffectiveFontPx():0;return{width:this.canvasWidthSegmented,height:Math.max(0,t.height-n)/e}}prepareScenarios(){var t,i,s,e;const n=this.resolveInherited("scenarios",this.scenarios);if(void 0!==n)return this.errors.remove("AUTO_scenarios"),n.split(",").map((t=>t.trim()));const r="auto"===(null===(t=this.scenarios)||void 0===t?void 0:t.trim().toLowerCase());return P(this.scenarios)||r?(null===(s=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===s?void 0:s.length)>0?(r?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(e=this.scenarios)||void 0===e?void 0:e.split(",").map((t=>t.trim())))}prepareAvg(){return"true"===this.showOverlayAvg}prepareMedian(){return"true"===this.showOverlayMedian}prepareVariances(){var t;const i=this.resolveInherited("variances",this.variances);return void 0!==i?i.split(",").map((t=>t.trim())):P(this.variances)?[]:null===(t=this.variances)||void 0===t?void 0:t.split(",").map((t=>t.trim()))}prepareHideAxisLabels(t){return t>=1||"true"!==this.showCategories}prepareI18n(){const t=p,i=new Map(["no-data"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries()])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const t=Q(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/t.value):"auto"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${ui.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const t=Q(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/t.value):"auto"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${ui.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}prepareLevel(){var t,i,s;const e="auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase());return P(this.level)||e?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?(e?this.errors.remove("AUTO_level"):this.errors.addOrReplace({id:"AUTO_level",type:"warning",message:`level: not set, auto-detected: ${this.datasetMeta.suggestedLevel}`}),di[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),di[null===(s=this.level)||void 0===s?void 0:s.toUpperCase()])}prepareOrder(){var t,i,s;const e=this.resolveInherited("order",this.order),n=this.resolveInherited("orderDirection",this.orderDirection),r=null!=e?e:this.order,a=null!=n?n:this.orderDirection;let o=(P(this.level)||"auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase()))&&(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?this.datasetMeta.suggestedLevel:this.level;const h="auto"===(null==r?void 0:r.trim().toLowerCase());return P(r)||h?(null===(s=this.datasetMeta)||void 0===s?void 0:s.suggestedLevel)&&(h?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:`order: not set, auto-detected: ${o}`})):(this.errors.remove("AUTO_order"),"levelindex"===(null==r?void 0:r.toLocaleLowerCase())&&(o+="Index")),{hierarchy:[_t[null==o?void 0:o.toUpperCase()]],direction:xt[null==a?void 0:a.toUpperCase()]}}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const s=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-time"].scaleFactors.scenarioOffset,scenarioLabelToColumn:i["bn-chart-time"].scaleFactors.scenarioLabelToColumn,labelToColumn:.3,labelToColum:i["bn-chart-time"].scaleFactors.labelToColum,labelToAxis:i["bn-chart-time"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-time"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-time"].scaleFactors.needleHeadWidth,columnWidth:i["bn-chart-time"].scaleFactors.columnWidth,varianceAxisLineWidth:i["bn-chart-time"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-time"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-time"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-time"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-time"].scaleFactors.markerWidth,markerOffset:i["bn-chart-time"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-time"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-time"].scaleFactors.axisTickLength},fontStyles:{font:`${s}px ${i.global.fontFamily}`,family:i.global.fontFamily,size:s,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-time"].axisStyles,barStyles:i["bn-chart-time"].barStyles,varianceStyles:i["bn-chart-time"].varianceStyles,stackColors:i["bn-chart-time"].stackColors,padding:i["bn-chart-time"].padding,pattern:null}}))}prepareLeftSideOffset(t,i){return this.syncSpaceLeft>-1?this.syncSpaceLeft:Gt.getMaxWidthOfArrayItems([...this.prepareVariances(),...this.prepareScenarios(),this.chartTitle],t,i)}prepareChartTitle(t){return t>=1?"":this.chartTitle}prepareLimit(){return Math.floor(Number(this.limit)||0)}prepareDateInterval(){var t,i,s;const e="auto"===(null===(t=this.dateInterval)||void 0===t?void 0:t.trim().toLowerCase());return P(this.dateInterval)||e?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedDateInterval)?(e?this.errors.remove("AUTO_dateInterval"):this.errors.addOrReplace({id:"AUTO_dateInterval",type:"warning",message:`dateInterval: not set, auto-detected: ${this.datasetMeta.suggestedDateInterval}`}),C[this.datasetMeta.suggestedDateInterval.toUpperCase()]):e?C.AUTO:void 0:(this.errors.remove("AUTO_dateInterval"),C[null===(s=this.dateInterval)||void 0===s?void 0:s.toUpperCase()])}prepareIntervalSpanLimit(){return this.intervalSpanLimit}prepareAxisLabelsMode(){var t;return vt[null===(t=this.axisLabelsMode)||void 0===t?void 0:t.toUpperCase()]}prepareFilter(){return 0===this.filter.length?"":this.filter}getDataStructure(){return{ITimeChartDataRow:{setName:{type:"string",isOptional:!1,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return P(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&"true"===this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareStackConfig(){if(P(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const t=JSON.parse(this.stack),i=t.by,s="WARN_stack_dimensions_scenarios";if(i===ut.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:s,type:"warning",message:`stack by dimensions: only the first scenario "${t[0]}" is used, the rest (${t.slice(1).join(", ")}) are discarded.`}):this.errors.remove(s)}else this.errors.remove(s);return{by:i,mode:t.mode||ft.ABSOLUTE,order:t.order||pt.DATASET}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareLineFullWidth(){return"true"===this.lineFullWidth}prepareChartMode(){var t;const i=null===(t=this.chartMode)||void 0===t?void 0:t.toLowerCase();return"line"===i?gt.LINE:"auto"===i?gt.AUTO:gt.BAR}prepareMaxBars(){return Math.floor(Number(this.maxBars)||28)}chartTemplate(t,s){const e=this.prepareI18n(),n=this.prepareStyle(),r=nt(this.element).width,a=this.preparePixelPerUnit(),o=this.preparePixelPerPercentage(),h=this.prepareStackConfig(),l=this.prepareScenarios(),c=(null==h?void 0:h.by)===ut.DIMENSIONS?l.slice(0,1):l;return i("ibcs-chart-time",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(s),scenarios:c,variances:[t],hideAxisLabels:this.prepareHideAxisLabels(s),pixelPerUnit:a,pixelPerPercentage:o,reportAutoScaling:this.handleAutoScalingReport,limit:this.prepareLimit(),leftSideOffsetForHorizontalSync:this.prepareLeftSideOffset(e,n),styles:n,i18n:e,order:this.prepareOrder(),level:this.prepareLevel(),dateInterval:this.prepareDateInterval(),intervalSpanLimit:this.prepareIntervalSpanLimit(),axisLabelsMode:this.prepareAxisLabelsMode(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showOverlayAvg:this.prepareAvg(),showOverlayMedian:this.prepareMedian(),showMeasureScale:this.prepareShowMeasureScale(s),chartMode:this.prepareChartMode(),maxBars:this.prepareMaxBars(),stackConfig:h,lineFullWidth:this.prepareLineFullWidth(),containerWidth:r,parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}async getLayoutState(t){var i,s,e,n;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",a=Ct(this.element),o=this.getEffectiveScaleFactor(),h=Number.isFinite(o)&&o>0?o:1,l=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*h,c=this.prepareVariances(),d=ct(this.element,"ibcs-chart-time",["base",...c],a,r),u=null===(s=this.element.shadowRoot)||void 0===s?void 0:s.querySelector("ibcs-chart-time"),p={version:Pt,tag:this.element.localName,id:At(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:Lt(this.element,a),em:{fontSizePx:l,appliedScaleFactor:h},regions:d.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(n=null==u?void 0:u.scenarios)&&void 0!==n?n:[],variances:c,barCount:d.barCount,chartMode:this.chartMode||void 0,hasNoData:0===d.barCount},diagnostics:Tt(this.element),scaling:this.resolveScalingInfo(l)};return d.elements&&(p.elements=d.elements),p}resolveScalingInfo(t){var i,s;const e={},n=Q(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===n.kind)e.unitMode="fixed",e.unitsPerEm=n.value,e.unitPxPerUnit=t/n.value;else{e.unitMode="auto";const s=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==s&&s>0&&(e.unitPxPerUnit=s,e.unitsPerEm=t/s)}const r=Q(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)e.percentageMode="fixed",e.percentagePointsPerEm=r.value,e.percentagePxPerPoint=t/r.value;else{e.percentageMode="auto";const i=null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.percentage;void 0!==i&&i>0&&(e.percentagePxPerPoint=i/100,e.percentagePointsPerEm=100*t/i)}return e}getEffectiveScaleFactor(){const{mode:t,factor:i}=rt(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){const t=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}));return t*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const a=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":a*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){let t=[""];const e=this.prepareVariances();e.length>0&&(t=[...t,...e]);const n=this.getFontStyles();return i(s,{key:"93a5778cad09ee33f54df92f3b3e32d030a734d6",style:n},i("div",{key:"b431ad76c90bc3c6e5f6820ba03df574155b0038",class:"container"},t.map(this.chartTemplate)))}get element(){return e(this)}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],syncSpaceLeft:[{validateLeftSync:0}],limit:[{validateLimit:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],dateInterval:[{validateDateInterval:0}],chartMode:[{validateChartMode:0}],maxBars:[{validateMaxBars:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}],axisLabelsMode:[{validateAxisLabelsMode:0}],lineFullWidth:[{validateLineFullWidth:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],showOverlayAvg:[{validateShowOverlayAvg:0}],showOverlayMedian:[{validateShowOverlayMedian:0}]}}};ui.style=":host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:column-reverse}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}";const pi=class{constructor(i){t(this,i),this.name="_default",h(this),this.errors=l(this),b(this,(t=>{this.stores||(this.stores=d(this.element));try{const i=JSON.parse(t);this.stores.componentStyles.set(this.name,i),this.errors.remove("JSON_PARSE")}catch(t){this.errors.addOrReplace({id:"JSON_PARSE",type:"error",message:`bn-component-style: Failed to parse JSON body — ${t.message}`}),console.error(t)}}))}render(){return i(s,{key:"9138ba4914f990823213f637bdc65274669bfe86"})}get element(){return e(this)}};pi.style="bn-component-style{display:none}";const fi=class{constructor(i){t(this,i),this.currentPageUpdate=void 0,h(this),this.errors=l(this)}setLocale(t){this.stores.context.state.locale=t}connectedCallback(){this.stores=f(this.element),this.locale&&(this.stores.context.state.locale=this.locale),this.currentPageUpdate=setTimeout((()=>{this.element.querySelectorAll("bn-page, bn-layout-page").forEach(((t,i)=>{if("bn-layout-page"===t.localName)t.setAttribute("page-number",(i+1).toString());else{const s=t.querySelector("bn-footer");s&&s.setAttribute("page-number",(i+1).toString())}}))}),250)}disconnectedCallback(){this.currentPageUpdate&&clearTimeout(this.currentPageUpdate)}async getLayoutState(t){var i,s;const e=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",n=Array.from(this.element.querySelectorAll("bn-body, bn-card, bn-chart-bubble, bn-chart-bullet, bn-chart-scatter, bn-chart-structure, bn-chart-time, bn-footer, bn-grid, bn-image, bn-layout-card, bn-layout-page, bn-message, bn-page, bn-table, bn-template, bn-text, bn-title, bn-tree"));await Promise.all(n.map((t=>{var i,s,e;return null!==(e=null===(s=(i=t).componentOnReady)||void 0===s?void 0:s.call(i))&&void 0!==e?e:Promise.resolve()})));const r=this.element.getBoundingClientRect(),a={x:r.left,y:r.top},o=await Promise.all(n.map((async t=>{const i=t.getBoundingClientRect(),s={context:a,component:{x:i.left,y:i.top}};try{const i=t;return"function"==typeof i.getLayoutState?await i.getLayoutState({detail:e}):li(t,s)}catch(i){let e;try{e=li(t,s)}catch(i){const s={x:0,y:0,width:0,height:0};e={version:Pt,tag:t.localName,id:t.localName,rect:{context:Object.assign({},s),component:Object.assign({},s)},em:{fontSizePx:0,appliedScaleFactor:1},regions:[],metadata:{},diagnostics:[]}}return e.error=String(i instanceof Error?i.message:i),e}}))),h=Nt(n.map((t=>({tag:t.localName,explicitId:Ut(t)}))));return o.forEach(((t,i)=>{t.id=h[i]})),{version:Pt,generatedAt:(new Date).toISOString(),detail:e,context:{viewport:Dt(r),locale:null===(s=this.stores)||void 0===s?void 0:s.context.state.locale},components:o}}componentWillLoad(){}componentDidLoad(){}componentShouldUpdate(){}componentWillRender(){}componentDidRender(){}componentWillUpdate(){}componentDidUpdate(){}render(){return i(s,{key:"005c68f320adbbd5d5269d3fe6f2da6a8096ed98"},i("slot",{key:"7d9fbf3e7a253fe24414cd26274fdffb03b2d5f6"}))}get element(){return e(this)}static get watchers(){return{locale:[{setLocale:0}]}}};fi.style=":host{display:block}";const vi=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],gi=["rowGroup","category","subCategory","columnGroup","columnSubGroup"];function mi(t){return"number"==typeof t&&!isNaN(t)&&isFinite(t)}function bi(t){const i=Array.from(t);return{distinctValues:i,count:i.length,hasData:i.length>0}}var wi=Uint8Array,yi=Uint16Array,Si=Int32Array,$i=new wi([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Oi=new wi([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ri=new wi([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Mi=function(t,i){for(var s=new yi(31),e=0;e<31;++e)s[e]=i+=1<<t[e-1];var n=new Si(s[30]);for(e=1;e<30;++e)for(var r=s[e];r<s[e+1];++r)n[r]=r-s[e]<<5|e;return{b:s,r:n}},xi=Mi($i,2),_i=xi.b,Ei=xi.r;_i[28]=258,Ei[258]=28;for(var ki=Mi(Oi,0).b,Pi=new yi(32768),Ti=0;Ti<32768;++Ti){var Li=(43690&Ti)>>1|(21845&Ti)<<1;Pi[Ti]=((65280&(Li=(61680&(Li=(52428&Li)>>2|(13107&Li)<<2))>>4|(3855&Li)<<4))>>8|(255&Li)<<8)>>1}var Ai=function(t,i,s){for(var e=t.length,n=0,r=new yi(i);n<e;++n)t[n]&&++r[t[n]-1];var a,o=new yi(i);for(n=1;n<i;++n)o[n]=o[n-1]+r[n-1]<<1;if(s){a=new yi(1<<i);var h=15-i;for(n=0;n<e;++n)if(t[n])for(var l=n<<4|t[n],c=i-t[n],d=o[t[n]-1]++<<c,u=d|(1<<c)-1;d<=u;++d)a[Pi[d]>>h]=l}else for(a=new yi(e),n=0;n<e;++n)t[n]&&(a[n]=Pi[o[t[n]-1]++]>>15-t[n]);return a},Ci=new wi(288);for(Ti=0;Ti<144;++Ti)Ci[Ti]=8;for(Ti=144;Ti<256;++Ti)Ci[Ti]=9;for(Ti=256;Ti<280;++Ti)Ci[Ti]=7;for(Ti=280;Ti<288;++Ti)Ci[Ti]=8;var Ni=new wi(32);for(Ti=0;Ti<32;++Ti)Ni[Ti]=5;var Ui=Ai(Ci,9,1),Di=Ai(Ni,5,1),Gi=function(t){for(var i=t[0],s=1;s<t.length;++s)t[s]>i&&(i=t[s]);return i},Wi=function(t,i,s){var e=i/8|0;return(t[e]|t[e+1]<<8)>>(7&i)&s},Fi=function(t,i){var s=i/8|0;return(t[s]|t[s+1]<<8|t[s+2]<<16)>>(7&i)},Ii=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Yi=function(t,i,s){var e=new Error(i||Ii[t]);if(e.code=t,Error.captureStackTrace&&Error.captureStackTrace(e,Yi),!s)throw e;return e},zi=new wi(0);function Bi(t,i){var s,e,n=function(t){31==t[0]&&139==t[1]&&8==t[2]||Yi(6,"invalid gzip data");var i=t[3],s=10;4&i&&(s+=2+(t[10]|t[11]<<8));for(var e=(i>>3&1)+(i>>4&1);e>0;e-=!t[s++]);return s+(2&i)}(t);return n+8>t.length&&Yi(6,"invalid gzip data"),function(t,i,s,e){var n=t.length;if(!n||i.f&&!i.l)return s||new wi(0);var r=!s,a=r||2!=i.i;r&&(s=new wi(3*n));var o,h,l=function(t){var i=s.length;if(t>i){var e=new wi(Math.max(2*i,t));e.set(s),s=e}},c=i.f||0,d=i.p||0,u=i.b||0,p=i.l,f=i.d,v=i.m,g=i.n,m=8*n;do{if(!p){c=Wi(t,d,1);var b=Wi(t,d+1,3);if(d+=3,!b){var w=t[(P=4+((d+7)/8|0))-4]|t[P-3]<<8,y=P+w;if(y>n){Yi(0);break}a&&l(u+w),s.set(t.subarray(P,y),u),i.b=u+=w,i.p=d=8*y,i.f=c;continue}if(1==b)p=Ui,f=Di,v=9,g=5;else if(2==b){var S=Wi(t,d,31)+257,$=Wi(t,d+10,15)+4,O=S+Wi(t,d+5,31)+1;d+=14;for(var R=new wi(O),M=new wi(19),x=0;x<$;++x)M[Ri[x]]=Wi(t,d+3*x,7);d+=3*$;var _=Gi(M),E=(1<<_)-1,k=Ai(M,_,1);for(x=0;x<O;){var P,T=k[Wi(t,d,E)];if(d+=15&T,(P=T>>4)<16)R[x++]=P;else{var L=0,A=0;for(16==P?(A=3+Wi(t,d,3),d+=2,L=R[x-1]):17==P?(A=3+Wi(t,d,7),d+=3):18==P&&(A=11+Wi(t,d,127),d+=7);A--;)R[x++]=L}}var C=R.subarray(0,S),N=R.subarray(S);v=Gi(C),g=Gi(N),p=Ai(C,v,1),f=Ai(N,g,1)}else Yi(1);if(d>m){Yi(0);break}}a&&l(u+131072);for(var U=(1<<v)-1,D=(1<<g)-1,G=d;;G=d){var W=(L=p[Fi(t,d)&U])>>4;if((d+=15&L)>m){Yi(0);break}if(L||Yi(2),W<256)s[u++]=W;else{if(256==W){G=d,p=null;break}var F=W-254;W>264&&(F=Wi(t,d,(1<<(z=$i[x=W-257]))-1)+_i[x],d+=z);var I=f[Fi(t,d)&D],Y=I>>4;if(I||Yi(3),d+=15&I,N=ki[Y],Y>3){var z=Oi[Y];N+=Fi(t,d)&(1<<z)-1,d+=z}if(d>m){Yi(0);break}a&&l(u+131072);var B=u+F;if(u<N){var H=0-N,V=Math.min(N,B);for(H+u<0&&Yi(3);u<V;++u)s[u]=e[H+u]}for(;u<B;++u)s[u]=s[u-N]}}i.l=p,i.p=G,i.b=u,i.f=c,p&&(c=1,i.m=v,i.d=f,i.n=g)}while(!c);return u!=s.length&&r?(o=s,(null==(h=u)||h>o.length)&&(h=o.length),new wi(o.subarray(0,h))):s.subarray(0,u)}(t.subarray(n,-8),{i:2},new wi(((s=t)[(e=s.length)-4]|s[e-3]<<8|s[e-2]<<16|s[e-1]<<24)>>>0),i)}var Hi="undefined"!=typeof TextDecoder&&new TextDecoder;try{Hi.decode(zi,{stream:!0})}catch(t){}function Vi(t){return N(t)}function ji(t){const i=t.indexOf(":");if(-1===i)throw new Error("Invalid compressed format: missing ':' separator");const s=t.slice(0,i),e=t.slice(i+1),n=atob(e),r=new Uint8Array(n.length);for(let t=0;t<n.length;t++)r[t]=n.charCodeAt(t);const a=Bi(r);return{hash:s,json:(new TextDecoder).decode(a)}}const Xi=class{constructor(i){t(this,i),this.datasources="",this.static=!1,this.raw=!0,this.interval=0,this.lastBodyHash=null,this.lastViewQuery=null,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,h(this),this.errors=l(this),((t,i)=>{let s,n=[],r=[];const a=t=>{let e;try{e=s.db.db.exec(`SELECT * FROM \`${t}\``)}catch(t){e=[]}i()},o=()=>{n.forEach((t=>t())),n=[],r.forEach((t=>{t&&(n.push(s.db.subscribe(t,(()=>a(t)))),a(t))}))},h=new MutationObserver((i=>{i.forEach((i=>{"datasources"===i.attributeName&&(r=(e(t).getAttribute("datasources")||"").split(","),o())}))})),l=t.connectedCallback;t.connectedCallback=()=>{const i=e(t);s=d(i),r=(i.getAttribute("datasources")||"").split(","),o(),h.observe(i,{attributes:!0,attributeFilter:["datasources"]}),c(l,t)};const u=t.disconnectedCallback;t.disconnectedCallback=()=>{h.disconnect(),n.forEach((t=>t())),n=[],v(e(t)),c(u,t)}})(this,(()=>{this.executeQuery()})),b(this,(t=>{const i=t.trim();if(this.isUrl(i)){if(i===this.currentUrl)return;return this.currentUrl=i,this.lastBodyHash=null,this.fetchAndStore(i),void this.startPolling()}let s,e;if(null!==this.currentUrl&&(this.cancelInFlight(),this.currentUrl=null),!this.raw&&this.static)try{const i=ji(t);s=i.hash,e=i.json}catch(i){return void console.error("Error decoding compressed dataset",i,String(t).slice(0,200))}else s=Vi(t),e=t;s!==this.lastBodyHash&&(this.lastBodyHash=s,this.query=e,this.executeQuery())}))}executeQuery(){if(this.stores||(this.stores=d(this.element)),!this.query||!this.name)return;const t=this.stores.db.db;let i;if(this.static){try{i=JSON.parse(this.query)}catch(t){console.error("Failed to parse static dataset",t),i=[]}t.tables[this.name]={data:Array.isArray(i)?i:[]},this.lastViewQuery=null}else{if(this.lastViewQuery!==this.query){try{t.exec(`DROP VIEW \`${this.name}\``)}catch(t){}null!=t.tables[this.name]&&delete t.tables[this.name],t.views&&null!=t.views[this.name]&&delete t.views[this.name];try{t.exec(`CREATE VIEW \`${this.name}\` AS ${this.query}`),this.lastViewQuery=this.query}catch(t){return console.error("bn-dataset: failed to register SQL view",t,this.query),this.lastViewQuery=null,i=[],void this.publish(i)}}try{i=t.exec(`SELECT * FROM \`${this.name}\``)}catch(t){return}}this.publish(i)}publish(t){this.latestResult!==t?(this.latestResult=t,this.stores.db.notify(this.name),this.stores.datasetsMeta.set(this.name,function(t){const i={};for(const t of gi)i[t]=new Set;const s={};for(const t of vi)s[t]={hasData:!1,min:null,max:null};const e=new Set;let n=null,r=null;const a=Array.isArray(t)?t:[];for(let t=0;t<a.length;t++){const o=a[t];if(null==o)continue;for(const t of gi){const s=o[t];null!=s&&""!==s&&i[t].add(String(s))}for(const t of vi){const i=o[t];if(mi(i)){const e=s[t];e.hasData=!0,(null===e.min||i<e.min)&&(e.min=i),(null===e.max||i>e.max)&&(e.max=i)}}const h=o.date;if(null!=h&&""!==h){const t=String(h);e.add(t),(null===n||t<n)&&(n=t),(null===r||t>r)&&(r=t)}}const o=vi.map((t=>({key:t,hasData:s[t].hasData,min:s[t].min,max:s[t].max}))),h=o.filter((t=>t.hasData)).map((t=>t.key)),l=bi(i.rowGroup),c=bi(i.category),d=bi(i.subCategory),u=bi(i.columnGroup),p=bi(i.columnSubGroup),f={min:n,max:r,hasData:e.size>0,distinctCount:e.size};let v="category";return d.hasData?v="subCategory":c.hasData?v="category":l.hasData&&(v="rowGroup"),{rowCount:a.length,scenarios:o,availableScenarios:h,rowGroup:l,category:c,subCategory:d,columnGroup:u,columnSubGroup:p,dateRange:f,suggestedLevel:v,suggestedOrder:v,suggestedDateInterval:f.hasData?"auto":null,calculatedAt:Date.now()}}(t))):this.stores.db.notify(this.name)}nameUpdated(){this.executeQuery()}onIntervalChange(){this.currentUrl&&this.startPolling()}disconnectedCallback(){var t,i;if(this.cancelInFlight(),(null===(i=null===(t=this.stores)||void 0===t?void 0:t.db)||void 0===i?void 0:i.db)&&this.name){const t=this.stores.db.db;try{t.exec(`DROP VIEW \`${this.name}\``)}catch(t){}null!=t.tables[this.name]&&delete t.tables[this.name],t.views&&null!=t.views[this.name]&&delete t.views[this.name],this.stores.db.notify(this.name)}}isUrl(t){return!(!t.startsWith("http://")&&!t.startsWith("https://"))||t.startsWith("/")&&!t.startsWith("//")}async fetchAndStore(t){var i;null===(i=this.abortController)||void 0===i||i.abort(),this.abortController=new AbortController,this.stores||(this.stores=d(this.element));try{const i=await fetch(t,{signal:this.abortController.signal}),s=await i.json();this.stores.db.db.tables[this.name]={data:Array.isArray(s)?s:[]},this.lastViewQuery=null,this.publish(s)}catch(i){if(i instanceof DOMException&&"AbortError"===i.name)return;console.error("bn-dataset: error fetching URL",i,t),this.stores.db.db.tables[this.name]={data:[]},this.lastViewQuery=null,this.publish([])}}clearPollTimer(){null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null)}cancelInFlight(){var t;this.clearPollTimer(),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPollTimer(),this.currentUrl&&this.interval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&this.fetchAndStore(this.currentUrl)}),1e3*this.interval))}render(){return i(s,{key:"bfa62b924abb8097cd9bad75eb71ab38caf02267"})}get element(){return e(this)}static get watchers(){return{name:[{nameUpdated:0}],interval:[{onIntervalChange:0}]}}};Xi.style="bn-dataset{display:none}";const Ji=class{constructor(i){t(this,i),this.raw=!0,this.interval=0,this.lastHash=null,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,h(this),this.errors=l(this),b(this,(t=>{this.stores||(this.stores=d(this.element));const i=t.trim();if(this.isUrl(i)){if(i===this.currentUrl)return;return this.currentUrl=i,this.lastHash=null,this.fetchAndStore(i),void this.startPolling()}null!==this.currentUrl&&(this.cancelInFlight(),this.currentUrl=null);try{let i,s;if(this.raw)i=Vi(t),s=t;else{const e=ji(t);i=e.hash,s=e.json}if(i===this.lastHash)return;this.lastHash=i;const e=JSON.parse(s);this.publish(e)}catch(i){console.error("Error parsing datasource",i,String(t).slice(0,200)),this.publish([])}}))}publish(t){this.stores.db.db.tables[this.name]={data:Array.isArray(t)?t:[]},this.stores.db.notify(this.name)}onIntervalChange(){this.currentUrl&&this.startPolling()}disconnectedCallback(){var t,i;this.cancelInFlight();const s=null===(i=null===(t=this.stores)||void 0===t?void 0:t.db)||void 0===i?void 0:i.db;s&&this.name&&(null!=s.tables[this.name]&&delete s.tables[this.name],s.views&&null!=s.views[this.name]&&delete s.views[this.name],this.stores.db.notify(this.name))}isUrl(t){return!(!t.startsWith("http://")&&!t.startsWith("https://"))||t.startsWith("/")&&!t.startsWith("//")}async fetchAndStore(t){var i;null===(i=this.abortController)||void 0===i||i.abort(),this.abortController=new AbortController,this.stores||(this.stores=d(this.element));try{const i=await fetch(t,{signal:this.abortController.signal}),s=await i.json();this.publish(s)}catch(i){if(i instanceof DOMException&&"AbortError"===i.name)return;console.error("bn-datasource: error fetching URL",i,t),this.publish([])}}clearPollTimer(){null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null)}cancelInFlight(){var t;this.clearPollTimer(),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPollTimer(),this.currentUrl&&this.interval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&this.fetchAndStore(this.currentUrl)}),1e3*this.interval))}render(){return i(s,{key:"4beaa62937dea949255669bfd5008a2928e460fc"})}get element(){return e(this)}static get watchers(){return{interval:[{onIntervalChange:0}]}}};Ji.style="bn-datasource{display:none}";const qi=class{constructor(i){t(this,i),this.pageNumber=null,this.displayPageNumber=!0,h(this),this.errors=l(this),this.componentStyle=w(this)}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}isValidHttpUrl(t){let i;try{i=new URL(t)}catch(t){return!1}return"http:"===i.protocol||"https:"===i.protocol}prepareAssetUrl(t){return this.isValidHttpUrl(t)?t:`./assets/${t}.png`}render(){return i(s,{key:"666fa787056f32825c15427f2a6c15b971fbc25e",id:this.displayPageNumber||this.text||this.code?"container-page-footer":"container",style:this.getFontStyles()},i("div",{key:"691752d51748c4e1eb7ec25d380c00ddf0095c83",id:"footer-text"},null!=this.text?i("span",{class:"note"},this.text):""),i("div",{key:"561a81e063e110ef6386fb0056a05f1b6a0e0f44",id:"code"},null!=this.code?i("img",{class:"image",src:a(`${this.prepareAssetUrl(this.code)}`)}):""),i("div",{key:"963658fcff1a6dd07b448f85e8d170000422e3cc",id:"page-number"},this.displayPageNumber?i("span",{class:"page"},this.pageNumber):""))}static get assetsDirs(){return["assets"]}get element(){return e(this)}};qi.style=':host{padding:0.2em 0.5em;display:flex;flex-direction:row;justify-content:space-between;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}:host(#container-page-footer){box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em solid #ddd}div#footer-text{font-size:0.6em;display:inline}div#code{flex:1;display:inline;text-align:right;padding-right:1em}div#page-number{font-size:0.6em;display:inline}.image{z-index:2;background-color:transparent;border:transparent;height:1.2em;width:auto}';const Zi=class{constructor(i){t(this,i),this.titleImage="",this.titleBusinessUnit="",this.titleOrder="category",this.titleOrderDirection="asc",this.titleDateFormat="none",this.titleDateLink="none",this.footerText="",this.cardLayout="full",this.cardCustomTemplate='"a b" "c d"',this.cardGridGap="0",this.cardFitToContent=!1,this.cardShowBorder=!0,this.templateMap=new Map([["split-vertical",'"a b"'],["split-horizontal",'"a" "b"'],["2x2",'"a b" "c d"'],["3x3",'"a b c" "d e f" "g h i"'],["4x4",'"a b c d" "e f g h" "i j k l" "m n o p"'],["1-over-2",'"a a" "b c"'],["2-over-1",'"a b" "c c"'],["1-over-3",'"a a a " "b c d"'],["3-over-1",'"a b c" "d d d"'],["custom-template",'"a b" "c c c"'],["gold3",'"a c" "b c"'],["gold4",'"a b c c" "d d c c"']]),this.errors=l(this),this.resolveInherited=et(this,[{propName:"titleScenarios",ancestorAttr:"title-scenarios"},{propName:"titleVariances",ancestorAttr:"title-variances"},{propName:"titleOrder",ancestorAttr:"title-order"},{propName:"titleOrderDirection",ancestorAttr:"title-order-direction"},{propName:"ruleset",ancestorAttr:"ruleset"}])}connectedCallback(){this.stores=d(this.element),this.reflectInheritedAttrs()}getCommonStyles(){let t="100%";return!0===this.cardFitToContent&&(t="fit-content"),{display:"grid",height:t,width:"100%",gap:this.cardGridGap+"px"}}calculateFractions(t){const i=t.trim().split(/\s+/).length;return 0===i?"minmax(0, 1fr)":Array(i).fill("minmax(0, 1fr)").join(" ")}getGridTemplateColumns(t){const i=this.getTemplatePattern(t).match(/"[\w\d\s.]+"/g);return i&&0!==i.length?this.calculateFractions(i[0]):"minmax(0, 1fr)"}getRowCount(t){const i=this.getTemplatePattern(t).match(/"[\w\d\s.]+"/g);return i?i.length:1}getGridTemplateRows(t){const i=this.getRowCount(t);return this.cardFitToContent?Array(i).fill("auto").join(" "):Array(i).fill("minmax(0, 1fr)").join(" ")}getLayoutStyle(){return Object.assign(Object.assign({},this.getCommonStyles()),{"grid-template-areas":this.getTemplatePattern(this.cardLayout),"grid-template-columns":this.getGridTemplateColumns(this.cardLayout),"grid-template-rows":this.getGridTemplateRows(this.cardLayout)})}createDivAreaStyles(t){return t.map((t=>({display:"flex",overflow:"hidden","grid-area":t})))}getSlots(t){const s=this.createDivAreaStyles(t);return i(o,null,s.map(((t,s)=>i("div",{style:t},i("slot",{name:"card-slot-"+s})))))}extractSlotNames(t){if(null==t)return[];const i=t.match(/\b\w+\b/g);return i?Array.from(new Set(i)):[]}getTemplatePattern(t){return!1===this.templateMap.has(t)&&"custom-template"!==t?'"a"':"custom-template"===t?this.cardCustomTemplate:this.templateMap.get(t)}async getNumberOfSlot(t){const i=this.getTemplatePattern(t);return this.extractSlotNames(i).length}componentDidUpdate(){}setCardClass(){return!0===this.cardShowBorder?"card_box border":"card_box"}reflectInheritedAttrs(){const t=[{prop:"titleScenarios",attr:"title-scenarios"},{prop:"titleVariances",attr:"title-variances"},{prop:"titleOrder",attr:"title-order"},{prop:"titleOrderDirection",attr:"title-order-direction"},{prop:"ruleset",attr:"ruleset"}];for(const{prop:i,attr:s}of t){const t=this.resolveInherited(i,this[i]);void 0!==t&&this.element.setAttribute(s,t)}}prepareTitleImage(t){if(null==t||""===t)return"";const i=this.stores.assets.state;return t.startsWith("asset:")?i[t.substring(6)]:i[t]||t}render(){var t,s,e,n,r,a;const o=this.getLayoutStyle(),h=this.extractSlotNames(o["grid-template-areas"]);return i("bn-card",{key:"2aa7bd3e3beb1a6b6b0dc0b06c7d7eda324299a0",styles:this.styles,"selected-style":this.selectedStyle,class:this.setCardClass()},i("div",{key:"65fe54ff342691b7f2b7df747af88499ffdbebc0",class:"cardtitle"},i("bn-title",{key:"be70a8c4e5cef0be0fb264fe74dc3732c2a42939","i18n-namespace":null!==(t=this.i18nNamespace)&&void 0!==t?t:this.titleNamespace,ruleset:null!==(s=this.resolveInherited("ruleset",this.ruleset))&&void 0!==s?s:this.ruleset,"business-unit":this.titleBusinessUnit,scenarios:null!==(e=this.resolveInherited("titleScenarios",this.titleScenarios))&&void 0!==e?e:this.titleScenarios,variances:null!==(n=this.resolveInherited("titleVariances",this.titleVariances))&&void 0!==n?n:this.titleVariances,order:null!==(r=this.resolveInherited("titleOrder",this.titleOrder))&&void 0!==r?r:this.titleOrder,"order-direction":null!==(a=this.resolveInherited("titleOrderDirection",this.titleOrderDirection))&&void 0!==a?a:this.titleOrderDirection,measures:this.titleMeasures,"date-start":this.titleDateStart,"date-end":this.titleDateEnd,"date-format":this.titleDateFormat,"date-link":this.titleDateLink}),null!=this.titleImage&&""!==this.titleImage?i("img",{class:"image",src:this.prepareTitleImage(this.titleImage)}):""),i("bn-body",{key:"5875c3e62ca38095588f13907936974259816215"},i("div",{key:"c845d5f8c130f2dd0ae48fc4c2301a55842f001a",style:o,"data-bn-fit-content":this.cardFitToContent?String(this.getRowCount(this.cardLayout)):null},this.getSlots(h))),i("bn-footer",{key:"388596894d04dc2f93d6d71b9f8a0348fb46195f",text:this.footerText,"page-number":0,"display-page-number":"false"}))}get element(){return e(this)}};Zi.style=':host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden}.cardtitle{display:inline-flex}::slotted(*){flex:1 1 auto;min-width:0}.image{margin-right:0.5em;margin-top:0.5em;z-index:2;background-color:transparent;border:transparent;height:4em;width:auto;display:inline}';const Ki=class{constructor(i){t(this,i),this.messageText="",this.messageImage="",this.titleBusinessUnit="",this.titleOrder="category",this.titleOrderDirection="asc",this.titleDateFormat="none",this.titleDateLink="none",this.footerDisplayPageNumber=!0,this.pageLayout="full",this.pageCustomTemplate='"a b" "c d"',this.pageGridGap="0",this.pageFitToContent=!1,this.templateMap=new Map([["split-vertical",'"a b"'],["split-horizontal",'"a" "b"'],["2x2",'"a b" "c d"'],["3x3",'"a b c" "d e f" "g h i"'],["4x4",'"a b c d" "e f g h" "i j k l" "m n o p"'],["1-over-2",'"a a" "b c"'],["2-over-1",'"a b" "c c"'],["1-over-3",'"a a a " "b c d"'],["3-over-1",'"a b c" "d d d"'],["custom-template",'"a b" "c c c"'],["gold3",'"a c" "b c"'],["gold4",'"a b c c" "d d c c"']]),this.errors=l(this)}getCommonStyles(){let t="100%";return!0===this.pageFitToContent&&(t="fit-content"),{display:"grid",height:t,width:"100%",gap:this.pageGridGap+"px"}}getRowCount(t){const i=this.getTemplateAreas(t).match(/"[\w\d\s.]+"/g);return i?i.length:1}getGridTemplateRows(t){const i=this.getRowCount(t);return this.pageFitToContent?Array(i).fill("auto").join(" "):Array(i).fill("minmax(0, 1fr)").join(" ")}getLayoutStyle(){return Object.assign(Object.assign({},this.getCommonStyles()),{"grid-template-areas":this.getTemplateAreas(this.pageLayout),"grid-template-columns":this.getGridTemplateColumns(this.pageLayout),"grid-template-rows":this.getGridTemplateRows(this.pageLayout)})}createDivAreaStyles(t){return t.map((t=>({display:"flex",overflow:"hidden","grid-area":t})))}getSlots(t){const s=this.createDivAreaStyles(t);return i(o,null,s.map(((t,s)=>i("div",{style:t},i("slot",{name:"slot-"+s})))))}extractSlotNames(t){if(null==t)return[];const i=t.match(/\b\w+\b/g);return i?Array.from(new Set(i)):[]}getTemplateAreas(t){return!1===this.templateMap.has(t)&&"custom-template"!==t?'"a"':"custom-template"===t?this.pageCustomTemplate:this.templateMap.get(t)}calculateFractions(t){const i=t.trim().split(/\s+/).length;return 0===i?"minmax(0, 1fr)":Array(i).fill("minmax(0, 1fr)").join(" ")}getGridTemplateColumns(t){if(!1===this.templateMap.has(t)&&"custom-template"!==t)return"1fr";let i;i="custom-template"===t?this.pageCustomTemplate:this.templateMap.get(t);const s=i.match(/"[\w\d\s.]+"/g);return this.calculateFractions(s[0])}async getNumberOfSlot(t){const i=this.getTemplateAreas(t);return this.extractSlotNames(i).length}componentDidUpdate(){const t=this.element.closest("bn-context").getAttribute("render-orientation");if(t&&t!==this.pageOrientation){const t=this.element.shadowRoot.querySelector("bn-page"),i=this.element.closest("bn-layout-page");i&&t&&(t.style.transform="rotate(-90deg) translate(-100%)",t.style.transformOrigin="top left",i.style.width=`${t.clientHeight}px`,i.style.height=`${t.clientWidth}px`)}}render(){var t;const s=this.getLayoutStyle(),e=this.extractSlotNames(s["grid-template-areas"]);return i("bn-page",{key:"6ce75e58dfb8ccab0686d8f34cc6f7830fd42db7",styles:this.styles,"selected-style":this.selectedStyle,format:this.pageFormat,orientation:this.pageOrientation},i("bn-message",{key:"0b7f297afe281b0df05691485a93ba6c3d8abbae",text:this.messageText,image:this.messageImage}),i("bn-title",{key:"b02de31fa8f7e03c38e12cd45ec7f02e2d986d70","i18n-namespace":null!==(t=this.i18nNamespace)&&void 0!==t?t:this.titleNamespace,ruleset:this.ruleset,"business-unit":this.titleBusinessUnit,scenarios:this.titleScenarios,variances:this.titleVariances,order:this.titleOrder,"order-direction":this.titleOrderDirection,measures:this.titleMeasures,"date-start":this.titleDateStart,"date-end":this.titleDateEnd,"date-format":this.titleDateFormat,"date-link":this.titleDateLink}),i("bn-body",{key:"8d43429effcb755ee69665820120838c60b8b9d1"},i("div",{key:"f2d61818b1272551c73bf174f91f61904799a780",style:s,"data-bn-fit-content":this.pageFitToContent?String(this.getRowCount(this.pageLayout)):null},this.getSlots(e))),i("bn-footer",{key:"8d6a6d76c7bef823ee7063586e87084654705771",text:this.footerText,"page-number":this.pageNumber,"display-page-number":this.footerDisplayPageNumber}))}get element(){return e(this)}};Ki.style=':host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:block;overflow:hidden}::slotted(*){flex:1 1 auto;min-width:0}';const Qi=class{constructor(i){t(this,i),h(this),this.errors=l(this),this.componentStyle=w(this)}connectedCallback(){this.stores=d(this.element)}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}prepareAssetUrl(t){if(null==t||""===t)return"";const i=this.stores.assets.state;return t.startsWith("asset:")?i[t.substring(6)]:i[t]||t}render(){return i(s,{key:"9ddcd517464de7fce9fda3c67a6b4c803e6ac4b9",id:this.text||this.image?"container-page-message":"container",style:this.getFontStyles()},i("div",{key:"4618ec0f8cf5b6573278dee2ceb861ca2ad7984d",id:"message-text"},null!=this.text&&""!==this.text?i("span",{class:"note",innerHTML:Xt(this.text)}):""),i("div",{key:"c8c090354330d866fd8431e2df345153bf537c30",id:"page-image"},null!=this.image&&""!==this.image?i("img",{class:"image",src:this.prepareAssetUrl(this.image)}):""))}static get assetsDirs(){return["assets"]}get element(){return e(this)}};Qi.style=':host{padding:0.2em 0.5em;display:flex;flex-direction:row;justify-content:space-between;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}:host(#container-page-message){min-height:4.55em;box-sizing:border-box;-webkit-box-sizing:border-box;border-bottom:0.1em solid #ddd}div#message-text{font-size:1.4em;overflow:clip;display:inline}span.note p{margin:0}.image{z-index:2;background-color:transparent;border:transparent;height:4em;width:auto;display:block}';const ts=["xga","hd","full-hd","4k","4k2k","a4","a3","a2","a1","a0","letter","legal"],is=["landscape","portrait"],ss=class{constructor(i){t(this,i),h(this),this.errors=l(this),this.componentStyle=w(this)}validateFormat(t){const i="ERR_format";P(t)||ts.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`format: invalid value '${t}' is not supported. Valid values: ${ts.join(", ")}`})}validateOrientation(t){const i="ERR_orientation";P(t)||is.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`orientation: invalid value '${t}' is not supported. Valid values: ${is.join(", ")}`})}render(){return i(s,{key:"8a24c1c3d796d335826e9dec5e73415a44cf6a1e",format:this.format,orientation:this.orientation,style:this.prepareStyle()},i("slot",{key:"23a59d11c2ac469047e11a7bf189e041bb58928b"}))}prepareStyle(){return{"font-family":this.componentStyle((t=>t.global.fontFamily)),"font-size":`${this.componentStyle((t=>t.global.fontSizePx))}px`,"--bn-font-family":this.componentStyle((t=>t.global.fontFamily))||"'Noto Sans', sans-serif","--bn-font-size":`${this.componentStyle((t=>t.global.fontSizePx))||13.3333}px`,"--bn-font-color":this.componentStyle((t=>t.global.fontColor))||"#000000","--bn-font-background":this.componentStyle((t=>t.global.fontBackgroundColor))||"#ffffff"}}get element(){return e(this)}static get watchers(){return{format:[{validateFormat:0}],orientation:[{validateOrientation:0}]}}};ss.style=':host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);height:768px;width:1024px;display:flex;flex-direction:column;page-break-after:always;overflow:hidden}:host([format=xga]){height:768px;width:1024px}:host([format=xga][orientation=portrait]){height:1024px;width:768px}:host([format=xga][orientation=landscape]){height:768px;width:1024px}:host([format=hd]){height:720px;width:1280px}:host([format=hd][orientation=portrait]){height:1280px;width:720px}:host([format=hd][orientation=landscape]){height:720px;width:1280px}:host([format=full_hd]){height:1080px;width:1920px}:host([format=full_hd][orientation=portrait]){height:1920px;width:1080px}:host([format=full_hd][orientation=landscape]){height:1080px;width:1920px}:host([format="4k"]){height:2160px;width:3840px}:host([format="4k"][orientation=portrait]){height:3840px;width:2160px}:host([format="4k"][orientation=landscape]){height:2160px;width:3840px}:host([format="4k2k"]){height:2160px;width:4096px}:host([format="4k2k"][orientation=portrait]){height:4096px;width:2160px}:host([format="4k2k"][orientation=landscape]){height:2160px;width:4096px}:host([format=a6]){height:5.83in;width:4.13in}:host([format=a6][orientation=portrait]){height:5.83in;width:4.13in}:host([format=a6][orientation=landscape]){height:4.13in;width:5.83in}:host([format=a5]){height:8.27in;width:5.83in}:host([format=a5][orientation=portrait]){height:8.27in;width:5.83in}:host([format=a5][orientation=landscape]){height:5.83in;width:8.27in}:host([format=a4]){height:11.6in;width:8.17in}:host([format=a4][orientation=portrait]){height:11.6in;width:8.17in}:host([format=a4][orientation=landscape]){height:8.17in;width:11.6in}:host([format=a3]){height:16.54in;width:11.7in}:host([format=a3][orientation=portrait]){height:16.54in;width:11.7in}:host([format=a3][orientation=landscape]){height:11.7in;width:16.54in}:host([format=a2]){height:23.4in;width:16.54in}:host([format=a2][orientation=portrait]){height:23.4in;width:16.54in}:host([format=a2][orientation=landscape]){height:16.54in;width:23.4in}:host([format=a1]){height:33.1in;width:23.4in}:host([format=a1][orientation=portrait]){height:33.1in;width:23.4in}:host([format=a1][orientation=landscape]){height:23.4in;width:33.1in}:host([format=a0]){height:46.8in;width:33.1in}:host([format=a0][orientation=portrait]){height:46.8in;width:33.1in}:host([format=a0][orientation=landscape]){height:33.1in;width:46.8in}:host([format=letter]){height:11in;width:8.5in}:host([format=letter][orientation=portrait]){height:11in;width:8.5in}:host([format=letter][orientation=landscape]){height:8.5in;width:11in}:host([format=legal]){height:14in;width:8.5in}:host([format=legal][orientation=portrait]){height:14in;width:8.5in}:host([format=legal][orientation=landscape]){height:8.5in;width:14in}:host([format=tabloid]){height:17in;width:11in}:host([format=tabloid][orientation=portrait]){height:17in;width:11in}:host([format=tabloid][orientation=landscape]){height:11in;width:17in}:host([format=ledger]){height:11in;width:17in}:host([format=ledger][orientation=portrait]){height:17in;width:11in}:host([format=ledger][orientation=landscape]){height:11in;width:17in}';const es=class{constructor(i){t(this,i),h(this),this.errors=l(this)}connectedCallback(){this.stores=d(this.element),this.pushToStore()}disconnectedCallback(){this.removeEntryIfOurs(this.storedName)}onNameChange(t,i){const s=null==i?void 0:i.toString().trim();s&&s!==(null==t?void 0:t.toString().trim())&&this.removeEntryIfOurs(s),this.pushToStore()}onValueChange(){this.pushToStore()}removeEntryIfOurs(t){t&&this.stores&&(this.storedName===t&&this.stores.scalingGroups.state[t]===this.storedValue&&this.stores.scalingGroups.set(t,void 0),this.storedName===t&&(this.storedName=void 0,this.storedValue=void 0))}pushToStore(){var t;if(!this.stores)return;const i=null===(t=this.name)||void 0===t?void 0:t.toString().trim(),s=at(i);if("auto"===s.kind)return void this.errors.addOrReplace({id:"ERR_reserved_name",type:"warning",message:'bn-scaling-group: name "auto" is reserved and cannot be used.'});if(this.errors.remove("ERR_reserved_name"),!i)return void this.errors.addOrReplace({id:"ERR_empty_name",type:"warning",message:"bn-scaling-group: name is required."});if(this.errors.remove("ERR_empty_name"),"number"===s.kind)return void this.errors.addOrReplace({id:"ERR_numeric_name",type:"warning",message:`bn-scaling-group: name "${i}" is not allowed — it would be ambiguous with a numeric scaling value.`});this.errors.remove("ERR_numeric_name");const e=at(this.value);if("number"!==e.kind)return void this.errors.addOrReplace({id:"ERR_invalid_value",type:"warning",message:`bn-scaling-group: invalid value "${this.value}" — must be a positive number, optionally with k/M/G/T suffix.`});this.errors.remove("ERR_invalid_value");const n=this.stores.scalingGroups.state[i];void 0===n||n===e.value||this.storedName===i&&this.storedValue===n?this.errors.remove("WARN_duplicate_group"):this.errors.addOrReplace({id:"WARN_duplicate_group",type:"warning",message:`bn-scaling-group: "${i}" is already registered with a different value (${tt(n)}); overwriting.`}),this.storedName&&this.storedName!==i&&this.removeEntryIfOurs(this.storedName),this.stores.scalingGroups.set(i,e.value),this.storedName=i,this.storedValue=e.value}render(){return i(s,{key:"7b125b03953f91d15c6c9df7ca178c9f33b054cc"})}get element(){return e(this)}static get watchers(){return{name:[{onNameChange:0}],value:[{onValueChange:0}]}}};var ns,rs,as,os,hs;es.style="bn-scaling-group{display:none}",function(t){t[t.ALL=-1]="ALL"}(ns||(ns={})),function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(rs||(rs={})),function(t){t.LIST="list",t.SUM="sum",t.SUMNOTOTAL="sumnototal",t.OPT="opt",t.OPTNOTOTAL="optnototal"}(as||(as={})),function(t){t.ASC="asc",t.DESC="desc"}(os||(os={})),function(t){t.HEADER="HEADER",t.GROUPHEAD="GROUPHEAD",t.SEPERATORLINE="SEPERATORLINE",t.SUM="SUM",t.GROUPSUM="GROUP_SUM",t.DRILLELEMENT="DRILLELEMENT",t.STANDARD="STANDARD",t.PARTELEMENT="PARTELEMENT",t.ENTRY="ENTRY"}(hs||(hs={}));const ls="none",cs="setname";function ds(t){return t===cs?"COALESCE([setname],[setName])":`normalizeDate([date], '${t}')`}function us(t){if(null==t)return"";if("string"==typeof t)return t.trim();const i=ps(t);return i?i.toISO():String(t)}function ps(t){if(null!=t){if("string"==typeof t){const i=g.fromISO(t);return i.isValid?i:void 0}if("number"==typeof t){const i=g.fromMillis(t);return i.isValid?i:void 0}if("boolean"==typeof t.isValid)return t.isValid?t:void 0}}const fs=class{validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("ERR_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"ERR_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("ERR_scale")}constructor(i){t(this,i),this.layoutObserver=null,this._lastScaledParentWidth=0,this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.hasBlankSetnames=!1,this.sumTitle="",this.filter="",this.measureUnit="",this.barColumnWidth="w10",this.unitScaling="100",this.percentageScaling="2",this.pixelPerUnitGroupMap=new Map,this.dataFormat="decimal",this.grouped="false",this.showMeasureScale="false",this.showGroupTitle="true",this.type="list",this.limit=0,this.thereof="[]",this.partof="[]",this.order="category",this.orderDirection="asc",this.measureType="volume",this.measureScale="greatest",this.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.categoryWidth="w15",this.columnthereof=null,this.interval="none",this.tableAttributes="",this._autoScaleGuard=!1,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=t=>{var i,s,e,n;this.lastAutoScalingReport={unit:null!==(i=t.unit)&&void 0!==i?i:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(e=t.percentage)&&void 0!==e?e:null===(n=this.lastAutoScalingReport)||void 0===n?void 0:n.percentage};const r=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t);if(void 0!==t.unit&&t.unit>0&&this.autoUnitWarningActive){const i=1/t.unit;r(i,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=i,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: invalid value "${this.unitScaling}" — auto-fitted to 1 em ≈ ${tt(i)} units.`}))}if(void 0!==t.percentage&&t.percentage>0&&this.autoPctWarningActive){const i=1/t.percentage;r(i,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=i,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: invalid value "${this.percentageScaling}" — auto-fitted to 1 em ≈ ${tt(i)} percentage points.`}))}},k(this),h(this),this.errors=l(this),ot(this),this.componentStyle=w(this),this.ruleSetConfig=ht(this),it(this,((t,i)=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1,this.hasBlankSetnames=Array.isArray(i)&&i.some((t=>{var i;return P(null!==(i=null==t?void 0:t.setname)&&void 0!==i?i:null==t?void 0:t.setName)}))}),((t,i)=>{this.datasetMeta=i})),this.t=st(this).t,this.resolveInherited=et(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}])}validateScenario(t){const i="ERR_scenarios";if(K(t))return void this.errors.remove(i);const s=y(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+(null==s?void 0:s.toString())+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances";if(K(t))return void this.errors.remove(i);const s=S(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateBarColumns(t){const i="ERR_barColumns";if(P(t))return void this.errors.remove(i);const s=D(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"barColumns: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateBarColumnWidth(t){const i="ERR_barColumnWidth";G(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"barColumnWidth: invalid value '"+t+"' is not supported."})}validateUnitScaling(t){const i="ERR_unitScaling";"invalid"===Q(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="ERR_percentageScaling";"invalid"===Q(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validateDataFormat(t){const i="ERR_dataFormat";W(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormat: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateGrouped(t){const i="ERR_grouped";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"grouped: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowMeasureScale(t){const i="ERR_grouped";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowGroupTitle(t){const i="ERR_showGroupTitle";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showGroupTitle: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateType(t){const i="ERR_type";F(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"type: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateLimit(t){const i="ERR_limit";M(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateThereOf(t){const i="ERR_thereof",s=I(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"ThereOf: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validatePartOf(t){const i="ERR_partof",s=Y(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"partof: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderList(t){const i="ERR_order";if(K(t))return void this.errors.remove(i);const s=O(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="ERR_orderDirection";K(t)||R(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasureType(t){const i="ERR_measureType";z(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureType: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasureScale(t){const i="ERR_measureScale";_(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDataFormatDigitsDecimal(t){const i="ERR_dataFormatDigitsDecimal";M(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsDecimal: invalid value(s) '"+t+"' are not supported."})}validateDateFormatDigitsPercent(t){const i="ERR_dataFormatDigitsPercent";M(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsPercent: invalid value(s) '"+t+"' are not supported."})}validateCategoryWidth(t){const i="ERR_categoryWidth";B(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"categoryWidth: invalid value(s) '"+t+"' are not supported."})}validateColumnThereOf(t){const i=H(t),s="ERR_categorythereof";i.length>0?this.errors.addOrReplace({id:s,type:"warning",message:"columnthereof: invalid value(s) '"+JSON.stringify(i)+"' are not supported."}):this.errors.remove(s)}validateInterval(t){const i="ERR_interval",s=null==t?void 0:t.trim().toLowerCase();P(t)||s===ls||s===cs||L(s)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"interval: invalid value '"+t+"' is not supported."})}validateTableAttributes(t){const i="ERR_attributes",s=V(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"attributes: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateDataFormat(this.dataFormat),this.validateGrouped(this.grouped),this.validateShowGroupTitle(this.showGroupTitle),this.validateType(this.type),this.validateLimit(this.limit),this.validateThereOf(this.thereof),this.validatePartOf(this.partof),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDateFormatDigitsPercent(this.dataFormatDigitsPercent),this.validateCategoryWidth(this.categoryWidth),this.validateMeasureType(this.measureType),this.validateMeasureScale(this.measureScale),this.validateColumnThereOf(this.columnthereof),this.validateInterval(this.interval),this.validateTableAttributes(this.tableAttributes),this.validateShowMeasureScale(this.showMeasureScale),this.validateBarColumns(this.barColumns),this.validateBarColumnWidth(this.barColumnWidth),this.validateUnitScaling(this.unitScaling),this.validatePercentageScaling(this.percentageScaling),this.validateScaling(this.scale)}componentDidLoad(){this.layoutObserver=lt(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=nt(this.element);t>0&&Math.abs(t-this._lastScaledParentWidth)>2&&(this._lastScaledParentWidth=t,r(this))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}componentDidRender(){const{mode:t}=rt(this.scale);if("auto"!==t&&"empty"!==t)return void(this._autoScaleGuard=!1);if(this._autoScaleGuard)return void(this._autoScaleGuard=!1);const i=this.element,{width:s}=nt(i);if(s<=0)return;this._lastScaledParentWidth=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollWidth,a=this.appliedScaleFactor;if(r<=s+1)return void this.errors.remove("AUTO_scale");const o=Math.max(.3,a*(s-1)/r);Math.abs(o-a)<.001||(i.style.setProperty("--bn-font-size",e*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled table by factor ${o.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,n((()=>{this.appliedScaleFactor=o})))}prepareDataFormat(){var t;return mt[null===(t=this.dataFormat)||void 0===t?void 0:t.toUpperCase()]}prepareGrouped(){return"true"===this.grouped}prepareShowGroupTitle(){return"true"===this.showGroupTitle}prepareTableType(){var t;return as[null===(t=this.type)||void 0===t?void 0:t.toUpperCase()]}prepareLimit(){return Math.floor(Number(this.limit)||0)}prepareThereOf(){return null==this.thereof||""===this.thereof.trim()?[]:JSON.parse(this.thereof)}preparePartOf(){return null==this.partof||""===this.partof.trim()?[]:JSON.parse(this.partof)}prepareOrder(){var t;const i=this.resolveInherited("order",this.order),s=this.resolveInherited("orderDirection",this.orderDirection),e=null!=i?i:this.order,n=null!=s?s:this.orderDirection,r="auto"===(null==e?void 0:e.trim().toLowerCase());let a=e;return r&&(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)&&(a=this.datasetMeta.suggestedOrder),{hierarchy:a.split(",").map((t=>_t[null==t?void 0:t.toUpperCase()])),direction:xt[null==n?void 0:n.toUpperCase()]}}prepareI18nMode(){return bt.META}prepareI18n(){const t=p,i=new Map(["in","category","operation","there_of","part_of","SUM_TOTAL","no-data","REST"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries()])}prepareDataFormatDigits(){return{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal}}prepareScenarios(){var t,i,s,e,n,r,a,o,h;const l=this.resolveInherited("scenarios",this.scenarios),c=this.resolveInherited("variances",this.variances);if(void 0!==l||void 0!==c){this.errors.remove("AUTO_scenarios");let i=[];return void 0!==l?i=i.concat(l.split(",")):P(this.scenarios)||(i=i.concat(this.scenarios.split(","))),void 0!==c?i=i.concat(c.split(",")):(null===(t=this.variances)||void 0===t?void 0:t.trim().length)>0&&(i=i.concat(this.variances.split(","))),i.map((t=>t.trim()))}const d="auto"===(null===(i=this.scenarios)||void 0===i?void 0:i.trim().toLowerCase());if((P(this.scenarios)||d)&&P(this.variances))return(null===(e=null===(s=this.datasetMeta)||void 0===s?void 0:s.availableScenarios)||void 0===e?void 0:e.length)>0?(d?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),this.datasetMeta.availableScenarios):[];let u=[];return d||P(this.scenarios)?(null===(r=null===(n=this.datasetMeta)||void 0===n?void 0:n.availableScenarios)||void 0===r?void 0:r.length)>0&&(d?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),u=u.concat(this.datasetMeta.availableScenarios)):(this.errors.remove("AUTO_scenarios"),u=u.concat(null===(a=this.scenarios)||void 0===a?void 0:a.split(","))),(null===(o=this.variances)||void 0===o?void 0:o.trim().length)>0&&(u=u.concat(null===(h=this.variances)||void 0===h?void 0:h.split(","))),u.map((t=>t.trim()))}prepareCategoryWidth(){var t;return P(this.categoryWidth)?wt.INF:wt[null===(t=this.categoryWidth)||void 0===t?void 0:t.toUpperCase()]}prepareMeasureScale(){return P(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareMeasureType(){var t;return P(this.measureType)?yt.VOLUME:yt[null===(t=this.measureType)||void 0===t?void 0:t.toUpperCase()]}prepareColumnThereOf(){if(null==this.columnthereof||""===this.columnthereof.trim())return new Map;const t=JSON.parse(this.columnthereof),i=new Map;for(const[s,e]of Object.entries(t))!1===i.has(e.scenario)&&i.set(e.scenario,[]),i.get(e.scenario).push(e);return i}prepareInterval(){var t;const i="ERR_intervalConflict",s="ERR_intervalNoDate",e="ERR_intervalSetname",n=P(this.interval)?ls:this.interval.trim().toLowerCase();return n!==ls&&n!==cs&&!L(n)||n===ls?(this.errors.remove(i),this.errors.remove(s),this.errors.remove(e),ls):null!=this.columnthereof&&""!==this.columnthereof.trim()?(this.errors.addOrReplace({id:i,type:"warning",message:"interval: cannot be combined with columnthereof, interval is ignored."}),this.errors.remove(s),this.errors.remove(e),ls):(this.errors.remove(i),n===cs?(this.hasBlankSetnames?this.errors.addOrReplace({id:e,type:"warning",message:"interval: rows with blank setname found, they are grouped under '—'."}):this.errors.remove(e),this.errors.remove(s),cs):(this.errors.remove(e),this.datasetMeta&&!(null===(t=this.datasetMeta.dateRange)||void 0===t?void 0:t.hasData)?(this.errors.addOrReplace({id:s,type:"warning",message:"interval: dataset has no date values, interval is ignored."}),ls):(this.errors.remove(s),n)))}prepareAttributes(){if(null==this.tableAttributes||""===this.tableAttributes.trim())return[];try{const t=JSON.parse(this.tableAttributes);return null===t||"object"!=typeof t||t instanceof Array?[]:Object.entries(t).map((([t,i],s)=>"string"==typeof i?j(t,`attr_${s}`,i):null)).filter((t=>null!==t))}catch(t){return[]}}prepareSumTitle(){return""===this.sumTitle||null==this.sumTitle?"SUM_TOTAL":this.sumTitle}prepareShowMeasureScale(){return"true"===this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareBarColumnWidth(){var t;const i=null===(t=this.barColumnWidth)||void 0===t?void 0:t.toUpperCase(),s=$t[i];return s?St[s]:St[$t.W10]}prepareBarColumns(){return P(this.barColumns)?[]:this.barColumns.split(",").map((t=>t.trim()))}prepareUnitScaling(){const t=Q(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,1/t.value):"auto"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: invalid value "${t.raw}" — auto-fitting to the bar column width.`}),0)}preparePercentageScaling(){const t=Q(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,1/t.value):"auto"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: invalid value "${t.raw}" — auto-fitting to the pin area.`}),0)}getDataStructure(){return{ITableDataRow:{setName:{type:"string",isOptional:!1,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}async getLayoutState(t){var i,s,e,n;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",a=Ct(this.element),o=this.getEffectiveScaleFactor(),h=Number.isFinite(o)&&o>0?o:1,l=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*h,c={version:Pt,tag:this.element.localName,id:At(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:Lt(this.element,a),em:{fontSizePx:l,appliedScaleFactor:h},regions:[],metadata:{},diagnostics:Tt(this.element),scaling:this.resolveScalingInfo(l)},d=null===(e=this.element.shadowRoot)||void 0===e?void 0:e.querySelector("ibcs-table");if(d){const t=null!==(n=d.scenarios)&&void 0!==n?n:[];if(c.metadata.scenarios=t.filter((t=>!t.startsWith("d"))),c.metadata.variances=t.filter((t=>t.startsWith("d"))),"function"==typeof d.getLayoutDetail){const t=await d.getLayoutDetail(a,r);c.regions=t.regions,c.metadata=Object.assign(Object.assign({},c.metadata),t.metadata),c.diagnostics=[...c.diagnostics,...t.diagnostics],t.elements&&(c.elements=t.elements),t.table&&(c.table=t.table)}}return c}resolveScalingInfo(t){var i,s;const e={},n=Q(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===n.kind)e.unitMode="fixed",e.unitsPerEm=n.value,e.unitPxPerUnit=t/n.value;else{e.unitMode="auto";const s=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==s&&s>0&&(e.unitsPerEm=1/s,e.unitPxPerUnit=s*t)}const r=Q(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)e.percentageMode="fixed",e.percentagePointsPerEm=r.value,e.percentagePxPerPoint=t/r.value;else{e.percentageMode="auto";const i=null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.percentage;void 0!==i&&i>0&&(e.percentagePointsPerEm=1/i,e.percentagePxPerPoint=i*t)}return e}getEffectiveScaleFactor(){const{mode:t,factor:i}=rt(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const a=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":a*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles(),e=this.getEffectiveScaleFactor();return i(s,{key:"0581f45b1d4af5a611e295afa924b3564ad4e916",style:t},i("div",{key:"461dfbb4bbaf75c3aa5df8aad21056dfb01be26c"},i("ibcs-table",{key:"c17a4104687aee9002144e2800b23b8c99c811a7",tableName:this.datasetName,dataVersion:this.dataVersion,sumTitle:this.prepareSumTitle(),scenarios:this.prepareScenarios(),scenariosDataFormat:this.prepareDataFormat(),grouped:this.prepareGrouped(),limit:this.prepareLimit(),showGroupTitle:this.prepareShowGroupTitle(),thereof:this.prepareThereOf(),partof:this.preparePartOf(),order:this.prepareOrder(),categorythereof:this.prepareColumnThereOf(),attributeColumns:this.prepareAttributes(),type:this.prepareTableType(),categoryWidth:this.prepareCategoryWidth(),dataFormatDigits:this.prepareDataFormatDigits(),i18n:this.prepareI18n(),i18nMode:this.prepareI18nMode(),measureScale:this.prepareMeasureScale(),measureType:this.prepareMeasureType(),measureUnit:this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(),filter:this.prepareFilter(),barColumns:this.prepareBarColumns(),interval:this.prepareInterval(),barColumnMaxWidth:this.prepareBarColumnWidth(),unitScaling:this.prepareUnitScaling(),percentageScaling:this.preparePercentageScaling(),reportAutoScaling:this.handleAutoScalingReport,scaleFactor:e,ruleSetConfig:this.ruleSetConfig(),selectedStyle:this.selectedStyle})))}get element(){return e(this)}static get watchers(){return{scale:[{validateScaling:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat:0}],grouped:[{validateGrouped:0}],showMeasureScale:[{validateShowMeasureScale:0}],showGroupTitle:[{validateShowGroupTitle:0}],type:[{validateType:0}],limit:[{validateLimit:0}],thereof:[{validateThereOf:0}],partof:[{validatePartOf:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],measureType:[{validateMeasureType:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDateFormatDigitsPercent:0}],categoryWidth:[{validateCategoryWidth:0}],columnthereof:[{validateColumnThereOf:0}],interval:[{validateInterval:0}],tableAttributes:[{validateTableAttributes:0}]}}};fs.style=":host{display:inline-block;position:relative;overflow:hidden}";const vs=class{constructor(i){t(this,i),this.businessUnit="",this.order="category",this.orderDirection="asc",this.dateFormat="none",this.dateLink="none",k(this),h(this),this.t=st(this).t,this.errors=l(this),this.componentStyle=w(this),this.ruleSetConfig=ht(this)}validateScenario(t){const i="ERR_scenarios",s=y(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+(null==s?void 0:s.toString())+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances",s=S(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+(null==s?void 0:s.toString())+"' are not supported."}):this.errors.remove(i)}validateOrder(t){const i=O(t),s="ERR_order";i.length>0?this.errors.addOrReplace({id:s,type:"warning",message:"order: invalid value(s) '"+(null==i?void 0:i.toString())+"' are not supported."}):this.errors.remove(s)}validateOrderDirection(t){const i="ERR_orderDirection";R(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasures(t){const i="ERR_measures",s=X(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"measures: invalid value(s) '"+(null==s?void 0:s.toString())+'\' are not supported. Valid format example: [{"name": "Bruttoumsatz", "unit": "mEUR"}]'}):this.errors.remove(i)}validateDateStart(t){const i="ERR_dateStart";J(t)||P(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateStart: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateEnd(t){const i="ERR_dateEnd";J(t)||P(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateStart: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateFormat(t){const i="ERR_dateFormat";L(t)||P(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateFormat: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateLink(t){const i="ERR_dateLink";q(t)||P(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateLink: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateMeasures(this.measures),this.validateDateStart(this.dateStart),this.validateDateEnd(this.dateEnd),this.validateDateFormat(this.dateFormat),this.validateDateLink(this.dateLink),this.validateOrderDirection(this.orderDirection),this.validateOrder(this.order)}prepareI18n(){const t=p,i=new Map(["SEPERATOR_WS","in","CONNECTOR_WS"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries()])}prepareI18nMode(){return bt.META}prepareLocale(){return d(this.element).context.state.locale||"de"}prepareTitleOrder(){var t;return P(this.order)||P(this.orderDirection)?null:{hierarchy:this.order.split(",").map((t=>t.trim())),direction:xt[null===(t=this.orderDirection)||void 0===t?void 0:t.toUpperCase()]}}prepareTitleTimePeriod(){var t,i;return P(this.dateStart)&&P(this.dateEnd)||P(this.dateLink)?null:{start:g.fromISO(this.dateStart),end:g.fromISO(this.dateEnd),format:C[null===(t=this.dateFormat)||void 0===t?void 0:t.toUpperCase()],link:Z[null===(i=this.dateLink)||void 0===i?void 0:i.toUpperCase()]}}prepareMeasures(){return P(this.measures)?[]:JSON.parse(this.measures)}prepareScenarios(){var t,i,s,e;if(P(this.scenarios)&&P(this.variances))return[];let n=[];return(null===(t=this.scenarios)||void 0===t?void 0:t.trim().length)>0&&(n=n.concat(null===(i=this.scenarios)||void 0===i?void 0:i.split(","))),(null===(s=this.variances)||void 0===s?void 0:s.trim().length)>0&&(n=n.concat(null===(e=this.variances)||void 0===e?void 0:e.split(","))),n.map((t=>t.trim()))}prepareBusinessUnit(){return P(this.businessUnit)||"null"===this.businessUnit?null:this.businessUnit}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles();return i(s,{key:"9b9c216010209bd5acaaeee39b6b5d8a8972710f",style:t},i("ibcs-title",{key:"5ccf7ddc7a4fbf1308d1d09d80f5b8aa3cbf6cbd",businessUnit:this.prepareBusinessUnit(),scenarios:this.prepareScenarios(),measures:this.prepareMeasures(),timeperiod:this.prepareTitleTimePeriod(),order:this.prepareTitleOrder(),i18n:this.prepareI18n(),"i18n-mode":this.prepareI18nMode(),locale:this.prepareLocale(),ruleSetConfig:this.ruleSetConfig()}))}get element(){return e(this)}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],measures:[{validateMeasures:0}],dateStart:[{validateDateStart:0}],dateEnd:[{validateDateEnd:0}],dateFormat:[{validateDateFormat:0}],dateLink:[{validateDateLink:0}]}}};vs.style=':host{padding:0.5em;margin-bottom:0.5em;box-sizing:border-box;-webkit-box-sizing:border-box;width:100%;display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}';let gs=class{constructor(t,i,s,e,n,r,a,o,h=!1){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=e,this.leftSideLengthSync=n,this.topSideLabelHeight=r>0?this.fontSize:0,this.hasStackedHeaders=h,this.leftSideLabelLength=this.calculateSideLabelLength(r,a,o),this.calculateSpacings(),this.calculateCategoryPosition(),this.calculateAxisPosition()}getBarPositionX(){return this.axisPosition.x}getBarCenterPositionY(t){return this.categoryPosition.y+this.spacings.scenarioOffset+t*this.spacings.categoryWidth}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.spacings.barWidth-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,e){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<e/2&&(this.axisPosition.x=e/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(){return this.getAxisPositionY()+(this.numberOfColumns+.5)*this.spacings.categoryWidth}getScenarioLabelPositionOffsetY(t){if(t){const t=.5*this.getBarWidth()+this.spacings.scenarioLabelToBar;return 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 e=t/2;let n=i;return e>n&&(n=e),s>n&&(n=s),n}},ms=class{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}},bs=class{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}},ws=class{constructor(t){this.container=new Wt,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 ys,Ss,$s;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(ys||(ys={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(Ss||(Ss={})),function(t){t[t.Y=1e24]="Y",t[t.Z=1e21]="Z",t[t.E=1e18]="E",t[t.P=1e15]="P",t[t.T=1e12]="T",t[t.G=1e9]="G",t[t.M=1e6]="M",t[t.k=1e3]="k",t[t.h=100]="h",t[t.da=10]="da",t[t.d=.1]="d",t[t.c=.01]="c",t[t.m=.001]="m",t[t.my=1e-6]="my",t[t.n=1e-9]="n",t[t.p=1e-12]="p",t[t.f=1e-15]="f",t[t.a=1e-18]="a",t[t.z=1e-21]="z",t[t.y=1e-24]="y"}($s||($s={}));class Os{static calculateMeasureScale(t,i,s,e){var n,r;if("_"===e)return new Jt;if("μ"===e&&(e="my"),null!=e&&[...this.unitsLeast,...this.unitsGreat].includes(e))return this.lookupPrefix(e);if(0===s.length||!i)return new Jt;const a=`SELECT MAX(GREATEST(${s.filter((t=>3===t.length)).map((t=>"ABS("+t+")")).toString()})) as prefixvalue\n FROM ${i}`,o=`SELECT MIN(LEAST(${s.filter((t=>3===t.length)).map((t=>"ABS("+t+")")).toString()})) as prefixvalue\n FROM ${i}`;let h,l=a;"LEAST"===(null==e?void 0:e.toUpperCase())&&(l=o);try{h=null!==(r=null===(n=t.exec(l)[0])||void 0===n?void 0:n.prefixvalue)&&void 0!==r?r:0}catch(t){return console.error("DataAnalyzer: measure-scale query failed",l,t),new Jt}return this.determinePrefix(Math.abs(h))}static determinePrefix(t){if(!Number.isFinite(t)||t<=0)return new Jt;if(t>=1e3){const i=Math.min(Math.floor(Math.log10(t)/3),this.unitsGreat.length)-1;return new Jt(this.unitsGreat[i],Math.pow(1e3,i+1))}if(t<=.001){const i=Math.min(-Math.floor(Math.log10(t)/3),this.unitsLeast.length)-1;return new Jt(this.unitsLeast[i],Math.pow(1e3,-(i+1)))}return new Jt}static lookupPrefix(t){return new Jt(t,$s[t])}}Os.unitsGreat=["k","M","G","T","P","E","Z","Y"],Os.unitsLeast=["m","my","n","p","f","a","z","y"];class Rs{adapt(t){return Et.adaptDefaultString(t)}default(){return""}}class Ms{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 kt(new Rs).default(),this.level=dt.CATEGORY,this.filter="",this.measureScale=new Jt,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.stackConfig=null}}class xs{constructor(t,i,s,e,n,r){this.dataRowAdapter=t,this.orderAdapter=i,this.stringAdapter=s,this.dataFormatDigitsAdapter=e,this.db=n,this.fromExpr=r}adapt(t){const i=Et.adaptArray(t.data,this.dataRowAdapter),s=Et.adaptArray(t.scenarios,this.stringAdapter),e=new Ms(i,s);return Ot.isArray(t.variances)&&(e.variances=Et.adaptArray(t.variances,this.stringAdapter)),Ot.isString(t.title)&&(e.title=t.title),Ot.isBoolean(t.hideCategories)&&(e.hideCategories=t.hideCategories),Ot.isNumber(t.pixelPerUnit)&&(e.pixelPerUnit=t.pixelPerUnit),Ot.isNumber(t.pixelPerPercentage)&&(e.pixelPerPercentage=t.pixelPerPercentage),Ot.isNumber(t.limit)&&(e.limit=t.limit),Ot.isExisting(t.sortOrder)&&(e.sortOrder=this.orderAdapter.adapt(t.sortOrder)),Ot.isExisting(t.level)&&(e.level=t.level),Ot.isString(t.filter)&&(e.filter=t.filter.trim()),Ot.isExisting(t.measureScale)&&(e.measureScale=Os.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale)),Ot.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),Ot.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),Ot.isExisting(t.dataFormatDigits)&&(e.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),Ot.isExisting(t.stackConfig)&&(e.stackConfig=t.stackConfig),e}default(){return new Ms([],[])}}let _s=class{constructor(t,i,s,e){this.value=t,this.scenario=i,this.pixelPerUnit=s||1,this.variance="neg"===e||e===Cs.NEG?Cs.NEG:"pos"===e||e===Cs.POS?Cs.POS:Cs.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:Cs.NEU===this.variance?Cs.NEU:Cs.POS===this.variance?Cs.NEG:Cs.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 Es{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 ks{constructor(){}adapt(t){const i=new Es;return Ot.isOperator(t.operation)&&(i.operation=t.operation),Ot.isNumber(t.rowGroupIndex)&&Ot.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),Ot.isNumber(t.categoryIndex)&&Ot.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),Ot.isNumber(t.subCategoryIndex)&&Ot.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),Ot.isNumber(t.columnGroupIndex)&&Ot.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),Ot.isNumber(t.columnSubGroupIndex)&&Ot.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 Es}setActualValues(t,i){Ot.isNumber(t.ac1)&&(i.ac1=t.ac1),Ot.isNumber(t.ac2)&&(i.ac2=t.ac2),Ot.isNumber(t.ac3)&&(i.ac3=t.ac3),Ot.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){Ot.isNumber(t.pl1)&&(i.pl1=t.pl1),Ot.isNumber(t.pl2)&&(i.pl2=t.pl2),Ot.isNumber(t.pl3)&&(i.pl3=t.pl3),Ot.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){Ot.isNumber(t.pp1)&&(i.pp1=t.pp1),Ot.isNumber(t.pp2)&&(i.pp2=t.pp2),Ot.isNumber(t.pp3)&&(i.pp3=t.pp3),Ot.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){Ot.isNumber(t.fc1)&&(i.fc1=t.fc1),Ot.isNumber(t.fc2)&&(i.fc2=t.fc2),Ot.isNumber(t.fc3)&&(i.fc3=t.fc3),Ot.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class Ps{constructor(t,i,s,e,n,r){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=e,this.varianceStyles=n,this.padding=r,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"]}}class Ts{constructor(t,i,s,e,n){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=e,this.paddingadapter=n}adapt(t){const i=new Ps(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return Ot.isExisting(t)&&(Ot.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),Ot.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),Ot.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),Ot.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),Ot.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),Ot.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 bs(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new Ps(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}class Ls{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 As{adapt(t){const i=new Ls;return Ot.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),Ot.isNumber(t.scenarioLabelToBar)&&(i.scenarioLabelToBar=t.scenarioLabelToBar),Ot.isNumber(t.labelToBar)&&(i.labelToBar=t.labelToBar),Ot.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),Ot.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),Ot.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),Ot.isNumber(t.barWidth)&&(i.barWidth=t.barWidth),Ot.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),Ot.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),Ot.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),Ot.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),Ot.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),Ot.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),Ot.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),Ot.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new Ls}}var Cs,Ns,Us;!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"}(Cs||(Cs={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(Ns||(Ns={})),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"}(Us||(Us={}));class Ds{constructor(t,i,s,e,n,r,a,o){this.group=null,this.segmentFillColor=null,this.maxWidth=null,this.ID_SCENARIOLABEL="Label",this.CSS_CATEGORIES="categories",this.x=i,this.y=s,this.value=n,null!=t&&(this.group=t.group().id(this.createElementID(t.toString(),e))),this.styles=r,this.isVarianceLabel=!1,this.isRelativeLabel=!1,this.verticalHookLocation=a||Us.Top,this.horizontalHookLocation=o||Us.Left}setToVarianceLabel(){return this.isVarianceLabel=!0,this}setToRelativeVarianceLabel(){return this.isVarianceLabel=!0,this.isRelativeLabel=!0,this}setSegmentFill(t){return this.segmentFillColor=t,this}setMaxWidth(t){return this.maxWidth=t,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 Jt){var s;if(this.isEmpty())return this;const e=this.group;let n;const r=this.styles.fontStyles.background||"#ffffff";let a="",o="start";if(!1===Number.isNaN(Number(this.value))){let s=t.percent,e=t.percent,r=1,h="percent";!1===this.isRelativeLabel&&(s=t.decimal,e=t.decimal,r=i.value,h="decimal"),n=Gt.number(Number(this.value),h,s,e,r),Number(this.value)<0&&(o="end"),this.isVarianceLabel&&Number(this.value)>=0&&(a="+")}else n=""+this.value,o="start";const h=e.text(a+n);h.move(this.x,this.y);const l=h.bbox(),c=l.w,d=l.h;return null!=this.maxWidth&&c>this.maxWidth?(null===(s=this.group)||void 0===s||s.remove(),this.group=null,this):(this.horizontalHookLocation===Us.Right?(o="end",h.move(h.x()-h.length(),h.y())):this.horizontalHookLocation===Us.Center&&(o="middle",h.move(h.x()-h.length()/2,h.y())),this.verticalHookLocation===Us.Center?h.move(h.x(),h.y()-d/2):this.verticalHookLocation===Us.Bottom&&h.move(h.x(),h.y()-d),h.font({anchor:o}),null!=this.segmentFillColor?h.fill(qt(this.segmentFillColor)):null==e||e.rect(c,.9*d).stroke(r).fill(r).opacity(.7).move(h.x(),h.y()+.1*d).insertBefore(h),this)}isEmpty(){return null==this.value||""===this.value}setPos(t,i){return this.x=t,this.y=i,this}}let Gs=class{constructor(t,i,s,e){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=e,this.label=new Ds(s,this.position.getAxisTitlePositionX(),this.position.getAxisTitlePositionY(),this.ID_AXIS_TITLE,this.labelText,this.style,Us.Bottom,Us.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 Ws{constructor(t,i,s,e,n,r,a,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=e,this.isPrimaryBar=n,this.position=t,this.barStyles=i.barStyles,this.overflowConfig=o,this.scenarioGroup=r,this.styles=i,null!=r&&(this.barGroup=r.group().id(r.toString()+"_"+this.ID_RECT)),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0;let i=Us.Left;s.value<0&&(i=Us.Right),this.dimensions=this.createDimensions(t,s,e,n),this.label=new Ds(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,Us.Center,i),this.scenarioLabel=this.getScenarioLabel(a)}}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}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 Jt){if(this.isEmpty()||null==this.dataPoint.getScenario())return this;let s=this.barStyles.getSVGStyle(this.dataPoint.getScenario());this.isVarianceBar&&(s=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()));const e=this.convertToSVGStyle(s,"stroke");let n=this.convertToSVGStyle(s,"fill");const r=this.barStyles.getSVGStyle(this.dataPoint.getScenario()).fillpattern;if(null!=r){const t=this.styles.pattern.get(r);null!=t&&(n=t.pattern)}null!=this.barGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(n,e):this.barGroup.rect(this.dimensions.barLength,this.position.getBarWidth()).fill(n).stroke(e).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(),e=this.position.getBarWidth(),n=this.dimensions.barLength,{breakGap:r}=this.overflowConfig;this.dataPoint.getScaledUnit()<0?(this.barGroup.rect(n,e).fill(t).stroke(i).x(s-n).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,e).fill(t).stroke(i).x(s-n-r-this.overdriveWidth).cy(this.dimensions.yPos),this.drawBreakIndicator(s-n-r,r)):(this.barGroup.rect(n,e).fill(t).stroke(i).x(s).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,e).fill(t).stroke(i).x(s+n+r).cy(this.dimensions.yPos),this.drawBreakIndicator(s+n,r))}drawBreakIndicator(t,i){if(!this.barGroup)return;const s=this.position.getBarWidth(),e=this.dimensions.yPos-s/2,n=t+i/2,r=.35*i,a=s/3;let o=`M ${n-r} ${e}`;for(let t=0;t<3;t++)o+=` L ${n-r-.3*i} ${e+a*(t+.5)} L ${n-r} ${e+a*(t+1)}`;let h=`M ${n+r} ${e}`;for(let t=0;t<3;t++)h+=` L ${n+r+.3*i} ${e+a*(t+.5)} L ${n+r} ${e+a*(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(h).fill("none").stroke({color:"#000000",width:1})}createDimensions(t,i,s,e){const n=i.getScaledUnit(),r=Math.abs(n);if(this.overflowConfig&&r>0){const a="ac"===i.getScenario()?this.overflowConfig.cutWidth:this.overflowConfig.cutWidth-this.overflowConfig.scenarioCutOffset;if(r>a){this.isOverflowing=!0;const{breakGap:i,overdriveZoneWidth:o,maxOverflow:h}=this.overflowConfig;this.overdriveWidth=h>0?(r-a)/h*o:0;const l=a+i+this.overdriveWidth;return n<0?{clipped:!1,barLength:a,xPos:t.getBarPositionX()-a,yPos:t.getBarPositionY(s,e),labelXPos:t.getLabelPositionX(-l),scenarioLabelXPos:t.getBarPositionX()-.5*a,scenarioLabelYPos:t.getBarPositionY(s,e)+t.getScenarioLabelPositionOffsetY(e)}:{clipped:!1,barLength:a,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,e),labelXPos:t.getLabelPositionX(l),scenarioLabelXPos:t.getBarPositionX()+.5*a,scenarioLabelYPos:t.getBarPositionY(s,e)+t.getScenarioLabelPositionOffsetY(e)}}}return n<0?{clipped:!1,barLength:r,xPos:t.getBarPositionX()+n,yPos:t.getBarPositionY(s,e),labelXPos:this.position.getLabelPositionX(n),scenarioLabelXPos:this.position.getBarPositionX()-.5*r,scenarioLabelYPos:this.position.getBarPositionY(s,e)+this.position.getScenarioLabelPositionOffsetY(e)}:{clipped:!1,barLength:n,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,e),labelXPos:this.position.getLabelPositionX(n),scenarioLabelXPos:this.position.getBarPositionX()+.5*r,scenarioLabelYPos:this.position.getBarPositionY(s,e)+this.position.getScenarioLabelPositionOffsetY(e)}}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.isVarianceBar||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw()}drawBarDataLabel(t,i=new Jt){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){return new Ds(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,this.isPrimaryBar?Us.Top:Us.Bottom,Us.Center)}}let Fs=class{constructor(t,i,s,e,n,r,a,o,h){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=n,this.barStyles=n?n.barStyles:null,this.scenario=e,!0!==(null==r?void 0:r.isEmpty())&&(this.hasData=!0,this.dimensions=this.createMarkerDimensions(r,a,h),this.scenarioLabel=this.getScenarioLabel(o,n,h))}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 Ds(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,s?Us.Bottom:Us.Top,Us.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.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),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)}},Is=class{constructor(t,i,s,e,n){if(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=e,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=n,this.styles=i,this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0,this.dimensions=this.createDimensions(t,s,e);let i=Us.Left;s.value<0&&(i=Us.Right),this.label=new Ds(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,Us.Center,i),this.label.setToRelativeVarianceLabel()}}updateLabelGroup(t){var i;return this.isEmpty()||null==t||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(){var t;if(this.isEmpty())return this;if(null==this.dimensions)return this;const i=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()),s=i.stroke;let e=i.fill;const n=this.barStyles[this.dataPoint.getScenario()];if(null!=n&&n.fillpattern){const t=this.styles.pattern.get(n.fillpattern);null!=t&&null!=t.pattern&&(e=t.pattern)}this.drawNeedleHead(e,s),this.barGroup.rect(this.dimensions.barLength,this.position.getNeedleWidth()).fill(e).stroke(s).cy(this.dimensions.yPos).x(this.dimensions.xPos),null===(t=this.label)||void 0===t||t.draw()}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,e=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(e)}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 Ys{constructor(t,i,s,e,n,r,a,o,h,l,c){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=e,this.baselineValue=n,this.segmentIndex=a,this.stackMode=o,this.totalValue=h,this.group=c,this.barGroup=c.group().id(`stacked_bar_${e}_seg_${a}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new Jt){if(!this.hasData||null==this.dataPoint.value)return;const s=this.dataPoint.value,e=this.dataPoint.pixelPerUnit,n=this.position.getBarPositionX(),r=this.position.getBarWidth();let a,o;if(this.stackMode===ft.RELATIVE){const t=e;a=(0!==this.totalValue?Math.abs(s)/Math.abs(this.totalValue):0)*t,o=n+this.baselineValue/Math.abs(this.totalValue)*t}else a=Math.abs(s*e),o=n+this.baselineValue*e;const h=this.position.getBarPositionY(this.index,!0),l=this.styles.stackColors,c=l[this.segmentIndex%l.length],d={color:c},u={color:c,width:.5};this.barGroup.rect(Math.max(a,.5),r).fill(d).stroke(u).cy(h).x(o);const p=a-6;if(p>0){const e=o+a/2;if(this.stackMode===ft.RELATIVE||this.stackMode===ft.ABSOLUTE_RELATIVE){const i=(0!==this.totalValue?s/this.totalValue*100:0).toFixed(t.percent)+"%";new Ds(this.group,e,h,"STACK_SEG",i,this.styles,Us.Center,Us.Center).setSegmentFill(c).setMaxWidth(p).draw()}else new Ds(this.group,e,h,"STACK_SEG",s,this.styles,Us.Center,Us.Center).setSegmentFill(c).setMaxWidth(p).draw(t,i)}}drawTotalLabel(t={percent:2,decimal:1},i=new Jt){if(this.stackMode===ft.RELATIVE)return;const s=this.position.getBarPositionX()+this.totalValue*this.dataPoint.pixelPerUnit+this.position.spacings.labelToBar,e=this.position.getBarPositionY(this.index,!0);new Ds(this.group,s,e,"STACK_TOTAL",this.totalValue,this.styles,Us.Center,Us.Left).draw(t,i)}}let zs=class{constructor(t,i,s,e,n){this.overflowConfig=null,this.i18n=n;const r=i.group().id("Scenario1"),a=i.group().id("Scenario2").insertBefore(r);this.svgGroups={parent:i,scenario1:r,scenario2:a,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=e}setOverflowConfig(t){this.overflowConfig=t}isLastDataPoint(t){return this.elementCnt-1===t}isFirsttDataPoint(t){return 0===t}createPrimaryBar(t,i){var s,e,n,r;const a=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===e?void 0:e.group().id(""+i),o=null===(r=null===(n=this.svgGroups)||void 0===n?void 0:n.scenario1Label)||void 0===r?void 0:r.group().id(""+i);let h=null;return this.isLastDataPoint(i)&&(h=`${this.i18n.get(t.scenario)||t.scenario}`),new Ws(this.position,this.styles,t,i,!0,a,h,this.overflowConfig).updateLabelGroup(o)}createVarianceBar(t,i){var s,e,n,r;const a=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===e?void 0:e.group().id(""+i),o=null===(r=null===(n=this.svgGroups)||void 0===n?void 0:n.scenario1Label)||void 0===r?void 0:r.group().id(""+i);let h=null;return this.isLastDataPoint(i)&&(h=`${this.i18n.get(t.scenario)||t.scenario}`),new Ws(this.position,this.styles,t,i,!0,a,h,this.overflowConfig).updateLabelGroup(o).setAsVariance()}createRelativeVarianceBar(t,i){var s,e,n,r;const a=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===e?void 0:e.group().id(""+i),o=null===(r=null===(n=this.svgGroups)||void 0===n?void 0:n.scenario1Label)||void 0===r?void 0:r.group().id(""+i);return new Is(this.position,this.styles,t,i,a).updateLabelGroup(o)}createSecondaryBar(t,i){var s,e;const n=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario2)||void 0===e?void 0:e.group().id(""+i);let r=null;return this.isFirsttDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new Ws(this.position,this.styles,t,i,!1,n,r,this.overflowConfig)}createPrimaryMarker(t,i){var s,e;const n=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario3)||void 0===e?void 0:e.group().id(""+i),r=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 a=null;return this.isFirstDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new Fs(this.position,n,r,t.scenario,this.styles,t,i,a,!0)}createSecondaryMarker(t,i){var s,e;const n=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario4)||void 0===e?void 0:e.group().id(""+i),r=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 a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new Fs(this.position,n,r,t.scenario,this.styles,t,i,a,!1)}isFirstDataPoint(t){return 0===t}};const Bs=.001;function Hs(t){return null!=t.fixedDomain?Math.max(0,t.fixedDomain):t.relativeVariance?0:Math.max(0,t.maxPositive)+Math.abs(Math.min(0,t.minNegative))}function Vs(t){var i;if(!t.relativeVariance)return 0;const s=null!==(i=t.sideClamp)&&void 0!==i?i:1.45;return Math.min(s,Math.max(0,t.maxPositive))+Math.min(s,Math.abs(Math.min(0,t.minNegative)))}function js(t){const i=t.unitExtent+t.pctExtent;if(i<=0)return{};const s=Math.max(Bs,(t.target-(t.measured-t.unitExtent*t.currentPpu-t.pctExtent*t.currentPpp))/i);return{ppu:t.unitExtent>0?s:void 0,ppp:t.pctExtent>0?s:void 0}}class Xs{constructor(t,i,s,e,n){this.dataModel=[],this.variancesDataModel=[],this.title="",this.configTitle="",this.configVariances=[],this.smallestDataPointValue=new _s(0,Cs.AC1,1,Cs.NEU),this.highestDataPointValue=new _s(0,Cs.AC1,1,Cs.NEU),this.smallestVarianceDataPointValue=new _s(0,Cs.AC1,1,Cs.NEU),this.highestVarianceDataPointValue=new _s(0,Cs.AC1,1,Cs.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.hideCategories=!1,this.axisScenario=Cs.AC1,this.CSS_CATEGORIES="categories",this.state=ys.DIRTY,this.titleLength=0,this.leftSideOffsetForHorizontalSync=0,this.limit=0,this.measureScale=new Jt,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.scenarioPropOrder=[],this.overflowConfig=null,this.highestStackedTotal=0,this.fromExpr="",this.rowCount=0,this.db=i,this.tableName=s,this.ruleSet=t||new Ft,this.i18n=this.createI18n(new Map),this.styles=n,this.setConfig(e),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 gs(new ms(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)}setStyles(t){this.styles=t}setRuleSet(t){this.ruleSet=t||new Ft}setConfig(t){var i;this.state=ys.DIRTY,this.scenarioPropOrder=[...t.scenarios];const s=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.dataModel=this.populateModel(s,t.level,t.sortOrder),t.stackConfig&&t.stackConfig.by!==ut.SCENARIOS&&this.populateDimensionStackSegments(s,t.stackConfig,t.level),this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.configTitle=t.title,this.configVariances=null!==(i=null==t?void 0:t.variances)&&void 0!==i?i:[],this.updateTitle(),this.smallestDataPointValue=this.findSmallestDataPointValue(this.dataModel),this.smallestVarianceDataPointValue=this.findSmallestDataPointValue(this.variancesDataModel),this.highestDataPointValue=this.findHighestDataPointValue(this.dataModel),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.highestStackedTotal=this.findHighestStackedRowTotal(this.dataModel),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||Gt.translateScenarioLabel(null===(t=this.configVariances)||void 0===t?void 0:t.toString(),this.i18n)}createI18n(t){this.state=ys.DIRTY;const i=new Map([["SEPERATOR_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"," "],["there_of","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=ys.DIRTY,!this.tableName)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=m(this.tableName,t);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}}getUnitBarExtent(){var t,i;const s=null!=this.stackConfig&&this.highestStackedTotal>0,e=this.getVarianceType(),n=e!==Ss.NONE,r=n?this.highestVarianceDataPointValue:this.highestDataPointValue,a=n?this.smallestVarianceDataPointValue:this.smallestDataPointValue;return Hs({fixedDomain:s?this.stackConfig.mode===ft.RELATIVE?1:this.highestStackedTotal:void 0,relativeVariance:e===Ss.RELATIVE,maxPositive:null!==(t=null==r?void 0:r.value)&&void 0!==t?t:0,minNegative:null!==(i=null==a?void 0:a.value)&&void 0!==i?i:0})}getPercentBarExtent(){var t,i,s,e;return Vs({relativeVariance:this.getVarianceType()===Ss.RELATIVE,maxPositive:null!==(i=null===(t=this.highestVarianceDataPointValue)||void 0===t?void 0:t.value)&&void 0!==i?i:0,minNegative:null!==(e=null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&void 0!==e?e: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.styles.padding.bottom}patternToString(){return"<svg></svg>"}layout(){this.draw(new Wt)}toString(){const t=new Wt;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===ys.DIRTY&&(this.state=ys.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)):(this.drawScenarios(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t))}setPattern(t,i){this.styles.pattern.set(t,i)}calculateTitleLength(t){const i=It(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?" ":Gt.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}setAxisScenario(t){let i=Cs.AC1;if(null!=t&&t.length>0){const s=new Yt(t.toString());s.isValid&&(i=s.delta)}return null===i&&(i=Cs.AC1),i}populateModel(t,i,s){if(0===this.rowCount||!this.fromExpr)return[];const e=[],n=this.createOrderStr(i,s),r=this.createSelectString(i,s),a=this.createGroupByStr(i,s);let o;try{o=this.db.exec(`SELECT ${r} ${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 ${a}\n ORDER BY ${n}`)}catch(t){return console.error("StructureChart: populateModel query failed",t),[]}return this.detectNaNCells(t,o),this.createDataRows(o,e,t),this.crateRESTRow(o,t,e),e}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new Yt(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(0===this.limit||this.limit>t.length)return;const e=[],n=t.slice(this.limit,t.length);this.createDataRows(n,e,i);const r=e.reduce((function(t,s){return{id:t.id,category:t.category,type:t.type,scenario1:new _s(t.scenario1.value+s.scenario1.value,i[0],t.scenario1.pixelPerUnit,Cs.NEU),scenario2:new _s(t.scenario2.value+s.scenario2.value,i[1],t.scenario2.pixelPerUnit,Cs.NEU),scenario3:new _s(t.scenario3.value+s.scenario3.value,i[2],t.scenario3.pixelPerUnit,Cs.NEU),scenario4:new _s(t.scenario4.value+s.scenario4.value,i[3],t.scenario4.pixelPerUnit,Cs.NEU)}}),{id:9999,category:"REST",type:Ss.NONE,scenario1:new _s(0,i[0],this.pixelPerUnit,Cs.NEU),scenario2:new _s(0,i[1],this.pixelPerUnit,Cs.NEU),scenario3:new _s(0,i[2],this.pixelPerUnit,Cs.NEU),scenario4:new _s(0,i[3],this.pixelPerUnit,Cs.NEU)});s.push(r)}createDataRows(t,i,s){let e=t;this.limit>0&&(e=t.slice(0,this.limit)),e.forEach(((t,e)=>{i.push({id:e,category:t.category,type:Ss.NONE,scenario1:new _s(t[s[0]],s[0],this.pixelPerUnit,Cs.NEU),scenario2:new _s(t[s[1]],s[1],this.pixelPerUnit,Cs.NEU),scenario3:new _s(t[s[2]],s[2],this.pixelPerUnit,Cs.NEU),scenario4:new _s(t[s[3]],s[3],this.pixelPerUnit,Cs.NEU)})}))}createOrderStr(t,i){let s=`${t.toLowerCase()}`;return i.hierarchy.length>=1&&(s=`${i.hierarchy.toString()} ${null==i?void 0:i.direction}`),s}createSelectString(t,i){return t===dt.CATEGORY&&i.hierarchy.includes(_t.CATEGORYINDEX)?`${_t.CATEGORYINDEX}, ${dt.CATEGORY} as category`:t===dt.ROWGROUP&&i.hierarchy.includes(_t.ROWGROUPINDEX)?`${_t.ROWGROUPINDEX}, ${dt.ROWGROUP} as category`:t===dt.SUBCATEGORY&&i.hierarchy.includes(_t.SUBCATEGORYINDEX)?`${_t.SUBCATEGORYINDEX}, ${dt.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===dt.CATEGORY&&i.hierarchy.includes(_t.CATEGORYINDEX)?`${_t.CATEGORYINDEX}, ${dt.CATEGORY}`:t===dt.ROWGROUP&&i.hierarchy.includes(_t.ROWGROUPINDEX)?`${_t.ROWGROUPINDEX}, ${dt.ROWGROUP}`:t===dt.SUBCATEGORY&&i.hierarchy.includes(_t.SUBCATEGORYINDEX)?`${_t.SUBCATEGORYINDEX}, ${dt.SUBCATEGORY}`:`${t.toString()}`}calculateCategoryWidth(){if(this.hideCategories)return 5;let t=0;for(const i of this.dataModel){const s=It(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 _s(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 _s(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}findHighestStackedRowTotal(t){if(!this.stackConfig||0===t.length)return 0;const i=this.stackConfig.by===ut.SCENARIOS;let s=0;for(const e of t){let t=0;if(i){const i=["scenario1","scenario2","scenario3","scenario4"],s=[];for(const t of i){const i=e[t];i&&!i.isEmpty()&&null!=i.value&&s.push({value:i.value,scenario:i.scenario})}if(new Set(s.map((t=>Zt(t.scenario)))).size>1){const i=new Map;for(const t of s){const s=Zt(t.scenario);i.set(s,(i.get(s)||0)+Math.abs(t.value))}t=Math.max(...i.values())}else t=s.reduce(((t,i)=>t+Math.abs(i.value)),0)}else e.stackSegments&&e.stackSegments.length>0&&(t=e.stackSegments.reduce(((t,i)=>t+Math.abs(i.value)),0));t>s&&(s=t)}return s}populateVarianceModel(t,i){const s=[];if(0===t.length)return s;let e=null;null!=i&&i.length>0&&(e=i[0]);for(const n in t){const r=new Yt(t[n]);if(r.isValid){const t=this.mapScenarios(r,e),n=r.direction;let a=this.pixelPerUnit;"dr"===r.type&&(a=this.pixelPerPercentage);for(const e in i)s.push({id:Number(e),category:i[e].category,type:"dr"===r.type?Ss.RELATIVE:Ss.ABSOLUTE,scenario1:new _s(this.calculateVariance(r,i[e],t),r.base,a,n),scenario2:new _s(null,null,null,null),scenario3:new _s(null,null,null,null),scenario4:new _s(null,null,null,null)})}}return s}calculateVariance(t,i,s){const e=s.get(t.base),n=s.get(t.delta);return null==e||null==n?null:t.type===Ss.RELATIVE?(i[e].value-i[n].value)/i[n].value:i[e].value-i[n].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((e=>{i[e].scenario===t.delta?s.set(t.delta,e):i[e].scenario===t.base&&s.set(t.base,e)})),s}calculateTextBoxWidth(t){return It(Gt.number(t,"decimal",1,0),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width}calculatePercentageTextBoxWidth(t){let i=0;return t>=0&&(i+=It("+",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width),i+=It(" %",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,It(Gt.number(t,"decimal",1,1),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width+i+i}cleanSVGforRedraw(t){t.clear()}drawAxisAndLabels(t,i){const s=i.group().id("AxisAndDateLables");let e=!1;this.hideCategories||t.forEach(((t,i)=>{t.type===Ss.RELATIVE&&(e=!0);let n=Us.Right,r=!0;t.scenario1.value<0&&(n=Us.Left,r=!1),new Ds(s,this.position.getCategoryPositionX(r),this.position.getBarCenterPositionY(i),"",this.i18n.get(t.category)||t.category,this.styles,Us.Center,n).draw()})),new Gs({scenarioType:this.axisScenario,labelText:this.title,isRelative:e},this.position,s,this.styles).draw()}drawScenarios(t,i){const s=i.group().id("Scenarios"),e=new zs(this.position,s,this.styles,t.length,this.i18n);e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{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()}))}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),e=new zs(this.position,s,this.styles,t.length,this.i18n);return e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.type===Ss.RELATIVE?e.createRelativeVarianceBar(t.scenario1,i).draw():e.createVarianceBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale)})),s}sortSegmentsByPropOrder(t){if(0===this.scenarioPropOrder.length)return;const i=this.scenarioPropOrder;t.sort(((t,s)=>{const e=i.indexOf(t.scenario),n=i.indexOf(s.scenario);return(-1===e?i.length:e)-(-1===n?i.length:n)}))}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),e=this.stackConfig.by===ut.SCENARIOS;t.forEach(((t,i)=>{const n=["scenario1","scenario2","scenario3","scenario4"],r=[];if(e){for(const i of n){const s=t[i];s&&!s.isEmpty()&&null!=s.value&&r.push({value:s.value,scenario:s.scenario,dataPoint:s})}this.sortSegmentsByPropOrder(r)}else{const i=t.scenario1;i&&!i.isEmpty()&&null!=i.value&&r.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0!==r.length)if((e?new Set(r.map((t=>Zt(t.scenario)))):new Set).size>1){const t=new Map;for(const i of r){const s=Zt(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const e=[];for(const i of Kt)t.has(i)&&(e.push({prefix:i,segments:t.get(i)}),t.delete(i));for(const[i,s]of t)e.push({prefix:i,segments:s});e.forEach(((t,n)=>{const r=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),a=e.length-1-n;let o=0,h=null;t.segments.forEach((t=>{const e=new Ys(this.position,this.styles,t.dataPoint,i,o,t.scenario,a,this.stackConfig.mode,r,!0,s);e.draw(this.dataFormatDigits,this.measureScale),o+=Math.abs(t.value),h=e})),h&&h.drawTotalLabel(this.dataFormatDigits,this.measureScale)}))}else{let n=r;!e&&t.stackSegments&&t.stackSegments.length>0&&(n=t.stackSegments.map((t=>({value:t.value,scenario:t.label,dataPoint:t.dataPoint})))),"asc"===this.stackConfig.order?n.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&n.sort(((t,i)=>i.value-t.value));const a=n.reduce(((t,i)=>t+Math.abs(i.value)),0);let o=0,h=null;n.forEach(((t,n)=>{const r=new Ys(this.position,this.styles,t.dataPoint,i,o,t.scenario,n,this.stackConfig.mode,a,e,s);r.draw(this.dataFormatDigits,this.measureScale),o+=Math.abs(t.value),h=r})),h&&h.drawTotalLabel(this.dataFormatDigits,this.measureScale)}}))}drawStackedHeaders(t,i){if(!this.stackConfig||0===t.length)return;const s=this.stackConfig.by===ut.SCENARIOS,e=i.group().id("StackedHeaders"),n=t[0];if(!s){const t=n.stackSegments;if(!t||0===t.length)return;const i=[...t];"asc"===this.stackConfig.order?i.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&i.sort(((t,i)=>i.value-t.value));const s=i.reduce(((t,i)=>t+Math.abs(i.value)),0),r=this.position.getBarPositionX(),a=this.position.getStackedHeaderPositionY();let o=0;return void i.forEach((t=>{const i=t.dataPoint.pixelPerUnit;let n;n=this.stackConfig.mode===ft.RELATIVE?(0!==s?Math.abs(t.value)/s:0)*i:Math.abs(t.value*i);const h=r+o+n/2,l=this.i18n.get(t.label)||t.label;new Ds(e,h,a,"STACK_HEADER",l,this.styles,Us.Bottom,Us.Center).draw(),o+=n}))}const r=["scenario1","scenario2","scenario3","scenario4"],a=[];for(const t of r){const i=n[t];i&&!i.isEmpty()&&null!=i.value&&a.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0===a.length)return;this.sortSegmentsByPropOrder(a);const o=new Set(a.map((t=>Zt(t.scenario)))),h=this.position.getBarPositionX(),l=this.position.getStackedHeaderPositionY();if(o.size>1){const t=new Map;for(const i of a){const s=Zt(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const i=[];for(const s of Kt)t.has(s)&&(i.push({prefix:s,segments:t.get(s)}),t.delete(s));for(const[s,e]of t)i.push({prefix:s,segments:e});i.forEach((t=>{const i=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),s=t.segments[0].dataPoint.pixelPerUnit,n=h+(this.stackConfig.mode===ft.RELATIVE?s:i*s)/2,r=this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase();new Ds(e,n,l,"STACK_HEADER",r,this.styles,Us.Bottom,Us.Center).draw()}))}else{"asc"===this.stackConfig.order?a.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&a.sort(((t,i)=>i.value-t.value));const t=a.reduce(((t,i)=>t+Math.abs(i.value)),0);let i=0;a.forEach((s=>{const n=s.dataPoint.pixelPerUnit;let r;r=this.stackConfig.mode===ft.RELATIVE?(0!==t?Math.abs(s.value)/t:0)*n:Math.abs(s.value*n);const a=h+i+r/2,o=this.i18n.get(s.scenario)||s.scenario;new Ds(e,a,l,"STACK_HEADER",o,this.styles,Us.Bottom,Us.Center).draw(),i+=r}))}}getVarianceType(){return this.variancesDataModel.length>0?this.variancesDataModel[0].type:Ss.NONE}calculateLeftSideWidth(t){var i,s,e;let n=0;const r=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(Ss.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);n=Math.abs(this.smallestDataPointValue.getScaledUnit())+r+t}else if(Ss.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);n=Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit())+r+t}else if(Ss.ABSOLUTE===t&&null!=(null===(e=this.smallestVarianceDataPointValue)||void 0===e?void 0:e.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value);n=Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())+r+t}return n<=this.titleLength?this.titleLength:n}calculateRightSideWidth(t){var i,s,e;if(null!=this.stackConfig&&this.highestStackedTotal>0){const t=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;let i;i=this.stackConfig.mode===ft.RELATIVE?this.pixelPerUnit:this.highestStackedTotal*this.pixelPerUnit;const s=this.calculateTextBoxWidth(this.highestStackedTotal);return Math.max(i+t+s,this.titleLength)}let n=0;const r=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(Ss.NONE===t&&null!=(null===(i=this.highestDataPointValue)||void 0===i?void 0:i.value)&&this.highestDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestDataPointValue.value);n=Math.abs(this.highestDataPointValue.getScaledUnit())+r+t}else if(Ss.RELATIVE===t&&null!=(null===(s=this.highestVarianceDataPointValue)||void 0===s?void 0:s.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculatePercentageTextBoxWidth(this.highestVarianceDataPointValue.value);n=Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit())+r+t}else if(Ss.ABSOLUTE===t&&null!=(null===(e=this.highestVarianceDataPointValue)||void 0===e?void 0:e.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value);n=Math.abs(this.highestVarianceDataPointValue.getScaledUnit())+r+t}return n<=this.titleLength?this.titleLength:n}populateDimensionStackSegments(t,i,s){if(0===this.rowCount||!this.fromExpr||0===t.length)return;const e={[dt.ROWGROUP]:"category",[dt.ROWGROUPINDEX]:"category",[dt.CATEGORY]:"subCategory",[dt.CATEGORYINDEX]:"subCategory"}[s];if(!e)return;const n=s.toString(),r=t[0];let a;try{a=this.db.exec(`SELECT [${n}] as displayGroup, [${e}] as stackLabel, SUM([${r}] * transformOperator(operation)) as stackValue FROM ${this.fromExpr} GROUP BY [${n}], [${e}]`)}catch(t){return void console.error("StructureChart: dimension-stack query failed",t)}const o=new Map;for(const t of a){const i=t.displayGroup;o.has(i)||o.set(i,[]),null!=t.stackValue&&null!=t.stackLabel&&o.get(i).push({label:t.stackLabel,value:t.stackValue})}for(const t of this.dataModel){const i=o.get(t.category);t.stackSegments=i&&i.length>0?i.map((t=>({label:t.label,value:t.value,dataPoint:new _s(t.value,r,this.pixelPerUnit,Cs.NEU)}))):[]}}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,e=t+i+s;this.variancesDataModel&&this.variancesDataModel.length>0?(this.highestVarianceDataPointValue.getScaledUnit()>t&&(this.highestVarianceDataPointValue=new _s(e,this.highestVarianceDataPointValue.scenario,1,this.highestVarianceDataPointValue.variance)),null!=this.smallestVarianceDataPointValue.value&&Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())>t&&(this.smallestVarianceDataPointValue=new _s(-e,this.smallestVarianceDataPointValue.scenario,1,this.smallestVarianceDataPointValue.variance))):(this.highestDataPointValue.getScaledUnit()>t&&(this.highestDataPointValue=new _s(e,this.highestDataPointValue.scenario,1,this.highestDataPointValue.variance)),null!=this.smallestDataPointValue.value&&Math.abs(this.smallestDataPointValue.getScaledUnit())>t&&(this.smallestDataPointValue=new _s(-e,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()===Ss.RELATIVE)return null;const s=i?this.highestVarianceDataPointValue:this.highestDataPointValue,e=i?this.smallestVarianceDataPointValue:this.smallestDataPointValue,n=s.getScaledUnit(),r=null!=e.value?Math.abs(e.getScaledUnit()):0,a=Math.max(n,r);if(a<=0)return null;const o=this.styles.fontStyles.size,h=o*this.styles.scaleFactors.labelToBar,l=1.5*o,c=.3*o,d=.8*o,u=t-this.position.getAxisPositionX()-this.styles.padding.left-this.styles.padding.right-h-this.calculateTextBoxWidth(s.value||0)-l-c;if(u<=d)return null;const p=u-d;return a<=p?null:{cutWidth:u,overdriveZoneWidth:l,breakGap:c,maxOverflow:a-p,scenarioCutOffset:d}}}class Js{constructor(t=2,i=1){this.percent=t,this.decimal=i}}class qs{adapt(t){const i=new Js;return Ot.isNumber(t.percent)&&(i.percent=t.percent),Ot.isNumber(t.decimal)&&(i.decimal=t.decimal),i}default(){return new Js}}const Zs=class{constructor(i){t(this,i),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:xt.ASC},this.level=dt.CATEGORY,this.filter="",this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.parentDimensions={width:0,height:0}}getDb(){return this.stores||(this.stores=d(this.element)),this.stores.db.db}render(){var t,e,n;if(void 0===this.chart)return i(s,null);if(this.chart.hasNoData()){const t=this.i18n.get("no-data")||"==No Data==";return i(s,null,i("p",{class:"warning"},t))}return i(s,null,i("div",{innerHTML:null===(t=this.pattern)||void 0===t?void 0:t.toString(),class:"hidePatternContainer"}),i("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(e=this.chart)||void 0===e?void 0:e.getFooter()),i("div",{innerHTML:null===(n=this.chart)||void 0===n?void 0:n.toString()}))}async componentWillLoad(){var t;const i=this.getDb(),s=this.prepareConfig(),e=this.prepareStyle();this.chart=new Xs(new Ft(this.ruleSetConfig),i,this.tableName,s,e),this.chart.setI18n(this.i18n);const n=s.pixelPerUnit<=0;this.autoFitScaling(s,e),this.chart.setAvailableWidth(n?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new ws(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}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 Ft(this.ruleSetConfig)),this.chart.setConfig(i);const e=i.pixelPerUnit<=0;this.autoFitScaling(i,s),this.chart.setAvailableWidth(e?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new ws(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}autoFitScaling(t,i){var s;const e=t.pixelPerUnit<=0,n=t.pixelPerPercentage<=0;if(!e&&!n)return;const r=()=>{var i;null===(i=this.reportAutoScaling)||void 0===i||i.call(this,{unit:e?t.pixelPerUnit:void 0,percentage:n?t.pixelPerPercentage:void 0})},a=null===(s=this.parentDimensions)||void 0===s?void 0:s.width,o=this.getDb(),h=()=>{this.chart=new Xs(new Ft(this.ruleSetConfig),o,this.tableName,t,i),this.chart.setI18n(this.i18n)},l=()=>(this.chart.layout(),this.chart.getAllocatedCanvasWidth());if(!a||a<=0)return e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=50),h(),void r();e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=1),h();let c=l();if(c<=0)return void r();const d=Math.max(Bs,.9*a/c);let u=!1,p=!1,f=null;for(let i=0;i<=3;i++){const i=js({target:a,measured:c,unitExtent:e?this.chart.getUnitBarExtent():0,pctExtent:n?this.chart.getPercentBarExtent():0,currentPpu:t.pixelPerUnit,currentPpp:t.pixelPerPercentage});if(void 0===i.ppu&&void 0===i.ppp)break;if(e&&void 0!==i.ppu&&(t.pixelPerUnit=i.ppu,u=!0),n&&void 0!==i.ppp&&(t.pixelPerPercentage=i.ppp,p=!0),h(),c=l(),c<=a+.5&&(f={ppu:t.pixelPerUnit,ppp:t.pixelPerPercentage},c>=.98*a))break}let v=!1;if(e&&!u&&(t.pixelPerUnit=d,v=!0),n&&!p&&(t.pixelPerPercentage=d,v=!0),c>a+.5){if(f)u&&(t.pixelPerUnit=f.ppu),p&&(t.pixelPerPercentage=f.ppp);else{const i=a/c;e&&(t.pixelPerUnit=Math.max(Bs,t.pixelPerUnit*i)),n&&(t.pixelPerPercentage=Math.max(Bs,t.pixelPerPercentage*i))}v=!0}v&&h(),r()}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){const t=this.getDb(),i=this.tableName?m(this.tableName,this.filter):"";return new xs(new ks,new kt(new Rs),new Rs,new qs,t,i).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})}prepareStyle(){return new Ts(new As,new zt,new Bt(new Ht),new ni(new Ht),new Vt).adapt(this.styles)}get element(){return e(this)}};Zs.style=':host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}';class Ks{constructor(){this.scenarioOffset=.3,this.scenarioLabelToColumn=.3,this.labelToColumn=.3,this.labelToAxis=.3,this.needleWidth=.3,this.needleHeadWidth=.6,this.columnWidth=2,this.varianceAxisLineWidth=.3,this.axisLineWidth=.1,this.auxiliaryLineWidth=.1,this.scenarioLineWidth=.2,this.markerWidth=.7,this.markerOffset=0,this.categoryWidth=3,this.axisTickLength=.3}}class Qs{adapt(t){const i=new Ks;return Ot.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),Ot.isNumber(t.scenarioLabelToColumn)&&(i.scenarioLabelToColumn=t.scenarioLabelToColumn),Ot.isNumber(t.labelToColumn)&&(i.labelToColumn=t.labelToColumn),Ot.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),Ot.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),Ot.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),Ot.isNumber(t.columnWidth)&&(i.columnWidth=t.columnWidth),Ot.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),Ot.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),Ot.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),Ot.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),Ot.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),Ot.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),Ot.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),Ot.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new Ks}}class te{constructor(t,i,s,e,n,r,a){this.categoryPosition={x:0,y:0},this.spacings=new Ks,this.categoriesBoxOffset={width:0,height:0},this.padding=t,this.scaleFactors=i,this.fontStlye=s,this.dataLabelHeight=this.caluculateDataLabelHeight(),this.axisPosition={x:0,y:0},this.columnValue={min:e,max:n},this.numberOfColumns=r,this.leftSideLabelLength=a,this.calculateSpacings(),this.calculateCategoryPosition(),this.calculateAxisPosition()}caluculateDataLabelHeight(){return 1.1*It("123456789",{font:this.fontStlye.font,fontSize:this.fontStlye.size+"px"}).height}getColumnCenterPositionX(t){return this.categoryPosition.y+this.spacings.scenarioOffset+t*this.spacings.categoryWidth+this.leftSideLabelLength+.5*this.spacings.columnWidth}getAxisPositionY(t){let i=this.columnValue.max.getScaledUnit();return t&&(i=this.columnValue.max.getScaledPercentUnit()+this.getNeedleWidth()),i+this.dataLabelHeight+this.spacings.labelToAxis+this.padding.top}getAxisPositionX(){return this.padding.left+this.leftSideLabelLength}getColumnPositionX(t,i){return i?this.getColumnCenterPositionX(t):this.getColumnCenterPositionX(t)-this.spacings.scenarioOffset}getColumnPositionY(){return this.columnValue.max.getScaledUnit()+this.dataLabelHeight+this.spacings.labelToColumn+this.padding.top}getNeedlePositionY(){return this.columnValue.max.getScaledPercentUnit()+this.dataLabelHeight+this.spacings.labelToColumn+this.getNeedleWidth()+this.padding.top}getMarkerPositionX(t,i){return i?this.getColumnCenterPositionX(t)-this.spacings.markerOffset-.5*this.getColumnWidth():this.getColumnCenterPositionX(t)+this.spacings.markerOffset+.5*this.getColumnWidth()}getMarkerPositionY(){return this.getColumnPositionY()}getAxisTitlePositionX(t){const i=t.width();return this.axisPosition.x-i}getAxisTitlePositionY(t,i){let s=this.columnValue.max.getScaledUnit();return i&&(s=this.columnValue.max.getScaledPercentUnit()),t?s+this.dataLabelHeight+this.spacings.labelToAxis:s}getColumnDataLabelPositionY(t){const i=this.spacings.labelToColumn;return t<0?this.getColumnPositionY()+Math.abs(t)+i:this.getColumnPositionY()-t-i}getNeedleDataLabelPositionY(t){const i=this.spacings.labelToColumn;return t<0?this.getNeedlePositionY()+Math.abs(t)+i+2*this.getNeedleWidth():this.getNeedlePositionY()-t-i-2*this.getNeedleWidth()}getAxisEndPositionX(){return this.getAxisPositionX()+(this.numberOfColumns+.5)*this.spacings.categoryWidth}getColumnWidth(){return this.spacings.columnWidth}getNeedleWidth(){return this.spacings.needleWidth}getNeedleHeadWidth(){return this.spacings.needleHeadWidth}getScenarioLabelPositionOffsetX(t){return t?.5*this.getColumnWidth()+this.spacings.scenarioLabelToColumn:-(.5*this.getColumnWidth()+this.spacings.scenarioLabelToColumn)}calculateSpacings(){this.spacings={scenarioOffset:this.fontStlye.size*this.scaleFactors.scenarioOffset,scenarioLabelToColumn:this.fontStlye.size*this.scaleFactors.scenarioLabelToColumn,markerOffset:this.fontStlye.size*this.scaleFactors.markerOffset,labelToColumn:this.fontStlye.size*this.scaleFactors.labelToColumn,labelToAxis:this.fontStlye.size*this.scaleFactors.labelToAxis,needleWidth:this.fontStlye.size*this.scaleFactors.needleWidth,needleHeadWidth:this.fontStlye.size*this.scaleFactors.needleHeadWidth,columnWidth:this.fontStlye.size*this.scaleFactors.columnWidth,varianceAxisLineWidth:this.fontStlye.size*this.scaleFactors.varianceAxisLineWidth,axisLineWidth:this.fontStlye.size*this.scaleFactors.axisLineWidth,auxiliaryLineWidth:this.fontStlye.size*this.scaleFactors.auxiliaryLineWidth,scenarioLineWidth:this.fontStlye.size*this.scaleFactors.scenarioLineWidth,markerWidth:this.fontStlye.size*this.scaleFactors.markerWidth,categoryWidth:this.fontStlye.size*this.scaleFactors.categoryWidth,axisTickLength:this.fontStlye.size*this.scaleFactors.axisTickLength}}calculateCategoryPosition(){this.categoryPosition={x:this.padding.left+.5*this.spacings.columnWidth,y:this.padding.top}}calculateAxisPosition(){this.axisPosition={x:this.getAxisPositionX(),y:this.getAxisPositionY(!1)}}getMarkerScenarioLabelPositionOffsetX(t){return t?this.spacings.labelToColumn-this.fontStlye.size:this.spacings.labelToColumn+.5*this.spacings.markerWidth}}class ie{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 se{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"},this.markerRight={bottom:"0,"+s,top:"0,0",right:s+","+s/2},this.markerRightBackground={bottom:"0,"+i,top:"0,0",right:i+","+i/2},this.markerLeft={bottom:s+","+s,top:s+",0",left:"0,"+s/2},this.markerLeftBackground={bottom:i+","+i,top:i+",0",Left:"0,"+i/2}}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}}rightMarkerPatternStrings(){return{background:this.markerRightBackground.top+" "+this.markerRightBackground.right+" "+this.markerRightBackground.bottom+" "+this.markerRightBackground.top,foreground:this.markerRight.top+" "+this.markerRight.right+" "+this.markerRight.bottom+" "+this.markerRight.top,bgOffset:this.bgOffset}}leftMarkerPatternStrings(){return{background:this.markerLeftBackground.top+" "+this.markerLeftBackground.Left+" "+this.markerLeftBackground.bottom+" "+this.markerLeftBackground.top,foreground:this.markerLeft.top+" "+this.markerLeft.left+" "+this.markerLeft.bottom+" "+this.markerLeft.top,bgOffset:this.bgOffset}}createPatternMapForStructureBar(){const t=new Map;return t.set("marker-up",this.upMarkerPatternStrings()),t.set("marker-down",this.downMarkerPatternStrings()),t.set("marker-right",this.rightMarkerPatternStrings()),t.set("marker-left",this.leftMarkerPatternStrings()),t}}class ee{constructor(t){this.container=new Wt,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-time-fc")}getFCPolygonPattern(){return{background:"",foreground:"",bgOffset:0,pattern:this.pattern}}toString(){return this.container.svg()}}class ne{constructor(t,i,s,e){this.value=t,this.scenario=i,this.pixelPerUnit=s||1,this.variance="neg"===e||e===le.NEG?le.NEG:"pos"===e||e===le.POS?le.POS:le.NEU}isEmpty(){return void 0===this.value||null==this.scenario}getScaledUnit(){return null==this.value?0:this.value*this.pixelPerUnit}getScaledPercentUnit(){return null==this.value?0:this.value>1.45?1.45*this.pixelPerUnit:this.value<-1.45?-1.45*this.pixelPerUnit:this.value*this.pixelPerUnit}getVarianceStyle(){return null==this.value||this.value>=0?this.variance:le.NEU===this.variance?le.NEU:le.POS===this.variance?le.NEG:le.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 re{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 ae{constructor(){}adapt(t){const i=new re;return Ot.isString(t.date)&&(i.date=this.parseDateString(t.date)),Ot.isOperator(t.operation)&&(i.operation=t.operation),Ot.isNumber(t.rowGroupIndex)&&Ot.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),Ot.isNumber(t.categoryIndex)&&Ot.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),Ot.isNumber(t.subCategoryIndex)&&Ot.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),Ot.isNumber(t.columnGroupIndex)&&Ot.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),Ot.isNumber(t.columnSubGroupIndex)&&Ot.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}parseDateString(t){if("string"!=typeof t)return;const i=g.fromISO(t);if(i.isValid)return i;console.warn(`TimeChartDataRow: invalid date value '${t}' — skipping row`)}default(){return new re}setActualValues(t,i){Ot.isNumber(t.ac1)&&(i.ac1=t.ac1),Ot.isNumber(t.ac2)&&(i.ac2=t.ac2),Ot.isNumber(t.ac3)&&(i.ac3=t.ac3),Ot.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){Ot.isNumber(t.pl1)&&(i.pl1=t.pl1),Ot.isNumber(t.pl2)&&(i.pl2=t.pl2),Ot.isNumber(t.pl3)&&(i.pl3=t.pl3),Ot.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){Ot.isNumber(t.pp1)&&(i.pp1=t.pp1),Ot.isNumber(t.pp2)&&(i.pp2=t.pp2),Ot.isNumber(t.pp3)&&(i.pp3=t.pp3),Ot.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){Ot.isNumber(t.fc1)&&(i.fc1=t.fc1),Ot.isNumber(t.fc2)&&(i.fc2=t.fc2),Ot.isNumber(t.fc3)&&(i.fc3=t.fc3),Ot.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class oe{constructor(t,i,s,e,n,r){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=e,this.varianceStyles=n,this.padding=r,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"]}}class he{constructor(t,i,s,e,n){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=e,this.paddingadapter=n}adapt(t){const i=new oe(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return Ot.isExisting(t)&&(Ot.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),Ot.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),Ot.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),Ot.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),Ot.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),Ot.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 se(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new oe(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}var le,ce;!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"}(le||(le={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(ce||(ce={}));class de{constructor(t,i,s){this.ID_AXIS="axis",this.CSS_AXIS_TITLE="categories",this.scenarioType=t.scenarioType,this.labelText=t.labelText||null,this.isRelative=t.isRelative||!1,this.position=i,this.svgGroup=s.group().id(this.ID_AXIS)}drawAxisTitle(t,i){null==i&&(i=""),t.text(i).addClass(this.CSS_AXIS_TITLE).attr("text-anchor","middle").move(this.position.getAxisTitlePositionX(t),this.position.getAxisTitlePositionY(!0,this.isRelative))}draw(){return this.labelText&&this.drawAxisTitle(this.svgGroup,this.labelText),this.svgGroup.line(this.position.getAxisPositionX(),this.position.getAxisPositionY(this.isRelative),this.position.getAxisEndPositionX(),this.position.getAxisPositionY(this.isRelative)).addClass(this.ID_AXIS+"-"+this.convertScenarioType()),this}convertScenarioType(){return void 0===this.scenarioType||null==this.scenarioType?"default":`${this.scenarioType}`.slice(0,2)}}class ue{constructor(t,i,s,e,n,r,a,o=null){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.isVarianceColumn=!1,this.overflowConfig=null,this.isOverflowing=!1,this.overdriveHeight=0,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=e,this.isPrimaryColumn=n,this.position=t,this.columnBarStyles=i.barStyles,this.overflowConfig=o,this.scenarioGroup=r,this.styles=i,this.columnGroup=r.group().id(r.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&(this.hasData=!0,this.dimensions=this.createDimensions(s,e,n),this.label=this.getDataLabel(s),this.scenarioLabel=this.getScenarioLabel(a))}setAsVariance(){var t;return this.isVarianceColumn=!0,null===(t=this.label)||void 0===t||t.setToVarianceLabel(),this}updateLabelGroup(t){var i;return this.isEmpty()||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1},i=new Jt){if(this.isEmpty())return this;const s=this.getScenarioStyle(),e=this.convertToSVGStyle(s,"stroke"),n=this.getFillStyle(s);null!=this.columnGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(n,e):this.columnGroup.rect(this.position.getColumnWidth(),this.dimensions.columnLength).fill(n).stroke(e).y(this.dimensions.yPos).cx(this.dimensions.xPos)),this.drawColumnDataLabel(t,i),this.drawScenarioLabel()}drawOverdriveBar(t,i){if(!this.columnGroup||!this.overflowConfig)return;const s=this.position.getColumnPositionY(),e=this.position.getColumnWidth(),n=this.dimensions.columnLength,{breakGap:r}=this.overflowConfig,a=s-n;this.columnGroup.rect(e,n).fill(t).stroke(i).y(a).cx(this.dimensions.xPos);const o=a-r-this.overdriveHeight;this.columnGroup.rect(e,this.overdriveHeight).fill(t).stroke(i).y(o).cx(this.dimensions.xPos),this.drawBreakIndicator(a,r)}drawBreakIndicator(t,i){if(!this.columnGroup)return;const s=this.position.getColumnWidth(),e=this.dimensions.xPos-s/2,n=t-i/2,r=.35*i,a=s/3;let o=`M ${e} ${n-r}`;for(let t=0;t<3;t++)o+=` L ${e+a*(t+.5)} ${n-r-.3*i} L ${e+a*(t+1)} ${n-r}`;let h=`M ${e} ${n+r}`;for(let t=0;t<3;t++)h+=` L ${e+a*(t+.5)} ${n+r+.3*i} L ${e+a*(t+1)} ${n+r}`;this.columnGroup.rect(s+2,i).fill("#ffffff").stroke("none").y(t-i).cx(this.dimensions.xPos),this.columnGroup.path(o).fill("none").stroke({color:"#000000",width:1}),this.columnGroup.path(h).fill("none").stroke({color:"#000000",width:1})}createDimensions(t,i,s){const e=t.getScaledUnit();if(this.overflowConfig&&e>0){const n="ac"===t.getScenario()?this.overflowConfig.cutHeight:this.overflowConfig.cutHeight-this.overflowConfig.scenarioCutOffset;if(e>n){this.isOverflowing=!0;const{breakGap:t,overdriveZoneHeight:r,maxOverflow:a}=this.overflowConfig;this.overdriveHeight=a>0?(e-n)/a*r:0;const o=n+t+this.overdriveHeight,h=this.position.getColumnPositionY();return{clipped:!1,columnLength:n,xPos:this.position.getColumnPositionX(i,s),yPos:h-n,labelYPos:h-o-this.position.spacings.labelToColumn,scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:h-.5*n}}}return e<0?{clipped:!1,columnLength:Math.abs(e),xPos:this.position.getColumnPositionX(i,s),yPos:this.position.getColumnPositionY(),labelYPos:this.position.getColumnDataLabelPositionY(e),scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getColumnPositionY()+.5*Math.abs(e)}:{clipped:!1,columnLength:e,xPos:this.position.getColumnPositionX(i,s),yPos:this.position.getColumnPositionY()-e,labelYPos:this.position.getColumnDataLabelPositionY(e),scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getColumnPositionY()-.5*Math.abs(e)}}getDataLabel(t){let i=ti.Bottom;null!=t.value&&t.value<0&&(i=ti.Top);const s=this.isOverflowing?this.dimensions.labelYPos:this.position.getColumnDataLabelPositionY(this.dataPoint.getScaledUnit());return new Qt(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),s,this.ID_DATA_PREFIX,t.value,this.styles,i,ti.Center)}getScenarioLabel(t){return new Qt(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,ti.Center,this.isPrimaryColumn?ti.Left:ti.Right)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.isVarianceColumn||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(!0)}drawColumnDataLabel(t,i=new Jt){var s;null===(s=this.label)||void 0===s||s.draw(this.isPrimaryColumn,t,i)}getFillStyle(t){var i,s,e,n;const r=this.columnBarStyles[this.dataPoint.getScenario()];return(null==r?void 0:r.fillpattern)&&(null===(i=this.styles.pattern.get(r.fillpattern))||void 0===i?void 0:i.pattern)?null===(n=null===(e=null===(s=this.styles)||void 0===s?void 0:s.pattern)||void 0===e?void 0:e.get(r.fillpattern))||void 0===n?void 0:n.pattern:this.convertToSVGStyle(t,"fill")}getScenarioStyle(){var t;return this.isVarianceColumn?null===(t=this.styles)||void 0===t?void 0:t.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()):this.columnBarStyles[this.dataPoint.getScenario()]}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}}class pe{constructor(t,i,s,e,n,r,a,o,h){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.FALLBACK_COLOUR="#000000",this.scenarioLabel=null,this._defaultMarkerPattern=null,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.position=t,this.markerGroup=i||null,this.markerPattern=s||this._defaultMarkerPattern,this.styles=n,this.barStyles=n?n.barStyles:null,this.scenario=e,!0!==(null==r?void 0:r.isEmpty())&&(this.hasData=!0,this.dimensions=this.createMarkerDimensions(r,a,h),this.scenarioLabel=this.getScenarioLabel(o,n,h))}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.polygon(this.markerPattern.background).fill("#ffffff").cy(this.dimensions.yPos-this.dimensions.columnLength).cx(this.dimensions.xPos),this.markerGroup.polygon(this.markerPattern.foreground).fill(i).stroke(t).cy(this.dimensions.yPos-this.dimensions.columnLength).cx(this.dimensions.xPos),null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(),this}createMarkerDimensions(t,i,s){return t.getScaledUnit()<0?{clipped:!1,labelYPos:0,columnLength:t.getScaledUnit(),xPos:this.position.getMarkerPositionX(i,s),yPos:this.position.getMarkerPositionY(),scenarioLabelXPos:this.position.getMarkerPositionX(i,s)+this.position.getMarkerScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getMarkerPositionY()+Math.abs(t.getScaledUnit())}:{clipped:!1,labelYPos:0,columnLength:t.getScaledUnit(),xPos:this.position.getMarkerPositionX(i,s),yPos:this.position.getMarkerPositionY(),scenarioLabelXPos:this.position.getMarkerPositionX(i,s)+this.position.getMarkerScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getMarkerPositionY()-Math.abs(t.getScaledUnit())}}getScenarioLabel(t,i,s){return null==this.markerGroup?null:new Qt(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,ti.Center,s?ti.Right:ti.Left)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}isEmpty(){return!1===this.hasData}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}class fe{constructor(t,i,s,e,n){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.dataLabel=null,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=e,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=n,this.styles=i,this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&(this.hasData=!0,this.dimensions=this.createDimensions(t,s,e),this.dataLabel=new Qt(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),this.position.getNeedleDataLabelPositionY(this.dataPoint.getScaledPercentUnit()),this.ID_DATA_PREFIX,s.value,this.styles,ti.Center,ti.Center),this.dataLabel.setToRelativeVarianceLabel())}updateLabelGroup(t){var i;return this.isEmpty()||null===(i=this.dataLabel)||void 0===i||i.updateGroup(t),this}draw(){var t;if(this.isEmpty())return this;const i=this.styles.varianceStyles[this.dataPoint.getVarianceStyle()],s=this.convertToSVGStyle(i,"stroke");let e=this.convertToSVGStyle(i,"fill");const n=this.convertToSVGStyle(this.styles.varianceStyles.ac,"stroke"),r=this.convertToSVGStyle(this.styles.varianceStyles.ac,"fill"),a=this.barStyles[this.dataPoint.getScenario()];if(null!=a&&a.fillpattern){const t=this.styles.pattern.get(a.fillpattern);null!=t&&(e=t.pattern)}this.dimensions.clipped?this.createClippedNeedleHead(e,s):this.createNeedleHead(n,r),this.barGroup.rect(this.position.getNeedleWidth(),this.dimensions.columnLength).cx(this.dimensions.xPos).y(this.dimensions.yPos).fill(e).stroke(s),null===(t=this.dataLabel)||void 0===t||t.draw()}createDimensions(t,i,s){return i.getScaledPercentUnit()<0?{labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,columnLength:Math.abs(i.getScaledPercentUnit()),xPos:t.getColumnCenterPositionX(s),yPos:t.getNeedlePositionY(),clipped:i.isClipped()}:{columnLength:i.getScaledPercentUnit(),xPos:t.getColumnCenterPositionX(s),yPos:t.getNeedlePositionY()-i.getScaledPercentUnit(),labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:i.isClipped()}}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}createClippedNeedleHead(t,i){const s=this.barGroup.polygon("0,0 5,9 -5,9 0,0 0,5 5,13 -5,13 0,5").fill(t).cx(this.dimensions.xPos).cy(this.getHeadYPosition()).fill(t).stroke(i);null!=this.dataPoint.value&&this.dataPoint.value<0&&s.flip("y")}createNeedleHead(t,i){this.barGroup.rect(2*this.position.getNeedleWidth(),this.position.getNeedleHeadWidth()).cx(this.dimensions.xPos).cy(this.getHeadYPosition()).fill(t).stroke(i)}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getHeadYPosition(){let t=this.dimensions.yPos;return null!=this.dataPoint.value&&this.dataPoint.value<0&&(t+=this.dimensions.columnLength),t}}const ve={ac:{markerFill:"#000000",markerStroke:"#000000",lineColor:"#000000"},pp:{markerFill:"#999999",markerStroke:"#999999",lineColor:"#999999"},fc:{markerFill:"#ffffff",markerStroke:"#000000",lineColor:"#000000",lineDashArray:"4,4"},pl:{markerFill:"#ffffff",markerStroke:"#000000",lineColor:"#000000"}};class ge{constructor(t,i,s,e,n,r,a,o,h=null){this.MARKER_SIZE=8,this.LINE_WIDTH=2,this.ID_LINE_PREFIX="LINE",this.ID_MARKER_PREFIX="MARKER",this.ID_LABEL_PREFIX="LABEL",this.ESTIMATED_LABEL_WIDTH=56,this.ESTIMATED_LABEL_HEIGHT=24,this.position=t,this.styles=i,this.dataPoints=s,this.scenarioGroup=e,this.labelGroup=n,this.scenarioName=r,this.scenarioLabel=a,this.collisionManager=h}draw(t={percent:2,decimal:1},i=new Jt){return this.drawGeometry(),this.drawLabels(t,i),this}drawGeometry(){if(0===this.dataPoints.length)return this;const t=this.getLineStyle();return this.drawLines(t),this.drawMarkers(t),this}drawLabels(t={percent:2,decimal:1},i=new Jt){return 0===this.dataPoints.length||(this.drawScenarioLabel(),this.drawValueLabels(t,i)),this}getLineStyle(){var t,i;const s=(null===(i=null===(t=this.scenarioName)||void 0===t?void 0:t.slice(0,2))||void 0===i?void 0:i.toLowerCase())||"ac";return ve[s]||ve.ac}getScenarioVariant(){var t;const i=parseInt((null===(t=this.scenarioName)||void 0===t?void 0:t.slice(-1))||"1",10);return isNaN(i)?1:Math.min(Math.max(i,1),4)}drawSquareMarker(t,i,s,e){const n=this.MARKER_SIZE/2;t.rect(this.MARKER_SIZE,this.MARKER_SIZE).fill(e.markerFill).stroke({color:e.markerStroke,width:1}).move(i-n,s-n)}drawCircleMarker(t,i,s,e){t.circle(this.MARKER_SIZE).fill(e.markerFill).stroke({color:e.markerStroke,width:1}).center(i,s)}drawTriangleMarker(t,i,s,e){const n=this.MARKER_SIZE/2;t.polygon(`${i},${s-n} ${i-n},${s+n} ${i+n},${s+n}`).fill(e.markerFill).stroke({color:e.markerStroke,width:1})}drawDiamondMarker(t,i,s,e){const n=this.MARKER_SIZE/2;t.polygon(`${i},${s-n} ${i+n},${s} ${i},${s+n} ${i-n},${s}`).fill(e.markerFill).stroke({color:e.markerStroke,width:1})}drawLines(t){const i=this.scenarioGroup.group().id(this.ID_LINE_PREFIX);for(let s=1;s<this.dataPoints.length;s++){const e=this.dataPoints[s-1],n=this.dataPoints[s];if(e.dataPoint.isEmpty()||n.dataPoint.isEmpty())continue;const r=this.position.getColumnCenterPositionX(e.index),a=this.position.getColumnPositionY()-e.dataPoint.getScaledUnit(),o=this.position.getColumnCenterPositionX(n.index),h=this.position.getColumnPositionY()-n.dataPoint.getScaledUnit(),l=i.line([[r,a],[o,h]]).stroke({color:t.lineColor,width:this.LINE_WIDTH,linecap:"round"}).fill("none");t.lineDashArray&&l.attr("stroke-dasharray",t.lineDashArray)}}drawMarkers(t){const i=this.scenarioGroup.group().id(this.ID_MARKER_PREFIX),s=this.getScenarioVariant();for(const e of this.dataPoints){if(e.dataPoint.isEmpty())continue;const n=this.position.getColumnCenterPositionX(e.index),r=this.position.getColumnPositionY()-e.dataPoint.getScaledUnit();switch(s){case 2:this.drawCircleMarker(i,n,r,t);break;case 3:this.drawTriangleMarker(i,n,r,t);break;case 4:this.drawDiamondMarker(i,n,r,t);break;default:this.drawSquareMarker(i,n,r,t)}}}getLabelPositionPriority(t){const i=this.dataPoints[t];let s=null;for(let i=t+1;i<this.dataPoints.length;i++)if(!this.dataPoints[i].dataPoint.isEmpty()){s=this.dataPoints[i];break}let e=null;for(let i=t-1;i>=0;i--)if(!this.dataPoints[i].dataPoint.isEmpty()){e=this.dataPoints[i];break}const n=i.dataPoint.getScaledUnit();return e&&s&&e.dataPoint.getScaledUnit()>n&&s.dataPoint.getScaledUnit()>n?[ii.Below,ii.Left,ii.Right,ii.Above]:[ii.Above,ii.Left,ii.Right,ii.Below]}getScenarioType(){var t,i;return(null===(i=null===(t=this.scenarioName)||void 0===t?void 0:t.slice(0,2))||void 0===i?void 0:i.toLowerCase())||"ac"}drawValueLabels(t,i){const s=this.getScenarioType();for(let e=0;e<this.dataPoints.length;e++){const n=this.dataPoints[e];if(n.dataPoint.isEmpty()||null===n.dataPoint.value)continue;const r=this.position.getColumnCenterPositionX(n.index),a=this.position.getColumnPositionY()-n.dataPoint.getScaledUnit();let o=r,h=a-this.MARKER_SIZE/2-2,l=ti.Bottom,c=ti.Center;if(this.collisionManager){const t=this.getLabelPositionPriority(e),i=this.collisionManager.getOptimalPlacement(r,a,this.ESTIMATED_LABEL_WIDTH,this.ESTIMATED_LABEL_HEIGHT,n.index,this.MARKER_SIZE,s,t);if(null===i)continue;o=i.labelX,h=i.labelY,l=i.verticalHook,c=i.horizontalHook;const d=Object.assign(Object.assign({},i.bounds),{scenarioType:s});this.collisionManager.register(d)}new Qt(this.labelGroup,o,h,this.ID_LABEL_PREFIX,n.dataPoint.value,this.styles,l,c).draw(!0,t,i)}}drawScenarioLabel(){if(!this.scenarioLabel)return;let t=null;for(let i=this.dataPoints.length-1;i>=0;i--)if(!this.dataPoints[i].dataPoint.isEmpty()){t=this.dataPoints[i];break}if(!t)return;const i=this.position.getColumnCenterPositionX(t.index)+this.MARKER_SIZE+4,s=this.position.getColumnPositionY()-t.dataPoint.getScaledUnit(),e=this.getScenarioType();if(this.collisionManager){if(this.collisionManager.shouldHideScenarioLabel(i,s,e))return;this.collisionManager.registerScenarioLabel(i,s,e)}new Qt(this.labelGroup,i,s,"SCENARIO_LABEL",this.scenarioLabel,this.styles,ti.Center,ti.Left).forceStringTypeDraw()}}class me{constructor(t,i,s,e,n,r,a,o,h,l,c){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=e,this.baselineValue=n,this.segmentIndex=a,this.stackMode=o,this.totalValue=h,this.group=c,this.columnGroup=c.group().id(`stacked_col_${e}_seg_${a}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new Jt){if(!this.hasData||null==this.dataPoint.value)return;const s=this.dataPoint.value,e=this.dataPoint.pixelPerUnit;let n,r;const a=this.position.getColumnPositionY();if(this.stackMode===ft.RELATIVE){const t=0!==this.totalValue?Math.abs(s)/Math.abs(this.totalValue):0,i=Rt*e;n=t*i,r=a-this.baselineValue/Math.abs(this.totalValue)*i-n}else n=Math.abs(s*e),r=a-this.baselineValue*e-n;const o=this.position.getColumnCenterPositionX(this.index),h=this.position.getColumnWidth(),l=this.styles.stackColors,c=l[this.segmentIndex%l.length],d={color:c},u={color:c,width:.5};if(this.columnGroup.rect(h,Math.max(n,.5)).fill(d).stroke(u).y(r).cx(o),n>=18){const e=r+n/2;if(this.stackMode===ft.RELATIVE||this.stackMode===ft.ABSOLUTE_RELATIVE){const i=(0!==this.totalValue?s/this.totalValue*100:0).toFixed(t.percent)+"%";new Qt(this.group,o,e,"STACK_SEG",i,this.styles,ti.Center,ti.Center).setSegmentFill(c).forceStringTypeDraw()}else new Qt(this.group,o,e,"STACK_SEG",s,this.styles,ti.Center,ti.Center).setSegmentFill(c).draw(!0,t,i)}}drawTotalLabel(t={percent:2,decimal:1},i=new Jt){if(this.stackMode===ft.RELATIVE)return;const s=this.position.getColumnCenterPositionX(this.index),e=this.position.getColumnPositionY();new Qt(this.group,s,e-this.totalValue*this.dataPoint.pixelPerUnit-this.position.spacings.labelToColumn,"STACK_TOTAL",this.totalValue,this.styles,ti.Bottom,ti.Center).draw(!0,t,i)}}const be={ac:{fill:"#000000",opacity:.3,lineColor:"#000000"},pp:{fill:"#999999",opacity:.3,lineColor:"#999999"},fc:{fill:"#000000",opacity:.2,lineColor:"#000000",dashArray:"4,4"},pl:{fill:"#000000",opacity:.1,lineColor:"#000000"}},we=[{fill:"#000000",opacity:.3},{fill:"#555555",opacity:.25},{fill:"#999999",opacity:.2},{fill:"#bbbbbb",opacity:.15},{fill:"#dddddd",opacity:.1}];class ye{constructor(t,i,s,e,n,r){this.group=t.group().id(`area_fill_${n}`),this.upperPoints=i,this.lowerPoints=s,this.scenarioType=e,this.segmentIndex=n,this.isScenarioStack=r}draw(){if(this.upperPoints.length<2||this.lowerPoints.length<2)return;let t,i,s=`M ${this.upperPoints[0].x},${this.upperPoints[0].y}`;for(let t=1;t<this.upperPoints.length;t++)s+=` L ${this.upperPoints[t].x},${this.upperPoints[t].y}`;for(let t=this.lowerPoints.length-1;t>=0;t--)s+=` L ${this.lowerPoints[t].x},${this.lowerPoints[t].y}`;if(s+=" Z",this.isScenarioStack&&this.scenarioType){const s=this.scenarioType.slice(0,2).toLowerCase(),e=be[s]||be.ac;t=e.fill,i=e.opacity}else{const s=Math.min(this.segmentIndex,we.length-1);t=we[s].fill,i=we[s].opacity}this.group.path(s).fill(t).opacity(i).stroke("none")}drawBoundaryLine(){if(this.upperPoints.length<2)return;let t,i="#000000";if(this.isScenarioStack&&this.scenarioType){const s=this.scenarioType.slice(0,2).toLowerCase(),e=be[s]||be.ac;i=e.lineColor,t=e.dashArray}const s=this.group.polyline(this.upperPoints.map((t=>[t.x,t.y]))).fill("none").stroke({color:i,width:1.5});t&&s.attr("stroke-dasharray",t)}}class Se{constructor(t,i,s,e,n,r,a,o){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.isVarianceLine=!1,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.previousDimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=n,this.isPrimaryLine=r,this.position=t,this.LineBarStyles=i.barStyles,this.scenarioGroup=a,this.styles=i,this.LineGroup=a.group().id(a.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&(this.hasData=!0,this.dimensions=this.createDimensions(s,n,r),this.label=this.getDataLabel(s),this.scenarioLabel=this.getScenarioLabel(o)),this.previousDimensions=this.createDimensions(e,n-1,r)}setAsVariance(){var t;return this.isVarianceLine=!0,null===(t=this.label)||void 0===t||t.setToVarianceLabel(),this}updateLabelGroup(t){var i;return this.isEmpty()||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1},i=new Jt){if(this.isEmpty())return this;const s=this.getScenarioStyle(),e=this.getFillStyle(s);null!=this.LineGroup&&this.LineGroup.line([[this.previousDimensions.xPos,this.previousDimensions.yPos],[this.dimensions.xPos,this.dimensions.yPos]]).fill(e).stroke({color:"#f06",width:3,linecap:"round"}),this.drawLineDataLabel(t,i),this.drawScenarioLabel()}createDimensions(t,i,s){return{clipped:!1,columnLength:t.getScaledUnit(),xPos:this.position.getColumnPositionX(i,s),yPos:this.position.getColumnPositionY()-t.getScaledUnit(),labelYPos:this.position.getColumnDataLabelPositionY(t.getScaledUnit()),scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getColumnPositionY()-t.getScaledUnit()}}getDataLabel(t){let i=ti.Bottom;return null!=t.value&&t.value<0&&(i=ti.Top),new Qt(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),this.position.getColumnDataLabelPositionY(this.dataPoint.getScaledUnit()),this.ID_DATA_PREFIX,t.value,this.styles,i,ti.Center)}getScenarioLabel(t){return new Qt(this.scenarioGroup,0,0,this.ID_SCENARIO_PREFIX,t,this.styles,ti.Bottom,ti.Left)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.isVarianceLine||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(!0)}drawLineDataLabel(t,i=new Jt){var s;null===(s=this.label)||void 0===s||s.draw(this.isPrimaryLine,t,i)}getFillStyle(t){var i,s,e,n;const r=this.LineBarStyles[this.dataPoint.getScenario()];return(null==r?void 0:r.fillpattern)&&(null===(i=this.styles.pattern.get(r.fillpattern))||void 0===i?void 0:i.pattern)?null===(n=null===(e=null===(s=this.styles)||void 0===s?void 0:s.pattern)||void 0===e?void 0:e.get(r.fillpattern))||void 0===n?void 0:n.pattern:this.convertToSVGStyle(t,"fill")}getScenarioStyle(){var t;return this.isVarianceLine?null===(t=this.styles)||void 0===t?void 0:t.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()):this.LineBarStyles[this.dataPoint.getScenario()]}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}}class $e{constructor(t,i,s,e,n){this.pixelPerUnit=1,this.collisionManager=null,this.overflowConfig=null,this.i18n=n;const r=i.group().id("Scenario1"),a=i.group().id("Scenario2").insertBefore(r);this.svgGroups={parent:i,scenario1:r,scenario2:a,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=e}setOverflowConfig(t){this.overflowConfig=t}createLine(t,i,s,e){const n=this.svgGroups.scenario1.group().id(""+e),r=this.svgGroups.scenario1Label.group().id(""+e);let a=null;return this.isLastDataPoint(e-1)&&(a=t),new Se(this.position,this.styles,i,s,e,!1,n,a).updateLabelGroup(r)}createPrimaryBar(t,i){const s=this.svgGroups.scenario1.group().id(""+i),e=this.svgGroups.scenario1Label.group().id(""+i);let n=null;return this.isLastDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new ue(this.position,this.styles,t,i,!0,s,n,this.overflowConfig).updateLabelGroup(e)}createVarianceBar(t,i){const s=this.svgGroups.scenario1.group().id(""+i),e=this.svgGroups.scenario1Label.group().id(""+i);let n=null;return this.isLastDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new ue(this.position,this.styles,t,i,!0,s,n,this.overflowConfig).updateLabelGroup(e).setAsVariance()}createRelativeVarianceBar(t,i){const s=this.svgGroups.scenario1.group().id(""+i),e=this.svgGroups.scenario1Label.group().id(""+i);return new fe(this.position,this.styles,t,i,s).updateLabelGroup(e)}createSecondaryBar(t,i){const s=this.svgGroups.scenario2.group().id(""+i);let e=null;return this.isFirstDataPoint(i)&&(e=`${this.i18n.get(t.scenario)||t.scenario}`),new ue(this.position,this.styles,t,i,!1,s,e,this.overflowConfig)}createPrimaryMarker(t,i){const s=this.svgGroups.scenario3.group().id(""+i),e=this.styles.pattern.get("marker-right")||{foreground:"#000000",background:"#ffffff",bgOffset:0};let n=null;return this.isFirstDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new pe(this.position,s,e,t.scenario,this.styles,t,i,n,!0)}createSecondaryMarker(t,i){const s=this.svgGroups.scenario4.group().id(""+i),e=this.styles.pattern.get("marker-left")||{foreground:"#000000",background:"#ffffff",bgOffset:0};let n=null;return this.isLastDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new pe(this.position,s,e,t.scenario,this.styles,t,i,n,!1)}isLastDataPoint(t){return this.elementCnt-1===t}isFirstDataPoint(t){return 0===t}setCollisionManager(t){this.collisionManager=t}moveLabelsToFront(){this.svgGroups.scenario1Label.front()}createLineSeries(t,i){const s=this.svgGroups.parent.group().id("LineSeries_"+i),e=this.svgGroups.scenario1Label.group().id("LineSeries_Label_"+i),n=`${this.i18n.get(i)||i}`;return new ge(this.position,this.styles,t,s,e,i,n,this.i18n,this.collisionManager)}}const Oe="bn-measurement-host";function Re(t,i){const s=function(){if("undefined"==typeof document||!document.body)return null;let t=document.getElementById(Oe);return t||(t=document.createElement("div"),t.id=Oe,t.style.cssText="opacity:0;position:absolute;left:-100%;top:-100%;overflow:hidden",t.setAttribute("aria-hidden","true"),document.body.appendChild(t)),t}();if(s){s.appendChild(t.node);try{i()}finally{t.node.parentNode===s&&s.removeChild(t.node)}}else i()}var Me,xe;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(Me||(Me={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(xe||(xe={}));class _e{constructor(t,i,s,e,n,r=0){this.CSS_CATEGORIES="categories",this.dataModel=[],this.variancesDataModel=[],this.title="",this.configTitle="",this.configVariances=[],this.smallestDataPointValue=new ne(0,le.AC1,1,le.NEU),this.highestDataPointValue=new ne(0,le.AC1,1,le.NEU),this.smallestVarianceDataPointValue=new ne(0,le.AC1,1,le.NEU),this.highestVarianceDataPointValue=new ne(0,le.AC1,1,le.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.hideAxisLabels=!1,this.axisScenario=le.AC1,this.fromExpr="",this.rowCount=0,this.axisCategoryArea={width:0,height:0},this.scenariosArea={width:0,height:0},this.state=Me.DIRTY,this.i18n=new Map,this.leftSideOffsetForHorizontalSync=-1,this.dateInterval=C.DAY,this.locale="de",this.axisLabelsMode=vt.SMART,this.intervalSpanLimit=32,this.measureScale=new Jt,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.showOverlayMedian=!1,this.showOverlayAvg=!1,this.chartMode=gt.BAR,this.maxBars=28,this.stackConfig=null,this.scenarioPropOrder=[],this.lineFullWidth=!0,this.availableWidth=0,this.overflowConfig=null,this.lastScenarios=[],this.db=i,this.tableName=s,this.ruleSet=t||new Ft,this.i18n=this.createI18n(new Map),this.styles=n,this.availableWidth=r,this.setConfig(e),this.position=this.createElementPosition(this.lastScenarios)}updatePosition(t){this.position=this.createElementPosition(t)}setStyles(t){this.styles=t}setRuleSet(t){this.ruleSet=t||new Ft}setAvailableWidth(t){this.availableWidth=t}setAvailableHeight(t){this.pixelPerUnit<=0||t<=0?this.overflowConfig=null:null==this.stackConfig&&this.determineEffectiveChartMode()===gt.BAR?(this.overflowConfig=this.calculateOverflowConfig(t),this.overflowConfig&&this.updatePosition(this.lastScenarios)):this.overflowConfig=null}calculateOverflowConfig(t){const i=(this.isVarianceChart()?this.highestVarianceDataPointValue:this.highestDataPointValue).getScaledUnit();if(i<=0)return null;const s=this.styles.fontStyles.size,e=1.5*s,n=.3*s,r=t-(this.position.dataLabelHeight+this.position.spacings.labelToColumn+this.position.padding.top+this.position.padding.bottom+this.position.spacings.labelToAxis+s)-e-n,a=.8*s;if(r<=a)return null;const o=r-a;return i<=o?null:{cutHeight:r,overdriveZoneHeight:e,breakGap:n,maxOverflow:i-o,scenarioCutOffset:a}}setConfig(t){var i;this.state=Me.DIRTY,this.locale=t.locale,this.scenarioPropOrder=[...t.scenarios];const s=this.sortScenariosbyVisualisationRules(t.scenarios);this.setSource(t.filter),this.hideAxisLabels=t.hideAxisLabels||!1,this.pixelPerUnit=t.pixelPerUnit,this.pixelPerPercentage=t.pixelPerPercentage,this.axisLabelsMode=t.axisLabelsMode,this.intervalSpanLimit=t.intervalSpanLimit,this.dateInterval=this.findDateInterval(t.dateInterval),this.dataModel=this.populateModel(s,this.dateInterval,t.level,t.sortOrder),this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.configTitle=t.title,this.configVariances=null!==(i=null==t?void 0:t.variances)&&void 0!==i?i:[],this.updateTitle(),this.smallestDataPointValue=this.findSmallestDataPointValue(this.dataModel),this.smallestVarianceDataPointValue=this.findSmallestDataPointValue(this.variancesDataModel),this.highestDataPointValue=this.findHighestDataPointValue(this.dataModel),this.highestVarianceDataPointValue=this.findHighestDataPointValue(this.variancesDataModel),this.axisScenario=this.setAxisScenario(t.variances),this.leftSideOffsetForHorizontalSync=t.leftSideOffsetForHorizontalSync,this.measureScale=t.measureScale,this.measureUnit=t.measureUnit,this.dataFormatDigits=t.dataFormatDigits,this.showOverlayMedian=t.showOverlayMedian,this.showOverlayAvg=t.showOverlayAvg,this.chartMode=t.chartMode,this.maxBars=t.maxBars,this.stackConfig=t.stackConfig,this.lineFullWidth=t.lineFullWidth,this.lastScenarios=s,this.updatePosition(s)}getFooter(){return 1===this.measureScale.value&&""===this.measureUnit?" ":Gt.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}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||Gt.translateScenarioLabel(null===(t=this.configVariances)||void 0===t?void 0:t.toString(),this.i18n)}setSource(t){var i,s;if(this.state=Me.DIRTY,!this.tableName)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=m(this.tableName,t);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}}getAllocatedCanvasWidth(){const t=this.position.getAxisEndPositionX(),i=3*this.styles.fontStyles.size,s=Math.max(this.axisCategoryArea.width,this.scenariosArea.width);return Math.max(t+i,s>0?s+this.position.leftSideLabelLength:0)}getAllocatedCanvasHeight(){if(null==this.smallestVarianceDataPointValue.value||null==this.highestVarianceDataPointValue.value||null==this.smallestDataPointValue.value||null==this.highestDataPointValue.value)return 0;const t=this.isVarianceChart()&&this.variancesDataModel.some((t=>t.type===xe.RELATIVE)),i=this.position.getAxisPositionY(t),s=this.position.spacings.labelToAxis+this.position.dataLabelHeight+this.styles.padding.bottom;let e;if(this.isOnSameAxisSide())e=i+s;else{const t=this.isVarianceChart()?this.smallestVarianceDataPointValue:this.smallestDataPointValue;e=i+Math.abs(t.getScaledUnit())+this.position.spacings.labelToColumn+this.position.dataLabelHeight+s}const n=this.isOnSameAxisSide();return Math.max(e,n?this.axisCategoryArea.height+this.scenariosArea.height:this.scenariosArea.height)}getUnitBarExtent(){var t,i,s;const e=this.isVarianceChart()&&this.variancesDataModel.some((t=>t.type===xe.RELATIVE)),n=this.isVarianceChart(),r=n?this.highestVarianceDataPointValue:this.highestDataPointValue,a=n?this.smallestVarianceDataPointValue:this.smallestDataPointValue;return Hs({fixedDomain:(null===(t=this.stackConfig)||void 0===t?void 0:t.mode)===ft.RELATIVE?Rt:void 0,relativeVariance:e,maxPositive:null!==(i=null==r?void 0:r.value)&&void 0!==i?i:0,minNegative:this.isOnSameAxisSide()?0:null!==(s=null==a?void 0:a.value)&&void 0!==s?s:0})}getPercentBarExtent(){var t,i,s,e;return Vs({relativeVariance:this.isVarianceChart()&&this.variancesDataModel.some((t=>t.type===xe.RELATIVE)),maxPositive:null!==(i=null===(t=this.highestVarianceDataPointValue)||void 0===t?void 0:t.value)&&void 0!==i?i:0,minNegative:this.isOnSameAxisSide()?0:null!==(e=null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&void 0!==e?e:0})}layout(){const t=new Wt;Re(t,(()=>this.draw(t)))}toString(){const t=new Wt;return Re(t,(()=>this.draw(t))),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),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===Me.DIRTY&&(this.state=Me.UP_TO_DATE),this.isVarianceChart()?(this.drawVarianceScenario(this.variancesDataModel,t),this.drawAxisAndLabels(this.variancesDataModel,t)):null!=this.stackConfig?this.determineEffectiveChartMode()===gt.LINE?(this.drawStackedAreaScenarios(this.dataModel,t),this.drawAxisAndLabelsForLineChart(this.dataModel,t)):(this.drawStackedScenarios(this.dataModel,t),this.drawStackedHeaders(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t)):this.determineEffectiveChartMode()===gt.LINE?(this.drawLineScenarios(this.dataModel,t),this.drawAxisAndLabelsForLineChart(this.dataModel,t)):(this.drawScenarios(this.dataModel,t),this.drawOverlayLayer(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t))}determineEffectiveChartMode(){return this.chartMode===gt.LINE||this.chartMode===gt.AUTO&&this.dataModel.length>this.maxBars?gt.LINE:gt.BAR}setPattern(t,i){this.styles.pattern.set(t,i)}hasNoData(){return 0===this.dataModel.length}isOnSameAxisSide(){return null!=this.smallestVarianceDataPointValue.value&&null!=this.highestVarianceDataPointValue.value&&null!=this.smallestDataPointValue.value&&null!=this.highestDataPointValue.value&&(this.isVarianceChart()?Math.sign(this.smallestVarianceDataPointValue.value)===Math.sign(this.highestVarianceDataPointValue.value)||0===this.smallestDataPointValue.value&&1===Math.sign(this.highestDataPointValue.value):Math.sign(this.smallestDataPointValue.value)===Math.sign(this.highestDataPointValue.value)||0===this.smallestDataPointValue.value&&1===Math.sign(this.highestDataPointValue.value))}createI18n(t){this.state=Me.DIRTY;const i=new Map([["SEPERATOR_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"," "],["there_of","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])}createElementPosition(t){var i;let s;const e=It(t.filter(((t,i)=>1===i||2===i)).map((t=>Gt.translateScenarioLabel(t,this.i18n))).reduce(((t,i)=>t.length<i.length?i:t),""),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,n=this.calculateTitleLength(this.leftSideOffsetForHorizontalSync);let r,a;if(s=e>n?e:n,null!=this.position&&(s+=this.position.spacings.labelToColumn),this.leftSideOffsetForHorizontalSync>-1&&(s=this.leftSideOffsetForHorizontalSync),this.isVarianceChart()?(r=this.smallestVarianceDataPointValue,a=this.highestVarianceDataPointValue):(r=this.smallestDataPointValue,a=this.highestDataPointValue),(null===(i=this.stackConfig)||void 0===i?void 0:i.mode)===ft.RELATIVE&&(a=new ne(Rt,a.scenario,this.pixelPerUnit,a.variance)),this.overflowConfig){const{cutHeight:t,overdriveZoneHeight:i,breakGap:s}=this.overflowConfig;a=new ne(t+i+s,a.scenario,1,a.variance)}let o=this.styles.scaleFactors;const h=this.determineEffectiveChartMode();if(this.lineFullWidth&&this.availableWidth>0&&this.dataModel.length>0&&!this.isVarianceChart()&&h===gt.LINE){const t=this.styles.fontStyles.size,i=this.styles.padding,e=this.styles.scaleFactors,n=this.availableWidth-(i.left+i.right+t*e.scenarioOffset+s+t*e.columnWidth);if(n>0){const i=Math.max(n/this.dataModel.length/t,1.2*e.columnWidth),s=new Ks;Object.assign(s,e),s.categoryWidth=i,o=s}}return new te(new ie(this.styles.padding),o,this.styles.fontStyles,r,a,this.dataModel.length,s)}calculateTitleLength(t){let i="_______";i.length<this.title.length&&(i=this.title);const s=It(i,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;return s<t?t:s}setAxisScenario(t){let i=le.AC1;if(null!=t&&t.length>0){const s=new Yt(t.toString());s.isValid&&(i=s.delta)}return null===i&&(i=le.AC1),i}populateModel(t,i,s,e){if(0===this.rowCount||!this.fromExpr)return[];let n=this.queryDataSet(i,"","");return this.detectNaNCells(t,n),n=this.leftOuterJoinDates(n,i),this.createDataRows(n,t)}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new Yt(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)))}findDateInterval(t){var i,s,e;if(t!==C.AUTO)return t;const n=this.queryMinMaxDates();let r=C.DAY;return null!=(null===(i=n[0])||void 0===i?void 0:i.mindate)&&(r=(new U).calculateDistanceType(null===(s=n[0])||void 0===s?void 0:s.mindate,null===(e=n[0])||void 0===e?void 0:e.maxdate,this.intervalSpanLimit)),r}queryMinMaxDates(){var t,i;let s;try{s=this.db.exec(`SELECT MAX(date) as maxdate, MIN(date) as mindate FROM ${this.fromExpr}`)}catch(t){return console.error("TimeChart: min/max date query failed",t),[{}]}return null!=(null===(t=s[0])||void 0===t?void 0:t.mindate)&&(s[0].mindate=_e.coerceDateTime(s[0].mindate)),null!=(null===(i=s[0])||void 0===i?void 0:i.maxdate)&&(s[0].maxdate=_e.coerceDateTime(s[0].maxdate)),s}static coerceDateTime(t){if(null!=t){if("string"==typeof t){const i=g.fromISO(t);return i.isValid?i:void 0}if("number"==typeof t){const i=g.fromMillis(t);return i.isValid?i:void 0}return"boolean"==typeof t.isValid?t:void 0}}queryDataSet(t,i,s){const e=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],n=`normalizeDate([date], '${t}' , '${this.locale}') as calcdate`;let r;try{r=this.db.exec(`SELECT p.calcdate ${i},\n ${e.map((t=>`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`)).join(",")}\n\n FROM (SELECT ${n} ${i},\n ac1,\n ac2,\n ac3,\n ac4,\n pp1,\n pp2,\n pp3,\n pp4,\n fc1,\n fc2,\n fc3,\n fc4,\n pl1,\n pl2,\n pl3,\n pl4\n FROM ${this.fromExpr}) as p\n GROUP BY calcdate ${s}\n ORDER BY calcdate asc`)}catch(t){return console.error("TimeChart: queryDataSet failed",t),[]}return r}createDataRows(t,i){const s=[];return t.forEach(((t,e)=>{s.push({id:e,category:t.category,type:xe.NONE,date:t.calcdate,scenario1:new ne(t[i[0]],i[0],this.pixelPerUnit,le.NEU),scenario2:new ne(t[i[1]],i[1],this.pixelPerUnit,le.NEU),scenario3:new ne(t[i[2]],i[2],this.pixelPerUnit,le.NEU),scenario4:new ne(t[i[3]],i[3],this.pixelPerUnit,le.NEU)})})),s}findSmallestDataPointValue(t){const i=this.isVarianceChart()?this.pixelPerPercentage:this.pixelPerUnit;let s=new ne(0,"default",i,le.NEU);for(const i of t)for(const t of[i.scenario1,i.scenario2,i.scenario3,i.scenario4])t&&null!=t.value&&t.value<Number(s.value)&&(s=t);return s}findHighestDataPointValue(t){const i=this.isVarianceChart()?this.pixelPerPercentage:this.pixelPerUnit;let s=new ne(0,"default",i,le.NEU);for(const i of t)for(const t of[i.scenario1,i.scenario2,i.scenario3,i.scenario4])null!=t&&t.value>Number(s.value)&&(s=t);return s}populateVarianceModel(t,i){const s=[];if(null==t||0===t.length)return s;let e=null;null!=i&&i.length>0&&(e=i[0]);for(const n in t){const r=new Yt(t[n]);if(r.isValid){const t=this.mapScenarios(r,e),n=r.direction,a="dr"===r.type?this.pixelPerPercentage:this.pixelPerUnit;for(const e in i)s.push({id:Number(e),category:i[e].category,type:"dr"===r.type?xe.RELATIVE:xe.ABSOLUTE,date:i[e].date,scenario1:new ne(this.calculateVariance(r,i[e],t),r.delta,a,n),scenario2:new ne(null,null,null,null),scenario3:new ne(null,null,null,null),scenario4:new ne(null,null,null,null)})}}return s}calculateVariance(t,i,s){const e=s.get(t.base),n=s.get(t.delta);return null==e||null==n||null==i[e].value||null==i[n].value?null:t.type===xe.RELATIVE?(i[e].value-i[n].value)/i[n].value:i[e].value-i[n].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((e=>{i[e].scenario===t.delta?s.set(t.delta,e):i[e].scenario===t.base&&s.set(t.base,e)})),s}cleanSVGforRedraw(t){t.clear()}isVarianceChart(){return this.variancesDataModel&&this.variancesDataModel.length>0}createDateFactory(){const t=new U;return t.setLocale(this.locale),t}drawAxisAndLabels(t,i){const s=this.createDateFactory(),e=i.group().id("AxisAndDateLables");let n=!1;if(!1===this.hideAxisLabels)t.forEach(((t,i)=>{let r=ti.Top,a=this.position.spacings.labelToAxis;t.scenario1.value<0&&(r=ti.Bottom,a*=-1),t.type===xe.RELATIVE&&(n=!0);let o=s.getDateString(t.date,this.dateInterval);this.axisLabelsMode===vt.SMART?(o=s.getSmartDateString(t.date,this.dateInterval),0===i&&this.dateInterval!==C.YEAR&&(o=s.getShortDateString(t.date,this.dateInterval))):this.axisLabelsMode===vt.SHORT&&(o=s.getShortDateString(t.date,this.dateInterval)),new Qt(e,this.position.getColumnCenterPositionX(i),this.position.getAxisPositionY(n)+a,"",o,this.styles,r,ti.Center).forceStringTypeDraw()}));else{const i=null==t?void 0:t[0];i&&i.type===xe.RELATIVE&&(n=!0)}new de({scenarioType:this.axisScenario,labelText:this.title,isRelative:n},this.position,e).draw();const r=e.bbox();this.axisCategoryArea={height:r.height,width:r.width}}drawScenarios(t,i){const s=i.group().id("Scenarios"),e=new $e(this.position,s,this.styles,t.length,this.i18n);e.setOverflowConfig(this.overflowConfig);let n=!1;t.forEach(((t,i)=>{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(),!1===t.scenario1.isEmpty()&&(n=!0)}));let r=0;!1===n&&(r=this.isOnSameAxisSide()?this.position.dataLabelHeight:2*this.position.dataLabelHeight);const a=s.bbox();this.scenariosArea={height:a.height+this.styles.padding.top+this.styles.padding.bottom+r,width:a.width+this.position.spacings.columnWidth}}drawLineScenarios(t,i){var s,e;const n=i.group().id("LineScenarios"),r=new si,a=new $e(this.position,n,this.styles,t.length,this.i18n);a.setCollisionManager(r);const o=["ac1","pp1","fc1","pl1"],h=[[],[],[],[]];t.forEach(((t,i)=>{["scenario1","scenario2","scenario3","scenario4"].forEach(((s,e)=>{t[s]&&h[e].push({dataPoint:t[s],index:i})}))}));const l=[];for(let t=0;t<h.length;t++){const i=h[t];if(i.length>0&&i.some((t=>!t.dataPoint.isEmpty()))){const n=(null===(e=null===(s=i[0])||void 0===s?void 0:s.dataPoint)||void 0===e?void 0:e.scenario)||o[t],r=n.slice(0,2).toLowerCase();l.push({points:i,scenarioName:n,scenarioType:r})}}l.sort(((t,i)=>(ei[i.scenarioType]||99)-(ei[t.scenarioType]||99)));const c=[];for(const t of l){const i=a.createLineSeries(t.points,t.scenarioName);c.push({series:i,scenarioType:t.scenarioType})}for(const t of c)t.series.drawGeometry();a.moveLabelsToFront();const d=[...c].sort(((t,i)=>(ei[t.scenarioType]||99)-(ei[i.scenarioType]||99)));for(const t of d)t.series.drawLabels(this.dataFormatDigits,this.measureScale);const u=this.position.getColumnPositionY(),p=n.bbox();this.scenariosArea={height:Math.max(p.height+this.styles.padding.top,u)+this.styles.padding.bottom,width:p.width+this.position.spacings.columnWidth}}drawAxisAndLabelsForLineChart(t,i){const s=this.createDateFactory(),e=i.group().id("AxisAndDateLabelsLine"),n=!1,r=t.length-1;!1===this.hideAxisLabels&&t.forEach(((i,a)=>{if(!this.shouldShowLineChartAxisLabel(t,a))return;let o,h=ti.Top,l=this.position.spacings.labelToAxis;i.scenario1.value<0&&(h=ti.Bottom,l*=-1),this.lineFullWidth&&this.availableWidth>0?this.axisLabelsMode===vt.SMART?(o=s.getSmartDateString(i.date,this.dateInterval),0===a&&this.dateInterval!==C.YEAR&&(o=s.getShortDateString(i.date,this.dateInterval))):o=this.axisLabelsMode===vt.SHORT?s.getShortDateString(i.date,this.dateInterval):s.getDateString(i.date,this.dateInterval):o=s.getShortDateString(i.date,this.dateInterval),new Qt(e,this.position.getColumnCenterPositionX(a),this.position.getAxisPositionY(n)+l,"",o,this.styles,h,ti.Center).forceStringTypeDraw(),a>0&&a<r&&this.isYearChange(t,a)&&this.drawYearSeparatorLine(e,a,n)})),new de({scenarioType:this.axisScenario,labelText:this.title,isRelative:n},this.position,e).draw();const a=e.bbox();this.axisCategoryArea={height:a.height,width:a.width}}shouldShowLineChartAxisLabel(t,i){return!!(this.lineFullWidth&&this.availableWidth>0)||(0===i||i===t.length-1||this.isYearChange(t,i))}isYearChange(t,i){var s,e;if(0===i)return!1;const n=null===(s=t[i])||void 0===s?void 0:s.date,r=null===(e=t[i-1])||void 0===e?void 0:e.date;return!(!n||!r)&&n.year!==r.year}drawYearSeparatorLine(t,i,s){const e=this.position.getColumnCenterPositionX(i)-this.position.spacings.columnWidth/2,n=this.position.columnValue.max.getScaledUnit()+this.position.dataLabelHeight,r=this.position.getAxisPositionY(s)-n,a=this.position.getAxisPositionY(s);t.line([[e,r],[e,a]]).stroke({color:"#999999",width:1,dasharray:"4,4"}).attr("stroke-dasharray","4,4")}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),e=new $e(this.position,s,this.styles,t.length,this.i18n);e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.type===xe.RELATIVE?e.createRelativeVarianceBar(t.scenario1,i).draw():e.createVarianceBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale)}));const n=s.bbox();return this.scenariosArea={height:n.height+this.styles.padding.top+this.styles.padding.bottom,width:n.width+this.position.spacings.columnWidth},s}sortSegmentsByPropOrder(t){if(0===this.scenarioPropOrder.length)return;const i=this.scenarioPropOrder;t.sort(((t,s)=>{const e=i.indexOf(t.scenario),n=i.indexOf(s.scenario);return(-1===e?i.length:e)-(-1===n?i.length:n)}))}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),e=this.stackConfig.by===ut.SCENARIOS;t.forEach(((t,i)=>{const n=["scenario1","scenario2","scenario3","scenario4"],r=[];if(e){for(const i of n){const s=t[i];s&&!s.isEmpty()&&null!=s.value&&r.push({value:s.value,scenario:s.scenario,dataPoint:s})}this.sortSegmentsByPropOrder(r)}else{const i=t.scenario1;i&&!i.isEmpty()&&null!=i.value&&r.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0!==r.length)if((e?new Set(r.map((t=>Zt(t.scenario)))):new Set).size>1){const t=new Map;for(const i of r){const s=Zt(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const e=[];for(const i of Kt)t.has(i)&&(e.push({prefix:i,segments:t.get(i)}),t.delete(i));for(const[i,s]of t)e.push({prefix:i,segments:s});e.forEach(((t,n)=>{const r=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),a=e.length-1-n;let o=0,h=null;t.segments.forEach((t=>{const e=new me(this.position,this.styles,t.dataPoint,i,o,t.scenario,a,this.stackConfig.mode,r,!0,s);e.draw(this.dataFormatDigits,this.measureScale),o+=Math.abs(t.value),h=e})),h&&h.drawTotalLabel(this.dataFormatDigits,this.measureScale)}))}else{"asc"===this.stackConfig.order?r.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&r.sort(((t,i)=>i.value-t.value));const t=r.reduce(((t,i)=>t+Math.abs(i.value)),0);let n=0,a=null;r.forEach(((r,o)=>{const h=new me(this.position,this.styles,r.dataPoint,i,n,r.scenario,o,this.stackConfig.mode,t,e,s);h.draw(this.dataFormatDigits,this.measureScale),n+=Math.abs(r.value),a=h})),a&&a.drawTotalLabel(this.dataFormatDigits,this.measureScale)}}));const n=s.bbox();this.scenariosArea={height:n.height+this.styles.padding.top+this.styles.padding.bottom,width:n.width+this.position.spacings.columnWidth}}drawStackedHeaders(t,i){if(!this.stackConfig||0===t.length)return;if(this.stackConfig.by!==ut.SCENARIOS)return;const s=i.group().id("StackedHeaders"),e=t[0],n=["scenario1","scenario2","scenario3","scenario4"],r=[];for(const t of n){const i=e[t];i&&!i.isEmpty()&&null!=i.value&&r.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0===r.length)return;this.sortSegmentsByPropOrder(r);const a=new Set(r.map((t=>Zt(t.scenario)))),o=this.position.getColumnPositionY(),h=this.position.getColumnCenterPositionX(0)-this.position.getColumnWidth()/2-this.position.spacings.labelToColumn;if(a.size>1){const t=new Map;for(const i of r){const s=Zt(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const i=[];for(const s of Kt)t.has(s)&&(i.push({prefix:s,segments:t.get(s)}),t.delete(s));for(const[s,e]of t)i.push({prefix:s,segments:e});i.forEach(((t,e)=>{const n=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),r=t.segments[0].dataPoint.pixelPerUnit,a=this.stackConfig.mode===ft.RELATIVE?Rt*r:n*r,l=e===i.length-1?o-a/2:o-a,c=this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase();new Qt(s,h,l,"STACK_HEADER",c,this.styles,ti.Center,ti.Right).forceStringTypeDraw()}))}else{"asc"===this.stackConfig.order?r.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&r.sort(((t,i)=>i.value-t.value));const t=r.reduce(((t,i)=>t+Math.abs(i.value)),0),i=r[0].dataPoint.pixelPerUnit;let e=0;r.forEach((n=>{let r;r=this.stackConfig.mode===ft.RELATIVE?(0!==t?Math.abs(n.value)/t:0)*Rt*i:Math.abs(n.value*i);const a=o-e-r/2,l=this.i18n.get(n.scenario)||n.scenario;new Qt(s,h,a,"STACK_HEADER",l,this.styles,ti.Center,ti.Right).forceStringTypeDraw(),e+=r}))}}drawStackedAreaScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedAreaScenarios"),e=this.stackConfig.by===ut.SCENARIOS,n=this.stackConfig.mode,r=["scenario1","scenario2","scenario3","scenario4"];if(0===(e?r.filter((i=>t.some((t=>t[i]&&!t[i].isEmpty())))).length:1))return;const a=[],o=[],h=[];for(const i of r)t.some((t=>t[i]&&!t[i].isEmpty()))&&h.push(i);if(e&&this.scenarioPropOrder.length>0){const i=this.scenarioPropOrder;h.sort(((s,e)=>{var n,r,a,o;const h=i.indexOf(null!==(r=null===(n=t[0][s])||void 0===n?void 0:n.scenario)&&void 0!==r?r:""),l=i.indexOf(null!==(o=null===(a=t[0][e])||void 0===a?void 0:a.scenario)&&void 0!==o?o:"");return(-1===h?i.length:h)-(-1===l?i.length:l)}))}for(let i=0;i<h.length;i++){const s=h[i],e=[];for(let r=0;r<t.length;r++){const o=t[r][s],l=o&&!o.isEmpty()&&null!=o.value?o.value:0,c=i>0?a[i-1][r]:0;if(n===ft.RELATIVE){const i=h.reduce(((i,s)=>{const e=t[r][s];return i+(e&&!e.isEmpty()&&null!=e.value?Math.abs(e.value):0)}),0),s=0!==i?Math.abs(l)/i:0;e.push(c+s)}else e.push(c+l)}a.push(e);const r=t[0][s];o.push((null==r?void 0:r.scenario)||"ac1")}const l=this.position.getColumnPositionY(),c=this.pixelPerUnit,d=t=>t.map(((t,i)=>({x:this.position.getColumnCenterPositionX(i),y:l-(n===ft.RELATIVE?t*Rt*c:t*c)}))),u=t.map(((t,i)=>({x:this.position.getColumnCenterPositionX(i),y:l})));for(let t=0;t<a.length;t++){const i=d(a[t]),n=0===t?u:d(a[t-1]),r=new ye(s,i,n,e?o[t]:null,t,e);r.draw(),r.drawBoundaryLine()}const p=s.bbox();this.scenariosArea={height:p.height+this.styles.padding.top+this.styles.padding.bottom,width:p.width+this.position.spacings.columnWidth}}drawOverlayLayer(t,i){const s=i.group().id("Overlay"),e=new $e(this.position,s,this.styles,t.length,this.i18n);if(!0===this.showOverlayAvg){let i=null;const s=function(t){const i=t.reduce(((t,i)=>{var s;return t+((null===(s=i.scenario1)||void 0===s?void 0:s.value)||0)}),0),s=t.filter((t=>{var i;return void 0!==(null===(i=t.scenario1)||void 0===i?void 0:i.value)})).length,e=s>0?i/s:0,n=Object.assign(Object.assign({},t[0]),{scenario1:new ne(e,t[0].scenario1.scenario,t[0].scenario1.pixelPerUnit,t[0].scenario1.variance)}),r=Object.assign(Object.assign({},t[t.length-1]),{scenario1:new ne(e,t[t.length-1].scenario1.scenario,t[t.length-1].scenario1.pixelPerUnit,t[t.length-1].scenario1.variance)});return[n,...t.map((t=>Object.assign(Object.assign({},t),{scenario1:new ne(e,t.scenario1.scenario,t.scenario1.pixelPerUnit,t.scenario1.variance)}))),r]}(t);s.forEach(((t,s)=>{null!=i&&e.createLine(`Ø ${this.i18n.get(t.scenario1.scenario)||t.scenario1.scenario}`,t.scenario1,i,s-1).draw(this.dataFormatDigits,this.measureScale),i=t.scenario1}))}if(!0===this.showOverlayMedian){let i=null;const s=function(t){const i=t.map((t=>{var i;return null===(i=t.scenario1)||void 0===i?void 0:i.value})).filter((t=>void 0!==t)).sort(((t,i)=>t-i)),s=i.length%2==0?(i[i.length/2-1]+i[i.length/2])/2:i[Math.floor(i.length/2)],e=Object.assign(Object.assign({},t[0]),{scenario1:new ne(s,t[0].scenario1.scenario,t[0].scenario1.pixelPerUnit,t[0].scenario1.variance)}),n=Object.assign(Object.assign({},t[t.length-1]),{scenario1:new ne(s,t[t.length-1].scenario1.scenario,t[t.length-1].scenario1.pixelPerUnit,t[t.length-1].scenario1.variance)});return[e,...t.map((t=>Object.assign(Object.assign({},t),{scenario1:new ne(s,t.scenario1.scenario,t.scenario1.pixelPerUnit,t.scenario1.variance)}))),n]}(t);s.forEach(((t,s)=>{null!=i&&e.createLine(`Mdn ${this.i18n.get(t.scenario1.scenario)||t.scenario1.scenario}`,t.scenario1,i,s-1).draw(this.dataFormatDigits,this.measureScale),i=t.scenario1}))}}leftOuterJoinDates(t,i){const s=t.map((t=>t.calcdate)).filter((t=>null!=t&&"boolean"==typeof t.isValid&&t.isValid));if(0===s.length)return t;const e=g.max(...s),n=g.min(...s),r=(new U).datesBetween(n,e,i,this.intervalSpanLimit),a=new Map;return r.forEach(((t,i)=>{a.set(t.toISO(),{id:i,calcdate:t,category:null,ac1:null,ac2:null,ac3:null,ac4:null,pp1:null,pp2:null,pp3:null,pp4:null,fc1:null,fc2:null,fc3:null,fc4:null,pl1:null,pl2:null,pl3:null,pl4:null,isEmpty:!0})})),t.forEach((t=>{const i=t.calcdate.toISO(),s=a.get(i);s&&s.isEmpty&&a.set(i,{id:s.id,calcdate:t.calcdate,category:t.category,ac1:t.ac1,ac2:t.ac2,ac3:t.ac3,ac4:t.ac4,pp1:t.pp1,pp2:t.pp2,pp3:t.pp3,pp4:t.pp4,fc1:t.fc1,fc2:t.fc2,fc3:t.fc3,fc4:t.fc4,pl1:t.pl1,pl2:t.pl2,pl3:t.pl3,pl4:t.pl4,isEmpty:!1})})),Array.from(a.values())}}class Ee{constructor(t,i){this.data=t,this.scenarios=i,this.variances=[],this.title="",this.hideAxisLabels=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.sortOrder=new kt(new Rs).default(),this.level=dt.CATEGORY,this.leftSideOffsetForHorizontalSync=-1,this.dateInterval=C.AUTO,this.axisLabelsMode=vt.SMART,this.intervalSpanLimit=28,this.filter="",this.measureScale=new Jt,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.showOverlayMedian=!0,this.showOverlayAvg=!0,this.chartMode=gt.BAR,this.maxBars=28,this.stackConfig=null,this.lineFullWidth=!0,this.locale="de"}}class ke{constructor(t,i,s,e,n,r){this.dataRowAdapter=t,this.orderAdapter=i,this.stringAdapter=s,this.dataFormatDigitsAdapter=e,this.db=n,this.fromExpr=r}adapt(t){const i=Et.adaptArray(t.data,this.dataRowAdapter),s=Et.adaptArray(t.scenarios,this.stringAdapter),e=new Ee(i,s);return Ot.isArray(t.variances)&&(e.variances=Et.adaptArray(t.variances,this.stringAdapter)),Ot.isString(t.title)&&(e.title=t.title),Ot.isBoolean(t.hideAxisLabels)&&(e.hideAxisLabels=t.hideAxisLabels),Ot.isNumber(t.pixelPerUnit)&&(e.pixelPerUnit=t.pixelPerUnit),Ot.isNumber(t.pixelPerPercentage)&&(e.pixelPerPercentage=t.pixelPerPercentage),Ot.isNumber(t.limit)&&(e.limit=t.limit),Ot.isExisting(t.sortOrder)&&(e.sortOrder=this.orderAdapter.adapt(t.sortOrder)),Ot.isExisting(t.level)&&(e.level=t.level),Ot.isExisting(t.dateInterval)&&(e.dateInterval=t.dateInterval),Ot.isExisting(t.axisLabelsMode)&&(e.axisLabelsMode=t.axisLabelsMode),Ot.isNumber(t.leftSideOffsetForHorizontalSync)&&(e.leftSideOffsetForHorizontalSync=t.leftSideOffsetForHorizontalSync),Ot.isNumber(t.intervalSpanLimit)&&(e.intervalSpanLimit=t.intervalSpanLimit),Ot.isString(t.filter)&&(e.filter=t.filter),Ot.isExisting(t.measureScale)&&(e.measureScale=Os.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale)),Ot.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),Ot.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),Ot.isExisting(t.dataFormatDigits)&&(e.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),Ot.isBoolean(t.showOverlayAvg)&&(e.showOverlayAvg=t.showOverlayAvg),Ot.isBoolean(t.showOverlayMedian)&&(e.showOverlayMedian=t.showOverlayMedian),Ot.isExisting(t.chartMode)&&(e.chartMode=t.chartMode),Ot.isNumber(t.maxBars)&&(e.maxBars=t.maxBars),Ot.isExisting(t.stackConfig)&&(e.stackConfig=t.stackConfig),Ot.isBoolean(t.lineFullWidth)&&(e.lineFullWidth=t.lineFullWidth),Ot.isString(t.locale)&&(e.locale=t.locale),e}default(){return new Ee([],[])}}const Pe=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.scenarios=[],this.variances=[],this.hideAxisLabels=!1,this.pixelPerUnit=2,this.pixelPerPercentage=50,this.limit=0,this.leftSideOffsetForHorizontalSync=-1,this.i18n=new Map,this.order={hierarchy:[],direction:xt.ASC},this.level=dt.CATEGORY,this.dateInterval=C.AUTO,this.intervalSpanLimit=28,this.axisLabelsMode=vt.SMART,this.filter="",this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.showOverlayMedian=!1,this.showOverlayAvg=!1,this.chartMode=gt.BAR,this.maxBars=28,this.stackConfig=null,this.lineFullWidth=!0,this.containerWidth=0,this.dataFormatDigits={percent:2,decimal:1},this.parentDimensions={width:0,height:0}}getDb(){return this.stores||(this.stores=d(this.element)),this.stores.db.db}render(){var t,e,n;if(void 0===this.chart)return i(s,null);if(this.chart.hasNoData()){const t=this.i18n.get("no-data")||"==No Data==";return i(s,null,i("p",{class:"warning"},t))}return i(s,null,i("div",{innerHTML:null===(t=this.pattern)||void 0===t?void 0:t.toString(),class:"hidePatternContainer"}),i("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(e=this.chart)||void 0===e?void 0:e.getFooter()),i("div",{innerHTML:null===(n=this.chart)||void 0===n?void 0:n.toString()}))}async componentWillLoad(){var t;const i=this.prepareConfig(),s=this.prepareStyle(),e=this.containerWidth||0;this.chart=new _e(new Ft(this.ruleSetConfig),this.getDb(),this.tableName,i,s,e),this.chart.setI18n(this.i18n);const n=i.pixelPerUnit<=0;this.autoFitScaling(i,s),this.chart.setAvailableHeight(n?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.height)||0),this.pattern=new ee(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}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.setAvailableWidth(this.containerWidth||0),this.chart.setRuleSet(new Ft(this.ruleSetConfig)),this.chart.setConfig(i);const e=i.pixelPerUnit<=0;this.autoFitScaling(i,s),this.chart.setAvailableHeight(e?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.height)||0),this.pattern=new ee(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}autoFitScaling(t,i){var s;const e=t.pixelPerUnit<=0,n=t.pixelPerPercentage<=0;if(!e&&!n)return;const r=()=>{var i;null===(i=this.reportAutoScaling)||void 0===i||i.call(this,{unit:e?t.pixelPerUnit:void 0,percentage:n?t.pixelPerPercentage:void 0})},a=null===(s=this.parentDimensions)||void 0===s?void 0:s.height,o=this.containerWidth||0,h=()=>{this.chart=new _e(new Ft(this.ruleSetConfig),this.getDb(),this.tableName,t,i,o),this.chart.setI18n(this.i18n)},l=()=>(this.chart.layout(),this.chart.getAllocatedCanvasHeight());if(!a||a<=0)return e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=50),h(),void r();e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=1),h();let c=l();if(c<=0)return void r();const d=Math.max(Bs,.9*a/c);let u=!1,p=!1,f=null;for(let i=0;i<=3;i++){const i=js({target:a,measured:c,unitExtent:e?this.chart.getUnitBarExtent():0,pctExtent:n?this.chart.getPercentBarExtent():0,currentPpu:t.pixelPerUnit,currentPpp:t.pixelPerPercentage});if(void 0===i.ppu&&void 0===i.ppp)break;if(e&&void 0!==i.ppu&&(t.pixelPerUnit=i.ppu,u=!0),n&&void 0!==i.ppp&&(t.pixelPerPercentage=i.ppp,p=!0),h(),c=l(),c<=a+.5&&(f={ppu:t.pixelPerUnit,ppp:t.pixelPerPercentage},c>=.98*a))break}let v=!1;if(e&&!u&&(t.pixelPerUnit=d,v=!0),n&&!p&&(t.pixelPerPercentage=d,v=!0),c>a+.5){if(f)u&&(t.pixelPerUnit=f.ppu),p&&(t.pixelPerPercentage=f.ppp);else{const i=a/c;e&&(t.pixelPerUnit=Math.max(Bs,t.pixelPerUnit*i)),n&&(t.pixelPerPercentage=Math.max(Bs,t.pixelPerPercentage*i))}v=!0}v&&h(),r()}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){var t,i,s;const e=this.getDb(),n=this.tableName?m(this.tableName,this.filter):"";return new ke(new ae,new kt(new Rs),new Rs,new qs,e,n).adapt({scenarios:this.scenarios,variances:this.variances,title:this.chartTitle,hideAxisLabels:this.hideAxisLabels,pixelPerUnit:this.pixelPerUnit,pixelPerPercentage:this.pixelPerPercentage,level:this.level,dateInterval:this.dateInterval,axisLabelsMode:this.axisLabelsMode,limit:this.limit,sortOrder:this.order,leftSideOffsetForHorizontalSync:this.leftSideOffsetForHorizontalSync,intervalSpanLimit:this.intervalSpanLimit,filter:this.filter,measureScale:this.measureScale,measureUnit:this.measureUnit,showMeasureScale:this.showMeasureScale,dataFormatDigits:this.dataFormatDigits,showOverlayMedian:this.showOverlayMedian,showOverlayAvg:this.showOverlayAvg,chartMode:this.chartMode,maxBars:this.maxBars,stackConfig:this.stackConfig,lineFullWidth:this.lineFullWidth,locale:(null===(s=null===(i=null===(t=this.stores)||void 0===t?void 0:t.context)||void 0===i?void 0:i.state)||void 0===s?void 0:s.locale)||"de"})}prepareStyle(){return new he(new Qs,new zt,new Bt(new Ht),new ni(new Ht),new Vt).adapt(this.styles)}get element(){return e(this)}};Pe.style=':host{position:relative;display:inline-block}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-default{stroke:black;stroke-width:0.1em}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.hide{opacity:0}.footer{margin:0.2em;font-size:0.6em}.footer-hide{display:none}svg#drawCanvas{display:block}';class Te{constructor(t,i,s,e,n,r,a,o,h){this.prefixStyle="prefix",this.isBarChart=!1,this.key=t,this.index=i,this.value=s,this.prefix=r||"",this.cssStyle=e||"",this.prefixStyle=a||"prefix",this.type=n,this.mark=void 0,this.colSpan=o||1,this.measureScale=h||1}getAsHeaderList(){if(null==this.value)return[""];const t=[];for(const i of this.value.toString().split("<br/>"))t.push(i);return t}draw(t){let i=this.value;if("undefined"===i||void 0===i||null==i)return"";if(Number.isNaN(Number(i)))return i;if(""===this.type||void 0===this.type||null==this.type)return i;let s=t.percent,e=t.percent;return"decimal"===this.type&&(i=+i/this.measureScale,s=t.decimal,e=t.decimal),Gt.number(Number(i),this.type,s,e)}drawPrefix(){return null==this.prefix?"":this.prefix}}class Le{constructor(t,i,s){this.index=t,this.groupindex=i,this.type=s,this.cssStyle=this.initCssStyle(),this.elements=[]}initCssStyle(){switch(this.type){case hs.HEADER:return"groupheader";case hs.SEPERATORLINE:return"";case hs.DRILLELEMENT:return"ofit";case hs.PARTELEMENT:return"partof";case hs.STANDARD:return"";case hs.SUM:return"sum";default:return""}}getCells(){return this.elements}createElement(t,i,s,e,n,r,a,o,h,l=!1,c,d=1,u){let p=r;"category"===i&&null!=o&&(p=`category-${o.toString()}`),this.type===hs.HEADER?p="headerlabel":this.type===hs.SEPERATORLINE&&(p=i),this.type===hs.PARTELEMENT&&("percent"===e&&(t="-"),"category"!==i&&"operation"!==i&&(e="percent",p="")),"-"===t&&(p="");let f="prefix-first";a&&(f="prefix-second"),s&&(p=`${p} ${s}`);const v=new Te(i,this.elements.length,t,p,e,n,f,d,h);v.isBarChart=l,v.columnStats=c,v.waterfall=u,this.elements.push(v)}}const Ae=.85;function Ce(t,i){return Math.max(0,(t-.5)*i)}function Ne(t,i){return Math.max(1,(t?1:0)+(i?1:0))}function Ue(t,i,s,e){const n=Ce(t,i),r=Ne(s,e),a=Math.min(2.85*i,n/(2*r)),o=(n-a*r)/r,h=Math.min(.3*i,.2*o),l=.15*o;return{totalWidth:n,labelAreaWidth:a,maxBarWidth:o,axisX:s?a+o:0,breakGap:h,overdriveZoneWidth:l,cutWidth:Math.max(0,o-h-l),labelGap:.3*i}}function De(t,i,s,e){const n=Ce(t,i),r=Ne(s,e),a=Math.min(3.375*i,n/2),o=n-a,h=o/r,l=Math.min(.375*i,.2*h);return{totalWidth:n,labelAreaWidth:a,maxPinLength:Math.max(0,h-l),pinPadding:l,axisX:s?h:0,labelX:o+.3*i}}const Ge={positive:{stroke:"#008f96",fill:"#008f96",fillpattern:"solid"},negative:{stroke:"#ff0000",fill:"#ff0000",fillpattern:"solid"},neutral:{stroke:"#808080",fill:"#808080",fillpattern:"outlined"},scenarios:{ac:{stroke:"#404040",fill:"#404040",fillpattern:"solid"},pp:{stroke:"#A6A6A6",fill:"#A6A6A6",fillpattern:"solid"},fc:{stroke:"#404040",fill:"#ffffff",fillpattern:"hatched"},pl:{stroke:"#404040",fill:"#ffffff",fillpattern:"outlined"}},fontColor:"#000000",fontSize:11.333305,emPx:13.3333,fontFamily:"'Noto Sans', sans-serif",unitScaling:.01,percentageScaling:.5,scaleFactor:1},We="#666666";function Fe(t,i){return`pattern-${t}-${i.replace("#","")}`}const Ie=({styles:t})=>{const s=t.scaleFactor,e=6*s,n=[{id:Fe("pos",t.positive.stroke),stroke:t.positive.stroke,fill:t.positive.fill},{id:Fe("neg",t.negative.stroke),stroke:t.negative.stroke,fill:t.negative.fill},{id:Fe("neu",t.neutral.stroke),stroke:t.neutral.stroke,fill:t.neutral.fill},...["ac","pp","fc","pl"].map((i=>({id:Fe(i,t.scenarios[i].stroke),stroke:t.scenarios[i].stroke,fill:t.scenarios[i].fill})))];return i("defs",null,n.map((t=>i("pattern",{id:t.id,patternUnits:"userSpaceOnUse",width:e,height:e},i("rect",{width:e,height:e,fill:"#ffffff"}),i("line",{x1:"0",y1:e,x2:e,y2:"0",stroke:t.stroke,"stroke-width":1.5*s})))))};function Ye(t,i,s=1){let e,n;const r=t>=0?"+":"";if(i)return e=100*t,r+Math.round(e).toString()+"%";{let i;return e=t/s,n=Math.abs(e),i=n>=1e9?(e/1e9).toFixed(n>=1e10?0:1)+"B":n>=1e6?(e/1e6).toFixed(n>=1e7?0:1)+"M":n>=1e3?(e/1e3).toFixed(n>=1e4?0:1)+"K":e.toFixed(n>=10?0:1),i=i.replace(/\.0([KMB]?)$/,"$1"),r+i}}function ze(t){const i=t.slice(0,2).toLowerCase();return["ac","pp","fc","pl"].includes(i)}function Be(t){const i=t.slice(0,2).toLowerCase();return"pp"===i?"pp":"fc"===i?"fc":"pl"===i?"pl":"ac"}function He(t,i,s,e){return ze(t)?function(t,i){const s=Be(t);return i.scenarios[s]}(t,e):function(t,i,s){const e=t>=0;return i?e?s.positive:s.negative:e?s.negative:s.positive}(i,s,e)}function Ve(t,i){const s=t.fillpattern;return"hatched"===s?`url(#${Fe(i,t.stroke)})`:"outlined"===s?"transparent":t.fill}function je(t){return"outlined"===t.fillpattern?{stroke:t.stroke,strokeWidth:1.5}:{stroke:"none",strokeWidth:0}}const Xe=t=>{const{value:s,scenario:e,columnStats:n,height:r,isPositiveGood:a,formattedValue:o,measureScale:h,columnWidthEm:l=10,styles:c=Ge}=t,d=c.scaleFactor,u=c.fontSize,p=n.min<0,f=n.max>0,{totalWidth:v,axisX:g,breakGap:m,overdriveZoneWidth:b,cutWidth:w,labelGap:y}=Ue(l,c.emPx,p,f),S=Math.abs(s)*c.unitScaling*u,$=S>w,O=Math.max(0,n.absMax*c.unitScaling*u-w),R=Math.max(0,S-w),M=O>0?R/O*b:0,x=2*d,_=r-2*x,E=x,k=s>=0,P=He(e,s,a,c),T=Ve(P,ze(e)?Be(e):a?k?"pos":"neg":k?"neg":"pos"),{stroke:L,strokeWidth:A}=je(P),C=o||Ye(s,!1,h),N=$?w:S,U=$?w+m+M:S,D=k?g+U+y:g-U-y,G=k?"start":"end";return i("svg",{width:v,height:r,class:"cell-bar-chart absolute-variance",style:{overflow:"visible"}},i(Ie,{styles:c}),i("line",{x1:g,y1:0,x2:g,y2:r,stroke:We,"stroke-width":1*d}),N>0&&i("rect",{x:k?g:g-N,y:E,width:N,height:_,fill:T,stroke:L,"stroke-width":A*d}),$&&M>0&&i("rect",{x:k?g+w+m:g-w-m-M,y:E,width:M,height:_,fill:T,stroke:L,"stroke-width":A*d}),$&&function(t,s,e,n,r){const a=t+s/2,o=.35*s,h=n/3,l=.3*s;let c=`M ${a-o} ${e}`;for(let t=0;t<3;t++)c+=` L ${a-o-l} ${e+h*(t+.5)} L ${a-o} ${e+h*(t+1)}`;let d=`M ${a+o} ${e}`;for(let t=0;t<3;t++)d+=` L ${a+o+l} ${e+h*(t+.5)} L ${a+o} ${e+h*(t+1)}`;return[i("rect",{x:t,y:e-1,width:s,height:n+2,fill:"#ffffff"}),i("path",{d:c,fill:"none",stroke:"#000000","stroke-width":1*r}),i("path",{d,fill:"none",stroke:"#000000","stroke-width":1*r})]}(k?g+w:g-w-m,m,E,_,d),i("text",{x:D,y:r/2,dy:"0.35em","text-anchor":G,fill:c.fontColor,"font-size":u,"font-family":c.fontFamily},C))},Je=t=>{const{value:s,scenario:e,columnStats:n,height:r,isPositiveGood:a,formattedValue:o,measureScale:h,columnWidthEm:l=10,styles:c=Ge}=t,d=c.scaleFactor,u=c.fontSize,p=n.min<0,f=n.max>0,{totalWidth:v,maxPinLength:g,axisX:m,labelX:b}=De(l,c.emPx,p,f),w=r/2,y=100*Math.abs(s)*c.percentageScaling*u,S=y>g,$=Math.min(y,g),O=s>=0,R=O?m+$:m-$,M=He(e,s,a,c),x=3*d,_=o||Ye(s,!0,h);return i("svg",{width:v,height:r,class:"cell-bar-chart relative-variance",style:{overflow:"visible"}},i("line",{x1:m,y1:0,x2:m,y2:r,stroke:We,"stroke-width":1*d}),!S&&i("circle",{cx:R,cy:w,r:x,fill:c.fontColor}),i("line",{x1:m,y1:w,x2:R,y2:w,stroke:M.fill,"stroke-width":2*d}),S&&O&&i("polygon",{points:`${m+g},${w} ${m+g-6*d},${w-3*d} ${m+g-6*d},${w+3*d}`,fill:M.fill}),S&&!O&&i("polygon",{points:`${m-g},${w} ${m-g+6*d},${w-3*d} ${m-g+6*d},${w+3*d}`,fill:M.fill}),i("text",{x:b,y:r/2,dy:"0.35em","text-anchor":"start",fill:c.fontColor,"font-size":u,"font-style":"italic","font-family":c.fontFamily},_))},qe=t=>{const{value:s,columnStats:e,isRelative:n,styles:r=Ge}=t;return null==s||isNaN(s)||!e||0===e.absMax?i("span",{class:"bar-chart-empty",style:{color:r.fontColor,fontStyle:"italic"}},"-"):i(n?Je:Xe,Object.assign({},t))},Ze=t=>{const{value:s,scenario:e,height:n,measureScale:r,columnWidthEm:a=10,styles:o=Ge,waterfall:h}=t,l=o.scaleFactor,c=o.fontSize,d=h.max-h.min;if(null==s||isNaN(s)||d<=0)return i("span",{class:"bar-chart-empty",style:{color:o.fontColor,fontStyle:"italic"}},"-");const{totalWidth:u,labelAreaWidth:p,barAreaWidth:f,labelGap:v}=function(t,i){const s=Ce(t,i),e=Math.min(2.85*i,s/4);return{totalWidth:s,labelAreaWidth:e,barAreaWidth:s-2*e,labelGap:.3*i}}(a,o.emPx),g=f/d,m=t=>p+(t-h.min)*g,b=2*l,w=n-2*b,y=b,S=m(0),$=m(h.start),O=m(h.end),R=Math.min($,O),M=Math.abs(O-$),x=He(e,s,!1,o),_=Ve(x,Be(e)),{stroke:E,strokeWidth:k}=je(x),P=Ye(s,"partof"===h.kind,r).replace(/^\+/,""),T=O<$,L=T?R-v:R+M+v,A=T?"end":"start";return i("svg",{width:u,height:n,class:"cell-bar-chart waterfall-bar",style:{overflow:"visible"}},i(Ie,{styles:o}),i("line",{x1:S,y1:0,x2:S,y2:n,stroke:We,"stroke-width":1*l}),void 0!==h.parentStart&&void 0!==h.parentEnd&&i("line",{x1:m(h.parentStart),y1:0,x2:m(h.parentStart),y2:n,stroke:We,"stroke-width":1*l,"stroke-dasharray":`${2*l},${2*l}`}),void 0!==h.parentStart&&void 0!==h.parentEnd&&i("line",{x1:m(h.parentEnd),y1:0,x2:m(h.parentEnd),y2:n,stroke:We,"stroke-width":1*l,"stroke-dasharray":`${2*l},${2*l}`}),M>0&&i("rect",{x:R,y,width:M,height:w,fill:_,stroke:E,"stroke-width":k*l}),i("text",{x:L,y:n/2,dy:"0.35em","text-anchor":A,fill:o.fontColor,"font-size":c,"font-family":o.fontFamily},P))};class Ke{constructor(t){this.groups=[jt.CATEGORY,jt.CATEGORYINDEX],as.OPT!==t.type&&as.OPTNOTOTAL!==t.type||this.groups.unshift(jt.OPERATION),t.grouped&&(this.groups.push(jt.ROWGROUP),this.groups.push(jt.ROWGROUPINDEX))}toString(){return this.groups.map((t=>`${t}`)).toString()}noCategory(){return this.groups.filter((t=>t!==jt.CATEGORY))}toArray(){return this.groups}}class Qe{constructor(t,i){this.hasPartOf=!1,this.config=t,this.i18n=i}execute(t,i){var s;this.db=t,this.fromExpr=i;const e=[],n=[],r=[],a=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),o=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),h=this.getRelativeScenarios(),l=this.config.attributes.map((t=>this.translateAttributeSQL(t))).toString(),c=new Ke(this.config),d=this.config.grouped?[jt.ROWGROUP,jt.ROWGROUPINDEX]:[];let u,p=["",""];this.config.sortOrder.hierarchy.length>0&&(p=this.createOrderString(this.config.sortOrder)),this.hasPartOf=this.checkConfigForPartOf();try{u=t.exec(`SELECT COUNT(DISTINCT ${jt.CATEGORY}) as ${jt.TOTALROWCOUNT} ${d.length>0?","+d:""}\n FROM ${i} ${d.length>0?"GROUP BY "+d:""}\n ORDER BY ${p[0]}`)}catch(t){return console.error("DataQuery: meta query failed",t),[]}return 0===u.length||1===u.length&&0===(null!==(s=u[0][jt.TOTALROWCOUNT])&&void 0!==s?s:0)&&0===d.length?[]:(u.forEach((t=>{const i=t.rowGroup&&t.rowGroup.length>0?`WHERE ${jt.ROWGROUP} = '${t.rowGroup}'`:"";let s="";this.config.limit&&(s=`LIMIT ${this.config.limit}`),this.createGroupHeaderRow(t,e),this.createDataRow(e,t,c,a,l,i,p,s),this.createRestRow(t,e,c,a,i,p),this.createGroupSumRow(e,n,t,o,p)})),this.createTotalSumRow(e,n,o),e.forEach((i=>{try{r.push(t.exec(i))}catch(t){console.error("DataQuery: SQL query execution failed",i,t)}})),this.detectNaNCells(this.config.scenarios,r),this.createThereOfDrillRows(a,l,p,r),this.createPartOfDrillRows(a,p,n,r),this.createIntervalColumns(r),this.createThereOfDrillColumns(this.config.categoryThereOf,r),this.calculateColumnGroupRest(r,this.config.categoryThereOf),this.calculateRelativeVariances(r,h),r)}detectNaNCells(t,i){i.forEach((i=>{i.map((i=>(t.forEach((t=>{const s=new Yt(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)))}))}createPartOfDrillRows(t,i,s,e){if(null==this.config.partOf||0===this.config.partOf.length||this.config.type===as.LIST)return;const n=this.createPartOfQuery(t,i);let r=[];const a=this.db;n.forEach((function(t){r.push(...a.exec(t))}));const o=this.exctractScenarioNames(t),h=[];s.forEach((function(t){h.push(...a.exec(t))}));const l=new Map;h.forEach((t=>l.set(t[jt.ROWGROUP],t))),r=this.reduceResDrillByCategoryGroups(r,o),r.forEach((function(t){o.forEach((i=>{try{t[i]=t[i]/l.get(t[jt.ROWGROUP])[i]}catch(s){console.error("DataQuery: partOf drill row calculation failed",i,s),t[i]=Number.NaN}}))})),this.injectDrillRowsToResultRows(r,e)}createRestRow(t,i,s,e,n,r){if(t.totalRowCnt-this.config.limit>0&&0!==this.config.limit){const a=this.exctractScenarioNames(e).map((t=>`SUM(${t}) as ${t}`)).join(", ");i.push(`SELECT ${jt.ROWNR}, 1 as ${jt.ROWGROUPINDEX} , 'ENTRY' as ${jt.TYPE}, 'NO_GROUP' as ${jt.ROWGROUP}, 'REST' as ${jt.CATEGORY} ${a.length>0?", "+a:""} FROM (SELECT ROWNUM() AS ${jt.ROWNR}, ${i.length} as ${jt.ROWGROUPINDEX} , 'ENTRY' as ${jt.TYPE}, '${t.rowGroup||"NO_GROUP"}' as ${jt.ROWGROUP}, ${s} ${e.length>0?",".concat(e):""} FROM ${this.fromExpr} ${n} GROUP BY ${s} ORDER BY ${r[0]}) t WHERE t.rowNr > ${this.config.limit}`)}}createDataRow(t,i,s,e,n,r,a,o){t.push(`SELECT ROWNUM() AS ${jt.ROWNR},\n ${t.length} as ${jt.ROWGROUPINDEX},\n 'ENTRY' as ${jt.TYPE},\n '${i.rowGroup||"NO_GROUP"}' as ${jt.ROWGROUP},\n '${jt.CATEGORYINDEX}',\n ${s} ${e.length>0?",".concat(e):""} ${n.length>0?",".concat(n):""}\n FROM ${this.fromExpr} ${r}\n GROUP BY ${s}\n ORDER BY ${a[0]} ${o}`)}createGroupHeaderRow(t,i){!0===this.config.grouped&&i.push(`SELECT ROWNUM() AS ${jt.ROWNR},\n ${i.length} as ${jt.ROWGROUPINDEX},\n 'GROUPHEAD' as ${jt.TYPE},\n '${t.rowGroup}' as ${jt.ROWGROUP} ${this.config.showGroupTitle?`,'${t.rowGroup}' as ${jt.CATEGORY}`:""}\n FROM ${this.fromExpr}\n GROUP BY '1'`)}createGroupSumRow(t,i,s,e,n){!0!==this.config.grouped||as.SUM!==this.config.type&&as.SUMNOTOTAL!==this.config.type&&as.OPT!==this.config.type&&as.OPTNOTOTAL!==this.config.type||(t.push(`SELECT ${t.length} as ${jt.ROWGROUPINDEX},\n '=' as ${jt.OPERATION},\n '${s.rowGroup}' as ${jt.ROWGROUP},\n ROWNUM() AS ${jt.ROWNR},\n 'GROUP_SUM' as ${jt.TYPE} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr}\n WHERE ${jt.ROWGROUP} = '${s.rowGroup}'\n ORDER BY ${n[0]} `),i.push(`SELECT ${t.length} as ${jt.ROWGROUPINDEX},\n '=' as ${jt.OPERATION},\n '${s.rowGroup}' as ${jt.ROWGROUP},\n ROWNUM() AS ${jt.ROWNR},\n 'GROUP_SUM' as ${jt.TYPE} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr}\n WHERE ${jt.ROWGROUP} = '${s.rowGroup}'\n ORDER BY ${n[0]} `))}createTotalSumRow(t,i,s){var e;if(as.SUM===this.config.type||as.OPT===this.config.type){const i=(null===(e=this.config.title)||void 0===e?void 0:e.trim())||"SUM_TOTAL",n=this.hasPartOf&&!1===this.config.grouped&&"SUM_TOTAL"!==i?`${this.i18n.get("SUM_TOTAL")||"SUM_TOTAL"} ${i}`:i;t.push(`SELECT ${t.length} as ${jt.ROWGROUPINDEX},\n '${n}' as ${jt.ROWGROUP},\n '=' as ${jt.OPERATION},\n 'SUM' as ${jt.TYPE} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr} `)}i.push(`SELECT ${t.length} as ${jt.ROWGROUPINDEX},\n 'SUM_TOTAL' as ${jt.ROWGROUP},\n '=' as ${jt.OPERATION},\n 'SUM' as ${jt.TYPE} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr} `)}reduceResDrillByCategoryGroups(t,i){const s=new Map;return t.forEach((function(t){const e=t.rowNr+t.rowGroup+t.type+t.category;if(s.has(e)){const n=s.get(e);i.forEach((i=>{try{n[i]+=t[i]}catch(t){console.error("DataQuery: drill row aggregation failed",i,t)}}))}else s.set(e,t)})),[...s.values()]}injectDrillRowsToResultRows(t,i){const s=new Map;if(!0===this.config.grouped)t.forEach((function(t){i.forEach((function(i){const e=i.findIndex((i=>i.category===t.category&&i.rowGroup===t.rowGroup));if(e>=0){if(s.has(`${t.category}_${t.rowGroup}`)){const i=s.get(`${t.category}_${t.rowGroup}`)||0;s.set(`${t.category}_${t.rowGroup}`,i+1)}else s.set(`${t.category}_${t.rowGroup}`,1);t[jt.ROWNR]=s.get(`${t.category}_${t.rowGroup}`),i.splice(e+t[jt.ROWNR],0,t)}}))}));else{const e=this.findDuplicateSubCategories(t);t.forEach((function(t){i.forEach((function(i){const n=i.findIndex((i=>null!=i.category&&i.category===t.category));if(n>=0){if(s.has(`${t.category}`)){const i=s.get(`${t.category}`)||0;s.set(`${t.category}`,i+1)}else s.set(`${t.category}`,1);(1===t[jt.ROWNR]||e.includes(t.subCategory))&&(t.subCategory=`${t.subCategory} (${t.rowGroup})`),i.splice(n+t[jt.ROWNR],0,t)}}))}))}}createThereOfDrillRows(t,i,s,e){if(void 0===this.config.thereOf||0===this.config.thereOf.length)return;const n=[],r=[];this.config.thereOf.forEach((e=>{let r=!0,a="1 <> 1 OR ( ";null!=e.category&&0!==e.category.length&&e.category.trim()&&(a+=` ${jt.CATEGORY} = '${e.category}'`,r=!1),null!=e.rowGroup&&0!==e.rowGroup.length&&e.rowGroup.trim()&&(a+=` ${r?"":"AND"} ${jt.ROWGROUP} = '${e.rowGroup}'`,r=!1),null!=e.subCategory&&0!==e.subCategory.length&&e.subCategory.trim()&&(a+=` ${r?"":"AND"} ${jt.SUBCATEGORY} = '${e.subCategory}'`),a+=")",n.push(`SELECT ROWNUM() AS ${jt.ROWNR},\n null as operation,\n 'DRILLELEMENT' as ${jt.TYPE},\n ${jt.CATEGORY},\n ${jt.SUBCATEGORY},\n ${jt.ROWGROUP} as ${jt.ROWGROUP},\n ${t} ${i.length>0?",".concat(i):""}\n FROM ${this.fromExpr}\n WHERE ${a}\n GROUP BY ${jt.ROWGROUP}, ${jt.CATEGORY}, ${jt.SUBCATEGORY}\n ORDER BY ${s[1]}`)}));const a=this.db;n.forEach((function(t){r.push(...a.exec(t))})),this.injectDrillRowsToResultRows(r,e)}calculateRelativeVariances(t,i){t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[jt.TYPE]&&i.forEach(((i,s)=>{t[s]=t[s]/t[i]}))}))}))}calculateColumnGroupRest(t,i){if(null==i||0===i.size)return;const s=new Map,e=new Map;i.forEach(((t,i)=>{const n=t,r=[];for(const t of n)r.push(`${i}##${t.name}`);s.set(i,r),e.set(`${i}##REST`,!1)})),t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[jt.TYPE]&&s.forEach(((i,s)=>{let n=0;i.forEach((i=>{void 0!==t[i]&&(n+=t[i])})),t[`${s}##REST`]=t[s]-n,0!==t[`${s}##REST`]&&e.set(`${s}##REST`,!0)}))}))}));const n=Array.from(e.entries()).filter((([t,i])=>!i)).map((([t])=>t));t.forEach((t=>{t.forEach((t=>{for(const i of n)delete t[i]}))}))}createIntervalColumns(t){var i,s,e,n,r;if(this.config.interval===ls||this.config.categoryThereOf.size>0||0===this.config.scenarios.length)return;const a="##",o=`(SELECT *, ${ds(this.config.interval)} as __interval FROM ${this.fromExpr}) as p`,h=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),l=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),c=this.exctractScenarioNames(h),d=this.getRelativeScenarios(),u=new Ke(this.config),p=as.OPT===this.config.type||as.OPTNOTOTAL===this.config.type,f=this.config.grouped&&(as.SUM===this.config.type||as.SUMNOTOTAL===this.config.type||as.OPT===this.config.type||as.OPTNOTOTAL===this.config.type),v=this.checkConfigForPartOf()&&this.config.type!==as.LIST,g=t=>{try{return this.db.exec(t)}catch(i){return console.error("DataQuery: interval query failed",t,i),[]}},m=t=>(this.config.scenarios.forEach((i=>{const s=new Yt(i);!0===s.isValid?0!==t[s.base+"_cnt"]&&0!==t[s.delta+"_cnt"]||(t[i]=Number.NaN):0===t[i+"_cnt"]&&(t[i]=Number.NaN)})),d.forEach(((i,s)=>{t[s]=t[s]/t[i]})),t),b=(t,i,s)=>{for(const e of this.config.scenarios)t[e+a+s]=i[e]},w=g(`SELECT ${u}, __interval ${h.length>0?",".concat(h):""}\n FROM ${o}\n GROUP BY ${u}, __interval`);if(this.config.limit>0)for(let e=0;e<t.length;e++){const n=t[e].find((t=>"ENTRY"===t.type&&"REST"===t.category));if(!n)continue;let r;for(let i=e-1;i>=0&&!r;i--){const s=t[i].filter((t=>"ENTRY"===t.type&&"REST"!==t.category));s.length>0&&(r=s)}if(!r)continue;const a=new Set(r.map((t=>t.category))),o=r[0].rowGroup,h=new Map;for(const t of w){if(this.config.grouped&&t.rowGroup!==o)continue;if(a.has(t.category))continue;const e=us(t.__interval);let n=h.get(e);n||(n={},h.set(e,n));for(const e of c)n[e]=(null!==(i=n[e])&&void 0!==i?i:0)+(null!==(s=t[e])&&void 0!==s?s:0)}h.forEach(((t,i)=>{b(n,m(t),i)}))}for(const i of w){const s=us(i.__interval);m(i);for(const e of t)for(const t of e)"ENTRY"===t.type&&"REST"!==t.category&&t.category===i.category&&(this.config.grouped&&t.rowGroup!==i.rowGroup||p&&t.operation!==i.operation||b(t,i,s))}const y=f||v&&this.config.grouped?g(`SELECT ${jt.ROWGROUP}, __interval ${l.length>0?",".concat(l):""}\n FROM ${o}\n GROUP BY ${jt.ROWGROUP}, __interval`):[],S=new Map;if(y.forEach((t=>S.set(`${t.rowGroup}${a}${us(t.__interval)}`,t))),f)for(const i of y){const s=us(i.__interval),e=m(Object.assign({},i));for(const n of t)for(const t of n)"GROUP_SUM"===t.type&&t.rowGroup===i.rowGroup&&b(t,e,s)}const $=as.SUM===this.config.type||as.OPT===this.config.type,O=$||v&&!this.config.grouped?g(`SELECT __interval ${l.length>0?",".concat(l):""}\n FROM ${o}\n GROUP BY __interval`):[],R=new Map;if(O.forEach((t=>R.set(us(t.__interval),t))),$)for(const i of O){const s=us(i.__interval),e=m(Object.assign({},i));for(const i of t)for(const t of i)"SUM"===t.type&&b(t,e,s)}if(null!=this.config.thereOf&&this.config.thereOf.length>0){const i=[];this.config.thereOf.forEach((t=>{i.push(...g(`SELECT ${jt.ROWGROUP}, ${jt.CATEGORY}, ${jt.SUBCATEGORY}, __interval ${h.length>0?",".concat(h):""}\n FROM ${o}\n WHERE ${this.createThereOfWhereClause(t)}\n GROUP BY ${jt.ROWGROUP}, ${jt.CATEGORY}, ${jt.SUBCATEGORY}, __interval`))}));for(const s of i){const i=us(s.__interval);m(s);for(const e of t)for(const t of e)"DRILLELEMENT"===t.type&&t.category===s.category&&(t.subCategory!==s.subCategory&&t.subCategory!==`${s.subCategory} (${s.rowGroup})`||b(t,s,i))}}if(v){let i="1 <> 1 ";null===(e=this.config.partOf)||void 0===e||e.forEach((t=>{i+=`OR (${jt.CATEGORY} = '${t.category}'`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(i+=`and ${jt.ROWGROUP} = '${t.rowGroup}'`),i+=")"}));const s=g(`SELECT ${jt.CATEGORY}, ${this.config.grouped?`${jt.ROWGROUP}`:`'SUM_TOTAL' as ${jt.ROWGROUP}`}, __interval ${h.length>0?",".concat(h):""}\n FROM ${o}\n WHERE ${i}\n GROUP BY ${jt.ROWGROUP}, ${jt.CATEGORY}, __interval`),l=new Map;for(const t of s){const i=`${t.rowGroup}${a}${t.category}${a}${us(t.__interval)}`,s=l.get(i);if(s)for(const i of c)s[i]=(null!==(n=s[i])&&void 0!==n?n:0)+(null!==(r=t[i])&&void 0!==r?r:0);else l.set(i,t)}l.forEach((i=>{const s=us(i.__interval),e=this.config.grouped?S.get(`${i.rowGroup}${a}${s}`):R.get(s);for(const t of c)i[t]=i[t]/(e?e[t]:Number.NaN);m(i);for(const e of t)for(const t of e)"PARTELEMENT"===t.type&&t.category===i.category&&t.rowGroup===i.rowGroup&&b(t,i,s)}))}}createThereOfWhereClause(t){let i=!0,s="1 <> 1 OR ( ";return null!=t.category&&0!==t.category.length&&t.category.trim()&&(s+=` ${jt.CATEGORY} = '${t.category}'`,i=!1),null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(s+=` ${i?"":"AND"} ${jt.ROWGROUP} = '${t.rowGroup}'`,i=!1),null!=t.subCategory&&0!==t.subCategory.length&&t.subCategory.trim()&&(s+=` ${i?"":"AND"} ${jt.SUBCATEGORY} = '${t.subCategory}'`),s+")"}getRelativeScenarios(){const t=new Map;return this.config.scenarios.forEach((i=>{const s=this.createRelativeScenario(i);null!=s&&t.set(s.key,s.value)})),t}translateScenarioSQL(t,i,s){const e=new Yt(t);return as.OPT===s||as.OPTNOTOTAL===s?e.isValid?"dr"===e.type?`SUM(${e.base} - ${e.delta}) as ${t}, SUM(${e.delta}) as dr_${e.delta}`:`SUM(${e.base} - ${e.delta}) as ${t}`:i?`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`:`SUM(${t}) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`:e.isValid?"dr"===e.type?`SUM((${e.base} * transformOperator(operation)) - (${e.delta} * transformOperator(operation))) as ${t}, SUM(${e.delta} * transformOperator(operation)) as dr_${e.delta}`:`SUM((${e.base} * transformOperator(operation))- (${e.delta} * transformOperator(operation))) as ${t}`:`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}translateAttributeSQL(t){const i=`[${t.arg}]`,s=/^(ac|pp|fc|pl)[1-4]$/.test(t.arg)&&this.config.type!==as.OPT&&this.config.type!==as.OPTNOTOTAL;switch(t.fn){case"set":return`SETAGG(${i}) as ${t.alias}`;case"first":return`FIRST(${i}) as ${t.alias}`;case"last":return`LAST(${i}) as ${t.alias}`;case"min":return`MIN(${i}) as ${t.alias}`;case"max":return`MAX(${i}) as ${t.alias}`;case"avg":return s?`AVG(${i} * transformOperator(operation)) as ${t.alias}`:`AVG(${i}) as ${t.alias}`;case"sum":return s?`SUM(${i} * transformOperator(operation)) as ${t.alias}`:`SUM(${i}) as ${t.alias}`;case"lit":return`${this.sqlLiteral(t.arg)} as ${t.alias}`}}sqlLiteral(t){return""===t||Number.isNaN(Number(t))?`'${t.replace(/'/g,"''")}'`:t}createOrderString(t){return[`${t.hierarchy.toString()} ${t.direction}`,`${t.hierarchy.toString()} ${os.ASC===t.direction?os.DESC:os.ASC}`]}createRelativeScenario(t){const i=new Yt(t);return i.isValid&&"dr"===i.type?{key:`${t}`,value:`dr_${i.delta}`}:null}exctractScenarioNames(t){const i=[];return t.split(",").forEach((t=>t.length>=2?i.push(t.split("as")[1].trim()):null)),i}findDuplicateSubCategories(t){const i=t.map((t=>({count:1,subCategory:t.subCategory}))).reduce(((t,i)=>(t[i.subCategory]=(t[i.subCategory]||0)+i.count,t)),{});return Object.keys(i).filter((t=>i[t]>1))}createPartOfQuery(t,i){var s;const e=[];let n="1 <> 1 ",r=` ${jt.ROWGROUP}`,a="ROWNUM()";return null===(s=this.config.partOf)||void 0===s||s.forEach((t=>{n+=`OR (${jt.CATEGORY} = '${t.category}'`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(n+=`and ${jt.ROWGROUP} = '${t.rowGroup}'`),!1===this.config.grouped&&(r=` 'SUM_TOTAL' as ${jt.ROWGROUP} `,a="1"),n+=")"})),e.push(`SELECT ${a} AS ${jt.ROWNR},\n 'PARTELEMENT' as ${jt.TYPE},\n ${jt.CATEGORY},\n ${r},\n ${t}\n FROM ${this.fromExpr}\n WHERE ${n}\n GROUP BY ${jt.ROWGROUP}, ${jt.CATEGORY}, ${jt.TYPE}\n ORDER BY ${i[1]}`),e}checkConfigForPartOf(){return null!=this.config.partOf&&0!==this.config.partOf.length}createThereOfDrillColumns(t,i){if(null==t||0===t.size)return;const s=[],e=[],n=this.fromExpr;t.forEach(((t,i)=>{let e="1 <> 1 ";t.forEach((t=>{e+=` or columnGroup = '${t.name}' `})),s.push(`SELECT 'ENTRY' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, columnGroup, scenario`),s.push(`SELECT 'ENTRY' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, scenario`),s.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, columnGroup, scenario`),s.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, columnGroup, scenario`),s.push(`SELECT 'SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, columnGroup, columnSubGroup, scenario`)}));for(const t of s)e.push(...this.db.exec(t));this.injectDrillColumnsToResultRows(e,i)}injectDrillColumnsToResultRows(t,i){const s="##";for(const e of t)for(const t of i)for(const i of t)i.type===e.rowlevel&&("ENTRY"===e.rowlevel?"COLUMNGROUP"===e.columnlevel&&i.category===e.category?i[e.scenario+s+e.columnGroup]=e.val:"SUBGROUP"===e.columnlevel&&i.category===e.category&&(i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val):"DRILLELEMENT"===e.rowlevel?"COLUMNGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory?i[e.scenario+s+e.columnGroup]=e.val:"SUBGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory?i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val:"COLUMNGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===`${e.subCategory} (${e.rowGroup})`?i[e.scenario+s+e.columnGroup]=e.val:"SUBGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===`${e.subCategory} (${e.rowGroup})`&&(i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val):("SUM"===e.rowlevel||"GROUP_SUM"===e.rowlevel)&&("COLUMNGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory&&(i[e.scenario+s+e.columnGroup]=e.val),"SUBGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory&&(i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val)))}}class tn{constructor(){this.geometry=new Map}set(t,i,s){let e=this.geometry.get(t);e||(e=new Map,this.geometry.set(t,e)),e.set(i,s)}get(t,i){var s;return null===(s=this.geometry.get(t))||void 0===s?void 0:s.get(i)}}function sn(t,i,s){const e=t[i];if(null==e)return null;const n=Number(e);return isNaN(n)?null:s!==as.OPT&&s!==as.OPTNOTOTAL||t[jt.TYPE]!==hs.ENTRY||"-"!==t[jt.OPERATION]?n:-n}class en{constructor(){this.normalizedHeader=[],this.attributesByAlias=new Map}getNormalizedHeader(){return this.normalizedHeader}createHeader(t,i,s,e,n,r,a=[]){const o=[];this.attributesByAlias=new Map(a.map((t=>[t.alias,t]))),this.normalizedHeader=this.normalizeHeader(t,i,a);const h=this.normalizedHeader.some((t=>void 0!==t.bucket));h&&o.push(this.createIntervalBandRow());const l=new Le(h?1:0,0,hs.HEADER),c=new Le(h?2:1,0,hs.SEPERATORLINE);for(const t of this.normalizedHeader){const i=this.attributesByAlias.get(t.name);l.createElement(i?s.get(i.label)||i.label:Gt.translateScenarioLabel(t.name,s),t.type,this.createColumnType(t),null,this.setHeaderPrefix(t,s,e,n,r),null,null,null,null),c.createElement(null,t.type,this.createColumnType(t),null,null,null,null,null,null)}return o.push(l),o.push(c),o}createIntervalBandRow(){const t=new Le(0,0,hs.HEADER);let i=0;for(;i<this.normalizedHeader.length;){const s=this.normalizedHeader[i];if(void 0===s.bucket){t.createElement(null,s.type,"filler",null,null,null,null,null,null),i+=1;continue}let e=1;for(;i+e<this.normalizedHeader.length&&this.normalizedHeader[i+e].bucket===s.bucket;)e+=1;t.createElement(s.bucketLabel,s.type,"intervalGroup",null,null,null,null,null,null,!1,void 0,e),i+=e}return t}setHeaderPrefix(t,i,s,e,n){let r="";return"category"===t.name&&n&&(0===s.prefix.length&&0===e.length||(r=Gt.translateScenarioLabel("in",i)+" "+s.prefix+e)),t.order&&(r+=Gt.translateScenarioLabel("ORDER_"+t.order,i)),r}normalizeHeader(t,i,s){let e=[{name:jt.CATEGORY,group:jt.CATEGORY,type:jt.CATEGORY,order:void 0}];as.OPT!==t&&as.OPTNOTOTAL!==t||(e=[{name:jt.OPERATION,group:jt.OPERATION,type:jt.OPERATION,order:void 0},{name:jt.CATEGORY,group:jt.CATEGORY,type:jt.CATEGORY,order:void 0}]);const n=s.map((t=>({name:t.alias,group:t.alias,type:t.alias,order:void 0})));return[...e,...n,...i]}createBodyRows(t,i,s,e){var n;const r=[];let a=-1;const o=new Qe(t,i).execute(s,e),h=this.calculateColumnStatistics(o,t.barColumns,t.interval!==ls),l=(null!==(n=t.barColumns)&&void 0!==n?n:[]).filter((t=>t.toUpperCase().trim()in Mt)),c=l.length>0&&t.interval===ls&&0===t.categoryThereOf.size&&function(t){for(const i of t)for(const t of i){const i=t[jt.TYPE];if(i===hs.SUM||i===hs.GROUPSUM||i===hs.DRILLELEMENT||i===hs.PARTELEMENT)return!0}return!1}(o)?function(t,i,s){const e=new tn;for(const n of i){let i,r=0,a=0;const o=[],h=(t,i)=>{o.push(i),e.set(t,n,i)};for(const e of t)for(const t of e){const e=t[jt.TYPE];if(e===hs.GROUPHEAD){i=void 0;continue}const o=sn(t,n,s);if(e===hs.ENTRY){if(null===o){i=void 0;continue}h(t,{start:r,end:r+o,min:0,max:0,kind:"cascade"}),i={start:r,end:r+o},a=i.start,r+=o}else if(e===hs.SUM||e===hs.GROUPSUM){if(null===o){i=void 0;continue}h(t,{start:0,end:o,min:0,max:0,kind:"anchor"}),i={start:0,end:o},a=0,r=o}else if(e===hs.DRILLELEMENT){if(null===o||void 0===i)continue;const s=a+(Math.sign(i.end-i.start)||1)*Math.abs(o);h(t,{start:a,end:s,min:0,max:0,kind:"thereof",parentStart:i.start,parentEnd:i.end}),a=s}else if(e===hs.PARTELEMENT){if(null===o||void 0===i)continue;const s=a+o*(i.end-i.start);h(t,{start:a,end:s,min:0,max:0,kind:"partof",parentStart:i.start,parentEnd:i.end}),a=s}}let l=0,c=0;for(const t of o)l=Math.min(l,t.start,t.end),c=Math.max(c,t.start,t.end);for(const t of o)t.min=l,t.max=c}return e}(o,l,t.type):void 0;for(const s of o)a+=1,r.push(...this.createRow(t.i18n,i,t.scenariosUnitType,s,a,-1,t.categoryWidth,t.measureScale,t.barColumns,h,c));return r}calculateColumnStatistics(t,i,s=!1){const e=new Map;if(!i||0===i.length)return e;const n=new Map;for(const t of i)e.set(t,{min:1/0,max:-1/0,absMax:0,median:0}),n.set(t,[]);for(const r of t)for(const t of r)for(const r of i){const i=s?this.extractIntervalColumnValues(t,r):[this.extractColumnValue(t,r)];for(const t of i)if(null!==t&&!isNaN(t)){const i=e.get(r);i.min=Math.min(i.min,t),i.max=Math.max(i.max,t),n.get(r).push(Math.abs(t))}}for(const[t,i]of e){i.min!==1/0&&i.max!==-1/0||(i.min=0,i.max=0),i.absMax=Math.max(Math.abs(i.min),Math.abs(i.max));const s=n.get(t);if(s.length>0){s.sort(((t,i)=>t-i));const t=Math.floor(s.length/2);i.median=s.length%2==0?(s[t-1]+s[t])/2:s[t]}e.set(t,i)}return e}extractIntervalColumnValues(t,i){const s=i+"##",e=[];for(const i of Object.keys(t))if(i.startsWith(s)){const s=Number(t[i]);e.push(isNaN(s)?null:s)}return e}extractColumnValue(t,i){if(void 0!==t[i]){const s=Number(t[i]);return isNaN(s)?null:s}for(const s of Object.keys(t))if(s===i||s.endsWith("##"+i)||s===i+"##"+i){const i=Number(t[s]);if(!isNaN(i))return i}return null}createRow(t,i,s,e,n,r,a,o,h,l,c){var d;const u=[];for(const p of e){const f=p[jt.ROWGROUP],v=p[jt.SUBCATEGORY],g=p[jt.TYPE],m=p[jt.ROWNR]>=2,b=this.createDetailRow(g,r+=1,n,e.length);for(const e of this.normalizedHeader){const n=this.getRawDataRowElement(p,e),r=null!==(d=null==h?void 0:h.includes(e.type))&&void 0!==d&&d,u=r?null==l?void 0:l.get(e.type):void 0,w=r&&void 0===e.bucket&&e.name===e.group&&e.name===e.type?null==c?void 0:c.get(p,e.type):void 0;b.createElement(this.translateSumCellLabel(t,i,n,f,v,g,e.type),e.type,this.createColumnType(e),this.setCellType(e.type,s),this.translateCellPrefix(i,g,e.type),this.translateScenarioCSS(e.type,n),m,a,null==o?void 0:o.value,r,u,1,w)}u.push(b)}return u}getRawDataRowElement(t,i){return void 0!==i.bucket?t[i.type+"##"+i.bucket]:i.name===i.group&&i.name===i.type?t[i.name]:i.name===i.group&&i.name!==i.type?t[i.type+"##"+i.name]:t[i.type+"##"+i.group+"##"+i.name]}createDetailRow(t,i,s,e){switch(t){case hs.GROUPHEAD:return new Le(i,s,hs.HEADER);case hs.SUM:case hs.GROUPSUM:return new Le(e+2,s,hs.SUM);case hs.DRILLELEMENT:return new Le(e+2,s,hs.DRILLELEMENT);case hs.PARTELEMENT:return new Le(e+2,s,hs.PARTELEMENT);default:return new Le(i,s,hs.STANDARD)}}translateSumCellLabel(t,i,s,e,n,r,a){return this.attributesByAlias.has(a)||!1===Number.isNaN(Number(s))||this.isOperationColumn(a)?s:this.isGroupHeadCategory(r,a)?t===bt.ALL?`${i.get(s)||s}`:s:this.isEntryCategory(r,a)?t===bt.ALL||"REST"===s?`${i.get(s)||s}`:s:this.isDrillElementCategory(r,a)?t===bt.ALL?`${i.get(n)||n}`:`${n}`:this.isPartElementCategory(r,a)?t===bt.ALL||"SUM_TOTAL"===e?`${i.get(e)||e}`:`${e}`:this.isSumElementCategory(r,a)?t===bt.ALL||"SUM_TOTAL"===e?`${i.get(e)||e}`:e:"GROUPHEAD"===r&&null==s?s:Number.isNaN(Number(s))?"-":Number(s)}isOperationColumn(t){return"operation"===t}translateScenarioCSS(t,i){if(this.attributesByAlias.has(t))return"attribute";const s=new Yt(t);let e="pos";return i<0&&(e="neg"),s.isValid?e+"_"+s.direction+("dr"===s.type?" relative_variance":""):t}setCellType(t,i){if("category"===t)return"";const s=this.attributesByAlias.get(t);if(s)return s.isNumeric?"decimal":"";let e;const n=new Yt(t);return i===mt.PERCENT?(e="percent",n.isValid&&"d"===n.type&&(e="decimal")):(e="decimal",n.isValid&&"dr"===n.type&&(e="percent")),e}isDrillElementCategory(t,i){return"DRILLELEMENT"===t&&"category"===i}isPartElementCategory(t,i){return"PARTELEMENT"===t&&"category"===i}isSumElementCategory(t,i){return("GROUP_SUM"===t||"SUM"===t)&&"category"===i}isEntryCategory(t,i){return"ENTRY"===t&&"category"===i}isGroupHeadCategory(t,i){return"GROUPHEAD"===t&&"category"===i}translateCellPrefix(t,i,s){return this.isOperationColumn(s)||this.isGroupHeadCategory(i,s)||this.isEntryCategory(i,s)?null:this.isDrillElementCategory(i,s)?`${t.get("there_of")} `:this.isPartElementCategory(i,s)?`${t.get("part_of")} `:null}createColumnType(t){return t.name===t.group&&t.name===t.type?"base":t.name===t.group?"columnGroup":"columnSubGroup"}}class nn{constructor(t,i,s,e){this.fromExpr="",this.rowCount=0,this.headerRows=[],this.bodyRows=[],this.intervalBuckets=[],this.ruleSet=t||new Ft,this.db=i,this.dataSetFactory=new en,this.config=this.initConfig(e),this.i18n=this.initI18n(new Map),this.setSource(s,e.filter)}setI18n(t){this.i18n=this.initI18n(t)}initI18n(t){const i=new Map([["",""],["SEPERATOR_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"," "],["there_of","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"]]);return this.state=rs.DIRTY,new Map([...i,...t||new Map])}initConfig(t){this.state=rs.DIRTY;const i=t,s=this;return t.scenarios.sort(((t,i)=>s.ruleSet.getScenarioSorIndex(t)-s.ruleSet.getScenarioSorIndex(i))),i}setConfig(t){this.config=this.initConfig(t)}setSource(t,i){var s,e;if(this.state=rs.DIRTY,!t)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=m(t,i);try{const t=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(e=null===(s=t[0])||void 0===s?void 0:s.cnt)&&void 0!==e?e:0}catch(t){this.rowCount=0}}update(){this.prepareIntervalBuckets();const t=this.normalizeScenarios(this.config.scenarios,this.config.categoryThereOf,this.config.sortOrder,this.intervalBuckets);this.headerRows=this.dataSetFactory.createHeader(this.config.type,t,this.i18n,this.config.measureScale,this.config.measureUnit,this.config.showMeasureScale,this.config.attributes),this.bodyRows=0!==this.rowCount&&this.fromExpr?this.dataSetFactory.createBodyRows(this.config,this.i18n,this.db,this.fromExpr):[],this.state=rs.UP_TO_DATE}getHeader(){return this.state===rs.DIRTY&&this.update(),this.headerRows}getBody(){return this.state===rs.DIRTY&&this.update(),this.bodyRows}getColumns(){return this.state===rs.DIRTY&&this.update(),this.dataSetFactory.getNormalizedHeader()}prepareIntervalBuckets(){this.intervalBuckets=[],this.config.interval===ls||!this.fromExpr||this.config.categoryThereOf.size>0?this.config.interval=ls:(this.config.interval=function(t,i,s){var e;if(s!==C.AUTO)return s;let n,r,a;try{n=t.exec(`SELECT [date] as d FROM ${i}`)}catch(t){return console.error("IntervalColumns: date query failed",t),C.DAY}for(const t of n){const i=null===(e=ps(t.d))||void 0===e?void 0:e.toMillis();void 0!==i&&(r=void 0===r?i:Math.min(r,i),a=void 0===a?i:Math.max(a,i))}return void 0===r||void 0===a?C.DAY:(new U).calculateDistanceType(g.fromMillis(r),g.fromMillis(a))}(this.db,this.fromExpr,this.config.interval),this.intervalBuckets=function(t,i,s,e){let n;try{n=t.exec(`SELECT ${ds(s)} as __interval FROM ${i}`)}catch(t){return console.error("IntervalColumns: bucket query failed",t),[]}if(s===cs){const t=new Set,i=[];for(const s of n){const e=us(s.__interval);t.has(e)||(t.add(e),i.push({key:e,label:0===e.length?"—":e}))}return i}const r=new Set,a=[];for(const t of n){const i=ps(t.__interval);if(!i)continue;const s=i.toISO();r.has(s)||(r.add(s),a.push(i))}a.sort(((t,i)=>t.toMillis()-i.toMillis()));const o=new U;return o.setLocale(e),a.map((t=>({key:t.toISO(),label:o.getDateString(t,s)})))}(this.db,this.fromExpr,this.config.interval,this.config.locale),0===this.intervalBuckets.length&&(this.config.interval=ls))}normalizeScenarios(t,i,s,e=[]){var n,r;const a=[];if(e.length>0){for(const i of e)for(const e of t)a.push({name:e,group:e,type:e,order:(null===(n=null==s?void 0:s.hierarchy)||void 0===n?void 0:n.at(0))===e?s.direction:void 0,bucket:i.key,bucketLabel:i.label});return a}for(const e of t){if(null==i?void 0:i.has(e)){const t=i.get(e);for(const i of t){a.push({name:i.name,group:i.name,type:e,order:void 0});for(const t of i.subGroups)a.push({name:t,group:i.name,type:e,order:void 0})}a.push({name:"REST",group:"REST",type:e,order:void 0})}let t;(null===(r=null==s?void 0:s.hierarchy)||void 0===r?void 0:r.at(0))===e&&(t=s.direction),a.push({name:e,group:e,type:e,order:t})}return a}hasNoData(){return 0===this.rowCount}}class rn{constructor(){this.title="",this.scenarios=[],this.scenariosUnitType=mt.DECIMAL,this.grouped=!1,this.showGroupTitle=!0,this.thereOf=[],this.categoryThereOf=new Map,this.partOf=[],this.attributes=[],this.sortOrder=new kt(new Rs).default(),this.type=as.LIST,this.limit=0,this.i18n=bt.ALL,this.categoryWidth=wt.W25,this.measureScale=new Jt,this.measureUnit="",this.measureType=yt.VOLUME,this.showMeasureScale=!0,this.filter="",this.barColumns=[],this.interval="none",this.locale="de"}}class an{constructor(t,i,s,e,n){this.tableDrillGroupAdapter=t,this.stringAdapter=i,this.orderAdapter=s,this.db=e,this.fromExpr=n}adapt(t){const i=new rn;return Ot.isString(t.title)&&(i.title=t.title),Ot.isArray(t.scenarios)&&(i.scenarios=Et.adaptArray(t.scenarios,this.stringAdapter)),Ot.isExisting(t.scenariosUnitType)&&(i.scenariosUnitType=t.scenariosUnitType),Ot.isBoolean(t.grouped)&&(i.grouped=t.grouped),Ot.isBoolean(t.showGroupTitle)&&(i.showGroupTitle=t.showGroupTitle),Ot.isBoolean(t.showMeasureScale)&&(i.showMeasureScale=t.showMeasureScale),Ot.isArray(t.thereOf)&&(i.thereOf=Et.adaptArray(t.thereOf,this.tableDrillGroupAdapter)),Ot.isExisting(t.categoryThereOf)&&(i.categoryThereOf=t.categoryThereOf),Ot.isArray(t.partOf)&&(i.partOf=Et.adaptArray(t.partOf,this.tableDrillGroupAdapter)),Ot.isArray(t.attributes)&&(i.attributes=t.attributes),Ot.isExisting(t.order)&&(i.sortOrder=this.orderAdapter.adapt(t.order)),Ot.isExisting(t.type)&&(i.type=t.type),Ot.isNumber(t.limit)&&(i.limit=t.limit),Ot.isExisting(t.i18n)&&(i.i18n=t.i18n),Ot.isExisting(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),Ot.isExisting(t.measureScale)&&(i.measureScale=Os.calculateMeasureScale(this.db,this.fromExpr,i.scenarios,t.measureScale)),Ot.isExisting(t.measureType)&&(i.measureType=t.measureType),Ot.isString(t.measureUnit)&&(i.measureUnit=t.measureUnit),Ot.isString(t.filter)&&(i.filter=t.filter.trim()),Ot.isArray(t.barColumns)&&(i.barColumns=t.barColumns),Ot.isString(t.interval)&&(i.interval=t.interval),Ot.isString(t.locale)&&(i.locale=t.locale),i}default(){return new rn}}class on{constructor(){this.rowGroup="",this.category="",this.subCategory="",this.partOf=""}}class hn{constructor(){}adapt(t){const i=new on;return Ot.isString(t.rowGroup)&&(i.rowGroup=t.rowGroup),Ot.isString(t.category)&&(i.category=t.category),Ot.isString(t.subCategory)&&(i.subCategory=t.subCategory),Ot.isString(t.partOf)&&(i.partOf=t.partOf),i}default(){return new on}}const ln=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.sumTitle="SUM_TOTAL",this.scenarios=[],this.scenariosDataFormat=mt.DECIMAL,this.grouped=!1,this.limit=0,this.showGroupTitle=!0,this.thereof=[],this.partof=[],this.order={hierarchy:[],direction:os.ASC},this.categorythereof=new Map,this.attributeColumns=[],this.type=as.LIST,this.categoryWidth=wt.INF,this.dataFormatDigits={percent:2,decimal:1},this.i18n=new Map,this.i18nMode=bt.ALL,this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.measureType=yt.VOLUME,this.filter="",this.barColumns=[],this.interval="none",this.barColumnMaxWidth=30,this.unitScaling=.01,this.percentageScaling=.5,this.scaleFactor=1,this.componentDataFormatDigits=new Js,this.componentStyle=w(this)}async getLayoutDetail(t,i){var s,e,n;const r={regions:[],metadata:{},diagnostics:[]},a=null===(s=this.element.shadowRoot)||void 0===s?void 0:s.querySelector("table");if(r.metadata.hasNoData=null===(n=null===(e=this.table)||void 0===e?void 0:e.hasNoData())||void 0===n||n,!this.table||!a)return r;const o=a.querySelector("thead"),h=a.querySelector("tbody");o&&r.regions.push({id:"header",rect:Lt(o,t)}),h&&r.regions.push({id:"body",rect:Lt(h,t)});const l=this.table.getHeader(),c=this.table.getBody(),d=this.table.getColumns();if(r.metadata.headerRowCount=l.length,r.metadata.rowCount=c.length,r.metadata.columnCount=d.length,r.metadata.cellCount=c.reduce(((t,i)=>t+i.getCells().length),0),"full"!==i)return r;const u=[],p=[],f=(i,s,e)=>{const n=e?Array.from(e.children).filter((t=>"tr"===t.localName)):[];s.forEach(((s,e)=>{const a=n[e];if(!a)return;u.push({section:i,index:e,type:s.type,rect:Lt(a,t)});const o=s.getCells(),h=Array.from(a.children);o.length===h.length?o.forEach(((s,n)=>{var r,a;const o=h[n],l={kind:"header"===i?"headerCell":"cell",row:e,column:s.index,key:s.key||void 0,colSpan:s.colSpan,value:null!==(r=s.value)&&void 0!==r?r:void 0,text:(null===(a=o.textContent)||void 0===a?void 0:a.trim())||void 0,type:s.type||void 0,rect:Lt(o,t)},c=o.querySelector("svg.cell-bar-chart");c&&(l.bar={variant:c.classList.contains("waterfall-bar")?"waterfall":c.classList.contains("relative-variance")?"relative":"absolute",rect:Lt(c,t)}),p.push(l)})):r.diagnostics.push({id:`LAYOUT_cellPairing_${i}_${e}`,type:"warning",message:`layout-state: model/DOM cell count mismatch in ${i} row ${e} (${o.length} vs ${h.length}); cell details skipped for this row.`})}))};return f("header",l,o),f("body",c,h),r.elements=p,r.table={rows:u,columns:d.map(((t,i)=>({index:i,key:t.name,group:t.group,type:t.type,bucket:t.bucket})))},r}render(){return i(s,null,(()=>{if(void 0!==this.table){if(this.table.hasNoData()){const t=this.i18n.get("no-data")||"==No Data==";return i("p",{class:"warning"},t)}return i("table",null,i("thead",null,this.table.getHeader().map((t=>i("tr",{class:t.cssStyle},t.getCells().map((t=>i("th",{colSpan:t.colSpan,class:t.cssStyle},t.getAsHeaderList().map(((s,e,n)=>i("span",null,e===n.length-1?i("span",{class:" "===s?"table-footer":""},s,t.drawPrefix()," "):i("span",null,s,t.drawPrefix(),i("br",null)))))))))))),i("tbody",null,this.table.getBody().map((t=>i("tr",{class:t.cssStyle},null==t?void 0:t.getCells().map((s=>i("td",{colSpan:s.colSpan,class:s.type?`${s.cssStyle} ${s.type}`:s.cssStyle},null!=s.prefix?i("span",{class:s.cssStyle+" "+s.prefixStyle},s.drawPrefix()):"",s.isBarChart&&s.columnStats&&(void 0!==s.waterfall||t.type!==hs.SUM)?void 0!==s.waterfall?i(Ze,{value:s.value,scenario:s.key,columnStats:s.columnStats,height:18*this.scaleFactor,isRelative:!1,isPositiveGood:s.key.endsWith("_pos"),measureScale:s.measureScale,columnWidthEm:this.barColumnMaxWidth,styles:this.barChartStyles,waterfall:s.waterfall}):i(qe,{value:s.value,scenario:s.key,columnStats:s.columnStats,height:18*this.scaleFactor,isRelative:s.key.startsWith("dr"),isPositiveGood:s.key.endsWith("_pos"),measureScale:s.measureScale,columnWidthEm:this.barColumnMaxWidth,styles:this.barChartStyles}):s.draw(this.componentDataFormatDigits)))))))))}})())}componentWillRender(){this.stores||(this.stores=d(this.element));const t=this.stores.db.db,i=this.prepareConfig(t);this.componentDataFormatDigits=(new qs).adapt(this.dataFormatDigits),this.table=new nn(new Ft(this.ruleSetConfig),t,this.tableName,i),this.table.setI18n(this.i18n),this.barChartStyles=this.prepareBarChartStyles()}prepareConfig(t){var i,s,e;const n=this.tableName?this.filter&&this.filter.length>0?`(SELECT * FROM \`${this.tableName}\` WHERE ${this.filter}) AS __src`:`\`${this.tableName}\``:"";return new an(new hn,new Rs,new kt(new Rs),t,n).adapt({title:this.sumTitle,scenarios:this.scenarios,scenariosUnitType:this.scenariosDataFormat,grouped:this.grouped,showGroupTitle:this.showGroupTitle,thereOf:this.thereof,partOf:this.partof,categoryThereOf:this.categorythereof,attributes:this.attributeColumns,order:this.order,type:this.type,limit:this.limit,i18n:this.i18nMode,categoryWidth:this.categoryWidth,measureScale:this.measureScale,measureUnit:this.measureUnit,measureType:this.measureType,showMeasureScale:this.showMeasureScale,filter:this.filter,barColumns:this.barColumns,interval:this.interval,locale:(null===(e=null===(s=null===(i=this.stores)||void 0===i?void 0:i.context)||void 0===s?void 0:s.state)||void 0===e?void 0:e.locale)||"de"})}prepareBarChartStyles(){var t;const i=!(this.unitScaling>0),s=!(this.percentageScaling>0),e=i?this.autoUnitScaling():this.unitScaling,n=s?this.autoPercentageScaling():this.percentageScaling;return(i||s)&&(null===(t=this.reportAutoScaling)||void 0===t||t.call(this,{unit:i?e:void 0,percentage:s?n:void 0})),this.componentStyle((t=>{var i,s,r,a,o,h,l,c,d,u,p,f,v,g,m,b,w,y,S,$,O,R,M,x,_,E,k;const P=null===(i=t["bn-chart-time"])||void 0===i?void 0:i.varianceStyles,T=null===(s=t["bn-chart-time"])||void 0===s?void 0:s.barStyles;return{positive:{stroke:(null===(r=null==P?void 0:P.pos)||void 0===r?void 0:r.stroke)||"#008f96",fill:(null===(a=null==P?void 0:P.pos)||void 0===a?void 0:a.fill)||"#008f96",fillpattern:(null===(o=null==P?void 0:P.pos)||void 0===o?void 0:o.fillpattern)||"solid"},negative:{stroke:(null===(h=null==P?void 0:P.neg)||void 0===h?void 0:h.stroke)||"#ff0000",fill:(null===(l=null==P?void 0:P.neg)||void 0===l?void 0:l.fill)||"#ff0000",fillpattern:(null===(c=null==P?void 0:P.neg)||void 0===c?void 0:c.fillpattern)||"solid"},neutral:{stroke:(null===(d=null==P?void 0:P.neu)||void 0===d?void 0:d.stroke)||"#808080",fill:(null===(u=null==P?void 0:P.neu)||void 0===u?void 0:u.fill)||"#808080",fillpattern:(null===(p=null==P?void 0:P.neu)||void 0===p?void 0:p.fillpattern)||"outlined"},scenarios:{ac:{stroke:(null===(f=null==T?void 0:T.ac)||void 0===f?void 0:f.stroke)||"#404040",fill:(null===(v=null==T?void 0:T.ac)||void 0===v?void 0:v.fill)||"#404040",fillpattern:(null===(g=null==T?void 0:T.ac)||void 0===g?void 0:g.fillpattern)||"solid"},pp:{stroke:(null===(m=null==T?void 0:T.pp)||void 0===m?void 0:m.stroke)||"#A6A6A6",fill:(null===(b=null==T?void 0:T.pp)||void 0===b?void 0:b.fill)||"#A6A6A6",fillpattern:(null===(w=null==T?void 0:T.pp)||void 0===w?void 0:w.fillpattern)||"solid"},fc:{stroke:(null===(y=null==T?void 0:T.fc)||void 0===y?void 0:y.stroke)||"#404040",fill:(null===(S=null==T?void 0:T.fc)||void 0===S?void 0:S.fill)||"#ffffff",fillpattern:(null===($=null==T?void 0:T.fc)||void 0===$?void 0:$.fillpattern)||"hatched"},pl:{stroke:(null===(O=null==T?void 0:T.pl)||void 0===O?void 0:O.stroke)||"#404040",fill:(null===(R=null==T?void 0:T.pl)||void 0===R?void 0:R.fill)||"#ffffff",fillpattern:(null===(M=null==T?void 0:T.pl)||void 0===M?void 0:M.fillpattern)||"outlined"}},fontColor:(null===(x=t.global)||void 0===x?void 0:x.fontColor)||"#000000",fontSize:((null===(_=t.global)||void 0===_?void 0:_.fontSizePx)||13.3333)*Ae*this.scaleFactor,emPx:((null===(E=t.global)||void 0===E?void 0:E.fontSizePx)||13.3333)*this.scaleFactor,fontFamily:(null===(k=t.global)||void 0===k?void 0:k.fontFamily)||"'Noto Sans', sans-serif",unitScaling:e,percentageScaling:n,scaleFactor:this.scaleFactor}}))}emPx(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*this.scaleFactor}autoUnitScaling(){const t=this.emPx(),i=t*Ae,{absMax:s,hasNeg:e,hasPos:n}=this.getAbsBarColumnStats();if(s<=0||i<=0)return.01;const{maxBarWidth:r,cutWidth:a}=Ue(this.barColumnMaxWidth,t,e,n);return Math.min(.8*r,a)/(s*i)}autoPercentageScaling(){const t=this.emPx(),i=t*Ae,{absMax:s,hasNeg:e,hasPos:n}=this.getRelativeBarColumnStats();if(s<=0||i<=0)return.5;const{maxPinLength:r}=De(this.barColumnMaxWidth,t,e,n);return.8*r/(s*i)}getAbsBarColumnStats(){return this.collectBarColumnStats((t=>!t.key.startsWith("dr")&&!t.waterfall),1)}getRelativeBarColumnStats(){return this.collectBarColumnStats((t=>t.key.startsWith("dr")),100)}collectBarColumnStats(t,i){const s={absMax:0,hasNeg:!1,hasPos:!1};if(!this.table)return s;for(const e of this.table.getBody())if(e.type!==hs.SUM)for(const n of e.getCells())n.isBarChart&&n.columnStats&&t(n)&&(s.absMax=Math.max(s.absMax,n.columnStats.absMax*i),s.hasNeg=s.hasNeg||n.columnStats.min<0,s.hasPos=s.hasPos||n.columnStats.max>0);return s}get element(){return e(this)}};ln.style=':host{position:relative;display:inline-block}table{background-color:var(--bn-font-background, white);font-size:var(--bn-font-size, 1em);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);border-spacing:0.3em 0}thead{border-style:none}tr:first-child td{border-top:none;padding-top:0.5em}td.ac1,td.ac2,td.ac3,td.ac4,td.pp1,td.pp2,td.pp3,td.pp4,td.pl1,td.pl2,td.pl3,td.pl4,td.fc1,td.fc2,td.fc3,td.fc4,td.share,td.variance,td.pos_pos,td.pos_neg,td.neg_pos,td.neg_neg,td.pos_neutral,td.neg_neutral{text-align:right}.category-w100{min-width:100em;max-width:100em}.category-w50{min-width:50em;max-width:50em}.category-w25{min-width:25em;max-width:25em}.category-w20{min-width:20em;max-width:20em}.category-w15{min-width:15em;max-width:15em}.category-w10{min-width:10em;max-width:10em}.category-w5{min-width:5em;max-width:5em}.prefix-second{color:transparent;font-style:normal}.prefix-first{font-style:normal}th{border-bottom:0.1em solid black;text-align:right;font-weight:normal;vertical-align:text-top}td.columnGroup,th.columnGroup{font-size:0.6em}td.columnSubGroup,th.columnSubGroup{font-size:0.6em;border-spacing:0em 0;font-style:italic}td.base,th.base{font-style:normal}th.ofit,td.ofit,tr.ofit,th.partof,td.partof,tr.partof{font-size:0.6em;font-style:italic}td.ofit,td.partof{font-size:0.6em;font-style:italic}th.ofit td,tr.ofit td,th.partof td,tr.partof td{border-top:0em solid black;padding-left:1em}th.ofit share,th.partof share,tr.share td{border-top:0em solid black}th.share,tr.share,td.share{font-size:0.6em;font-style:italic}th.filler{border-bottom:0em solid black;text-align:right}td.filler{border-top:0em none !important;border-bottom:0em none;text-align:right}th.group{text-align:center;border-spacing:1em 0}th.headerlabel{border-bottom:0em none black;padding-bottom:0em}th.intervalGroup{border-bottom:0.1em solid black;text-align:center;font-weight:bold}td.variance:after{content:"%"}td.relative_variance{font-style:italic}td.percent{font-style:italic;text-align:right}td.decimal{text-align:right}td.pos_pos{color:#008f96}td.neg_pos{color:#ff0000}td.pos_neg{color:#ff0000}td.neg_neg{color:#008f96}td.pos_pos:before{content:"+"}td.pos_neg:before{content:"+"}td.pos_neu:before{content:"+"}th.ac1,th.ac2,th.ac3,th.ac4{padding-top:0em;border-bottom:0.3em solid black}th.pp1,th.pp2,th.pp3,th.pp4{padding-top:0em;border-bottom:0.3em solid grey}th.pl1,th.pl2,th.pl3,th.pl4{padding-top:0em;border-bottom:0.3em double black}th.fc1,th.fc2,th.fc3,th.fc4{border-bottom:0.3em solid;border-image:repeating-linear-gradient(-45deg, white, white, black, white, white 0.3em) 2}td.colsum{font-weight:bold}th.colsum{padding-top:0em;font-weight:bold}tr.sum td{border-top:0.1em solid black;font-weight:bold;padding-bottom:0.5em}tr.groupheader td{border-top:0em dotted #ddd;padding-top:0.5em;font-weight:bold;font-style:italic}tr.begingroup td{border-top:0em dotted #ddd;padding-top:0.5em}th.begin-group{padding-left:0.75em}th.end-group{padding-left:0.75em}td{box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em dashed #ddd;padding-left:0.5em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.table-footer{font-size:0.6em}.cell-bar-chart{display:inline-block;vertical-align:middle}.bar-chart-empty{color:#999}td:has(.cell-bar-chart){padding:0 0.25em;vertical-align:middle}td:has(.cell-bar-chart).pos_pos:before,td:has(.cell-bar-chart).pos_neg:before,td:has(.cell-bar-chart).pos_neu:before{content:none}td:has(.cell-bar-chart).variance:after{content:none}';class cn{constructor(){}createMeasures(t,i,s){if(this.allMeasuresUseSameUnit(t)){const e=t.length;let n="",r="";for(let a=0;a<e;a++){let o="";a>0&&(o=i.get("SEPERATOR_WS")),e>1&&a===e-1&&(o=i.get("CONNECTOR_WS")),s===bt.ALL?(n=(i.get(n)||n)+o+(i.get(t[a].name)||t[a].name),r=i.get(t[a].unit)||t[a].unit):(n=n+o+t[a].name,r=t[a].unit)}return[{name:n,unit:r}]}return t}createDimension(t,i,s,e,n,r="de"){let a="";if(void 0!==i){const t=new U;t.setLocale(r),a=t.getDateLinkString(i.start,i.end,i.link,i.format,n)}const o=t.map((t=>{let i="";return null!=s&&null!=s.hierarchy&&s.hierarchy.find((i=>i===t))&&(i=e.get("asc"===s.direction?"ORDER_asc":"ORDER_desc")),"".concat(" ",Gt.translateScenarioLabel(t,e),i)})).toString();return a+o}allMeasuresUseSameUnit(t){const i=new Map;return t.forEach((function(t){i.set(t.unit,!0)})),1===i.size}}class dn{constructor(){this.businessunit="",this.measures=[],this.scenarios=[],this.i18nMode=bt.ALL,this.intervalSpanLimit=32,this.locale="de"}}class un{constructor(t,i,s,e){this.measureEntryAdapter=t,this.timePeriodAdapter=i,this.orderAdapter=s,this.stringAdapter=e}adapt(t){const i=new dn;return Ot.isString(t.businessunit)&&(i.businessunit=t.businessunit),Ot.isArray(t.measures)&&(i.measures=Et.adaptArray(t.measures,this.measureEntryAdapter)),Ot.isArray(t.scenarios)&&(i.scenarios=Et.adaptArray(t.scenarios,this.stringAdapter)),Ot.isExisting(t.timeperiod)&&(i.timeperiod=this.timePeriodAdapter.adapt(t.timeperiod)),Ot.isNumber(t.intervalSpanLimit)&&(i.intervalSpanLimit=t.intervalSpanLimit),Ot.isExisting(t.i18nMode)&&(i.i18nMode=t.i18nMode),Ot.isExisting(t.order)&&(i.order=this.orderAdapter.adapt(t.order)),Ot.isString(t.locale)&&(i.locale=t.locale),i}default(){return new dn}}var pn;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(pn||(pn={}));class fn{constructor(t){this.i18n=new Map,this.unit="",this.measures=[],this.dimension="",this.config=new dn,this.state=pn.DIRTY,this.ruleSet=t||new Ft,this.dataSetFactory=new cn,this.state=pn.DIRTY,this.setI18n(new Map)}setRuleSet(t){this.ruleSet=t||new Ft}setI18n(t){this.state=pn.DIRTY;const i=new Map([["SEPERATOR_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"," "],["there_of","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"],["CONNECTOR_WS"," und "]]);this.i18n=new Map([...i,...t||new Map])}update(){return pn.DIRTY===this.state&&(this.unit=this.config.businessunit,this.measures=this.dataSetFactory.createMeasures(this.config.measures,this.i18n,this.config.i18nMode),this.dimension=this.dataSetFactory.createDimension(this.config.scenarios,this.config.timeperiod,this.config.order,this.i18n,this.config.intervalSpanLimit,this.config.locale),this.state=pn.UP_TO_DATE),this}setConfig(t){this.config=this.initConfig(t)}initConfig(t){this.state=pn.DIRTY;const i=t,s=this;return t.scenarios.sort(((t,i)=>s.ruleSet.getScenarioSorIndex(t)-s.ruleSet.getScenarioSorIndex(i))),i}}class vn{constructor(t="",i=""){this.name=t,this.unit=i}}class gn{construnctor(){}adapt(t){const i=new vn;return Ot.isString(t.name)&&(i.name=t.name),Ot.isString(t.unit)&&(i.unit=t.unit),i}default(){return new vn("","")}}class mn{constructor(t=g.now(),i=g.now(),s=C.AUTO,e=Z.AUTO){this.start=t,this.end=i,this.format=s,this.link=e}}class bn{construnctor(){}adapt(t){const i=new mn;return Ot.isDate(t.start)&&(i.start=t.start),Ot.isDate(t.end)&&(i.end=t.end),Ot.isExisting(t.format)&&(i.format=t.format),Ot.isExisting(t.link)&&(i.link=t.link),i}default(){return new mn}}const wn=class{constructor(i){t(this,i),this.businessUnit="",this.scenarios=[],this.measures=[],this.intervalSpanLimit=28,this.order={hierarchy:[],direction:xt.ASC},this.i18n=new Map,this.i18nMode=bt.ALL,this.locale="de",this.title=new fn(new Ft)}async setBusinessUnit(t){this.businessUnit=t}async setProps(t){Object.keys(t).forEach((i=>{this[i]=t[i]}))}render(){return i("div",{key:"4a675a92695130e13bd690587098cf70d81028c9"},i("div",{key:"54c98ac466109f4ea1306aa57379f5cb25cf654f",innerHTML:Xt(this.title.unit)}),i("div",{key:"35e8592454c45c06db9e3b6db5525165a3ee4a00"},this.title.measures.map(((t,s)=>i("span",null,this.isFirstElement(s)?this.title.i18n.get("SEPERATOR_WS"):"",i("span",{class:"measure"},t.name)," ",t.unit?this.title.i18n.get("in"):""," ",t.unit)))),i("div",{key:"29c93306567a592ac956d5c97501dc5e7acf90ec"},this.title.dimension))}componentWillLoad(){const t=this.prepareConfig();this.title=new fn(new Ft(this.ruleSetConfig)),this.title.setI18n(this.i18n),this.title.setConfig(t)}componentWillUpdate(){const t=this.prepareConfig();this.title.setI18n(this.i18n),this.title.setRuleSet(new Ft(this.ruleSetConfig)),this.title.setConfig(t)}componentWillRender(){this.title.update()}isFirstElement(t){return 0!==t}prepareConfig(){return new un(new gn,new bn,new kt(new Rs),new Rs).adapt({businessunit:this.businessUnit,measures:this.measures,scenarios:this.scenarios,timeperiod:this.timeperiod,intervalSpanLimit:this.intervalSpanLimit,i18nMode:this.i18nMode,order:this.order,locale:this.locale})}};wn.style=':host{display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.measure{font-weight:bold}div{background-color:var(--bn-font-background, white);color:var(--bn-font-color, black)}p{margin:0}';export{ri as bn_asset,ai as bn_body,oi as bn_card,ci as bn_chart_structure,ui as bn_chart_time,pi as bn_component_style,fi as bn_context,Xi as bn_dataset,Ji as bn_datasource,qi as bn_footer,Zi as bn_layout_card,Ki as bn_layout_page,Qi as bn_message,ss as bn_page,es as bn_scaling_group,fs as bn_table,vs as bn_title,Zs as ibcs_chart_structure,Pe as ibcs_chart_time,ln as ibcs_table,wn as ibcs_title}
|
|
1
|
+
import{r as t,h as i,H as s,g as e,d as n,f as r,e as a,F as o}from"./p-C5UYpZUU.js";import{w as h,a as l,r as c}from"./p-DtLI_CzV.js";import{g as d,h as u,a as p,i as f,c as v,D as g,d as m}from"./p-D5e8I9Qe.js";import{w as b}from"./p-CTrNbSXN.js";import{b as w,g as y,h as S,j as $,v as O,d as R,a as M,e as x,k as _,l as E,w as k,i as P,f as T,m as L,n as A,D as C,o as N,p as U,q as D,r as G,s as W,t as F,u as I,x as Y,y as z,z as B,A as H,B as V,C as j,E as X,F as J,G as q,H as Z}from"./p-CsJ84YRk.js";import{i as K,r as Q,b as tt,w as it,a as st,c as et,g as nt,p as rt,d as at}from"./p-EtT29btN.js";import{w as ot}from"./p-BcaI745G.js";import{w as ht,o as lt,a as ct}from"./p-DjPXefnq.js";import{A as dt,f as ut,g as pt,h as ft,c as vt,i as gt,D as mt,I as bt,e as wt,M as yt,B as St,T as $t,C as Ot,R as Rt,S as Mt}from"./p-BbmobTg0.js";import{O as xt,b as _t,A as Et,c as kt}from"./p-B5Jd_eCX.js";import{LAYOUT_STATE_VERSION as Pt}from"./index.esm.js";import{r as Tt,m as Lt,a as At,o as Ct,b as Nt,c as Ut,t as Dt}from"./p-BcLsoDrW.js";import{F as Gt,S as Wt,I as Ft,C as It,V as Yt,a as zt,b as Bt,c as Ht,P as Vt,Q as jt}from"./p-TuLpbB5O.js";import{s as Xt}from"./p-BA48JiHe.js";import{S as Jt,g as qt,a as Zt,I as Kt,b as Qt,H as ti,c as ii,L as si,d as ei}from"./p-DVrDYxlh.js";import{S as ni}from"./p-CWWWM-XC.js";const ri=class{constructor(i){t(this,i),h(this),this.errors=l(this),b(this,(t=>{this.stores||(this.stores=d(this.element));try{const i=t.replace(/\s/g,"");this.stores.assets.set(this.name,i)}catch(i){console.error("Error parsing asset",i,t),this.stores.assets.set(this.name,void 0)}}))}render(){return i(s,{key:"dfec9f90136278bddab194479301aa3fa5bc1e72"})}get element(){return e(this)}};ri.style=":host{display:none}";const ai=class{constructor(i){t(this,i),h(this),this.errors=l(this),this.componentStyle=w(this)}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){return i(s,{key:"f43978af1c6658c6fa165093c3ada6b5f3b5986d",style:this.getFontStyles()},i("slot",{key:"b9c97432089676fc373b1d5ee59573ef5681a5c5"}))}get element(){return e(this)}};ai.style=':host{flex:1;min-height:0;position:relative;overflow:hidden;display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}';const oi=class{constructor(i){t(this,i),h(this),this.errors=l(this),this.componentStyle=w(this)}render(){return i(s,{key:"92bcbc010336d3a542c86e182831bbfddda2aa9b",style:this.prepareStyle()},i("slot",{key:"d836aa5443283df158dcb50345aee0df97f74a6e"}))}prepareStyle(){return{"font-family":this.componentStyle((t=>t.global.fontFamily)),"font-size":`${this.componentStyle((t=>t.global.fontSizePx))}px`,"--bn-font-family":this.componentStyle((t=>t.global.fontFamily))||"'Noto Sans', sans-serif","--bn-font-size":`${this.componentStyle((t=>t.global.fontSizePx))||13.3333}px`,"--bn-font-color":this.componentStyle((t=>t.global.fontColor))||"#000000","--bn-font-background":this.componentStyle((t=>t.global.fontBackgroundColor))||"#ffffff"}}get element(){return e(this)}};function hi(t){if("function"==typeof getComputedStyle){const i=parseFloat(getComputedStyle(t).fontSize);if(Number.isFinite(i)&&i>0)return i}return u.global.fontSizePx}function li(t,i){var s;return{version:Pt,tag:t.localName,id:At(t),slot:null!==(s=t.getAttribute("slot"))&&void 0!==s?s:void 0,rect:Lt(t,i),em:{fontSizePx:hi(t),appliedScaleFactor:1},regions:[],metadata:{},diagnostics:Tt(t)}}oi.style=':host{display:flex;flex-direction:column;justify-content:space-between;flex:1;min-height:0;padding:0.25em;margin:0.5em;background-origin:content-box;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}:host(.border){box-sizing:border-box;-webkit-box-sizing:border-box;border:0.1em solid #ddd}div{color:var(--bn-font-color, black)}';const ci=class{validateScenario(t){const i="ERR_scenarios";if(K(t))return void this.errors.remove(i);const s=y(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances";if(K(t))return void this.errors.remove(i);const s=S(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateUnitScaling(t){const i="ERR_unitScaling";"invalid"===Q(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="ERR_percentageScaling";"invalid"===Q(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validateLevel(t){const i="ERR_level";$(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"level: invalid value(s) '"+t+"' are not supported."})}validateOrderList(t){const i="ERR_order";if(K(t))return void this.errors.remove(i);const s=O(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="ERR_orderDirection";K(t)||R(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateLimit(t){const i="ERR_limit";M(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateShowCategories(t){const i="ERR_showCategories";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showCategories: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateMeasureScale(t){const i="ERR_measureScale";_(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateShowMeasureScale(t){const i="ERR_grouped";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateStack(t){const i="ERR_stack",s=E(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:s.join("; ")}):this.errors.remove(i)}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("ERR_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"ERR_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("ERR_scale")}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this._lastScaledParentHeight=0,this.chartTitle="",this.filter="",this.limit=0,this.showCategories="true",this.measureScale="greatest",this.showMeasureScale="false",this.measureUnit="",this.stack="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=t=>{var i,s,e,n,r,a;this.lastAutoScalingReport={unit:null!==(i=t.unit)&&void 0!==i?i:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(e=t.percentage)&&void 0!==e?e:null===(n=this.lastAutoScalingReport)||void 0===n?void 0:n.percentage};const o=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),h=this.getEffectiveFontPx();if(void 0!==t.unit&&t.unit>0&&this.autoUnitWarningActive){const i=h/t.unit;o(i,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=i,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${ci.describeScalingInput(String(null!==(r=this.unitScaling)&&void 0!==r?r:"").trim())}, auto-fitted to 1 em ≈ ${tt(i)} units.`}))}if(void 0!==t.percentage&&t.percentage>0&&this.autoPctWarningActive){const i=100*h/t.percentage;o(i,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=i,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${ci.describeScalingInput(String(null!==(a=this.percentageScaling)&&void 0!==a?a:"").trim())}, auto-fitted to 1 em ≈ ${tt(i)} percentage points.`}))}},k(this),h(this),it(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=l(this),ot(this),this.componentStyle=w(this),this.ruleSetConfig=ht(this),this.t=st(this).t,this.resolveInherited=et(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}])}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateShowCategories(this.showCategories),this.validateMeasureScale(this.measureScale),this.validateShowMeasureScale(this.showMeasureScale),this.validateStack(this.stack),this.validateScaling(this.scale)}componentDidRender(){const{mode:t}=rt(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{height:s}=nt(i);if(s<=0)return void this.checkOverflow();this._lastScaledParentHeight=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollHeight,a=this.appliedScaleFactor;if(r<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,a*(s-1)/r);Math.abs(o-a)<.01||(i.style.setProperty("--bn-font-size",e*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${o.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,n((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=lt(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=nt(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,r(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=nt(this.element);this._lastScaledParentHeight=t,r(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}measureContentWidth(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("ibcs-chart-structure");let s=0,e=!1;return null==i||i.forEach((t=>{var i,n,r;const a=parseFloat(null!==(r=null===(n=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===n?void 0:n.getAttribute("width"))&&void 0!==r?r:"");Number.isNaN(a)||(s+=a,e=!0)})),e?Math.max(Math.floor(s),this.element.scrollWidth):this.element.scrollWidth}checkOverflow(){const t="WARN_overflow",i=nt(this.element),s=this.measureContentWidth(),e=this.element.scrollHeight,n=i.width>0&&s>i.width+1,r=i.height>0&&e>i.height+1;if(!n&&!r)return void this.errors.remove(t);const a=this.prepareVariances().some((t=>t.startsWith("dr"))),o="value"===Q(this.unitScaling,this.pixelPerUnitGroupMap).kind,h=a&&"value"===Q(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:l}=rt(this.scale),c="auto"!==l&&"empty"!==l,d=[];n&&o&&d.push("unit-scaling"),n&&h&&d.push("percentage-scaling"),r&&c&&d.push("scale");const u=[];n&&u.push(`width (${Math.round(s)}px > ${Math.round(i.width)}px)`),r&&u.push(`height (${Math.round(e)}px > ${Math.round(i.height)}px)`),this.errors.addOrReplace({id:t,type:d.length>0?"error":"warning",message:`Chart exceeds available ${u.join(" and ")}. `+(d.length>0?`Adjust ${d.join(" / ")} or set to "auto".`:"Content does not fit even at minimum auto scaling; enlarge the container.")})}prepareDimension(){const t=nt(this.element),i=this.prepareVariances();return this.canvasWidthSegmented=t.width/(1+i.length),{width:this.canvasWidthSegmented,height:t.height}}prepareScenarios(){var t,i,s,e;const n=this.resolveInherited("scenarios",this.scenarios);if(void 0!==n)return this.errors.remove("AUTO_scenarios"),n.split(",").map((t=>t.trim()));const r="auto"===(null===(t=this.scenarios)||void 0===t?void 0:t.trim().toLowerCase());return P(this.scenarios)||r?(null===(s=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===s?void 0:s.length)>0?(r?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(e=this.scenarios)||void 0===e?void 0:e.split(",").map((t=>t.trim())))}prepareVariances(){var t;const i=this.resolveInherited("variances",this.variances);return void 0!==i?i.split(",").map((t=>t.trim())):P(this.variances)?[]:null===(t=this.variances)||void 0===t?void 0:t.split(",").map((t=>t.trim()))}prepareHideCategories(t){return t>=1||"true"!==this.showCategories}prepareI18n(){const t=p,i=new Map(["no-data","REST"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries()])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const t=Q(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/t.value):"auto"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${ci.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const t=Q(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/t.value):"auto"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${ci.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}prepareLevel(){var t,i,s;const e="auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase());return P(this.level)||e?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?(e?this.errors.remove("AUTO_level"):this.errors.addOrReplace({id:"AUTO_level",type:"warning",message:`level: not set, auto-detected: ${this.datasetMeta.suggestedLevel}`}),dt[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),dt[null===(s=this.level)||void 0===s?void 0:s.toUpperCase()])}prepareOrder(){var t;const i=this.resolveInherited("order",this.order),s=this.resolveInherited("orderDirection",this.orderDirection),e=null!=i?i:this.order,n=null!=s?s:this.orderDirection,r="auto"===(null==e?void 0:e.trim().toLowerCase());let a;return P(e)||r?(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)?(r?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:`order: not set, auto-detected: ${this.datasetMeta.suggestedOrder}`}),a=this.datasetMeta.suggestedOrder):a=e:(this.errors.remove("AUTO_order"),a=e),{hierarchy:null==a?void 0:a.split(",").map((t=>_t[null==t?void 0:t.toUpperCase()])),direction:xt[null==n?void 0:n.toUpperCase()]}}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const s=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-structure"].scaleFactors.scenarioOffset,scenarioLabelToBar:i["bn-chart-structure"].scaleFactors.scenarioLabelToBar,labelToBar:i["bn-chart-structure"].scaleFactors.labelToBar,labelToAxis:i["bn-chart-structure"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-structure"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-structure"].scaleFactors.needleHeadWidth,barWidth:i["bn-chart-structure"].scaleFactors.barWidth,varianceAxisLineWidth:i["bn-chart-structure"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-structure"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-structure"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-structure"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-structure"].scaleFactors.markerWidth,markerOffset:i["bn-chart-structure"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-structure"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-structure"].scaleFactors.axisTickLength},fontStyles:{font:`${s}px ${i.global.fontFamily}`,family:i.global.fontFamily,size:s,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-structure"].axisStyles,barStyles:i["bn-chart-structure"].barStyles,varianceStyles:i["bn-chart-structure"].varianceStyles,padding:i["bn-chart-structure"].padding,pattern:null}}))}prepareChartTitle(t){return t>=1?"":this.chartTitle}prepareStackConfig(){if(P(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const t=JSON.parse(this.stack),i=t.by,s="WARN_stack_dimensions_scenarios";if(i===ut.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:s,type:"warning",message:`stack by dimensions: only the first scenario "${t[0]}" is used, the rest (${t.slice(1).join(", ")}) are discarded.`}):this.errors.remove(s)}else this.errors.remove(s);return{by:i,mode:t.mode||ft.ABSOLUTE,order:t.order||pt.DATASET}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareLimit(){return Math.floor(Number(this.limit)||0)}getDataStructure(){return{IStructureChartDataRow:{operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return P(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&"true"===this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}chartTemplate(t,s){const e=this.preparePixelPerUnit(),n=this.preparePixelPerPercentage(),r=this.prepareStackConfig(),a=this.prepareScenarios(),o=(null==r?void 0:r.by)===ut.DIMENSIONS?a.slice(0,1):a;return i("ibcs-chart-structure",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(s),scenarios:o,variances:[t],hideCategories:this.prepareHideCategories(s),pixelPerUnit:e,pixelPerPercentage:n,reportAutoScaling:this.handleAutoScalingReport,limit:this.prepareLimit(),styles:this.prepareStyle(),i18n:this.prepareI18n(),order:this.prepareOrder(),level:this.prepareLevel(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(s),stackConfig:r,parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}async getLayoutState(t){var i,s,e,n;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",a=Ct(this.element),o=this.getEffectiveScaleFactor(),h=Number.isFinite(o)&&o>0?o:1,l=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*h,c=this.prepareVariances(),d=ct(this.element,"ibcs-chart-structure",["base",...c],a,r),u=null===(s=this.element.shadowRoot)||void 0===s?void 0:s.querySelector("ibcs-chart-structure"),p={version:Pt,tag:this.element.localName,id:At(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:Lt(this.element,a),em:{fontSizePx:l,appliedScaleFactor:h},regions:d.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(n=null==u?void 0:u.scenarios)&&void 0!==n?n:[],variances:c,barCount:d.barCount,hasNoData:0===d.barCount},diagnostics:Tt(this.element),scaling:this.resolveScalingInfo(l)};return d.elements&&(p.elements=d.elements),p}resolveScalingInfo(t){var i,s;const e={},n=Q(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===n.kind)e.unitMode="fixed",e.unitsPerEm=n.value,e.unitPxPerUnit=t/n.value;else{e.unitMode="auto";const s=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==s&&s>0&&(e.unitPxPerUnit=s,e.unitsPerEm=t/s)}const r=Q(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)e.percentageMode="fixed",e.percentagePointsPerEm=r.value,e.percentagePxPerPoint=t/r.value;else{e.percentageMode="auto";const i=null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.percentage;void 0!==i&&i>0&&(e.percentagePxPerPoint=i/100,e.percentagePointsPerEm=100*t/i)}return e}getEffectiveScaleFactor(){const{mode:t,factor:i}=rt(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){const t=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}));return t*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const a=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":a*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){let t=[""];const e=this.prepareVariances();e.length>0&&(t=[...t,...e]);const n=this.getFontStyles();return i(s,{key:"4039c2676dbb48bc14e30092d5f5e7a8c080bd2a",style:n},i("div",{key:"c57dbcf301b86f4b22da3142c242008f8f049268",class:"container"},t.map(this.chartTemplate)))}get element(){return e(this)}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}}};var di;ci.style=':host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}',function(t){t.ROWGROUP="rowGroup",t.ROWGROUPINDEX="rowGroupIndex",t.CATEGORY="category",t.CATEGORYINDEX="categoryIndex",t.SUBCATEGORY="subCategory",t.SUBCATEGORYINDEX="subCategoryIndex"}(di||(di={}));const ui=class{validateScenario(t){const i="ERR_scenarios";if(K(t))return void this.errors.remove(i);const s=y(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances";if(K(t))return void this.errors.remove(i);const s=S(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateLeftSync(t){const i="ERR_syncSpaceLeft";T(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"syncSpaceLeft: invalid value(s) '"+t+"' are not supported."})}validateLimit(t){const i="ERR_limit";M(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateUnitScaling(t){const i="ERR_unitScaling";"invalid"===Q(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="ERR_percentageScaling";"invalid"===Q(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validateLevel(t){const i="ERR_level";$(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"level: invalid value(s) '"+t+"' are not supported."})}validateOrderList(t){const i="ERR_order";if(K(t))return void this.errors.remove(i);const s=O(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="ERR_orderDirection";K(t)||R(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateInterval(t){const i="ERR_dateInterval";L(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateInterval: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateChartMode(t){const i="ERR_chartMode";["bar","line","auto"].includes(null==t?void 0:t.toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"chartMode: invalid value '"+(null==t?void 0:t.toString())+"' is not supported. Valid values are: bar, line, auto."})}validateMaxBars(t){const i="ERR_maxBars";!M(t)||t<1?this.errors.addOrReplace({id:i,type:"warning",message:"maxBars: invalid value '"+(null==t?void 0:t.toString())+"' is not supported. Must be a positive integer."}):this.errors.remove(i)}validateStack(t){const i="ERR_stack",s=E(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:s.join("; ")}):this.errors.remove(i)}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("ERR_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"ERR_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("ERR_scale")}validateAxisLabelsMode(t){const i="ERR_axisLabelsMode";A(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"axisLabelsMode: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateLineFullWidth(t){const i="ERR_lineFullWidth";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"lineFullWidth: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowCategories(t){const i="ERR_showCategories";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showCategories: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateMeasureScale(t){const i="ERR_measureScale";_(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateShowMeasureScale(t){const i="ERR_grouped";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowOverlayAvg(t){const i="ERR_grouped";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showOverlayAvg: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowOverlayMedian(t){const i="ERR_grouped";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showOverlayMedian: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.chartTitle="",this.filter="",this.syncSpaceLeft=-1,this.limit=0,this.chartMode="bar",this.maxBars=28,this.stack="",this.intervalSpanLimit=28,this.lineFullWidth="true",this.showCategories="true",this.measureScale="greatest",this.showMeasureScale="false",this.showOverlayAvg="true",this.showOverlayMedian="false",this.measureUnit="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this._lastObservedWidth=0,this._settleTimer=null,this._lastAppliedHeight=0,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=t=>{var i,s,e,n,r,a;this.lastAutoScalingReport={unit:null!==(i=t.unit)&&void 0!==i?i:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(e=t.percentage)&&void 0!==e?e:null===(n=this.lastAutoScalingReport)||void 0===n?void 0:n.percentage};const o=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),h=this.getEffectiveFontPx();if(void 0!==t.unit&&t.unit>0&&this.autoUnitWarningActive){const i=h/t.unit;o(i,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=i,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${ui.describeScalingInput(String(null!==(r=this.unitScaling)&&void 0!==r?r:"").trim())}, auto-fitted to 1 em ≈ ${tt(i)} units.`}))}if(void 0!==t.percentage&&t.percentage>0&&this.autoPctWarningActive){const i=100*h/t.percentage;o(i,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=i,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${ui.describeScalingInput(String(null!==(a=this.percentageScaling)&&void 0!==a?a:"").trim())}, auto-fitted to 1 em ≈ ${tt(i)} percentage points.`}))}},k(this),h(this),it(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=l(this),ot(this),this.componentStyle=w(this),this.ruleSetConfig=ht(this),this.t=st(this).t,this.resolveInherited=et(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}])}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLimit(this.limit),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateLeftSync(this.syncSpaceLeft),this.validateDateInterval(this.dateInterval),this.validateAxisLabelsMode(this.axisLabelsMode),this.validateLineFullWidth(this.lineFullWidth),this.validateShowCategories(this.showCategories),this.validateMeasureScale(this.measureScale),this.validateShowMeasureScale(this.showMeasureScale),this.validateShowOverlayAvg(this.showOverlayAvg),this.validateShowOverlayMedian(this.showOverlayMedian),this.validateChartMode(this.chartMode),this.validateMaxBars(this.maxBars),this.validateStack(this.stack),this.validateScaling(this.scale)}measureContentWidth(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("ibcs-chart-time");let s=0,e=!1;return null==i||i.forEach((t=>{var i,n,r;const a=parseFloat(null!==(r=null===(n=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===n?void 0:n.getAttribute("width"))&&void 0!==r?r:"");Number.isNaN(a)||(s=Math.max(s,a),e=!0)})),e?Math.max(Math.floor(s),this.element.scrollWidth):this.element.scrollWidth}measureContentHeight(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("ibcs-chart-time");let s=0,e=!1;return null==i||i.forEach((t=>{var i,n,r;const a=parseFloat(null!==(r=null===(n=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===n?void 0:n.getAttribute("height"))&&void 0!==r?r:"");Number.isNaN(a)||(s+=a,e=!0)})),e?Math.max(Math.floor(s),this.element.scrollHeight):this.element.scrollHeight}checkOverflow(){const t="WARN_overflow",i=nt(this.element),s=this.measureContentWidth(),e=this.measureContentHeight(),n=i.width>0&&s>i.width+1,r=i.height>0&&e>i.height+1;if(!n&&!r)return void this.errors.remove(t);const a=this.prepareVariances().some((t=>t.startsWith("dr"))),o="value"===Q(this.unitScaling,this.pixelPerUnitGroupMap).kind,h=a&&"value"===Q(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:l}=rt(this.scale),c="auto"!==l&&"empty"!==l,d=[];r&&o&&d.push("unit-scaling"),r&&h&&d.push("percentage-scaling"),n&&c&&d.push("scale");const u=[];n&&u.push(`width (${Math.round(s)}px > ${Math.round(i.width)}px)`),r&&u.push(`height (${Math.round(e)}px > ${Math.round(i.height)}px)`),this.errors.addOrReplace({id:t,type:d.length>0?"error":"warning",message:`Chart exceeds available ${u.join(" and ")}. `+(d.length>0?`Adjust ${d.join(" / ")} or set to "auto".`:"Content does not fit even at minimum auto scaling; enlarge the container.")})}componentDidRender(){const{mode:t}=rt(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{width:s}=nt(i);if(s<=0)return void this.checkOverflow();this._lastObservedWidth=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollWidth,a=this.appliedScaleFactor;if(r<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,a*(s-1)/r);Math.abs(o-a)<.01||(i.style.setProperty("--bn-font-size",e*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${o.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,n((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=lt(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=nt(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2&&(this._lastObservedWidth=t,r(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=nt(this.element);this._lastObservedWidth=t,r(this)}))})),this.settleParentHeight()}settleParentHeight(){const t=[150,400,1e3,2500],i=()=>{if(this._settleTimer=null,!this.element.isConnected)return;const{height:s}=nt(this.element);s>0&&Math.abs(s-this._lastAppliedHeight)>8&&!this._autoScaleGuard&&r(this);const e=t.shift();void 0!==e&&(this._settleTimer=setTimeout(i,e))};this._settleTimer=setTimeout(i,t.shift())}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null,null!=this._settleTimer&&(clearTimeout(this._settleTimer),this._settleTimer=null)}prepareDimension(){const t=nt(this.element),i=this.prepareScenarios(),s=this.prepareVariances();this.canvasWidthSegmented=t.width/(i.length+s.length||1),this._lastAppliedHeight=t.height;const e=1+s.length,n="true"===this.showMeasureScale?this.getEffectiveFontPx():0;return{width:this.canvasWidthSegmented,height:Math.max(0,t.height-n)/e}}prepareScenarios(){var t,i,s,e;const n=this.resolveInherited("scenarios",this.scenarios);if(void 0!==n)return this.errors.remove("AUTO_scenarios"),n.split(",").map((t=>t.trim()));const r="auto"===(null===(t=this.scenarios)||void 0===t?void 0:t.trim().toLowerCase());return P(this.scenarios)||r?(null===(s=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===s?void 0:s.length)>0?(r?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(e=this.scenarios)||void 0===e?void 0:e.split(",").map((t=>t.trim())))}prepareAvg(){return"true"===this.showOverlayAvg}prepareMedian(){return"true"===this.showOverlayMedian}prepareVariances(){var t;const i=this.resolveInherited("variances",this.variances);return void 0!==i?i.split(",").map((t=>t.trim())):P(this.variances)?[]:null===(t=this.variances)||void 0===t?void 0:t.split(",").map((t=>t.trim()))}prepareHideAxisLabels(t){return t>=1||"true"!==this.showCategories}prepareI18n(){const t=p,i=new Map(["no-data"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries()])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const t=Q(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/t.value):"auto"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${ui.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const t=Q(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/t.value):"auto"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${ui.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}prepareLevel(){var t,i,s;const e="auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase());return P(this.level)||e?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?(e?this.errors.remove("AUTO_level"):this.errors.addOrReplace({id:"AUTO_level",type:"warning",message:`level: not set, auto-detected: ${this.datasetMeta.suggestedLevel}`}),di[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),di[null===(s=this.level)||void 0===s?void 0:s.toUpperCase()])}prepareOrder(){var t,i,s;const e=this.resolveInherited("order",this.order),n=this.resolveInherited("orderDirection",this.orderDirection),r=null!=e?e:this.order,a=null!=n?n:this.orderDirection;let o=(P(this.level)||"auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase()))&&(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?this.datasetMeta.suggestedLevel:this.level;const h="auto"===(null==r?void 0:r.trim().toLowerCase());return P(r)||h?(null===(s=this.datasetMeta)||void 0===s?void 0:s.suggestedLevel)&&(h?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:`order: not set, auto-detected: ${o}`})):(this.errors.remove("AUTO_order"),"levelindex"===(null==r?void 0:r.toLocaleLowerCase())&&(o+="Index")),{hierarchy:[_t[null==o?void 0:o.toUpperCase()]],direction:xt[null==a?void 0:a.toUpperCase()]}}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const s=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-time"].scaleFactors.scenarioOffset,scenarioLabelToColumn:i["bn-chart-time"].scaleFactors.scenarioLabelToColumn,labelToColumn:.3,labelToColum:i["bn-chart-time"].scaleFactors.labelToColum,labelToAxis:i["bn-chart-time"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-time"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-time"].scaleFactors.needleHeadWidth,columnWidth:i["bn-chart-time"].scaleFactors.columnWidth,varianceAxisLineWidth:i["bn-chart-time"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-time"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-time"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-time"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-time"].scaleFactors.markerWidth,markerOffset:i["bn-chart-time"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-time"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-time"].scaleFactors.axisTickLength},fontStyles:{font:`${s}px ${i.global.fontFamily}`,family:i.global.fontFamily,size:s,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-time"].axisStyles,barStyles:i["bn-chart-time"].barStyles,varianceStyles:i["bn-chart-time"].varianceStyles,stackColors:i["bn-chart-time"].stackColors,padding:i["bn-chart-time"].padding,pattern:null}}))}prepareLeftSideOffset(t,i){return this.syncSpaceLeft>-1?this.syncSpaceLeft:Gt.getMaxWidthOfArrayItems([...this.prepareVariances(),...this.prepareScenarios(),this.chartTitle],t,i)}prepareChartTitle(t){return t>=1?"":this.chartTitle}prepareLimit(){return Math.floor(Number(this.limit)||0)}prepareDateInterval(){var t,i,s;const e="auto"===(null===(t=this.dateInterval)||void 0===t?void 0:t.trim().toLowerCase());return P(this.dateInterval)||e?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedDateInterval)?(e?this.errors.remove("AUTO_dateInterval"):this.errors.addOrReplace({id:"AUTO_dateInterval",type:"warning",message:`dateInterval: not set, auto-detected: ${this.datasetMeta.suggestedDateInterval}`}),C[this.datasetMeta.suggestedDateInterval.toUpperCase()]):e?C.AUTO:void 0:(this.errors.remove("AUTO_dateInterval"),C[null===(s=this.dateInterval)||void 0===s?void 0:s.toUpperCase()])}prepareIntervalSpanLimit(){return this.intervalSpanLimit}prepareAxisLabelsMode(){var t;return vt[null===(t=this.axisLabelsMode)||void 0===t?void 0:t.toUpperCase()]}prepareFilter(){return 0===this.filter.length?"":this.filter}getDataStructure(){return{ITimeChartDataRow:{setName:{type:"string",isOptional:!1,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return P(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&"true"===this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareStackConfig(){if(P(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const t=JSON.parse(this.stack),i=t.by,s="WARN_stack_dimensions_scenarios";if(i===ut.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:s,type:"warning",message:`stack by dimensions: only the first scenario "${t[0]}" is used, the rest (${t.slice(1).join(", ")}) are discarded.`}):this.errors.remove(s)}else this.errors.remove(s);return{by:i,mode:t.mode||ft.ABSOLUTE,order:t.order||pt.DATASET}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareLineFullWidth(){return"true"===this.lineFullWidth}prepareChartMode(){var t;const i=null===(t=this.chartMode)||void 0===t?void 0:t.toLowerCase();return"line"===i?gt.LINE:"auto"===i?gt.AUTO:gt.BAR}prepareMaxBars(){return Math.floor(Number(this.maxBars)||28)}chartTemplate(t,s){const e=this.prepareI18n(),n=this.prepareStyle(),r=nt(this.element).width,a=this.preparePixelPerUnit(),o=this.preparePixelPerPercentage(),h=this.prepareStackConfig(),l=this.prepareScenarios(),c=(null==h?void 0:h.by)===ut.DIMENSIONS?l.slice(0,1):l;return i("ibcs-chart-time",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(s),scenarios:c,variances:[t],hideAxisLabels:this.prepareHideAxisLabels(s),pixelPerUnit:a,pixelPerPercentage:o,reportAutoScaling:this.handleAutoScalingReport,limit:this.prepareLimit(),leftSideOffsetForHorizontalSync:this.prepareLeftSideOffset(e,n),styles:n,i18n:e,order:this.prepareOrder(),level:this.prepareLevel(),dateInterval:this.prepareDateInterval(),intervalSpanLimit:this.prepareIntervalSpanLimit(),axisLabelsMode:this.prepareAxisLabelsMode(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showOverlayAvg:this.prepareAvg(),showOverlayMedian:this.prepareMedian(),showMeasureScale:this.prepareShowMeasureScale(s),chartMode:this.prepareChartMode(),maxBars:this.prepareMaxBars(),stackConfig:h,lineFullWidth:this.prepareLineFullWidth(),containerWidth:r,parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}async getLayoutState(t){var i,s,e,n;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",a=Ct(this.element),o=this.getEffectiveScaleFactor(),h=Number.isFinite(o)&&o>0?o:1,l=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*h,c=this.prepareVariances(),d=ct(this.element,"ibcs-chart-time",["base",...c],a,r),u=null===(s=this.element.shadowRoot)||void 0===s?void 0:s.querySelector("ibcs-chart-time"),p={version:Pt,tag:this.element.localName,id:At(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:Lt(this.element,a),em:{fontSizePx:l,appliedScaleFactor:h},regions:d.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(n=null==u?void 0:u.scenarios)&&void 0!==n?n:[],variances:c,barCount:d.barCount,chartMode:this.chartMode||void 0,hasNoData:0===d.barCount},diagnostics:Tt(this.element),scaling:this.resolveScalingInfo(l)};return d.elements&&(p.elements=d.elements),p}resolveScalingInfo(t){var i,s;const e={},n=Q(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===n.kind)e.unitMode="fixed",e.unitsPerEm=n.value,e.unitPxPerUnit=t/n.value;else{e.unitMode="auto";const s=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==s&&s>0&&(e.unitPxPerUnit=s,e.unitsPerEm=t/s)}const r=Q(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)e.percentageMode="fixed",e.percentagePointsPerEm=r.value,e.percentagePxPerPoint=t/r.value;else{e.percentageMode="auto";const i=null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.percentage;void 0!==i&&i>0&&(e.percentagePxPerPoint=i/100,e.percentagePointsPerEm=100*t/i)}return e}getEffectiveScaleFactor(){const{mode:t,factor:i}=rt(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){const t=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}));return t*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const a=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":a*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){let t=[""];const e=this.prepareVariances();e.length>0&&(t=[...t,...e]);const n=this.getFontStyles();return i(s,{key:"93a5778cad09ee33f54df92f3b3e32d030a734d6",style:n},i("div",{key:"b431ad76c90bc3c6e5f6820ba03df574155b0038",class:"container"},t.map(this.chartTemplate)))}get element(){return e(this)}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],syncSpaceLeft:[{validateLeftSync:0}],limit:[{validateLimit:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],dateInterval:[{validateDateInterval:0}],chartMode:[{validateChartMode:0}],maxBars:[{validateMaxBars:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}],axisLabelsMode:[{validateAxisLabelsMode:0}],lineFullWidth:[{validateLineFullWidth:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],showOverlayAvg:[{validateShowOverlayAvg:0}],showOverlayMedian:[{validateShowOverlayMedian:0}]}}};ui.style=":host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:column-reverse}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}";const pi=class{constructor(i){t(this,i),this.name="_default",h(this),this.errors=l(this),b(this,(t=>{this.stores||(this.stores=d(this.element));try{const i=JSON.parse(t);this.stores.componentStyles.set(this.name,i),this.errors.remove("JSON_PARSE")}catch(t){this.errors.addOrReplace({id:"JSON_PARSE",type:"error",message:`bn-component-style: Failed to parse JSON body — ${t.message}`}),console.error(t)}}))}render(){return i(s,{key:"9138ba4914f990823213f637bdc65274669bfe86"})}get element(){return e(this)}};pi.style="bn-component-style{display:none}";const fi=class{constructor(i){t(this,i),this.currentPageUpdate=void 0,h(this),this.errors=l(this)}setLocale(t){this.stores.context.state.locale=t}connectedCallback(){this.stores=f(this.element),this.locale&&(this.stores.context.state.locale=this.locale),this.currentPageUpdate=setTimeout((()=>{this.element.querySelectorAll("bn-page, bn-layout-page").forEach(((t,i)=>{if("bn-layout-page"===t.localName)t.setAttribute("page-number",(i+1).toString());else{const s=t.querySelector("bn-footer");s&&s.setAttribute("page-number",(i+1).toString())}}))}),250)}disconnectedCallback(){this.currentPageUpdate&&clearTimeout(this.currentPageUpdate)}async getLayoutState(t){var i,s;const e=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",n=Array.from(this.element.querySelectorAll("bn-body, bn-card, bn-chart-bubble, bn-chart-bullet, bn-chart-scatter, bn-chart-structure, bn-chart-time, bn-footer, bn-grid, bn-image, bn-layout-card, bn-layout-page, bn-message, bn-page, bn-table, bn-template, bn-text, bn-title, bn-tree"));await Promise.all(n.map((t=>{var i,s,e;return null!==(e=null===(s=(i=t).componentOnReady)||void 0===s?void 0:s.call(i))&&void 0!==e?e:Promise.resolve()})));const r=this.element.getBoundingClientRect(),a={x:r.left,y:r.top},o=await Promise.all(n.map((async t=>{const i=t.getBoundingClientRect(),s={context:a,component:{x:i.left,y:i.top}};try{const i=t;return"function"==typeof i.getLayoutState?await i.getLayoutState({detail:e}):li(t,s)}catch(i){let e;try{e=li(t,s)}catch(i){const s={x:0,y:0,width:0,height:0};e={version:Pt,tag:t.localName,id:t.localName,rect:{context:Object.assign({},s),component:Object.assign({},s)},em:{fontSizePx:0,appliedScaleFactor:1},regions:[],metadata:{},diagnostics:[]}}return e.error=String(i instanceof Error?i.message:i),e}}))),h=Nt(n.map((t=>({tag:t.localName,explicitId:Ut(t)}))));return o.forEach(((t,i)=>{t.id=h[i]})),{version:Pt,generatedAt:(new Date).toISOString(),detail:e,context:{viewport:Dt(r),locale:null===(s=this.stores)||void 0===s?void 0:s.context.state.locale},components:o}}componentWillLoad(){}componentDidLoad(){}componentShouldUpdate(){}componentWillRender(){}componentDidRender(){}componentWillUpdate(){}componentDidUpdate(){}render(){return i(s,{key:"005c68f320adbbd5d5269d3fe6f2da6a8096ed98"},i("slot",{key:"7d9fbf3e7a253fe24414cd26274fdffb03b2d5f6"}))}get element(){return e(this)}static get watchers(){return{locale:[{setLocale:0}]}}};fi.style=":host{display:block}";const vi=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],gi=["rowGroup","category","subCategory","columnGroup","columnSubGroup"];function mi(t){return"number"==typeof t&&!isNaN(t)&&isFinite(t)}function bi(t){const i=Array.from(t);return{distinctValues:i,count:i.length,hasData:i.length>0}}var wi=Uint8Array,yi=Uint16Array,Si=Int32Array,$i=new wi([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Oi=new wi([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ri=new wi([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Mi=function(t,i){for(var s=new yi(31),e=0;e<31;++e)s[e]=i+=1<<t[e-1];var n=new Si(s[30]);for(e=1;e<30;++e)for(var r=s[e];r<s[e+1];++r)n[r]=r-s[e]<<5|e;return{b:s,r:n}},xi=Mi($i,2),_i=xi.b,Ei=xi.r;_i[28]=258,Ei[258]=28;for(var ki=Mi(Oi,0).b,Pi=new yi(32768),Ti=0;Ti<32768;++Ti){var Li=(43690&Ti)>>1|(21845&Ti)<<1;Pi[Ti]=((65280&(Li=(61680&(Li=(52428&Li)>>2|(13107&Li)<<2))>>4|(3855&Li)<<4))>>8|(255&Li)<<8)>>1}var Ai=function(t,i,s){for(var e=t.length,n=0,r=new yi(i);n<e;++n)t[n]&&++r[t[n]-1];var a,o=new yi(i);for(n=1;n<i;++n)o[n]=o[n-1]+r[n-1]<<1;if(s){a=new yi(1<<i);var h=15-i;for(n=0;n<e;++n)if(t[n])for(var l=n<<4|t[n],c=i-t[n],d=o[t[n]-1]++<<c,u=d|(1<<c)-1;d<=u;++d)a[Pi[d]>>h]=l}else for(a=new yi(e),n=0;n<e;++n)t[n]&&(a[n]=Pi[o[t[n]-1]++]>>15-t[n]);return a},Ci=new wi(288);for(Ti=0;Ti<144;++Ti)Ci[Ti]=8;for(Ti=144;Ti<256;++Ti)Ci[Ti]=9;for(Ti=256;Ti<280;++Ti)Ci[Ti]=7;for(Ti=280;Ti<288;++Ti)Ci[Ti]=8;var Ni=new wi(32);for(Ti=0;Ti<32;++Ti)Ni[Ti]=5;var Ui=Ai(Ci,9,1),Di=Ai(Ni,5,1),Gi=function(t){for(var i=t[0],s=1;s<t.length;++s)t[s]>i&&(i=t[s]);return i},Wi=function(t,i,s){var e=i/8|0;return(t[e]|t[e+1]<<8)>>(7&i)&s},Fi=function(t,i){var s=i/8|0;return(t[s]|t[s+1]<<8|t[s+2]<<16)>>(7&i)},Ii=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Yi=function(t,i,s){var e=new Error(i||Ii[t]);if(e.code=t,Error.captureStackTrace&&Error.captureStackTrace(e,Yi),!s)throw e;return e},zi=new wi(0);function Bi(t,i){var s,e,n=function(t){31==t[0]&&139==t[1]&&8==t[2]||Yi(6,"invalid gzip data");var i=t[3],s=10;4&i&&(s+=2+(t[10]|t[11]<<8));for(var e=(i>>3&1)+(i>>4&1);e>0;e-=!t[s++]);return s+(2&i)}(t);return n+8>t.length&&Yi(6,"invalid gzip data"),function(t,i,s,e){var n=t.length;if(!n||i.f&&!i.l)return s||new wi(0);var r=!s,a=r||2!=i.i;r&&(s=new wi(3*n));var o,h,l=function(t){var i=s.length;if(t>i){var e=new wi(Math.max(2*i,t));e.set(s),s=e}},c=i.f||0,d=i.p||0,u=i.b||0,p=i.l,f=i.d,v=i.m,g=i.n,m=8*n;do{if(!p){c=Wi(t,d,1);var b=Wi(t,d+1,3);if(d+=3,!b){var w=t[(P=4+((d+7)/8|0))-4]|t[P-3]<<8,y=P+w;if(y>n){Yi(0);break}a&&l(u+w),s.set(t.subarray(P,y),u),i.b=u+=w,i.p=d=8*y,i.f=c;continue}if(1==b)p=Ui,f=Di,v=9,g=5;else if(2==b){var S=Wi(t,d,31)+257,$=Wi(t,d+10,15)+4,O=S+Wi(t,d+5,31)+1;d+=14;for(var R=new wi(O),M=new wi(19),x=0;x<$;++x)M[Ri[x]]=Wi(t,d+3*x,7);d+=3*$;var _=Gi(M),E=(1<<_)-1,k=Ai(M,_,1);for(x=0;x<O;){var P,T=k[Wi(t,d,E)];if(d+=15&T,(P=T>>4)<16)R[x++]=P;else{var L=0,A=0;for(16==P?(A=3+Wi(t,d,3),d+=2,L=R[x-1]):17==P?(A=3+Wi(t,d,7),d+=3):18==P&&(A=11+Wi(t,d,127),d+=7);A--;)R[x++]=L}}var C=R.subarray(0,S),N=R.subarray(S);v=Gi(C),g=Gi(N),p=Ai(C,v,1),f=Ai(N,g,1)}else Yi(1);if(d>m){Yi(0);break}}a&&l(u+131072);for(var U=(1<<v)-1,D=(1<<g)-1,G=d;;G=d){var W=(L=p[Fi(t,d)&U])>>4;if((d+=15&L)>m){Yi(0);break}if(L||Yi(2),W<256)s[u++]=W;else{if(256==W){G=d,p=null;break}var F=W-254;W>264&&(F=Wi(t,d,(1<<(z=$i[x=W-257]))-1)+_i[x],d+=z);var I=f[Fi(t,d)&D],Y=I>>4;if(I||Yi(3),d+=15&I,N=ki[Y],Y>3){var z=Oi[Y];N+=Fi(t,d)&(1<<z)-1,d+=z}if(d>m){Yi(0);break}a&&l(u+131072);var B=u+F;if(u<N){var H=0-N,V=Math.min(N,B);for(H+u<0&&Yi(3);u<V;++u)s[u]=e[H+u]}for(;u<B;++u)s[u]=s[u-N]}}i.l=p,i.p=G,i.b=u,i.f=c,p&&(c=1,i.m=v,i.d=f,i.n=g)}while(!c);return u!=s.length&&r?(o=s,(null==(h=u)||h>o.length)&&(h=o.length),new wi(o.subarray(0,h))):s.subarray(0,u)}(t.subarray(n,-8),{i:2},new wi(((s=t)[(e=s.length)-4]|s[e-3]<<8|s[e-2]<<16|s[e-1]<<24)>>>0),i)}var Hi="undefined"!=typeof TextDecoder&&new TextDecoder;try{Hi.decode(zi,{stream:!0})}catch(t){}function Vi(t){return N(t)}function ji(t){const i=t.indexOf(":");if(-1===i)throw new Error("Invalid compressed format: missing ':' separator");const s=t.slice(0,i),e=t.slice(i+1),n=atob(e),r=new Uint8Array(n.length);for(let t=0;t<n.length;t++)r[t]=n.charCodeAt(t);const a=Bi(r);return{hash:s,json:(new TextDecoder).decode(a)}}const Xi=class{constructor(i){t(this,i),this.datasources="",this.static=!1,this.raw=!0,this.interval=0,this.lastBodyHash=null,this.lastViewQuery=null,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,h(this),this.errors=l(this),((t,i)=>{let s,n=[],r=[];const a=t=>{let e;try{e=s.db.db.exec(`SELECT * FROM \`${t}\``)}catch(t){e=[]}i()},o=()=>{n.forEach((t=>t())),n=[],r.forEach((t=>{t&&(n.push(s.db.subscribe(t,(()=>a(t)))),a(t))}))},h=new MutationObserver((i=>{i.forEach((i=>{"datasources"===i.attributeName&&(r=(e(t).getAttribute("datasources")||"").split(","),o())}))})),l=t.connectedCallback;t.connectedCallback=()=>{const i=e(t);s=d(i),r=(i.getAttribute("datasources")||"").split(","),o(),h.observe(i,{attributes:!0,attributeFilter:["datasources"]}),c(l,t)};const u=t.disconnectedCallback;t.disconnectedCallback=()=>{h.disconnect(),n.forEach((t=>t())),n=[],v(e(t)),c(u,t)}})(this,(()=>{this.executeQuery()})),b(this,(t=>{const i=t.trim();if(this.isUrl(i)){if(i===this.currentUrl)return;return this.currentUrl=i,this.lastBodyHash=null,this.fetchAndStore(i),void this.startPolling()}let s,e;if(null!==this.currentUrl&&(this.cancelInFlight(),this.currentUrl=null),!this.raw&&this.static)try{const i=ji(t);s=i.hash,e=i.json}catch(i){return void console.error("Error decoding compressed dataset",i,String(t).slice(0,200))}else s=Vi(t),e=t;s!==this.lastBodyHash&&(this.lastBodyHash=s,this.query=e,this.executeQuery())}))}executeQuery(){if(this.stores||(this.stores=d(this.element)),!this.query||!this.name)return;const t=this.stores.db.db;let i;if(this.static){try{i=JSON.parse(this.query)}catch(t){console.error("Failed to parse static dataset",t),i=[]}t.tables[this.name]={data:Array.isArray(i)?i:[]},this.lastViewQuery=null}else{if(this.lastViewQuery!==this.query){try{t.exec(`DROP VIEW \`${this.name}\``)}catch(t){}null!=t.tables[this.name]&&delete t.tables[this.name],t.views&&null!=t.views[this.name]&&delete t.views[this.name];try{t.exec(`CREATE VIEW \`${this.name}\` AS ${this.query}`),this.lastViewQuery=this.query}catch(t){return console.error("bn-dataset: failed to register SQL view",t,this.query),this.lastViewQuery=null,i=[],void this.publish(i)}}try{i=t.exec(`SELECT * FROM \`${this.name}\``)}catch(t){return}}this.publish(i)}publish(t){this.latestResult!==t?(this.latestResult=t,this.stores.db.notify(this.name),this.stores.datasetsMeta.set(this.name,function(t){const i={};for(const t of gi)i[t]=new Set;const s={};for(const t of vi)s[t]={hasData:!1,min:null,max:null};const e=new Set;let n=null,r=null;const a=Array.isArray(t)?t:[];for(let t=0;t<a.length;t++){const o=a[t];if(null==o)continue;for(const t of gi){const s=o[t];null!=s&&""!==s&&i[t].add(String(s))}for(const t of vi){const i=o[t];if(mi(i)){const e=s[t];e.hasData=!0,(null===e.min||i<e.min)&&(e.min=i),(null===e.max||i>e.max)&&(e.max=i)}}const h=o.date;if(null!=h&&""!==h){const t=String(h);e.add(t),(null===n||t<n)&&(n=t),(null===r||t>r)&&(r=t)}}const o=vi.map((t=>({key:t,hasData:s[t].hasData,min:s[t].min,max:s[t].max}))),h=o.filter((t=>t.hasData)).map((t=>t.key)),l=bi(i.rowGroup),c=bi(i.category),d=bi(i.subCategory),u=bi(i.columnGroup),p=bi(i.columnSubGroup),f={min:n,max:r,hasData:e.size>0,distinctCount:e.size};let v="category";return d.hasData?v="subCategory":c.hasData?v="category":l.hasData&&(v="rowGroup"),{rowCount:a.length,scenarios:o,availableScenarios:h,rowGroup:l,category:c,subCategory:d,columnGroup:u,columnSubGroup:p,dateRange:f,suggestedLevel:v,suggestedOrder:v,suggestedDateInterval:f.hasData?"auto":null,calculatedAt:Date.now()}}(t))):this.stores.db.notify(this.name)}nameUpdated(){this.executeQuery()}onIntervalChange(){this.currentUrl&&this.startPolling()}disconnectedCallback(){var t,i;if(this.cancelInFlight(),(null===(i=null===(t=this.stores)||void 0===t?void 0:t.db)||void 0===i?void 0:i.db)&&this.name){const t=this.stores.db.db;try{t.exec(`DROP VIEW \`${this.name}\``)}catch(t){}null!=t.tables[this.name]&&delete t.tables[this.name],t.views&&null!=t.views[this.name]&&delete t.views[this.name],this.stores.db.notify(this.name)}}isUrl(t){return!(!t.startsWith("http://")&&!t.startsWith("https://"))||t.startsWith("/")&&!t.startsWith("//")}async fetchAndStore(t){var i;null===(i=this.abortController)||void 0===i||i.abort(),this.abortController=new AbortController,this.stores||(this.stores=d(this.element));try{const i=await fetch(t,{signal:this.abortController.signal}),s=await i.json();this.stores.db.db.tables[this.name]={data:Array.isArray(s)?s:[]},this.lastViewQuery=null,this.publish(s)}catch(i){if(i instanceof DOMException&&"AbortError"===i.name)return;console.error("bn-dataset: error fetching URL",i,t),this.stores.db.db.tables[this.name]={data:[]},this.lastViewQuery=null,this.publish([])}}clearPollTimer(){null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null)}cancelInFlight(){var t;this.clearPollTimer(),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPollTimer(),this.currentUrl&&this.interval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&this.fetchAndStore(this.currentUrl)}),1e3*this.interval))}render(){return i(s,{key:"bfa62b924abb8097cd9bad75eb71ab38caf02267"})}get element(){return e(this)}static get watchers(){return{name:[{nameUpdated:0}],interval:[{onIntervalChange:0}]}}};Xi.style="bn-dataset{display:none}";const Ji=class{constructor(i){t(this,i),this.raw=!0,this.interval=0,this.lastHash=null,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,h(this),this.errors=l(this),b(this,(t=>{this.stores||(this.stores=d(this.element));const i=t.trim();if(this.isUrl(i)){if(i===this.currentUrl)return;return this.currentUrl=i,this.lastHash=null,this.fetchAndStore(i),void this.startPolling()}null!==this.currentUrl&&(this.cancelInFlight(),this.currentUrl=null);try{let i,s;if(this.raw)i=Vi(t),s=t;else{const e=ji(t);i=e.hash,s=e.json}if(i===this.lastHash)return;this.lastHash=i;const e=JSON.parse(s);this.publish(e)}catch(i){console.error("Error parsing datasource",i,String(t).slice(0,200)),this.publish([])}}))}publish(t){this.stores.db.db.tables[this.name]={data:Array.isArray(t)?t:[]},this.stores.db.notify(this.name)}onIntervalChange(){this.currentUrl&&this.startPolling()}disconnectedCallback(){var t,i;this.cancelInFlight();const s=null===(i=null===(t=this.stores)||void 0===t?void 0:t.db)||void 0===i?void 0:i.db;s&&this.name&&(null!=s.tables[this.name]&&delete s.tables[this.name],s.views&&null!=s.views[this.name]&&delete s.views[this.name],this.stores.db.notify(this.name))}isUrl(t){return!(!t.startsWith("http://")&&!t.startsWith("https://"))||t.startsWith("/")&&!t.startsWith("//")}async fetchAndStore(t){var i;null===(i=this.abortController)||void 0===i||i.abort(),this.abortController=new AbortController,this.stores||(this.stores=d(this.element));try{const i=await fetch(t,{signal:this.abortController.signal}),s=await i.json();this.publish(s)}catch(i){if(i instanceof DOMException&&"AbortError"===i.name)return;console.error("bn-datasource: error fetching URL",i,t),this.publish([])}}clearPollTimer(){null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null)}cancelInFlight(){var t;this.clearPollTimer(),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPollTimer(),this.currentUrl&&this.interval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&this.fetchAndStore(this.currentUrl)}),1e3*this.interval))}render(){return i(s,{key:"4beaa62937dea949255669bfd5008a2928e460fc"})}get element(){return e(this)}static get watchers(){return{interval:[{onIntervalChange:0}]}}};Ji.style="bn-datasource{display:none}";const qi=class{constructor(i){t(this,i),this.pageNumber=null,this.displayPageNumber=!0,h(this),this.errors=l(this),this.componentStyle=w(this)}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}isValidHttpUrl(t){let i;try{i=new URL(t)}catch(t){return!1}return"http:"===i.protocol||"https:"===i.protocol}prepareAssetUrl(t){return this.isValidHttpUrl(t)?t:`./assets/${t}.png`}render(){return i(s,{key:"666fa787056f32825c15427f2a6c15b971fbc25e",id:this.displayPageNumber||this.text||this.code?"container-page-footer":"container",style:this.getFontStyles()},i("div",{key:"691752d51748c4e1eb7ec25d380c00ddf0095c83",id:"footer-text"},null!=this.text?i("span",{class:"note"},this.text):""),i("div",{key:"561a81e063e110ef6386fb0056a05f1b6a0e0f44",id:"code"},null!=this.code?i("img",{class:"image",src:a(`${this.prepareAssetUrl(this.code)}`)}):""),i("div",{key:"963658fcff1a6dd07b448f85e8d170000422e3cc",id:"page-number"},this.displayPageNumber?i("span",{class:"page"},this.pageNumber):""))}static get assetsDirs(){return["assets"]}get element(){return e(this)}};qi.style=':host{padding:0.2em 0.5em;display:flex;flex-direction:row;justify-content:space-between;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}:host(#container-page-footer){box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em solid #ddd}div#footer-text{font-size:0.6em;display:inline}div#code{flex:1;display:inline;text-align:right;padding-right:1em}div#page-number{font-size:0.6em;display:inline}.image{z-index:2;background-color:transparent;border:transparent;height:1.2em;width:auto}';const Zi=class{constructor(i){t(this,i),this.titleImage="",this.titleBusinessUnit="",this.titleOrder="category",this.titleOrderDirection="asc",this.titleDateFormat="none",this.titleDateLink="none",this.footerText="",this.cardLayout="full",this.cardCustomTemplate='"a b" "c d"',this.cardGridGap="0",this.cardFitToContent=!1,this.cardShowBorder=!0,this.templateMap=new Map([["split-vertical",'"a b"'],["split-horizontal",'"a" "b"'],["2x2",'"a b" "c d"'],["3x3",'"a b c" "d e f" "g h i"'],["4x4",'"a b c d" "e f g h" "i j k l" "m n o p"'],["1-over-2",'"a a" "b c"'],["2-over-1",'"a b" "c c"'],["1-over-3",'"a a a " "b c d"'],["3-over-1",'"a b c" "d d d"'],["custom-template",'"a b" "c c c"'],["gold3",'"a c" "b c"'],["gold4",'"a b c c" "d d c c"']]),this.errors=l(this),this.resolveInherited=et(this,[{propName:"titleScenarios",ancestorAttr:"title-scenarios"},{propName:"titleVariances",ancestorAttr:"title-variances"},{propName:"titleOrder",ancestorAttr:"title-order"},{propName:"titleOrderDirection",ancestorAttr:"title-order-direction"},{propName:"ruleset",ancestorAttr:"ruleset"}])}connectedCallback(){this.stores=d(this.element),this.reflectInheritedAttrs()}getCommonStyles(){let t="100%";return!0===this.cardFitToContent&&(t="fit-content"),{display:"grid",height:t,width:"100%",gap:this.cardGridGap+"px"}}calculateFractions(t){const i=t.trim().split(/\s+/).length;return 0===i?"minmax(0, 1fr)":Array(i).fill("minmax(0, 1fr)").join(" ")}getGridTemplateColumns(t){const i=this.getTemplatePattern(t).match(/"[\w\d\s.]+"/g);return i&&0!==i.length?this.calculateFractions(i[0]):"minmax(0, 1fr)"}getRowCount(t){const i=this.getTemplatePattern(t).match(/"[\w\d\s.]+"/g);return i?i.length:1}getGridTemplateRows(t){const i=this.getRowCount(t);return this.cardFitToContent?Array(i).fill("auto").join(" "):Array(i).fill("minmax(0, 1fr)").join(" ")}getLayoutStyle(){return Object.assign(Object.assign({},this.getCommonStyles()),{"grid-template-areas":this.getTemplatePattern(this.cardLayout),"grid-template-columns":this.getGridTemplateColumns(this.cardLayout),"grid-template-rows":this.getGridTemplateRows(this.cardLayout)})}createDivAreaStyles(t){return t.map((t=>({display:"flex",overflow:"hidden","grid-area":t})))}getSlots(t){const s=this.createDivAreaStyles(t);return i(o,null,s.map(((t,s)=>i("div",{style:t},i("slot",{name:"card-slot-"+s})))))}extractSlotNames(t){if(null==t)return[];const i=t.match(/\b\w+\b/g);return i?Array.from(new Set(i)):[]}getTemplatePattern(t){return!1===this.templateMap.has(t)&&"custom-template"!==t?'"a"':"custom-template"===t?this.cardCustomTemplate:this.templateMap.get(t)}async getNumberOfSlot(t){const i=this.getTemplatePattern(t);return this.extractSlotNames(i).length}componentDidUpdate(){}setCardClass(){return!0===this.cardShowBorder?"card_box border":"card_box"}reflectInheritedAttrs(){const t=[{prop:"titleScenarios",attr:"title-scenarios"},{prop:"titleVariances",attr:"title-variances"},{prop:"titleOrder",attr:"title-order"},{prop:"titleOrderDirection",attr:"title-order-direction"},{prop:"ruleset",attr:"ruleset"}];for(const{prop:i,attr:s}of t){const t=this.resolveInherited(i,this[i]);void 0!==t&&this.element.setAttribute(s,t)}}prepareTitleImage(t){if(null==t||""===t)return"";const i=this.stores.assets.state;return t.startsWith("asset:")?i[t.substring(6)]:i[t]||t}render(){var t,s,e,n,r,a;const o=this.getLayoutStyle(),h=this.extractSlotNames(o["grid-template-areas"]);return i("bn-card",{key:"2aa7bd3e3beb1a6b6b0dc0b06c7d7eda324299a0",styles:this.styles,"selected-style":this.selectedStyle,class:this.setCardClass()},i("div",{key:"65fe54ff342691b7f2b7df747af88499ffdbebc0",class:"cardtitle"},i("bn-title",{key:"be70a8c4e5cef0be0fb264fe74dc3732c2a42939","i18n-namespace":null!==(t=this.i18nNamespace)&&void 0!==t?t:this.titleNamespace,ruleset:null!==(s=this.resolveInherited("ruleset",this.ruleset))&&void 0!==s?s:this.ruleset,"business-unit":this.titleBusinessUnit,scenarios:null!==(e=this.resolveInherited("titleScenarios",this.titleScenarios))&&void 0!==e?e:this.titleScenarios,variances:null!==(n=this.resolveInherited("titleVariances",this.titleVariances))&&void 0!==n?n:this.titleVariances,order:null!==(r=this.resolveInherited("titleOrder",this.titleOrder))&&void 0!==r?r:this.titleOrder,"order-direction":null!==(a=this.resolveInherited("titleOrderDirection",this.titleOrderDirection))&&void 0!==a?a:this.titleOrderDirection,measures:this.titleMeasures,"date-start":this.titleDateStart,"date-end":this.titleDateEnd,"date-format":this.titleDateFormat,"date-link":this.titleDateLink}),null!=this.titleImage&&""!==this.titleImage?i("img",{class:"image",src:this.prepareTitleImage(this.titleImage)}):""),i("bn-body",{key:"5875c3e62ca38095588f13907936974259816215"},i("div",{key:"c845d5f8c130f2dd0ae48fc4c2301a55842f001a",style:o,"data-bn-fit-content":this.cardFitToContent?String(this.getRowCount(this.cardLayout)):null},this.getSlots(h))),i("bn-footer",{key:"388596894d04dc2f93d6d71b9f8a0348fb46195f",text:this.footerText,"page-number":0,"display-page-number":"false"}))}get element(){return e(this)}};Zi.style=':host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden}.cardtitle{display:inline-flex}::slotted(*){flex:1 1 auto;min-width:0}.image{margin-right:0.5em;margin-top:0.5em;z-index:2;background-color:transparent;border:transparent;height:4em;width:auto;display:inline}';const Ki=class{constructor(i){t(this,i),this.messageText="",this.messageImage="",this.titleBusinessUnit="",this.titleOrder="category",this.titleOrderDirection="asc",this.titleDateFormat="none",this.titleDateLink="none",this.footerDisplayPageNumber=!0,this.pageLayout="full",this.pageCustomTemplate='"a b" "c d"',this.pageGridGap="0",this.pageFitToContent=!1,this.templateMap=new Map([["split-vertical",'"a b"'],["split-horizontal",'"a" "b"'],["2x2",'"a b" "c d"'],["3x3",'"a b c" "d e f" "g h i"'],["4x4",'"a b c d" "e f g h" "i j k l" "m n o p"'],["1-over-2",'"a a" "b c"'],["2-over-1",'"a b" "c c"'],["1-over-3",'"a a a " "b c d"'],["3-over-1",'"a b c" "d d d"'],["custom-template",'"a b" "c c c"'],["gold3",'"a c" "b c"'],["gold4",'"a b c c" "d d c c"']]),this.errors=l(this)}getCommonStyles(){let t="100%";return!0===this.pageFitToContent&&(t="fit-content"),{display:"grid",height:t,width:"100%",gap:this.pageGridGap+"px"}}getRowCount(t){const i=this.getTemplateAreas(t).match(/"[\w\d\s.]+"/g);return i?i.length:1}getGridTemplateRows(t){const i=this.getRowCount(t);return this.pageFitToContent?Array(i).fill("auto").join(" "):Array(i).fill("minmax(0, 1fr)").join(" ")}getLayoutStyle(){return Object.assign(Object.assign({},this.getCommonStyles()),{"grid-template-areas":this.getTemplateAreas(this.pageLayout),"grid-template-columns":this.getGridTemplateColumns(this.pageLayout),"grid-template-rows":this.getGridTemplateRows(this.pageLayout)})}createDivAreaStyles(t){return t.map((t=>({display:"flex",overflow:"hidden","grid-area":t})))}getSlots(t){const s=this.createDivAreaStyles(t);return i(o,null,s.map(((t,s)=>i("div",{style:t},i("slot",{name:"slot-"+s})))))}extractSlotNames(t){if(null==t)return[];const i=t.match(/\b\w+\b/g);return i?Array.from(new Set(i)):[]}getTemplateAreas(t){return!1===this.templateMap.has(t)&&"custom-template"!==t?'"a"':"custom-template"===t?this.pageCustomTemplate:this.templateMap.get(t)}calculateFractions(t){const i=t.trim().split(/\s+/).length;return 0===i?"minmax(0, 1fr)":Array(i).fill("minmax(0, 1fr)").join(" ")}getGridTemplateColumns(t){if(!1===this.templateMap.has(t)&&"custom-template"!==t)return"1fr";let i;i="custom-template"===t?this.pageCustomTemplate:this.templateMap.get(t);const s=i.match(/"[\w\d\s.]+"/g);return this.calculateFractions(s[0])}async getNumberOfSlot(t){const i=this.getTemplateAreas(t);return this.extractSlotNames(i).length}componentDidUpdate(){const t=this.element.closest("bn-context").getAttribute("render-orientation");if(t&&t!==this.pageOrientation){const t=this.element.shadowRoot.querySelector("bn-page"),i=this.element.closest("bn-layout-page");i&&t&&(t.style.transform="rotate(-90deg) translate(-100%)",t.style.transformOrigin="top left",i.style.width=`${t.clientHeight}px`,i.style.height=`${t.clientWidth}px`)}}render(){var t;const s=this.getLayoutStyle(),e=this.extractSlotNames(s["grid-template-areas"]);return i("bn-page",{key:"6ce75e58dfb8ccab0686d8f34cc6f7830fd42db7",styles:this.styles,"selected-style":this.selectedStyle,format:this.pageFormat,orientation:this.pageOrientation},i("bn-message",{key:"0b7f297afe281b0df05691485a93ba6c3d8abbae",text:this.messageText,image:this.messageImage}),i("bn-title",{key:"b02de31fa8f7e03c38e12cd45ec7f02e2d986d70","i18n-namespace":null!==(t=this.i18nNamespace)&&void 0!==t?t:this.titleNamespace,ruleset:this.ruleset,"business-unit":this.titleBusinessUnit,scenarios:this.titleScenarios,variances:this.titleVariances,order:this.titleOrder,"order-direction":this.titleOrderDirection,measures:this.titleMeasures,"date-start":this.titleDateStart,"date-end":this.titleDateEnd,"date-format":this.titleDateFormat,"date-link":this.titleDateLink}),i("bn-body",{key:"8d43429effcb755ee69665820120838c60b8b9d1"},i("div",{key:"f2d61818b1272551c73bf174f91f61904799a780",style:s,"data-bn-fit-content":this.pageFitToContent?String(this.getRowCount(this.pageLayout)):null},this.getSlots(e))),i("bn-footer",{key:"8d6a6d76c7bef823ee7063586e87084654705771",text:this.footerText,"page-number":this.pageNumber,"display-page-number":this.footerDisplayPageNumber}))}get element(){return e(this)}};Ki.style=':host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:block;overflow:hidden}::slotted(*){flex:1 1 auto;min-width:0}';const Qi=class{constructor(i){t(this,i),h(this),this.errors=l(this),this.componentStyle=w(this)}connectedCallback(){this.stores=d(this.element)}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}prepareAssetUrl(t){if(null==t||""===t)return"";const i=this.stores.assets.state;return t.startsWith("asset:")?i[t.substring(6)]:i[t]||t}render(){return i(s,{key:"9ddcd517464de7fce9fda3c67a6b4c803e6ac4b9",id:this.text||this.image?"container-page-message":"container",style:this.getFontStyles()},i("div",{key:"4618ec0f8cf5b6573278dee2ceb861ca2ad7984d",id:"message-text"},null!=this.text&&""!==this.text?i("span",{class:"note",innerHTML:Xt(this.text)}):""),i("div",{key:"c8c090354330d866fd8431e2df345153bf537c30",id:"page-image"},null!=this.image&&""!==this.image?i("img",{class:"image",src:this.prepareAssetUrl(this.image)}):""))}static get assetsDirs(){return["assets"]}get element(){return e(this)}};Qi.style=':host{padding:0.2em 0.5em;display:flex;flex-direction:row;justify-content:space-between;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}:host(#container-page-message){min-height:4.55em;box-sizing:border-box;-webkit-box-sizing:border-box;border-bottom:0.1em solid #ddd}div#message-text{font-size:1.4em;overflow:clip;display:inline}span.note p{margin:0}.image{z-index:2;background-color:transparent;border:transparent;height:4em;width:auto;display:block}';const ts=["xga","hd","full-hd","4k","4k2k","a4","a3","a2","a1","a0","letter","legal"],is=["landscape","portrait"],ss=class{constructor(i){t(this,i),h(this),this.errors=l(this),this.componentStyle=w(this)}validateFormat(t){const i="ERR_format";P(t)||ts.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`format: invalid value '${t}' is not supported. Valid values: ${ts.join(", ")}`})}validateOrientation(t){const i="ERR_orientation";P(t)||is.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`orientation: invalid value '${t}' is not supported. Valid values: ${is.join(", ")}`})}render(){return i(s,{key:"8a24c1c3d796d335826e9dec5e73415a44cf6a1e",format:this.format,orientation:this.orientation,style:this.prepareStyle()},i("slot",{key:"23a59d11c2ac469047e11a7bf189e041bb58928b"}))}prepareStyle(){return{"font-family":this.componentStyle((t=>t.global.fontFamily)),"font-size":`${this.componentStyle((t=>t.global.fontSizePx))}px`,"--bn-font-family":this.componentStyle((t=>t.global.fontFamily))||"'Noto Sans', sans-serif","--bn-font-size":`${this.componentStyle((t=>t.global.fontSizePx))||13.3333}px`,"--bn-font-color":this.componentStyle((t=>t.global.fontColor))||"#000000","--bn-font-background":this.componentStyle((t=>t.global.fontBackgroundColor))||"#ffffff"}}get element(){return e(this)}static get watchers(){return{format:[{validateFormat:0}],orientation:[{validateOrientation:0}]}}};ss.style=':host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);height:768px;width:1024px;display:flex;flex-direction:column;page-break-after:always;overflow:hidden}:host([format=xga]){height:768px;width:1024px}:host([format=xga][orientation=portrait]){height:1024px;width:768px}:host([format=xga][orientation=landscape]){height:768px;width:1024px}:host([format=hd]){height:720px;width:1280px}:host([format=hd][orientation=portrait]){height:1280px;width:720px}:host([format=hd][orientation=landscape]){height:720px;width:1280px}:host([format=full_hd]){height:1080px;width:1920px}:host([format=full_hd][orientation=portrait]){height:1920px;width:1080px}:host([format=full_hd][orientation=landscape]){height:1080px;width:1920px}:host([format="4k"]){height:2160px;width:3840px}:host([format="4k"][orientation=portrait]){height:3840px;width:2160px}:host([format="4k"][orientation=landscape]){height:2160px;width:3840px}:host([format="4k2k"]){height:2160px;width:4096px}:host([format="4k2k"][orientation=portrait]){height:4096px;width:2160px}:host([format="4k2k"][orientation=landscape]){height:2160px;width:4096px}:host([format=a6]){height:5.83in;width:4.13in}:host([format=a6][orientation=portrait]){height:5.83in;width:4.13in}:host([format=a6][orientation=landscape]){height:4.13in;width:5.83in}:host([format=a5]){height:8.27in;width:5.83in}:host([format=a5][orientation=portrait]){height:8.27in;width:5.83in}:host([format=a5][orientation=landscape]){height:5.83in;width:8.27in}:host([format=a4]){height:11.6in;width:8.17in}:host([format=a4][orientation=portrait]){height:11.6in;width:8.17in}:host([format=a4][orientation=landscape]){height:8.17in;width:11.6in}:host([format=a3]){height:16.54in;width:11.7in}:host([format=a3][orientation=portrait]){height:16.54in;width:11.7in}:host([format=a3][orientation=landscape]){height:11.7in;width:16.54in}:host([format=a2]){height:23.4in;width:16.54in}:host([format=a2][orientation=portrait]){height:23.4in;width:16.54in}:host([format=a2][orientation=landscape]){height:16.54in;width:23.4in}:host([format=a1]){height:33.1in;width:23.4in}:host([format=a1][orientation=portrait]){height:33.1in;width:23.4in}:host([format=a1][orientation=landscape]){height:23.4in;width:33.1in}:host([format=a0]){height:46.8in;width:33.1in}:host([format=a0][orientation=portrait]){height:46.8in;width:33.1in}:host([format=a0][orientation=landscape]){height:33.1in;width:46.8in}:host([format=letter]){height:11in;width:8.5in}:host([format=letter][orientation=portrait]){height:11in;width:8.5in}:host([format=letter][orientation=landscape]){height:8.5in;width:11in}:host([format=legal]){height:14in;width:8.5in}:host([format=legal][orientation=portrait]){height:14in;width:8.5in}:host([format=legal][orientation=landscape]){height:8.5in;width:14in}:host([format=tabloid]){height:17in;width:11in}:host([format=tabloid][orientation=portrait]){height:17in;width:11in}:host([format=tabloid][orientation=landscape]){height:11in;width:17in}:host([format=ledger]){height:11in;width:17in}:host([format=ledger][orientation=portrait]){height:17in;width:11in}:host([format=ledger][orientation=landscape]){height:11in;width:17in}';const es=class{constructor(i){t(this,i),h(this),this.errors=l(this)}connectedCallback(){this.stores=d(this.element),this.pushToStore()}disconnectedCallback(){this.removeEntryIfOurs(this.storedName)}onNameChange(t,i){const s=null==i?void 0:i.toString().trim();s&&s!==(null==t?void 0:t.toString().trim())&&this.removeEntryIfOurs(s),this.pushToStore()}onValueChange(){this.pushToStore()}removeEntryIfOurs(t){t&&this.stores&&(this.storedName===t&&this.stores.scalingGroups.state[t]===this.storedValue&&this.stores.scalingGroups.set(t,void 0),this.storedName===t&&(this.storedName=void 0,this.storedValue=void 0))}pushToStore(){var t;if(!this.stores)return;const i=null===(t=this.name)||void 0===t?void 0:t.toString().trim(),s=at(i);if("auto"===s.kind)return void this.errors.addOrReplace({id:"ERR_reserved_name",type:"warning",message:'bn-scaling-group: name "auto" is reserved and cannot be used.'});if(this.errors.remove("ERR_reserved_name"),!i)return void this.errors.addOrReplace({id:"ERR_empty_name",type:"warning",message:"bn-scaling-group: name is required."});if(this.errors.remove("ERR_empty_name"),"number"===s.kind)return void this.errors.addOrReplace({id:"ERR_numeric_name",type:"warning",message:`bn-scaling-group: name "${i}" is not allowed — it would be ambiguous with a numeric scaling value.`});this.errors.remove("ERR_numeric_name");const e=at(this.value);if("number"!==e.kind)return void this.errors.addOrReplace({id:"ERR_invalid_value",type:"warning",message:`bn-scaling-group: invalid value "${this.value}" — must be a positive number, optionally with k/M/G/T suffix.`});this.errors.remove("ERR_invalid_value");const n=this.stores.scalingGroups.state[i];void 0===n||n===e.value||this.storedName===i&&this.storedValue===n?this.errors.remove("WARN_duplicate_group"):this.errors.addOrReplace({id:"WARN_duplicate_group",type:"warning",message:`bn-scaling-group: "${i}" is already registered with a different value (${tt(n)}); overwriting.`}),this.storedName&&this.storedName!==i&&this.removeEntryIfOurs(this.storedName),this.stores.scalingGroups.set(i,e.value),this.storedName=i,this.storedValue=e.value}render(){return i(s,{key:"7b125b03953f91d15c6c9df7ca178c9f33b054cc"})}get element(){return e(this)}static get watchers(){return{name:[{onNameChange:0}],value:[{onValueChange:0}]}}};var ns,rs,as,os,hs;es.style="bn-scaling-group{display:none}",function(t){t[t.ALL=-1]="ALL"}(ns||(ns={})),function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(rs||(rs={})),function(t){t.LIST="list",t.SUM="sum",t.SUMNOTOTAL="sumnototal",t.OPT="opt",t.OPTNOTOTAL="optnototal"}(as||(as={})),function(t){t.ASC="asc",t.DESC="desc"}(os||(os={})),function(t){t.HEADER="HEADER",t.GROUPHEAD="GROUPHEAD",t.SEPERATORLINE="SEPERATORLINE",t.SUM="SUM",t.GROUPSUM="GROUP_SUM",t.DRILLELEMENT="DRILLELEMENT",t.STANDARD="STANDARD",t.PARTELEMENT="PARTELEMENT",t.ENTRY="ENTRY"}(hs||(hs={}));const ls="none",cs="setname";function ds(t){return t===cs?"COALESCE([setname],[setName])":`normalizeDate([date], '${t}')`}function us(t){if(null==t)return"";if("string"==typeof t)return t.trim();const i=ps(t);return i?i.toISO():String(t)}function ps(t){if(null!=t){if("string"==typeof t){const i=g.fromISO(t);return i.isValid?i:void 0}if("number"==typeof t){const i=g.fromMillis(t);return i.isValid?i:void 0}if("boolean"==typeof t.isValid)return t.isValid?t:void 0}}const fs=class{validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("ERR_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"ERR_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("ERR_scale")}constructor(i){t(this,i),this.layoutObserver=null,this._lastScaledParentWidth=0,this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.hasBlankSetnames=!1,this.sumTitle="",this.filter="",this.measureUnit="",this.barColumnWidth="w10",this.unitScaling="100",this.percentageScaling="2",this.pixelPerUnitGroupMap=new Map,this.dataFormat="decimal",this.grouped="false",this.showMeasureScale="false",this.showGroupTitle="true",this.type="list",this.limit=0,this.thereof="[]",this.partof="[]",this.order="category",this.orderDirection="asc",this.measureType="volume",this.measureScale="greatest",this.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.categoryWidth="w15",this.columnthereof=null,this.interval="none",this.tableAttributes="",this._autoScaleGuard=!1,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=t=>{var i,s,e,n;this.lastAutoScalingReport={unit:null!==(i=t.unit)&&void 0!==i?i:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(e=t.percentage)&&void 0!==e?e:null===(n=this.lastAutoScalingReport)||void 0===n?void 0:n.percentage};const r=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t);if(void 0!==t.unit&&t.unit>0&&this.autoUnitWarningActive){const i=1/t.unit;r(i,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=i,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: invalid value "${this.unitScaling}" — auto-fitted to 1 em ≈ ${tt(i)} units.`}))}if(void 0!==t.percentage&&t.percentage>0&&this.autoPctWarningActive){const i=1/t.percentage;r(i,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=i,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: invalid value "${this.percentageScaling}" — auto-fitted to 1 em ≈ ${tt(i)} percentage points.`}))}},k(this),h(this),this.errors=l(this),ot(this),this.componentStyle=w(this),this.ruleSetConfig=ht(this),it(this,((t,i)=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1,this.hasBlankSetnames=Array.isArray(i)&&i.some((t=>{var i;return P(null!==(i=null==t?void 0:t.setname)&&void 0!==i?i:null==t?void 0:t.setName)}))}),((t,i)=>{this.datasetMeta=i})),this.t=st(this).t,this.resolveInherited=et(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}])}validateScenario(t){const i="ERR_scenarios";if(K(t))return void this.errors.remove(i);const s=y(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+(null==s?void 0:s.toString())+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances";if(K(t))return void this.errors.remove(i);const s=S(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateBarColumns(t){const i="ERR_barColumns";if(P(t))return void this.errors.remove(i);const s=D(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"barColumns: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateBarColumnWidth(t){const i="ERR_barColumnWidth";G(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"barColumnWidth: invalid value '"+t+"' is not supported."})}validateUnitScaling(t){const i="ERR_unitScaling";"invalid"===Q(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="ERR_percentageScaling";"invalid"===Q(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validateDataFormat(t){const i="ERR_dataFormat";W(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormat: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateGrouped(t){const i="ERR_grouped";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"grouped: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowMeasureScale(t){const i="ERR_grouped";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateShowGroupTitle(t){const i="ERR_showGroupTitle";x(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showGroupTitle: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateType(t){const i="ERR_type";F(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"type: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateLimit(t){const i="ERR_limit";M(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateThereOf(t){const i="ERR_thereof",s=I(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"ThereOf: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validatePartOf(t){const i="ERR_partof",s=Y(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"partof: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderList(t){const i="ERR_order";if(K(t))return void this.errors.remove(i);const s=O(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="ERR_orderDirection";K(t)||R(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasureType(t){const i="ERR_measureType";z(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureType: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasureScale(t){const i="ERR_measureScale";_(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDataFormatDigitsDecimal(t){const i="ERR_dataFormatDigitsDecimal";M(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsDecimal: invalid value(s) '"+t+"' are not supported."})}validateDateFormatDigitsPercent(t){const i="ERR_dataFormatDigitsPercent";M(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsPercent: invalid value(s) '"+t+"' are not supported."})}validateCategoryWidth(t){const i="ERR_categoryWidth";B(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"categoryWidth: invalid value(s) '"+t+"' are not supported."})}validateColumnThereOf(t){const i=H(t),s="ERR_categorythereof";i.length>0?this.errors.addOrReplace({id:s,type:"warning",message:"columnthereof: invalid value(s) '"+JSON.stringify(i)+"' are not supported."}):this.errors.remove(s)}validateInterval(t){const i="ERR_interval",s=null==t?void 0:t.trim().toLowerCase();P(t)||s===ls||s===cs||L(s)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"interval: invalid value '"+t+"' is not supported."})}validateTableAttributes(t){const i="ERR_attributes",s=V(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"attributes: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateDataFormat(this.dataFormat),this.validateGrouped(this.grouped),this.validateShowGroupTitle(this.showGroupTitle),this.validateType(this.type),this.validateLimit(this.limit),this.validateThereOf(this.thereof),this.validatePartOf(this.partof),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDateFormatDigitsPercent(this.dataFormatDigitsPercent),this.validateCategoryWidth(this.categoryWidth),this.validateMeasureType(this.measureType),this.validateMeasureScale(this.measureScale),this.validateColumnThereOf(this.columnthereof),this.validateInterval(this.interval),this.validateTableAttributes(this.tableAttributes),this.validateShowMeasureScale(this.showMeasureScale),this.validateBarColumns(this.barColumns),this.validateBarColumnWidth(this.barColumnWidth),this.validateUnitScaling(this.unitScaling),this.validatePercentageScaling(this.percentageScaling),this.validateScaling(this.scale)}componentDidLoad(){this.layoutObserver=lt(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=nt(this.element);t>0&&Math.abs(t-this._lastScaledParentWidth)>2&&(this._lastScaledParentWidth=t,r(this))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}componentDidRender(){const{mode:t}=rt(this.scale);if("auto"!==t&&"empty"!==t)return void(this._autoScaleGuard=!1);if(this._autoScaleGuard)return void(this._autoScaleGuard=!1);const i=this.element,{width:s}=nt(i);if(s<=0)return;this._lastScaledParentWidth=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollWidth,a=this.appliedScaleFactor;if(r<=s+1)return void this.errors.remove("AUTO_scale");const o=Math.max(.3,a*(s-1)/r);Math.abs(o-a)<.001||(i.style.setProperty("--bn-font-size",e*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled table by factor ${o.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,n((()=>{this.appliedScaleFactor=o})))}prepareDataFormat(){var t;return mt[null===(t=this.dataFormat)||void 0===t?void 0:t.toUpperCase()]}prepareGrouped(){return"true"===this.grouped}prepareShowGroupTitle(){return"true"===this.showGroupTitle}prepareTableType(){var t;return as[null===(t=this.type)||void 0===t?void 0:t.toUpperCase()]}prepareLimit(){return Math.floor(Number(this.limit)||0)}prepareThereOf(){return null==this.thereof||""===this.thereof.trim()?[]:JSON.parse(this.thereof)}preparePartOf(){return null==this.partof||""===this.partof.trim()?[]:JSON.parse(this.partof)}prepareOrder(){var t;const i=this.resolveInherited("order",this.order),s=this.resolveInherited("orderDirection",this.orderDirection),e=null!=i?i:this.order,n=null!=s?s:this.orderDirection,r="auto"===(null==e?void 0:e.trim().toLowerCase());let a=e;return r&&(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)&&(a=this.datasetMeta.suggestedOrder),{hierarchy:a.split(",").map((t=>_t[null==t?void 0:t.toUpperCase()])),direction:xt[null==n?void 0:n.toUpperCase()]}}prepareI18nMode(){return bt.META}prepareI18n(){const t=p,i=new Map(["in","category","operation","there_of","part_of","SUM_TOTAL","no-data","REST"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries()])}prepareDataFormatDigits(){return{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal}}prepareScenarios(){var t,i,s,e,n,r,a,o,h;const l=this.resolveInherited("scenarios",this.scenarios),c=this.resolveInherited("variances",this.variances);if(void 0!==l||void 0!==c){this.errors.remove("AUTO_scenarios");let i=[];return void 0!==l?i=i.concat(l.split(",")):P(this.scenarios)||(i=i.concat(this.scenarios.split(","))),void 0!==c?i=i.concat(c.split(",")):(null===(t=this.variances)||void 0===t?void 0:t.trim().length)>0&&(i=i.concat(this.variances.split(","))),i.map((t=>t.trim()))}const d="auto"===(null===(i=this.scenarios)||void 0===i?void 0:i.trim().toLowerCase());if((P(this.scenarios)||d)&&P(this.variances))return(null===(e=null===(s=this.datasetMeta)||void 0===s?void 0:s.availableScenarios)||void 0===e?void 0:e.length)>0?(d?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),this.datasetMeta.availableScenarios):[];let u=[];return d||P(this.scenarios)?(null===(r=null===(n=this.datasetMeta)||void 0===n?void 0:n.availableScenarios)||void 0===r?void 0:r.length)>0&&(d?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),u=u.concat(this.datasetMeta.availableScenarios)):(this.errors.remove("AUTO_scenarios"),u=u.concat(null===(a=this.scenarios)||void 0===a?void 0:a.split(","))),(null===(o=this.variances)||void 0===o?void 0:o.trim().length)>0&&(u=u.concat(null===(h=this.variances)||void 0===h?void 0:h.split(","))),u.map((t=>t.trim()))}prepareCategoryWidth(){var t;return P(this.categoryWidth)?wt.INF:wt[null===(t=this.categoryWidth)||void 0===t?void 0:t.toUpperCase()]}prepareMeasureScale(){return P(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareMeasureType(){var t;return P(this.measureType)?yt.VOLUME:yt[null===(t=this.measureType)||void 0===t?void 0:t.toUpperCase()]}prepareColumnThereOf(){if(null==this.columnthereof||""===this.columnthereof.trim())return new Map;const t=JSON.parse(this.columnthereof),i=new Map;for(const[s,e]of Object.entries(t))!1===i.has(e.scenario)&&i.set(e.scenario,[]),i.get(e.scenario).push(e);return i}prepareInterval(){var t;const i="ERR_intervalConflict",s="ERR_intervalNoDate",e="ERR_intervalSetname",n=P(this.interval)?ls:this.interval.trim().toLowerCase();return n!==ls&&n!==cs&&!L(n)||n===ls?(this.errors.remove(i),this.errors.remove(s),this.errors.remove(e),ls):null!=this.columnthereof&&""!==this.columnthereof.trim()?(this.errors.addOrReplace({id:i,type:"warning",message:"interval: cannot be combined with columnthereof, interval is ignored."}),this.errors.remove(s),this.errors.remove(e),ls):(this.errors.remove(i),n===cs?(this.hasBlankSetnames?this.errors.addOrReplace({id:e,type:"warning",message:"interval: rows with blank setname found, they are grouped under '—'."}):this.errors.remove(e),this.errors.remove(s),cs):(this.errors.remove(e),this.datasetMeta&&!(null===(t=this.datasetMeta.dateRange)||void 0===t?void 0:t.hasData)?(this.errors.addOrReplace({id:s,type:"warning",message:"interval: dataset has no date values, interval is ignored."}),ls):(this.errors.remove(s),n)))}prepareAttributes(){if(null==this.tableAttributes||""===this.tableAttributes.trim())return[];try{const t=JSON.parse(this.tableAttributes);return null===t||"object"!=typeof t||t instanceof Array?[]:Object.entries(t).map((([t,i],s)=>"string"==typeof i?j(t,`attr_${s}`,i):null)).filter((t=>null!==t))}catch(t){return[]}}prepareSumTitle(){return""===this.sumTitle||null==this.sumTitle?"SUM_TOTAL":this.sumTitle}prepareShowMeasureScale(){return"true"===this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareBarColumnWidth(){var t;const i=null===(t=this.barColumnWidth)||void 0===t?void 0:t.toUpperCase(),s=$t[i];return s?St[s]:St[$t.W10]}prepareBarColumns(){return P(this.barColumns)?[]:this.barColumns.split(",").map((t=>t.trim()))}prepareUnitScaling(){const t=Q(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,1/t.value):"auto"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: invalid value "${t.raw}" — auto-fitting to the bar column width.`}),0)}preparePercentageScaling(){const t=Q(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,1/t.value):"auto"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: invalid value "${t.raw}" — auto-fitting to the pin area.`}),0)}getDataStructure(){return{ITableDataRow:{setName:{type:"string",isOptional:!1,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}async getLayoutState(t){var i,s,e,n;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",a=Ct(this.element),o=this.getEffectiveScaleFactor(),h=Number.isFinite(o)&&o>0?o:1,l=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*h,c={version:Pt,tag:this.element.localName,id:At(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:Lt(this.element,a),em:{fontSizePx:l,appliedScaleFactor:h},regions:[],metadata:{},diagnostics:Tt(this.element),scaling:this.resolveScalingInfo(l)},d=null===(e=this.element.shadowRoot)||void 0===e?void 0:e.querySelector("ibcs-table");if(d){const t=null!==(n=d.scenarios)&&void 0!==n?n:[];if(c.metadata.scenarios=t.filter((t=>!t.startsWith("d"))),c.metadata.variances=t.filter((t=>t.startsWith("d"))),"function"==typeof d.getLayoutDetail){const t=await d.getLayoutDetail(a,r);c.regions=t.regions,c.metadata=Object.assign(Object.assign({},c.metadata),t.metadata),c.diagnostics=[...c.diagnostics,...t.diagnostics],t.elements&&(c.elements=t.elements),t.table&&(c.table=t.table)}}return c}resolveScalingInfo(t){var i,s;const e={},n=Q(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===n.kind)e.unitMode="fixed",e.unitsPerEm=n.value,e.unitPxPerUnit=t/n.value;else{e.unitMode="auto";const s=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==s&&s>0&&(e.unitsPerEm=1/s,e.unitPxPerUnit=s*t)}const r=Q(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)e.percentageMode="fixed",e.percentagePointsPerEm=r.value,e.percentagePxPerPoint=t/r.value;else{e.percentageMode="auto";const i=null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.percentage;void 0!==i&&i>0&&(e.percentagePointsPerEm=1/i,e.percentagePxPerPoint=i*t)}return e}getEffectiveScaleFactor(){const{mode:t,factor:i}=rt(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const a=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":a*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles(),e=this.getEffectiveScaleFactor();return i(s,{key:"0581f45b1d4af5a611e295afa924b3564ad4e916",style:t},i("div",{key:"461dfbb4bbaf75c3aa5df8aad21056dfb01be26c"},i("ibcs-table",{key:"c17a4104687aee9002144e2800b23b8c99c811a7",tableName:this.datasetName,dataVersion:this.dataVersion,sumTitle:this.prepareSumTitle(),scenarios:this.prepareScenarios(),scenariosDataFormat:this.prepareDataFormat(),grouped:this.prepareGrouped(),limit:this.prepareLimit(),showGroupTitle:this.prepareShowGroupTitle(),thereof:this.prepareThereOf(),partof:this.preparePartOf(),order:this.prepareOrder(),categorythereof:this.prepareColumnThereOf(),attributeColumns:this.prepareAttributes(),type:this.prepareTableType(),categoryWidth:this.prepareCategoryWidth(),dataFormatDigits:this.prepareDataFormatDigits(),i18n:this.prepareI18n(),i18nMode:this.prepareI18nMode(),measureScale:this.prepareMeasureScale(),measureType:this.prepareMeasureType(),measureUnit:this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(),filter:this.prepareFilter(),barColumns:this.prepareBarColumns(),interval:this.prepareInterval(),barColumnMaxWidth:this.prepareBarColumnWidth(),unitScaling:this.prepareUnitScaling(),percentageScaling:this.preparePercentageScaling(),reportAutoScaling:this.handleAutoScalingReport,scaleFactor:e,ruleSetConfig:this.ruleSetConfig(),selectedStyle:this.selectedStyle})))}get element(){return e(this)}static get watchers(){return{scale:[{validateScaling:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat:0}],grouped:[{validateGrouped:0}],showMeasureScale:[{validateShowMeasureScale:0}],showGroupTitle:[{validateShowGroupTitle:0}],type:[{validateType:0}],limit:[{validateLimit:0}],thereof:[{validateThereOf:0}],partof:[{validatePartOf:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],measureType:[{validateMeasureType:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDateFormatDigitsPercent:0}],categoryWidth:[{validateCategoryWidth:0}],columnthereof:[{validateColumnThereOf:0}],interval:[{validateInterval:0}],tableAttributes:[{validateTableAttributes:0}]}}};fs.style=":host{display:inline-block;position:relative;overflow:hidden}";const vs=class{constructor(i){t(this,i),this.businessUnit="",this.order="category",this.orderDirection="asc",this.dateFormat="none",this.dateLink="none",k(this),h(this),this.t=st(this).t,this.errors=l(this),this.componentStyle=w(this),this.ruleSetConfig=ht(this)}validateScenario(t){const i="ERR_scenarios",s=y(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+(null==s?void 0:s.toString())+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances",s=S(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+(null==s?void 0:s.toString())+"' are not supported."}):this.errors.remove(i)}validateOrder(t){const i=O(t),s="ERR_order";i.length>0?this.errors.addOrReplace({id:s,type:"warning",message:"order: invalid value(s) '"+(null==i?void 0:i.toString())+"' are not supported."}):this.errors.remove(s)}validateOrderDirection(t){const i="ERR_orderDirection";R(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasures(t){const i="ERR_measures",s=X(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"measures: invalid value(s) '"+(null==s?void 0:s.toString())+'\' are not supported. Valid format example: [{"name": "Bruttoumsatz", "unit": "mEUR"}]'}):this.errors.remove(i)}validateDateStart(t){const i="ERR_dateStart";J(t)||P(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateStart: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateEnd(t){const i="ERR_dateEnd";J(t)||P(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateStart: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateFormat(t){const i="ERR_dateFormat";L(t)||P(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateFormat: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateLink(t){const i="ERR_dateLink";q(t)||P(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateLink: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateMeasures(this.measures),this.validateDateStart(this.dateStart),this.validateDateEnd(this.dateEnd),this.validateDateFormat(this.dateFormat),this.validateDateLink(this.dateLink),this.validateOrderDirection(this.orderDirection),this.validateOrder(this.order)}prepareI18n(){const t=p,i=new Map(["SEPERATOR_WS","in","CONNECTOR_WS"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries()])}prepareI18nMode(){return bt.META}prepareLocale(){return d(this.element).context.state.locale||"de"}prepareTitleOrder(){var t;return P(this.order)||P(this.orderDirection)?null:{hierarchy:this.order.split(",").map((t=>t.trim())),direction:xt[null===(t=this.orderDirection)||void 0===t?void 0:t.toUpperCase()]}}prepareTitleTimePeriod(){var t,i;return P(this.dateStart)&&P(this.dateEnd)||P(this.dateLink)?null:{start:g.fromISO(this.dateStart),end:g.fromISO(this.dateEnd),format:C[null===(t=this.dateFormat)||void 0===t?void 0:t.toUpperCase()],link:Z[null===(i=this.dateLink)||void 0===i?void 0:i.toUpperCase()]}}prepareMeasures(){return P(this.measures)?[]:JSON.parse(this.measures)}prepareScenarios(){var t,i,s,e;if(P(this.scenarios)&&P(this.variances))return[];let n=[];return(null===(t=this.scenarios)||void 0===t?void 0:t.trim().length)>0&&(n=n.concat(null===(i=this.scenarios)||void 0===i?void 0:i.split(","))),(null===(s=this.variances)||void 0===s?void 0:s.trim().length)>0&&(n=n.concat(null===(e=this.variances)||void 0===e?void 0:e.split(","))),n.map((t=>t.trim()))}prepareBusinessUnit(){return P(this.businessUnit)||"null"===this.businessUnit?null:this.businessUnit}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles();return i(s,{key:"9b9c216010209bd5acaaeee39b6b5d8a8972710f",style:t},i("ibcs-title",{key:"5ccf7ddc7a4fbf1308d1d09d80f5b8aa3cbf6cbd",businessUnit:this.prepareBusinessUnit(),scenarios:this.prepareScenarios(),measures:this.prepareMeasures(),timeperiod:this.prepareTitleTimePeriod(),order:this.prepareTitleOrder(),i18n:this.prepareI18n(),"i18n-mode":this.prepareI18nMode(),locale:this.prepareLocale(),ruleSetConfig:this.ruleSetConfig()}))}get element(){return e(this)}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],measures:[{validateMeasures:0}],dateStart:[{validateDateStart:0}],dateEnd:[{validateDateEnd:0}],dateFormat:[{validateDateFormat:0}],dateLink:[{validateDateLink:0}]}}};vs.style=':host{padding:0.5em;margin-bottom:0.5em;box-sizing:border-box;-webkit-box-sizing:border-box;width:100%;display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}';let gs=class{constructor(t,i,s,e,n,r,a,o,h=!1){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=e,this.leftSideLengthSync=n,this.topSideLabelHeight=r>0?this.fontSize:0,this.hasStackedHeaders=h,this.leftSideLabelLength=this.calculateSideLabelLength(r,a,o),this.calculateSpacings(),this.calculateCategoryPosition(),this.calculateAxisPosition()}getBarPositionX(){return this.axisPosition.x}getBarCenterPositionY(t){return this.categoryPosition.y+this.spacings.scenarioOffset+t*this.spacings.categoryWidth}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.spacings.barWidth-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,e){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<e/2&&(this.axisPosition.x=e/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(){return this.getAxisPositionY()+(this.numberOfColumns+.5)*this.spacings.categoryWidth}getScenarioLabelPositionOffsetY(t){if(t){const t=.5*this.getBarWidth()+this.spacings.scenarioLabelToBar;return 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 e=t/2;let n=i;return e>n&&(n=e),s>n&&(n=s),n}},ms=class{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}},bs=class{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}},ws=class{constructor(t){this.container=new Wt,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 ys,Ss,$s;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(ys||(ys={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(Ss||(Ss={})),function(t){t[t.Y=1e24]="Y",t[t.Z=1e21]="Z",t[t.E=1e18]="E",t[t.P=1e15]="P",t[t.T=1e12]="T",t[t.G=1e9]="G",t[t.M=1e6]="M",t[t.k=1e3]="k",t[t.h=100]="h",t[t.da=10]="da",t[t.d=.1]="d",t[t.c=.01]="c",t[t.m=.001]="m",t[t.my=1e-6]="my",t[t.n=1e-9]="n",t[t.p=1e-12]="p",t[t.f=1e-15]="f",t[t.a=1e-18]="a",t[t.z=1e-21]="z",t[t.y=1e-24]="y"}($s||($s={}));class Os{static calculateMeasureScale(t,i,s,e){var n,r;if("_"===e)return new Jt;if("μ"===e&&(e="my"),null!=e&&[...this.unitsLeast,...this.unitsGreat].includes(e))return this.lookupPrefix(e);if(0===s.length||!i)return new Jt;const a=`SELECT MAX(GREATEST(${s.filter((t=>3===t.length)).map((t=>"ABS("+t+")")).toString()})) as prefixvalue\n FROM ${i}`,o=`SELECT MIN(LEAST(${s.filter((t=>3===t.length)).map((t=>"ABS("+t+")")).toString()})) as prefixvalue\n FROM ${i}`;let h,l=a;"LEAST"===(null==e?void 0:e.toUpperCase())&&(l=o);try{h=null!==(r=null===(n=t.exec(l)[0])||void 0===n?void 0:n.prefixvalue)&&void 0!==r?r:0}catch(t){return console.error("DataAnalyzer: measure-scale query failed",l,t),new Jt}return this.determinePrefix(Math.abs(h))}static determinePrefix(t){if(!Number.isFinite(t)||t<=0)return new Jt;if(t>=1e3){const i=Math.min(Math.floor(Math.log10(t)/3),this.unitsGreat.length)-1;return new Jt(this.unitsGreat[i],Math.pow(1e3,i+1))}if(t<=.001){const i=Math.min(-Math.floor(Math.log10(t)/3),this.unitsLeast.length)-1;return new Jt(this.unitsLeast[i],Math.pow(1e3,-(i+1)))}return new Jt}static lookupPrefix(t){return new Jt(t,$s[t])}}Os.unitsGreat=["k","M","G","T","P","E","Z","Y"],Os.unitsLeast=["m","my","n","p","f","a","z","y"];class Rs{adapt(t){return Et.adaptDefaultString(t)}default(){return""}}class Ms{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 kt(new Rs).default(),this.level=dt.CATEGORY,this.filter="",this.measureScale=new Jt,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.stackConfig=null}}class xs{constructor(t,i,s,e,n,r){this.dataRowAdapter=t,this.orderAdapter=i,this.stringAdapter=s,this.dataFormatDigitsAdapter=e,this.db=n,this.fromExpr=r}adapt(t){const i=Et.adaptArray(t.data,this.dataRowAdapter),s=Et.adaptArray(t.scenarios,this.stringAdapter),e=new Ms(i,s);return Ot.isArray(t.variances)&&(e.variances=Et.adaptArray(t.variances,this.stringAdapter)),Ot.isString(t.title)&&(e.title=t.title),Ot.isBoolean(t.hideCategories)&&(e.hideCategories=t.hideCategories),Ot.isNumber(t.pixelPerUnit)&&(e.pixelPerUnit=t.pixelPerUnit),Ot.isNumber(t.pixelPerPercentage)&&(e.pixelPerPercentage=t.pixelPerPercentage),Ot.isNumber(t.limit)&&(e.limit=t.limit),Ot.isExisting(t.sortOrder)&&(e.sortOrder=this.orderAdapter.adapt(t.sortOrder)),Ot.isExisting(t.level)&&(e.level=t.level),Ot.isString(t.filter)&&(e.filter=t.filter.trim()),Ot.isExisting(t.measureScale)&&(e.measureScale=Os.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale)),Ot.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),Ot.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),Ot.isExisting(t.dataFormatDigits)&&(e.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),Ot.isExisting(t.stackConfig)&&(e.stackConfig=t.stackConfig),e}default(){return new Ms([],[])}}let _s=class{constructor(t,i,s,e){this.value=t,this.scenario=i,this.pixelPerUnit=s||1,this.variance="neg"===e||e===Cs.NEG?Cs.NEG:"pos"===e||e===Cs.POS?Cs.POS:Cs.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:Cs.NEU===this.variance?Cs.NEU:Cs.POS===this.variance?Cs.NEG:Cs.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 Es{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 ks{constructor(){}adapt(t){const i=new Es;return Ot.isOperator(t.operation)&&(i.operation=t.operation),Ot.isNumber(t.rowGroupIndex)&&Ot.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),Ot.isNumber(t.categoryIndex)&&Ot.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),Ot.isNumber(t.subCategoryIndex)&&Ot.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),Ot.isNumber(t.columnGroupIndex)&&Ot.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),Ot.isNumber(t.columnSubGroupIndex)&&Ot.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 Es}setActualValues(t,i){Ot.isNumber(t.ac1)&&(i.ac1=t.ac1),Ot.isNumber(t.ac2)&&(i.ac2=t.ac2),Ot.isNumber(t.ac3)&&(i.ac3=t.ac3),Ot.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){Ot.isNumber(t.pl1)&&(i.pl1=t.pl1),Ot.isNumber(t.pl2)&&(i.pl2=t.pl2),Ot.isNumber(t.pl3)&&(i.pl3=t.pl3),Ot.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){Ot.isNumber(t.pp1)&&(i.pp1=t.pp1),Ot.isNumber(t.pp2)&&(i.pp2=t.pp2),Ot.isNumber(t.pp3)&&(i.pp3=t.pp3),Ot.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){Ot.isNumber(t.fc1)&&(i.fc1=t.fc1),Ot.isNumber(t.fc2)&&(i.fc2=t.fc2),Ot.isNumber(t.fc3)&&(i.fc3=t.fc3),Ot.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class Ps{constructor(t,i,s,e,n,r){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=e,this.varianceStyles=n,this.padding=r,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"]}}class Ts{constructor(t,i,s,e,n){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=e,this.paddingadapter=n}adapt(t){const i=new Ps(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return Ot.isExisting(t)&&(Ot.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),Ot.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),Ot.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),Ot.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),Ot.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),Ot.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 bs(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new Ps(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}class Ls{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 As{adapt(t){const i=new Ls;return Ot.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),Ot.isNumber(t.scenarioLabelToBar)&&(i.scenarioLabelToBar=t.scenarioLabelToBar),Ot.isNumber(t.labelToBar)&&(i.labelToBar=t.labelToBar),Ot.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),Ot.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),Ot.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),Ot.isNumber(t.barWidth)&&(i.barWidth=t.barWidth),Ot.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),Ot.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),Ot.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),Ot.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),Ot.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),Ot.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),Ot.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),Ot.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new Ls}}var Cs,Ns,Us;!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"}(Cs||(Cs={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(Ns||(Ns={})),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"}(Us||(Us={}));class Ds{constructor(t,i,s,e,n,r,a,o){this.group=null,this.segmentFillColor=null,this.maxWidth=null,this.ID_SCENARIOLABEL="Label",this.CSS_CATEGORIES="categories",this.x=i,this.y=s,this.value=n,null!=t&&(this.group=t.group().id(this.createElementID(t.toString(),e))),this.styles=r,this.isVarianceLabel=!1,this.isRelativeLabel=!1,this.verticalHookLocation=a||Us.Top,this.horizontalHookLocation=o||Us.Left}setToVarianceLabel(){return this.isVarianceLabel=!0,this}setToRelativeVarianceLabel(){return this.isVarianceLabel=!0,this.isRelativeLabel=!0,this}setSegmentFill(t){return this.segmentFillColor=t,this}setMaxWidth(t){return this.maxWidth=t,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 Jt){var s;if(this.isEmpty())return this;const e=this.group;let n;const r=this.styles.fontStyles.background||"#ffffff";let a="",o="start";if(!1===Number.isNaN(Number(this.value))){let s=t.percent,e=t.percent,r=1,h="percent";!1===this.isRelativeLabel&&(s=t.decimal,e=t.decimal,r=i.value,h="decimal"),n=Gt.number(Number(this.value),h,s,e,r),Number(this.value)<0&&(o="end"),this.isVarianceLabel&&Number(this.value)>=0&&(a="+")}else n=""+this.value,o="start";const h=e.text(a+n);h.move(this.x,this.y);const l=h.bbox(),c=l.w,d=l.h;return null!=this.maxWidth&&c>this.maxWidth?(null===(s=this.group)||void 0===s||s.remove(),this.group=null,this):(this.horizontalHookLocation===Us.Right?(o="end",h.move(h.x()-h.length(),h.y())):this.horizontalHookLocation===Us.Center&&(o="middle",h.move(h.x()-h.length()/2,h.y())),this.verticalHookLocation===Us.Center?h.move(h.x(),h.y()-d/2):this.verticalHookLocation===Us.Bottom&&h.move(h.x(),h.y()-d),h.font({anchor:o}),null!=this.segmentFillColor?h.fill(qt(this.segmentFillColor)):null==e||e.rect(c,.9*d).stroke(r).fill(r).opacity(.7).move(h.x(),h.y()+.1*d).insertBefore(h),this)}isEmpty(){return null==this.value||""===this.value}setPos(t,i){return this.x=t,this.y=i,this}}let Gs=class{constructor(t,i,s,e){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=e,this.label=new Ds(s,this.position.getAxisTitlePositionX(),this.position.getAxisTitlePositionY(),this.ID_AXIS_TITLE,this.labelText,this.style,Us.Bottom,Us.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 Ws{constructor(t,i,s,e,n,r,a,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=e,this.isPrimaryBar=n,this.position=t,this.barStyles=i.barStyles,this.overflowConfig=o,this.scenarioGroup=r,this.styles=i,null!=r&&(this.barGroup=r.group().id(r.toString()+"_"+this.ID_RECT)),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0;let i=Us.Left;s.value<0&&(i=Us.Right),this.dimensions=this.createDimensions(t,s,e,n),this.label=new Ds(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,Us.Center,i),this.scenarioLabel=this.getScenarioLabel(a)}}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}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 Jt){if(this.isEmpty()||null==this.dataPoint.getScenario())return this;let s=this.barStyles.getSVGStyle(this.dataPoint.getScenario());this.isVarianceBar&&(s=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()));const e=this.convertToSVGStyle(s,"stroke");let n=this.convertToSVGStyle(s,"fill");const r=this.barStyles.getSVGStyle(this.dataPoint.getScenario()).fillpattern;if(null!=r){const t=this.styles.pattern.get(r);null!=t&&(n=t.pattern)}null!=this.barGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(n,e):this.barGroup.rect(this.dimensions.barLength,this.position.getBarWidth()).fill(n).stroke(e).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(),e=this.position.getBarWidth(),n=this.dimensions.barLength,{breakGap:r}=this.overflowConfig;this.dataPoint.getScaledUnit()<0?(this.barGroup.rect(n,e).fill(t).stroke(i).x(s-n).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,e).fill(t).stroke(i).x(s-n-r-this.overdriveWidth).cy(this.dimensions.yPos),this.drawBreakIndicator(s-n-r,r)):(this.barGroup.rect(n,e).fill(t).stroke(i).x(s).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,e).fill(t).stroke(i).x(s+n+r).cy(this.dimensions.yPos),this.drawBreakIndicator(s+n,r))}drawBreakIndicator(t,i){if(!this.barGroup)return;const s=this.position.getBarWidth(),e=this.dimensions.yPos-s/2,n=t+i/2,r=.35*i,a=s/3;let o=`M ${n-r} ${e}`;for(let t=0;t<3;t++)o+=` L ${n-r-.3*i} ${e+a*(t+.5)} L ${n-r} ${e+a*(t+1)}`;let h=`M ${n+r} ${e}`;for(let t=0;t<3;t++)h+=` L ${n+r+.3*i} ${e+a*(t+.5)} L ${n+r} ${e+a*(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(h).fill("none").stroke({color:"#000000",width:1})}createDimensions(t,i,s,e){const n=i.getScaledUnit(),r=Math.abs(n);if(this.overflowConfig&&r>0){const a="ac"===i.getScenario()?this.overflowConfig.cutWidth:this.overflowConfig.cutWidth-this.overflowConfig.scenarioCutOffset;if(r>a){this.isOverflowing=!0;const{breakGap:i,overdriveZoneWidth:o,maxOverflow:h}=this.overflowConfig;this.overdriveWidth=h>0?(r-a)/h*o:0;const l=a+i+this.overdriveWidth;return n<0?{clipped:!1,barLength:a,xPos:t.getBarPositionX()-a,yPos:t.getBarPositionY(s,e),labelXPos:t.getLabelPositionX(-l),scenarioLabelXPos:t.getBarPositionX()-.5*a,scenarioLabelYPos:t.getBarPositionY(s,e)+t.getScenarioLabelPositionOffsetY(e)}:{clipped:!1,barLength:a,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,e),labelXPos:t.getLabelPositionX(l),scenarioLabelXPos:t.getBarPositionX()+.5*a,scenarioLabelYPos:t.getBarPositionY(s,e)+t.getScenarioLabelPositionOffsetY(e)}}}return n<0?{clipped:!1,barLength:r,xPos:t.getBarPositionX()+n,yPos:t.getBarPositionY(s,e),labelXPos:this.position.getLabelPositionX(n),scenarioLabelXPos:this.position.getBarPositionX()-.5*r,scenarioLabelYPos:this.position.getBarPositionY(s,e)+this.position.getScenarioLabelPositionOffsetY(e)}:{clipped:!1,barLength:n,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,e),labelXPos:this.position.getLabelPositionX(n),scenarioLabelXPos:this.position.getBarPositionX()+.5*r,scenarioLabelYPos:this.position.getBarPositionY(s,e)+this.position.getScenarioLabelPositionOffsetY(e)}}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.isVarianceBar||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw()}drawBarDataLabel(t,i=new Jt){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){return new Ds(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,this.isPrimaryBar?Us.Top:Us.Bottom,Us.Center)}}let Fs=class{constructor(t,i,s,e,n,r,a,o,h){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=n,this.barStyles=n?n.barStyles:null,this.scenario=e,!0!==(null==r?void 0:r.isEmpty())&&(this.hasData=!0,this.dimensions=this.createMarkerDimensions(r,a,h),this.scenarioLabel=this.getScenarioLabel(o,n,h))}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 Ds(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,s?Us.Bottom:Us.Top,Us.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.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),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)}},Is=class{constructor(t,i,s,e,n){if(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=e,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=n,this.styles=i,this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0,this.dimensions=this.createDimensions(t,s,e);let i=Us.Left;s.value<0&&(i=Us.Right),this.label=new Ds(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,Us.Center,i),this.label.setToRelativeVarianceLabel()}}updateLabelGroup(t){var i;return this.isEmpty()||null==t||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(){var t;if(this.isEmpty())return this;if(null==this.dimensions)return this;const i=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()),s=i.stroke;let e=i.fill;const n=this.barStyles[this.dataPoint.getScenario()];if(null!=n&&n.fillpattern){const t=this.styles.pattern.get(n.fillpattern);null!=t&&null!=t.pattern&&(e=t.pattern)}this.drawNeedleHead(e,s),this.barGroup.rect(this.dimensions.barLength,this.position.getNeedleWidth()).fill(e).stroke(s).cy(this.dimensions.yPos).x(this.dimensions.xPos),null===(t=this.label)||void 0===t||t.draw()}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,e=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(e)}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 Ys{constructor(t,i,s,e,n,r,a,o,h,l,c){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=e,this.baselineValue=n,this.segmentIndex=a,this.stackMode=o,this.totalValue=h,this.group=c,this.barGroup=c.group().id(`stacked_bar_${e}_seg_${a}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new Jt){if(!this.hasData||null==this.dataPoint.value)return;const s=this.dataPoint.value,e=this.dataPoint.pixelPerUnit,n=this.position.getBarPositionX(),r=this.position.getBarWidth();let a,o;if(this.stackMode===ft.RELATIVE){const t=e;a=(0!==this.totalValue?Math.abs(s)/Math.abs(this.totalValue):0)*t,o=n+this.baselineValue/Math.abs(this.totalValue)*t}else a=Math.abs(s*e),o=n+this.baselineValue*e;const h=this.position.getBarPositionY(this.index,!0),l=this.styles.stackColors,c=l[this.segmentIndex%l.length],d={color:c},u={color:c,width:.5};this.barGroup.rect(Math.max(a,.5),r).fill(d).stroke(u).cy(h).x(o);const p=a-6;if(p>0){const e=o+a/2;if(this.stackMode===ft.RELATIVE||this.stackMode===ft.ABSOLUTE_RELATIVE){const i=(0!==this.totalValue?s/this.totalValue*100:0).toFixed(t.percent)+"%";new Ds(this.group,e,h,"STACK_SEG",i,this.styles,Us.Center,Us.Center).setSegmentFill(c).setMaxWidth(p).draw()}else new Ds(this.group,e,h,"STACK_SEG",s,this.styles,Us.Center,Us.Center).setSegmentFill(c).setMaxWidth(p).draw(t,i)}}drawTotalLabel(t={percent:2,decimal:1},i=new Jt){if(this.stackMode===ft.RELATIVE)return;const s=this.position.getBarPositionX()+this.totalValue*this.dataPoint.pixelPerUnit+this.position.spacings.labelToBar,e=this.position.getBarPositionY(this.index,!0);new Ds(this.group,s,e,"STACK_TOTAL",this.totalValue,this.styles,Us.Center,Us.Left).draw(t,i)}}let zs=class{constructor(t,i,s,e,n){this.overflowConfig=null,this.i18n=n;const r=i.group().id("Scenario1"),a=i.group().id("Scenario2").insertBefore(r);this.svgGroups={parent:i,scenario1:r,scenario2:a,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=e}setOverflowConfig(t){this.overflowConfig=t}isLastDataPoint(t){return this.elementCnt-1===t}isFirsttDataPoint(t){return 0===t}createPrimaryBar(t,i){var s,e,n,r;const a=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===e?void 0:e.group().id(""+i),o=null===(r=null===(n=this.svgGroups)||void 0===n?void 0:n.scenario1Label)||void 0===r?void 0:r.group().id(""+i);let h=null;return this.isLastDataPoint(i)&&(h=`${this.i18n.get(t.scenario)||t.scenario}`),new Ws(this.position,this.styles,t,i,!0,a,h,this.overflowConfig).updateLabelGroup(o)}createVarianceBar(t,i){var s,e,n,r;const a=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===e?void 0:e.group().id(""+i),o=null===(r=null===(n=this.svgGroups)||void 0===n?void 0:n.scenario1Label)||void 0===r?void 0:r.group().id(""+i);let h=null;return this.isLastDataPoint(i)&&(h=`${this.i18n.get(t.scenario)||t.scenario}`),new Ws(this.position,this.styles,t,i,!0,a,h,this.overflowConfig).updateLabelGroup(o).setAsVariance()}createRelativeVarianceBar(t,i){var s,e,n,r;const a=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===e?void 0:e.group().id(""+i),o=null===(r=null===(n=this.svgGroups)||void 0===n?void 0:n.scenario1Label)||void 0===r?void 0:r.group().id(""+i);return new Is(this.position,this.styles,t,i,a).updateLabelGroup(o)}createSecondaryBar(t,i){var s,e;const n=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario2)||void 0===e?void 0:e.group().id(""+i);let r=null;return this.isFirsttDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new Ws(this.position,this.styles,t,i,!1,n,r,this.overflowConfig)}createPrimaryMarker(t,i){var s,e;const n=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario3)||void 0===e?void 0:e.group().id(""+i),r=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 a=null;return this.isFirstDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new Fs(this.position,n,r,t.scenario,this.styles,t,i,a,!0)}createSecondaryMarker(t,i){var s,e;const n=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario4)||void 0===e?void 0:e.group().id(""+i),r=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 a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new Fs(this.position,n,r,t.scenario,this.styles,t,i,a,!1)}isFirstDataPoint(t){return 0===t}};const Bs=.001;function Hs(t){return null!=t.fixedDomain?Math.max(0,t.fixedDomain):t.relativeVariance?0:Math.max(0,t.maxPositive)+Math.abs(Math.min(0,t.minNegative))}function Vs(t){var i;if(!t.relativeVariance)return 0;const s=null!==(i=t.sideClamp)&&void 0!==i?i:1.45;return Math.min(s,Math.max(0,t.maxPositive))+Math.min(s,Math.abs(Math.min(0,t.minNegative)))}function js(t){const i=t.unitExtent+t.pctExtent;if(i<=0)return{};const s=Math.max(Bs,(t.target-(t.measured-t.unitExtent*t.currentPpu-t.pctExtent*t.currentPpp))/i);return{ppu:t.unitExtent>0?s:void 0,ppp:t.pctExtent>0?s:void 0}}class Xs{constructor(t,i,s,e,n){this.dataModel=[],this.variancesDataModel=[],this.title="",this.configTitle="",this.configVariances=[],this.smallestDataPointValue=new _s(0,Cs.AC1,1,Cs.NEU),this.highestDataPointValue=new _s(0,Cs.AC1,1,Cs.NEU),this.smallestVarianceDataPointValue=new _s(0,Cs.AC1,1,Cs.NEU),this.highestVarianceDataPointValue=new _s(0,Cs.AC1,1,Cs.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.hideCategories=!1,this.axisScenario=Cs.AC1,this.CSS_CATEGORIES="categories",this.state=ys.DIRTY,this.titleLength=0,this.leftSideOffsetForHorizontalSync=0,this.limit=0,this.measureScale=new Jt,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.scenarioPropOrder=[],this.overflowConfig=null,this.highestStackedTotal=0,this.fromExpr="",this.rowCount=0,this.db=i,this.tableName=s,this.ruleSet=t||new Ft,this.i18n=this.createI18n(new Map),this.styles=n,this.setConfig(e),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 gs(new ms(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)}setStyles(t){this.styles=t}setRuleSet(t){this.ruleSet=t||new Ft}setConfig(t){var i;this.state=ys.DIRTY,this.scenarioPropOrder=[...t.scenarios];const s=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.dataModel=this.populateModel(s,t.level,t.sortOrder),t.stackConfig&&t.stackConfig.by!==ut.SCENARIOS&&this.populateDimensionStackSegments(s,t.stackConfig,t.level),this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.configTitle=t.title,this.configVariances=null!==(i=null==t?void 0:t.variances)&&void 0!==i?i:[],this.updateTitle(),this.smallestDataPointValue=this.findSmallestDataPointValue(this.dataModel),this.smallestVarianceDataPointValue=this.findSmallestDataPointValue(this.variancesDataModel),this.highestDataPointValue=this.findHighestDataPointValue(this.dataModel),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.highestStackedTotal=this.findHighestStackedRowTotal(this.dataModel),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||Gt.translateScenarioLabel(null===(t=this.configVariances)||void 0===t?void 0:t.toString(),this.i18n)}createI18n(t){this.state=ys.DIRTY;const i=new Map([["SEPERATOR_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"," "],["there_of","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=ys.DIRTY,!this.tableName)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=m(this.tableName,t);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}}getUnitBarExtent(){var t,i;const s=null!=this.stackConfig&&this.highestStackedTotal>0,e=this.getVarianceType(),n=e!==Ss.NONE,r=n?this.highestVarianceDataPointValue:this.highestDataPointValue,a=n?this.smallestVarianceDataPointValue:this.smallestDataPointValue;return Hs({fixedDomain:s?this.stackConfig.mode===ft.RELATIVE?1:this.highestStackedTotal:void 0,relativeVariance:e===Ss.RELATIVE,maxPositive:null!==(t=null==r?void 0:r.value)&&void 0!==t?t:0,minNegative:null!==(i=null==a?void 0:a.value)&&void 0!==i?i:0})}getPercentBarExtent(){var t,i,s,e;return Vs({relativeVariance:this.getVarianceType()===Ss.RELATIVE,maxPositive:null!==(i=null===(t=this.highestVarianceDataPointValue)||void 0===t?void 0:t.value)&&void 0!==i?i:0,minNegative:null!==(e=null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&void 0!==e?e: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.styles.padding.bottom}patternToString(){return"<svg></svg>"}layout(){this.draw(new Wt)}toString(){const t=new Wt;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===ys.DIRTY&&(this.state=ys.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)):(this.drawScenarios(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t))}setPattern(t,i){this.styles.pattern.set(t,i)}calculateTitleLength(t){const i=It(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?" ":Gt.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}setAxisScenario(t){let i=Cs.AC1;if(null!=t&&t.length>0){const s=new Yt(t.toString());s.isValid&&(i=s.delta)}return null===i&&(i=Cs.AC1),i}populateModel(t,i,s){if(0===this.rowCount||!this.fromExpr)return[];const e=[],n=this.createOrderStr(i,s),r=this.createSelectString(i,s),a=this.createGroupByStr(i,s);let o;try{o=this.db.exec(`SELECT ${r} ${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 ${a}\n ORDER BY ${n}`)}catch(t){return console.error("StructureChart: populateModel query failed",t),[]}return this.detectNaNCells(t,o),this.createDataRows(o,e,t),this.crateRESTRow(o,t,e),e}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new Yt(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(0===this.limit||this.limit>t.length)return;const e=[],n=t.slice(this.limit,t.length);this.createDataRows(n,e,i);const r=e.reduce((function(t,s){return{id:t.id,category:t.category,type:t.type,scenario1:new _s(t.scenario1.value+s.scenario1.value,i[0],t.scenario1.pixelPerUnit,Cs.NEU),scenario2:new _s(t.scenario2.value+s.scenario2.value,i[1],t.scenario2.pixelPerUnit,Cs.NEU),scenario3:new _s(t.scenario3.value+s.scenario3.value,i[2],t.scenario3.pixelPerUnit,Cs.NEU),scenario4:new _s(t.scenario4.value+s.scenario4.value,i[3],t.scenario4.pixelPerUnit,Cs.NEU)}}),{id:9999,category:"REST",type:Ss.NONE,scenario1:new _s(0,i[0],this.pixelPerUnit,Cs.NEU),scenario2:new _s(0,i[1],this.pixelPerUnit,Cs.NEU),scenario3:new _s(0,i[2],this.pixelPerUnit,Cs.NEU),scenario4:new _s(0,i[3],this.pixelPerUnit,Cs.NEU)});s.push(r)}createDataRows(t,i,s){let e=t;this.limit>0&&(e=t.slice(0,this.limit)),e.forEach(((t,e)=>{i.push({id:e,category:t.category,type:Ss.NONE,scenario1:new _s(t[s[0]],s[0],this.pixelPerUnit,Cs.NEU),scenario2:new _s(t[s[1]],s[1],this.pixelPerUnit,Cs.NEU),scenario3:new _s(t[s[2]],s[2],this.pixelPerUnit,Cs.NEU),scenario4:new _s(t[s[3]],s[3],this.pixelPerUnit,Cs.NEU)})}))}createOrderStr(t,i){let s=`${t.toLowerCase()}`;return i.hierarchy.length>=1&&(s=`${i.hierarchy.toString()} ${null==i?void 0:i.direction}`),s}createSelectString(t,i){return t===dt.CATEGORY&&i.hierarchy.includes(_t.CATEGORYINDEX)?`${_t.CATEGORYINDEX}, ${dt.CATEGORY} as category`:t===dt.ROWGROUP&&i.hierarchy.includes(_t.ROWGROUPINDEX)?`${_t.ROWGROUPINDEX}, ${dt.ROWGROUP} as category`:t===dt.SUBCATEGORY&&i.hierarchy.includes(_t.SUBCATEGORYINDEX)?`${_t.SUBCATEGORYINDEX}, ${dt.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===dt.CATEGORY&&i.hierarchy.includes(_t.CATEGORYINDEX)?`${_t.CATEGORYINDEX}, ${dt.CATEGORY}`:t===dt.ROWGROUP&&i.hierarchy.includes(_t.ROWGROUPINDEX)?`${_t.ROWGROUPINDEX}, ${dt.ROWGROUP}`:t===dt.SUBCATEGORY&&i.hierarchy.includes(_t.SUBCATEGORYINDEX)?`${_t.SUBCATEGORYINDEX}, ${dt.SUBCATEGORY}`:`${t.toString()}`}calculateCategoryWidth(){if(this.hideCategories)return 5;let t=0;for(const i of this.dataModel){const s=It(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 _s(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 _s(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}findHighestStackedRowTotal(t){if(!this.stackConfig||0===t.length)return 0;const i=this.stackConfig.by===ut.SCENARIOS;let s=0;for(const e of t){let t=0;if(i){const i=["scenario1","scenario2","scenario3","scenario4"],s=[];for(const t of i){const i=e[t];i&&!i.isEmpty()&&null!=i.value&&s.push({value:i.value,scenario:i.scenario})}if(new Set(s.map((t=>Zt(t.scenario)))).size>1){const i=new Map;for(const t of s){const s=Zt(t.scenario);i.set(s,(i.get(s)||0)+Math.abs(t.value))}t=Math.max(...i.values())}else t=s.reduce(((t,i)=>t+Math.abs(i.value)),0)}else e.stackSegments&&e.stackSegments.length>0&&(t=e.stackSegments.reduce(((t,i)=>t+Math.abs(i.value)),0));t>s&&(s=t)}return s}populateVarianceModel(t,i){const s=[];if(0===t.length)return s;let e=null;null!=i&&i.length>0&&(e=i[0]);for(const n in t){const r=new Yt(t[n]);if(r.isValid){const t=this.mapScenarios(r,e),n=r.direction;let a=this.pixelPerUnit;"dr"===r.type&&(a=this.pixelPerPercentage);for(const e in i)s.push({id:Number(e),category:i[e].category,type:"dr"===r.type?Ss.RELATIVE:Ss.ABSOLUTE,scenario1:new _s(this.calculateVariance(r,i[e],t),r.base,a,n),scenario2:new _s(null,null,null,null),scenario3:new _s(null,null,null,null),scenario4:new _s(null,null,null,null)})}}return s}calculateVariance(t,i,s){const e=s.get(t.base),n=s.get(t.delta);return null==e||null==n?null:t.type===Ss.RELATIVE?(i[e].value-i[n].value)/i[n].value:i[e].value-i[n].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((e=>{i[e].scenario===t.delta?s.set(t.delta,e):i[e].scenario===t.base&&s.set(t.base,e)})),s}calculateTextBoxWidth(t){return It(Gt.number(t,"decimal",1,0),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width}calculatePercentageTextBoxWidth(t){let i=0;return t>=0&&(i+=It("+",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width),i+=It(" %",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,It(Gt.number(t,"decimal",1,1),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width+i+i}cleanSVGforRedraw(t){t.clear()}drawAxisAndLabels(t,i){const s=i.group().id("AxisAndDateLables");let e=!1;this.hideCategories||t.forEach(((t,i)=>{t.type===Ss.RELATIVE&&(e=!0);let n=Us.Right,r=!0;t.scenario1.value<0&&(n=Us.Left,r=!1),new Ds(s,this.position.getCategoryPositionX(r),this.position.getBarCenterPositionY(i),"",this.i18n.get(t.category)||t.category,this.styles,Us.Center,n).draw()})),new Gs({scenarioType:this.axisScenario,labelText:this.title,isRelative:e},this.position,s,this.styles).draw()}drawScenarios(t,i){const s=i.group().id("Scenarios"),e=new zs(this.position,s,this.styles,t.length,this.i18n);e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{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()}))}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),e=new zs(this.position,s,this.styles,t.length,this.i18n);return e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.type===Ss.RELATIVE?e.createRelativeVarianceBar(t.scenario1,i).draw():e.createVarianceBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale)})),s}sortSegmentsByPropOrder(t){if(0===this.scenarioPropOrder.length)return;const i=this.scenarioPropOrder;t.sort(((t,s)=>{const e=i.indexOf(t.scenario),n=i.indexOf(s.scenario);return(-1===e?i.length:e)-(-1===n?i.length:n)}))}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),e=this.stackConfig.by===ut.SCENARIOS;t.forEach(((t,i)=>{const n=["scenario1","scenario2","scenario3","scenario4"],r=[];if(e){for(const i of n){const s=t[i];s&&!s.isEmpty()&&null!=s.value&&r.push({value:s.value,scenario:s.scenario,dataPoint:s})}this.sortSegmentsByPropOrder(r)}else{const i=t.scenario1;i&&!i.isEmpty()&&null!=i.value&&r.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0!==r.length)if((e?new Set(r.map((t=>Zt(t.scenario)))):new Set).size>1){const t=new Map;for(const i of r){const s=Zt(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const e=[];for(const i of Kt)t.has(i)&&(e.push({prefix:i,segments:t.get(i)}),t.delete(i));for(const[i,s]of t)e.push({prefix:i,segments:s});e.forEach(((t,n)=>{const r=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),a=e.length-1-n;let o=0,h=null;t.segments.forEach((t=>{const e=new Ys(this.position,this.styles,t.dataPoint,i,o,t.scenario,a,this.stackConfig.mode,r,!0,s);e.draw(this.dataFormatDigits,this.measureScale),o+=Math.abs(t.value),h=e})),h&&h.drawTotalLabel(this.dataFormatDigits,this.measureScale)}))}else{let n=r;!e&&t.stackSegments&&t.stackSegments.length>0&&(n=t.stackSegments.map((t=>({value:t.value,scenario:t.label,dataPoint:t.dataPoint})))),"asc"===this.stackConfig.order?n.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&n.sort(((t,i)=>i.value-t.value));const a=n.reduce(((t,i)=>t+Math.abs(i.value)),0);let o=0,h=null;n.forEach(((t,n)=>{const r=new Ys(this.position,this.styles,t.dataPoint,i,o,t.scenario,n,this.stackConfig.mode,a,e,s);r.draw(this.dataFormatDigits,this.measureScale),o+=Math.abs(t.value),h=r})),h&&h.drawTotalLabel(this.dataFormatDigits,this.measureScale)}}))}drawStackedHeaders(t,i){if(!this.stackConfig||0===t.length)return;const s=this.stackConfig.by===ut.SCENARIOS,e=i.group().id("StackedHeaders"),n=t[0];if(!s){const t=n.stackSegments;if(!t||0===t.length)return;const i=[...t];"asc"===this.stackConfig.order?i.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&i.sort(((t,i)=>i.value-t.value));const s=i.reduce(((t,i)=>t+Math.abs(i.value)),0),r=this.position.getBarPositionX(),a=this.position.getStackedHeaderPositionY();let o=0;return void i.forEach((t=>{const i=t.dataPoint.pixelPerUnit;let n;n=this.stackConfig.mode===ft.RELATIVE?(0!==s?Math.abs(t.value)/s:0)*i:Math.abs(t.value*i);const h=r+o+n/2,l=this.i18n.get(t.label)||t.label;new Ds(e,h,a,"STACK_HEADER",l,this.styles,Us.Bottom,Us.Center).draw(),o+=n}))}const r=["scenario1","scenario2","scenario3","scenario4"],a=[];for(const t of r){const i=n[t];i&&!i.isEmpty()&&null!=i.value&&a.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0===a.length)return;this.sortSegmentsByPropOrder(a);const o=new Set(a.map((t=>Zt(t.scenario)))),h=this.position.getBarPositionX(),l=this.position.getStackedHeaderPositionY();if(o.size>1){const t=new Map;for(const i of a){const s=Zt(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const i=[];for(const s of Kt)t.has(s)&&(i.push({prefix:s,segments:t.get(s)}),t.delete(s));for(const[s,e]of t)i.push({prefix:s,segments:e});i.forEach((t=>{const i=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),s=t.segments[0].dataPoint.pixelPerUnit,n=h+(this.stackConfig.mode===ft.RELATIVE?s:i*s)/2,r=this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase();new Ds(e,n,l,"STACK_HEADER",r,this.styles,Us.Bottom,Us.Center).draw()}))}else{"asc"===this.stackConfig.order?a.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&a.sort(((t,i)=>i.value-t.value));const t=a.reduce(((t,i)=>t+Math.abs(i.value)),0);let i=0;a.forEach((s=>{const n=s.dataPoint.pixelPerUnit;let r;r=this.stackConfig.mode===ft.RELATIVE?(0!==t?Math.abs(s.value)/t:0)*n:Math.abs(s.value*n);const a=h+i+r/2,o=this.i18n.get(s.scenario)||s.scenario;new Ds(e,a,l,"STACK_HEADER",o,this.styles,Us.Bottom,Us.Center).draw(),i+=r}))}}getVarianceType(){return this.variancesDataModel.length>0?this.variancesDataModel[0].type:Ss.NONE}calculateLeftSideWidth(t){var i,s,e;let n=0;const r=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(Ss.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);n=Math.abs(this.smallestDataPointValue.getScaledUnit())+r+t}else if(Ss.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);n=Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit())+r+t}else if(Ss.ABSOLUTE===t&&null!=(null===(e=this.smallestVarianceDataPointValue)||void 0===e?void 0:e.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value);n=Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())+r+t}return n<=this.titleLength?this.titleLength:n}calculateRightSideWidth(t){var i,s,e;if(null!=this.stackConfig&&this.highestStackedTotal>0){const t=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;let i;i=this.stackConfig.mode===ft.RELATIVE?this.pixelPerUnit:this.highestStackedTotal*this.pixelPerUnit;const s=this.calculateTextBoxWidth(this.highestStackedTotal);return Math.max(i+t+s,this.titleLength)}let n=0;const r=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(Ss.NONE===t&&null!=(null===(i=this.highestDataPointValue)||void 0===i?void 0:i.value)&&this.highestDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestDataPointValue.value);n=Math.abs(this.highestDataPointValue.getScaledUnit())+r+t}else if(Ss.RELATIVE===t&&null!=(null===(s=this.highestVarianceDataPointValue)||void 0===s?void 0:s.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculatePercentageTextBoxWidth(this.highestVarianceDataPointValue.value);n=Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit())+r+t}else if(Ss.ABSOLUTE===t&&null!=(null===(e=this.highestVarianceDataPointValue)||void 0===e?void 0:e.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value);n=Math.abs(this.highestVarianceDataPointValue.getScaledUnit())+r+t}return n<=this.titleLength?this.titleLength:n}populateDimensionStackSegments(t,i,s){if(0===this.rowCount||!this.fromExpr||0===t.length)return;const e={[dt.ROWGROUP]:"category",[dt.ROWGROUPINDEX]:"category",[dt.CATEGORY]:"subCategory",[dt.CATEGORYINDEX]:"subCategory"}[s];if(!e)return;const n=s.toString(),r=t[0];let a;try{a=this.db.exec(`SELECT [${n}] as displayGroup, [${e}] as stackLabel, SUM([${r}] * transformOperator(operation)) as stackValue FROM ${this.fromExpr} GROUP BY [${n}], [${e}]`)}catch(t){return void console.error("StructureChart: dimension-stack query failed",t)}const o=new Map;for(const t of a){const i=t.displayGroup;o.has(i)||o.set(i,[]),null!=t.stackValue&&null!=t.stackLabel&&o.get(i).push({label:t.stackLabel,value:t.stackValue})}for(const t of this.dataModel){const i=o.get(t.category);t.stackSegments=i&&i.length>0?i.map((t=>({label:t.label,value:t.value,dataPoint:new _s(t.value,r,this.pixelPerUnit,Cs.NEU)}))):[]}}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,e=t+i+s;this.variancesDataModel&&this.variancesDataModel.length>0?(this.highestVarianceDataPointValue.getScaledUnit()>t&&(this.highestVarianceDataPointValue=new _s(e,this.highestVarianceDataPointValue.scenario,1,this.highestVarianceDataPointValue.variance)),null!=this.smallestVarianceDataPointValue.value&&Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())>t&&(this.smallestVarianceDataPointValue=new _s(-e,this.smallestVarianceDataPointValue.scenario,1,this.smallestVarianceDataPointValue.variance))):(this.highestDataPointValue.getScaledUnit()>t&&(this.highestDataPointValue=new _s(e,this.highestDataPointValue.scenario,1,this.highestDataPointValue.variance)),null!=this.smallestDataPointValue.value&&Math.abs(this.smallestDataPointValue.getScaledUnit())>t&&(this.smallestDataPointValue=new _s(-e,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()===Ss.RELATIVE)return null;const s=i?this.highestVarianceDataPointValue:this.highestDataPointValue,e=i?this.smallestVarianceDataPointValue:this.smallestDataPointValue,n=s.getScaledUnit(),r=null!=e.value?Math.abs(e.getScaledUnit()):0,a=Math.max(n,r);if(a<=0)return null;const o=this.styles.fontStyles.size,h=o*this.styles.scaleFactors.labelToBar,l=1.5*o,c=.3*o,d=.8*o,u=t-this.position.getAxisPositionX()-this.styles.padding.left-this.styles.padding.right-h-this.calculateTextBoxWidth(s.value||0)-l-c;if(u<=d)return null;const p=u-d;return a<=p?null:{cutWidth:u,overdriveZoneWidth:l,breakGap:c,maxOverflow:a-p,scenarioCutOffset:d}}}class Js{constructor(t=2,i=1){this.percent=t,this.decimal=i}}class qs{adapt(t){const i=new Js;return Ot.isNumber(t.percent)&&(i.percent=t.percent),Ot.isNumber(t.decimal)&&(i.decimal=t.decimal),i}default(){return new Js}}const Zs=class{constructor(i){t(this,i),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:xt.ASC},this.level=dt.CATEGORY,this.filter="",this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.parentDimensions={width:0,height:0}}getDb(){return this.stores||(this.stores=d(this.element)),this.stores.db.db}render(){var t,e,n;if(void 0===this.chart)return i(s,null);if(this.chart.hasNoData()){const t=this.i18n.get("no-data")||"==No Data==";return i(s,null,i("p",{class:"warning"},t))}return i(s,null,i("div",{innerHTML:null===(t=this.pattern)||void 0===t?void 0:t.toString(),class:"hidePatternContainer"}),i("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(e=this.chart)||void 0===e?void 0:e.getFooter()),i("div",{innerHTML:null===(n=this.chart)||void 0===n?void 0:n.toString()}))}async componentWillLoad(){var t;const i=this.getDb(),s=this.prepareConfig(),e=this.prepareStyle();this.chart=new Xs(new Ft(this.ruleSetConfig),i,this.tableName,s,e),this.chart.setI18n(this.i18n);const n=s.pixelPerUnit<=0;this.autoFitScaling(s,e),this.chart.setAvailableWidth(n?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new ws(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}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 Ft(this.ruleSetConfig)),this.chart.setConfig(i);const e=i.pixelPerUnit<=0;this.autoFitScaling(i,s),this.chart.setAvailableWidth(e?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new ws(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}autoFitScaling(t,i){var s;const e=t.pixelPerUnit<=0,n=t.pixelPerPercentage<=0;if(!e&&!n)return;const r=()=>{var i;null===(i=this.reportAutoScaling)||void 0===i||i.call(this,{unit:e?t.pixelPerUnit:void 0,percentage:n?t.pixelPerPercentage:void 0})},a=null===(s=this.parentDimensions)||void 0===s?void 0:s.width,o=this.getDb(),h=()=>{this.chart=new Xs(new Ft(this.ruleSetConfig),o,this.tableName,t,i),this.chart.setI18n(this.i18n)},l=()=>(this.chart.layout(),this.chart.getAllocatedCanvasWidth());if(!a||a<=0)return e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=50),h(),void r();e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=1),h();let c=l();if(c<=0)return void r();const d=Math.max(Bs,.9*a/c);let u=!1,p=!1,f=null;for(let i=0;i<=3;i++){const i=js({target:a,measured:c,unitExtent:e?this.chart.getUnitBarExtent():0,pctExtent:n?this.chart.getPercentBarExtent():0,currentPpu:t.pixelPerUnit,currentPpp:t.pixelPerPercentage});if(void 0===i.ppu&&void 0===i.ppp)break;if(e&&void 0!==i.ppu&&(t.pixelPerUnit=i.ppu,u=!0),n&&void 0!==i.ppp&&(t.pixelPerPercentage=i.ppp,p=!0),h(),c=l(),c<=a+.5&&(f={ppu:t.pixelPerUnit,ppp:t.pixelPerPercentage},c>=.98*a))break}let v=!1;if(e&&!u&&(t.pixelPerUnit=d,v=!0),n&&!p&&(t.pixelPerPercentage=d,v=!0),c>a+.5){if(f)u&&(t.pixelPerUnit=f.ppu),p&&(t.pixelPerPercentage=f.ppp);else{const i=a/c;e&&(t.pixelPerUnit=Math.max(Bs,t.pixelPerUnit*i)),n&&(t.pixelPerPercentage=Math.max(Bs,t.pixelPerPercentage*i))}v=!0}v&&h(),r()}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){const t=this.getDb(),i=this.tableName?m(this.tableName,this.filter):"";return new xs(new ks,new kt(new Rs),new Rs,new qs,t,i).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})}prepareStyle(){return new Ts(new As,new zt,new Bt(new Ht),new ni(new Ht),new Vt).adapt(this.styles)}get element(){return e(this)}};Zs.style=':host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}';class Ks{constructor(){this.scenarioOffset=.3,this.scenarioLabelToColumn=.3,this.labelToColumn=.3,this.labelToAxis=.3,this.needleWidth=.3,this.needleHeadWidth=.6,this.columnWidth=2,this.varianceAxisLineWidth=.3,this.axisLineWidth=.1,this.auxiliaryLineWidth=.1,this.scenarioLineWidth=.2,this.markerWidth=.7,this.markerOffset=0,this.categoryWidth=3,this.axisTickLength=.3}}class Qs{adapt(t){const i=new Ks;return Ot.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),Ot.isNumber(t.scenarioLabelToColumn)&&(i.scenarioLabelToColumn=t.scenarioLabelToColumn),Ot.isNumber(t.labelToColumn)&&(i.labelToColumn=t.labelToColumn),Ot.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),Ot.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),Ot.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),Ot.isNumber(t.columnWidth)&&(i.columnWidth=t.columnWidth),Ot.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),Ot.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),Ot.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),Ot.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),Ot.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),Ot.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),Ot.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),Ot.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new Ks}}class te{constructor(t,i,s,e,n,r,a){this.categoryPosition={x:0,y:0},this.spacings=new Ks,this.categoriesBoxOffset={width:0,height:0},this.padding=t,this.scaleFactors=i,this.fontStlye=s,this.dataLabelHeight=this.caluculateDataLabelHeight(),this.axisPosition={x:0,y:0},this.columnValue={min:e,max:n},this.numberOfColumns=r,this.leftSideLabelLength=a,this.calculateSpacings(),this.calculateCategoryPosition(),this.calculateAxisPosition()}caluculateDataLabelHeight(){return 1.1*It("123456789",{font:this.fontStlye.font,fontSize:this.fontStlye.size+"px"}).height}getColumnCenterPositionX(t){return this.categoryPosition.y+this.spacings.scenarioOffset+t*this.spacings.categoryWidth+this.leftSideLabelLength+.5*this.spacings.columnWidth}getAxisPositionY(t){let i=this.columnValue.max.getScaledUnit();return t&&(i=this.columnValue.max.getScaledPercentUnit()+this.getNeedleWidth()),i+this.dataLabelHeight+this.spacings.labelToAxis+this.padding.top}getAxisPositionX(){return this.padding.left+this.leftSideLabelLength}getColumnPositionX(t,i){return i?this.getColumnCenterPositionX(t):this.getColumnCenterPositionX(t)-this.spacings.scenarioOffset}getColumnPositionY(){return this.columnValue.max.getScaledUnit()+this.dataLabelHeight+this.spacings.labelToColumn+this.padding.top}getNeedlePositionY(){return this.columnValue.max.getScaledPercentUnit()+this.dataLabelHeight+this.spacings.labelToColumn+this.getNeedleWidth()+this.padding.top}getMarkerPositionX(t,i){return i?this.getColumnCenterPositionX(t)-this.spacings.markerOffset-.5*this.getColumnWidth():this.getColumnCenterPositionX(t)+this.spacings.markerOffset+.5*this.getColumnWidth()}getMarkerPositionY(){return this.getColumnPositionY()}getAxisTitlePositionX(t){const i=t.width();return this.axisPosition.x-i}getAxisTitlePositionY(t,i){let s=this.columnValue.max.getScaledUnit();return i&&(s=this.columnValue.max.getScaledPercentUnit()),t?s+this.dataLabelHeight+this.spacings.labelToAxis:s}getColumnDataLabelPositionY(t){const i=this.spacings.labelToColumn;return t<0?this.getColumnPositionY()+Math.abs(t)+i:this.getColumnPositionY()-t-i}getNeedleDataLabelPositionY(t){const i=this.spacings.labelToColumn;return t<0?this.getNeedlePositionY()+Math.abs(t)+i+2*this.getNeedleWidth():this.getNeedlePositionY()-t-i-2*this.getNeedleWidth()}getAxisEndPositionX(){return this.getAxisPositionX()+(this.numberOfColumns+.5)*this.spacings.categoryWidth}getColumnWidth(){return this.spacings.columnWidth}getNeedleWidth(){return this.spacings.needleWidth}getNeedleHeadWidth(){return this.spacings.needleHeadWidth}getScenarioLabelPositionOffsetX(t){return t?.5*this.getColumnWidth()+this.spacings.scenarioLabelToColumn:-(.5*this.getColumnWidth()+this.spacings.scenarioLabelToColumn)}calculateSpacings(){this.spacings={scenarioOffset:this.fontStlye.size*this.scaleFactors.scenarioOffset,scenarioLabelToColumn:this.fontStlye.size*this.scaleFactors.scenarioLabelToColumn,markerOffset:this.fontStlye.size*this.scaleFactors.markerOffset,labelToColumn:this.fontStlye.size*this.scaleFactors.labelToColumn,labelToAxis:this.fontStlye.size*this.scaleFactors.labelToAxis,needleWidth:this.fontStlye.size*this.scaleFactors.needleWidth,needleHeadWidth:this.fontStlye.size*this.scaleFactors.needleHeadWidth,columnWidth:this.fontStlye.size*this.scaleFactors.columnWidth,varianceAxisLineWidth:this.fontStlye.size*this.scaleFactors.varianceAxisLineWidth,axisLineWidth:this.fontStlye.size*this.scaleFactors.axisLineWidth,auxiliaryLineWidth:this.fontStlye.size*this.scaleFactors.auxiliaryLineWidth,scenarioLineWidth:this.fontStlye.size*this.scaleFactors.scenarioLineWidth,markerWidth:this.fontStlye.size*this.scaleFactors.markerWidth,categoryWidth:this.fontStlye.size*this.scaleFactors.categoryWidth,axisTickLength:this.fontStlye.size*this.scaleFactors.axisTickLength}}calculateCategoryPosition(){this.categoryPosition={x:this.padding.left+.5*this.spacings.columnWidth,y:this.padding.top}}calculateAxisPosition(){this.axisPosition={x:this.getAxisPositionX(),y:this.getAxisPositionY(!1)}}getMarkerScenarioLabelPositionOffsetX(t){return t?this.spacings.labelToColumn-this.fontStlye.size:this.spacings.labelToColumn+.5*this.spacings.markerWidth}}class ie{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 se{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"},this.markerRight={bottom:"0,"+s,top:"0,0",right:s+","+s/2},this.markerRightBackground={bottom:"0,"+i,top:"0,0",right:i+","+i/2},this.markerLeft={bottom:s+","+s,top:s+",0",left:"0,"+s/2},this.markerLeftBackground={bottom:i+","+i,top:i+",0",Left:"0,"+i/2}}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}}rightMarkerPatternStrings(){return{background:this.markerRightBackground.top+" "+this.markerRightBackground.right+" "+this.markerRightBackground.bottom+" "+this.markerRightBackground.top,foreground:this.markerRight.top+" "+this.markerRight.right+" "+this.markerRight.bottom+" "+this.markerRight.top,bgOffset:this.bgOffset}}leftMarkerPatternStrings(){return{background:this.markerLeftBackground.top+" "+this.markerLeftBackground.Left+" "+this.markerLeftBackground.bottom+" "+this.markerLeftBackground.top,foreground:this.markerLeft.top+" "+this.markerLeft.left+" "+this.markerLeft.bottom+" "+this.markerLeft.top,bgOffset:this.bgOffset}}createPatternMapForStructureBar(){const t=new Map;return t.set("marker-up",this.upMarkerPatternStrings()),t.set("marker-down",this.downMarkerPatternStrings()),t.set("marker-right",this.rightMarkerPatternStrings()),t.set("marker-left",this.leftMarkerPatternStrings()),t}}class ee{constructor(t){this.container=new Wt,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-time-fc")}getFCPolygonPattern(){return{background:"",foreground:"",bgOffset:0,pattern:this.pattern}}toString(){return this.container.svg()}}class ne{constructor(t,i,s,e){this.value=t,this.scenario=i,this.pixelPerUnit=s||1,this.variance="neg"===e||e===le.NEG?le.NEG:"pos"===e||e===le.POS?le.POS:le.NEU}isEmpty(){return void 0===this.value||null==this.scenario}getScaledUnit(){return null==this.value?0:this.value*this.pixelPerUnit}getScaledPercentUnit(){return null==this.value?0:this.value>1.45?1.45*this.pixelPerUnit:this.value<-1.45?-1.45*this.pixelPerUnit:this.value*this.pixelPerUnit}getVarianceStyle(){return null==this.value||this.value>=0?this.variance:le.NEU===this.variance?le.NEU:le.POS===this.variance?le.NEG:le.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 re{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 ae{constructor(){}adapt(t){const i=new re;return Ot.isString(t.date)&&(i.date=this.parseDateString(t.date)),Ot.isOperator(t.operation)&&(i.operation=t.operation),Ot.isNumber(t.rowGroupIndex)&&Ot.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),Ot.isNumber(t.categoryIndex)&&Ot.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),Ot.isNumber(t.subCategoryIndex)&&Ot.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),Ot.isNumber(t.columnGroupIndex)&&Ot.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),Ot.isNumber(t.columnSubGroupIndex)&&Ot.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}parseDateString(t){if("string"!=typeof t)return;const i=g.fromISO(t);if(i.isValid)return i;console.warn(`TimeChartDataRow: invalid date value '${t}' — skipping row`)}default(){return new re}setActualValues(t,i){Ot.isNumber(t.ac1)&&(i.ac1=t.ac1),Ot.isNumber(t.ac2)&&(i.ac2=t.ac2),Ot.isNumber(t.ac3)&&(i.ac3=t.ac3),Ot.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){Ot.isNumber(t.pl1)&&(i.pl1=t.pl1),Ot.isNumber(t.pl2)&&(i.pl2=t.pl2),Ot.isNumber(t.pl3)&&(i.pl3=t.pl3),Ot.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){Ot.isNumber(t.pp1)&&(i.pp1=t.pp1),Ot.isNumber(t.pp2)&&(i.pp2=t.pp2),Ot.isNumber(t.pp3)&&(i.pp3=t.pp3),Ot.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){Ot.isNumber(t.fc1)&&(i.fc1=t.fc1),Ot.isNumber(t.fc2)&&(i.fc2=t.fc2),Ot.isNumber(t.fc3)&&(i.fc3=t.fc3),Ot.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class oe{constructor(t,i,s,e,n,r){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=e,this.varianceStyles=n,this.padding=r,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"]}}class he{constructor(t,i,s,e,n){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=e,this.paddingadapter=n}adapt(t){const i=new oe(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return Ot.isExisting(t)&&(Ot.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),Ot.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),Ot.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),Ot.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),Ot.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),Ot.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 se(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new oe(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}var le,ce;!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"}(le||(le={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(ce||(ce={}));class de{constructor(t,i,s){this.ID_AXIS="axis",this.CSS_AXIS_TITLE="categories",this.scenarioType=t.scenarioType,this.labelText=t.labelText||null,this.isRelative=t.isRelative||!1,this.position=i,this.svgGroup=s.group().id(this.ID_AXIS)}drawAxisTitle(t,i){null==i&&(i=""),t.text(i).addClass(this.CSS_AXIS_TITLE).attr("text-anchor","middle").move(this.position.getAxisTitlePositionX(t),this.position.getAxisTitlePositionY(!0,this.isRelative))}draw(){return this.labelText&&this.drawAxisTitle(this.svgGroup,this.labelText),this.svgGroup.line(this.position.getAxisPositionX(),this.position.getAxisPositionY(this.isRelative),this.position.getAxisEndPositionX(),this.position.getAxisPositionY(this.isRelative)).addClass(this.ID_AXIS+"-"+this.convertScenarioType()),this}convertScenarioType(){return void 0===this.scenarioType||null==this.scenarioType?"default":`${this.scenarioType}`.slice(0,2)}}class ue{constructor(t,i,s,e,n,r,a,o=null){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.isVarianceColumn=!1,this.overflowConfig=null,this.isOverflowing=!1,this.overdriveHeight=0,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=e,this.isPrimaryColumn=n,this.position=t,this.columnBarStyles=i.barStyles,this.overflowConfig=o,this.scenarioGroup=r,this.styles=i,this.columnGroup=r.group().id(r.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&(this.hasData=!0,this.dimensions=this.createDimensions(s,e,n),this.label=this.getDataLabel(s),this.scenarioLabel=this.getScenarioLabel(a))}setAsVariance(){var t;return this.isVarianceColumn=!0,null===(t=this.label)||void 0===t||t.setToVarianceLabel(),this}updateLabelGroup(t){var i;return this.isEmpty()||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1},i=new Jt){if(this.isEmpty())return this;const s=this.getScenarioStyle(),e=this.convertToSVGStyle(s,"stroke"),n=this.getFillStyle(s);null!=this.columnGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(n,e):this.columnGroup.rect(this.position.getColumnWidth(),this.dimensions.columnLength).fill(n).stroke(e).y(this.dimensions.yPos).cx(this.dimensions.xPos)),this.drawColumnDataLabel(t,i),this.drawScenarioLabel()}drawOverdriveBar(t,i){if(!this.columnGroup||!this.overflowConfig)return;const s=this.position.getColumnPositionY(),e=this.position.getColumnWidth(),n=this.dimensions.columnLength,{breakGap:r}=this.overflowConfig,a=s-n;this.columnGroup.rect(e,n).fill(t).stroke(i).y(a).cx(this.dimensions.xPos);const o=a-r-this.overdriveHeight;this.columnGroup.rect(e,this.overdriveHeight).fill(t).stroke(i).y(o).cx(this.dimensions.xPos),this.drawBreakIndicator(a,r)}drawBreakIndicator(t,i){if(!this.columnGroup)return;const s=this.position.getColumnWidth(),e=this.dimensions.xPos-s/2,n=t-i/2,r=.35*i,a=s/3;let o=`M ${e} ${n-r}`;for(let t=0;t<3;t++)o+=` L ${e+a*(t+.5)} ${n-r-.3*i} L ${e+a*(t+1)} ${n-r}`;let h=`M ${e} ${n+r}`;for(let t=0;t<3;t++)h+=` L ${e+a*(t+.5)} ${n+r+.3*i} L ${e+a*(t+1)} ${n+r}`;this.columnGroup.rect(s+2,i).fill("#ffffff").stroke("none").y(t-i).cx(this.dimensions.xPos),this.columnGroup.path(o).fill("none").stroke({color:"#000000",width:1}),this.columnGroup.path(h).fill("none").stroke({color:"#000000",width:1})}createDimensions(t,i,s){const e=t.getScaledUnit();if(this.overflowConfig&&e>0){const n="ac"===t.getScenario()?this.overflowConfig.cutHeight:this.overflowConfig.cutHeight-this.overflowConfig.scenarioCutOffset;if(e>n){this.isOverflowing=!0;const{breakGap:t,overdriveZoneHeight:r,maxOverflow:a}=this.overflowConfig;this.overdriveHeight=a>0?(e-n)/a*r:0;const o=n+t+this.overdriveHeight,h=this.position.getColumnPositionY();return{clipped:!1,columnLength:n,xPos:this.position.getColumnPositionX(i,s),yPos:h-n,labelYPos:h-o-this.position.spacings.labelToColumn,scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:h-.5*n}}}return e<0?{clipped:!1,columnLength:Math.abs(e),xPos:this.position.getColumnPositionX(i,s),yPos:this.position.getColumnPositionY(),labelYPos:this.position.getColumnDataLabelPositionY(e),scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getColumnPositionY()+.5*Math.abs(e)}:{clipped:!1,columnLength:e,xPos:this.position.getColumnPositionX(i,s),yPos:this.position.getColumnPositionY()-e,labelYPos:this.position.getColumnDataLabelPositionY(e),scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getColumnPositionY()-.5*Math.abs(e)}}getDataLabel(t){let i=ti.Bottom;null!=t.value&&t.value<0&&(i=ti.Top);const s=this.isOverflowing?this.dimensions.labelYPos:this.position.getColumnDataLabelPositionY(this.dataPoint.getScaledUnit());return new Qt(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),s,this.ID_DATA_PREFIX,t.value,this.styles,i,ti.Center)}getScenarioLabel(t){return new Qt(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,ti.Center,this.isPrimaryColumn?ti.Left:ti.Right)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.isVarianceColumn||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(!0)}drawColumnDataLabel(t,i=new Jt){var s;null===(s=this.label)||void 0===s||s.draw(this.isPrimaryColumn,t,i)}getFillStyle(t){var i,s,e,n;const r=this.columnBarStyles[this.dataPoint.getScenario()];return(null==r?void 0:r.fillpattern)&&(null===(i=this.styles.pattern.get(r.fillpattern))||void 0===i?void 0:i.pattern)?null===(n=null===(e=null===(s=this.styles)||void 0===s?void 0:s.pattern)||void 0===e?void 0:e.get(r.fillpattern))||void 0===n?void 0:n.pattern:this.convertToSVGStyle(t,"fill")}getScenarioStyle(){var t;return this.isVarianceColumn?null===(t=this.styles)||void 0===t?void 0:t.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()):this.columnBarStyles[this.dataPoint.getScenario()]}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}}class pe{constructor(t,i,s,e,n,r,a,o,h){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.FALLBACK_COLOUR="#000000",this.scenarioLabel=null,this._defaultMarkerPattern=null,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.position=t,this.markerGroup=i||null,this.markerPattern=s||this._defaultMarkerPattern,this.styles=n,this.barStyles=n?n.barStyles:null,this.scenario=e,!0!==(null==r?void 0:r.isEmpty())&&(this.hasData=!0,this.dimensions=this.createMarkerDimensions(r,a,h),this.scenarioLabel=this.getScenarioLabel(o,n,h))}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.polygon(this.markerPattern.background).fill("#ffffff").cy(this.dimensions.yPos-this.dimensions.columnLength).cx(this.dimensions.xPos),this.markerGroup.polygon(this.markerPattern.foreground).fill(i).stroke(t).cy(this.dimensions.yPos-this.dimensions.columnLength).cx(this.dimensions.xPos),null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(),this}createMarkerDimensions(t,i,s){return t.getScaledUnit()<0?{clipped:!1,labelYPos:0,columnLength:t.getScaledUnit(),xPos:this.position.getMarkerPositionX(i,s),yPos:this.position.getMarkerPositionY(),scenarioLabelXPos:this.position.getMarkerPositionX(i,s)+this.position.getMarkerScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getMarkerPositionY()+Math.abs(t.getScaledUnit())}:{clipped:!1,labelYPos:0,columnLength:t.getScaledUnit(),xPos:this.position.getMarkerPositionX(i,s),yPos:this.position.getMarkerPositionY(),scenarioLabelXPos:this.position.getMarkerPositionX(i,s)+this.position.getMarkerScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getMarkerPositionY()-Math.abs(t.getScaledUnit())}}getScenarioLabel(t,i,s){return null==this.markerGroup?null:new Qt(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,ti.Center,s?ti.Right:ti.Left)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}isEmpty(){return!1===this.hasData}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}class fe{constructor(t,i,s,e,n){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.dataLabel=null,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=e,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=n,this.styles=i,this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&(this.hasData=!0,this.dimensions=this.createDimensions(t,s,e),this.dataLabel=new Qt(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),this.position.getNeedleDataLabelPositionY(this.dataPoint.getScaledPercentUnit()),this.ID_DATA_PREFIX,s.value,this.styles,ti.Center,ti.Center),this.dataLabel.setToRelativeVarianceLabel())}updateLabelGroup(t){var i;return this.isEmpty()||null===(i=this.dataLabel)||void 0===i||i.updateGroup(t),this}draw(){var t;if(this.isEmpty())return this;const i=this.styles.varianceStyles[this.dataPoint.getVarianceStyle()],s=this.convertToSVGStyle(i,"stroke");let e=this.convertToSVGStyle(i,"fill");const n=this.convertToSVGStyle(this.styles.varianceStyles.ac,"stroke"),r=this.convertToSVGStyle(this.styles.varianceStyles.ac,"fill"),a=this.barStyles[this.dataPoint.getScenario()];if(null!=a&&a.fillpattern){const t=this.styles.pattern.get(a.fillpattern);null!=t&&(e=t.pattern)}this.dimensions.clipped?this.createClippedNeedleHead(e,s):this.createNeedleHead(n,r),this.barGroup.rect(this.position.getNeedleWidth(),this.dimensions.columnLength).cx(this.dimensions.xPos).y(this.dimensions.yPos).fill(e).stroke(s),null===(t=this.dataLabel)||void 0===t||t.draw()}createDimensions(t,i,s){return i.getScaledPercentUnit()<0?{labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,columnLength:Math.abs(i.getScaledPercentUnit()),xPos:t.getColumnCenterPositionX(s),yPos:t.getNeedlePositionY(),clipped:i.isClipped()}:{columnLength:i.getScaledPercentUnit(),xPos:t.getColumnCenterPositionX(s),yPos:t.getNeedlePositionY()-i.getScaledPercentUnit(),labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:i.isClipped()}}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}createClippedNeedleHead(t,i){const s=this.barGroup.polygon("0,0 5,9 -5,9 0,0 0,5 5,13 -5,13 0,5").fill(t).cx(this.dimensions.xPos).cy(this.getHeadYPosition()).fill(t).stroke(i);null!=this.dataPoint.value&&this.dataPoint.value<0&&s.flip("y")}createNeedleHead(t,i){this.barGroup.rect(2*this.position.getNeedleWidth(),this.position.getNeedleHeadWidth()).cx(this.dimensions.xPos).cy(this.getHeadYPosition()).fill(t).stroke(i)}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getHeadYPosition(){let t=this.dimensions.yPos;return null!=this.dataPoint.value&&this.dataPoint.value<0&&(t+=this.dimensions.columnLength),t}}const ve={ac:{markerFill:"#000000",markerStroke:"#000000",lineColor:"#000000"},pp:{markerFill:"#999999",markerStroke:"#999999",lineColor:"#999999"},fc:{markerFill:"#ffffff",markerStroke:"#000000",lineColor:"#000000",lineDashArray:"4,4"},pl:{markerFill:"#ffffff",markerStroke:"#000000",lineColor:"#000000"}};class ge{constructor(t,i,s,e,n,r,a,o,h=null){this.MARKER_SIZE=8,this.LINE_WIDTH=2,this.ID_LINE_PREFIX="LINE",this.ID_MARKER_PREFIX="MARKER",this.ID_LABEL_PREFIX="LABEL",this.ESTIMATED_LABEL_WIDTH=56,this.ESTIMATED_LABEL_HEIGHT=24,this.position=t,this.styles=i,this.dataPoints=s,this.scenarioGroup=e,this.labelGroup=n,this.scenarioName=r,this.scenarioLabel=a,this.collisionManager=h}draw(t={percent:2,decimal:1},i=new Jt){return this.drawGeometry(),this.drawLabels(t,i),this}drawGeometry(){if(0===this.dataPoints.length)return this;const t=this.getLineStyle();return this.drawLines(t),this.drawMarkers(t),this}drawLabels(t={percent:2,decimal:1},i=new Jt){return 0===this.dataPoints.length||(this.drawScenarioLabel(),this.drawValueLabels(t,i)),this}getLineStyle(){var t,i;const s=(null===(i=null===(t=this.scenarioName)||void 0===t?void 0:t.slice(0,2))||void 0===i?void 0:i.toLowerCase())||"ac";return ve[s]||ve.ac}getScenarioVariant(){var t;const i=parseInt((null===(t=this.scenarioName)||void 0===t?void 0:t.slice(-1))||"1",10);return isNaN(i)?1:Math.min(Math.max(i,1),4)}drawSquareMarker(t,i,s,e){const n=this.MARKER_SIZE/2;t.rect(this.MARKER_SIZE,this.MARKER_SIZE).fill(e.markerFill).stroke({color:e.markerStroke,width:1}).move(i-n,s-n)}drawCircleMarker(t,i,s,e){t.circle(this.MARKER_SIZE).fill(e.markerFill).stroke({color:e.markerStroke,width:1}).center(i,s)}drawTriangleMarker(t,i,s,e){const n=this.MARKER_SIZE/2;t.polygon(`${i},${s-n} ${i-n},${s+n} ${i+n},${s+n}`).fill(e.markerFill).stroke({color:e.markerStroke,width:1})}drawDiamondMarker(t,i,s,e){const n=this.MARKER_SIZE/2;t.polygon(`${i},${s-n} ${i+n},${s} ${i},${s+n} ${i-n},${s}`).fill(e.markerFill).stroke({color:e.markerStroke,width:1})}drawLines(t){const i=this.scenarioGroup.group().id(this.ID_LINE_PREFIX);for(let s=1;s<this.dataPoints.length;s++){const e=this.dataPoints[s-1],n=this.dataPoints[s];if(e.dataPoint.isEmpty()||n.dataPoint.isEmpty())continue;const r=this.position.getColumnCenterPositionX(e.index),a=this.position.getColumnPositionY()-e.dataPoint.getScaledUnit(),o=this.position.getColumnCenterPositionX(n.index),h=this.position.getColumnPositionY()-n.dataPoint.getScaledUnit(),l=i.line([[r,a],[o,h]]).stroke({color:t.lineColor,width:this.LINE_WIDTH,linecap:"round"}).fill("none");t.lineDashArray&&l.attr("stroke-dasharray",t.lineDashArray)}}drawMarkers(t){const i=this.scenarioGroup.group().id(this.ID_MARKER_PREFIX),s=this.getScenarioVariant();for(const e of this.dataPoints){if(e.dataPoint.isEmpty())continue;const n=this.position.getColumnCenterPositionX(e.index),r=this.position.getColumnPositionY()-e.dataPoint.getScaledUnit();switch(s){case 2:this.drawCircleMarker(i,n,r,t);break;case 3:this.drawTriangleMarker(i,n,r,t);break;case 4:this.drawDiamondMarker(i,n,r,t);break;default:this.drawSquareMarker(i,n,r,t)}}}getLabelPositionPriority(t){const i=this.dataPoints[t];let s=null;for(let i=t+1;i<this.dataPoints.length;i++)if(!this.dataPoints[i].dataPoint.isEmpty()){s=this.dataPoints[i];break}let e=null;for(let i=t-1;i>=0;i--)if(!this.dataPoints[i].dataPoint.isEmpty()){e=this.dataPoints[i];break}const n=i.dataPoint.getScaledUnit();return e&&s&&e.dataPoint.getScaledUnit()>n&&s.dataPoint.getScaledUnit()>n?[ii.Below,ii.Left,ii.Right,ii.Above]:[ii.Above,ii.Left,ii.Right,ii.Below]}getScenarioType(){var t,i;return(null===(i=null===(t=this.scenarioName)||void 0===t?void 0:t.slice(0,2))||void 0===i?void 0:i.toLowerCase())||"ac"}drawValueLabels(t,i){const s=this.getScenarioType();for(let e=0;e<this.dataPoints.length;e++){const n=this.dataPoints[e];if(n.dataPoint.isEmpty()||null===n.dataPoint.value)continue;const r=this.position.getColumnCenterPositionX(n.index),a=this.position.getColumnPositionY()-n.dataPoint.getScaledUnit();let o=r,h=a-this.MARKER_SIZE/2-2,l=ti.Bottom,c=ti.Center;if(this.collisionManager){const t=this.getLabelPositionPriority(e),i=this.collisionManager.getOptimalPlacement(r,a,this.ESTIMATED_LABEL_WIDTH,this.ESTIMATED_LABEL_HEIGHT,n.index,this.MARKER_SIZE,s,t);if(null===i)continue;o=i.labelX,h=i.labelY,l=i.verticalHook,c=i.horizontalHook;const d=Object.assign(Object.assign({},i.bounds),{scenarioType:s});this.collisionManager.register(d)}new Qt(this.labelGroup,o,h,this.ID_LABEL_PREFIX,n.dataPoint.value,this.styles,l,c).draw(!0,t,i)}}drawScenarioLabel(){if(!this.scenarioLabel)return;let t=null;for(let i=this.dataPoints.length-1;i>=0;i--)if(!this.dataPoints[i].dataPoint.isEmpty()){t=this.dataPoints[i];break}if(!t)return;const i=this.position.getColumnCenterPositionX(t.index)+this.MARKER_SIZE+4,s=this.position.getColumnPositionY()-t.dataPoint.getScaledUnit(),e=this.getScenarioType();if(this.collisionManager){if(this.collisionManager.shouldHideScenarioLabel(i,s,e))return;this.collisionManager.registerScenarioLabel(i,s,e)}new Qt(this.labelGroup,i,s,"SCENARIO_LABEL",this.scenarioLabel,this.styles,ti.Center,ti.Left).forceStringTypeDraw()}}class me{constructor(t,i,s,e,n,r,a,o,h,l,c){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=e,this.baselineValue=n,this.segmentIndex=a,this.stackMode=o,this.totalValue=h,this.group=c,this.columnGroup=c.group().id(`stacked_col_${e}_seg_${a}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new Jt){if(!this.hasData||null==this.dataPoint.value)return;const s=this.dataPoint.value,e=this.dataPoint.pixelPerUnit;let n,r;const a=this.position.getColumnPositionY();if(this.stackMode===ft.RELATIVE){const t=0!==this.totalValue?Math.abs(s)/Math.abs(this.totalValue):0,i=Rt*e;n=t*i,r=a-this.baselineValue/Math.abs(this.totalValue)*i-n}else n=Math.abs(s*e),r=a-this.baselineValue*e-n;const o=this.position.getColumnCenterPositionX(this.index),h=this.position.getColumnWidth(),l=this.styles.stackColors,c=l[this.segmentIndex%l.length],d={color:c},u={color:c,width:.5};if(this.columnGroup.rect(h,Math.max(n,.5)).fill(d).stroke(u).y(r).cx(o),n>=18){const e=r+n/2;if(this.stackMode===ft.RELATIVE||this.stackMode===ft.ABSOLUTE_RELATIVE){const i=(0!==this.totalValue?s/this.totalValue*100:0).toFixed(t.percent)+"%";new Qt(this.group,o,e,"STACK_SEG",i,this.styles,ti.Center,ti.Center).setSegmentFill(c).forceStringTypeDraw()}else new Qt(this.group,o,e,"STACK_SEG",s,this.styles,ti.Center,ti.Center).setSegmentFill(c).draw(!0,t,i)}}drawTotalLabel(t={percent:2,decimal:1},i=new Jt){if(this.stackMode===ft.RELATIVE)return;const s=this.position.getColumnCenterPositionX(this.index),e=this.position.getColumnPositionY();new Qt(this.group,s,e-this.totalValue*this.dataPoint.pixelPerUnit-this.position.spacings.labelToColumn,"STACK_TOTAL",this.totalValue,this.styles,ti.Bottom,ti.Center).draw(!0,t,i)}}const be={ac:{fill:"#000000",opacity:.3,lineColor:"#000000"},pp:{fill:"#999999",opacity:.3,lineColor:"#999999"},fc:{fill:"#000000",opacity:.2,lineColor:"#000000",dashArray:"4,4"},pl:{fill:"#000000",opacity:.1,lineColor:"#000000"}},we=[{fill:"#000000",opacity:.3},{fill:"#555555",opacity:.25},{fill:"#999999",opacity:.2},{fill:"#bbbbbb",opacity:.15},{fill:"#dddddd",opacity:.1}];class ye{constructor(t,i,s,e,n,r){this.group=t.group().id(`area_fill_${n}`),this.upperPoints=i,this.lowerPoints=s,this.scenarioType=e,this.segmentIndex=n,this.isScenarioStack=r}draw(){if(this.upperPoints.length<2||this.lowerPoints.length<2)return;let t,i,s=`M ${this.upperPoints[0].x},${this.upperPoints[0].y}`;for(let t=1;t<this.upperPoints.length;t++)s+=` L ${this.upperPoints[t].x},${this.upperPoints[t].y}`;for(let t=this.lowerPoints.length-1;t>=0;t--)s+=` L ${this.lowerPoints[t].x},${this.lowerPoints[t].y}`;if(s+=" Z",this.isScenarioStack&&this.scenarioType){const s=this.scenarioType.slice(0,2).toLowerCase(),e=be[s]||be.ac;t=e.fill,i=e.opacity}else{const s=Math.min(this.segmentIndex,we.length-1);t=we[s].fill,i=we[s].opacity}this.group.path(s).fill(t).opacity(i).stroke("none")}drawBoundaryLine(){if(this.upperPoints.length<2)return;let t,i="#000000";if(this.isScenarioStack&&this.scenarioType){const s=this.scenarioType.slice(0,2).toLowerCase(),e=be[s]||be.ac;i=e.lineColor,t=e.dashArray}const s=this.group.polyline(this.upperPoints.map((t=>[t.x,t.y]))).fill("none").stroke({color:i,width:1.5});t&&s.attr("stroke-dasharray",t)}}class Se{constructor(t,i,s,e,n,r,a,o){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.isVarianceLine=!1,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.previousDimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=n,this.isPrimaryLine=r,this.position=t,this.LineBarStyles=i.barStyles,this.scenarioGroup=a,this.styles=i,this.LineGroup=a.group().id(a.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&(this.hasData=!0,this.dimensions=this.createDimensions(s,n,r),this.label=this.getDataLabel(s),this.scenarioLabel=this.getScenarioLabel(o)),this.previousDimensions=this.createDimensions(e,n-1,r)}setAsVariance(){var t;return this.isVarianceLine=!0,null===(t=this.label)||void 0===t||t.setToVarianceLabel(),this}updateLabelGroup(t){var i;return this.isEmpty()||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1},i=new Jt){if(this.isEmpty())return this;const s=this.getScenarioStyle(),e=this.getFillStyle(s);null!=this.LineGroup&&this.LineGroup.line([[this.previousDimensions.xPos,this.previousDimensions.yPos],[this.dimensions.xPos,this.dimensions.yPos]]).fill(e).stroke({color:"#f06",width:3,linecap:"round"}),this.drawLineDataLabel(t,i),this.drawScenarioLabel()}createDimensions(t,i,s){return{clipped:!1,columnLength:t.getScaledUnit(),xPos:this.position.getColumnPositionX(i,s),yPos:this.position.getColumnPositionY()-t.getScaledUnit(),labelYPos:this.position.getColumnDataLabelPositionY(t.getScaledUnit()),scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getColumnPositionY()-t.getScaledUnit()}}getDataLabel(t){let i=ti.Bottom;return null!=t.value&&t.value<0&&(i=ti.Top),new Qt(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),this.position.getColumnDataLabelPositionY(this.dataPoint.getScaledUnit()),this.ID_DATA_PREFIX,t.value,this.styles,i,ti.Center)}getScenarioLabel(t){return new Qt(this.scenarioGroup,0,0,this.ID_SCENARIO_PREFIX,t,this.styles,ti.Bottom,ti.Left)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.isVarianceLine||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(!0)}drawLineDataLabel(t,i=new Jt){var s;null===(s=this.label)||void 0===s||s.draw(this.isPrimaryLine,t,i)}getFillStyle(t){var i,s,e,n;const r=this.LineBarStyles[this.dataPoint.getScenario()];return(null==r?void 0:r.fillpattern)&&(null===(i=this.styles.pattern.get(r.fillpattern))||void 0===i?void 0:i.pattern)?null===(n=null===(e=null===(s=this.styles)||void 0===s?void 0:s.pattern)||void 0===e?void 0:e.get(r.fillpattern))||void 0===n?void 0:n.pattern:this.convertToSVGStyle(t,"fill")}getScenarioStyle(){var t;return this.isVarianceLine?null===(t=this.styles)||void 0===t?void 0:t.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()):this.LineBarStyles[this.dataPoint.getScenario()]}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}}class $e{constructor(t,i,s,e,n){this.pixelPerUnit=1,this.collisionManager=null,this.overflowConfig=null,this.i18n=n;const r=i.group().id("Scenario1"),a=i.group().id("Scenario2").insertBefore(r);this.svgGroups={parent:i,scenario1:r,scenario2:a,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=e}setOverflowConfig(t){this.overflowConfig=t}createLine(t,i,s,e){const n=this.svgGroups.scenario1.group().id(""+e),r=this.svgGroups.scenario1Label.group().id(""+e);let a=null;return this.isLastDataPoint(e-1)&&(a=t),new Se(this.position,this.styles,i,s,e,!1,n,a).updateLabelGroup(r)}createPrimaryBar(t,i){const s=this.svgGroups.scenario1.group().id(""+i),e=this.svgGroups.scenario1Label.group().id(""+i);let n=null;return this.isLastDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new ue(this.position,this.styles,t,i,!0,s,n,this.overflowConfig).updateLabelGroup(e)}createVarianceBar(t,i){const s=this.svgGroups.scenario1.group().id(""+i),e=this.svgGroups.scenario1Label.group().id(""+i);let n=null;return this.isLastDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new ue(this.position,this.styles,t,i,!0,s,n,this.overflowConfig).updateLabelGroup(e).setAsVariance()}createRelativeVarianceBar(t,i){const s=this.svgGroups.scenario1.group().id(""+i),e=this.svgGroups.scenario1Label.group().id(""+i);return new fe(this.position,this.styles,t,i,s).updateLabelGroup(e)}createSecondaryBar(t,i){const s=this.svgGroups.scenario2.group().id(""+i);let e=null;return this.isFirstDataPoint(i)&&(e=`${this.i18n.get(t.scenario)||t.scenario}`),new ue(this.position,this.styles,t,i,!1,s,e,this.overflowConfig)}createPrimaryMarker(t,i){const s=this.svgGroups.scenario3.group().id(""+i),e=this.styles.pattern.get("marker-right")||{foreground:"#000000",background:"#ffffff",bgOffset:0};let n=null;return this.isFirstDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new pe(this.position,s,e,t.scenario,this.styles,t,i,n,!0)}createSecondaryMarker(t,i){const s=this.svgGroups.scenario4.group().id(""+i),e=this.styles.pattern.get("marker-left")||{foreground:"#000000",background:"#ffffff",bgOffset:0};let n=null;return this.isLastDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new pe(this.position,s,e,t.scenario,this.styles,t,i,n,!1)}isLastDataPoint(t){return this.elementCnt-1===t}isFirstDataPoint(t){return 0===t}setCollisionManager(t){this.collisionManager=t}moveLabelsToFront(){this.svgGroups.scenario1Label.front()}createLineSeries(t,i){const s=this.svgGroups.parent.group().id("LineSeries_"+i),e=this.svgGroups.scenario1Label.group().id("LineSeries_Label_"+i),n=`${this.i18n.get(i)||i}`;return new ge(this.position,this.styles,t,s,e,i,n,this.i18n,this.collisionManager)}}const Oe="bn-measurement-host";function Re(t,i){const s=function(){if("undefined"==typeof document||!document.body)return null;let t=document.getElementById(Oe);return t||(t=document.createElement("div"),t.id=Oe,t.style.cssText="opacity:0;position:absolute;left:-100%;top:-100%;overflow:hidden",t.setAttribute("aria-hidden","true"),document.body.appendChild(t)),t}();if(s){s.appendChild(t.node);try{i()}finally{t.node.parentNode===s&&s.removeChild(t.node)}}else i()}var Me,xe;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(Me||(Me={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(xe||(xe={}));class _e{constructor(t,i,s,e,n,r=0){this.CSS_CATEGORIES="categories",this.dataModel=[],this.variancesDataModel=[],this.title="",this.configTitle="",this.configVariances=[],this.smallestDataPointValue=new ne(0,le.AC1,1,le.NEU),this.highestDataPointValue=new ne(0,le.AC1,1,le.NEU),this.smallestVarianceDataPointValue=new ne(0,le.AC1,1,le.NEU),this.highestVarianceDataPointValue=new ne(0,le.AC1,1,le.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.hideAxisLabels=!1,this.axisScenario=le.AC1,this.fromExpr="",this.rowCount=0,this.axisCategoryArea={width:0,height:0},this.scenariosArea={width:0,height:0},this.state=Me.DIRTY,this.i18n=new Map,this.leftSideOffsetForHorizontalSync=-1,this.dateInterval=C.DAY,this.locale="de",this.axisLabelsMode=vt.SMART,this.intervalSpanLimit=32,this.measureScale=new Jt,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.showOverlayMedian=!1,this.showOverlayAvg=!1,this.chartMode=gt.BAR,this.maxBars=28,this.stackConfig=null,this.scenarioPropOrder=[],this.lineFullWidth=!0,this.availableWidth=0,this.overflowConfig=null,this.lastScenarios=[],this.db=i,this.tableName=s,this.ruleSet=t||new Ft,this.i18n=this.createI18n(new Map),this.styles=n,this.availableWidth=r,this.setConfig(e),this.position=this.createElementPosition(this.lastScenarios)}updatePosition(t){this.position=this.createElementPosition(t)}setStyles(t){this.styles=t}setRuleSet(t){this.ruleSet=t||new Ft}setAvailableWidth(t){this.availableWidth=t}setAvailableHeight(t){this.pixelPerUnit<=0||t<=0?this.overflowConfig=null:null==this.stackConfig&&this.determineEffectiveChartMode()===gt.BAR?(this.overflowConfig=this.calculateOverflowConfig(t),this.overflowConfig&&this.updatePosition(this.lastScenarios)):this.overflowConfig=null}calculateOverflowConfig(t){const i=(this.isVarianceChart()?this.highestVarianceDataPointValue:this.highestDataPointValue).getScaledUnit();if(i<=0)return null;const s=this.styles.fontStyles.size,e=1.5*s,n=.3*s,r=t-(this.position.dataLabelHeight+this.position.spacings.labelToColumn+this.position.padding.top+this.position.padding.bottom+this.position.spacings.labelToAxis+s)-e-n,a=.8*s;if(r<=a)return null;const o=r-a;return i<=o?null:{cutHeight:r,overdriveZoneHeight:e,breakGap:n,maxOverflow:i-o,scenarioCutOffset:a}}setConfig(t){var i;this.state=Me.DIRTY,this.locale=t.locale,this.scenarioPropOrder=[...t.scenarios];const s=this.sortScenariosbyVisualisationRules(t.scenarios);this.setSource(t.filter),this.hideAxisLabels=t.hideAxisLabels||!1,this.pixelPerUnit=t.pixelPerUnit,this.pixelPerPercentage=t.pixelPerPercentage,this.axisLabelsMode=t.axisLabelsMode,this.intervalSpanLimit=t.intervalSpanLimit,this.dateInterval=this.findDateInterval(t.dateInterval),this.dataModel=this.populateModel(s,this.dateInterval,t.level,t.sortOrder),this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.configTitle=t.title,this.configVariances=null!==(i=null==t?void 0:t.variances)&&void 0!==i?i:[],this.updateTitle(),this.smallestDataPointValue=this.findSmallestDataPointValue(this.dataModel),this.smallestVarianceDataPointValue=this.findSmallestDataPointValue(this.variancesDataModel),this.highestDataPointValue=this.findHighestDataPointValue(this.dataModel),this.highestVarianceDataPointValue=this.findHighestDataPointValue(this.variancesDataModel),this.axisScenario=this.setAxisScenario(t.variances),this.leftSideOffsetForHorizontalSync=t.leftSideOffsetForHorizontalSync,this.measureScale=t.measureScale,this.measureUnit=t.measureUnit,this.dataFormatDigits=t.dataFormatDigits,this.showOverlayMedian=t.showOverlayMedian,this.showOverlayAvg=t.showOverlayAvg,this.chartMode=t.chartMode,this.maxBars=t.maxBars,this.stackConfig=t.stackConfig,this.lineFullWidth=t.lineFullWidth,this.lastScenarios=s,this.updatePosition(s)}getFooter(){return 1===this.measureScale.value&&""===this.measureUnit?" ":Gt.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}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||Gt.translateScenarioLabel(null===(t=this.configVariances)||void 0===t?void 0:t.toString(),this.i18n)}setSource(t){var i,s;if(this.state=Me.DIRTY,!this.tableName)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=m(this.tableName,t);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}}getAllocatedCanvasWidth(){const t=this.position.getAxisEndPositionX(),i=3*this.styles.fontStyles.size,s=Math.max(this.axisCategoryArea.width,this.scenariosArea.width);return Math.max(t+i,s>0?s+this.position.leftSideLabelLength:0)}getAllocatedCanvasHeight(){if(null==this.smallestVarianceDataPointValue.value||null==this.highestVarianceDataPointValue.value||null==this.smallestDataPointValue.value||null==this.highestDataPointValue.value)return 0;const t=this.isVarianceChart()&&this.variancesDataModel.some((t=>t.type===xe.RELATIVE)),i=this.position.getAxisPositionY(t),s=this.position.spacings.labelToAxis+this.position.dataLabelHeight+this.styles.padding.bottom;let e;if(this.isOnSameAxisSide())e=i+s;else{const t=this.isVarianceChart()?this.smallestVarianceDataPointValue:this.smallestDataPointValue;e=i+Math.abs(t.getScaledUnit())+this.position.spacings.labelToColumn+this.position.dataLabelHeight+s}const n=this.isOnSameAxisSide();return Math.max(e,n?this.axisCategoryArea.height+this.scenariosArea.height:this.scenariosArea.height)}getUnitBarExtent(){var t,i,s;const e=this.isVarianceChart()&&this.variancesDataModel.some((t=>t.type===xe.RELATIVE)),n=this.isVarianceChart(),r=n?this.highestVarianceDataPointValue:this.highestDataPointValue,a=n?this.smallestVarianceDataPointValue:this.smallestDataPointValue;return Hs({fixedDomain:(null===(t=this.stackConfig)||void 0===t?void 0:t.mode)===ft.RELATIVE?Rt:void 0,relativeVariance:e,maxPositive:null!==(i=null==r?void 0:r.value)&&void 0!==i?i:0,minNegative:this.isOnSameAxisSide()?0:null!==(s=null==a?void 0:a.value)&&void 0!==s?s:0})}getPercentBarExtent(){var t,i,s,e;return Vs({relativeVariance:this.isVarianceChart()&&this.variancesDataModel.some((t=>t.type===xe.RELATIVE)),maxPositive:null!==(i=null===(t=this.highestVarianceDataPointValue)||void 0===t?void 0:t.value)&&void 0!==i?i:0,minNegative:this.isOnSameAxisSide()?0:null!==(e=null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&void 0!==e?e:0})}layout(){const t=new Wt;Re(t,(()=>this.draw(t)))}toString(){const t=new Wt;return Re(t,(()=>this.draw(t))),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),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===Me.DIRTY&&(this.state=Me.UP_TO_DATE),this.isVarianceChart()?(this.drawVarianceScenario(this.variancesDataModel,t),this.drawAxisAndLabels(this.variancesDataModel,t)):null!=this.stackConfig?this.determineEffectiveChartMode()===gt.LINE?(this.drawStackedAreaScenarios(this.dataModel,t),this.drawAxisAndLabelsForLineChart(this.dataModel,t)):(this.drawStackedScenarios(this.dataModel,t),this.drawStackedHeaders(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t)):this.determineEffectiveChartMode()===gt.LINE?(this.drawLineScenarios(this.dataModel,t),this.drawAxisAndLabelsForLineChart(this.dataModel,t)):(this.drawScenarios(this.dataModel,t),this.drawOverlayLayer(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t))}determineEffectiveChartMode(){return this.chartMode===gt.LINE||this.chartMode===gt.AUTO&&this.dataModel.length>this.maxBars?gt.LINE:gt.BAR}setPattern(t,i){this.styles.pattern.set(t,i)}hasNoData(){return 0===this.dataModel.length}isOnSameAxisSide(){return null!=this.smallestVarianceDataPointValue.value&&null!=this.highestVarianceDataPointValue.value&&null!=this.smallestDataPointValue.value&&null!=this.highestDataPointValue.value&&(this.isVarianceChart()?Math.sign(this.smallestVarianceDataPointValue.value)===Math.sign(this.highestVarianceDataPointValue.value)||0===this.smallestDataPointValue.value&&1===Math.sign(this.highestDataPointValue.value):Math.sign(this.smallestDataPointValue.value)===Math.sign(this.highestDataPointValue.value)||0===this.smallestDataPointValue.value&&1===Math.sign(this.highestDataPointValue.value))}createI18n(t){this.state=Me.DIRTY;const i=new Map([["SEPERATOR_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"," "],["there_of","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])}createElementPosition(t){var i;let s;const e=It(t.filter(((t,i)=>1===i||2===i)).map((t=>Gt.translateScenarioLabel(t,this.i18n))).reduce(((t,i)=>t.length<i.length?i:t),""),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,n=this.calculateTitleLength(this.leftSideOffsetForHorizontalSync);let r,a;if(s=e>n?e:n,null!=this.position&&(s+=this.position.spacings.labelToColumn),this.leftSideOffsetForHorizontalSync>-1&&(s=this.leftSideOffsetForHorizontalSync),this.isVarianceChart()?(r=this.smallestVarianceDataPointValue,a=this.highestVarianceDataPointValue):(r=this.smallestDataPointValue,a=this.highestDataPointValue),(null===(i=this.stackConfig)||void 0===i?void 0:i.mode)===ft.RELATIVE&&(a=new ne(Rt,a.scenario,this.pixelPerUnit,a.variance)),this.overflowConfig){const{cutHeight:t,overdriveZoneHeight:i,breakGap:s}=this.overflowConfig;a=new ne(t+i+s,a.scenario,1,a.variance)}let o=this.styles.scaleFactors;const h=this.determineEffectiveChartMode();if(this.lineFullWidth&&this.availableWidth>0&&this.dataModel.length>0&&!this.isVarianceChart()&&h===gt.LINE){const t=this.styles.fontStyles.size,i=this.styles.padding,e=this.styles.scaleFactors,n=this.availableWidth-(i.left+i.right+t*e.scenarioOffset+s+t*e.columnWidth);if(n>0){const i=Math.max(n/this.dataModel.length/t,1.2*e.columnWidth),s=new Ks;Object.assign(s,e),s.categoryWidth=i,o=s}}return new te(new ie(this.styles.padding),o,this.styles.fontStyles,r,a,this.dataModel.length,s)}calculateTitleLength(t){let i="_______";i.length<this.title.length&&(i=this.title);const s=It(i,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;return s<t?t:s}setAxisScenario(t){let i=le.AC1;if(null!=t&&t.length>0){const s=new Yt(t.toString());s.isValid&&(i=s.delta)}return null===i&&(i=le.AC1),i}populateModel(t,i,s,e){if(0===this.rowCount||!this.fromExpr)return[];let n=this.queryDataSet(i,"","");return this.detectNaNCells(t,n),n=this.leftOuterJoinDates(n,i),this.createDataRows(n,t)}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new Yt(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)))}findDateInterval(t){var i,s,e;if(t!==C.AUTO)return t;const n=this.queryMinMaxDates();let r=C.DAY;return null!=(null===(i=n[0])||void 0===i?void 0:i.mindate)&&(r=(new U).calculateDistanceType(null===(s=n[0])||void 0===s?void 0:s.mindate,null===(e=n[0])||void 0===e?void 0:e.maxdate,this.intervalSpanLimit)),r}queryMinMaxDates(){var t,i;let s;try{s=this.db.exec(`SELECT MAX(date) as maxdate, MIN(date) as mindate FROM ${this.fromExpr}`)}catch(t){return console.error("TimeChart: min/max date query failed",t),[{}]}return null!=(null===(t=s[0])||void 0===t?void 0:t.mindate)&&(s[0].mindate=_e.coerceDateTime(s[0].mindate)),null!=(null===(i=s[0])||void 0===i?void 0:i.maxdate)&&(s[0].maxdate=_e.coerceDateTime(s[0].maxdate)),s}static coerceDateTime(t){if(null!=t){if("string"==typeof t){const i=g.fromISO(t);return i.isValid?i:void 0}if("number"==typeof t){const i=g.fromMillis(t);return i.isValid?i:void 0}return"boolean"==typeof t.isValid?t:void 0}}queryDataSet(t,i,s){const e=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],n=`normalizeDate([date], '${t}' , '${this.locale}') as calcdate`;let r;try{r=this.db.exec(`SELECT p.calcdate ${i},\n ${e.map((t=>`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`)).join(",")}\n\n FROM (SELECT ${n} ${i},\n ac1,\n ac2,\n ac3,\n ac4,\n pp1,\n pp2,\n pp3,\n pp4,\n fc1,\n fc2,\n fc3,\n fc4,\n pl1,\n pl2,\n pl3,\n pl4\n FROM ${this.fromExpr}) as p\n GROUP BY calcdate ${s}\n ORDER BY calcdate asc`)}catch(t){return console.error("TimeChart: queryDataSet failed",t),[]}return r}createDataRows(t,i){const s=[];return t.forEach(((t,e)=>{s.push({id:e,category:t.category,type:xe.NONE,date:t.calcdate,scenario1:new ne(t[i[0]],i[0],this.pixelPerUnit,le.NEU),scenario2:new ne(t[i[1]],i[1],this.pixelPerUnit,le.NEU),scenario3:new ne(t[i[2]],i[2],this.pixelPerUnit,le.NEU),scenario4:new ne(t[i[3]],i[3],this.pixelPerUnit,le.NEU)})})),s}findSmallestDataPointValue(t){const i=this.isVarianceChart()?this.pixelPerPercentage:this.pixelPerUnit;let s=new ne(0,"default",i,le.NEU);for(const i of t)for(const t of[i.scenario1,i.scenario2,i.scenario3,i.scenario4])t&&null!=t.value&&t.value<Number(s.value)&&(s=t);return s}findHighestDataPointValue(t){const i=this.isVarianceChart()?this.pixelPerPercentage:this.pixelPerUnit;let s=new ne(0,"default",i,le.NEU);for(const i of t)for(const t of[i.scenario1,i.scenario2,i.scenario3,i.scenario4])null!=t&&t.value>Number(s.value)&&(s=t);return s}populateVarianceModel(t,i){const s=[];if(null==t||0===t.length)return s;let e=null;null!=i&&i.length>0&&(e=i[0]);for(const n in t){const r=new Yt(t[n]);if(r.isValid){const t=this.mapScenarios(r,e),n=r.direction,a="dr"===r.type?this.pixelPerPercentage:this.pixelPerUnit;for(const e in i)s.push({id:Number(e),category:i[e].category,type:"dr"===r.type?xe.RELATIVE:xe.ABSOLUTE,date:i[e].date,scenario1:new ne(this.calculateVariance(r,i[e],t),r.delta,a,n),scenario2:new ne(null,null,null,null),scenario3:new ne(null,null,null,null),scenario4:new ne(null,null,null,null)})}}return s}calculateVariance(t,i,s){const e=s.get(t.base),n=s.get(t.delta);return null==e||null==n||null==i[e].value||null==i[n].value?null:t.type===xe.RELATIVE?(i[e].value-i[n].value)/i[n].value:i[e].value-i[n].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((e=>{i[e].scenario===t.delta?s.set(t.delta,e):i[e].scenario===t.base&&s.set(t.base,e)})),s}cleanSVGforRedraw(t){t.clear()}isVarianceChart(){return this.variancesDataModel&&this.variancesDataModel.length>0}createDateFactory(){const t=new U;return t.setLocale(this.locale),t}drawAxisAndLabels(t,i){const s=this.createDateFactory(),e=i.group().id("AxisAndDateLables");let n=!1;if(!1===this.hideAxisLabels)t.forEach(((t,i)=>{let r=ti.Top,a=this.position.spacings.labelToAxis;t.scenario1.value<0&&(r=ti.Bottom,a*=-1),t.type===xe.RELATIVE&&(n=!0);let o=s.getDateString(t.date,this.dateInterval);this.axisLabelsMode===vt.SMART?(o=s.getSmartDateString(t.date,this.dateInterval),0===i&&this.dateInterval!==C.YEAR&&(o=s.getShortDateString(t.date,this.dateInterval))):this.axisLabelsMode===vt.SHORT&&(o=s.getShortDateString(t.date,this.dateInterval)),new Qt(e,this.position.getColumnCenterPositionX(i),this.position.getAxisPositionY(n)+a,"",o,this.styles,r,ti.Center).forceStringTypeDraw()}));else{const i=null==t?void 0:t[0];i&&i.type===xe.RELATIVE&&(n=!0)}new de({scenarioType:this.axisScenario,labelText:this.title,isRelative:n},this.position,e).draw();const r=e.bbox();this.axisCategoryArea={height:r.height,width:r.width}}drawScenarios(t,i){const s=i.group().id("Scenarios"),e=new $e(this.position,s,this.styles,t.length,this.i18n);e.setOverflowConfig(this.overflowConfig);let n=!1;t.forEach(((t,i)=>{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(),!1===t.scenario1.isEmpty()&&(n=!0)}));let r=0;!1===n&&(r=this.isOnSameAxisSide()?this.position.dataLabelHeight:2*this.position.dataLabelHeight);const a=s.bbox();this.scenariosArea={height:a.height+this.styles.padding.top+this.styles.padding.bottom+r,width:a.width+this.position.spacings.columnWidth}}drawLineScenarios(t,i){var s,e;const n=i.group().id("LineScenarios"),r=new si,a=new $e(this.position,n,this.styles,t.length,this.i18n);a.setCollisionManager(r);const o=["ac1","pp1","fc1","pl1"],h=[[],[],[],[]];t.forEach(((t,i)=>{["scenario1","scenario2","scenario3","scenario4"].forEach(((s,e)=>{t[s]&&h[e].push({dataPoint:t[s],index:i})}))}));const l=[];for(let t=0;t<h.length;t++){const i=h[t];if(i.length>0&&i.some((t=>!t.dataPoint.isEmpty()))){const n=(null===(e=null===(s=i[0])||void 0===s?void 0:s.dataPoint)||void 0===e?void 0:e.scenario)||o[t],r=n.slice(0,2).toLowerCase();l.push({points:i,scenarioName:n,scenarioType:r})}}l.sort(((t,i)=>(ei[i.scenarioType]||99)-(ei[t.scenarioType]||99)));const c=[];for(const t of l){const i=a.createLineSeries(t.points,t.scenarioName);c.push({series:i,scenarioType:t.scenarioType})}for(const t of c)t.series.drawGeometry();a.moveLabelsToFront();const d=[...c].sort(((t,i)=>(ei[t.scenarioType]||99)-(ei[i.scenarioType]||99)));for(const t of d)t.series.drawLabels(this.dataFormatDigits,this.measureScale);const u=this.position.getColumnPositionY(),p=n.bbox();this.scenariosArea={height:Math.max(p.height+this.styles.padding.top,u)+this.styles.padding.bottom,width:p.width+this.position.spacings.columnWidth}}drawAxisAndLabelsForLineChart(t,i){const s=this.createDateFactory(),e=i.group().id("AxisAndDateLabelsLine"),n=!1,r=t.length-1;!1===this.hideAxisLabels&&t.forEach(((i,a)=>{if(!this.shouldShowLineChartAxisLabel(t,a))return;let o,h=ti.Top,l=this.position.spacings.labelToAxis;i.scenario1.value<0&&(h=ti.Bottom,l*=-1),this.lineFullWidth&&this.availableWidth>0?this.axisLabelsMode===vt.SMART?(o=s.getSmartDateString(i.date,this.dateInterval),0===a&&this.dateInterval!==C.YEAR&&(o=s.getShortDateString(i.date,this.dateInterval))):o=this.axisLabelsMode===vt.SHORT?s.getShortDateString(i.date,this.dateInterval):s.getDateString(i.date,this.dateInterval):o=s.getShortDateString(i.date,this.dateInterval),new Qt(e,this.position.getColumnCenterPositionX(a),this.position.getAxisPositionY(n)+l,"",o,this.styles,h,ti.Center).forceStringTypeDraw(),a>0&&a<r&&this.isYearChange(t,a)&&this.drawYearSeparatorLine(e,a,n)})),new de({scenarioType:this.axisScenario,labelText:this.title,isRelative:n},this.position,e).draw();const a=e.bbox();this.axisCategoryArea={height:a.height,width:a.width}}shouldShowLineChartAxisLabel(t,i){return!!(this.lineFullWidth&&this.availableWidth>0)||(0===i||i===t.length-1||this.isYearChange(t,i))}isYearChange(t,i){var s,e;if(0===i)return!1;const n=null===(s=t[i])||void 0===s?void 0:s.date,r=null===(e=t[i-1])||void 0===e?void 0:e.date;return!(!n||!r)&&n.year!==r.year}drawYearSeparatorLine(t,i,s){const e=this.position.getColumnCenterPositionX(i)-this.position.spacings.columnWidth/2,n=this.position.columnValue.max.getScaledUnit()+this.position.dataLabelHeight,r=this.position.getAxisPositionY(s)-n,a=this.position.getAxisPositionY(s);t.line([[e,r],[e,a]]).stroke({color:"#999999",width:1,dasharray:"4,4"}).attr("stroke-dasharray","4,4")}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),e=new $e(this.position,s,this.styles,t.length,this.i18n);e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.type===xe.RELATIVE?e.createRelativeVarianceBar(t.scenario1,i).draw():e.createVarianceBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale)}));const n=s.bbox();return this.scenariosArea={height:n.height+this.styles.padding.top+this.styles.padding.bottom,width:n.width+this.position.spacings.columnWidth},s}sortSegmentsByPropOrder(t){if(0===this.scenarioPropOrder.length)return;const i=this.scenarioPropOrder;t.sort(((t,s)=>{const e=i.indexOf(t.scenario),n=i.indexOf(s.scenario);return(-1===e?i.length:e)-(-1===n?i.length:n)}))}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),e=this.stackConfig.by===ut.SCENARIOS;t.forEach(((t,i)=>{const n=["scenario1","scenario2","scenario3","scenario4"],r=[];if(e){for(const i of n){const s=t[i];s&&!s.isEmpty()&&null!=s.value&&r.push({value:s.value,scenario:s.scenario,dataPoint:s})}this.sortSegmentsByPropOrder(r)}else{const i=t.scenario1;i&&!i.isEmpty()&&null!=i.value&&r.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0!==r.length)if((e?new Set(r.map((t=>Zt(t.scenario)))):new Set).size>1){const t=new Map;for(const i of r){const s=Zt(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const e=[];for(const i of Kt)t.has(i)&&(e.push({prefix:i,segments:t.get(i)}),t.delete(i));for(const[i,s]of t)e.push({prefix:i,segments:s});e.forEach(((t,n)=>{const r=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),a=e.length-1-n;let o=0,h=null;t.segments.forEach((t=>{const e=new me(this.position,this.styles,t.dataPoint,i,o,t.scenario,a,this.stackConfig.mode,r,!0,s);e.draw(this.dataFormatDigits,this.measureScale),o+=Math.abs(t.value),h=e})),h&&h.drawTotalLabel(this.dataFormatDigits,this.measureScale)}))}else{"asc"===this.stackConfig.order?r.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&r.sort(((t,i)=>i.value-t.value));const t=r.reduce(((t,i)=>t+Math.abs(i.value)),0);let n=0,a=null;r.forEach(((r,o)=>{const h=new me(this.position,this.styles,r.dataPoint,i,n,r.scenario,o,this.stackConfig.mode,t,e,s);h.draw(this.dataFormatDigits,this.measureScale),n+=Math.abs(r.value),a=h})),a&&a.drawTotalLabel(this.dataFormatDigits,this.measureScale)}}));const n=s.bbox();this.scenariosArea={height:n.height+this.styles.padding.top+this.styles.padding.bottom,width:n.width+this.position.spacings.columnWidth}}drawStackedHeaders(t,i){if(!this.stackConfig||0===t.length)return;if(this.stackConfig.by!==ut.SCENARIOS)return;const s=i.group().id("StackedHeaders"),e=t[0],n=["scenario1","scenario2","scenario3","scenario4"],r=[];for(const t of n){const i=e[t];i&&!i.isEmpty()&&null!=i.value&&r.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0===r.length)return;this.sortSegmentsByPropOrder(r);const a=new Set(r.map((t=>Zt(t.scenario)))),o=this.position.getColumnPositionY(),h=this.position.getColumnCenterPositionX(0)-this.position.getColumnWidth()/2-this.position.spacings.labelToColumn;if(a.size>1){const t=new Map;for(const i of r){const s=Zt(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}const i=[];for(const s of Kt)t.has(s)&&(i.push({prefix:s,segments:t.get(s)}),t.delete(s));for(const[s,e]of t)i.push({prefix:s,segments:e});i.forEach(((t,e)=>{const n=t.segments.reduce(((t,i)=>t+Math.abs(i.value)),0),r=t.segments[0].dataPoint.pixelPerUnit,a=this.stackConfig.mode===ft.RELATIVE?Rt*r:n*r,l=e===i.length-1?o-a/2:o-a,c=this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase();new Qt(s,h,l,"STACK_HEADER",c,this.styles,ti.Center,ti.Right).forceStringTypeDraw()}))}else{"asc"===this.stackConfig.order?r.sort(((t,i)=>t.value-i.value)):"desc"===this.stackConfig.order&&r.sort(((t,i)=>i.value-t.value));const t=r.reduce(((t,i)=>t+Math.abs(i.value)),0),i=r[0].dataPoint.pixelPerUnit;let e=0;r.forEach((n=>{let r;r=this.stackConfig.mode===ft.RELATIVE?(0!==t?Math.abs(n.value)/t:0)*Rt*i:Math.abs(n.value*i);const a=o-e-r/2,l=this.i18n.get(n.scenario)||n.scenario;new Qt(s,h,a,"STACK_HEADER",l,this.styles,ti.Center,ti.Right).forceStringTypeDraw(),e+=r}))}}drawStackedAreaScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedAreaScenarios"),e=this.stackConfig.by===ut.SCENARIOS,n=this.stackConfig.mode,r=["scenario1","scenario2","scenario3","scenario4"];if(0===(e?r.filter((i=>t.some((t=>t[i]&&!t[i].isEmpty())))).length:1))return;const a=[],o=[],h=[];for(const i of r)t.some((t=>t[i]&&!t[i].isEmpty()))&&h.push(i);if(e&&this.scenarioPropOrder.length>0){const i=this.scenarioPropOrder;h.sort(((s,e)=>{var n,r,a,o;const h=i.indexOf(null!==(r=null===(n=t[0][s])||void 0===n?void 0:n.scenario)&&void 0!==r?r:""),l=i.indexOf(null!==(o=null===(a=t[0][e])||void 0===a?void 0:a.scenario)&&void 0!==o?o:"");return(-1===h?i.length:h)-(-1===l?i.length:l)}))}for(let i=0;i<h.length;i++){const s=h[i],e=[];for(let r=0;r<t.length;r++){const o=t[r][s],l=o&&!o.isEmpty()&&null!=o.value?o.value:0,c=i>0?a[i-1][r]:0;if(n===ft.RELATIVE){const i=h.reduce(((i,s)=>{const e=t[r][s];return i+(e&&!e.isEmpty()&&null!=e.value?Math.abs(e.value):0)}),0),s=0!==i?Math.abs(l)/i:0;e.push(c+s)}else e.push(c+l)}a.push(e);const r=t[0][s];o.push((null==r?void 0:r.scenario)||"ac1")}const l=this.position.getColumnPositionY(),c=this.pixelPerUnit,d=t=>t.map(((t,i)=>({x:this.position.getColumnCenterPositionX(i),y:l-(n===ft.RELATIVE?t*Rt*c:t*c)}))),u=t.map(((t,i)=>({x:this.position.getColumnCenterPositionX(i),y:l})));for(let t=0;t<a.length;t++){const i=d(a[t]),n=0===t?u:d(a[t-1]),r=new ye(s,i,n,e?o[t]:null,t,e);r.draw(),r.drawBoundaryLine()}const p=s.bbox();this.scenariosArea={height:p.height+this.styles.padding.top+this.styles.padding.bottom,width:p.width+this.position.spacings.columnWidth}}drawOverlayLayer(t,i){const s=i.group().id("Overlay"),e=new $e(this.position,s,this.styles,t.length,this.i18n);if(!0===this.showOverlayAvg){let i=null;const s=function(t){const i=t.reduce(((t,i)=>{var s;return t+((null===(s=i.scenario1)||void 0===s?void 0:s.value)||0)}),0),s=t.filter((t=>{var i;return void 0!==(null===(i=t.scenario1)||void 0===i?void 0:i.value)})).length,e=s>0?i/s:0,n=Object.assign(Object.assign({},t[0]),{scenario1:new ne(e,t[0].scenario1.scenario,t[0].scenario1.pixelPerUnit,t[0].scenario1.variance)}),r=Object.assign(Object.assign({},t[t.length-1]),{scenario1:new ne(e,t[t.length-1].scenario1.scenario,t[t.length-1].scenario1.pixelPerUnit,t[t.length-1].scenario1.variance)});return[n,...t.map((t=>Object.assign(Object.assign({},t),{scenario1:new ne(e,t.scenario1.scenario,t.scenario1.pixelPerUnit,t.scenario1.variance)}))),r]}(t);s.forEach(((t,s)=>{null!=i&&e.createLine(`Ø ${this.i18n.get(t.scenario1.scenario)||t.scenario1.scenario}`,t.scenario1,i,s-1).draw(this.dataFormatDigits,this.measureScale),i=t.scenario1}))}if(!0===this.showOverlayMedian){let i=null;const s=function(t){const i=t.map((t=>{var i;return null===(i=t.scenario1)||void 0===i?void 0:i.value})).filter((t=>void 0!==t)).sort(((t,i)=>t-i)),s=i.length%2==0?(i[i.length/2-1]+i[i.length/2])/2:i[Math.floor(i.length/2)],e=Object.assign(Object.assign({},t[0]),{scenario1:new ne(s,t[0].scenario1.scenario,t[0].scenario1.pixelPerUnit,t[0].scenario1.variance)}),n=Object.assign(Object.assign({},t[t.length-1]),{scenario1:new ne(s,t[t.length-1].scenario1.scenario,t[t.length-1].scenario1.pixelPerUnit,t[t.length-1].scenario1.variance)});return[e,...t.map((t=>Object.assign(Object.assign({},t),{scenario1:new ne(s,t.scenario1.scenario,t.scenario1.pixelPerUnit,t.scenario1.variance)}))),n]}(t);s.forEach(((t,s)=>{null!=i&&e.createLine(`Mdn ${this.i18n.get(t.scenario1.scenario)||t.scenario1.scenario}`,t.scenario1,i,s-1).draw(this.dataFormatDigits,this.measureScale),i=t.scenario1}))}}leftOuterJoinDates(t,i){const s=t.map((t=>t.calcdate)).filter((t=>null!=t&&"boolean"==typeof t.isValid&&t.isValid));if(0===s.length)return t;const e=g.max(...s),n=g.min(...s),r=(new U).datesBetween(n,e,i,this.intervalSpanLimit),a=new Map;return r.forEach(((t,i)=>{a.set(t.toISO(),{id:i,calcdate:t,category:null,ac1:null,ac2:null,ac3:null,ac4:null,pp1:null,pp2:null,pp3:null,pp4:null,fc1:null,fc2:null,fc3:null,fc4:null,pl1:null,pl2:null,pl3:null,pl4:null,isEmpty:!0})})),t.forEach((t=>{const i=t.calcdate.toISO(),s=a.get(i);s&&s.isEmpty&&a.set(i,{id:s.id,calcdate:t.calcdate,category:t.category,ac1:t.ac1,ac2:t.ac2,ac3:t.ac3,ac4:t.ac4,pp1:t.pp1,pp2:t.pp2,pp3:t.pp3,pp4:t.pp4,fc1:t.fc1,fc2:t.fc2,fc3:t.fc3,fc4:t.fc4,pl1:t.pl1,pl2:t.pl2,pl3:t.pl3,pl4:t.pl4,isEmpty:!1})})),Array.from(a.values())}}class Ee{constructor(t,i){this.data=t,this.scenarios=i,this.variances=[],this.title="",this.hideAxisLabels=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.sortOrder=new kt(new Rs).default(),this.level=dt.CATEGORY,this.leftSideOffsetForHorizontalSync=-1,this.dateInterval=C.AUTO,this.axisLabelsMode=vt.SMART,this.intervalSpanLimit=28,this.filter="",this.measureScale=new Jt,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.showOverlayMedian=!0,this.showOverlayAvg=!0,this.chartMode=gt.BAR,this.maxBars=28,this.stackConfig=null,this.lineFullWidth=!0,this.locale="de"}}class ke{constructor(t,i,s,e,n,r){this.dataRowAdapter=t,this.orderAdapter=i,this.stringAdapter=s,this.dataFormatDigitsAdapter=e,this.db=n,this.fromExpr=r}adapt(t){const i=Et.adaptArray(t.data,this.dataRowAdapter),s=Et.adaptArray(t.scenarios,this.stringAdapter),e=new Ee(i,s);return Ot.isArray(t.variances)&&(e.variances=Et.adaptArray(t.variances,this.stringAdapter)),Ot.isString(t.title)&&(e.title=t.title),Ot.isBoolean(t.hideAxisLabels)&&(e.hideAxisLabels=t.hideAxisLabels),Ot.isNumber(t.pixelPerUnit)&&(e.pixelPerUnit=t.pixelPerUnit),Ot.isNumber(t.pixelPerPercentage)&&(e.pixelPerPercentage=t.pixelPerPercentage),Ot.isNumber(t.limit)&&(e.limit=t.limit),Ot.isExisting(t.sortOrder)&&(e.sortOrder=this.orderAdapter.adapt(t.sortOrder)),Ot.isExisting(t.level)&&(e.level=t.level),Ot.isExisting(t.dateInterval)&&(e.dateInterval=t.dateInterval),Ot.isExisting(t.axisLabelsMode)&&(e.axisLabelsMode=t.axisLabelsMode),Ot.isNumber(t.leftSideOffsetForHorizontalSync)&&(e.leftSideOffsetForHorizontalSync=t.leftSideOffsetForHorizontalSync),Ot.isNumber(t.intervalSpanLimit)&&(e.intervalSpanLimit=t.intervalSpanLimit),Ot.isString(t.filter)&&(e.filter=t.filter),Ot.isExisting(t.measureScale)&&(e.measureScale=Os.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale)),Ot.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),Ot.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),Ot.isExisting(t.dataFormatDigits)&&(e.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),Ot.isBoolean(t.showOverlayAvg)&&(e.showOverlayAvg=t.showOverlayAvg),Ot.isBoolean(t.showOverlayMedian)&&(e.showOverlayMedian=t.showOverlayMedian),Ot.isExisting(t.chartMode)&&(e.chartMode=t.chartMode),Ot.isNumber(t.maxBars)&&(e.maxBars=t.maxBars),Ot.isExisting(t.stackConfig)&&(e.stackConfig=t.stackConfig),Ot.isBoolean(t.lineFullWidth)&&(e.lineFullWidth=t.lineFullWidth),Ot.isString(t.locale)&&(e.locale=t.locale),e}default(){return new Ee([],[])}}const Pe=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.scenarios=[],this.variances=[],this.hideAxisLabels=!1,this.pixelPerUnit=2,this.pixelPerPercentage=50,this.limit=0,this.leftSideOffsetForHorizontalSync=-1,this.i18n=new Map,this.order={hierarchy:[],direction:xt.ASC},this.level=dt.CATEGORY,this.dateInterval=C.AUTO,this.intervalSpanLimit=28,this.axisLabelsMode=vt.SMART,this.filter="",this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.showOverlayMedian=!1,this.showOverlayAvg=!1,this.chartMode=gt.BAR,this.maxBars=28,this.stackConfig=null,this.lineFullWidth=!0,this.containerWidth=0,this.dataFormatDigits={percent:2,decimal:1},this.parentDimensions={width:0,height:0}}getDb(){return this.stores||(this.stores=d(this.element)),this.stores.db.db}render(){var t,e,n;if(void 0===this.chart)return i(s,null);if(this.chart.hasNoData()){const t=this.i18n.get("no-data")||"==No Data==";return i(s,null,i("p",{class:"warning"},t))}return i(s,null,i("div",{innerHTML:null===(t=this.pattern)||void 0===t?void 0:t.toString(),class:"hidePatternContainer"}),i("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(e=this.chart)||void 0===e?void 0:e.getFooter()),i("div",{innerHTML:null===(n=this.chart)||void 0===n?void 0:n.toString()}))}async componentWillLoad(){var t;const i=this.prepareConfig(),s=this.prepareStyle(),e=this.containerWidth||0;this.chart=new _e(new Ft(this.ruleSetConfig),this.getDb(),this.tableName,i,s,e),this.chart.setI18n(this.i18n);const n=i.pixelPerUnit<=0;this.autoFitScaling(i,s),this.chart.setAvailableHeight(n?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.height)||0),this.pattern=new ee(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}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.setAvailableWidth(this.containerWidth||0),this.chart.setRuleSet(new Ft(this.ruleSetConfig)),this.chart.setConfig(i);const e=i.pixelPerUnit<=0;this.autoFitScaling(i,s),this.chart.setAvailableHeight(e?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.height)||0),this.pattern=new ee(this.chart.styles),this.chart.setPattern("fc",this.pattern.getFCPolygonPattern())}autoFitScaling(t,i){var s;const e=t.pixelPerUnit<=0,n=t.pixelPerPercentage<=0;if(!e&&!n)return;const r=()=>{var i;null===(i=this.reportAutoScaling)||void 0===i||i.call(this,{unit:e?t.pixelPerUnit:void 0,percentage:n?t.pixelPerPercentage:void 0})},a=null===(s=this.parentDimensions)||void 0===s?void 0:s.height,o=this.containerWidth||0,h=()=>{this.chart=new _e(new Ft(this.ruleSetConfig),this.getDb(),this.tableName,t,i,o),this.chart.setI18n(this.i18n)},l=()=>(this.chart.layout(),this.chart.getAllocatedCanvasHeight());if(!a||a<=0)return e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=50),h(),void r();e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=1),h();let c=l();if(c<=0)return void r();const d=Math.max(Bs,.9*a/c);let u=!1,p=!1,f=null;for(let i=0;i<=3;i++){const i=js({target:a,measured:c,unitExtent:e?this.chart.getUnitBarExtent():0,pctExtent:n?this.chart.getPercentBarExtent():0,currentPpu:t.pixelPerUnit,currentPpp:t.pixelPerPercentage});if(void 0===i.ppu&&void 0===i.ppp)break;if(e&&void 0!==i.ppu&&(t.pixelPerUnit=i.ppu,u=!0),n&&void 0!==i.ppp&&(t.pixelPerPercentage=i.ppp,p=!0),h(),c=l(),c<=a+.5&&(f={ppu:t.pixelPerUnit,ppp:t.pixelPerPercentage},c>=.98*a))break}let v=!1;if(e&&!u&&(t.pixelPerUnit=d,v=!0),n&&!p&&(t.pixelPerPercentage=d,v=!0),c>a+.5){if(f)u&&(t.pixelPerUnit=f.ppu),p&&(t.pixelPerPercentage=f.ppp);else{const i=a/c;e&&(t.pixelPerUnit=Math.max(Bs,t.pixelPerUnit*i)),n&&(t.pixelPerPercentage=Math.max(Bs,t.pixelPerPercentage*i))}v=!0}v&&h(),r()}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){var t,i,s;const e=this.getDb(),n=this.tableName?m(this.tableName,this.filter):"";return new ke(new ae,new kt(new Rs),new Rs,new qs,e,n).adapt({scenarios:this.scenarios,variances:this.variances,title:this.chartTitle,hideAxisLabels:this.hideAxisLabels,pixelPerUnit:this.pixelPerUnit,pixelPerPercentage:this.pixelPerPercentage,level:this.level,dateInterval:this.dateInterval,axisLabelsMode:this.axisLabelsMode,limit:this.limit,sortOrder:this.order,leftSideOffsetForHorizontalSync:this.leftSideOffsetForHorizontalSync,intervalSpanLimit:this.intervalSpanLimit,filter:this.filter,measureScale:this.measureScale,measureUnit:this.measureUnit,showMeasureScale:this.showMeasureScale,dataFormatDigits:this.dataFormatDigits,showOverlayMedian:this.showOverlayMedian,showOverlayAvg:this.showOverlayAvg,chartMode:this.chartMode,maxBars:this.maxBars,stackConfig:this.stackConfig,lineFullWidth:this.lineFullWidth,locale:(null===(s=null===(i=null===(t=this.stores)||void 0===t?void 0:t.context)||void 0===i?void 0:i.state)||void 0===s?void 0:s.locale)||"de"})}prepareStyle(){return new he(new Qs,new zt,new Bt(new Ht),new ni(new Ht),new Vt).adapt(this.styles)}get element(){return e(this)}};Pe.style=':host{position:relative;display:inline-block}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-default{stroke:black;stroke-width:0.1em}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}.hide{opacity:0}.footer{margin:0.2em;font-size:0.6em}.footer-hide{display:none}svg#drawCanvas{display:block}';class Te{constructor(t,i,s,e,n,r,a,o,h){this.prefixStyle="prefix",this.isBarChart=!1,this.key=t,this.index=i,this.value=s,this.prefix=r||"",this.cssStyle=e||"",this.prefixStyle=a||"prefix",this.type=n,this.mark=void 0,this.colSpan=o||1,this.measureScale=h||1}getAsHeaderList(){if(null==this.value)return[""];const t=[];for(const i of this.value.toString().split("<br/>"))t.push(i);return t}draw(t){let i=this.value;if("undefined"===i||void 0===i||null==i)return"";if(Number.isNaN(Number(i)))return i;if(""===this.type||void 0===this.type||null==this.type)return i;let s=t.percent,e=t.percent;return"decimal"===this.type&&(i=+i/this.measureScale,s=t.decimal,e=t.decimal),Gt.number(Number(i),this.type,s,e)}drawPrefix(){return null==this.prefix?"":this.prefix}}class Le{constructor(t,i,s){this.index=t,this.groupindex=i,this.type=s,this.cssStyle=this.initCssStyle(),this.elements=[]}initCssStyle(){switch(this.type){case hs.HEADER:return"groupheader";case hs.SEPERATORLINE:return"";case hs.DRILLELEMENT:return"ofit";case hs.PARTELEMENT:return"partof";case hs.STANDARD:return"";case hs.SUM:return"sum";default:return""}}getCells(){return this.elements}createElement(t,i,s,e,n,r,a,o,h,l=!1,c,d=1,u){let p=r;"category"===i&&null!=o&&(p=`category-${o.toString()}`),this.type===hs.HEADER?p="headerlabel":this.type===hs.SEPERATORLINE&&(p=i),this.type===hs.PARTELEMENT&&("percent"===e&&(t="-"),"category"!==i&&"operation"!==i&&(e="percent",p="")),"-"===t&&(p="");let f="prefix-first";a&&(f="prefix-second"),s&&(p=`${p} ${s}`);const v=new Te(i,this.elements.length,t,p,e,n,f,d,h);v.isBarChart=l,v.columnStats=c,v.waterfall=u,this.elements.push(v)}}const Ae=.85;function Ce(t,i){return Math.max(0,(t-.5)*i)}function Ne(t,i){return Math.max(1,(t?1:0)+(i?1:0))}function Ue(t,i,s,e){const n=Ce(t,i),r=Ne(s,e),a=Math.min(2.85*i,n/(2*r)),o=(n-a*r)/r,h=Math.min(.3*i,.2*o),l=.15*o;return{totalWidth:n,labelAreaWidth:a,maxBarWidth:o,axisX:s?a+o:0,breakGap:h,overdriveZoneWidth:l,cutWidth:Math.max(0,o-h-l),labelGap:.3*i}}function De(t,i,s,e){const n=Ce(t,i),r=Ne(s,e),a=Math.min(3.375*i,n/2),o=n-a,h=o/r,l=Math.min(.375*i,.2*h);return{totalWidth:n,labelAreaWidth:a,maxPinLength:Math.max(0,h-l),pinPadding:l,axisX:s?h:0,labelX:o+.3*i}}const Ge={positive:{stroke:"#008f96",fill:"#008f96",fillpattern:"solid"},negative:{stroke:"#ff0000",fill:"#ff0000",fillpattern:"solid"},neutral:{stroke:"#808080",fill:"#808080",fillpattern:"outlined"},scenarios:{ac:{stroke:"#404040",fill:"#404040",fillpattern:"solid"},pp:{stroke:"#A6A6A6",fill:"#A6A6A6",fillpattern:"solid"},fc:{stroke:"#404040",fill:"#ffffff",fillpattern:"hatched"},pl:{stroke:"#404040",fill:"#ffffff",fillpattern:"outlined"}},fontColor:"#000000",fontSize:11.333305,emPx:13.3333,fontFamily:"'Noto Sans', sans-serif",unitScaling:.01,percentageScaling:.5,scaleFactor:1},We="#666666";function Fe(t,i){return`pattern-${t}-${i.replace("#","")}`}const Ie=({styles:t})=>{const s=t.scaleFactor,e=6*s,n=[{id:Fe("pos",t.positive.stroke),stroke:t.positive.stroke,fill:t.positive.fill},{id:Fe("neg",t.negative.stroke),stroke:t.negative.stroke,fill:t.negative.fill},{id:Fe("neu",t.neutral.stroke),stroke:t.neutral.stroke,fill:t.neutral.fill},...["ac","pp","fc","pl"].map((i=>({id:Fe(i,t.scenarios[i].stroke),stroke:t.scenarios[i].stroke,fill:t.scenarios[i].fill})))];return i("defs",null,n.map((t=>i("pattern",{id:t.id,patternUnits:"userSpaceOnUse",width:e,height:e},i("rect",{width:e,height:e,fill:"#ffffff"}),i("line",{x1:"0",y1:e,x2:e,y2:"0",stroke:t.stroke,"stroke-width":1.5*s})))))};function Ye(t,i,s=1){let e,n;const r=t>=0?"+":"";if(i)return e=100*t,r+Math.round(e).toString()+"%";{let i;return e=t/s,n=Math.abs(e),i=n>=1e9?(e/1e9).toFixed(n>=1e10?0:1)+"B":n>=1e6?(e/1e6).toFixed(n>=1e7?0:1)+"M":n>=1e3?(e/1e3).toFixed(n>=1e4?0:1)+"K":e.toFixed(n>=10?0:1),i=i.replace(/\.0([KMB]?)$/,"$1"),r+i}}function ze(t){const i=t.slice(0,2).toLowerCase();return["ac","pp","fc","pl"].includes(i)}function Be(t){const i=t.slice(0,2).toLowerCase();return"pp"===i?"pp":"fc"===i?"fc":"pl"===i?"pl":"ac"}function He(t,i,s,e){return ze(t)?function(t,i){const s=Be(t);return i.scenarios[s]}(t,e):function(t,i,s){const e=t>=0;return i?e?s.positive:s.negative:e?s.negative:s.positive}(i,s,e)}function Ve(t,i){const s=t.fillpattern;return"hatched"===s?`url(#${Fe(i,t.stroke)})`:"outlined"===s?"transparent":t.fill}function je(t){return"outlined"===t.fillpattern?{stroke:t.stroke,strokeWidth:1.5}:{stroke:"none",strokeWidth:0}}const Xe=t=>{const{value:s,scenario:e,columnStats:n,height:r,isPositiveGood:a,formattedValue:o,measureScale:h,columnWidthEm:l=10,styles:c=Ge}=t,d=c.scaleFactor,u=c.fontSize,p=n.min<0,f=n.max>0,{totalWidth:v,axisX:g,breakGap:m,overdriveZoneWidth:b,cutWidth:w,labelGap:y}=Ue(l,c.emPx,p,f),S=Math.abs(s)*c.unitScaling*u,$=S>w,O=Math.max(0,n.absMax*c.unitScaling*u-w),R=Math.max(0,S-w),M=O>0?R/O*b:0,x=2*d,_=r-2*x,E=x,k=s>=0,P=He(e,s,a,c),T=Ve(P,ze(e)?Be(e):a?k?"pos":"neg":k?"neg":"pos"),{stroke:L,strokeWidth:A}=je(P),C=o||Ye(s,!1,h),N=$?w:S,U=$?w+m+M:S,D=k?g+U+y:g-U-y,G=k?"start":"end";return i("svg",{width:v,height:r,class:"cell-bar-chart absolute-variance",style:{overflow:"visible"}},i(Ie,{styles:c}),i("line",{x1:g,y1:0,x2:g,y2:r,stroke:We,"stroke-width":1*d}),N>0&&i("rect",{x:k?g:g-N,y:E,width:N,height:_,fill:T,stroke:L,"stroke-width":A*d}),$&&M>0&&i("rect",{x:k?g+w+m:g-w-m-M,y:E,width:M,height:_,fill:T,stroke:L,"stroke-width":A*d}),$&&function(t,s,e,n,r){const a=t+s/2,o=.35*s,h=n/3,l=.3*s;let c=`M ${a-o} ${e}`;for(let t=0;t<3;t++)c+=` L ${a-o-l} ${e+h*(t+.5)} L ${a-o} ${e+h*(t+1)}`;let d=`M ${a+o} ${e}`;for(let t=0;t<3;t++)d+=` L ${a+o+l} ${e+h*(t+.5)} L ${a+o} ${e+h*(t+1)}`;return[i("rect",{x:t,y:e-1,width:s,height:n+2,fill:"#ffffff"}),i("path",{d:c,fill:"none",stroke:"#000000","stroke-width":1*r}),i("path",{d,fill:"none",stroke:"#000000","stroke-width":1*r})]}(k?g+w:g-w-m,m,E,_,d),i("text",{x:D,y:r/2,dy:"0.35em","text-anchor":G,fill:c.fontColor,"font-size":u,"font-family":c.fontFamily},C))},Je=t=>{const{value:s,scenario:e,columnStats:n,height:r,isPositiveGood:a,formattedValue:o,measureScale:h,columnWidthEm:l=10,styles:c=Ge}=t,d=c.scaleFactor,u=c.fontSize,p=n.min<0,f=n.max>0,{totalWidth:v,maxPinLength:g,axisX:m,labelX:b}=De(l,c.emPx,p,f),w=r/2,y=100*Math.abs(s)*c.percentageScaling*u,S=y>g,$=Math.min(y,g),O=s>=0,R=O?m+$:m-$,M=He(e,s,a,c),x=3*d,_=o||Ye(s,!0,h);return i("svg",{width:v,height:r,class:"cell-bar-chart relative-variance",style:{overflow:"visible"}},i("line",{x1:m,y1:0,x2:m,y2:r,stroke:We,"stroke-width":1*d}),!S&&i("circle",{cx:R,cy:w,r:x,fill:c.fontColor}),i("line",{x1:m,y1:w,x2:R,y2:w,stroke:M.fill,"stroke-width":2*d}),S&&O&&i("polygon",{points:`${m+g},${w} ${m+g-6*d},${w-3*d} ${m+g-6*d},${w+3*d}`,fill:M.fill}),S&&!O&&i("polygon",{points:`${m-g},${w} ${m-g+6*d},${w-3*d} ${m-g+6*d},${w+3*d}`,fill:M.fill}),i("text",{x:b,y:r/2,dy:"0.35em","text-anchor":"start",fill:c.fontColor,"font-size":u,"font-style":"italic","font-family":c.fontFamily},_))},qe=t=>{const{value:s,columnStats:e,isRelative:n,styles:r=Ge}=t;return null==s||isNaN(s)||!e||0===e.absMax?i("span",{class:"bar-chart-empty",style:{color:r.fontColor,fontStyle:"italic"}},"-"):i(n?Je:Xe,Object.assign({},t))},Ze=t=>{const{value:s,scenario:e,height:n,measureScale:r,columnWidthEm:a=10,styles:o=Ge,waterfall:h}=t,l=o.scaleFactor,c=o.fontSize,d=h.max-h.min;if(null==s||isNaN(s)||d<=0)return i("span",{class:"bar-chart-empty",style:{color:o.fontColor,fontStyle:"italic"}},"-");const{totalWidth:u,labelAreaWidth:p,barAreaWidth:f,labelGap:v}=function(t,i){const s=Ce(t,i),e=Math.min(2.85*i,s/4);return{totalWidth:s,labelAreaWidth:e,barAreaWidth:s-2*e,labelGap:.3*i}}(a,o.emPx),g=f/d,m=t=>p+(t-h.min)*g,b=2*l,w=n-2*b,y=b,S=m(0),$=m(h.start),O=m(h.end),R=Math.min($,O),M=Math.abs(O-$),x=He(e,s,!1,o),_=Ve(x,Be(e)),{stroke:E,strokeWidth:k}=je(x),P=Ye(s,"partof"===h.kind,r).replace(/^\+/,""),T=O<$,L=T?R-v:R+M+v,A=T?"end":"start";return i("svg",{width:u,height:n,class:"cell-bar-chart waterfall-bar",style:{overflow:"visible"}},i(Ie,{styles:o}),i("line",{x1:S,y1:0,x2:S,y2:n,stroke:We,"stroke-width":1*l}),void 0!==h.parentStart&&void 0!==h.parentEnd&&i("line",{x1:m(h.parentStart),y1:0,x2:m(h.parentStart),y2:n,stroke:We,"stroke-width":1*l,"stroke-dasharray":`${2*l},${2*l}`}),void 0!==h.parentStart&&void 0!==h.parentEnd&&i("line",{x1:m(h.parentEnd),y1:0,x2:m(h.parentEnd),y2:n,stroke:We,"stroke-width":1*l,"stroke-dasharray":`${2*l},${2*l}`}),M>0&&i("rect",{x:R,y,width:M,height:w,fill:_,stroke:E,"stroke-width":k*l}),i("text",{x:L,y:n/2,dy:"0.35em","text-anchor":A,fill:o.fontColor,"font-size":c,"font-family":o.fontFamily},P))};class Ke{constructor(t){this.groups=[jt.CATEGORY,jt.CATEGORYINDEX],as.OPT!==t.type&&as.OPTNOTOTAL!==t.type||this.groups.unshift(jt.OPERATION),t.grouped&&(this.groups.push(jt.ROWGROUP),this.groups.push(jt.ROWGROUPINDEX))}toString(){return this.groups.map((t=>`${t}`)).toString()}noCategory(){return this.groups.filter((t=>t!==jt.CATEGORY))}toArray(){return this.groups}}class Qe{constructor(t,i){this.hasPartOf=!1,this.config=t,this.i18n=i}execute(t,i){var s;this.db=t,this.fromExpr=i;const e=[],n=[],r=[],a=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),o=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),h=this.getRelativeScenarios(),l=this.config.attributes.map((t=>this.translateAttributeSQL(t))).toString(),c=new Ke(this.config),d=this.config.grouped?[jt.ROWGROUP,jt.ROWGROUPINDEX]:[];let u,p=["",""];this.config.sortOrder.hierarchy.length>0&&(p=this.createOrderString(this.config.sortOrder)),this.hasPartOf=this.checkConfigForPartOf();try{u=t.exec(`SELECT COUNT(DISTINCT ${jt.CATEGORY}) as ${jt.TOTALROWCOUNT} ${d.length>0?","+d:""}\n FROM ${i} ${d.length>0?"GROUP BY "+d:""}\n ORDER BY ${p[0]}`)}catch(t){return console.error("DataQuery: meta query failed",t),[]}return 0===u.length||1===u.length&&0===(null!==(s=u[0][jt.TOTALROWCOUNT])&&void 0!==s?s:0)&&0===d.length?[]:(u.forEach((t=>{const i=t.rowGroup&&t.rowGroup.length>0?`WHERE ${jt.ROWGROUP} = '${t.rowGroup}'`:"";let s="";this.config.limit&&(s=`LIMIT ${this.config.limit}`),this.createGroupHeaderRow(t,e),this.createDataRow(e,t,c,a,l,i,p,s),this.createRestRow(t,e,c,a,i,p),this.createGroupSumRow(e,n,t,o,p)})),this.createTotalSumRow(e,n,o),e.forEach((i=>{try{r.push(t.exec(i))}catch(t){console.error("DataQuery: SQL query execution failed",i,t)}})),this.detectNaNCells(this.config.scenarios,r),this.createThereOfDrillRows(a,l,p,r),this.createPartOfDrillRows(a,p,n,r),this.createIntervalColumns(r),this.createThereOfDrillColumns(this.config.categoryThereOf,r),this.calculateColumnGroupRest(r,this.config.categoryThereOf),this.calculateRelativeVariances(r,h),r)}detectNaNCells(t,i){i.forEach((i=>{i.map((i=>(t.forEach((t=>{const s=new Yt(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)))}))}createPartOfDrillRows(t,i,s,e){if(null==this.config.partOf||0===this.config.partOf.length||this.config.type===as.LIST)return;const n=this.createPartOfQuery(t,i);let r=[];const a=this.db;n.forEach((function(t){r.push(...a.exec(t))}));const o=this.exctractScenarioNames(t),h=[];s.forEach((function(t){h.push(...a.exec(t))}));const l=new Map;h.forEach((t=>l.set(t[jt.ROWGROUP],t))),r=this.reduceResDrillByCategoryGroups(r,o),r.forEach((function(t){o.forEach((i=>{try{t[i]=t[i]/l.get(t[jt.ROWGROUP])[i]}catch(s){console.error("DataQuery: partOf drill row calculation failed",i,s),t[i]=Number.NaN}}))})),this.injectDrillRowsToResultRows(r,e)}createRestRow(t,i,s,e,n,r){if(t.totalRowCnt-this.config.limit>0&&0!==this.config.limit){const a=this.exctractScenarioNames(e).map((t=>`SUM(${t}) as ${t}`)).join(", ");i.push(`SELECT ${jt.ROWNR}, 1 as ${jt.ROWGROUPINDEX} , 'ENTRY' as ${jt.TYPE}, 'NO_GROUP' as ${jt.ROWGROUP}, 'REST' as ${jt.CATEGORY} ${a.length>0?", "+a:""} FROM (SELECT ROWNUM() AS ${jt.ROWNR}, ${i.length} as ${jt.ROWGROUPINDEX} , 'ENTRY' as ${jt.TYPE}, '${t.rowGroup||"NO_GROUP"}' as ${jt.ROWGROUP}, ${s} ${e.length>0?",".concat(e):""} FROM ${this.fromExpr} ${n} GROUP BY ${s} ORDER BY ${r[0]}) t WHERE t.rowNr > ${this.config.limit}`)}}createDataRow(t,i,s,e,n,r,a,o){t.push(`SELECT ROWNUM() AS ${jt.ROWNR},\n ${t.length} as ${jt.ROWGROUPINDEX},\n 'ENTRY' as ${jt.TYPE},\n '${i.rowGroup||"NO_GROUP"}' as ${jt.ROWGROUP},\n '${jt.CATEGORYINDEX}',\n ${s} ${e.length>0?",".concat(e):""} ${n.length>0?",".concat(n):""}\n FROM ${this.fromExpr} ${r}\n GROUP BY ${s}\n ORDER BY ${a[0]} ${o}`)}createGroupHeaderRow(t,i){!0===this.config.grouped&&i.push(`SELECT ROWNUM() AS ${jt.ROWNR},\n ${i.length} as ${jt.ROWGROUPINDEX},\n 'GROUPHEAD' as ${jt.TYPE},\n '${t.rowGroup}' as ${jt.ROWGROUP} ${this.config.showGroupTitle?`,'${t.rowGroup}' as ${jt.CATEGORY}`:""}\n FROM ${this.fromExpr}\n GROUP BY '1'`)}createGroupSumRow(t,i,s,e,n){!0!==this.config.grouped||as.SUM!==this.config.type&&as.SUMNOTOTAL!==this.config.type&&as.OPT!==this.config.type&&as.OPTNOTOTAL!==this.config.type||(t.push(`SELECT ${t.length} as ${jt.ROWGROUPINDEX},\n '=' as ${jt.OPERATION},\n '${s.rowGroup}' as ${jt.ROWGROUP},\n ROWNUM() AS ${jt.ROWNR},\n 'GROUP_SUM' as ${jt.TYPE} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr}\n WHERE ${jt.ROWGROUP} = '${s.rowGroup}'\n ORDER BY ${n[0]} `),i.push(`SELECT ${t.length} as ${jt.ROWGROUPINDEX},\n '=' as ${jt.OPERATION},\n '${s.rowGroup}' as ${jt.ROWGROUP},\n ROWNUM() AS ${jt.ROWNR},\n 'GROUP_SUM' as ${jt.TYPE} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr}\n WHERE ${jt.ROWGROUP} = '${s.rowGroup}'\n ORDER BY ${n[0]} `))}createTotalSumRow(t,i,s){var e;if(as.SUM===this.config.type||as.OPT===this.config.type){const i=(null===(e=this.config.title)||void 0===e?void 0:e.trim())||"SUM_TOTAL",n=this.hasPartOf&&!1===this.config.grouped&&"SUM_TOTAL"!==i?`${this.i18n.get("SUM_TOTAL")||"SUM_TOTAL"} ${i}`:i;t.push(`SELECT ${t.length} as ${jt.ROWGROUPINDEX},\n '${n}' as ${jt.ROWGROUP},\n '=' as ${jt.OPERATION},\n 'SUM' as ${jt.TYPE} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr} `)}i.push(`SELECT ${t.length} as ${jt.ROWGROUPINDEX},\n 'SUM_TOTAL' as ${jt.ROWGROUP},\n '=' as ${jt.OPERATION},\n 'SUM' as ${jt.TYPE} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr} `)}reduceResDrillByCategoryGroups(t,i){const s=new Map;return t.forEach((function(t){const e=t.rowNr+t.rowGroup+t.type+t.category;if(s.has(e)){const n=s.get(e);i.forEach((i=>{try{n[i]+=t[i]}catch(t){console.error("DataQuery: drill row aggregation failed",i,t)}}))}else s.set(e,t)})),[...s.values()]}injectDrillRowsToResultRows(t,i){const s=new Map;if(!0===this.config.grouped)t.forEach((function(t){i.forEach((function(i){const e=i.findIndex((i=>i.category===t.category&&i.rowGroup===t.rowGroup));if(e>=0){if(s.has(`${t.category}_${t.rowGroup}`)){const i=s.get(`${t.category}_${t.rowGroup}`)||0;s.set(`${t.category}_${t.rowGroup}`,i+1)}else s.set(`${t.category}_${t.rowGroup}`,1);t[jt.ROWNR]=s.get(`${t.category}_${t.rowGroup}`),i.splice(e+t[jt.ROWNR],0,t)}}))}));else{const e=this.findDuplicateSubCategories(t);t.forEach((function(t){i.forEach((function(i){const n=i.findIndex((i=>null!=i.category&&i.category===t.category));if(n>=0){if(s.has(`${t.category}`)){const i=s.get(`${t.category}`)||0;s.set(`${t.category}`,i+1)}else s.set(`${t.category}`,1);(1===t[jt.ROWNR]||e.includes(t.subCategory))&&(t.subCategory=`${t.subCategory} (${t.rowGroup})`),i.splice(n+t[jt.ROWNR],0,t)}}))}))}}createThereOfDrillRows(t,i,s,e){if(void 0===this.config.thereOf||0===this.config.thereOf.length)return;const n=[],r=[];this.config.thereOf.forEach((e=>{let r=!0,a="1 <> 1 OR ( ";null!=e.category&&0!==e.category.length&&e.category.trim()&&(a+=` ${jt.CATEGORY} = '${e.category}'`,r=!1),null!=e.rowGroup&&0!==e.rowGroup.length&&e.rowGroup.trim()&&(a+=` ${r?"":"AND"} ${jt.ROWGROUP} = '${e.rowGroup}'`,r=!1),null!=e.subCategory&&0!==e.subCategory.length&&e.subCategory.trim()&&(a+=` ${r?"":"AND"} ${jt.SUBCATEGORY} = '${e.subCategory}'`),a+=")",n.push(`SELECT ROWNUM() AS ${jt.ROWNR},\n null as operation,\n 'DRILLELEMENT' as ${jt.TYPE},\n ${jt.CATEGORY},\n ${jt.SUBCATEGORY},\n ${jt.ROWGROUP} as ${jt.ROWGROUP},\n ${t} ${i.length>0?",".concat(i):""}\n FROM ${this.fromExpr}\n WHERE ${a}\n GROUP BY ${jt.ROWGROUP}, ${jt.CATEGORY}, ${jt.SUBCATEGORY}\n ORDER BY ${s[1]}`)}));const a=this.db;n.forEach((function(t){r.push(...a.exec(t))})),this.injectDrillRowsToResultRows(r,e)}calculateRelativeVariances(t,i){t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[jt.TYPE]&&i.forEach(((i,s)=>{t[s]=t[s]/t[i]}))}))}))}calculateColumnGroupRest(t,i){if(null==i||0===i.size)return;const s=new Map,e=new Map;i.forEach(((t,i)=>{const n=t,r=[];for(const t of n)r.push(`${i}##${t.name}`);s.set(i,r),e.set(`${i}##REST`,!1)})),t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[jt.TYPE]&&s.forEach(((i,s)=>{let n=0;i.forEach((i=>{void 0!==t[i]&&(n+=t[i])})),t[`${s}##REST`]=t[s]-n,0!==t[`${s}##REST`]&&e.set(`${s}##REST`,!0)}))}))}));const n=Array.from(e.entries()).filter((([t,i])=>!i)).map((([t])=>t));t.forEach((t=>{t.forEach((t=>{for(const i of n)delete t[i]}))}))}createIntervalColumns(t){var i,s,e,n,r;if(this.config.interval===ls||this.config.categoryThereOf.size>0||0===this.config.scenarios.length)return;const a="##",o=`(SELECT *, ${ds(this.config.interval)} as __interval FROM ${this.fromExpr}) as p`,h=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),l=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),c=this.exctractScenarioNames(h),d=this.getRelativeScenarios(),u=new Ke(this.config),p=as.OPT===this.config.type||as.OPTNOTOTAL===this.config.type,f=this.config.grouped&&(as.SUM===this.config.type||as.SUMNOTOTAL===this.config.type||as.OPT===this.config.type||as.OPTNOTOTAL===this.config.type),v=this.checkConfigForPartOf()&&this.config.type!==as.LIST,g=t=>{try{return this.db.exec(t)}catch(i){return console.error("DataQuery: interval query failed",t,i),[]}},m=t=>(this.config.scenarios.forEach((i=>{const s=new Yt(i);!0===s.isValid?0!==t[s.base+"_cnt"]&&0!==t[s.delta+"_cnt"]||(t[i]=Number.NaN):0===t[i+"_cnt"]&&(t[i]=Number.NaN)})),d.forEach(((i,s)=>{t[s]=t[s]/t[i]})),t),b=(t,i,s)=>{for(const e of this.config.scenarios)t[e+a+s]=i[e]},w=g(`SELECT ${u}, __interval ${h.length>0?",".concat(h):""}\n FROM ${o}\n GROUP BY ${u}, __interval`);if(this.config.limit>0)for(let e=0;e<t.length;e++){const n=t[e].find((t=>"ENTRY"===t.type&&"REST"===t.category));if(!n)continue;let r;for(let i=e-1;i>=0&&!r;i--){const s=t[i].filter((t=>"ENTRY"===t.type&&"REST"!==t.category));s.length>0&&(r=s)}if(!r)continue;const a=new Set(r.map((t=>t.category))),o=r[0].rowGroup,h=new Map;for(const t of w){if(this.config.grouped&&t.rowGroup!==o)continue;if(a.has(t.category))continue;const e=us(t.__interval);let n=h.get(e);n||(n={},h.set(e,n));for(const e of c)n[e]=(null!==(i=n[e])&&void 0!==i?i:0)+(null!==(s=t[e])&&void 0!==s?s:0)}h.forEach(((t,i)=>{b(n,m(t),i)}))}for(const i of w){const s=us(i.__interval);m(i);for(const e of t)for(const t of e)"ENTRY"===t.type&&"REST"!==t.category&&t.category===i.category&&(this.config.grouped&&t.rowGroup!==i.rowGroup||p&&t.operation!==i.operation||b(t,i,s))}const y=f||v&&this.config.grouped?g(`SELECT ${jt.ROWGROUP}, __interval ${l.length>0?",".concat(l):""}\n FROM ${o}\n GROUP BY ${jt.ROWGROUP}, __interval`):[],S=new Map;if(y.forEach((t=>S.set(`${t.rowGroup}${a}${us(t.__interval)}`,t))),f)for(const i of y){const s=us(i.__interval),e=m(Object.assign({},i));for(const n of t)for(const t of n)"GROUP_SUM"===t.type&&t.rowGroup===i.rowGroup&&b(t,e,s)}const $=as.SUM===this.config.type||as.OPT===this.config.type,O=$||v&&!this.config.grouped?g(`SELECT __interval ${l.length>0?",".concat(l):""}\n FROM ${o}\n GROUP BY __interval`):[],R=new Map;if(O.forEach((t=>R.set(us(t.__interval),t))),$)for(const i of O){const s=us(i.__interval),e=m(Object.assign({},i));for(const i of t)for(const t of i)"SUM"===t.type&&b(t,e,s)}if(null!=this.config.thereOf&&this.config.thereOf.length>0){const i=[];this.config.thereOf.forEach((t=>{i.push(...g(`SELECT ${jt.ROWGROUP}, ${jt.CATEGORY}, ${jt.SUBCATEGORY}, __interval ${h.length>0?",".concat(h):""}\n FROM ${o}\n WHERE ${this.createThereOfWhereClause(t)}\n GROUP BY ${jt.ROWGROUP}, ${jt.CATEGORY}, ${jt.SUBCATEGORY}, __interval`))}));for(const s of i){const i=us(s.__interval);m(s);for(const e of t)for(const t of e)"DRILLELEMENT"===t.type&&t.category===s.category&&(t.subCategory!==s.subCategory&&t.subCategory!==`${s.subCategory} (${s.rowGroup})`||b(t,s,i))}}if(v){let i="1 <> 1 ";null===(e=this.config.partOf)||void 0===e||e.forEach((t=>{i+=`OR (${jt.CATEGORY} = '${t.category}'`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(i+=`and ${jt.ROWGROUP} = '${t.rowGroup}'`),i+=")"}));const s=g(`SELECT ${jt.CATEGORY}, ${this.config.grouped?`${jt.ROWGROUP}`:`'SUM_TOTAL' as ${jt.ROWGROUP}`}, __interval ${h.length>0?",".concat(h):""}\n FROM ${o}\n WHERE ${i}\n GROUP BY ${jt.ROWGROUP}, ${jt.CATEGORY}, __interval`),l=new Map;for(const t of s){const i=`${t.rowGroup}${a}${t.category}${a}${us(t.__interval)}`,s=l.get(i);if(s)for(const i of c)s[i]=(null!==(n=s[i])&&void 0!==n?n:0)+(null!==(r=t[i])&&void 0!==r?r:0);else l.set(i,t)}l.forEach((i=>{const s=us(i.__interval),e=this.config.grouped?S.get(`${i.rowGroup}${a}${s}`):R.get(s);for(const t of c)i[t]=i[t]/(e?e[t]:Number.NaN);m(i);for(const e of t)for(const t of e)"PARTELEMENT"===t.type&&t.category===i.category&&t.rowGroup===i.rowGroup&&b(t,i,s)}))}}createThereOfWhereClause(t){let i=!0,s="1 <> 1 OR ( ";return null!=t.category&&0!==t.category.length&&t.category.trim()&&(s+=` ${jt.CATEGORY} = '${t.category}'`,i=!1),null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(s+=` ${i?"":"AND"} ${jt.ROWGROUP} = '${t.rowGroup}'`,i=!1),null!=t.subCategory&&0!==t.subCategory.length&&t.subCategory.trim()&&(s+=` ${i?"":"AND"} ${jt.SUBCATEGORY} = '${t.subCategory}'`),s+")"}getRelativeScenarios(){const t=new Map;return this.config.scenarios.forEach((i=>{const s=this.createRelativeScenario(i);null!=s&&t.set(s.key,s.value)})),t}translateScenarioSQL(t,i,s){const e=new Yt(t);return as.OPT===s||as.OPTNOTOTAL===s?e.isValid?"dr"===e.type?`SUM(${e.base} - ${e.delta}) as ${t}, SUM(${e.delta}) as dr_${e.delta}`:`SUM(${e.base} - ${e.delta}) as ${t}`:i?`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`:`SUM(${t}) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`:e.isValid?"dr"===e.type?`SUM((${e.base} * transformOperator(operation)) - (${e.delta} * transformOperator(operation))) as ${t}, SUM(${e.delta} * transformOperator(operation)) as dr_${e.delta}`:`SUM((${e.base} * transformOperator(operation))- (${e.delta} * transformOperator(operation))) as ${t}`:`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}translateAttributeSQL(t){const i=`[${t.arg}]`,s=/^(ac|pp|fc|pl)[1-4]$/.test(t.arg)&&this.config.type!==as.OPT&&this.config.type!==as.OPTNOTOTAL;switch(t.fn){case"set":return`SETAGG(${i}) as ${t.alias}`;case"first":return`FIRST(${i}) as ${t.alias}`;case"last":return`LAST(${i}) as ${t.alias}`;case"min":return`MIN(${i}) as ${t.alias}`;case"max":return`MAX(${i}) as ${t.alias}`;case"avg":return s?`AVG(${i} * transformOperator(operation)) as ${t.alias}`:`AVG(${i}) as ${t.alias}`;case"sum":return s?`SUM(${i} * transformOperator(operation)) as ${t.alias}`:`SUM(${i}) as ${t.alias}`;case"lit":return`${this.sqlLiteral(t.arg)} as ${t.alias}`}}sqlLiteral(t){return""===t||Number.isNaN(Number(t))?`'${t.replace(/'/g,"''")}'`:t}createOrderString(t){return[`${t.hierarchy.toString()} ${t.direction}`,`${t.hierarchy.toString()} ${os.ASC===t.direction?os.DESC:os.ASC}`]}createRelativeScenario(t){const i=new Yt(t);return i.isValid&&"dr"===i.type?{key:`${t}`,value:`dr_${i.delta}`}:null}exctractScenarioNames(t){const i=[];return t.split(",").forEach((t=>t.length>=2?i.push(t.split("as")[1].trim()):null)),i}findDuplicateSubCategories(t){const i=t.map((t=>({count:1,subCategory:t.subCategory}))).reduce(((t,i)=>(t[i.subCategory]=(t[i.subCategory]||0)+i.count,t)),{});return Object.keys(i).filter((t=>i[t]>1))}createPartOfQuery(t,i){var s;const e=[];let n="1 <> 1 ",r=` ${jt.ROWGROUP}`,a="ROWNUM()";return null===(s=this.config.partOf)||void 0===s||s.forEach((t=>{n+=`OR (${jt.CATEGORY} = '${t.category}'`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(n+=`and ${jt.ROWGROUP} = '${t.rowGroup}'`),!1===this.config.grouped&&(r=` 'SUM_TOTAL' as ${jt.ROWGROUP} `,a="1"),n+=")"})),e.push(`SELECT ${a} AS ${jt.ROWNR},\n 'PARTELEMENT' as ${jt.TYPE},\n ${jt.CATEGORY},\n ${r},\n ${t}\n FROM ${this.fromExpr}\n WHERE ${n}\n GROUP BY ${jt.ROWGROUP}, ${jt.CATEGORY}, ${jt.TYPE}\n ORDER BY ${i[1]}`),e}checkConfigForPartOf(){return null!=this.config.partOf&&0!==this.config.partOf.length}createThereOfDrillColumns(t,i){if(null==t||0===t.size)return;const s=[],e=[],n=this.fromExpr;t.forEach(((t,i)=>{let e="1 <> 1 ";t.forEach((t=>{e+=` or columnGroup = '${t.name}' `})),s.push(`SELECT 'ENTRY' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, columnGroup, scenario`),s.push(`SELECT 'ENTRY' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, scenario`),s.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, columnGroup, scenario`),s.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, columnGroup, scenario`),s.push(`SELECT 'SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, columnGroup, columnSubGroup, scenario`)}));for(const t of s)e.push(...this.db.exec(t));this.injectDrillColumnsToResultRows(e,i)}injectDrillColumnsToResultRows(t,i){const s="##";for(const e of t)for(const t of i)for(const i of t)i.type===e.rowlevel&&("ENTRY"===e.rowlevel?"COLUMNGROUP"===e.columnlevel&&i.category===e.category?i[e.scenario+s+e.columnGroup]=e.val:"SUBGROUP"===e.columnlevel&&i.category===e.category&&(i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val):"DRILLELEMENT"===e.rowlevel?"COLUMNGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory?i[e.scenario+s+e.columnGroup]=e.val:"SUBGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory?i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val:"COLUMNGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===`${e.subCategory} (${e.rowGroup})`?i[e.scenario+s+e.columnGroup]=e.val:"SUBGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===`${e.subCategory} (${e.rowGroup})`&&(i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val):("SUM"===e.rowlevel||"GROUP_SUM"===e.rowlevel)&&("COLUMNGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory&&(i[e.scenario+s+e.columnGroup]=e.val),"SUBGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory&&(i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val)))}}class tn{constructor(){this.geometry=new Map}set(t,i,s){let e=this.geometry.get(t);e||(e=new Map,this.geometry.set(t,e)),e.set(i,s)}get(t,i){var s;return null===(s=this.geometry.get(t))||void 0===s?void 0:s.get(i)}}function sn(t,i,s){const e=t[i];if(null==e)return null;const n=Number(e);return isNaN(n)?null:s!==as.OPT&&s!==as.OPTNOTOTAL||t[jt.TYPE]!==hs.ENTRY||"-"!==t[jt.OPERATION]?n:-n}class en{constructor(){this.normalizedHeader=[],this.attributesByAlias=new Map}getNormalizedHeader(){return this.normalizedHeader}createHeader(t,i,s,e,n,r,a=[]){const o=[];this.attributesByAlias=new Map(a.map((t=>[t.alias,t]))),this.normalizedHeader=this.normalizeHeader(t,i,a);const h=this.normalizedHeader.some((t=>void 0!==t.bucket));h&&o.push(this.createIntervalBandRow());const l=new Le(h?1:0,0,hs.HEADER),c=new Le(h?2:1,0,hs.SEPERATORLINE);for(const t of this.normalizedHeader){const i=this.attributesByAlias.get(t.name);l.createElement(i?s.get(i.label)||i.label:Gt.translateScenarioLabel(t.name,s),t.type,this.createColumnType(t),null,this.setHeaderPrefix(t,s,e,n,r),null,null,null,null),c.createElement(null,t.type,this.createColumnType(t),null,null,null,null,null,null)}return o.push(l),o.push(c),o}createIntervalBandRow(){const t=new Le(0,0,hs.HEADER);let i=0;for(;i<this.normalizedHeader.length;){const s=this.normalizedHeader[i];if(void 0===s.bucket){t.createElement(null,s.type,"filler",null,null,null,null,null,null),i+=1;continue}let e=1;for(;i+e<this.normalizedHeader.length&&this.normalizedHeader[i+e].bucket===s.bucket;)e+=1;t.createElement(s.bucketLabel,s.type,"intervalGroup",null,null,null,null,null,null,!1,void 0,e),i+=e}return t}setHeaderPrefix(t,i,s,e,n){let r="";return"category"===t.name&&n&&(0===s.prefix.length&&0===e.length||(r=Gt.translateScenarioLabel("in",i)+" "+s.prefix+e)),t.order&&(r+=Gt.translateScenarioLabel("ORDER_"+t.order,i)),r}normalizeHeader(t,i,s){let e=[{name:jt.CATEGORY,group:jt.CATEGORY,type:jt.CATEGORY,order:void 0}];as.OPT!==t&&as.OPTNOTOTAL!==t||(e=[{name:jt.OPERATION,group:jt.OPERATION,type:jt.OPERATION,order:void 0},{name:jt.CATEGORY,group:jt.CATEGORY,type:jt.CATEGORY,order:void 0}]);const n=s.map((t=>({name:t.alias,group:t.alias,type:t.alias,order:void 0})));return[...e,...n,...i]}createBodyRows(t,i,s,e){var n;const r=[];let a=-1;const o=new Qe(t,i).execute(s,e),h=this.calculateColumnStatistics(o,t.barColumns,t.interval!==ls),l=(null!==(n=t.barColumns)&&void 0!==n?n:[]).filter((t=>t.toUpperCase().trim()in Mt)),c=l.length>0&&t.interval===ls&&0===t.categoryThereOf.size&&function(t){for(const i of t)for(const t of i){const i=t[jt.TYPE];if(i===hs.SUM||i===hs.GROUPSUM||i===hs.DRILLELEMENT||i===hs.PARTELEMENT)return!0}return!1}(o)?function(t,i,s){const e=new tn;for(const n of i){let i,r=0,a=0;const o=[],h=(t,i)=>{o.push(i),e.set(t,n,i)};for(const e of t)for(const t of e){const e=t[jt.TYPE];if(e===hs.GROUPHEAD){i=void 0;continue}const o=sn(t,n,s);if(e===hs.ENTRY){if(null===o){i=void 0;continue}h(t,{start:r,end:r+o,min:0,max:0,kind:"cascade"}),i={start:r,end:r+o},a=i.start,r+=o}else if(e===hs.SUM||e===hs.GROUPSUM){if(null===o){i=void 0;continue}h(t,{start:0,end:o,min:0,max:0,kind:"anchor"}),i={start:0,end:o},a=0,r=o}else if(e===hs.DRILLELEMENT){if(null===o||void 0===i)continue;const s=a+(Math.sign(i.end-i.start)||1)*Math.abs(o);h(t,{start:a,end:s,min:0,max:0,kind:"thereof",parentStart:i.start,parentEnd:i.end}),a=s}else if(e===hs.PARTELEMENT){if(null===o||void 0===i)continue;const s=a+o*(i.end-i.start);h(t,{start:a,end:s,min:0,max:0,kind:"partof",parentStart:i.start,parentEnd:i.end}),a=s}}let l=0,c=0;for(const t of o)l=Math.min(l,t.start,t.end),c=Math.max(c,t.start,t.end);for(const t of o)t.min=l,t.max=c}return e}(o,l,t.type):void 0;for(const s of o)a+=1,r.push(...this.createRow(t.i18n,i,t.scenariosUnitType,s,a,-1,t.categoryWidth,t.measureScale,t.barColumns,h,c));return r}calculateColumnStatistics(t,i,s=!1){const e=new Map;if(!i||0===i.length)return e;const n=new Map;for(const t of i)e.set(t,{min:1/0,max:-1/0,absMax:0,median:0}),n.set(t,[]);for(const r of t)for(const t of r)for(const r of i){const i=s?this.extractIntervalColumnValues(t,r):[this.extractColumnValue(t,r)];for(const t of i)if(null!==t&&!isNaN(t)){const i=e.get(r);i.min=Math.min(i.min,t),i.max=Math.max(i.max,t),n.get(r).push(Math.abs(t))}}for(const[t,i]of e){i.min!==1/0&&i.max!==-1/0||(i.min=0,i.max=0),i.absMax=Math.max(Math.abs(i.min),Math.abs(i.max));const s=n.get(t);if(s.length>0){s.sort(((t,i)=>t-i));const t=Math.floor(s.length/2);i.median=s.length%2==0?(s[t-1]+s[t])/2:s[t]}e.set(t,i)}return e}extractIntervalColumnValues(t,i){const s=i+"##",e=[];for(const i of Object.keys(t))if(i.startsWith(s)){const s=Number(t[i]);e.push(isNaN(s)?null:s)}return e}extractColumnValue(t,i){if(void 0!==t[i]){const s=Number(t[i]);return isNaN(s)?null:s}for(const s of Object.keys(t))if(s===i||s.endsWith("##"+i)||s===i+"##"+i){const i=Number(t[s]);if(!isNaN(i))return i}return null}createRow(t,i,s,e,n,r,a,o,h,l,c){var d;const u=[];for(const p of e){const f=p[jt.ROWGROUP],v=p[jt.SUBCATEGORY],g=p[jt.TYPE],m=p[jt.ROWNR]>=2,b=this.createDetailRow(g,r+=1,n,e.length);for(const e of this.normalizedHeader){const n=this.getRawDataRowElement(p,e),r=null!==(d=null==h?void 0:h.includes(e.type))&&void 0!==d&&d,u=r?null==l?void 0:l.get(e.type):void 0,w=r&&void 0===e.bucket&&e.name===e.group&&e.name===e.type?null==c?void 0:c.get(p,e.type):void 0;b.createElement(this.translateSumCellLabel(t,i,n,f,v,g,e.type),e.type,this.createColumnType(e),this.setCellType(e.type,s),this.translateCellPrefix(i,g,e.type),this.translateScenarioCSS(e.type,n),m,a,null==o?void 0:o.value,r,u,1,w)}u.push(b)}return u}getRawDataRowElement(t,i){return void 0!==i.bucket?t[i.type+"##"+i.bucket]:i.name===i.group&&i.name===i.type?t[i.name]:i.name===i.group&&i.name!==i.type?t[i.type+"##"+i.name]:t[i.type+"##"+i.group+"##"+i.name]}createDetailRow(t,i,s,e){switch(t){case hs.GROUPHEAD:return new Le(i,s,hs.HEADER);case hs.SUM:case hs.GROUPSUM:return new Le(e+2,s,hs.SUM);case hs.DRILLELEMENT:return new Le(e+2,s,hs.DRILLELEMENT);case hs.PARTELEMENT:return new Le(e+2,s,hs.PARTELEMENT);default:return new Le(i,s,hs.STANDARD)}}translateSumCellLabel(t,i,s,e,n,r,a){return this.attributesByAlias.has(a)||!1===Number.isNaN(Number(s))||this.isOperationColumn(a)?s:this.isGroupHeadCategory(r,a)?t===bt.ALL?`${i.get(s)||s}`:s:this.isEntryCategory(r,a)?t===bt.ALL||"REST"===s?`${i.get(s)||s}`:s:this.isDrillElementCategory(r,a)?t===bt.ALL?`${i.get(n)||n}`:`${n}`:this.isPartElementCategory(r,a)?t===bt.ALL||"SUM_TOTAL"===e?`${i.get(e)||e}`:`${e}`:this.isSumElementCategory(r,a)?t===bt.ALL||"SUM_TOTAL"===e?`${i.get(e)||e}`:e:"GROUPHEAD"===r&&null==s?s:Number.isNaN(Number(s))?"-":Number(s)}isOperationColumn(t){return"operation"===t}translateScenarioCSS(t,i){if(this.attributesByAlias.has(t))return"attribute";const s=new Yt(t);let e="pos";return i<0&&(e="neg"),s.isValid?e+"_"+s.direction+("dr"===s.type?" relative_variance":""):t}setCellType(t,i){if("category"===t)return"";const s=this.attributesByAlias.get(t);if(s)return s.isNumeric?"decimal":"";let e;const n=new Yt(t);return i===mt.PERCENT?(e="percent",n.isValid&&"d"===n.type&&(e="decimal")):(e="decimal",n.isValid&&"dr"===n.type&&(e="percent")),e}isDrillElementCategory(t,i){return"DRILLELEMENT"===t&&"category"===i}isPartElementCategory(t,i){return"PARTELEMENT"===t&&"category"===i}isSumElementCategory(t,i){return("GROUP_SUM"===t||"SUM"===t)&&"category"===i}isEntryCategory(t,i){return"ENTRY"===t&&"category"===i}isGroupHeadCategory(t,i){return"GROUPHEAD"===t&&"category"===i}translateCellPrefix(t,i,s){return this.isOperationColumn(s)||this.isGroupHeadCategory(i,s)||this.isEntryCategory(i,s)?null:this.isDrillElementCategory(i,s)?`${t.get("there_of")} `:this.isPartElementCategory(i,s)?`${t.get("part_of")} `:null}createColumnType(t){return t.name===t.group&&t.name===t.type?"base":t.name===t.group?"columnGroup":"columnSubGroup"}}class nn{constructor(t,i,s,e){this.fromExpr="",this.rowCount=0,this.headerRows=[],this.bodyRows=[],this.intervalBuckets=[],this.ruleSet=t||new Ft,this.db=i,this.dataSetFactory=new en,this.config=this.initConfig(e),this.i18n=this.initI18n(new Map),this.setSource(s,e.filter)}setI18n(t){this.i18n=this.initI18n(t)}initI18n(t){const i=new Map([["",""],["SEPERATOR_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"," "],["there_of","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"]]);return this.state=rs.DIRTY,new Map([...i,...t||new Map])}initConfig(t){this.state=rs.DIRTY;const i=t,s=this;return t.scenarios.sort(((t,i)=>s.ruleSet.getScenarioSorIndex(t)-s.ruleSet.getScenarioSorIndex(i))),i}setConfig(t){this.config=this.initConfig(t)}setSource(t,i){var s,e;if(this.state=rs.DIRTY,!t)return this.fromExpr="",void(this.rowCount=0);this.fromExpr=m(t,i);try{const t=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(e=null===(s=t[0])||void 0===s?void 0:s.cnt)&&void 0!==e?e:0}catch(t){this.rowCount=0}}update(){this.prepareIntervalBuckets();const t=this.normalizeScenarios(this.config.scenarios,this.config.categoryThereOf,this.config.sortOrder,this.intervalBuckets);this.headerRows=this.dataSetFactory.createHeader(this.config.type,t,this.i18n,this.config.measureScale,this.config.measureUnit,this.config.showMeasureScale,this.config.attributes),this.bodyRows=0!==this.rowCount&&this.fromExpr?this.dataSetFactory.createBodyRows(this.config,this.i18n,this.db,this.fromExpr):[],this.state=rs.UP_TO_DATE}getHeader(){return this.state===rs.DIRTY&&this.update(),this.headerRows}getBody(){return this.state===rs.DIRTY&&this.update(),this.bodyRows}getColumns(){return this.state===rs.DIRTY&&this.update(),this.dataSetFactory.getNormalizedHeader()}prepareIntervalBuckets(){this.intervalBuckets=[],this.config.interval===ls||!this.fromExpr||this.config.categoryThereOf.size>0?this.config.interval=ls:(this.config.interval=function(t,i,s){var e;if(s!==C.AUTO)return s;let n,r,a;try{n=t.exec(`SELECT [date] as d FROM ${i}`)}catch(t){return console.error("IntervalColumns: date query failed",t),C.DAY}for(const t of n){const i=null===(e=ps(t.d))||void 0===e?void 0:e.toMillis();void 0!==i&&(r=void 0===r?i:Math.min(r,i),a=void 0===a?i:Math.max(a,i))}return void 0===r||void 0===a?C.DAY:(new U).calculateDistanceType(g.fromMillis(r),g.fromMillis(a))}(this.db,this.fromExpr,this.config.interval),this.intervalBuckets=function(t,i,s,e){let n;try{n=t.exec(`SELECT ${ds(s)} as __interval FROM ${i}`)}catch(t){return console.error("IntervalColumns: bucket query failed",t),[]}if(s===cs){const t=new Set,i=[];for(const s of n){const e=us(s.__interval);t.has(e)||(t.add(e),i.push({key:e,label:0===e.length?"—":e}))}return i}const r=new Set,a=[];for(const t of n){const i=ps(t.__interval);if(!i)continue;const s=i.toISO();r.has(s)||(r.add(s),a.push(i))}a.sort(((t,i)=>t.toMillis()-i.toMillis()));const o=new U;return o.setLocale(e),a.map((t=>({key:t.toISO(),label:o.getDateString(t,s)})))}(this.db,this.fromExpr,this.config.interval,this.config.locale),0===this.intervalBuckets.length&&(this.config.interval=ls))}normalizeScenarios(t,i,s,e=[]){var n,r;const a=[];if(e.length>0){for(const i of e)for(const e of t)a.push({name:e,group:e,type:e,order:(null===(n=null==s?void 0:s.hierarchy)||void 0===n?void 0:n.at(0))===e?s.direction:void 0,bucket:i.key,bucketLabel:i.label});return a}for(const e of t){if(null==i?void 0:i.has(e)){const t=i.get(e);for(const i of t){a.push({name:i.name,group:i.name,type:e,order:void 0});for(const t of i.subGroups)a.push({name:t,group:i.name,type:e,order:void 0})}a.push({name:"REST",group:"REST",type:e,order:void 0})}let t;(null===(r=null==s?void 0:s.hierarchy)||void 0===r?void 0:r.at(0))===e&&(t=s.direction),a.push({name:e,group:e,type:e,order:t})}return a}hasNoData(){return 0===this.rowCount}}class rn{constructor(){this.title="",this.scenarios=[],this.scenariosUnitType=mt.DECIMAL,this.grouped=!1,this.showGroupTitle=!0,this.thereOf=[],this.categoryThereOf=new Map,this.partOf=[],this.attributes=[],this.sortOrder=new kt(new Rs).default(),this.type=as.LIST,this.limit=0,this.i18n=bt.ALL,this.categoryWidth=wt.W25,this.measureScale=new Jt,this.measureUnit="",this.measureType=yt.VOLUME,this.showMeasureScale=!0,this.filter="",this.barColumns=[],this.interval="none",this.locale="de"}}class an{constructor(t,i,s,e,n){this.tableDrillGroupAdapter=t,this.stringAdapter=i,this.orderAdapter=s,this.db=e,this.fromExpr=n}adapt(t){const i=new rn;return Ot.isString(t.title)&&(i.title=t.title),Ot.isArray(t.scenarios)&&(i.scenarios=Et.adaptArray(t.scenarios,this.stringAdapter)),Ot.isExisting(t.scenariosUnitType)&&(i.scenariosUnitType=t.scenariosUnitType),Ot.isBoolean(t.grouped)&&(i.grouped=t.grouped),Ot.isBoolean(t.showGroupTitle)&&(i.showGroupTitle=t.showGroupTitle),Ot.isBoolean(t.showMeasureScale)&&(i.showMeasureScale=t.showMeasureScale),Ot.isArray(t.thereOf)&&(i.thereOf=Et.adaptArray(t.thereOf,this.tableDrillGroupAdapter)),Ot.isExisting(t.categoryThereOf)&&(i.categoryThereOf=t.categoryThereOf),Ot.isArray(t.partOf)&&(i.partOf=Et.adaptArray(t.partOf,this.tableDrillGroupAdapter)),Ot.isArray(t.attributes)&&(i.attributes=t.attributes),Ot.isExisting(t.order)&&(i.sortOrder=this.orderAdapter.adapt(t.order)),Ot.isExisting(t.type)&&(i.type=t.type),Ot.isNumber(t.limit)&&(i.limit=t.limit),Ot.isExisting(t.i18n)&&(i.i18n=t.i18n),Ot.isExisting(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),Ot.isExisting(t.measureScale)&&(i.measureScale=Os.calculateMeasureScale(this.db,this.fromExpr,i.scenarios,t.measureScale)),Ot.isExisting(t.measureType)&&(i.measureType=t.measureType),Ot.isString(t.measureUnit)&&(i.measureUnit=t.measureUnit),Ot.isString(t.filter)&&(i.filter=t.filter.trim()),Ot.isArray(t.barColumns)&&(i.barColumns=t.barColumns),Ot.isString(t.interval)&&(i.interval=t.interval),Ot.isString(t.locale)&&(i.locale=t.locale),i}default(){return new rn}}class on{constructor(){this.rowGroup="",this.category="",this.subCategory="",this.partOf=""}}class hn{constructor(){}adapt(t){const i=new on;return Ot.isString(t.rowGroup)&&(i.rowGroup=t.rowGroup),Ot.isString(t.category)&&(i.category=t.category),Ot.isString(t.subCategory)&&(i.subCategory=t.subCategory),Ot.isString(t.partOf)&&(i.partOf=t.partOf),i}default(){return new on}}const ln=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.sumTitle="SUM_TOTAL",this.scenarios=[],this.scenariosDataFormat=mt.DECIMAL,this.grouped=!1,this.limit=0,this.showGroupTitle=!0,this.thereof=[],this.partof=[],this.order={hierarchy:[],direction:os.ASC},this.categorythereof=new Map,this.attributeColumns=[],this.type=as.LIST,this.categoryWidth=wt.INF,this.dataFormatDigits={percent:2,decimal:1},this.i18n=new Map,this.i18nMode=bt.ALL,this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.measureType=yt.VOLUME,this.filter="",this.barColumns=[],this.interval="none",this.barColumnMaxWidth=30,this.unitScaling=.01,this.percentageScaling=.5,this.scaleFactor=1,this.componentDataFormatDigits=new Js,this.componentStyle=w(this)}async getLayoutDetail(t,i){var s,e,n;const r={regions:[],metadata:{},diagnostics:[]},a=null===(s=this.element.shadowRoot)||void 0===s?void 0:s.querySelector("table");if(r.metadata.hasNoData=null===(n=null===(e=this.table)||void 0===e?void 0:e.hasNoData())||void 0===n||n,!this.table||!a)return r;const o=a.querySelector("thead"),h=a.querySelector("tbody");o&&r.regions.push({id:"header",rect:Lt(o,t)}),h&&r.regions.push({id:"body",rect:Lt(h,t)});const l=this.table.getHeader(),c=this.table.getBody(),d=this.table.getColumns();if(r.metadata.headerRowCount=l.length,r.metadata.rowCount=c.length,r.metadata.columnCount=d.length,r.metadata.cellCount=c.reduce(((t,i)=>t+i.getCells().length),0),"full"!==i)return r;const u=[],p=[],f=(i,s,e)=>{const n=e?Array.from(e.children).filter((t=>"tr"===t.localName)):[];s.forEach(((s,e)=>{const a=n[e];if(!a)return;u.push({section:i,index:e,type:s.type,rect:Lt(a,t)});const o=s.getCells(),h=Array.from(a.children);o.length===h.length?o.forEach(((s,n)=>{var r,a;const o=h[n],l={kind:"header"===i?"headerCell":"cell",row:e,column:s.index,key:s.key||void 0,colSpan:s.colSpan,value:null!==(r=s.value)&&void 0!==r?r:void 0,text:(null===(a=o.textContent)||void 0===a?void 0:a.trim())||void 0,type:s.type||void 0,rect:Lt(o,t)},c=o.querySelector("svg.cell-bar-chart");c&&(l.bar={variant:c.classList.contains("waterfall-bar")?"waterfall":c.classList.contains("relative-variance")?"relative":"absolute",rect:Lt(c,t)}),p.push(l)})):r.diagnostics.push({id:`LAYOUT_cellPairing_${i}_${e}`,type:"warning",message:`layout-state: model/DOM cell count mismatch in ${i} row ${e} (${o.length} vs ${h.length}); cell details skipped for this row.`})}))};return f("header",l,o),f("body",c,h),r.elements=p,r.table={rows:u,columns:d.map(((t,i)=>({index:i,key:t.name,group:t.group,type:t.type,bucket:t.bucket})))},r}render(){return i(s,null,(()=>{if(void 0!==this.table){if(this.table.hasNoData()){const t=this.i18n.get("no-data")||"==No Data==";return i("p",{class:"warning"},t)}return i("table",null,i("thead",null,this.table.getHeader().map((t=>i("tr",{class:t.cssStyle},t.getCells().map((t=>i("th",{colSpan:t.colSpan,class:t.cssStyle},t.getAsHeaderList().map(((s,e,n)=>i("span",null,e===n.length-1?i("span",{class:" "===s?"table-footer":""},s,t.drawPrefix()," "):i("span",null,s,t.drawPrefix(),i("br",null)))))))))))),i("tbody",null,this.table.getBody().map((t=>i("tr",{class:t.cssStyle},null==t?void 0:t.getCells().map((s=>i("td",{colSpan:s.colSpan,class:s.type?`${s.cssStyle} ${s.type}`:s.cssStyle},null!=s.prefix?i("span",{class:s.cssStyle+" "+s.prefixStyle},s.drawPrefix()):"",s.isBarChart&&s.columnStats&&(void 0!==s.waterfall||t.type!==hs.SUM)?void 0!==s.waterfall?i(Ze,{value:s.value,scenario:s.key,columnStats:s.columnStats,height:18*this.scaleFactor,isRelative:!1,isPositiveGood:s.key.endsWith("_pos"),measureScale:s.measureScale,columnWidthEm:this.barColumnMaxWidth,styles:this.barChartStyles,waterfall:s.waterfall}):i(qe,{value:s.value,scenario:s.key,columnStats:s.columnStats,height:18*this.scaleFactor,isRelative:s.key.startsWith("dr"),isPositiveGood:s.key.endsWith("_pos"),measureScale:s.measureScale,columnWidthEm:this.barColumnMaxWidth,styles:this.barChartStyles}):s.draw(this.componentDataFormatDigits)))))))))}})())}componentWillRender(){this.stores||(this.stores=d(this.element));const t=this.stores.db.db,i=this.prepareConfig(t);this.componentDataFormatDigits=(new qs).adapt(this.dataFormatDigits),this.table=new nn(new Ft(this.ruleSetConfig),t,this.tableName,i),this.table.setI18n(this.i18n),this.barChartStyles=this.prepareBarChartStyles()}prepareConfig(t){var i,s,e;const n=this.tableName?this.filter&&this.filter.length>0?`(SELECT * FROM \`${this.tableName}\` WHERE ${this.filter}) AS __src`:`\`${this.tableName}\``:"";return new an(new hn,new Rs,new kt(new Rs),t,n).adapt({title:this.sumTitle,scenarios:this.scenarios,scenariosUnitType:this.scenariosDataFormat,grouped:this.grouped,showGroupTitle:this.showGroupTitle,thereOf:this.thereof,partOf:this.partof,categoryThereOf:this.categorythereof,attributes:this.attributeColumns,order:this.order,type:this.type,limit:this.limit,i18n:this.i18nMode,categoryWidth:this.categoryWidth,measureScale:this.measureScale,measureUnit:this.measureUnit,measureType:this.measureType,showMeasureScale:this.showMeasureScale,filter:this.filter,barColumns:this.barColumns,interval:this.interval,locale:(null===(e=null===(s=null===(i=this.stores)||void 0===i?void 0:i.context)||void 0===s?void 0:s.state)||void 0===e?void 0:e.locale)||"de"})}prepareBarChartStyles(){var t;const i=!(this.unitScaling>0),s=!(this.percentageScaling>0),e=i?this.autoUnitScaling():this.unitScaling,n=s?this.autoPercentageScaling():this.percentageScaling;return(i||s)&&(null===(t=this.reportAutoScaling)||void 0===t||t.call(this,{unit:i?e:void 0,percentage:s?n:void 0})),this.componentStyle((t=>{var i,s,r,a,o,h,l,c,d,u,p,f,v,g,m,b,w,y,S,$,O,R,M,x,_,E,k;const P=null===(i=t["bn-chart-time"])||void 0===i?void 0:i.varianceStyles,T=null===(s=t["bn-chart-time"])||void 0===s?void 0:s.barStyles;return{positive:{stroke:(null===(r=null==P?void 0:P.pos)||void 0===r?void 0:r.stroke)||"#008f96",fill:(null===(a=null==P?void 0:P.pos)||void 0===a?void 0:a.fill)||"#008f96",fillpattern:(null===(o=null==P?void 0:P.pos)||void 0===o?void 0:o.fillpattern)||"solid"},negative:{stroke:(null===(h=null==P?void 0:P.neg)||void 0===h?void 0:h.stroke)||"#ff0000",fill:(null===(l=null==P?void 0:P.neg)||void 0===l?void 0:l.fill)||"#ff0000",fillpattern:(null===(c=null==P?void 0:P.neg)||void 0===c?void 0:c.fillpattern)||"solid"},neutral:{stroke:(null===(d=null==P?void 0:P.neu)||void 0===d?void 0:d.stroke)||"#808080",fill:(null===(u=null==P?void 0:P.neu)||void 0===u?void 0:u.fill)||"#808080",fillpattern:(null===(p=null==P?void 0:P.neu)||void 0===p?void 0:p.fillpattern)||"outlined"},scenarios:{ac:{stroke:(null===(f=null==T?void 0:T.ac)||void 0===f?void 0:f.stroke)||"#404040",fill:(null===(v=null==T?void 0:T.ac)||void 0===v?void 0:v.fill)||"#404040",fillpattern:(null===(g=null==T?void 0:T.ac)||void 0===g?void 0:g.fillpattern)||"solid"},pp:{stroke:(null===(m=null==T?void 0:T.pp)||void 0===m?void 0:m.stroke)||"#A6A6A6",fill:(null===(b=null==T?void 0:T.pp)||void 0===b?void 0:b.fill)||"#A6A6A6",fillpattern:(null===(w=null==T?void 0:T.pp)||void 0===w?void 0:w.fillpattern)||"solid"},fc:{stroke:(null===(y=null==T?void 0:T.fc)||void 0===y?void 0:y.stroke)||"#404040",fill:(null===(S=null==T?void 0:T.fc)||void 0===S?void 0:S.fill)||"#ffffff",fillpattern:(null===($=null==T?void 0:T.fc)||void 0===$?void 0:$.fillpattern)||"hatched"},pl:{stroke:(null===(O=null==T?void 0:T.pl)||void 0===O?void 0:O.stroke)||"#404040",fill:(null===(R=null==T?void 0:T.pl)||void 0===R?void 0:R.fill)||"#ffffff",fillpattern:(null===(M=null==T?void 0:T.pl)||void 0===M?void 0:M.fillpattern)||"outlined"}},fontColor:(null===(x=t.global)||void 0===x?void 0:x.fontColor)||"#000000",fontSize:((null===(_=t.global)||void 0===_?void 0:_.fontSizePx)||13.3333)*Ae*this.scaleFactor,emPx:((null===(E=t.global)||void 0===E?void 0:E.fontSizePx)||13.3333)*this.scaleFactor,fontFamily:(null===(k=t.global)||void 0===k?void 0:k.fontFamily)||"'Noto Sans', sans-serif",unitScaling:e,percentageScaling:n,scaleFactor:this.scaleFactor}}))}emPx(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*this.scaleFactor}autoUnitScaling(){const t=this.emPx(),i=t*Ae,{absMax:s,hasNeg:e,hasPos:n}=this.getAbsBarColumnStats();if(s<=0||i<=0)return.01;const{maxBarWidth:r,cutWidth:a}=Ue(this.barColumnMaxWidth,t,e,n);return Math.min(.8*r,a)/(s*i)}autoPercentageScaling(){const t=this.emPx(),i=t*Ae,{absMax:s,hasNeg:e,hasPos:n}=this.getRelativeBarColumnStats();if(s<=0||i<=0)return.5;const{maxPinLength:r}=De(this.barColumnMaxWidth,t,e,n);return.8*r/(s*i)}getAbsBarColumnStats(){return this.collectBarColumnStats((t=>!t.key.startsWith("dr")&&!t.waterfall),1)}getRelativeBarColumnStats(){return this.collectBarColumnStats((t=>t.key.startsWith("dr")),100)}collectBarColumnStats(t,i){const s={absMax:0,hasNeg:!1,hasPos:!1};if(!this.table)return s;for(const e of this.table.getBody())if(e.type!==hs.SUM)for(const n of e.getCells())n.isBarChart&&n.columnStats&&t(n)&&(s.absMax=Math.max(s.absMax,n.columnStats.absMax*i),s.hasNeg=s.hasNeg||n.columnStats.min<0,s.hasPos=s.hasPos||n.columnStats.max>0);return s}get element(){return e(this)}};ln.style=':host{position:relative;display:inline-block}table{background-color:var(--bn-font-background, white);font-size:var(--bn-font-size, 1em);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);border-spacing:0.3em 0}thead{border-style:none}tr:first-child td{border-top:none;padding-top:0.5em}td.ac1,td.ac2,td.ac3,td.ac4,td.pp1,td.pp2,td.pp3,td.pp4,td.pl1,td.pl2,td.pl3,td.pl4,td.fc1,td.fc2,td.fc3,td.fc4,td.share,td.variance,td.pos_pos,td.pos_neg,td.neg_pos,td.neg_neg,td.pos_neutral,td.neg_neutral{text-align:right}.category-w100{min-width:100em;max-width:100em}.category-w50{min-width:50em;max-width:50em}.category-w25{min-width:25em;max-width:25em}.category-w20{min-width:20em;max-width:20em}.category-w15{min-width:15em;max-width:15em}.category-w10{min-width:10em;max-width:10em}.category-w5{min-width:5em;max-width:5em}.prefix-second{color:transparent;font-style:normal}.prefix-first{font-style:normal}th{border-bottom:0.1em solid black;text-align:right;font-weight:normal;vertical-align:text-top}td.columnGroup,th.columnGroup{font-size:0.6em}td.columnSubGroup,th.columnSubGroup{font-size:0.6em;border-spacing:0em 0;font-style:italic}td.base,th.base{font-style:normal}th.ofit,td.ofit,tr.ofit,th.partof,td.partof,tr.partof{font-size:0.6em;font-style:italic}td.ofit,td.partof{font-size:0.6em;font-style:italic}th.ofit td,tr.ofit td,th.partof td,tr.partof td{border-top:0em solid black;padding-left:1em}th.ofit share,th.partof share,tr.share td{border-top:0em solid black}th.share,tr.share,td.share{font-size:0.6em;font-style:italic}th.filler{border-bottom:0em solid black;text-align:right}td.filler{border-top:0em none !important;border-bottom:0em none;text-align:right}th.group{text-align:center;border-spacing:1em 0}th.headerlabel{border-bottom:0em none black;padding-bottom:0em}th.intervalGroup{border-bottom:0.1em solid black;text-align:center;font-weight:bold}td.variance:after{content:"%"}td.relative_variance{font-style:italic}td.percent{font-style:italic;text-align:right}td.decimal{text-align:right}td.pos_pos{color:#008f96}td.neg_pos{color:#ff0000}td.pos_neg{color:#ff0000}td.neg_neg{color:#008f96}td.pos_pos:before{content:"+"}td.pos_neg:before{content:"+"}td.pos_neu:before{content:"+"}th.ac1,th.ac2,th.ac3,th.ac4{padding-top:0em;border-bottom:0.3em solid black}th.pp1,th.pp2,th.pp3,th.pp4{padding-top:0em;border-bottom:0.3em solid grey}th.pl1,th.pl2,th.pl3,th.pl4{padding-top:0em;border-bottom:0.3em double black}th.fc1,th.fc2,th.fc3,th.fc4{border-bottom:0.3em solid;border-image:repeating-linear-gradient(-45deg, white, white, black, white, white 0.3em) 2}td.colsum{font-weight:bold}th.colsum{padding-top:0em;font-weight:bold}tr.sum td{border-top:0.1em solid black;font-weight:bold;padding-bottom:0.5em}tr.groupheader td{border-top:0em dotted #ddd;padding-top:0.5em;font-weight:bold;font-style:italic}tr.begingroup td{border-top:0em dotted #ddd;padding-top:0.5em}th.begin-group{padding-left:0.75em}th.end-group{padding-left:0.75em}td{box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em dashed #ddd;padding-left:0.5em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.table-footer{font-size:0.6em}.cell-bar-chart{display:inline-block;vertical-align:middle}.bar-chart-empty{color:#999}td:has(.cell-bar-chart){padding:0 0.25em;vertical-align:middle}td:has(.cell-bar-chart).pos_pos:before,td:has(.cell-bar-chart).pos_neg:before,td:has(.cell-bar-chart).pos_neu:before{content:none}td:has(.cell-bar-chart).variance:after{content:none}';class cn{constructor(){}createMeasures(t,i,s){if(this.allMeasuresUseSameUnit(t)){const e=t.length;let n="",r="";for(let a=0;a<e;a++){let o="";a>0&&(o=i.get("SEPERATOR_WS")),e>1&&a===e-1&&(o=i.get("CONNECTOR_WS")),s===bt.ALL?(n=(i.get(n)||n)+o+(i.get(t[a].name)||t[a].name),r=i.get(t[a].unit)||t[a].unit):(n=n+o+t[a].name,r=t[a].unit)}return[{name:n,unit:r}]}return t}createDimension(t,i,s,e,n,r="de"){let a="";if(void 0!==i){const t=new U;t.setLocale(r),a=t.getDateLinkString(i.start,i.end,i.link,i.format,n)}const o=t.map((t=>{let i="";return null!=s&&null!=s.hierarchy&&s.hierarchy.find((i=>i===t))&&(i=e.get("asc"===s.direction?"ORDER_asc":"ORDER_desc")),"".concat(" ",Gt.translateScenarioLabel(t,e),i)})).toString();return a+o}allMeasuresUseSameUnit(t){const i=new Map;return t.forEach((function(t){i.set(t.unit,!0)})),1===i.size}}class dn{constructor(){this.businessunit="",this.measures=[],this.scenarios=[],this.i18nMode=bt.ALL,this.intervalSpanLimit=32,this.locale="de"}}class un{constructor(t,i,s,e){this.measureEntryAdapter=t,this.timePeriodAdapter=i,this.orderAdapter=s,this.stringAdapter=e}adapt(t){const i=new dn;return Ot.isString(t.businessunit)&&(i.businessunit=t.businessunit),Ot.isArray(t.measures)&&(i.measures=Et.adaptArray(t.measures,this.measureEntryAdapter)),Ot.isArray(t.scenarios)&&(i.scenarios=Et.adaptArray(t.scenarios,this.stringAdapter)),Ot.isExisting(t.timeperiod)&&(i.timeperiod=this.timePeriodAdapter.adapt(t.timeperiod)),Ot.isNumber(t.intervalSpanLimit)&&(i.intervalSpanLimit=t.intervalSpanLimit),Ot.isExisting(t.i18nMode)&&(i.i18nMode=t.i18nMode),Ot.isExisting(t.order)&&(i.order=this.orderAdapter.adapt(t.order)),Ot.isString(t.locale)&&(i.locale=t.locale),i}default(){return new dn}}var pn;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(pn||(pn={}));class fn{constructor(t){this.i18n=new Map,this.unit="",this.measures=[],this.dimension="",this.config=new dn,this.state=pn.DIRTY,this.ruleSet=t||new Ft,this.dataSetFactory=new cn,this.state=pn.DIRTY,this.setI18n(new Map)}setRuleSet(t){this.ruleSet=t||new Ft}setI18n(t){this.state=pn.DIRTY;const i=new Map([["SEPERATOR_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"," "],["there_of","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"],["CONNECTOR_WS"," und "]]);this.i18n=new Map([...i,...t||new Map])}update(){return pn.DIRTY===this.state&&(this.unit=this.config.businessunit,this.measures=this.dataSetFactory.createMeasures(this.config.measures,this.i18n,this.config.i18nMode),this.dimension=this.dataSetFactory.createDimension(this.config.scenarios,this.config.timeperiod,this.config.order,this.i18n,this.config.intervalSpanLimit,this.config.locale),this.state=pn.UP_TO_DATE),this}setConfig(t){this.config=this.initConfig(t)}initConfig(t){this.state=pn.DIRTY;const i=t,s=this;return t.scenarios.sort(((t,i)=>s.ruleSet.getScenarioSorIndex(t)-s.ruleSet.getScenarioSorIndex(i))),i}}class vn{constructor(t="",i=""){this.name=t,this.unit=i}}class gn{construnctor(){}adapt(t){const i=new vn;return Ot.isString(t.name)&&(i.name=t.name),Ot.isString(t.unit)&&(i.unit=t.unit),i}default(){return new vn("","")}}class mn{constructor(t=g.now(),i=g.now(),s=C.AUTO,e=Z.AUTO){this.start=t,this.end=i,this.format=s,this.link=e}}class bn{construnctor(){}adapt(t){const i=new mn;return Ot.isDate(t.start)&&(i.start=t.start),Ot.isDate(t.end)&&(i.end=t.end),Ot.isExisting(t.format)&&(i.format=t.format),Ot.isExisting(t.link)&&(i.link=t.link),i}default(){return new mn}}const wn=class{constructor(i){t(this,i),this.businessUnit="",this.scenarios=[],this.measures=[],this.intervalSpanLimit=28,this.order={hierarchy:[],direction:xt.ASC},this.i18n=new Map,this.i18nMode=bt.ALL,this.locale="de",this.title=new fn(new Ft)}async setBusinessUnit(t){this.businessUnit=t}async setProps(t){Object.keys(t).forEach((i=>{this[i]=t[i]}))}render(){return i("div",{key:"4a675a92695130e13bd690587098cf70d81028c9"},i("div",{key:"54c98ac466109f4ea1306aa57379f5cb25cf654f",innerHTML:Xt(this.title.unit)}),i("div",{key:"35e8592454c45c06db9e3b6db5525165a3ee4a00"},this.title.measures.map(((t,s)=>i("span",null,this.isFirstElement(s)?this.title.i18n.get("SEPERATOR_WS"):"",i("span",{class:"measure"},t.name)," ",t.unit?this.title.i18n.get("in"):""," ",t.unit)))),i("div",{key:"29c93306567a592ac956d5c97501dc5e7acf90ec"},this.title.dimension))}componentWillLoad(){const t=this.prepareConfig();this.title=new fn(new Ft(this.ruleSetConfig)),this.title.setI18n(this.i18n),this.title.setConfig(t)}componentWillUpdate(){const t=this.prepareConfig();this.title.setI18n(this.i18n),this.title.setRuleSet(new Ft(this.ruleSetConfig)),this.title.setConfig(t)}componentWillRender(){this.title.update()}isFirstElement(t){return 0!==t}prepareConfig(){return new un(new gn,new bn,new kt(new Rs),new Rs).adapt({businessunit:this.businessUnit,measures:this.measures,scenarios:this.scenarios,timeperiod:this.timeperiod,intervalSpanLimit:this.intervalSpanLimit,i18nMode:this.i18nMode,order:this.order,locale:this.locale})}};wn.style=':host{display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.measure{font-weight:bold}div{background-color:var(--bn-font-background, white);color:var(--bn-font-color, black)}p{margin:0}';export{ri as bn_asset,ai as bn_body,oi as bn_card,ci as bn_chart_structure,ui as bn_chart_time,pi as bn_component_style,fi as bn_context,Xi as bn_dataset,Ji as bn_datasource,qi as bn_footer,Zi as bn_layout_card,Ki as bn_layout_page,Qi as bn_message,ss as bn_page,es as bn_scaling_group,fs as bn_table,vs as bn_title,Zs as ibcs_chart_structure,Pe as ibcs_chart_time,ln as ibcs_table,wn as ibcs_title}
|