@bino-bi/bn-template-engine 1.0.0-next.36 → 1.0.0-next.38
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-2dcdac86.entry.js → p-e15ccc4a.entry.js} +1 -1
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +221 -53
- package/dist/collection/components/bn-table/bn-table-renderer/bn-table-renderer.js +55 -15
- package/dist/collection/components/bn-table/bn-table.js +5 -2
- package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +25 -15
- package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +2 -2
- package/dist/collection/components/bn-table/utils/helper/DataQuery.js +24 -10
- package/dist/collection/components/bn-table/utils/helper/WaterfallCalculator.js +9 -3
- package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +105 -10
- package/dist/components/bn-table-renderer.js +1 -1
- package/dist/components/bn-table.js +1 -1
- package/dist/components/p--HIZm_2v.js +1 -0
- package/dist/esm/bn-annotation-layer_30.entry.js +221 -53
- package/dist/types/components/bn-table/bn-table-renderer/bn-table-renderer.d.ts +5 -0
- package/dist/types/components/bn-table/bn-table.d.ts +3 -0
- package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +7 -2
- package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +1 -0
- package/dist/types/components/bn-table/utils/helper/WaterfallCalculator.d.ts +5 -2
- package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +31 -8
- package/dist/types/components.d.ts +2 -2
- package/package.json +1 -1
- package/dist/components/p-CLilvhjH.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as i,w as e,h as a,a as s,t as r,f as n}from"./p-D6YGOYV1.js";import{h as o,a as l}from"./p-DDvWTgk1.js";import{v as d,a as h,i as p,p as c,q as u,r as v,s as m,h as g,t as f,u as y,w as b,c as O,x as S,l as w,y as T,z as D,f as A,A as N}from"./p-DT04Cka0.js";import{w as _}from"./p-DJUffGeB.js";import{w as W}from"./p-Dq9dG0Kr.js";import{w as C}from"./p-DQl2K2Xl.js";import{w as M,a as F,i as R}from"./p-BU_53KVT.js";import{w as j}from"./p-Bo_R7f_T.js";import{w as x}from"./p-DjPWZfry.js";import{r as U}from"./p-CniN8ALm.js";import{w as P}from"./p-OquycEMA.js";import{w as k,r as B}from"./p-4vVbchX2.js";import{g as G}from"./p-DD1zlev_.js";import{f as I,r as L,p as E}from"./p-Xb6Ilq8u.js";import{o as $}from"./p-B6kka9sT.js";import{D as z,I as J,d as V,M as q,B as K,T as X}from"./p-B5tixDPM.js";import{I as Y,a as Q,T as Z,d as H}from"./p-CLilvhjH.js";import{p as tt}from"./p-DCPLGEs_.js";import{a as it,n as et}from"./p-16rjcQ0t.js";import{LAYOUT_STATE_VERSION as at}from"./index.js";import{o as st,m as rt}from"./p-DaOm9YwQ.js";import{r as nt,a as ot}from"./p-CckAR27O.js";import{b as lt}from"./p-t4xPltK2.js";import{s as dt}from"./p-DakXa7Dp.js";const ht=t(class extends i{validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("WARN_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"WARN_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("WARN_scale")}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),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=!1,this.showMeasureScale=!1,this.showGroupTitle=!0,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,e,a,s;this.lastAutoScalingReport={unit:null!==(i=t.unit)&&void 0!==i?i:null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.unit,percentage:null!==(a=t.percentage)&&void 0!==a?a:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.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 ≈ ${I(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 ≈ ${I(i)} percentage points.`}))}},j(this),W(this),this.errors=k(this),C(this),this.componentStyle=x(this),this.ruleSetConfig=P(this),_(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=M(this).t,this.resolveInherited=F(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}],this.errors)}validateFilter(t){const i="ERR_filter";o(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(R(t))return void this.errors.remove(i);const e=d(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+(null==e?void 0:""+e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(R(t))return void this.errors.remove(i);const e=h(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateBarColumns(t){const i="WARN_barColumns";if(p(t))return void this.errors.remove(i);const e=c(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"barColumns: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateBarColumnWidth(t){const i="WARN_barColumnWidth";u(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"barColumnWidth: invalid value '"+t+"' is not supported."})}validateUnitScaling(t){const i="WARN_unitScaling";"invalid"===L(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="WARN_percentageScaling";"invalid"===L(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="WARN_dataFormat";v(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormat: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateType(t){const i="WARN_type";m(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"type: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateLimit(t){const i="WARN_limit";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateThereOf(t){const i="WARN_thereof",e=f(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"ThereOf: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validatePartOf(t){const i="WARN_partof",e=y(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"partof: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderList(t){const i="WARN_order";if(R(t))return void this.errors.remove(i);const e=b(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="WARN_orderDirection";R(t)||O(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureType(t){const i="WARN_measureType";S(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureType: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";w(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateDataFormatDigitsDecimal(t){const i="WARN_dataFormatDigitsDecimal";g(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="WARN_dataFormatDigitsPercent";g(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="WARN_categoryWidth";T(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=D(t),e="WARN_columnthereof";i.length>0?this.errors.addOrReplace({id:e,type:"warning",message:"columnthereof: invalid value(s) '"+JSON.stringify(i)+"' are not supported."}):this.errors.remove(e)}validateInterval(t){const i="WARN_interval",e=null==t?void 0:t.trim().toLowerCase();p(t)||e===Y||e===Q||A(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"interval: invalid value '"+t+"' is not supported."})}validateTableAttributes(t){const i="WARN_attributes",e=N(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"attributes: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateDataFormat(this.dataFormat),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.validateBarColumns(this.barColumns),this.validateBarColumnWidth(this.barColumnWidth),this.validateUnitScaling(this.unitScaling),this.validatePercentageScaling(this.percentageScaling),this.validateScaling(this.scale)}componentDidLoad(){this.layoutObserver=$(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=G(this.element);t>0&&Math.abs(t-this._lastScaledParentWidth)>2&&(this._lastScaledParentWidth=t,n(this))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}componentDidRender(){dt(this.element,"bn-table-renderer");const{mode:t}=E(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:a}=G(i);if(a<=0)return void this.checkOverflow();this._lastScaledParentWidth=a;const s=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollWidth,n=this.appliedScaleFactor;if(r<=a+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,n*(a-1)/r);Math.abs(o-n)<.001||(i.style.setProperty("--bn-font-size",s*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,e((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}checkOverflow(){const t=G(this.element),i=this.element.scrollWidth,e=this.element.scrollHeight,a=t.width>0&&i>t.width+1,s=t.height>0&&e>t.height+1;if(!a&&!s)return void B(this.errors,null);const{mode:r}=E(this.scale),n="auto"!==r&&"empty"!==r,o=[];a&&o.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),s&&o.push(`height (${Math.round(e)}px > ${Math.round(t.height)}px)`),B(this.errors,`Table exceeds available ${o.join(" and ")}. Give the component more space, reduce rows (e.g. limit), or set a smaller scale.`,n)}prepareDataFormat(){var t;return z[null===(t=this.dataFormat)||void 0===t?void 0:t.toUpperCase()]}prepareGrouped(){return this.grouped}prepareShowGroupTitle(){return this.showGroupTitle}prepareTableType(){var t;return Z[null===(t=this.type)||void 0===t?void 0:t.toUpperCase()]}prepareLimit(){return Math.floor(Number(this.limit)||0)}prepareThereOf(){if(null==this.thereof||""===this.thereof.trim())return[];try{return JSON.parse(this.thereof)}catch(t){return[]}}preparePartOf(){if(null==this.partof||""===this.partof.trim())return[];try{return JSON.parse(this.partof)}catch(t){return[]}}prepareOrder(){var t;const i=this.resolveInherited("order",this.order,"category").value,e=this.resolveInherited("orderDirection",this.orderDirection,"asc").value,a="auto"===(null==i?void 0:i.trim().toLowerCase());let s=i;return a&&(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)&&(s=this.datasetMeta.suggestedOrder),{hierarchy:s.split(",").map((t=>et(t))),direction:it[null==e?void 0:e.toUpperCase()]}}prepareI18nMode(){return J.META}prepareI18n(){const t=l,i=new Map(["in","category","operation","thereof","part_of","SUM_TOTAL","no-data","REST"].map((t=>[t,this.t(".".concat(t))]))),e=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...i.entries(),...U(this.ruleSetConfig("user"))])}prepareDataFormatDigits(){return{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal}}prepareScenarios(){var t,i,e,a,s,r,n,o,l,d,h;const c=this.resolveInherited("scenarios",this.scenarios),u=this.resolveInherited("variances",this.variances);if(c.inherited||u.inherited){this.errors.remove("AUTO_scenarios");let a=[];return p(c.value)?c.unresolved&&(a=a.concat(null!==(i=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==i?i:[])):a=a.concat(c.value.split(",")),(null===(e=u.value)||void 0===e?void 0:e.trim().length)>0&&(a=a.concat(u.value.split(","))),a.map((t=>t.trim()))}const v="auto"===(null===(a=c.value)||void 0===a?void 0:a.trim().toLowerCase()),m=v||c.unresolved;if((p(c.value)||v)&&p(u.value))return(null===(r=null===(s=this.datasetMeta)||void 0===s?void 0:s.availableScenarios)||void 0===r?void 0:r.length)>0?(m?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 g=[];return v||p(c.value)?(null===(o=null===(n=this.datasetMeta)||void 0===n?void 0:n.availableScenarios)||void 0===o?void 0:o.length)>0&&(m?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),g=g.concat(this.datasetMeta.availableScenarios)):(this.errors.remove("AUTO_scenarios"),g=g.concat(null===(l=c.value)||void 0===l?void 0:l.split(","))),(null===(d=u.value)||void 0===d?void 0:d.trim().length)>0&&(g=g.concat(null===(h=u.value)||void 0===h?void 0:h.split(","))),g.map((t=>t.trim()))}prepareCategoryWidth(){var t;return p(this.categoryWidth)?V.INF:V[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)?q.VOLUME:q[null===(t=this.measureType)||void 0===t?void 0:t.toUpperCase()]}prepareColumnThereOf(){if(null==this.columnthereof||""===this.columnthereof.trim())return new Map;const t=new Map;try{const i=JSON.parse(this.columnthereof);for(const[e,a]of Object.entries(i))!1===t.has(a.scenario)&&t.set(a.scenario,[]),t.get(a.scenario).push(a)}catch(t){return new Map}return t}prepareInterval(){var t;const i="WARN_intervalConflict",e="WARN_intervalNoDate",a="WARN_intervalSetname",s=p(this.interval)?Y:this.interval.trim().toLowerCase();return s!==Y&&s!==Q&&!A(s)||s===Y?(this.errors.remove(i),this.errors.remove(e),this.errors.remove(a),Y):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(e),this.errors.remove(a),Y):(this.errors.remove(i),s===Q?(this.hasBlankSetnames?this.errors.addOrReplace({id:a,type:"warning",message:"interval: rows with blank setname found, they are grouped under '-'."}):this.errors.remove(a),this.errors.remove(e),Q):(this.errors.remove(a),this.datasetMeta&&!(null===(t=this.datasetMeta.dateRange)||void 0===t?void 0:t.hasData)?(this.errors.addOrReplace({id:e,type:"warning",message:"interval: dataset has no date values, interval is ignored."}),Y):(this.errors.remove(e),s)))}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],e)=>"string"==typeof i?tt(t,"attr_"+e,i):null)).filter((t=>null!==t))}catch(t){return[]}}prepareSumTitle(){return""===this.sumTitle||null==this.sumTitle?"SUM_TOTAL":this.sumTitle}prepareShowMeasureScale(){return 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(),e=X[i];return e?K[e]:K[X.W10]}prepareBarColumns(){return p(this.barColumns)?[]:this.barColumns.split(",").map((t=>t.trim()))}prepareUnitScaling(){const t=L(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=L(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 getBaseline(){return this.readBaseline()}readBaseline(){var t,i,e;const a=null===(e=null===(i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelector("bn-table-renderer"))||void 0===i?void 0:i.shadowRoot)||void 0===e?void 0:e.querySelector("table");return lt(a,this.element)}async getLayoutState(t){var i,e,a,s;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",n=st(this.element),o=this.getEffectiveScaleFactor(),l=Number.isFinite(o)&&o>0?o:1,d=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*l,h={version:at,tag:this.element.localName,id:ot(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:rt(this.element,n),em:{fontSizePx:d,appliedScaleFactor:l},regions:[],metadata:{},diagnostics:nt(this.element),scaling:this.resolveScalingInfo(d),baseline:this.readBaseline()},p=null===(a=this.element.shadowRoot)||void 0===a?void 0:a.querySelector("bn-table-renderer");if(p){const t=null!==(s=p.scenarios)&&void 0!==s?s:[];if(h.metadata.scenarios=t.filter((t=>!t.startsWith("d"))),h.metadata.variances=t.filter((t=>t.startsWith("d"))),"function"==typeof p.getLayoutDetail){const t=await p.getLayoutDetail(n,r);h.regions=t.regions,h.metadata=Object.assign(Object.assign({},h.metadata),t.metadata),h.diagnostics=[...h.diagnostics,...t.diagnostics],t.elements&&(h.elements=t.elements),t.table&&(h.table=t.table)}}return h}resolveScalingInfo(t){var i,e;const a={},s=L(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===s.kind)a.unitMode="fixed",a.unitsPerEm=s.value,a.unitPxPerUnit=t/s.value;else{a.unitMode="auto";const e=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==e&&e>0&&(a.unitsPerEm=1/e,a.unitPxPerUnit=e*t)}const r=L(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)a.percentageMode="fixed",a.percentagePointsPerEm=r.value,a.percentagePxPerPoint=t/r.value;else{a.percentageMode="auto";const i=null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.percentage;void 0!==i&&i>0&&(a.percentagePointsPerEm=1/i,a.percentagePxPerPoint=i*t)}return a}getEffectiveScaleFactor(){const{mode:t,factor:i}=E(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,a,s,r;const n=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(a=i.global)||void 0===a?void 0:a.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(s=i.global)||void 0===s?void 0:s.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles(),i=this.getEffectiveScaleFactor();return a(s,{key:"2f24deddc4e58f57ef27443a27b4706b5f1b90db",style:t},a("div",{key:"b6368e143f868d9c2a7ad8ec753a14813b60e197"},a("bn-table-renderer",{key:"399b2dc8d5cf3e7a8093a9a486635ea4d1bb74b9",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,errors:this.errors,scaleFactor:i,ruleSetConfig:this.ruleSetConfig(),selectedStyle:this.selectedStyle})))}get element(){return this}static get watchers(){return{scale:[{validateScaling:0}],filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat: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}]}}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}'}},[1,"bn-table",{datasets:[513],i18nNamespace:[513,"i18n-namespace"],scale:[1],ruleset:[513],selectedStyle:[513,"selected-style"],sumTitle:[1,"sum-title"],filter:[1],measureUnit:[1,"measure-unit"],scenarios:[1],variances:[1],barColumns:[1,"bar-columns"],barColumnWidth:[1,"bar-column-width"],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],dataFormat:[1,"data-format"],grouped:[4],showMeasureScale:[4,"show-measure-scale"],showGroupTitle:[4,"show-group-title"],type:[1],limit:[2],thereof:[1],partof:[1],order:[1],orderDirection:[1,"order-direction"],measureType:[1,"measure-type"],measureScale:[1,"measure-scale"],dataFormatDigitsDecimal:[2,"data-format-digits-decimal"],dataFormatDigitsPercent:[2,"data-format-digits-percent"],categoryWidth:[1,"category-width"],columnthereof:[1],interval:[1],tableAttributes:[1,"attributes"],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],hasBlankSetnames:[32],getBaseline:[64],getLayoutState:[64]},void 0,{scale:[{validateScaling:0}],filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat: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}]}]),pt=ht,ct=function(){"undefined"!=typeof customElements&&["bn-table","bn-table-renderer"].forEach((t=>{switch(t){case"bn-table":customElements.get(r(t))||customElements.define(r(t),ht);break;case"bn-table-renderer":customElements.get(r(t))||H()}}))};export{pt as BnTable,ct as defineCustomElement}
|
|
1
|
+
import{p as t,H as i,w as e,h as a,a as s,t as r,f as n}from"./p-D6YGOYV1.js";import{h as o,a as l}from"./p-DDvWTgk1.js";import{v as h,a as d,i as p,p as c,q as u,r as v,s as m,h as g,t as f,u as y,w as b,c as O,x as S,l as w,y as T,z as D,f as A,A as N}from"./p-DT04Cka0.js";import{w as _}from"./p-DJUffGeB.js";import{w as W}from"./p-Dq9dG0Kr.js";import{w as M}from"./p-DQl2K2Xl.js";import{w as C,a as F,i as R}from"./p-BU_53KVT.js";import{w as j}from"./p-Bo_R7f_T.js";import{w as x}from"./p-DjPWZfry.js";import{r as U}from"./p-CniN8ALm.js";import{w as P}from"./p-OquycEMA.js";import{w as k,r as B}from"./p-4vVbchX2.js";import{g as G}from"./p-DD1zlev_.js";import{f as I,r as L,p as E}from"./p-Xb6Ilq8u.js";import{o as $}from"./p-B6kka9sT.js";import{D as z,I as J,d as V,M as q,B as K,T as X}from"./p-B5tixDPM.js";import{I as Y,a as Q,T as Z,d as H}from"./p--HIZm_2v.js";import{p as tt}from"./p-DCPLGEs_.js";import{a as it,n as et}from"./p-16rjcQ0t.js";import{LAYOUT_STATE_VERSION as at}from"./index.js";import{o as st,m as rt}from"./p-DaOm9YwQ.js";import{r as nt,a as ot}from"./p-CckAR27O.js";import{b as lt}from"./p-t4xPltK2.js";import{s as ht}from"./p-DakXa7Dp.js";const dt=t(class extends i{validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("WARN_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"WARN_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("WARN_scale")}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),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=!1,this.showMeasureScale=!1,this.showGroupTitle=!0,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,e,a,s;this.lastAutoScalingReport={unit:null!==(i=t.unit)&&void 0!==i?i:null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.unit,percentage:null!==(a=t.percentage)&&void 0!==a?a:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.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 ≈ ${I(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 ≈ ${I(i)} percentage points.`}))}},j(this),W(this),this.errors=k(this),M(this),this.componentStyle=x(this),this.ruleSetConfig=P(this),_(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=C(this).t,this.resolveInherited=F(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}],this.errors)}validateFilter(t){const i="ERR_filter";o(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(R(t))return void this.errors.remove(i);const e=h(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+(null==e?void 0:""+e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(R(t))return void this.errors.remove(i);const e=d(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateBarColumns(t){const i="WARN_barColumns";if(p(t))return void this.errors.remove(i);const e=c(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"barColumns: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateBarColumnWidth(t){const i="WARN_barColumnWidth";u(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"barColumnWidth: invalid value '"+t+"' is not supported."})}validateUnitScaling(t){const i="WARN_unitScaling";"invalid"===L(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="WARN_percentageScaling";"invalid"===L(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="WARN_dataFormat";v(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormat: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateType(t){const i="WARN_type";m(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"type: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateLimit(t){const i="WARN_limit";g(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateThereOf(t){const i="WARN_thereof",e=f(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"ThereOf: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validatePartOf(t){const i="WARN_partof",e=y(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"partof: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderList(t){const i="WARN_order";if(R(t))return void this.errors.remove(i);const e=b(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="WARN_orderDirection";R(t)||O(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureType(t){const i="WARN_measureType";S(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureType: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";w(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateDataFormatDigitsDecimal(t){const i="WARN_dataFormatDigitsDecimal";g(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="WARN_dataFormatDigitsPercent";g(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="WARN_categoryWidth";T(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=D(t),e="WARN_columnthereof";i.length>0?this.errors.addOrReplace({id:e,type:"warning",message:"columnthereof: invalid value(s) '"+JSON.stringify(i)+"' are not supported."}):this.errors.remove(e)}validateInterval(t){const i="WARN_interval",e=null==t?void 0:t.trim().toLowerCase();p(t)||e===Y||e===Q||A(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"interval: invalid value '"+t+"' is not supported."})}validateTableAttributes(t){const i="WARN_attributes",e=N(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"attributes: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateDataFormat(this.dataFormat),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.validateBarColumns(this.barColumns),this.validateBarColumnWidth(this.barColumnWidth),this.validateUnitScaling(this.unitScaling),this.validatePercentageScaling(this.percentageScaling),this.validateScaling(this.scale)}componentDidLoad(){this.layoutObserver=$(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=G(this.element);t>0&&Math.abs(t-this._lastScaledParentWidth)>2&&(this._lastScaledParentWidth=t,n(this))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}componentDidRender(){ht(this.element,"bn-table-renderer");const{mode:t}=E(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:a}=G(i);if(a<=0)return void this.checkOverflow();this._lastScaledParentWidth=a;const s=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),r=i.scrollWidth,n=this.appliedScaleFactor;if(r<=a+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,n*(a-1)/r);Math.abs(o-n)<.001||(i.style.setProperty("--bn-font-size",s*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,e((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}checkOverflow(){const t=G(this.element),i=this.element.scrollWidth,e=this.element.scrollHeight,a=t.width>0&&i>t.width+1,s=t.height>0&&e>t.height+1;if(!a&&!s)return void B(this.errors,null);const{mode:r}=E(this.scale),n="auto"!==r&&"empty"!==r,o=[];a&&o.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),s&&o.push(`height (${Math.round(e)}px > ${Math.round(t.height)}px)`),B(this.errors,`Table exceeds available ${o.join(" and ")}. Give the component more space, reduce rows (e.g. limit), or set a smaller scale.`,n)}prepareDataFormat(){var t;return z[null===(t=this.dataFormat)||void 0===t?void 0:t.toUpperCase()]}prepareGrouped(){return this.grouped}prepareShowGroupTitle(){return this.showGroupTitle}prepareTableType(){var t;return Z[null===(t=this.type)||void 0===t?void 0:t.toUpperCase()]}prepareLimit(){return Math.floor(Number(this.limit)||0)}prepareThereOf(){if(null==this.thereof||""===this.thereof.trim())return[];try{return JSON.parse(this.thereof)}catch(t){return[]}}preparePartOf(){if(null==this.partof||""===this.partof.trim())return[];try{return JSON.parse(this.partof)}catch(t){return[]}}prepareOrder(){var t;const i=this.resolveInherited("order",this.order,"category").value,e=this.resolveInherited("orderDirection",this.orderDirection,"asc").value,a="auto"===(null==i?void 0:i.trim().toLowerCase());let s=i;return a&&(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)&&(s=this.datasetMeta.suggestedOrder),{hierarchy:s.split(",").map((t=>et(t))),direction:it[null==e?void 0:e.toUpperCase()]}}prepareI18nMode(){return J.META}prepareI18n(){const t=l,i=new Map(["in","category","operation","thereof","part_of","SUM_TOTAL","no-data","REST"].map((t=>[t,this.t(".".concat(t))]))),e=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...i.entries(),...U(this.ruleSetConfig("user"))])}prepareDataFormatDigits(){return{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal}}prepareScenarios(){var t,i,e,a,s,r,n,o,l,h,d;const c=this.resolveInherited("scenarios",this.scenarios),u=this.resolveInherited("variances",this.variances);if(c.inherited||u.inherited){this.errors.remove("AUTO_scenarios");let a=[];return p(c.value)?c.unresolved&&(a=a.concat(null!==(i=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==i?i:[])):a=a.concat(c.value.split(",")),(null===(e=u.value)||void 0===e?void 0:e.trim().length)>0&&(a=a.concat(u.value.split(","))),a.map((t=>t.trim()))}const v="auto"===(null===(a=c.value)||void 0===a?void 0:a.trim().toLowerCase()),m=v||c.unresolved;if((p(c.value)||v)&&p(u.value))return(null===(r=null===(s=this.datasetMeta)||void 0===s?void 0:s.availableScenarios)||void 0===r?void 0:r.length)>0?(m?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 g=[];return v||p(c.value)?(null===(o=null===(n=this.datasetMeta)||void 0===n?void 0:n.availableScenarios)||void 0===o?void 0:o.length)>0&&(m?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),g=g.concat(this.datasetMeta.availableScenarios)):(this.errors.remove("AUTO_scenarios"),g=g.concat(null===(l=c.value)||void 0===l?void 0:l.split(","))),(null===(h=u.value)||void 0===h?void 0:h.trim().length)>0&&(g=g.concat(null===(d=u.value)||void 0===d?void 0:d.split(","))),g.map((t=>t.trim()))}prepareCategoryWidth(){var t;return p(this.categoryWidth)?V.INF:V[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)?q.VOLUME:q[null===(t=this.measureType)||void 0===t?void 0:t.toUpperCase()]}prepareColumnThereOf(){if(null==this.columnthereof||""===this.columnthereof.trim())return new Map;const t=new Map;try{const i=JSON.parse(this.columnthereof);for(const[e,a]of Object.entries(i))!1===t.has(a.scenario)&&t.set(a.scenario,[]),t.get(a.scenario).push(a)}catch(t){return new Map}return t}prepareInterval(){var t;const i="WARN_intervalConflict",e="WARN_intervalNoDate",a="WARN_intervalSetname",s=p(this.interval)?Y:this.interval.trim().toLowerCase();return s!==Y&&s!==Q&&!A(s)||s===Y?(this.errors.remove(i),this.errors.remove(e),this.errors.remove(a),Y):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(e),this.errors.remove(a),Y):(this.errors.remove(i),s===Q?(this.hasBlankSetnames?this.errors.addOrReplace({id:a,type:"warning",message:"interval: rows with blank setname found, they are grouped under '-'."}):this.errors.remove(a),this.errors.remove(e),Q):(this.errors.remove(a),this.datasetMeta&&!(null===(t=this.datasetMeta.dateRange)||void 0===t?void 0:t.hasData)?(this.errors.addOrReplace({id:e,type:"warning",message:"interval: dataset has no date values, interval is ignored."}),Y):(this.errors.remove(e),s)))}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],e)=>"string"==typeof i?tt(t,"attr_"+e,i):null)).filter((t=>null!==t))}catch(t){return[]}}prepareSumTitle(){return""===this.sumTitle||null==this.sumTitle?"SUM_TOTAL":this.sumTitle}prepareShowMeasureScale(){return 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(),e=X[i];return e?K[e]:K[X.W10]}prepareBarColumns(){return p(this.barColumns)?[]:this.barColumns.split(",").map((t=>t.trim()))}prepareUnitScaling(){const t=L(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=L(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 getBaseline(){return this.readBaseline()}readBaseline(){var t,i,e;const a=null===(e=null===(i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelector("bn-table-renderer"))||void 0===i?void 0:i.shadowRoot)||void 0===e?void 0:e.querySelector("table");return lt(a,this.element)}async getLayoutState(t){var i,e,a,s;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",n=st(this.element),o=this.getEffectiveScaleFactor(),l=Number.isFinite(o)&&o>0?o:1,h=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*l,d={version:at,tag:this.element.localName,id:ot(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:rt(this.element,n),em:{fontSizePx:h,appliedScaleFactor:l},regions:[],metadata:{},diagnostics:nt(this.element),scaling:this.resolveScalingInfo(h),baseline:this.readBaseline()},p=null===(a=this.element.shadowRoot)||void 0===a?void 0:a.querySelector("bn-table-renderer");if(p){const t=null!==(s=p.scenarios)&&void 0!==s?s:[];if(d.metadata.scenarios=t.filter((t=>!t.startsWith("d"))),d.metadata.variances=t.filter((t=>t.startsWith("d"))),"function"==typeof p.getLayoutDetail){const t=await p.getLayoutDetail(n,r);d.regions=t.regions,d.metadata=Object.assign(Object.assign({},d.metadata),t.metadata),d.diagnostics=[...d.diagnostics,...t.diagnostics],t.elements&&(d.elements=t.elements),t.table&&(d.table=t.table)}}return d}resolveScalingInfo(t){var i,e;const a={},s=L(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===s.kind)a.unitMode="fixed",a.unitsPerEm=s.value,a.unitPxPerUnit=t/s.value;else{a.unitMode="auto";const e=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==e&&e>0&&(a.unitsPerEm=1/e,a.unitPxPerUnit=e*t)}const r=L(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)a.percentageMode="fixed",a.percentagePointsPerEm=r.value,a.percentagePxPerPoint=t/r.value;else{a.percentageMode="auto";const i=null===(e=this.lastAutoScalingReport)||void 0===e?void 0:e.percentage;void 0!==i&&i>0&&(a.percentagePointsPerEm=1/i,a.percentagePxPerPoint=i*t)}return a}getEffectiveScaleFactor(){const{mode:t,factor:i}=E(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,a,s,r;const n=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(a=i.global)||void 0===a?void 0:a.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(s=i.global)||void 0===s?void 0:s.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles(),i=this.getEffectiveScaleFactor();return a(s,{key:"42974a4931f678c35e5c740bf6d630966368fb4b",style:t},a("div",{key:"2c8f99a8bd155e2c93e55e9542090d04afe22a31"},a("bn-table-renderer",{key:"cae9e83bf297e730f12a8a390cbf279413c40b54",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,errors:this.errors,scaleFactor:i,ruleSetConfig:this.ruleSetConfig(),selectedStyle:this.selectedStyle})))}get element(){return this}static get watchers(){return{scale:[{validateScaling:0}],filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat: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}]}}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}'}},[1,"bn-table",{datasets:[513],i18nNamespace:[513,"i18n-namespace"],scale:[1],ruleset:[513],selectedStyle:[513,"selected-style"],sumTitle:[1,"sum-title"],filter:[1],measureUnit:[1,"measure-unit"],scenarios:[1],variances:[1],barColumns:[1,"bar-columns"],barColumnWidth:[1,"bar-column-width"],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],dataFormat:[1,"data-format"],grouped:[4],showMeasureScale:[4,"show-measure-scale"],showGroupTitle:[4,"show-group-title"],type:[1],limit:[2],thereof:[1],partof:[1],order:[1],orderDirection:[1,"order-direction"],measureType:[1,"measure-type"],measureScale:[1,"measure-scale"],dataFormatDigitsDecimal:[2,"data-format-digits-decimal"],dataFormatDigitsPercent:[2,"data-format-digits-percent"],categoryWidth:[1,"category-width"],columnthereof:[1],interval:[1],tableAttributes:[1,"attributes"],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],hasBlankSetnames:[32],getBaseline:[64],getLayoutState:[64]},void 0,{scale:[{validateScaling:0}],filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat: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}]}]),pt=dt,ct=function(){"undefined"!=typeof customElements&&["bn-table","bn-table-renderer"].forEach((t=>{switch(t){case"bn-table":customElements.get(r(t))||customElements.define(r(t),dt);break;case"bn-table-renderer":customElements.get(r(t))||H()}}))};export{pt as BnTable,ct as defineCustomElement}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as t,p as e,H as i,f as n,a as o,t as s}from"./p-D6YGOYV1.js";import{m as r,a as l,b as a}from"./p-DaOm9YwQ.js";import{p as h,n as c,r as u,d}from"./p-BzjGUtYh.js";import{F as f,V as p,Q as v,s as $,a as m,I as g,b}from"./p-CniN8ALm.js";import{S as w,I as E,D as S,C as y,d as R,M}from"./p-B5tixDPM.js";import{N as O,r as N}from"./p-fCjsrD7I.js";import{D as U,w as _}from"./p-Dq9dG0Kr.js";import{D as G,b as T}from"./p-sLbQ7yZ1.js";import{F as L}from"./p-DCPLGEs_.js";import{p as x,c as C}from"./p-16rjcQ0t.js";import{d as k,g as A}from"./p-DDvWTgk1.js";import{D as P,a as D,b as W}from"./p-7ieJFBUk.js";import{A as B}from"./p-BXg3v5AO.js";import{S as F}from"./p-BPGLOHUe.js";import{S as H}from"./p-CeE4_3wQ.js";import{w as Y}from"./p-DjPWZfry.js";var j,I,z,Q,V;!function(t){t[t.ALL=-1]="ALL"}(j||(j={})),function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(I||(I={})),function(t){t.LIST="list",t.SUM="sum",t.SUMNOTOTAL="sumnototal",t.OPT="opt",t.OPTNOTOTAL="optnototal"}(z||(z={})),function(t){t.ASC="asc",t.DESC="desc"}(Q||(Q={})),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"}(V||(V={}));const X="none",q="setname";function K(t){return t===q?"COALESCE([setname],[setName])":`normalizeDate([date], '${t}')`}function Z(t){if(null==t)return"";if("string"==typeof t)return t.trim();const e=J(t);return e?e.toISO():String(t)}function J(t){if(null!=t){if("string"==typeof t){const e=U.fromISO(t,{zone:"utc"});return e.isValid?e:void 0}if("number"==typeof t){const e=U.fromMillis(t,{zone:"utc"});return e.isValid?e:void 0}if("boolean"==typeof t.isValid)return t.isValid?t:void 0}}const tt=/[\s\u200e\u200f\u061c]*[%\u066a][\s\u200e\u200f\u061c]*/;class et{constructor(t,e,i,n,o,s,r,l,a){this.prefixStyle="prefix",this.isBarChart=!1,this.key=t,this.index=e,this.value=i,this.prefix=s||"",this.cssStyle=n||"",this.prefixStyle=r||"prefix",this.type=o,this.mark=void 0,this.colSpan=l||1,this.measureScale=a||1}getAsHeaderList(){if(null==this.value)return[""];const t=[];for(const e of this.value.toString().split("<br/>"))t.push(e);return t}draw(t,e){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 n=t.percent,o=t.percent;return"percentpoint"===this.type?f.number(Number(i),"percent",n,o,1,e).replace(tt,""):("decimal"===this.type&&(i=+i/this.measureScale,n=t.decimal,o=t.decimal),f.number(Number(i),this.type,n,o,1,e))}drawPrefix(){return null==this.prefix?"":this.prefix}}class it{constructor(t,e,i){this.index=t,this.groupindex=e,this.type=i,this.cssStyle=this.initCssStyle(),this.elements=[]}initCssStyle(){switch(this.type){case V.HEADER:return"groupheader";case V.SEPERATORLINE:return"";case V.DRILLELEMENT:return"ofit";case V.PARTELEMENT:return"partof";case V.STANDARD:return"";case V.SUM:return"sum";default:return""}}getCells(){return this.elements}createElement(t,e,i,n,o,s,r,l,a,h=!1,c,u=1,d){let f=s;"category"===e&&null!=l&&(f=`category-${l.toString()}`),this.type===V.HEADER?f="headerlabel":this.type===V.SEPERATORLINE&&(f=null!=s?s:e),this.type===V.PARTELEMENT&&("percent"===n&&(t="-"),"category"!==e&&"operation"!==e&&(n="percent",f="")),("-"===t||t===O&&"percent"===n)&&(f="");let p="prefix-first";r&&(p="prefix-second"),i&&(f=`${f} ${i}`);const v=new et(e,this.elements.length,t,f,n,o,p,u,a);v.isBarChart=h,v.columnStats=c,v.waterfall=d,this.elements.push(v)}}const nt=.85,ot=.3,st=.25,rt={".":.28,",":.28,"-":.34,"%":.89," ":.28," ":.28," ":.28,M:.9};function lt(t,e){var i;let n=0;for(const e of t)n+=null!==(i=rt[e])&&void 0!==i?i:/[0-9+]/.test(e)?.59:.72;return n*e*1.1}let at;function ht(t,e,i,n){const o=function(){var t,e,i;if(void 0===at)try{at="undefined"==typeof document?null:null!==(i=null===(e=(t=document.createElement("canvas")).getContext)||void 0===e?void 0:e.call(t,"2d"))&&void 0!==i?i:null}catch(t){at=null}return at}();if(o){o.font="1px __bn_font_sentinel__";const s=o.font;if(o.font=`${n?"italic ":""}${e}px ${i}`,o.font===s)return lt(t,e);const r=o.measureText(t).width;if(Number.isFinite(r)&&(r>0||""===t))return r+.15*e}return lt(t,e)}function ct(t,e){return Math.max(0,(t-.5)*e)}function ut(t,e,i){const n=void 0!==t.neg,o=void 0!==t.pos||!n,s=(t,n)=>t?e+i+(null!=n?n:0):0;return{sides:(n?1:0)+(o?1:0),neg:s(n,t.neg),pos:s(o,t.pos)}}function dt(t,e,i,n){const{sides:o,neg:s,pos:r}=ut(e,i,n),l=s+r>0?Math.min(1,t/(s+r)):1,a=Math.max(0,(t-(s+r)*l)/o);return{extent:a,axisX:void 0!==e.neg?s*l+a:0}}function ft(t,e,i,n){const o=ct(t,e),{sides:s,neg:r,pos:l}=ut(i,n/2,ot*e);return r+l+s*function(t,e,i){return Math.min(1*e,t/(2*i))}(o,e,s)<=o+1e-6}function pt(t,e){const i=.15*t;return{maxBarWidth:t,breakGap:e,overdriveZoneWidth:i,cutWidth:Math.max(0,t-e-i)}}function vt(t,e,i,n){var o,s;const r=ct(t,e),l=ot*e,{extent:a,axisX:h}=dt(r,i,st*e/2,l),c=Math.min(.3*e,.2*a),u=void 0!==i.neg,d=void 0!==i.pos||!u;let f=u?a:0;const p=Math.max(0,null!==(o=null==n?void 0:n.neg)&&void 0!==o?o:0),v=Math.max(0,null!==(s=null==n?void 0:n.pos)&&void 0!==s?s:0);u&&d&&p+v>0&&(f=(c+(2*a*.85-2*c)*p/(p+v))/.85);const $=d?u?2*a-f:a:0;return{totalWidth:r,neg:pt(f,c),pos:pt($,c),axisX:u?h-a+f:0,labelGap:l}}function $t(t,e,i,n,o){var s,r;const l=ct(t,e),a=ot*e,{extent:h,axisX:c}=dt(l,i,n/2,a),u=void 0!==i.neg,d=void 0!==i.pos||!u;let f=u?h:0,p=d?h:0;if(o&&u&&d){const t=2*h,e=Math.max(0,null!==(s=o.neg)&&void 0!==s?s:0),i=Math.max(0,null!==(r=o.pos)&&void 0!==r?r:0);e+i<=t+1e-6?(f=e+(t-e-i)/2,p=t-f):e<h?(f=e,p=t-f):i<h&&(p=i,f=t-p)}return{totalWidth:l,maxPinLength:Math.max(f,p),negPinLength:f,posPinLength:p,axisX:u?c-h+f:0,labelGap:a}}const mt={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},gt="#666666";function bt(t,e){return`pattern-${t}-${e.replace("#","")}`}const wt=({styles:e})=>{const i=e.scaleFactor,n=6*i,o=[{id:bt("pos",e.positive.stroke),stroke:e.positive.stroke,fill:e.positive.fill},{id:bt("neg",e.negative.stroke),stroke:e.negative.stroke,fill:e.negative.fill},{id:bt("neu",e.neutral.stroke),stroke:e.neutral.stroke,fill:e.neutral.fill},...["ac","pp","fc","pl"].map((t=>({id:bt(t,e.scenarios[t].stroke),stroke:e.scenarios[t].stroke,fill:e.scenarios[t].fill})))];return t("defs",null,o.map((e=>t("pattern",{id:e.id,patternUnits:"userSpaceOnUse",width:n,height:n},t("rect",{width:n,height:n,fill:"#ffffff"}),t("line",{x1:"0",y1:n,x2:n,y2:"0",stroke:e.stroke,"stroke-width":1.5*i})))))};function Et(t,e,i=1,n,o=0,s=!0,r){const l=(e,i)=>(t>0&&e!==i?"+":"")+e;if(e){const e=(t,e)=>s?f.number(t,"percent",e,e,1,n):f.number(100*t,"decimal",e,e,1,n),i=i=>l(e(t,i),e(0,i));let r=Math.min(20,Math.max(0,Math.trunc(o)||0));for(;r>0&&i(r).length>7;)r--;return i(r)}const a=t/i;if(void 0!==r){const t=t=>f.number(t,"decimal",r,r,1,n);return l(t(a),t(0))}const h=Math.abs(a);let c=1,u="";h>=9995e5?(c=1e9,u="B"):h>=999500?(c=1e6,u="M"):h>=999.5&&(c=1e3,u="K");const d=h>=10*c?0:1;return l(f.number(a/c,"decimal",d,0,1,n),f.number(0,"decimal",d,0,1,n))+u}function St(t){const e=t.slice(0,2).toLowerCase();return["ac","pp","fc","pl"].includes(e)}function yt(t){const e=t.slice(0,2).toLowerCase();return"pp"===e?"pp":"fc"===e?"fc":"pl"===e?"pl":"ac"}function Rt(t,e){if(St(t))return null;const i=new p(t);if(!i.isValid)return null;const n=yt(i.base),o=yt(i.delta);return{minuend:e.scenarios[n],minuendSlot:n,reference:e.scenarios[o],referenceSlot:o}}const Mt=({x:e,height:i,look:n,styles:o})=>{const s=o.scaleFactor,r=st*o.emPx,{reference:l,referenceSlot:a}=n;let h;if("outlined"===l.fillpattern){const n=r/2-.5*s;h=[e-n,e+n].map((e=>t("line",{x1:e,y1:0,x2:e,y2:i,stroke:l.stroke,"stroke-width":1*s})))}else h=t("line","hatched"===l.fillpattern?{x1:e,y1:0,x2:e,y2:i,stroke:l.stroke,"stroke-width":r,"stroke-dasharray":""+2*s}:{x1:e,y1:0,x2:e,y2:i,stroke:l.fill,"stroke-width":r});return t("g",{class:`variance-axis axis-${a}`},h)};function Ot(t){return void 0!==t.pos||void 0===t.neg}function Nt(t,e){return{neg:t.min<0?e:void 0,pos:t.max>0?e:void 0}}function Ut(t,e,i,n){return St(t)?function(t,e){const i=yt(t);return e.scenarios[i]}(t,n):function(t,e,i){const n=t>=0;return e?n?i.positive:i.negative:n?i.negative:i.positive}(e,i,n)}function _t(t,e){const i=t.fillpattern;return"hatched"===i?`url(#${bt(e,t.stroke)})`:"outlined"===i?"transparent":t.fill}function Gt(t){return"outlined"===t.fillpattern?{stroke:t.stroke,strokeWidth:1.5}:{stroke:"none",strokeWidth:0}}const Tt=e=>{const{value:i,scenario:n,columnStats:o,height:s,isPositiveGood:r,formattedValue:l,measureScale:a,locale:h,decimalDigits:c,columnWidthEm:u=10,labelWidths:d,sideMax:f,styles:p=mt}=e,v=p.scaleFactor,$=p.fontSize,m=l||Et(i,!1,a,h,0,!0,c),g=null!=d?d:Nt(o,ht(m,$,p.fontFamily,!1)),b=i>0||0===i&&Ot(g),{neg:w=Math.max(0,-o.min),pos:E=Math.max(0,o.max)}=null!=f?f:{},S=vt(u,p.emPx,g,{neg:w,pos:E}),{totalWidth:y,axisX:R,labelGap:M}=S,{breakGap:O,overdriveZoneWidth:N,cutWidth:U}=b?S.pos:S.neg,_=Math.abs(i)*p.unitScaling*$,G=_-U>1e-6,T=Math.max(0,(b?E:w)*p.unitScaling*$-U),L=Math.max(0,_-U),x=T>0?L/T*N:0,C=2*v,k=s-2*C,A=C,P=Rt(n,p),D=Ut(n,i,r,p),W=null==P?void 0:P.minuend.fillpattern,B="hatched"===W||"outlined"===W?Object.assign(Object.assign({},D),{fillpattern:W}):D,F=_t(B,St(n)?yt(n):r?b?"pos":"neg":b?"neg":"pos"),{stroke:H,strokeWidth:Y}=P&&"hatched"===B.fillpattern?{stroke:B.stroke,strokeWidth:1}:Gt(B),j=P?st*p.emPx/2:0,I=b?R+j:R-j,z=G?U:_,Q=G?U+O+x:_,V=b?I+Q+M:I-Q-M,X=b?"start":"end";return t("svg",{width:y,height:s,class:"cell-bar-chart absolute-variance",style:{overflow:"visible"}},t(wt,{styles:p}),!P&&t("line",{x1:R,y1:0,x2:R,y2:s,stroke:gt,"stroke-width":1*v}),z>0&&t("rect",{x:b?I:I-z,y:A,width:z,height:k,fill:F,stroke:H,"stroke-width":Y*v}),G&&x>0&&t("rect",{x:b?I+U+O:I-U-O-x,y:A,width:x,height:k,fill:F,stroke:H,"stroke-width":Y*v}),G&&function(e,i,n,o,s){const r=e+i/2,l=.35*i,a=o/3,h=.3*i;let c=`M ${r-l} ${n}`;for(let t=0;t<3;t++)c+=` L ${r-l-h} ${n+a*(t+.5)} L ${r-l} ${n+a*(t+1)}`;let u=`M ${r+l} ${n}`;for(let t=0;t<3;t++)u+=` L ${r+l+h} ${n+a*(t+.5)} L ${r+l} ${n+a*(t+1)}`;return[t("rect",{x:e,y:n-1,width:i,height:o+2,fill:"#ffffff"}),t("path",{d:c,fill:"none",stroke:"#000000","stroke-width":1*s}),t("path",{d:u,fill:"none",stroke:"#000000","stroke-width":1*s})]}(b?I+U:I-U-O,O,A,k,v),P&&t(Mt,{x:R,height:s,look:P,styles:p}),t("text",{x:V,y:s/2,dy:"0.35em","text-anchor":X,fill:p.fontColor,"font-size":$,"font-family":p.fontFamily},m))},Lt=e=>{var i,n;const{value:o,scenario:s,columnStats:r,height:l,isPositiveGood:a,formattedValue:h,measureScale:c,locale:u,percentDigits:d,percentSign:f,columnWidthEm:p=10,labelWidths:v,sideMax:$,styles:m=mt}=e,g=m.scaleFactor,b=m.fontSize,w=10*g,E=100*m.percentageScaling*b,S=h||Et(o,!0,c,u,d,f),y=null!=v?v:Nt(r,ht(S,b,m.fontFamily,!0)),{neg:R=Math.max(0,-r.min),pos:M=Math.max(0,r.max)}=null!=$?$:{},{totalWidth:O,negPinLength:N,posPinLength:U,axisX:_,labelGap:G}=$t(p,m.emPx,y,w,{neg:R*E,pos:M*E}),T=l/2,L=Math.abs(o)*E,x=o>0||0===o&&Ot(y),C=x?U:N,k=L-C>1e-6,A=x?1:-1,P=_+A*Math.min(L,C),D=Ut(s,o,a,m),W=Rt(s,m),B=null!==(i=null==W?void 0:W.minuend)&&void 0!==i?i:m.scenarios.ac,F=_+A*(C+w/2),H=F-A*w,Y=(k?F:P+A*(w/2))+A*G;return t("svg",{width:O,height:l,class:"cell-bar-chart relative-variance",style:{overflow:"visible"}},t(wt,{styles:m}),W?t(Mt,{x:_,height:l,look:W,styles:m}):t("line",{x1:_,y1:0,x2:_,y2:l,stroke:gt,"stroke-width":1*g}),t("line",{x1:_,y1:T,x2:k?H:P,y2:T,stroke:D.fill,"stroke-width":3*g}),k?t("polygon",{points:`${F},${T} ${H},${T-w/2} ${H},${T+w/2}`,fill:D.fill}):t("rect",{x:P-w/2,y:T-w/2,width:w,height:w,fill:"outlined"===B.fillpattern?"#ffffff":_t(B,null!==(n=null==W?void 0:W.minuendSlot)&&void 0!==n?n:"ac"),stroke:B.stroke,"stroke-width":1*g}),t("text",{x:Y,y:l/2,dy:"0.35em","text-anchor":x?"start":"end",fill:m.fontColor,"font-size":b,"font-style":"italic","font-family":m.fontFamily},S))},xt=e=>{const{value:i,columnStats:n,isRelative:o,styles:s=mt}=e;return null==i||isNaN(i)||!n||0===n.absMax?t("span",{class:"bar-chart-empty",style:{color:s.fontColor,fontStyle:"italic"}},"-"):t(o?Lt:Tt,Object.assign({},e))},Ct=e=>{const{value:i,scenario:n,height:o,measureScale:s,locale:r,decimalDigits:l,columnWidthEm:a=10,styles:h=mt,waterfall:c}=e,u=h.scaleFactor,d=h.fontSize,f=c.max-c.min;if(null==i||isNaN(i)||f<=0)return t("span",{class:"bar-chart-empty",style:{color:h.fontColor,fontStyle:"italic"}},"-");const{totalWidth:p,labelAreaWidth:v,barAreaWidth:$,labelGap:m}=function(t,e){const i=ct(t,e),n=Math.min(2.85*e,i/4);return{totalWidth:i,labelAreaWidth:n,barAreaWidth:i-2*n,labelGap:ot*e}}(a,h.emPx),g=$/f,b=t=>v+(t-c.min)*g,w=2*u,E=o-2*w,S=w,y=b(0),R=b(c.start),M=b(c.end),O=Math.min(R,M),N=Math.abs(M-R),U=Ut(n,i,!1,h),_=_t(U,yt(n)),{stroke:G,strokeWidth:T}=Gt(U),L=Et(i,"partof"===c.kind,s,r,0,!0,l).replace(/^\+/,""),x=M<R,C=x?O-m:O+N+m,k=x?"end":"start";return t("svg",{width:p,height:o,class:"cell-bar-chart waterfall-bar",style:{overflow:"visible"}},t(wt,{styles:h}),t("line",{x1:y,y1:0,x2:y,y2:o,stroke:gt,"stroke-width":1*u}),void 0!==c.parentStart&&void 0!==c.parentEnd&&t("line",{x1:b(c.parentStart),y1:0,x2:b(c.parentStart),y2:o,stroke:gt,"stroke-width":1*u,"stroke-dasharray":`${2*u},${2*u}`}),void 0!==c.parentStart&&void 0!==c.parentEnd&&t("line",{x1:b(c.parentEnd),y1:0,x2:b(c.parentEnd),y2:o,stroke:gt,"stroke-width":1*u,"stroke-dasharray":`${2*u},${2*u}`}),N>0&&t("rect",{x:O,y:S,width:N,height:E,fill:_,stroke:G,"stroke-width":T*u}),t("text",{x:C,y:o/2,dy:"0.35em","text-anchor":k,fill:h.fontColor,"font-size":d,"font-family":h.fontFamily},L))},kt=`IFNULL(${v.ROWGROUP}, '')`;class At{constructor(t){this.groups=[v.CATEGORY,v.CATEGORYINDEX],z.OPT!==t.type&&z.OPTNOTOTAL!==t.type||this.groups.unshift(v.OPERATION),t.grouped&&(this.groups.push(v.ROWGROUP),this.groups.push(v.ROWGROUPINDEX))}toString(){return this.groups.map((t=>t===v.ROWGROUP?kt:t)).toString()}select(){return this.groups.map((t=>t===v.ROWGROUP?`${kt} as ${t}`:t)).toString()}noCategory(){return this.groups.filter((t=>t!==v.CATEGORY))}toArray(){return this.groups}}class Pt{constructor(t,e){this.hasPartOf=!1,this.params=[],this.sortSelect="",this.hasBlankRowGroup=!1,this.config=t,this.i18n=e}execute(t,e){var i;this.db=t,this.fromExpr=e;for(const t of[...this.config.scenarios,...this.config.categoryThereOf.keys()])if(!L.test(t))throw new Error(`invalid identifier "${t}"`);const n=[],o=[],s=[],r=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(),a=this.getRelativeScenarios(),h=this.config.attributes.map((t=>this.translateAttributeSQL(t))).toString(),c=new At(this.config),u=this.config.interval===q?this.config.sortOrder:{hierarchy:this.config.sortOrder.hierarchy.map((t=>{var e,i;return null!==(i=null===(e=x(t))||void 0===e?void 0:e.column)&&void 0!==i?i:t})),direction:this.config.sortOrder.direction};let d=["",""];u.hierarchy.length>0&&(d=this.createOrderString(u)),this.hasPartOf=this.checkConfigForPartOf();const{hierarchy:f,direction:p}=u,$=f.filter((t=>t===v.ROWGROUP||t===v.ROWGROUPINDEX||t.toUpperCase()in w)),m=$.filter((t=>t.toUpperCase()in w)).map((t=>`, SUM(${t} * transformOperator(operation)) as ${t}`)).join(""),g=$.length>0?$.map((t=>`${t} ${p}`)).toString():`${v.ROWGROUPINDEX} asc`,b=t.exec(`SELECT COUNT(DISTINCT ${v.CATEGORY}) as ${v.TOTALROWCOUNT} ${this.config.grouped?`, ${kt} as ${v.ROWGROUP}, FIRST(${v.ROWGROUPINDEX}) as ${v.ROWGROUPINDEX}${m}`:""}\n FROM ${e} ${this.config.grouped?`GROUP BY ${kt} ORDER BY ${g}`:""}`);return 0===b.length||1===b.length&&0===(null!==(i=b[0][v.TOTALROWCOUNT])&&void 0!==i?i:0)&&!this.config.grouped?[]:(this.hasBlankRowGroup=this.config.grouped&&b.some((t=>""===t.rowGroup)),b.forEach((t=>{const e=this.config.grouped?""===t.rowGroup?`WHERE (${v.ROWGROUP} IS NULL OR ${v.ROWGROUP} = '')`:`WHERE ${v.ROWGROUP} = ${this.bind(t.rowGroup)}`:"";let i="";this.config.limit&&(i=`LIMIT ${this.config.limit}`),this.createGroupHeaderRow(t,n),this.createDataRow(n,t,c,r,h,e,d,i),this.createRestRow(t,n,c,r,e,d),this.createGroupSumRow(n,o,t,l,e,d)})),this.createTotalSumRow(n,o,l),n.forEach((t=>s.push(this.exec(t)))),this.detectNaNCells(this.config.scenarios,s),this.createThereOfDrillRows(r,h,d,s),this.createPartOfDrillRows(r,d,o,s),this.createIntervalColumns(s),this.createThereOfDrillColumns(this.config.categoryThereOf,s),this.calculateColumnGroupRest(s,this.config.categoryThereOf),this.calculateRelativeVariances(s,a),s)}detectNaNCells(t,e){e.forEach((e=>{e.map((e=>(t.forEach((t=>{const i=new p(t);!0===i.isValid?0!==e[i.base+"_cnt"]&&0!==e[i.delta+"_cnt"]||(e[t]=Number.NaN):0===e[t+"_cnt"]&&(e[t]=Number.NaN)})),e)))}))}createPartOfDrillRows(t,e,i,n){if(null==this.config.partOf||0===this.config.partOf.length||this.config.type===z.LIST)return;const o=this.createPartOfQuery(t,e);let s=[];const r=this.db,l=this.params;o.forEach((t=>{s.push(...this.exec(t))}));const a=this.exctractScenarioNames(t),h=[];i.forEach((function(t){h.push(...r.exec(t,l))}));const c=new Map;h.forEach((t=>c.set(t[v.ROWGROUP],t))),s=this.reduceResDrillByCategoryGroups(s,a),s.forEach((function(t){a.forEach((e=>{try{t[e]=t[e]/c.get(t[v.ROWGROUP])[e]}catch(i){console.error("DataQuery: partOf drill row calculation failed",e,i),t[e]=Number.NaN}}))})),this.injectDrillRowsToResultRows(s,n)}createRestRow(t,e,i,n,o,s){var r;if(t.totalRowCnt-this.config.limit>0&&0!==this.config.limit){const l=this.exctractScenarioNames(n).map((t=>`SUM(${t}) as ${t}`)).join(", "),a=z.OPT===this.config.type||z.OPTNOTOTAL===this.config.type?", CASE WHEN MAX(transformOperator(operation)) = -1 THEN '-' ELSE '+' END as restOperation":"";e.push(`SELECT ${v.ROWNR}, 1 as ${v.ROWGROUPINDEX} , 'ENTRY' as ${v.TYPE}, 'NO_GROUP' as ${v.ROWGROUP}, ${this.bind(String(null!==(r=t.rowGroup)&&void 0!==r?r:""))} as restRowGroup, 'REST' as ${v.CATEGORY}${a} ${l.length>0?", "+l:""} FROM (SELECT ROWNUM() AS ${v.ROWNR}, ${e.length} as ${v.ROWGROUPINDEX} , 'ENTRY' as ${v.TYPE}, ${this.bind(String(t.rowGroup||"NO_GROUP"))} as ${v.ROWGROUP}, ${i.select()} ${n.length>0?",".concat(n):""}${this.sortSelect} FROM ${this.fromExpr} ${o} GROUP BY ${i} ORDER BY ${s[0]}) t WHERE t.rowNr > ${this.config.limit}`)}}createDataRow(t,e,i,n,o,s,r,l){t.push(`SELECT ROWNUM() AS ${v.ROWNR},\n ${t.length} as ${v.ROWGROUPINDEX},\n 'ENTRY' as ${v.TYPE},\n ${this.bind(String(e.rowGroup||"NO_GROUP"))} as ${v.ROWGROUP},\n '${v.CATEGORYINDEX}',\n ${i.select()} ${n.length>0?",".concat(n):""} ${o.length>0?",".concat(o):""}${this.sortSelect}\n FROM ${this.fromExpr} ${s}\n GROUP BY ${i}\n ORDER BY ${r[0]} ${l}`)}createGroupHeaderRow(t,e){if(!0===this.config.grouped&&(this.config.showGroupTitle||!this.hasGroupSum())){const i=this.bind(String(t.rowGroup)),n=""===t.rowGroup?this.bind("-"):i;e.push(`SELECT ROWNUM() AS ${v.ROWNR},\n ${e.length} as ${v.ROWGROUPINDEX},\n 'GROUPHEAD' as ${v.TYPE},\n ${i} as ${v.ROWGROUP} ${this.config.showGroupTitle?`,${n} as ${v.CATEGORY}`:""}\n FROM ${this.fromExpr}\n GROUP BY '1'`)}}hasGroupSum(){return z.SUM===this.config.type||z.SUMNOTOTAL===this.config.type||z.OPT===this.config.type||z.OPTNOTOTAL===this.config.type}createGroupSumRow(t,e,i,n,o,s){if(!0===this.config.grouped&&this.hasGroupSum()){const r=this.bind(String(i.rowGroup));t.push(`SELECT ${t.length} as ${v.ROWGROUPINDEX},\n '=' as ${v.OPERATION},\n ${r} as ${v.ROWGROUP},\n ROWNUM() AS ${v.ROWNR},\n 'GROUP_SUM' as ${v.TYPE} ${n.length>0?",".concat(n):""}\n FROM ${this.fromExpr} ${o}\n ORDER BY ${s[0]} `),e.push(`SELECT ${t.length} as ${v.ROWGROUPINDEX},\n '=' as ${v.OPERATION},\n ${r} as ${v.ROWGROUP},\n ROWNUM() AS ${v.ROWNR},\n 'GROUP_SUM' as ${v.TYPE} ${n.length>0?",".concat(n):""}\n FROM ${this.fromExpr} ${o}\n ORDER BY ${s[0]} `)}}createTotalSumRow(t,e,i){var n;if(z.SUM===this.config.type||z.OPT===this.config.type){const e=(null===(n=this.config.title)||void 0===n?void 0:n.trim())||"SUM_TOTAL",o=this.hasPartOf&&!1===this.config.grouped&&"SUM_TOTAL"!==e?`${this.i18n.get("SUM_TOTAL")||"SUM_TOTAL"} ${e}`:e;t.push(`SELECT ${t.length} as ${v.ROWGROUPINDEX},\n ${this.bind(o)} as ${v.ROWGROUP},\n '=' as ${v.OPERATION},\n 'SUM' as ${v.TYPE} ${i.length>0?",".concat(i):""}\n FROM ${this.fromExpr} `)}e.push(`SELECT ${t.length} as ${v.ROWGROUPINDEX},\n 'SUM_TOTAL' as ${v.ROWGROUP},\n '=' as ${v.OPERATION},\n 'SUM' as ${v.TYPE} ${i.length>0?",".concat(i):""}\n FROM ${this.fromExpr} `)}reduceResDrillByCategoryGroups(t,e){const i=new Map;return t.forEach((function(t){const n=t.rowNr+t.rowGroup+t.type+t.category;if(i.has(n)){const o=i.get(n);e.forEach((e=>{try{o[e]+=t[e]}catch(t){console.error("DataQuery: drill row aggregation failed",e,t)}}))}else i.set(n,t)})),[...i.values()]}injectDrillRowsToResultRows(t,e){const i=new Map;if(!0===this.config.grouped)t.forEach((function(t){e.forEach((function(e){const n=e.findIndex((e=>e.category===t.category&&e.rowGroup===t.rowGroup));if(n>=0){if(i.has(`${t.category}_${t.rowGroup}`)){const e=i.get(`${t.category}_${t.rowGroup}`)||0;i.set(`${t.category}_${t.rowGroup}`,e+1)}else i.set(`${t.category}_${t.rowGroup}`,1);t[v.ROWNR]=i.get(`${t.category}_${t.rowGroup}`),e.splice(n+t[v.ROWNR],0,t)}}))}));else{const n=this.findDuplicateSubCategories(t);t.forEach((function(t){e.forEach((function(e){const o=e.findIndex((e=>null!=e.category&&e.category===t.category));if(o>=0){if(i.has(`${t.category}`)){const e=i.get(`${t.category}`)||0;i.set(`${t.category}`,e+1)}else i.set(`${t.category}`,1);null!=t.rowGroup&&""!==t.rowGroup&&n.includes(`${t.category}##${t.subCategory}`)&&(t.rawSubCategory=t.subCategory,t.subCategory=`${t.subCategory} (${t.rowGroup})`),e.splice(o+t[v.ROWNR],0,t)}}))}))}}createThereOfDrillRows(t,e,i,n){if(void 0===this.config.thereOf||0===this.config.thereOf.length)return;const o=[],s=[];this.config.thereOf.forEach((n=>{let s=!0,r="1 <> 1 OR ( ";null!=n.category&&0!==n.category.length&&n.category.trim()&&(r+=` ${v.CATEGORY} = ${this.bind(n.category)}`,s=!1),null!=n.rowGroup&&0!==n.rowGroup.length&&n.rowGroup.trim()&&(r+=` ${s?"":"AND"} ${v.ROWGROUP} = ${this.bind(n.rowGroup)}`,s=!1),null!=n.subCategory&&0!==n.subCategory.length&&n.subCategory.trim()&&(r+=` ${s?"":"AND"} ${v.SUBCATEGORY} = ${this.bind(n.subCategory)}`),r+=")",o.push(`SELECT ROWNUM() AS ${v.ROWNR},\n null as operation,\n 'DRILLELEMENT' as ${v.TYPE},\n ${v.CATEGORY},\n ${v.SUBCATEGORY},\n ${this.drillRowGroup} as ${v.ROWGROUP},\n ${t} ${e.length>0?",".concat(e):""}${this.sortSelect}\n FROM ${this.fromExpr}\n WHERE ${r}\n GROUP BY ${this.drillRowGroup}, ${v.CATEGORY}, ${v.SUBCATEGORY}\n ORDER BY ${i[1]}`)})),o.forEach((t=>{s.push(...this.exec(t))})),this.injectDrillRowsToResultRows(s,n)}calculateRelativeVariances(t,e){t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[v.TYPE]&&e.forEach(((e,i)=>{var n;t[i]=null!==(n=N(t[i],t[e]))&&void 0!==n?n:O}))}))}))}calculateColumnGroupRest(t,e){if(null==e||0===e.size)return;const i=new Map,n=new Map;e.forEach(((t,e)=>{const o=t,s=[];for(const t of o)s.push(`${e}##${t.name}`);i.set(e,s),n.set(`${e}##REST`,!1)})),t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[v.TYPE]&&i.forEach(((e,i)=>{let o=0;e.forEach((e=>{void 0!==t[e]&&(o+=t[e])})),t[`${i}##REST`]=t[i]-o,0!==t[`${i}##REST`]&&n.set(`${i}##REST`,!0)}))}))}));const o=Array.from(n.entries()).filter((([t,e])=>!e)).map((([t])=>t));t.forEach((t=>{t.forEach((t=>{for(const e of o)delete t[e]}))}))}createIntervalColumns(t){var e,i,n,o,s;if(this.config.interval===X||this.config.categoryThereOf.size>0||0===this.config.scenarios.length)return;const r="##",l=`(SELECT *, ${K(this.config.interval)} as __interval FROM ${this.fromExpr}) as p`,a=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),h=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),c=[...new Set(this.exctractScenarioNames(a))],u=this.getRelativeScenarios(),d=new At(this.config),f=z.OPT===this.config.type||z.OPTNOTOTAL===this.config.type,$=this.config.grouped&&(z.SUM===this.config.type||z.SUMNOTOTAL===this.config.type||z.OPT===this.config.type||z.OPTNOTOTAL===this.config.type),m=this.checkConfigForPartOf()&&this.config.type!==z.LIST,g=t=>this.exec(t),b=t=>(this.config.scenarios.forEach((e=>{const i=new p(e);!0===i.isValid?0!==t[i.base+"_cnt"]&&0!==t[i.delta+"_cnt"]||(t[e]=Number.NaN):0===t[e+"_cnt"]&&(t[e]=Number.NaN)})),u.forEach(((e,i)=>{var n;t[i]=null!==(n=N(t[i],t[e]))&&void 0!==n?n:O})),t),w=(t,e,i)=>{for(const n of this.config.scenarios)t[n+r+i]=e[n]},E=g(`SELECT ${d.select()}, __interval ${a.length>0?",".concat(a):""}\n FROM ${l}\n GROUP BY ${d}, __interval`),S=t=>"ENTRY"===t.type&&null!=t.restRowGroup;if(this.config.limit>0)for(let n=0;n<t.length;n++){const o=t[n].find(S);if(!o)continue;let s;for(let e=n-1;e>=0&&!s;e--){const i=t[e].filter((t=>"ENTRY"===t.type&&!S(t)));i.length>0&&(s=i)}if(!s)continue;const r=new Set(s.map((t=>t.category))),l=s[0].rowGroup,a=new Map;for(const t of E){if(this.config.grouped&&t.rowGroup!==l)continue;if(r.has(t.category))continue;const n=Z(t.__interval);let o=a.get(n);o||(o={},a.set(n,o));for(const n of c)o[n]=(null!==(e=o[n])&&void 0!==e?e:0)+(null!==(i=t[n])&&void 0!==i?i:0)}a.forEach(((t,e)=>{w(o,b(t),e)}))}for(const e of E){const i=Z(e.__interval);b(e);for(const n of t)for(const t of n)"ENTRY"!==t.type||S(t)||t.category!==e.category||this.config.grouped&&t.rowGroup!==e.rowGroup||f&&t.operation!==e.operation||w(t,e,i)}const y=$||m&&this.config.grouped?g(`SELECT ${kt} as ${v.ROWGROUP}, __interval ${h.length>0?",".concat(h):""}\n FROM ${l}\n GROUP BY ${kt}, __interval`):[],R=new Map;if(y.forEach((t=>R.set(`${t.rowGroup}${r}${Z(t.__interval)}`,t))),$)for(const e of y){const i=Z(e.__interval),n=b(Object.assign({},e));for(const o of t)for(const t of o)"GROUP_SUM"===t.type&&t.rowGroup===e.rowGroup&&w(t,n,i)}const M=z.SUM===this.config.type||z.OPT===this.config.type,U=M||m&&!this.config.grouped?g(`SELECT __interval ${h.length>0?",".concat(h):""}\n FROM ${l}\n GROUP BY __interval`):[],_=new Map;if(U.forEach((t=>_.set(Z(t.__interval),t))),M)for(const e of U){const i=Z(e.__interval),n=b(Object.assign({},e));for(const e of t)for(const t of e)"SUM"===t.type&&w(t,n,i)}if(null!=this.config.thereOf&&this.config.thereOf.length>0){const e=[];this.config.thereOf.forEach((t=>{e.push(...g(`SELECT ${this.drillRowGroup} as ${v.ROWGROUP}, ${v.CATEGORY}, ${v.SUBCATEGORY}, __interval ${a.length>0?",".concat(a):""}\n FROM ${l}\n WHERE ${this.createThereOfWhereClause(t)}\n GROUP BY ${this.drillRowGroup}, ${v.CATEGORY}, ${v.SUBCATEGORY}, __interval`))}));for(const i of e){const e=Z(i.__interval);b(i);for(const n of t)for(const t of n)"DRILLELEMENT"===t.type&&t.category===i.category&&t.rowGroup===i.rowGroup&&(t.subCategory!==i.subCategory&&t.subCategory!==`${i.subCategory} (${i.rowGroup})`||w(t,i,e))}}if(m){let e="1 <> 1 ";null===(n=this.config.partOf)||void 0===n||n.forEach((t=>{e+=`OR (${v.CATEGORY} = ${this.bind(t.category)}`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(e+=`and ${v.ROWGROUP} = ${this.bind(t.rowGroup)}`),e+=")"}));const i=g(`SELECT ${v.CATEGORY}, ${this.config.grouped?`${v.ROWGROUP}`:`'SUM_TOTAL' as ${v.ROWGROUP}`}, __interval ${a.length>0?",".concat(a):""}\n FROM ${l}\n WHERE ${e}\n GROUP BY ${v.ROWGROUP}, ${v.CATEGORY}, __interval`),h=new Map;for(const t of i){const e=`${t.rowGroup}${r}${t.category}${r}${Z(t.__interval)}`,i=h.get(e);if(i)for(const e of c)i[e]=(null!==(o=i[e])&&void 0!==o?o:0)+(null!==(s=t[e])&&void 0!==s?s:0);else h.set(e,t)}h.forEach((e=>{const i=Z(e.__interval),n=this.config.grouped?R.get(`${e.rowGroup}${r}${i}`):_.get(i);for(const t of c)e[t]=e[t]/(n?n[t]:Number.NaN);b(e);for(const n of t)for(const t of n)"PARTELEMENT"===t.type&&t.category===e.category&&t.rowGroup===e.rowGroup&&w(t,e,i)}))}}createThereOfWhereClause(t){let e=!0,i="1 <> 1 OR ( ";return null!=t.category&&0!==t.category.length&&t.category.trim()&&(i+=` ${v.CATEGORY} = ${this.bind(t.category)}`,e=!1),null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(i+=` ${e?"":"AND"} ${v.ROWGROUP} = ${this.bind(t.rowGroup)}`,e=!1),null!=t.subCategory&&0!==t.subCategory.length&&t.subCategory.trim()&&(i+=` ${e?"":"AND"} ${v.SUBCATEGORY} = ${this.bind(t.subCategory)}`),i+")"}getRelativeScenarios(){const t=new Map;return this.config.scenarios.forEach((e=>{const i=this.createRelativeScenario(e);null!=i&&t.set(i.key,i.value)})),t}translateScenarioSQL(t,e,i){const n=new p(t);if(z.OPT===i||z.OPTNOTOTAL===i){if(n.isValid){const i=e?" * transformOperator(operation)":"",o=e?`SUM((${n.base} - ${n.delta})${i}) as ${t}`:`SUM(${n.base} - ${n.delta}) as ${t}`;return"dr"===n.type?`${o}, SUM(${n.delta}${i}) as dr_${n.delta}`:o}return e?`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`:`SUM(${t}) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}return n.isValid?"dr"===n.type?`SUM((${n.base} * transformOperator(operation)) - (${n.delta} * transformOperator(operation))) as ${t}, SUM(${n.delta} * transformOperator(operation)) as dr_${n.delta}`:`SUM((${n.base} * transformOperator(operation))- (${n.delta} * transformOperator(operation))) as ${t}`:`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}translateAttributeSQL(t){const e=`[${t.arg}]`,i=/^(ac|pp|fc|pl)[1-4]$/.test(t.arg)&&this.config.type!==z.OPT&&this.config.type!==z.OPTNOTOTAL;switch(t.fn){case"set":return`SETAGG(${e}) as ${t.alias}`;case"first":return`FIRST(${e}) as ${t.alias}`;case"last":return`LAST(${e}) as ${t.alias}`;case"min":return`MIN(${e}) as ${t.alias}`;case"max":return`MAX(${e}) as ${t.alias}`;case"avg":return i?`AVG(${e} * transformOperator(operation)) as ${t.alias}`:`AVG(${e}) as ${t.alias}`;case"sum":return i?`SUM(${e} * transformOperator(operation)) as ${t.alias}`:`SUM(${e}) as ${t.alias}`;case"lit":{const e=t.arg;return`${this.bind(""===e||Number.isNaN(Number(e))?e:Number(e))} as ${t.alias}`}}}get drillRowGroup(){return this.config.grouped?kt:v.ROWGROUP}exec(t){const e=this.db.exec(t,this.params);return this.config.grouped&&e.forEach((t=>t.rowGroup=null==t.rowGroup?"":String(t.rowGroup))),e}bind(t){return`$${this.params.push(t)-1} `}createOrderString(t){const e=Q.ASC===t.direction?Q.DESC:Q.ASC,i=new Map;t.hierarchy.forEach(((t,e)=>{const n=x(t),o=null==n?void 0:n.bucket;("variance"===(null==n?void 0:n.kind)||"scenario"===(null==n?void 0:n.kind)&&void 0!==o)&&i.set(e,this.translateSortKeySQL(n,o,e))})),this.sortSelect=[...i.values()].map((t=>`, ${t}`)).join("");const n=t.hierarchy.some((t=>{var e;const i=null===(e=x(t))||void 0===e?void 0:e.kind;return"scenario"===i||"variance"===i}));n&&(this.sortSelect+=`, CASE WHEN ${v.CATEGORY} = 'REST' THEN 1 ELSE 0 END as __sortrest`);const o=(t,e,n)=>i.has(e)?`__sortnull${e} asc, __sort${e} ${n}`:`${t} ${n}`,s=t.hierarchy.map(((e,i)=>o(e,i,t.direction))).toString(),r=t.hierarchy.map(((t,i)=>o(t,i,e))).toString();return n?[`__sortrest asc, ${s}`,`__sortrest desc, ${r}`]:[s,r]}translateSortKeySQL(t,e,i){const n=z.OPT===this.config.type||z.OPTNOTOTAL===this.config.type?"":" * transformOperator(operation)",o=void 0===e?"":`TRIM(CAST(${K(q)} AS STRING)) = ${this.bind(e)}`,s=t=>`SUM(${o?`(CASE WHEN ${o} THEN ${t} ELSE 0 END)`:t}${n})`,r=t=>`SUM(CASE WHEN ${o?`${o} AND `:""}${t} IS NOT NULL THEN 1 ELSE 0 END) = 0`;if("scenario"===t.kind)return`${s(t.column)} as __sort${i}, CASE WHEN ${r(t.column)} THEN 1 ELSE 0 END as __sortnull${i}`;const l=`(${s(t.base)} - ${s(t.delta)})`;let a=l,h=`${r(t.base)} OR ${r(t.delta)}`;if("dr"===t.type){const e=s(t.delta),i=`ABS(${e}) <= ABS(${l}) * 0.000000001`;a=`CASE WHEN ${i} THEN 0 ELSE ${l} / ABS(${e}) END`,h+=` OR ${i}`}return`${a} as __sort${i}, CASE WHEN ${h} THEN 1 ELSE 0 END as __sortnull${i}`}createRelativeScenario(t){const e=new p(t);return e.isValid&&"dr"===e.type?{key:`${t}`,value:`dr_${e.delta}`}:null}exctractScenarioNames(t){const e=[];return t.split(",").forEach((t=>t.length>=2?e.push(t.split("as")[1].trim()):null)),e}findDuplicateSubCategories(t){const e=t.map((t=>({count:1,subCategory:`${t.category}##${t.subCategory}`}))).reduce(((t,e)=>(t[e.subCategory]=(t[e.subCategory]||0)+e.count,t)),{});return Object.keys(e).filter((t=>e[t]>1))}createPartOfQuery(t,e){var i;const n=[];let o="1 <> 1 ",s=` ${this.drillRowGroup} as ${v.ROWGROUP}`,r="ROWNUM()";return null===(i=this.config.partOf)||void 0===i||i.forEach((t=>{o+=`OR (${v.CATEGORY} = ${this.bind(t.category)}`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(o+=`and ${v.ROWGROUP} = ${this.bind(t.rowGroup)}`),!1===this.config.grouped&&(s=` 'SUM_TOTAL' as ${v.ROWGROUP} `,r="1"),o+=")"})),n.push(`SELECT ${r} AS ${v.ROWNR},\n 'PARTELEMENT' as ${v.TYPE},\n ${v.CATEGORY},\n ${s},\n ${t}${this.sortSelect}\n FROM ${this.fromExpr}\n WHERE ${o}\n GROUP BY ${this.drillRowGroup}, ${v.CATEGORY}, ${v.TYPE}\n ORDER BY ${e[1]}`),n}checkConfigForPartOf(){return null!=this.config.partOf&&0!==this.config.partOf.length}createThereOfDrillColumns(t,e){if(null==t||0===t.size)return;const i=[],n=[],o=this.fromExpr;t.forEach(((t,e)=>{let n="1 <> 1 ";t.forEach((t=>{n+=` or columnGroup = ${this.bind(String(t.name))} `})),i.push(`SELECT 'ENTRY' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, category, columnGroup, scenario`),i.push(`SELECT 'ENTRY' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, category, columnGroup, columnSubGroup, scenario`),i.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, scenario`),i.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, columnSubGroup, scenario`),i.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, columnGroup, scenario`),i.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, columnGroup, columnSubGroup, scenario`),i.push(`SELECT 'SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, columnGroup, scenario`),i.push(`SELECT 'SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, columnGroup, columnSubGroup, scenario`)}));for(const t of i)n.push(...this.db.exec(t,this.params));this.injectDrillColumnsToResultRows(n,e)}injectDrillColumnsToResultRows(t,e){const i="##";for(const n of t)for(const t of e)for(const e of t)if(e.type===n.rowlevel)if("ENTRY"===n.rowlevel)"COLUMNGROUP"===n.columnlevel&&e.category===n.category?e[n.scenario+i+n.columnGroup]=n.val:"SUBGROUP"===n.columnlevel&&e.category===n.category&&(e[n.scenario+i+n.columnGroup+i+n.columnSubGroup]=n.val);else if("DRILLELEMENT"===n.rowlevel){if(!this.config.grouped&&e.rowGroup!==n.rowGroup)continue;"COLUMNGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory?e[n.scenario+i+n.columnGroup]=n.val:"SUBGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory?e[n.scenario+i+n.columnGroup+i+n.columnSubGroup]=n.val:"COLUMNGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===`${n.subCategory} (${n.rowGroup})`?e[n.scenario+i+n.columnGroup]=n.val:"SUBGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===`${n.subCategory} (${n.rowGroup})`&&(e[n.scenario+i+n.columnGroup+i+n.columnSubGroup]=n.val)}else("SUM"===n.rowlevel||"GROUP_SUM"===n.rowlevel)&&("COLUMNGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory&&(e[n.scenario+i+n.columnGroup]=n.val),"SUBGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory&&(e[n.scenario+i+n.columnGroup+i+n.columnSubGroup]=n.val))}}class Dt{constructor(){this.geometry=new Map}set(t,e,i){let n=this.geometry.get(t);n||(n=new Map,this.geometry.set(t,n)),n.set(e,i)}get(t,e){var i;return null===(i=this.geometry.get(t))||void 0===i?void 0:i.get(e)}}function Wt(t,e,i){const n=t[e];if(null==n)return null;const o=Number(n);return isNaN(o)?null:i!==z.OPT&&i!==z.OPTNOTOTAL||t[v.TYPE]!==V.ENTRY||"-"!==t[v.OPERATION]?o:-o}class Bt{constructor(t){this.ruleSet=t,this.normalizedHeader=[],this.attributesByAlias=new Map,this.hasBlankRowGroup=!1,this.dateBuckets=!1,this.unsignedEntries=!1}underlineClass(t){return this.ruleSet&&/^(ac|pp|fc|pl)[1-4]$/.test(t)?$(this.ruleSet.getScenarioColorIndex(t))+t.slice(2):null}getNormalizedHeader(){return this.normalizedHeader}createHeader(t,e,i,n,o,s,r=[]){const l=[];this.attributesByAlias=new Map(r.map((t=>[t.alias,t]))),this.normalizedHeader=this.normalizeHeader(t,e,r);const a=this.normalizedHeader.some((t=>void 0!==t.bucket));a&&l.push(this.createIntervalBandRow());const h=new it(a?1:0,0,V.HEADER),c=new it(a?2:1,0,V.SEPERATORLINE);for(const t of this.normalizedHeader){const e=this.attributesByAlias.get(t.name);h.createElement(e?i.get(e.label)||e.label:f.translateScenarioLabel(t.name,i),t.type,this.createColumnType(t),null,this.setHeaderPrefix(t,i,n,o,s),null,null,null,null),c.createElement(null,t.type,this.createColumnType(t),null,null,this.underlineClass(t.type),null,null,null)}return l.push(h),l.push(c),l}createIntervalBandRow(){const t=new it(0,0,V.HEADER);let e=0;for(;e<this.normalizedHeader.length;){const i=this.normalizedHeader[e];if(void 0===i.bucket){t.createElement(null,i.type,"filler",null,null,null,null,null,null),e+=1;continue}let n=1;for(;e+n<this.normalizedHeader.length&&this.normalizedHeader[e+n].bucket===i.bucket;)n+=1;t.createElement(i.bucketLabel,i.type,"intervalGroup",null,null,null,null,null,null,!1,void 0,n),e+=n}return t}setHeaderPrefix(t,e,i,n,o){let s="";return"category"===t.name&&o&&(0===i.prefix.length&&0===n.length||(s=f.translateScenarioLabel("in",e)+" "+i.prefix+n)),t.order&&(s+=f.translateScenarioLabel("ORDER_"+t.order,e)),s}normalizeHeader(t,e,i){let n=[{name:v.CATEGORY,group:v.CATEGORY,type:v.CATEGORY,order:void 0}];z.OPT!==t&&z.OPTNOTOTAL!==t||(n=[{name:v.OPERATION,group:v.OPERATION,type:v.OPERATION,order:void 0},{name:v.CATEGORY,group:v.CATEGORY,type:v.CATEGORY,order:void 0}]);const o=i.map((t=>({name:t.alias,group:t.alias,type:t.alias,order:void 0})));return[...n,...o,...e]}createBodyRows(t,e,i,n){var o;const s=[];let r=-1;const l=new Pt(t,e);var a;this.dateBuckets=(a=t.interval)!==X&&a!==q,this.unsignedEntries=z.OPT===t.type||z.OPTNOTOTAL===t.type;const h=l.execute(i,n);this.hasBlankRowGroup=l.hasBlankRowGroup;const c=this.calculateColumnStatistics(h,t.barColumns,t.interval!==X),u=(null!==(o=t.barColumns)&&void 0!==o?o:[]).filter((t=>t.toUpperCase().trim()in w)),d=u.length>0&&t.interval===X&&0===t.categoryThereOf.size&&function(t){for(const e of t)for(const t of e){const e=t[v.TYPE];if(e===V.SUM||e===V.GROUPSUM||e===V.DRILLELEMENT||e===V.PARTELEMENT)return!0}return!1}(h)?function(t,e,i){const n=new Dt;for(const o of e){let e,s=0,r=0;const l=[],a=(t,e)=>{l.push(e),n.set(t,o,e)};for(const n of t)for(const t of n){const n=t[v.TYPE];if(n===V.GROUPHEAD){s=0,e=void 0;continue}const l=Wt(t,o,i);if(n===V.ENTRY){if(null===l){e=void 0;continue}a(t,{start:s,end:s+l,min:0,max:0,kind:"cascade"}),e={start:s,end:s+l},r=e.start,s+=l}else if(n===V.SUM||n===V.GROUPSUM){if(null===l){e=void 0;continue}a(t,{start:0,end:l,min:0,max:0,kind:"anchor"}),e={start:0,end:l},r=0,s=n===V.GROUPSUM?0:l}else if(n===V.DRILLELEMENT){if(null===l||void 0===e)continue;const i=r+(Math.sign(e.end-e.start)||1)*Math.abs(l);a(t,{start:r,end:i,min:0,max:0,kind:"thereof",parentStart:e.start,parentEnd:e.end}),r=i}else if(n===V.PARTELEMENT){if(null===l||void 0===e)continue;const i=r+l*(e.end-e.start);a(t,{start:r,end:i,min:0,max:0,kind:"partof",parentStart:e.start,parentEnd:e.end}),r=i}}let h=0,c=0;for(const t of l)h=Math.min(h,t.start,t.end),c=Math.max(c,t.start,t.end);for(const t of l)t.min=h,t.max=c}return n}(h,u,t.type):void 0;for(const i of h)r+=1,s.push(...this.createRow(t.i18n,e,t.scenariosUnitType,i,r,-1,t.categoryWidth,t.measureScale,t.barColumns,c,d));return s}calculateColumnStatistics(t,e,i=!1){const n=new Map;if(!e||0===e.length)return n;const o=new Map;for(const t of e)n.set(t,{min:1/0,max:-1/0,absMax:0,median:0}),o.set(t,[]);for(const s of t)for(const t of s){const s=t[v.TYPE];if(s!==V.SUM&&s!==V.GROUPSUM)for(const s of e){const e=i?this.extractIntervalColumnValues(t,s):[this.extractColumnValue(t,s)];for(const t of e)if(null!==t&&!isNaN(t)){const e=n.get(s);e.min=Math.min(e.min,t),e.max=Math.max(e.max,t),o.get(s).push(Math.abs(t))}}}for(const[t,e]of n){e.min!==1/0&&e.max!==-1/0||(e.min=0,e.max=0),e.absMax=Math.max(Math.abs(e.min),Math.abs(e.max));const i=o.get(t);if(i.length>0){i.sort(((t,e)=>t-e));const t=Math.floor(i.length/2);e.median=i.length%2==0?(i[t-1]+i[t])/2:i[t]}n.set(t,e)}return n}extractIntervalColumnValues(t,e){const i=e+"##",n=[];for(const e of Object.keys(t))if(e.startsWith(i)){const i=Number(t[e]);n.push(isNaN(i)?null:i)}return n}extractColumnValue(t,e){if(void 0!==t[e]){const i=Number(t[e]);return isNaN(i)?null:i}for(const i of Object.keys(t))if(i===e||i.endsWith("##"+e)||i===e+"##"+e){const e=Number(t[i]);if(!isNaN(e))return e}return null}createRow(t,e,i,n,o,s,r,l,a,c,u){var d,f,$;const m=[];let g;for(const b of n){const w=b[v.ROWGROUP],E=""===w?"-":w,S=b[v.SUBCATEGORY],y=b[v.TYPE],R=b[v.ROWNR]>=2;g=null!==(f=null!==(d=b.operation)&&void 0!==d?d:b.restOperation)&&void 0!==f?f:g;const M=this.createDetailRow(y,s+=1,o,n.length);M.key=this.rowKey(b);for(const n of this.normalizedHeader){const o=this.getRawDataRowElement(b,n),s=null!==($=null==a?void 0:a.includes(n.type))&&void 0!==$&&$,d=s?null==c?void 0:c.get(n.type):void 0,f=s&&void 0===n.bucket&&n.name===n.group&&n.name===n.type?null==u?void 0:u.get(b,n.type):void 0;M.createElement(this.translateSumCellLabel(t,e,o,E,S,y,n.type),n.type,this.createColumnType(n),this.setCellType(n.type,i),this.translateCellPrefix(e,y,n.type),this.translateScenarioCSS(n.type,o,g),R,r,null==l?void 0:l.value,s,d,1,f);const v=M.elements[M.elements.length-1];this.dateBuckets&&void 0!==n.bucket&&(v.date=h(n.bucket));const m=new p(n.type);m.isValid&&(v.direction=this.resolveDirection(m,g))}m.push(M)}return m}rowKey(t){var e;const i=null!=t.restRowGroup?t.restRowGroup:"NO_GROUP"===t.rowGroup?void 0:t.rowGroup;switch(t.type){case V.ENTRY:return{rowGroup:i,category:t.category,subCategory:t.subCategory};case V.DRILLELEMENT:return{rowGroup:i,category:t.category,subCategory:null!==(e=t.rawSubCategory)&&void 0!==e?e:t.subCategory};case V.GROUPSUM:return{rowGroup:i,row:"subtotal"};case V.SUM:return{row:"total"};default:return}}getRawDataRowElement(t,e){return void 0!==e.bucket?t[e.type+"##"+e.bucket]:e.name===e.group&&e.name===e.type?t[e.name]:e.name===e.group&&e.name!==e.type?t[e.type+"##"+e.name]:t[e.type+"##"+e.group+"##"+e.name]}createDetailRow(t,e,i,n){switch(t){case V.GROUPHEAD:return new it(e,i,V.HEADER);case V.SUM:case V.GROUPSUM:return new it(n+2,i,V.SUM);case V.DRILLELEMENT:return new it(n+2,i,V.DRILLELEMENT);case V.PARTELEMENT:return new it(n+2,i,V.PARTELEMENT);default:return new it(e,i,V.STANDARD)}}translateSumCellLabel(t,e,i,n,o,s,r){return this.attributesByAlias.has(r)||!1===Number.isNaN(Number(i))||this.isOperationColumn(r)?i:this.isGroupHeadCategory(s,r)?t===E.ALL?`${e.get(i)||i}`:i:this.isEntryCategory(s,r)?t===E.ALL||"REST"===i?`${e.get(i)||i}`:i:this.isDrillElementCategory(s,r)?t===E.ALL?`${e.get(o)||o}`:`${o}`:this.isPartElementCategory(s,r)?t===E.ALL||"SUM_TOTAL"===n?`${e.get(n)||n}`:`${n}`:this.isSumElementCategory(s,r)?t===E.ALL||"SUM_TOTAL"===n?`${e.get(n)||n}`:n:"GROUPHEAD"===s&&null==i||i===O?i:Number.isNaN(Number(i))?"-":Number(i)}isOperationColumn(t){return"operation"===t}translateScenarioCSS(t,e,i){if(this.attributesByAlias.has(t))return"attribute";const n=new p(t);let o="pos";return e<0&&(o="neg"),n.isValid?o+"_"+this.resolveDirection(n,i)+("dr"===n.type?" relative_variance":""):t}resolveDirection(t,e){return m(t.direction,e,!this.unsignedEntries)}setCellType(t,e){if("category"===t)return"";const i=this.attributesByAlias.get(t);if(i)return i.isNumeric?"decimal":"";let n;const o=new p(t);return e===S.PERCENT?(n="percent",o.isValid&&"d"===o.type&&(n="percentpoint")):(n="decimal",o.isValid&&"dr"===o.type&&(n="percent")),n}isDrillElementCategory(t,e){return"DRILLELEMENT"===t&&"category"===e}isPartElementCategory(t,e){return"PARTELEMENT"===t&&"category"===e}isSumElementCategory(t,e){return("GROUP_SUM"===t||"SUM"===t)&&"category"===e}isEntryCategory(t,e){return"ENTRY"===t&&"category"===e}isGroupHeadCategory(t,e){return"GROUPHEAD"===t&&"category"===e}translateCellPrefix(t,e,i){return this.isOperationColumn(i)||this.isGroupHeadCategory(e,i)||this.isEntryCategory(e,i)?null:this.isDrillElementCategory(e,i)?`${t.get("thereof")} `:this.isPartElementCategory(e,i)?`${t.get("part_of")} `:null}createColumnType(t){return t.name===t.group&&t.name===t.type?"base":t.name===t.group?"columnGroup":"columnSubGroup"}}class Ft{constructor(t,e,i,n){this.fromExpr="",this.rowCount=0,this.headerRows=[],this.bodyRows=[],this.intervalBuckets=[],this.ruleSet=t||new g,this.db=e,this.dataSetFactory=new Bt(this.ruleSet),this.config=this.initConfig(n),this.i18n=this.initI18n(new Map),this.setSource(i,n.filter)}setI18n(t){this.i18n=this.initI18n(t)}initI18n(t){const e=new Map([["",""],["SEPARATOR_WS",", "],["in","in"],["ORDER_asc","↑"],["ORDER_desc","↓"],["ac1","AC"],["pp1","PY"],["fc1","FC"],["pl1","PL"],["ac2","AC2"],["pp2","PY2"],["fc2","FC2"],["pl2","PL2"],["ac3","AC3"],["pp3","PY3"],["fc3","FC3"],["pl3","PL3"],["ac4","AC4"],["pp4","PY4"],["fc4","FC4"],["pl4","PL4"],["category"," "],["operation"," "],["thereof","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"]]);return this.state=I.DIRTY,new Map([...e,...t||new Map])}initConfig(t){this.state=I.DIRTY;const e=t,i=this;return t.scenarios.sort(((t,e)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(e))),e}setConfig(t){this.config=this.initConfig(t)}setSource(t,e){var i,n;if(this.state=I.DIRTY,this.fromExpr=k(this.db,t,e),!this.fromExpr)return void(this.rowCount=0);const o=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(n=null===(i=o[0])||void 0===i?void 0:i.cnt)&&void 0!==n?n: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=I.UP_TO_DATE}getHeader(){return this.state===I.DIRTY&&this.update(),this.headerRows}getBody(){return this.state===I.DIRTY&&this.update(),this.bodyRows}getColumns(){return this.state===I.DIRTY&&this.update(),this.dataSetFactory.getNormalizedHeader()}prepareIntervalBuckets(){this.intervalBuckets=[],this.config.interval===X||!this.fromExpr||this.config.categoryThereOf.size>0?this.config.interval=X:(this.config.interval=function(t,e,i){var n;if(i!==G.AUTO)return i;const o=t.exec(`SELECT [date] as d FROM ${e}`);let s,r;for(const t of o){const e=null===(n=J(t.d))||void 0===n?void 0:n.toMillis();void 0!==e&&(s=void 0===s?e:Math.min(s,e),r=void 0===r?e:Math.max(r,e))}return void 0===s||void 0===r?G.DAY:(new T).calculateDistanceType(U.fromMillis(s),U.fromMillis(r))}(this.db,this.fromExpr,this.config.interval),this.intervalBuckets=function(t,e,i,n){const o=t.exec(`SELECT ${K(i)} as __interval FROM ${e}`);if(i===q){const t=new Set,e=[];for(const i of o){const n=Z(i.__interval);t.has(n)||(t.add(n),e.push({key:n,label:0===n.length?"-":n}))}return e}const s=new Set,r=[];for(const t of o){const e=J(t.__interval);if(!e)continue;const i=e.toISO();s.has(i)||(s.add(i),r.push(e))}r.sort(((t,e)=>t.toMillis()-e.toMillis()));const l=new T;return l.setLocale(n),r.map((t=>({key:t.toISO(),label:l.getDateString(t,i)})))}(this.db,this.fromExpr,this.config.interval,this.config.locale),0===this.intervalBuckets.length&&(this.config.interval=X))}normalizeScenarios(t,e,i,n=[]){var o;const s=[],r=null===(o=null==i?void 0:i.hierarchy)||void 0===o?void 0:o.map((t=>x(t))).find((t=>"dim"!==(null==t?void 0:t.kind))),l=this.config.interval===q?null==r?void 0:r.bucket:void 0,a=(t,e)=>{var n;return null==r||(null===(n=x(t))||void 0===n?void 0:n.column)!==r.column||void 0!==l&&l!==e?void 0:i.direction};if(n.length>0){for(const e of n)for(const i of t)s.push({name:i,group:i,type:i,order:a(i,e.key),bucket:e.key,bucketLabel:e.label});return s}for(const i of t){if(null==e?void 0:e.has(i)){const t=e.get(i);for(const e of t){s.push({name:e.name,group:e.name,type:i,order:void 0});for(const t of e.subGroups)s.push({name:t,group:e.name,type:i,order:void 0})}s.push({name:"REST",group:"REST",type:i,order:void 0})}s.push({name:i,group:i,type:i,order:a(i)})}return s}hasNoData(){return 0===this.rowCount}orderBucketWarning(){var t,e;if(this.hasNoData()||this.state!==I.UP_TO_DATE)return;const i=(null!==(e=null===(t=this.config.sortOrder)||void 0===t?void 0:t.hierarchy)&&void 0!==e?e:[]).map((t=>{var e;return null===(e=x(t))||void 0===e?void 0:e.bucket})).filter((t=>void 0!==t));if(0===i.length)return;if(this.config.interval!==q)return`order: '@${i[0]}' needs interval setname, the bucket is ignored.`;const n=i.find((t=>!this.intervalBuckets.some((e=>e.key===t))));return void 0===n?void 0:`order: setname '${n}' not found, the rows are not sorted by it.`}hasBlankRowGroup(){return this.dataSetFactory.hasBlankRowGroup}}class Ht{constructor(){this.title="",this.scenarios=[],this.scenariosUnitType=S.DECIMAL,this.grouped=!1,this.showGroupTitle=!0,this.thereOf=[],this.categoryThereOf=new Map,this.partOf=[],this.attributes=[],this.sortOrder=new C(new F).default(),this.type=z.LIST,this.limit=0,this.i18n=E.ALL,this.categoryWidth=R.W25,this.measureScale=new H,this.measureUnit="",this.measureType=M.VOLUME,this.showMeasureScale=!0,this.filter="",this.barColumns=[],this.interval="none",this.locale="de"}}class Yt{constructor(t,e,i,n,o,s){this.tableDrillGroupAdapter=t,this.stringAdapter=e,this.orderAdapter=i,this.db=n,this.fromExpr=o,this.onQueryError=s}adapt(t){const e=new Ht;return y.isString(t.title)&&(e.title=t.title),y.isArray(t.scenarios)&&(e.scenarios=B.adaptArray(t.scenarios,this.stringAdapter)),y.isExisting(t.scenariosUnitType)&&(e.scenariosUnitType=t.scenariosUnitType),y.isBoolean(t.grouped)&&(e.grouped=t.grouped),y.isBoolean(t.showGroupTitle)&&(e.showGroupTitle=t.showGroupTitle),y.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),y.isArray(t.thereOf)&&(e.thereOf=B.adaptArray(t.thereOf,this.tableDrillGroupAdapter)),y.isExisting(t.categoryThereOf)&&(e.categoryThereOf=t.categoryThereOf),y.isArray(t.partOf)&&(e.partOf=B.adaptArray(t.partOf,this.tableDrillGroupAdapter)),y.isArray(t.attributes)&&(e.attributes=t.attributes),y.isExisting(t.order)&&(e.sortOrder=this.orderAdapter.adapt(t.order)),y.isExisting(t.type)&&(e.type=t.type),y.isNumber(t.limit)&&(e.limit=t.limit),y.isExisting(t.i18n)&&(e.i18n=t.i18n),y.isExisting(t.categoryWidth)&&(e.categoryWidth=t.categoryWidth),y.isExisting(t.measureScale)&&(e.measureScale=P.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale,this.onQueryError)),y.isExisting(t.measureType)&&(e.measureType=t.measureType),y.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),y.isString(t.filter)&&(e.filter=t.filter.trim()),y.isArray(t.barColumns)&&(e.barColumns=t.barColumns),y.isString(t.interval)&&(e.interval=t.interval),y.isString(t.locale)&&(e.locale=t.locale),e}default(){return new Ht}}class jt{constructor(){this.rowGroup="",this.category="",this.subCategory="",this.partOf=""}}class It{constructor(){}adapt(t){const e=new jt;return y.isString(t.rowGroup)&&(e.rowGroup=t.rowGroup),y.isString(t.category)&&(e.category=t.category),y.isString(t.subCategory)&&(e.subCategory=t.subCategory),y.isString(t.partOf)&&(e.partOf=t.partOf),e}default(){return new jt}}const zt=e(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.sumTitle="SUM_TOTAL",this.scenarios=[],this.scenariosDataFormat=S.DECIMAL,this.grouped=!1,this.limit=0,this.showGroupTitle=!0,this.thereof=[],this.partof=[],this.order={hierarchy:[],direction:Q.ASC},this.categorythereof=new Map,this.attributeColumns=[],this.type=z.LIST,this.categoryWidth=R.INF,this.dataFormatDigits={percent:2,decimal:1},this.i18n=new Map,this.i18nMode=E.ALL,this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.measureType=M.VOLUME,this.filter="",this.barColumns=[],this.interval="none",this.barColumnMaxWidth=30,this.unitScaling=.01,this.percentageScaling=.5,this.scaleFactor=1,this.componentDataFormatDigits=new D,this.barColumnLayouts=new Map,this.relayout=()=>{this.barColumnLayouts.size>0&&n(this)},_(this),this.componentStyle=Y(this)}connectedCallback(){var t;null===(t=document.fonts)||void 0===t||t.addEventListener("loadingdone",this.relayout)}disconnectedCallback(){var t;null===(t=document.fonts)||void 0===t||t.removeEventListener("loadingdone",this.relayout)}async getLayoutDetail(t,e){var i,n,o;const s={regions:[],metadata:{},diagnostics:[]},h=null===(i=this.element.shadowRoot)||void 0===i?void 0:i.querySelector("table");if(s.metadata.hasNoData=null===(o=null===(n=this.table)||void 0===n?void 0:n.hasNoData())||void 0===o||o,!this.table||!h)return s;const c=h.querySelector("thead"),d=h.querySelector("tbody");c&&s.regions.push({id:"header",rect:r(c,t)}),d&&s.regions.push({id:"body",rect:r(d,t)});const f=this.table.getHeader(),p=this.table.getBody(),v=this.table.getColumns();if(s.metadata.headerRowCount=f.length,s.metadata.rowCount=p.length,s.metadata.columnCount=v.length,s.metadata.cellCount=p.reduce(((t,e)=>t+e.getCells().length),0),"full"!==e)return s;const $=[],m=[],g=(e,i,n)=>{const o=n?Array.from(n.children).filter((t=>"tr"===t.localName)):[];i.forEach(((i,n)=>{const h=o[n];if(!h)return;$.push({section:e,index:n,type:i.type,rect:r(h,t),point:u(h)});const c=i.getCells(),d=Array.from(h.children);c.length===d.length?c.forEach(((i,o)=>{var s,h;const c=d[o],f={kind:"header"===e?"headerCell":"cell",row:n,column:i.index,key:i.key||void 0,colSpan:i.colSpan,value:null!==(s=i.value)&&void 0!==s?s:void 0,text:(null===(h=c.textContent)||void 0===h?void 0:h.trim())||void 0,type:i.type||void 0,rect:r(c,t),point:u(c)};f.point&&(f.content=l(c,t),f.contentSign=a(c)||void 0);const p=c.querySelector("svg.cell-bar-chart");p&&(f.bar={variant:p.classList.contains("waterfall-bar")?"waterfall":p.classList.contains("relative-variance")?"relative":"absolute",rect:r(p,t)}),m.push(f)})):s.diagnostics.push({id:`WARN_layout_cell_pairing_${e}_${n}`,type:"warning",message:`layout-state: model/DOM cell count mismatch in ${e} row ${n} (${c.length} vs ${d.length}); cell details skipped for this row.`})}))};return g("header",f,c),g("body",p,d),s.elements=m,s.table={rows:$,columns:v.map(((t,e)=>({index:e,key:t.name,group:t.group,type:t.type,bucket:t.bucket})))},s}render(){var e;return t(o,{class:{"no-data":!0===(null===(e=this.table)||void 0===e?void 0:e.hasNoData())}},(()=>{var e,i,n,o;if(void 0===this.table)return;if(this.table.hasNoData()){const i=null!==(e=this.i18n.get("no-data"))&&void 0!==e?e:"No Data";return t("div",{class:"empty-state"},i)}const s=null===(o=null===(n=null===(i=this.stores)||void 0===i?void 0:i.context)||void 0===n?void 0:n.state)||void 0===o?void 0:o.locale;return t("table",null,t("thead",null,this.table.getHeader().map((e=>t("tr",{class:e.cssStyle},e.getCells().map((e=>t("th",{colSpan:e.colSpan,class:e.cssStyle},e.getAsHeaderList().map(((i,n,o)=>t("span",null,n===o.length-1?t("span",{class:" "===i?"table-footer":""},i,e.drawPrefix()," "):t("span",null,i,e.drawPrefix(),t("br",null)))))))))))),t("tbody",null,this.table.getBody().map((e=>t("tr",Object.assign({class:e.cssStyle},d(e.key,"element")),null==e?void 0:e.getCells().map((i=>{var n,o,r,l,a;return t("td",Object.assign({colSpan:i.colSpan,class:i.type?`${i.cssStyle} ${i.type}`:i.cssStyle},e.key&&null!=i.value&&""!==i.value&&"-"!==i.value?d(Object.assign(Object.assign({},e.key),{date:i.date,scenario:i.key}),"element"):{}),null!=i.prefix?t("span",{class:i.cssStyle+" "+i.prefixStyle},i.drawPrefix()):"",!i.isBarChart||!i.columnStats||i.value===O||!this.showGroupTitle&&e.type===V.HEADER||void 0===i.waterfall&&e.type===V.SUM?i.draw(this.componentDataFormatDigits,s):void 0!==i.waterfall?t(Ct,{value:i.value,scenario:i.key,columnStats:i.columnStats,height:18*this.scaleFactor,isRelative:!1,isPositiveGood:"pos"===i.direction,measureScale:i.measureScale,locale:s,decimalDigits:Vt(i,this.componentDataFormatDigits),columnWidthEm:this.barColumnMaxWidth,styles:this.barChartStyles,waterfall:i.waterfall}):t(xt,{value:i.value,scenario:i.key,columnStats:i.columnStats,height:18*this.scaleFactor,isRelative:i.key.startsWith("dr"),isPositiveGood:"pos"===i.direction,measureScale:Qt(i),locale:s,decimalDigits:Vt(i,this.componentDataFormatDigits),percentDigits:null!==(o=null===(n=this.barColumnLayouts.get(i.key))||void 0===n?void 0:n.percentDigits)&&void 0!==o?o:this.componentDataFormatDigits.percent,percentSign:null===(r=this.barColumnLayouts.get(i.key))||void 0===r?void 0:r.percentSign,columnWidthEm:this.barColumnMaxWidth,labelWidths:null===(l=this.barColumnLayouts.get(i.key))||void 0===l?void 0:l.labels,sideMax:null===(a=this.barColumnLayouts.get(i.key))||void 0===a?void 0:a.sideMax,styles:this.barChartStyles}))})))))))})())}componentWillRender(){var t,e,i,n,o,s,r,l;this.stores||(this.stores=A(this.element));const a=this.stores.db.db;this.componentDataFormatDigits=(new W).adapt(this.dataFormatDigits);try{const e=this.prepareConfig(a);this.table=new Ft(new g(this.ruleSetConfig),a,this.tableName,e),this.table.setI18n(this.i18n),this.table.hasNoData()||this.table.getBody(),null===(t=this.errors)||void 0===t||t.remove("ERR_sql")}catch(t){console.error("bn-table-renderer: query failed",t),this.table=void 0,null===(e=this.errors)||void 0===e||e.addOrReplace({id:"ERR_sql",type:"error",message:`Query failed: ${t instanceof Error?t.message:t}`})}(null===(i=this.table)||void 0===i?void 0:i.hasBlankRowGroup())?null===(n=this.errors)||void 0===n||n.addOrReplace({id:"WARN_blankRowGroup",type:"warning",message:"grouped: rows with blank rowGroup found, they are grouped under '-'."}):null===(o=this.errors)||void 0===o||o.remove("WARN_blankRowGroup");const h=null===(s=this.table)||void 0===s?void 0:s.orderBucketWarning();h?null===(r=this.errors)||void 0===r||r.addOrReplace({id:"WARN_orderBucket",type:"warning",message:h}):null===(l=this.errors)||void 0===l||l.remove("WARN_orderBucket"),this.barColumnLayouts=this.collectBarColumnLayouts(),this.barChartStyles=this.prepareBarChartStyles()}prepareConfig(t){var e,i,n;const o=k(t,this.tableName,this.filter);return new Yt(new It,new F,new C(new F,!0),t,o,(t=>{throw t})).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===(n=null===(i=null===(e=this.stores)||void 0===e?void 0:e.context)||void 0===i?void 0:i.state)||void 0===n?void 0:n.locale)||"de"})}prepareBarChartStyles(){var t;const e=!(this.unitScaling>0),i=!(this.percentageScaling>0),n=e?this.autoUnitScaling():this.unitScaling,o=i?this.autoPercentageScaling():this.percentageScaling;return(e||i)&&(null===(t=this.reportAutoScaling)||void 0===t||t.call(this,{unit:e?n:void 0,percentage:i?o:void 0})),this.componentStyle((t=>{var e,i,s,r,l,a,h,u,d,f,p,v,$,m,w,E,S,y,R,M,O,N,U,_,G,T;const L=null===(e=t["bn-chart-time"])||void 0===e?void 0:e.varianceStyles,x=null===(i=t["bn-chart-time"])||void 0===i?void 0:i.barStyles;return{positive:{stroke:(null===(s=null==L?void 0:L.pos)||void 0===s?void 0:s.stroke)||"#008f96",fill:(null===(r=null==L?void 0:L.pos)||void 0===r?void 0:r.fill)||"#008f96",fillpattern:c(null===(l=null==L?void 0:L.pos)||void 0===l?void 0:l.fillpattern)||"solid"},negative:{stroke:(null===(a=null==L?void 0:L.neg)||void 0===a?void 0:a.stroke)||"#ff0000",fill:(null===(h=null==L?void 0:L.neg)||void 0===h?void 0:h.fill)||"#ff0000",fillpattern:c(null===(u=null==L?void 0:L.neg)||void 0===u?void 0:u.fillpattern)||"solid"},neutral:{stroke:(null===(d=null==L?void 0:L.neu)||void 0===d?void 0:d.stroke)||"#808080",fill:(null===(f=null==L?void 0:L.neu)||void 0===f?void 0:f.fill)||"#808080",fillpattern:c(null===(p=null==L?void 0:L.neu)||void 0===p?void 0:p.fillpattern)||"outlined"},scenarios:b({ac:{stroke:(null===(v=null==x?void 0:x.ac)||void 0===v?void 0:v.stroke)||"#404040",fill:(null===($=null==x?void 0:x.ac)||void 0===$?void 0:$.fill)||"#404040",fillpattern:c(null===(m=null==x?void 0:x.ac)||void 0===m?void 0:m.fillpattern)||"solid"},pp:{stroke:(null===(w=null==x?void 0:x.pp)||void 0===w?void 0:w.stroke)||"#A6A6A6",fill:(null===(E=null==x?void 0:x.pp)||void 0===E?void 0:E.fill)||"#A6A6A6",fillpattern:c(null===(S=null==x?void 0:x.pp)||void 0===S?void 0:S.fillpattern)||"solid"},fc:{stroke:(null===(y=null==x?void 0:x.fc)||void 0===y?void 0:y.stroke)||"#404040",fill:(null===(R=null==x?void 0:x.fc)||void 0===R?void 0:R.fill)||"#ffffff",fillpattern:c(null===(M=null==x?void 0:x.fc)||void 0===M?void 0:M.fillpattern)||"hatched"},pl:{stroke:(null===(O=null==x?void 0:x.pl)||void 0===O?void 0:O.stroke)||"#404040",fill:(null===(N=null==x?void 0:x.pl)||void 0===N?void 0:N.fill)||"#ffffff",fillpattern:c(null===(U=null==x?void 0:x.pl)||void 0===U?void 0:U.fillpattern)||"outlined"}},new g(this.ruleSetConfig)),fontColor:(null===(_=t.global)||void 0===_?void 0:_.fontColor)||"#000000",fontSize:((null===(G=t.global)||void 0===G?void 0:G.fontSizePx)||13.3333)*nt*this.scaleFactor,emPx:((null===(T=t.global)||void 0===T?void 0:T.fontSizePx)||13.3333)*this.scaleFactor,fontFamily:this.labelFontFamily(),unitScaling:n,percentageScaling:o,scaleFactor:this.scaleFactor}}))}labelFontFamily(){return this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif"}))}emPx(){return this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*this.scaleFactor}autoUnitScaling(){var t;const e=this.emPx(),i=e*nt;let n=1/0;for(const{isRelative:o,absMax:s,labels:r,sideMax:l}of this.barColumnLayouts.values()){if(o||s<=0)continue;const a=vt(this.barColumnMaxWidth,e,r,l);for(const e of["neg","pos"]){const o=null!==(t=l[e])&&void 0!==t?t:0;if(o<=0)continue;const{maxBarWidth:s,cutWidth:r}=a[e];n=Math.min(n,Math.min(.8*s,r)/(o*i))}}return Number.isFinite(n)&&i>0?n:.01}autoPercentageScaling(){var t,e;const i=this.emPx(),n=i*nt;let o=1/0;for(const{isRelative:s,absMax:r,labels:l,sideMax:a}of this.barColumnLayouts.values()){if(!s||r<=0)continue;const h=10*this.scaleFactor,{negPinLength:c,posPinLength:u}=$t(this.barColumnMaxWidth,i,l,h),d=100*((null!==(t=a.neg)&&void 0!==t?t:0)+(null!==(e=a.pos)&&void 0!==e?e:0));o=Math.min(o,(c+u)/(d*n))}return Number.isFinite(o)&&n>0?o:.5}collectBarColumnLayouts(){var t,e,i,n;const o=new Map;if(!this.table||this.table.hasNoData())return o;const s=new Map;for(const e of this.table.getBody())if(e.type!==V.SUM)for(const i of e.getCells())i.isBarChart&&i.columnStats&&void 0===i.waterfall&&("number"!=typeof i.value||isNaN(i.value)||s.set(i.key,[...null!==(t=s.get(i.key))&&void 0!==t?t:[],i]));const r=this.emPx(),l=r*nt,a=10*this.scaleFactor,h=null===(n=null===(i=null===(e=this.stores)||void 0===e?void 0:e.context)||void 0===i?void 0:i.state)||void 0===n?void 0:n.locale,c=this.labelFontFamily();for(const[t,e]of s){const i=t.startsWith("dr"),n=e.map((t=>t.value)),s=(t,o)=>{var s;const r={neg:n.some((t=>t<0))?0:void 0,pos:n.some((t=>t>0))?0:void 0},a=Ot(r);for(const n of e){const e=n.value,u=e>0||0===e&&a?"pos":"neg",d=Et(e,i,Qt(n),h,t,o,Vt(n,this.componentDataFormatDigits));r[u]=Math.max(null!==(s=r[u])&&void 0!==s?s:0,ht(d,l,c,i))}return r};let u=Math.min(20,Math.max(0,Math.trunc(this.componentDataFormatDigits.percent)||0)),d=!0,f=s(u,d);for(;i&&(u>0||d)&&!ft(this.barColumnMaxWidth,r,f,a);)u>0?u--:d=!1,f=s(u,d);const p=Math.max(...n.map(Math.abs))*(i?100:1),v={neg:void 0===f.neg?void 0:Math.max(0,...n.map((t=>-t))),pos:void 0===f.pos?void 0:Math.max(0,...n)};o.set(t,{isRelative:i,absMax:p,labels:f,sideMax:v,percentDigits:u,percentSign:d})}return o}get element(){return this}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{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,td.percentpoint{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}'}},[1,"bn-table-renderer",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],selectedStyle:[513,"selected-style"],sumTitle:[1,"sum-title"],scenarios:[16],scenariosDataFormat:[1,"scenarios-data-format"],grouped:[4],limit:[2],showGroupTitle:[4,"show-group-title"],thereof:[16],partof:[16],order:[16],categorythereof:[16],attributeColumns:[16],type:[1],categoryWidth:[1,"category-width"],dataFormatDigits:[16],ruleSetConfig:[16],i18n:[1040],i18nMode:[1,"i18n-mode"],measureScale:[1,"measure-scale"],measureUnit:[1,"measure-unit"],showMeasureScale:[4,"show-measure-scale"],measureType:[1,"measure-type"],filter:[1],barColumns:[16],interval:[1],barColumnMaxWidth:[2,"bar-column-max-width"],unitScaling:[2,"unit-scaling"],percentageScaling:[2,"percentage-scaling"],reportAutoScaling:[16],errors:[16],scaleFactor:[2,"scale-factor"],getLayoutDetail:[64]}]);function Qt(t){return"percentpoint"===t.type?.01:t.measureScale}function Vt(t,e){return"percentpoint"===t.type?e.percent:"decimal"===t.type?e.decimal:void 0}function Xt(){"undefined"!=typeof customElements&&["bn-table-renderer"].forEach((t=>{"bn-table-renderer"===t&&(customElements.get(s(t))||customElements.define(s(t),zt))}))}export{zt as B,X as I,z as T,q as a,Xt as d}
|