@bino-bi/bn-template-engine 1.0.0-next.49 → 1.0.0-next.51
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-0cad5598.entry.js +1 -0
- package/dist/bn-template-engine/{p-2de524d0.entry.js → p-150bdb68.entry.js} +1 -1
- package/dist/bn-template-engine/{p-Bxa4pX1M.js → p-Bvunba5p.js} +1 -1
- package/dist/bn-template-engine/p-NxJ6P79y.js +1 -0
- package/dist/bn-template-engine/{p-8fc90dc8.entry.js → p-b75a4b52.entry.js} +1 -1
- package/dist/bn-template-engine/{p-510d2ee6.entry.js → p-fdf42a77.entry.js} +1 -1
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +1045 -63
- package/dist/cjs/bn-grid.cjs.entry.js +1 -1
- package/dist/cjs/bn-image.cjs.entry.js +1 -1
- package/dist/cjs/bn-template-engine.cjs.js +1 -1
- package/dist/cjs/bn-text.cjs.entry.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{withStyled-pkdctrK9.js → withStyled-BISQLGLe.js} +9 -0
- package/dist/cjs/{withTranslation-BIzTNYZM.js → withTranslation-B7T30EVU.js} +1 -1
- package/dist/collection/components/bn-annotation-layer/bn-annotation-layer.js +109 -11
- package/dist/collection/components/bn-annotation-layer/utils/marks.js +126 -4
- package/dist/collection/components/bn-annotation-layer/utils/matchPoint.js +2 -1
- package/dist/collection/components/bn-chart-structure/bn-chart-structure-renderer/bn-chart-structure-renderer.js +133 -0
- package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +258 -2
- package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +507 -27
- package/dist/collection/components/bn-chart-structure/utils/elements/Bar.js +3 -1
- package/dist/collection/components/bn-chart-structure/utils/elements/Label.js +12 -0
- package/dist/collection/components/bn-chart-structure/utils/elements/StackedBar.js +23 -8
- package/dist/collection/components/bn-chart-structure/utils/helper/ElementPositions.js +19 -3
- package/dist/collection/components/bn-chart-structure/utils/model/StructureChartComponentConfig.js +23 -0
- package/dist/collection/components/bn-context/bn-context.js +56 -1
- package/dist/collection/components/bn-layout-card/bn-layout-card.js +62 -2
- package/dist/collection/utils/formatter.js +13 -2
- package/dist/collection/utils/validate.js +9 -0
- package/dist/components/bn-annotation-layer.js +1 -1
- package/dist/components/bn-chart-bubble-renderer.js +1 -1
- package/dist/components/bn-chart-bubble.js +1 -1
- package/dist/components/bn-chart-bullet-renderer.js +1 -1
- package/dist/components/bn-chart-bullet.js +1 -1
- package/dist/components/bn-chart-scatter-renderer.js +1 -1
- package/dist/components/bn-chart-scatter.js +1 -1
- package/dist/components/bn-chart-structure-renderer.js +1 -1
- package/dist/components/bn-chart-structure.js +1 -1
- package/dist/components/bn-chart-time-renderer.js +1 -1
- package/dist/components/bn-chart-time.js +1 -1
- package/dist/components/bn-context.js +1 -1
- package/dist/components/bn-grid.js +1 -1
- package/dist/components/bn-image.js +1 -1
- package/dist/components/bn-layout-card.js +1 -1
- package/dist/components/bn-layout-page.js +1 -1
- package/dist/components/bn-page.js +1 -1
- package/dist/components/bn-table-renderer.js +1 -1
- package/dist/components/bn-table.js +1 -1
- package/dist/components/bn-text.js +1 -1
- package/dist/components/bn-title-renderer.js +1 -1
- package/dist/components/bn-title.js +1 -1
- package/dist/components/bn-tree.js +1 -1
- package/dist/components/p-BOwmXBm-.js +1 -0
- package/dist/components/p-Bs5V6Ibu.js +1 -0
- package/dist/components/{p-CVfmhtEW.js → p-CU9CdEBF.js} +1 -1
- package/dist/components/{p-Cc0gaLwp.js → p-CZSp0rSS.js} +1 -1
- package/dist/components/p-CcfvGlBq.js +1 -0
- package/dist/components/p-CiljAoC5.js +1 -0
- package/dist/components/p-D0v9GMIf.js +1 -0
- package/dist/components/{p-DBj1Yd3M.js → p-D65TnLS9.js} +1 -1
- package/dist/components/p-DKcw-1ot.js +1 -0
- package/dist/components/{p-k7heRDPP.js → p-DLmQ_mi7.js} +1 -1
- package/dist/components/p-DOKqRsAu.js +1 -0
- package/dist/components/p-Dpc8_R-Y.js +1 -0
- package/dist/components/p-LHIKI9Dp.js +1 -0
- package/dist/components/{p-Blre9f28.js → p-NdDdfez6.js} +1 -1
- package/dist/components/p-Zz3fAPcH.js +1 -0
- package/dist/components/{p-y12CmIFS.js → p-dSUX43yf.js} +1 -1
- package/dist/components/p-jEqo8YD5.js +1 -0
- package/dist/esm/bn-annotation-layer_30.entry.js +1045 -63
- package/dist/esm/bn-grid.entry.js +1 -1
- package/dist/esm/bn-image.entry.js +1 -1
- package/dist/esm/bn-template-engine.js +1 -1
- package/dist/esm/bn-text.entry.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{withStyled-B62R20Zx.js → withStyled-CrTxIZ0Q.js} +9 -0
- package/dist/esm/{withTranslation-BEseMLQ6.js → withTranslation-BtSJmx1J.js} +1 -1
- package/dist/schemas/stack.schema.json +42 -0
- package/dist/types/components/bn-annotation-layer/utils/marks.d.ts +53 -0
- package/dist/types/components/bn-annotation-layer/utils/matchPoint.d.ts +2 -0
- package/dist/types/components/bn-chart-structure/bn-chart-structure-renderer/bn-chart-structure-renderer.d.ts +11 -1
- package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +49 -0
- package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +45 -0
- package/dist/types/components/bn-chart-structure/utils/elements/Label.d.ts +4 -0
- package/dist/types/components/bn-chart-structure/utils/elements/StackedBar.d.ts +13 -1
- package/dist/types/components/bn-chart-structure/utils/helper/ElementPositions.d.ts +13 -1
- package/dist/types/components/bn-chart-structure/utils/model/StructureChartComponentConfig.d.ts +23 -0
- package/dist/types/components/bn-context/bn-context.d.ts +11 -0
- package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +12 -0
- package/dist/types/components.d.ts +113 -2
- package/dist/types/schemas.d.ts +12 -0
- package/dist/types/utils/annotations.d.ts +1 -1
- package/dist/types/utils/formatter.d.ts +5 -0
- package/package.json +1 -1
- package/dist/bn-template-engine/p-BFl7OwcC.js +0 -1
- package/dist/bn-template-engine/p-c1d679af.entry.js +0 -1
- package/dist/components/p-B11cXOLy.js +0 -1
- package/dist/components/p-BVNOmHh4.js +0 -1
- package/dist/components/p-CHhxQoF9.js +0 -1
- package/dist/components/p-CO6bgquz.js +0 -1
- package/dist/components/p-CmvpJzLd.js +0 -1
- package/dist/components/p-CuUfiEu0.js +0 -1
- package/dist/components/p-DHloMyxV.js +0 -1
- package/dist/components/p-Dd1QOWDV.js +0 -1
- package/dist/components/p-HVN8BNWN.js +0 -1
- package/dist/components/p-x0W2_FAX.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as t,p as e,H as n,f as o,d as i,t as s}from"./p-BnmylmXF.js";import{b as r,a as l,F as a,O as c,T as h,c as u}from"./p-BZXiWkDS.js";import{m as d,a as f,b as p}from"./p-DdvG1D18.js";import{p as v,n as m,r as $,d as g}from"./p-DHX92KDP.js";import{F as b,V as w,Q as y,s as S,a as R,I as E,b as M}from"./p-CmvpJzLd.js";import{S as O,D as _,I as x,C as N,d as k,M as G}from"./p-DguYWLBj.js";import{N as U,r as C}from"./p-fCjsrD7I.js";import{D as T,w as L}from"./p-BrQCbmG0.js";import{D as P,b as A}from"./p-ja0FCkHB.js";import{p as W,c as D}from"./p-BBdzTx8V.js";import{d as B,g as F}from"./p-6242qMx1.js";import{D as H,a as I,b as Y}from"./p-keKnrAVS.js";import{A as j}from"./p-DsC0ew4j.js";import{S as z}from"./p-Do-IGHJk.js";import{S as X}from"./p-CeE4_3wQ.js";import{w as V}from"./p-JG4Sx1lE.js";const Q="none",K="setname";function q(t){return t===K?"COALESCE([setname],[setName])":`normalizeDate([date], '${t}')`}function Z(t){if("string"==typeof t?""===t.trim():"number"!=typeof t)return;const e=Number(t);return Number.isFinite(e)?e:void 0}function J(t){if(null==t)return"";if("string"==typeof t)return t.trim();const e=tt(t);return e?e.toISO():String(t)}function tt(t){if(null!=t){if("string"==typeof t){const e=T.fromISO(t,{zone:"utc"});return e.isValid?e:void 0}if("number"==typeof t){const e=T.fromMillis(t,{zone:"utc"});return e.isValid?e:void 0}if("boolean"==typeof t.isValid)return t.isValid?t:void 0}}const et=/[\s\u200e\u200f\u061c]*[%\u066a][\s\u200e\u200f\u061c]*/;class nt{constructor(t,e,n,o,i,s,r,l,a){this.prefixStyle="prefix",this.isBarChart=!1,this.key=t,this.index=e,this.value=n,this.prefix=s||"",this.cssStyle=o||"",this.prefixStyle=r||"prefix",this.type=i,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){return this.format(this.value,t,e)}roundsToZero(t,e){return"number"==typeof this.value&&!!this.type&&this.draw(t,e)===this.format(0,t,e)}format(t,e,n){let o=t;if("undefined"===o||void 0===o||null==o)return"";if(Number.isNaN(Number(o)))return o;if(""===this.type||void 0===this.type||null==this.type)return o;let i=e.percent,s=e.percent;return"percentpoint"===this.type?b.number(Number(o),"percent",i,s,1,n).replace(et,""):("decimal"===this.type&&(o=+o/this.measureScale,i=e.decimal,s=e.decimal),b.number(Number(o),this.type,i,s,1,n))}drawPrefix(){return null==this.prefix?"":this.prefix}}class ot{constructor(t,e,n){this.index=t,this.groupindex=e,this.type=n,this.cssStyle=this.initCssStyle(),this.elements=[]}initCssStyle(){switch(this.type){case r.HEADER:return"groupheader";case r.SEPERATORLINE:return"";case r.DRILLELEMENT:return"ofit";case r.PARTELEMENT:return"partof";case r.STANDARD:return"";case r.SUM:return"sum";default:return""}}getCells(){return this.elements}createElement(t,e,n,o,i,s,l,a,c,h=!1,u,d=1,f){let p=s;if("category"===e&&null!=a&&(p=`category-${a.toString()}`),this.type===r.HEADER?p="headerlabel":this.type===r.SEPERATORLINE&&(p=null!=s?s:e),this.type===r.PARTELEMENT){const n=new w(e);n.isValid&&Number.isFinite(t)?(o="d"===n.type?"percentpoint":"percent",p=(null!=s?s:"").replace(/^(pos|neg)_\w+/,"$1_neu")):(("percent"===o||n.isValid)&&(t="-"),"category"!==e&&"operation"!==e&&(o="percent",p=""))}("-"===t||t===U&&"percent"===o)&&(p="");let v="prefix-first";l&&(v="prefix-second"),n&&(p=`${p} ${n}`);const m=new nt(e,this.elements.length,t,p,o,i,v,d,c);m.isBarChart=h,m.columnStats=u,m.waterfall=f,this.elements.push(m)}}const it=.85,st=.3,rt=.25;function lt(t){const e=.6*t;return{barY:(t-e)/2,barHeight:e}}const at={".":.28,",":.28,"-":.34,"%":.89," ":.28," ":.28," ":.28,M:.9};let ct;function ht(t,e,n,o,i=!1){const s=()=>function(t,e){var n;let o=0;for(const e of t)o+=null!==(n=at[e])&&void 0!==n?n:/[0-9+]/.test(e)?.59:.72;return o*e*1.1}(t,e)*(i?1.08:1),r=function(){var t,e,n;if(void 0===ct)try{ct="undefined"==typeof document?null:null!==(n=null===(e=(t=document.createElement("canvas")).getContext)||void 0===e?void 0:e.call(t,"2d"))&&void 0!==n?n:null}catch(t){ct=null}return ct}();if(r){r.font="1px __bn_font_sentinel__";const l=r.font;if(r.font=`${o?"italic ":""}${i?"bold ":""}${e}px ${n}`,r.font===l)return s();const a=r.measureText(t).width;if(Number.isFinite(a)&&(a>0||""===t))return a+.15*e}return s()}function ut(t,e){return Math.max(0,(t-.5)*e)}function dt(t,e,n){const o=void 0!==t.neg,i=void 0!==t.pos||!o,s=(t,o)=>t?e+n+(null!=o?o:0):0;return{sides:(o?1:0)+(i?1:0),neg:s(o,t.neg),pos:s(i,t.pos)}}function ft(t,e,n,o){const{sides:i,neg:s,pos:r}=dt(e,n,o),l=s+r>0?Math.min(1,t/(s+r)):1,a=Math.max(0,(t-(s+r)*l)/i);return{extent:a,axisX:void 0!==e.neg?s*l+a:0}}function pt(t,e,n,o){const i=ut(t,e),{sides:s,neg:r,pos:l}=dt(n,o/2,st*e);return r+l+s*function(t,e,n){return Math.min(1*e,t/(2*n))}(i,e,s)<=i+1e-6}function vt(t,e){const n=.15*t;return{maxBarWidth:t,breakGap:e,overdriveZoneWidth:n,cutWidth:Math.max(0,t-e-n)}}function mt(t,e,n,o){var i,s;const r=ut(t,e),l=st*e,{extent:a,axisX:c}=ft(r,n,rt*e/2,l),h=Math.min(.3*e,.2*a),u=void 0!==n.neg,d=void 0!==n.pos||!u;let f=u?a:0;const p=Math.max(0,null!==(i=null==o?void 0:o.neg)&&void 0!==i?i:0),v=Math.max(0,null!==(s=null==o?void 0:o.pos)&&void 0!==s?s:0);u&&d&&p+v>0&&(f=(h+(2*a*.85-2*h)*p/(p+v))/.85);const m=d?u?2*a-f:a:0;return{totalWidth:r,neg:vt(f,h),pos:vt(m,h),axisX:u?c-a+f:0,labelGap:l}}function $t(t,e,n,o,i){var s,r;const l=ut(t,e),a=st*e,{extent:c,axisX:h}=ft(l,n,o/2,a),u=void 0!==n.neg,d=void 0!==n.pos||!u;let f=u?c:0,p=d?c:0;if(i&&u&&d){const t=2*c,e=Math.max(0,null!==(s=i.neg)&&void 0!==s?s:0),n=Math.max(0,null!==(r=i.pos)&&void 0!==r?r:0);e+n<=t+1e-6?(f=e+(t-e-n)/2,p=t-f):e<c?(f=e,p=t-f):n<c&&(p=n,f=t-p)}return{totalWidth:l,maxPinLength:Math.max(f,p),negPinLength:f,posPinLength:p,axisX:u?h-c+f:0,labelGap:a}}function gt(t,e,n){const o=ut(t,e),i=st*e,s=Math.min(2.85*e,o/4);let r=s,l=s;const a=n?n.max-n.min:0;if(n&&a>0){const t=(t,e)=>Math.max(0,...n.labels.filter((e=>e.pointsLeft===t)).map((o=>o.width+i-(t?o.end-n.min:n.max-o.end)*e)));r=t(!0,0),l=t(!1,0);const e=o/2;for(let n=0;n<8;n++){const n=Math.max(0,o-r-l)/a,i=Math.min(r,t(!0,n)),s=Math.min(l,t(!1,n)),c=i+s<=e||i===r&&s===l;if(r=i,l=s,c)break}if(r+l>e)if(Math.min(r,l)>s){const t=e/(r+l);r*=t,l*=t}else r<=l?l=e-r:r=e-l}return{totalWidth:o,labelAreaLeft:r,labelAreaRight:l,barAreaWidth:o-r-l,labelGap:i}}const bt={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},wt="#666666";function yt(t,e){return`pattern-${t}-${e.replace("#","")}`}function St(t,e){return yt(`head-${t}`,e)}const Rt=({styles:e})=>{const n=e.scaleFactor,o=3*n,i=[{id:yt("pos",e.positive.stroke),line:e.positive.stroke,background:"#ffffff",lineWidth:1},{id:yt("neg",e.negative.stroke),line:e.negative.stroke,background:"#ffffff",lineWidth:1},{id:yt("neu",e.neutral.stroke),line:e.neutral.stroke,background:"#ffffff",lineWidth:1},...["ac","pp","fc","pl"].flatMap((t=>[{id:yt(t,e.scenarios[t].stroke),line:e.scenarios[t].stroke,background:"#ffffff",lineWidth:1},{id:St(t,e.scenarios[t].stroke),line:"#ffffff",background:e.scenarios[t].stroke,lineWidth:.6}]))],s=[[0,o,o,0],[-n,n,n,-n],[o-n,o+n,o+n,o-n]];return t("defs",null,i.map((e=>t("pattern",{id:e.id,patternUnits:"userSpaceOnUse",width:o,height:o},t("rect",{width:o,height:o,fill:e.background}),s.map((([o,i,s,r])=>t("line",{x1:o,y1:i,x2:s,y2:r,stroke:e.line,"stroke-width":e.lineWidth*n})))))))};function Et(t,e,n=1,o,i=0,s=!0,r){const l=(e,n)=>(t>0&&e!==n?"+":"")+e;if(e){const e=(t,e)=>s?b.number(t,"percent",e,e,1,o):b.number(100*t,"decimal",e,e,1,o),n=n=>l(e(t,n),e(0,n));let r=Math.min(20,Math.max(0,Math.trunc(i)||0));for(;r>0&&n(r).length>7;)r--;return n(r)}const a=t/n;if(void 0!==r){const t=t=>b.number(t,"decimal",r,r,1,o);return l(t(a),t(0))}const c=Math.abs(a);let h=1,u="";c>=9995e5?(h=1e9,u="B"):c>=999500?(h=1e6,u="M"):c>=999.5&&(h=1e3,u="K");const d=c>=10*h?0:1;return l(b.number(a/h,"decimal",d,0,1,o),b.number(0,"decimal",d,0,1,o))+u}function Mt(t){const e=t.slice(0,2).toLowerCase();return["ac","pp","fc","pl"].includes(e)}function Ot(t){const e=t.slice(0,2).toLowerCase();return"pp"===e?"pp":"fc"===e?"fc":"pl"===e?"pl":"ac"}function _t(t,e){if(Mt(t))return null;const n=new w(t);if(!n.isValid)return null;const o=Ot(n.base),i=Ot(n.delta);return{minuend:e.scenarios[o],minuendSlot:o,reference:e.scenarios[i],referenceSlot:i}}const xt=({x:e,height:n,look:o,styles:i})=>{const s=i.scaleFactor,r=rt*i.emPx,{reference:l,referenceSlot:a}=o;let c;if("outlined"===l.fillpattern){const o=r/3,i=(r-o)/2;c=[e-i,e+i].map((e=>t("line",{x1:e,y1:0,x2:e,y2:n,stroke:l.stroke,"stroke-width":o})))}else c=t("line","hatched"===l.fillpattern?{x1:e,y1:0,x2:e,y2:n,stroke:l.stroke,"stroke-width":r,"stroke-dasharray":""+2*s}:{x1:e,y1:0,x2:e,y2:n,stroke:l.fill,"stroke-width":r});return t("g",{class:`variance-axis axis-${a}`},c)};function Nt(t){return void 0!==t.pos||void 0===t.neg}function kt(t,e){return{neg:t.min<0?e:void 0,pos:t.max>0?e:void 0}}function Gt(t,e,n,o){return Mt(t)?function(t,e){const n=Ot(t);return e.scenarios[n]}(t,o):function(t,e,n){const o=t>=0;return e?o?n.positive:n.negative:o?n.negative:n.positive}(e,n,o)}function Ut(t,e){const n=t.fillpattern;return"hatched"===n?`url(#${yt(e,t.stroke)})`:"outlined"===n?"transparent":t.fill}function Ct(t){return"outlined"===t.fillpattern?{stroke:t.stroke,strokeWidth:1.5}:{stroke:"none",strokeWidth:0}}const Tt=e=>{const{value:n,scenario:o,columnStats:i,height:s,isPositiveGood:r,formattedValue:l,measureScale:a,locale:c,decimalDigits:h,columnWidthEm:u=10,labelWidths:d,sideMax:f,bold:p,styles:v=bt}=e,m=v.scaleFactor,$=v.fontSize,g=l||Et(n,!1,a,c,0,!0,h),b=null!=d?d:kt(i,ht(g,$,v.fontFamily,!1,p)),w=n>0||0===n&&Nt(b),{neg:y=Math.max(0,-i.min),pos:S=Math.max(0,i.max)}=null!=f?f:{},R=mt(u,v.emPx,b,{neg:y,pos:S}),{totalWidth:E,axisX:M,labelGap:O}=R,{breakGap:_,overdriveZoneWidth:x,cutWidth:N}=w?R.pos:R.neg,k=Math.abs(n)*v.unitScaling*$,G=k-N>1e-6,U=Math.max(0,(w?S:y)*v.unitScaling*$-N),C=Math.max(0,k-N),T=U>0?C/U*x:0,{barY:L,barHeight:P}=lt(s),A=_t(o,v),W=Gt(o,n,r,v),D=null==A?void 0:A.minuend.fillpattern,B="hatched"===D||"outlined"===D?Object.assign(Object.assign({},W),{fillpattern:D}):W,F=Ut(B,Mt(o)?Ot(o):r?w?"pos":"neg":w?"neg":"pos"),{stroke:H,strokeWidth:I}=A&&"hatched"===B.fillpattern?{stroke:B.stroke,strokeWidth:1}:Ct(B),Y=A?rt*v.emPx/2:0,j=w?M+Y:M-Y,z=G?N:k,X=G?N+_+T:k,V=w?j+X+O:j-X-O,Q=w?"start":"end";return t("svg",{width:E,height:s,class:"cell-bar-chart absolute-variance",style:{overflow:"visible"}},t(Rt,{styles:v}),!A&&t("line",{x1:M,y1:0,x2:M,y2:s,stroke:wt,"stroke-width":1*m}),z>0&&t("rect",{x:w?j:j-z,y:L,width:z,height:P,fill:F,stroke:H,"stroke-width":I*m}),G&&T>0&&t("rect",{x:w?j+N+_:j-N-_-T,y:L,width:T,height:P,fill:F,stroke:H,"stroke-width":I*m}),G&&function(e,n,o,i,s){const r=e+n/2,l=.35*n,a=i/3,c=.3*n;let h=`M ${r-l} ${o}`;for(let t=0;t<3;t++)h+=` L ${r-l-c} ${o+a*(t+.5)} L ${r-l} ${o+a*(t+1)}`;let u=`M ${r+l} ${o}`;for(let t=0;t<3;t++)u+=` L ${r+l+c} ${o+a*(t+.5)} L ${r+l} ${o+a*(t+1)}`;return[t("rect",{x:e,y:o-1,width:n,height:i+2,fill:"#ffffff"}),t("path",{d:h,fill:"none",stroke:"#000000","stroke-width":1*s}),t("path",{d:u,fill:"none",stroke:"#000000","stroke-width":1*s})]}(w?j+N:j-N-_,_,L,P,m),A&&t(xt,{x:M,height:s,look:A,styles:v}),t("text",{x:V,y:s/2,dy:"0.35em","text-anchor":Q,fill:v.fontColor,"font-size":$,"font-family":v.fontFamily},g))},Lt=e=>{var n,o;const{value:i,scenario:s,columnStats:r,height:l,isPositiveGood:a,formattedValue:c,measureScale:h,locale:u,percentDigits:d,percentSign:f,columnWidthEm:p=10,labelWidths:v,sideMax:m,bold:$,styles:g=bt}=e,b=g.scaleFactor,w=g.fontSize,y=8*b,S=100*g.percentageScaling*w,R=c||Et(i,!0,h,u,d,f),E=ht(R,w,g.fontFamily,!0,$),M=null!=v?v:kt(r,E),{neg:O=Math.max(0,-r.min),pos:_=Math.max(0,r.max)}=null!=m?m:{},{totalWidth:x,negPinLength:N,posPinLength:k,axisX:G,labelGap:U}=$t(p,g.emPx,M,y,{neg:O*S,pos:_*S}),C=l/2,T=Math.abs(i)*S,L=i>0||0===i&&Nt(M),P=L?k:N,A=T-P>1e-6,W=L?1:-1,D=G+W*Math.min(T,P),B=Gt(s,i,a,g),F=_t(s,g),H=null!==(n=null==F?void 0:F.minuend)&&void 0!==n?n:g.scenarios.ac,I=G+W*(P+y/2),Y=1.2*y,j=I-W*Y,z=.2*w,X=E+2*z,V=Math.abs(j-G)-rt*g.emPx/2,Q=A&&V>=X+2*z,K=j-W*(z+X/2)-X/2,q=Q?K+X/2:(A?I:D+W*(y/2))+W*U;return t("svg",{width:x,height:l,class:"cell-bar-chart relative-variance",style:{overflow:"visible"}},t(Rt,{styles:g}),A?t("polygon",{points:`${I},${C} ${j},${C-Y/2} ${j},${C+Y/2}`,fill:B.fill}):t("rect",{x:D-y/2,y:C-y/2,width:y,height:y,fill:"outlined"===H.fillpattern?"#ffffff":"hatched"===H.fillpattern?`url(#${St(null!==(o=null==F?void 0:F.minuendSlot)&&void 0!==o?o:"ac",H.stroke)})`:H.fill,stroke:H.stroke,"stroke-width":1*b}),t("line",{x1:G,y1:C,x2:A?j:D,y2:C,stroke:B.fill,"stroke-width":3*b}),Q&&t("rect",{class:"pin-label-band",x:K,y:C-3*b/2,width:X,height:3*b,fill:"#ffffff","fill-opacity":"0.5"}),F?t(xt,{x:G,height:l,look:F,styles:g}):t("line",{x1:G,y1:0,x2:G,y2:l,stroke:wt,"stroke-width":1*b}),t("text",{x:q,y:l/2,dy:"0.35em","text-anchor":Q?"middle":L?"start":"end",fill:g.fontColor,"font-size":w,"font-style":"italic","font-family":g.fontFamily},R))},Pt=e=>{const{value:n,columnStats:o,isRelative:i,styles:s=bt}=e;return null==n||isNaN(n)||!o||0===o.absMax?t("span",{class:"bar-chart-empty",style:{color:s.fontColor,fontStyle:"italic"}},"-"):t(i?Lt:Tt,Object.assign({},e))};function At(t,e,n,o,i,s=!1){const r=Et(t,"partof"===e,n,o,0,!0,i);return s?r:r.replace(/^\+/,"")}const Wt=e=>{var n;const{value:o,scenario:i,height:s,isPositiveGood:r,measureScale:l,locale:a,decimalDigits:c,columnWidthEm:h=10,styles:u=bt,waterfall:d,geometry:f,bold:p,connectorReach:v={top:0,bottom:0}}=e,m=u.scaleFactor,$=u.fontSize,g=d.max-d.min;if(null==o||isNaN(o)||g<=0)return t("span",{class:"bar-chart-empty",style:{color:u.fontColor,fontStyle:"italic"}},"-");const{totalWidth:b,labelAreaLeft:w,barAreaWidth:y,labelGap:S}=null!=f?f:gt(h,u.emPx),R=y/g,E=t=>w+(t-d.min)*R,{barY:M,barHeight:O}=lt(s),_=E(0),x=E(d.start),N=E(d.end),k=Math.min(x,N),G=Math.abs(N-x),U=_t(i,u),C=Gt(i,o,r,u),T=null==U?void 0:U.minuend.fillpattern,L="hatched"===T||"outlined"===T?Object.assign(Object.assign({},C),{fillpattern:T}):C,P=Ut(L,U?C===u.positive?"pos":"neg":Ot(i)),{stroke:A,strokeWidth:W}=U&&"hatched"===L.fillpattern?{stroke:L.stroke,strokeWidth:1}:Ct(L),D=At(o,d.kind,l,a,c,null!==U),B=N<x,F=B?k-S:k+G+S,H=B?"end":"start",I=ht(D,$,u.fontFamily,!1,p),Y=S/2,j=(B?F-I:F)-Y,z=(B?F:F+I)+Y,X=t=>t>j&&t<z,V=void 0!==d.parentEnd?E(d.parentEnd):void 0,Q=s/2-$/2,K=s/2+$/2,q=(t,e,n,o=0)=>t+o>j&&t-o<z?[[e,Math.min(n,Q)],[Math.max(e,K),n]].filter((([t,e])=>e>t)):[[e,n]],Z=-v.top,J=s+v.bottom;return t("svg",{width:b,height:s,class:"cell-bar-chart waterfall-bar"+(U?" variance-waterfall":""),style:{overflow:"visible"}},t(Rt,{styles:u}),!U&&!X(_)&&t("line",{x1:_,y1:0,x2:_,y2:s,stroke:wt,"stroke-width":1*m}),void 0!==d.parentStart&&void 0!==d.parentEnd&&t("line",{x1:E(d.parentStart),y1:0,x2:E(d.parentStart),y2:s,stroke:wt,"stroke-width":1*m,"stroke-dasharray":`${2*m},${2*m}`}),void 0!==d.parentStart&&void 0!==V&&!X(V)&&t("line",{x1:V,y1:0,x2:V,y2:s,stroke:wt,"stroke-width":1*m,"stroke-dasharray":`${2*m},${2*m}`}),null===(n=d.connectors)||void 0===n?void 0:n.map((({at:e,part:n})=>q(E(e),"bottom"===n?M+O:Z,"top"===n?M:J).map((([n,o])=>t("line",{class:"waterfall-connector",x1:E(e),y1:n,x2:E(e),y2:o,stroke:wt,"stroke-width":1*m}))))),G>0&&t("rect",{x:k,y:M,width:G,height:O,fill:P,stroke:A,"stroke-width":W*m}),U&&q(_,Z,J,rt*u.emPx/2).map((([e,n])=>t("g",{transform:`translate(0,${e})`},t(xt,{x:_,height:n-e,look:U,styles:u})))),t("text",{x:F,y:s/2,dy:"0.35em","text-anchor":H,fill:u.fontColor,"font-size":$,"font-family":u.fontFamily},D))},Dt=`IFNULL(${y.ROWGROUP}, '')`;class Bt{constructor(t){this.groups=[y.CATEGORY,y.CATEGORYINDEX],l.OPT!==t.type&&l.OPTNOTOTAL!==t.type||this.groups.unshift(y.OPERATION),t.grouped&&(this.groups.push(y.ROWGROUP),this.groups.push(y.ROWGROUPINDEX))}toString(){return this.groups.map((t=>t===y.ROWGROUP?Dt:t)).toString()}select(){return this.groups.map((t=>t===y.ROWGROUP?`${Dt} as ${t}`:t)).toString()}noCategory(){return this.groups.filter((t=>t!==y.CATEGORY))}toArray(){return this.groups}}function Ft(t,e){return Math.abs(t-e)<=1e-9*Math.max(1,Math.abs(t),Math.abs(e))}function Ht(t,e){const n=(t,e,n)=>{var o;t.connectors=[...null!==(o=t.connectors)&&void 0!==o?o:[],{at:e,part:n}]},o=(t,e,o,i)=>{n(t,i,"bottom"),e.forEach((t=>n(t,i,"through"))),n(o,i,"top")};let i=null;for(const n of t){if(null===n){i=null;continue}const{main:t,children:s}=n,r="anchor"===t.kind?t.end:t.start;if(i&&!n.gapAbove&&Ft(i.main.end,r)&&o(i.main,e?s:i.children,t,r),!n.gapAbove&&!n.gapBelow&&(s.forEach(((t,e)=>{e>0&&o(s[e-1],[],t,t.start)})),s.length>0)){const n=s[s.length-1];e?Ft(n.end,t.end)&&o(n,[],t,t.end):o(t,[],s[0],t.start)}i=n.gapBelow?null:n}}class It{constructor(){this.geometry=new Map,this.columns=new Set}set(t,e,n){let o=this.geometry.get(t);o||(o=new Map,this.geometry.set(t,o)),o.set(e,n),this.columns.add(e)}get(t,e){var n;return null===(n=this.geometry.get(t))||void 0===n?void 0:n.get(e)}has(t){return this.columns.has(t)}}function Yt(t){for(const e of t)for(const t of e){const e=t[y.TYPE];if(e===r.SUM||e===r.GROUPSUM||e===r.DRILLELEMENT||e===r.PARTELEMENT)return!0}return!1}function jt(t){return`${t}__signed`}function zt(t){var e;return"-"===(null!==(e=t[y.OPERATION])&&void 0!==e?e:t.restOperation)?-1:1}function Xt(t,e,n){const o=t[e];if(null==o)return null;const i=Number(o);if(isNaN(i))return null;if((n===l.OPT||n===l.OPTNOTOTAL)&&t[y.TYPE]===r.ENTRY){const n=t[jt(e)];return"number"==typeof n?n:zt(t)*i}return i}function Vt(t,e){return null==t&&null==e?e:(null!=t?t:0)+(null!=e?e:0)}class Qt{constructor(t,e){this.hasPartOf=!1,this.params=[],this.sortSelect="",this.hasBlankRowGroup=!1,this.config=t,this.i18n=e}execute(t,e){var n;this.db=t,this.fromExpr=e;for(const t of[...this.config.scenarios,...this.config.categoryThereOf.keys()])if(!a.test(t))throw new Error(`invalid identifier "${t}"`);const o=[],i=[],s=[],r=this.scenariosSQL(!1),l=this.scenariosSQL(!0),c=this.getRelativeScenarios(),h=this.config.attributes.map((t=>this.translateAttributeSQL(t))).toString(),u=new Bt(this.config),d=this.config.interval===K?this.config.sortOrder:{hierarchy:this.config.sortOrder.hierarchy.map((t=>{var e,n;return null!==(n=null===(e=W(t))||void 0===e?void 0:e.column)&&void 0!==n?n:t})),direction:this.config.sortOrder.direction};let f=["",""];d.hierarchy.length>0&&(f=this.createOrderString(d)),this.hasPartOf=this.checkConfigForPartOf();const{hierarchy:p,direction:v}=d,m=p.filter((t=>t===y.ROWGROUP||t===y.ROWGROUPINDEX||t.toUpperCase()in O)),$=m.filter((t=>t.toUpperCase()in O)).map((t=>`, SUM(${t} * transformOperator(operation)) as ${t}`)).join(""),g=m.length>0?m.map((t=>`${t} ${v}`)).toString():`${y.ROWGROUPINDEX} asc`,b=t.exec(`SELECT COUNT(DISTINCT ${y.CATEGORY}) as ${y.TOTALROWCOUNT} ${this.config.grouped?`, ${Dt} as ${y.ROWGROUP}, FIRST(${y.ROWGROUPINDEX}) as ${y.ROWGROUPINDEX}${$}`:""}\n FROM ${e} ${this.config.grouped?`GROUP BY ${Dt} ORDER BY ${g}`:""}`);return 0===b.length||1===b.length&&0===(null!==(n=b[0][y.TOTALROWCOUNT])&&void 0!==n?n: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 (${y.ROWGROUP} IS NULL OR ${y.ROWGROUP} = '')`:`WHERE ${y.ROWGROUP} = ${this.bind(t.rowGroup)}`:"";let n="";this.config.limit&&(n=`LIMIT ${this.config.limit}`),this.createGroupHeaderRow(t,o),this.createDataRow(o,t,u,r,h,e,f,n),this.createRestRow(t,o,u,r,e,f),this.createGroupSumRow(o,i,t,l,e,f)})),this.createTotalSumRow(o,i,l),o.forEach((t=>s.push(this.exec(t)))),this.hasRunningSum()&&this.accumulateGroupSums(s,[...new Set(this.exctractScenarioNames(l))]),this.detectNaNCells(this.config.scenarios,s),this.createThereOfDrillRows(r,h,f,s),this.createPartOfDrillRows(r,f,i,s),this.createIntervalColumns(s),this.createThereOfDrillColumns(this.config.categoryThereOf,s),this.calculateColumnGroupRest(s,this.config.categoryThereOf),this.calculateRelativeVariances(s,c),s)}detectNaNCells(t,e){e.forEach((e=>{e.map((e=>(t.forEach((t=>{const n=new w(t);!0===n.isValid?0!==e[n.base+"_cnt"]&&0!==e[n.delta+"_cnt"]||(e[t]=Number.NaN):0===e[t+"_cnt"]&&(e[t]=Number.NaN)})),e)))}))}createPartOfDrillRows(t,e,n,o){if(null==this.config.partOf||0===this.config.partOf.length||this.config.type===l.LIST)return;const i=this.createPartOfQuery(t,e);let s=[];const r=this.db,a=this.params;i.forEach((t=>{s.push(...this.exec(t))}));const c=[...new Set(this.exctractScenarioNames(t))],h=[];n.forEach((function(t){h.push(...r.exec(t,a))}));const u=new Map;h.forEach((t=>u.set(t[y.ROWGROUP],t))),s=this.reduceResDrillByCategoryGroups(s,c),s.forEach((t=>{this.toShares(t,u.get(t[y.ROWGROUP]),c)})),this.injectDrillRowsToResultRows(s,o)}toShares(t,e,n){var o;const i=n=>t[n]/(e?e[n]:Number.NaN),s=new Map;for(const t of n){const e=new w(t);e.isValid&&s.set(t,i(e.base)-i(e.delta))}for(const e of n)t[e]=null!==(o=s.get(e))&&void 0!==o?o:i(e)}createRestRow(t,e,n,o,i,s){var r;if(t.totalRowCnt-this.config.limit>0&&0!==this.config.limit){const a=this.exctractScenarioNames(o).map((t=>`SUM(${t}) as ${t}`)).join(", "),c=this.exctractScenarioNames(o).filter((t=>{var e;return null===(e=this.config.barColumns)||void 0===e?void 0:e.includes(t)})).map((t=>`, SUM(${t} * transformOperator(operation)) as ${jt(t)}`)).join(""),h=l.OPT===this.config.type||l.OPTNOTOTAL===this.config.type?`, CASE WHEN MAX(transformOperator(operation)) = -1 THEN '-' ELSE '+' END as restOperation${c}`:"";e.push(`SELECT ${y.ROWNR}, 1 as ${y.ROWGROUPINDEX} , 'ENTRY' as ${y.TYPE}, 'NO_GROUP' as ${y.ROWGROUP}, ${this.bind(String(null!==(r=t.rowGroup)&&void 0!==r?r:""))} as restRowGroup, 'REST' as ${y.CATEGORY}${h} ${a.length>0?", "+a:""} FROM (SELECT ROWNUM() AS ${y.ROWNR}, ${e.length} as ${y.ROWGROUPINDEX} , 'ENTRY' as ${y.TYPE}, ${this.bind(String(t.rowGroup||"NO_GROUP"))} as ${y.ROWGROUP}, ${n.select()} ${o.length>0?",".concat(o):""}${this.sortSelect} FROM ${this.fromExpr} ${i} GROUP BY ${n} ORDER BY ${s[0]}) t WHERE t.rowNr > ${this.config.limit}`)}}createDataRow(t,e,n,o,i,s,r,l){t.push(`SELECT ROWNUM() AS ${y.ROWNR},\n ${t.length} as ${y.ROWGROUPINDEX},\n 'ENTRY' as ${y.TYPE},\n ${this.bind(String(e.rowGroup||"NO_GROUP"))} as ${y.ROWGROUP},\n '${y.CATEGORYINDEX}',\n ${n.select()} ${o.length>0?",".concat(o):""} ${i.length>0?",".concat(i):""}${this.sortSelect}\n FROM ${this.fromExpr} ${s}\n GROUP BY ${n}\n ORDER BY ${r[0]} ${l}`)}createGroupHeaderRow(t,e){if(!0===this.config.grouped&&(this.config.showGroupTitle||!this.hasGroupSum())){const n=this.bind(String(t.rowGroup)),o=""===t.rowGroup?this.bind("-"):n;e.push(`SELECT ROWNUM() AS ${y.ROWNR},\n ${e.length} as ${y.ROWGROUPINDEX},\n 'GROUPHEAD' as ${y.TYPE},\n ${n} as ${y.ROWGROUP} ${this.config.showGroupTitle?`,${o} as ${y.CATEGORY}`:""}\n FROM ${this.fromExpr}\n GROUP BY '1'`)}}hasGroupSum(){return l.SUM===this.config.type||l.SUMNOTOTAL===this.config.type||l.OPT===this.config.type||l.OPTNOTOTAL===this.config.type}hasRunningSum(){return this.config.runningSum&&this.config.grouped&&this.hasGroupSum()&&0===this.config.categoryThereOf.size}accumulateGroupSums(t,e){const n={};for(const o of t)for(const t of o)if("GROUP_SUM"===t[y.TYPE])for(const o of e)n[o]=Vt(n[o],t[o]),t[o]=n[o]}createGroupSumRow(t,e,n,o,i,s){if(!0===this.config.grouped&&this.hasGroupSum()){const r=this.bind(String(n.rowGroup));t.push(`SELECT ${t.length} as ${y.ROWGROUPINDEX},\n '=' as ${y.OPERATION},\n ${r} as ${y.ROWGROUP},\n ROWNUM() AS ${y.ROWNR},\n 'GROUP_SUM' as ${y.TYPE} ${o.length>0?",".concat(o):""}\n FROM ${this.fromExpr} ${i}\n ORDER BY ${s[0]} `),e.push(`SELECT ${t.length} as ${y.ROWGROUPINDEX},\n '=' as ${y.OPERATION},\n ${r} as ${y.ROWGROUP},\n ROWNUM() AS ${y.ROWNR},\n 'GROUP_SUM' as ${y.TYPE} ${o.length>0?",".concat(o):""}\n FROM ${this.fromExpr} ${i}\n ORDER BY ${s[0]} `)}}createTotalSumRow(t,e,n){var o;if(l.SUM===this.config.type||l.OPT===this.config.type){const e=(null===(o=this.config.title)||void 0===o?void 0:o.trim())||"SUM_TOTAL",i=this.hasPartOf&&!1===this.config.grouped&&"SUM_TOTAL"!==e?`${this.i18n.get("SUM_TOTAL")||"SUM_TOTAL"} ${e}`:e;t.push(`SELECT ${t.length} as ${y.ROWGROUPINDEX},\n ${this.bind(i)} as ${y.ROWGROUP},\n '=' as ${y.OPERATION},\n 'SUM' as ${y.TYPE} ${n.length>0?",".concat(n):""}\n FROM ${this.fromExpr} `)}e.push(`SELECT ${t.length} as ${y.ROWGROUPINDEX},\n 'SUM_TOTAL' as ${y.ROWGROUP},\n '=' as ${y.OPERATION},\n 'SUM' as ${y.TYPE} ${n.length>0?",".concat(n):""}\n FROM ${this.fromExpr} `)}reduceResDrillByCategoryGroups(t,e){const n=new Map;return t.forEach((function(t){const o=t.rowNr+t.rowGroup+t.type+t.category;if(n.has(o)){const i=n.get(o);e.forEach((e=>{try{i[e]+=t[e]}catch(t){console.error("DataQuery: drill row aggregation failed",e,t)}}))}else n.set(o,t)})),[...n.values()]}injectDrillRowsToResultRows(t,e){const n=new Map;if(!0===this.config.grouped)t.forEach((function(t){e.forEach((function(e){const o=e.findIndex((e=>e.category===t.category&&e.rowGroup===t.rowGroup));if(o>=0){if(n.has(`${t.category}_${t.rowGroup}`)){const e=n.get(`${t.category}_${t.rowGroup}`)||0;n.set(`${t.category}_${t.rowGroup}`,e+1)}else n.set(`${t.category}_${t.rowGroup}`,1);t[y.ROWNR]=n.get(`${t.category}_${t.rowGroup}`),e.splice(o+t[y.ROWNR],0,t)}}))}));else{const o=this.findDuplicateSubCategories(t);t.forEach((function(t){e.forEach((function(e){const i=e.findIndex((e=>null!=e.category&&e.category===t.category));if(i>=0){if(n.has(`${t.category}`)){const e=n.get(`${t.category}`)||0;n.set(`${t.category}`,e+1)}else n.set(`${t.category}`,1);null!=t.rowGroup&&""!==t.rowGroup&&o.includes(`${t.category}##${t.subCategory}`)&&(t.rawSubCategory=t.subCategory,t.subCategory=`${t.subCategory} (${t.rowGroup})`),e.splice(i+t[y.ROWNR],0,t)}}))}))}}createThereOfDrillRows(t,e,n,o){if(void 0===this.config.thereOf||0===this.config.thereOf.length)return;const i=[],s=[];this.config.thereOf.forEach((o=>{let s=!0,r="1 <> 1 OR ( ";null!=o.category&&0!==o.category.length&&o.category.trim()&&(r+=` ${y.CATEGORY} = ${this.bind(o.category)}`,s=!1),null!=o.rowGroup&&0!==o.rowGroup.length&&o.rowGroup.trim()&&(r+=` ${s?"":"AND"} ${y.ROWGROUP} = ${this.bind(o.rowGroup)}`,s=!1),null!=o.subCategory&&0!==o.subCategory.length&&o.subCategory.trim()&&(r+=` ${s?"":"AND"} ${y.SUBCATEGORY} = ${this.bind(o.subCategory)}`),r+=")",i.push(`SELECT ROWNUM() AS ${y.ROWNR},\n null as operation,\n 'DRILLELEMENT' as ${y.TYPE},\n ${y.CATEGORY},\n ${y.SUBCATEGORY},\n ${this.drillRowGroup} as ${y.ROWGROUP},\n ${t} ${e.length>0?",".concat(e):""}${this.sortSelect}\n FROM ${this.fromExpr}\n WHERE ${r}\n GROUP BY ${this.drillRowGroup}, ${y.CATEGORY}, ${y.SUBCATEGORY}\n ORDER BY ${n[1]}`)})),i.forEach((t=>{s.push(...this.exec(t))})),this.injectDrillRowsToResultRows(s,o)}calculateRelativeVariances(t,e){t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[y.TYPE]&&e.forEach(((e,n)=>{var o;t[n]=null!==(o=C(t[n],t[e]))&&void 0!==o?o:U}))}))}))}calculateColumnGroupRest(t,e){if(null==e||0===e.size)return;const n=new Map,o=new Map;e.forEach(((t,e)=>{const i=t,s=[];for(const t of i)s.push(`${e}##${t.name}`);n.set(e,s),o.set(`${e}##REST`,!1)})),t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[y.TYPE]&&n.forEach(((e,n)=>{let i=0;e.forEach((e=>{void 0!==t[e]&&(i+=t[e])})),t[`${n}##REST`]=t[n]-i,0!==t[`${n}##REST`]&&o.set(`${n}##REST`,!0)}))}))}));const i=Array.from(o.entries()).filter((([t,e])=>!e)).map((([t])=>t));t.forEach((t=>{t.forEach((t=>{for(const e of i)delete t[e]}))}))}createIntervalColumns(t){var e,n,o,i,s;if(this.config.interval===Q||this.config.categoryThereOf.size>0||0===this.config.scenarios.length)return;const r="##",a=`(SELECT *, ${q(this.config.interval)} as __interval FROM ${this.fromExpr}) as p`,c=this.scenariosSQL(!1),h=this.scenariosSQL(!0),u=[...new Set(this.exctractScenarioNames(c))],d=this.getRelativeScenarios(),f=new Bt(this.config),p=l.OPT===this.config.type||l.OPTNOTOTAL===this.config.type,v=this.config.grouped&&(l.SUM===this.config.type||l.SUMNOTOTAL===this.config.type||l.OPT===this.config.type||l.OPTNOTOTAL===this.config.type),m=this.checkConfigForPartOf()&&this.config.type!==l.LIST,$=t=>this.exec(t),g=t=>(this.config.scenarios.forEach((e=>{const n=new w(e);!0===n.isValid?0!==t[n.base+"_cnt"]&&0!==t[n.delta+"_cnt"]||(t[e]=Number.NaN):0===t[e+"_cnt"]&&(t[e]=Number.NaN)})),d.forEach(((e,n)=>{var o;t[n]=null!==(o=C(t[n],t[e]))&&void 0!==o?o:U})),t),b=(t,e,n)=>{for(const o of this.config.scenarios)t[o+r+n]=e[o]},S=$(`SELECT ${f.select()}, __interval ${c.length>0?",".concat(c):""}\n FROM ${a}\n GROUP BY ${f}, __interval`),R=t=>"ENTRY"===t.type&&null!=t.restRowGroup;if(this.config.limit>0)for(let o=0;o<t.length;o++){const i=t[o].find(R);if(!i)continue;let s;for(let e=o-1;e>=0&&!s;e--){const n=t[e].filter((t=>"ENTRY"===t.type&&!R(t)));n.length>0&&(s=n)}if(!s)continue;const r=new Set(s.map((t=>t.category))),l=s[0].rowGroup,a=new Map;for(const t of S){if(this.config.grouped&&t.rowGroup!==l)continue;if(r.has(t.category))continue;const o=J(t.__interval);let i=a.get(o);i||(i={},a.set(o,i));for(const o of u)i[o]=(null!==(e=i[o])&&void 0!==e?e:0)+(null!==(n=t[o])&&void 0!==n?n:0)}a.forEach(((t,e)=>{b(i,g(t),e)}))}for(const e of S){const n=J(e.__interval);g(e);for(const o of t)for(const t of o)"ENTRY"!==t.type||R(t)||t.category!==e.category||this.config.grouped&&t.rowGroup!==e.rowGroup||p&&t.operation!==e.operation||b(t,e,n)}const E=v||m&&this.config.grouped?$(`SELECT ${Dt} as ${y.ROWGROUP}, __interval ${h.length>0?",".concat(h):""}\n FROM ${a}\n GROUP BY ${Dt}, __interval`):[],M=new Map;if(E.forEach((t=>M.set(`${t.rowGroup}${r}${J(t.__interval)}`,t))),v&&this.hasRunningSum()){const e=[...new Set(this.exctractScenarioNames(h))],n=t.flat().filter((t=>"GROUP_SUM"===t.type));for(const t of new Set(E.map((t=>J(t.__interval))))){let o;for(const i of n){const n=M.get(`${i.rowGroup}${r}${t}`);if(n){null!=o||(o={});for(const t of e)o[t]=Vt(o[t],n[t])}o&&b(i,g(Object.assign({},o)),t)}}}else if(v)for(const e of E){const n=J(e.__interval),o=g(Object.assign({},e));for(const i of t)for(const t of i)"GROUP_SUM"===t.type&&t.rowGroup===e.rowGroup&&b(t,o,n)}const O=l.SUM===this.config.type||l.OPT===this.config.type,_=O||m&&!this.config.grouped?$(`SELECT __interval ${h.length>0?",".concat(h):""}\n FROM ${a}\n GROUP BY __interval`):[],x=new Map;if(_.forEach((t=>x.set(J(t.__interval),t))),O)for(const e of _){const n=J(e.__interval),o=g(Object.assign({},e));for(const e of t)for(const t of e)"SUM"===t.type&&b(t,o,n)}if(null!=this.config.thereOf&&this.config.thereOf.length>0){const e=[];this.config.thereOf.forEach((t=>{e.push(...$(`SELECT ${this.drillRowGroup} as ${y.ROWGROUP}, ${y.CATEGORY}, ${y.SUBCATEGORY}, __interval ${c.length>0?",".concat(c):""}\n FROM ${a}\n WHERE ${this.createThereOfWhereClause(t)}\n GROUP BY ${this.drillRowGroup}, ${y.CATEGORY}, ${y.SUBCATEGORY}, __interval`))}));for(const n of e){const e=J(n.__interval);g(n);for(const o of t)for(const t of o)"DRILLELEMENT"===t.type&&t.category===n.category&&t.rowGroup===n.rowGroup&&(t.subCategory!==n.subCategory&&t.subCategory!==`${n.subCategory} (${n.rowGroup})`||b(t,n,e))}}if(m){let e="1 <> 1 ";null===(o=this.config.partOf)||void 0===o||o.forEach((t=>{e+=`OR (${y.CATEGORY} = ${this.bind(t.category)}`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(e+=`and ${y.ROWGROUP} = ${this.bind(t.rowGroup)}`),e+=")"}));const n=$(`SELECT ${y.CATEGORY}, ${this.config.grouped?`${y.ROWGROUP}`:`'SUM_TOTAL' as ${y.ROWGROUP}`}, __interval ${c.length>0?",".concat(c):""}\n FROM ${a}\n WHERE ${e}\n GROUP BY ${y.ROWGROUP}, ${y.CATEGORY}, __interval`),l=new Map;for(const t of n){const e=`${t.rowGroup}${r}${t.category}${r}${J(t.__interval)}`,n=l.get(e);if(n)for(const e of u)n[e]=(null!==(i=n[e])&&void 0!==i?i:0)+(null!==(s=t[e])&&void 0!==s?s:0);else l.set(e,t)}l.forEach((e=>{const n=J(e.__interval),o=this.config.grouped?M.get(`${e.rowGroup}${r}${n}`):x.get(n);this.toShares(e,o,u),g(e);for(const o of t)for(const t of o)"PARTELEMENT"===t.type&&t.category===e.category&&t.rowGroup===e.rowGroup&&b(t,e,n)}))}}createThereOfWhereClause(t){let e=!0,n="1 <> 1 OR ( ";return null!=t.category&&0!==t.category.length&&t.category.trim()&&(n+=` ${y.CATEGORY} = ${this.bind(t.category)}`,e=!1),null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(n+=` ${e?"":"AND"} ${y.ROWGROUP} = ${this.bind(t.rowGroup)}`,e=!1),null!=t.subCategory&&0!==t.subCategory.length&&t.subCategory.trim()&&(n+=` ${e?"":"AND"} ${y.SUBCATEGORY} = ${this.bind(t.subCategory)}`),n+")"}scenariosSQL(t){const e=this.config.scenarios,n=e.map((e=>this.translateScenarioSQL(e,t,this.config.type)));if(this.checkConfigForPartOf()&&this.config.type!==l.LIST){const o=new Set;for(const t of e){const e=new w(t);e.isValid&&o.add(e.base).add(e.delta)}for(const i of o)e.includes(i)||n.push(this.translateScenarioSQL(i,t,this.config.type).split(", COUNT(")[0])}return n.toString()}getRelativeScenarios(){const t=new Map;return this.config.scenarios.forEach((e=>{const n=this.createRelativeScenario(e);null!=n&&t.set(n.key,n.value)})),t}translateScenarioSQL(t,e,n){const o=new w(t);if(l.OPT===n||l.OPTNOTOTAL===n){if(o.isValid){const n=e?" * transformOperator(operation)":"",i=e?`SUM((${o.base} - ${o.delta})${n}) as ${t}`:`SUM(${o.base} - ${o.delta}) as ${t}`;return"dr"===o.type?`${i}, SUM(${o.delta}${n}) as dr_${o.delta}`:i}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 o.isValid?"dr"===o.type?`SUM((${o.base} * transformOperator(operation)) - (${o.delta} * transformOperator(operation))) as ${t}, SUM(${o.delta} * transformOperator(operation)) as dr_${o.delta}`:`SUM((${o.base} * transformOperator(operation))- (${o.delta} * transformOperator(operation))) as ${t}`:`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}translateAttributeSQL(t){const e=`[${t.arg}]`,n=/^(ac|pp|fc|pl)[1-4]$/.test(t.arg)&&this.config.type!==l.OPT&&this.config.type!==l.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 n?`AVG(${e} * transformOperator(operation)) as ${t.alias}`:`AVG(${e}) as ${t.alias}`;case"sum":return n?`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?Dt:y.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=c.ASC===t.direction?c.DESC:c.ASC,n=new Map;t.hierarchy.forEach(((t,e)=>{const o=W(t),i=null==o?void 0:o.bucket;("variance"===(null==o?void 0:o.kind)||"scenario"===(null==o?void 0:o.kind)&&void 0!==i)&&n.set(e,this.translateSortKeySQL(o,i,e))})),this.sortSelect=[...n.values()].map((t=>`, ${t}`)).join("");const o=t.hierarchy.some((t=>{var e;const n=null===(e=W(t))||void 0===e?void 0:e.kind;return"scenario"===n||"variance"===n}));o&&(this.sortSelect+=`, CASE WHEN ${y.CATEGORY} = 'REST' THEN 1 ELSE 0 END as __sortrest`);const i=(t,e,o)=>n.has(e)?`__sortnull${e} asc, __sort${e} ${o}`:`${t} ${o}`,s=t.hierarchy.map(((e,n)=>i(e,n,t.direction))).toString(),r=t.hierarchy.map(((t,n)=>i(t,n,e))).toString();return o?[`__sortrest asc, ${s}`,`__sortrest desc, ${r}`]:[s,r]}translateSortKeySQL(t,e,n){const o=l.OPT===this.config.type||l.OPTNOTOTAL===this.config.type?"":" * transformOperator(operation)",i=void 0===e?"":`TRIM(CAST(${q(K)} AS STRING)) = ${this.bind(e)}`,s=t=>`SUM(${i?`(CASE WHEN ${i} THEN ${t} ELSE 0 END)`:t}${o})`,r=t=>`SUM(CASE WHEN ${i?`${i} AND `:""}${t} IS NOT NULL THEN 1 ELSE 0 END) = 0`;if("scenario"===t.kind)return`${s(t.column)} as __sort${n}, CASE WHEN ${r(t.column)} THEN 1 ELSE 0 END as __sortnull${n}`;const a=`(${s(t.base)} - ${s(t.delta)})`;let c=a,h=`${r(t.base)} OR ${r(t.delta)}`;if("dr"===t.type){const e=s(t.delta),n=`ABS(${e}) <= ABS(${a}) * 0.000000001`;c=`CASE WHEN ${n} THEN 0 ELSE ${a} / ABS(${e}) END`,h+=` OR ${n}`}return`${c} as __sort${n}, CASE WHEN ${h} THEN 1 ELSE 0 END as __sortnull${n}`}createRelativeScenario(t){const e=new w(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 n;const o=[];let i="1 <> 1 ",s=` ${this.drillRowGroup} as ${y.ROWGROUP}`,r="ROWNUM()";return null===(n=this.config.partOf)||void 0===n||n.forEach((t=>{i+=`OR (${y.CATEGORY} = ${this.bind(t.category)}`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(i+=`and ${y.ROWGROUP} = ${this.bind(t.rowGroup)}`),!1===this.config.grouped&&(s=` 'SUM_TOTAL' as ${y.ROWGROUP} `,r="1"),i+=")"})),o.push(`SELECT ${r} AS ${y.ROWNR},\n 'PARTELEMENT' as ${y.TYPE},\n ${y.CATEGORY},\n ${s},\n ${t}${this.sortSelect}\n FROM ${this.fromExpr}\n WHERE ${i}\n GROUP BY ${this.drillRowGroup}, ${y.CATEGORY}, ${y.TYPE}\n ORDER BY ${e[1]}`),o}checkConfigForPartOf(){return null!=this.config.partOf&&0!==this.config.partOf.length}createThereOfDrillColumns(t,e){if(null==t||0===t.size)return;const n=[],o=[],i=this.fromExpr;t.forEach(((t,e)=>{let o="1 <> 1 ";t.forEach((t=>{o+=` or columnGroup = ${this.bind(String(t.name))} `})),n.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 ${i}\n WHERE ${o}\n GROUP BY rowlevel, rowGroup, category, columnGroup, scenario`),n.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 ${i}\n WHERE ${o}\n GROUP BY rowlevel, rowGroup, category, columnGroup, columnSubGroup, scenario`),n.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 ${i}\n WHERE ${o}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, scenario`),n.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 ${i}\n WHERE ${o}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, columnSubGroup, scenario`),n.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 ${i}\n WHERE ${o}\n GROUP BY rowlevel, rowGroup, columnGroup, scenario`),n.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 ${i}\n WHERE ${o}\n GROUP BY rowlevel, rowGroup, columnGroup, columnSubGroup, scenario`),n.push(`SELECT 'SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${i}\n WHERE ${o}\n GROUP BY rowlevel, columnGroup, scenario`),n.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 ${i}\n WHERE ${o}\n GROUP BY rowlevel, columnGroup, columnSubGroup, scenario`)}));for(const t of n)o.push(...this.db.exec(t,this.params));this.injectDrillColumnsToResultRows(o,e)}injectDrillColumnsToResultRows(t,e){const n="##";for(const o of t)for(const t of e)for(const e of t)if(e.type===o.rowlevel)if("ENTRY"===o.rowlevel)"COLUMNGROUP"===o.columnlevel&&e.category===o.category?e[o.scenario+n+o.columnGroup]=o.val:"SUBGROUP"===o.columnlevel&&e.category===o.category&&(e[o.scenario+n+o.columnGroup+n+o.columnSubGroup]=o.val);else if("DRILLELEMENT"===o.rowlevel){if(!this.config.grouped&&e.rowGroup!==o.rowGroup)continue;"COLUMNGROUP"===o.columnlevel&&e.category===o.category&&e.subCategory===o.subCategory?e[o.scenario+n+o.columnGroup]=o.val:"SUBGROUP"===o.columnlevel&&e.category===o.category&&e.subCategory===o.subCategory?e[o.scenario+n+o.columnGroup+n+o.columnSubGroup]=o.val:"COLUMNGROUP"===o.columnlevel&&e.category===o.category&&e.subCategory===`${o.subCategory} (${o.rowGroup})`?e[o.scenario+n+o.columnGroup]=o.val:"SUBGROUP"===o.columnlevel&&e.category===o.category&&e.subCategory===`${o.subCategory} (${o.rowGroup})`&&(e[o.scenario+n+o.columnGroup+n+o.columnSubGroup]=o.val)}else("SUM"===o.rowlevel||"GROUP_SUM"===o.rowlevel)&&("COLUMNGROUP"===o.columnlevel&&e.category===o.category&&e.subCategory===o.subCategory&&(e[o.scenario+n+o.columnGroup]=o.val),"SUBGROUP"===o.columnlevel&&e.category===o.category&&e.subCategory===o.subCategory&&(e[o.scenario+n+o.columnGroup+n+o.columnSubGroup]=o.val))}}class Kt{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)?S(this.ruleSet.getScenarioColorIndex(t))+t.slice(2):null}getNormalizedHeader(){return this.normalizedHeader}createHeader(t,e,n,o,i,s,l=[],a=0){const c=[];this.attributesByAlias=new Map(l.map((t=>[t.alias,t]))),this.normalizedHeader=this.normalizeHeader(t,e,l,a);const h=this.normalizedHeader.some((t=>void 0!==t.bucket));h&&c.push(this.createIntervalBandRow());const u=new ot(h?1:0,0,r.HEADER),d=new ot(h?2:1,0,r.SEPERATORLINE);for(const t of this.normalizedHeader){const e=this.attributesByAlias.get(t.name);u.createElement(e?n.get(e.label)||e.label:b.translateScenarioLabel(t.name,n),t.type,this.createColumnType(t),null,this.setHeaderPrefix(t,n,o,i,s),null,null,null,null),d.createElement(null,t.type,this.createColumnType(t),null,null,this.underlineClass(t.type),null,null,null)}return c.push(u),c.push(d),c}createIntervalBandRow(){const t=new ot(0,0,r.HEADER);let e=0;for(;e<this.normalizedHeader.length;){const n=this.normalizedHeader[e];if(void 0===n.bucket){t.createElement(null,n.type,"filler",null,null,null,null,null,null),e+=1;continue}let o=1;for(;e+o<this.normalizedHeader.length&&this.normalizedHeader[e+o].bucket===n.bucket;)o+=1;t.createElement(n.bucketLabel,n.type,"intervalGroup",null,null,null,null,null,null,!1,void 0,o),e+=o}return t}setHeaderPrefix(t,e,n,o,i){let s="";return"category"===t.name&&i&&(0===n.prefix.length&&0===o.length||(s=b.translateScenarioLabel("in",e)+" "+n.prefix+o)),t.order&&(s+=b.translateScenarioLabel("ORDER_"+t.order,e)),s}normalizeHeader(t,e,n,o=0){let i=[{name:y.CATEGORY,group:y.CATEGORY,type:y.CATEGORY,order:void 0}];l.OPT!==t&&l.OPTNOTOTAL!==t||(i=[{name:y.OPERATION,group:y.OPERATION,type:y.OPERATION,order:void 0},{name:y.CATEGORY,group:y.CATEGORY,type:y.CATEGORY,order:void 0}]);const s=n.map((t=>({name:t.alias,group:t.alias,type:t.alias,order:void 0})));return[...e.slice(0,o),...i,...s,...e.slice(o)]}createBodyRows(t,e,n,o){var i;const s=[];let a=-1;const c=new Qt(t,e);var u;this.dateBuckets=(u=t.interval)!==Q&&u!==K,this.unsignedEntries=l.OPT===t.type||l.OPTNOTOTAL===t.type;const d=c.execute(n,o);this.hasBlankRowGroup=c.hasBlankRowGroup;const f=this.calculateColumnStatistics(d,t.barColumns,t.interval!==Q),p=t.thereOfPosition===h.ABOVE,v=null!==(i=t.barColumns)&&void 0!==i?i:[],m=v.filter((t=>t.toUpperCase().trim()in O)),$=[...m.length>0&&Yt(d)?m:[],...t.varianceWaterfall?v.filter((t=>"d"===new w(t).type)):[]],g=$.length>0&&t.interval===Q&&0===t.categoryThereOf.size?function(t,e,n,o=!1,i=!1){const s=new It,a=n===l.OPT||n===l.OPTNOTOTAL;for(const l of e){const e=new w(l).isValid;let c,h=0,u=0;const d=[],f=[];let p=null;const v=(t,e)=>(d.push(e),s.set(t,l,e),e),m=t=>{p=t&&{main:t,children:[],gapAbove:!1,gapBelow:!1},f.push(p)};for(const s of t)for(const t of s){const s=t[y.TYPE];if(s===r.GROUPHEAD){o||(h=0),c=void 0,m(null);continue}const d=Xt(t,l,n);if(s===r.ENTRY){if(null===d){c=void 0,m(null);continue}m(v(t,{start:h,end:h+d,min:0,max:0,kind:"cascade"})),c={start:h,end:h+d,sign:a?zt(t):1},u=c.start,h+=d}else if(s===r.SUM||s===r.GROUPSUM){if(null===d){c=void 0,m(null);continue}m(v(t,{start:0,end:d,min:0,max:0,kind:"anchor"})),c={start:0,end:d,sign:1},u=0,h=s!==r.GROUPSUM||o?d:0}else if(!e||s!==r.DRILLELEMENT&&s!==r.PARTELEMENT){if(s===r.DRILLELEMENT){if(null===d||void 0===c)continue;const e=u+(Math.sign(c.end-c.start)||1)*Math.abs(d);v(t,{start:u,end:e,min:0,max:0,kind:"thereof",parentStart:c.start,parentEnd:c.end}),u=e}else if(s===r.PARTELEMENT){if(null===d||void 0===c)continue;const e=u+d*(c.end-c.start);v(t,{start:u,end:e,min:0,max:0,kind:"partof",parentStart:c.start,parentEnd:c.end}),u=e}}else if(s===r.DRILLELEMENT&&null!==d&&void 0!==c&&p){const e=u+c.sign*d;p.children.push(v(t,{start:u,end:e,min:0,max:0,kind:"thereof"})),u=e}else p&&(i&&s===r.DRILLELEMENT?p.gapAbove=!0:p.gapBelow=!0)}e&&Ht(f,i);let $=0,g=0;for(const t of d)$=Math.min($,t.start,t.end),g=Math.max(g,t.start,t.end);for(const t of d)t.min=$,t.max=g}return s}(d,$,t.type,c.hasRunningSum(),p):void 0;for(const n of d)a+=1,s.push(...this.createRow(t.i18n,e,t.scenariosUnitType,n,a,-1,t.categoryWidth,t.measureScale,t.barColumns,f,g,p));return s}calculateColumnStatistics(t,e,n=!1){const o=new Map;if(!e||0===e.length)return o;const i=new Map;for(const t of e)o.set(t,{min:1/0,max:-1/0,absMax:0,median:0}),i.set(t,[]);for(const s of t)for(const t of s){const s=t[y.TYPE];if(s!==r.SUM&&s!==r.GROUPSUM)for(const s of e){const e=n?this.extractIntervalColumnValues(t,s):[this.extractColumnValue(t,s)];for(const t of e)if(null!==t&&!isNaN(t)){const e=o.get(s);e.min=Math.min(e.min,t),e.max=Math.max(e.max,t),i.get(s).push(Math.abs(t))}}}for(const[t,e]of o){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 n=i.get(t);if(n.length>0){n.sort(((t,e)=>t-e));const t=Math.floor(n.length/2);e.median=n.length%2==0?(n[t-1]+n[t])/2:n[t]}o.set(t,e)}return o}extractIntervalColumnValues(t,e){const n=e+"##",o=[];for(const e of Object.keys(t))if(e.startsWith(n)){const n=Number(t[e]);o.push(isNaN(n)?null:n)}return o}extractColumnValue(t,e){if(void 0!==t[e]){const n=Number(t[e]);return isNaN(n)?null:n}for(const n of Object.keys(t))if(n===e||n.endsWith("##"+e)||n===e+"##"+e){const e=Number(t[n]);if(!isNaN(e))return e}return null}createRow(t,e,n,o,i,s,l,a,c,h,u,d=!1){var f,p,m;const $=[];let g,b,S=-1;for(const R of o){const E=R[y.ROWGROUP],M=""===E?"-":E,O=R[y.SUBCATEGORY],x=R[y.TYPE],N=R[y.ROWNR]>=2;b=null!==(p=null!==(f=R.operation)&&void 0!==f?f:R.restOperation)&&void 0!==p?p:b;const k=d&&x===r.DRILLELEMENT&&void 0!==g&&g[y.CATEGORY]===R[y.CATEGORY]&&("NO_GROUP"===g[y.ROWGROUP]||g[y.ROWGROUP]===E),G=this.createDetailRow(x,s+=1,i,o.length);G.key=this.rowKey(R);for(const o of this.normalizedHeader){const i=this.getRawDataRowElement(R,o),s=null!==(m=null==c?void 0:c.includes(o.type))&&void 0!==m&&m,d=s&&void 0===o.bucket&&o.name===o.group&&o.name===o.type?null==u?void 0:u.get(R,o.type):void 0,f=x===r.PARTELEMENT&&new w(o.type).isValid,p=s&&!f,$=p?null==h?void 0:h.get(o.type):void 0;G.createElement(f&&n===_.PERCENT?"-":this.translateSumCellLabel(t,e,i,M,O,x,o.type),o.type,this.createColumnType(o),this.setCellType(o.type,n),k?null:this.translateCellPrefix(e,x,o.type),this.translateScenarioCSS(o.type,i,b),N,l,null==a?void 0:a.value,p,$,1,d);const g=G.elements[G.elements.length-1];this.dateBuckets&&void 0!==o.bucket&&(g.date=v(o.bucket));const y=new w(o.type);y.isValid&&(g.direction=this.resolveDirection(y,b))}k?(G.cssStyle="ofit-above",$[S].cssStyle="ofit-sum",$.splice(S,0,G),S+=1):(x===r.ENTRY&&(S=$.length,g=R),$.push(G))}return $}rowKey(t){var e;const n=null!=t.restRowGroup?t.restRowGroup:"NO_GROUP"===t.rowGroup?void 0:t.rowGroup;switch(t.type){case r.ENTRY:return{rowGroup:n,category:t.category,subCategory:t.subCategory};case r.DRILLELEMENT:return{rowGroup:n,category:t.category,subCategory:null!==(e=t.rawSubCategory)&&void 0!==e?e:t.subCategory};case r.GROUPSUM:return{rowGroup:n,row:"subtotal"};case r.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,n,o){switch(t){case r.GROUPHEAD:return new ot(e,n,r.HEADER);case r.SUM:case r.GROUPSUM:return new ot(o+2,n,r.SUM);case r.DRILLELEMENT:return new ot(o+2,n,r.DRILLELEMENT);case r.PARTELEMENT:return new ot(o+2,n,r.PARTELEMENT);default:return new ot(e,n,r.STANDARD)}}translateSumCellLabel(t,e,n,o,i,s,r){return this.attributesByAlias.has(r)||!1===Number.isNaN(Number(n))||this.isOperationColumn(r)?n:this.isGroupHeadCategory(s,r)?t===x.ALL?`${e.get(n)||n}`:n:this.isEntryCategory(s,r)?t===x.ALL||"REST"===n?`${e.get(n)||n}`:n:this.isDrillElementCategory(s,r)?t===x.ALL?`${e.get(i)||i}`:`${i}`:this.isPartElementCategory(s,r)?t===x.ALL||"SUM_TOTAL"===o?`${e.get(o)||o}`:`${o}`:this.isSumElementCategory(s,r)?t===x.ALL||"SUM_TOTAL"===o?`${e.get(o)||o}`:o:"GROUPHEAD"===s&&null==n||n===U?n:Number.isNaN(Number(n))?"-":Number(n)}isOperationColumn(t){return"operation"===t}translateScenarioCSS(t,e,n){if(this.attributesByAlias.has(t))return"attribute";const o=new w(t);let i="pos";return e<0&&(i="neg"),o.isValid?i+"_"+this.resolveDirection(o,n)+("dr"===o.type?" relative_variance":""):t}resolveDirection(t,e){return R(t.direction,e,!this.unsignedEntries)}setCellType(t,e){if("category"===t)return"";const n=this.attributesByAlias.get(t);if(n)return n.isNumeric?"decimal":"";let o;const i=new w(t);return e===_.PERCENT?(o="percent",i.isValid&&"d"===i.type&&(o="percentpoint")):(o="decimal",i.isValid&&"dr"===i.type&&(o="percent")),o}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,n){return this.isOperationColumn(n)||this.isGroupHeadCategory(e,n)||this.isEntryCategory(e,n)?null:this.isDrillElementCategory(e,n)?`${t.get("thereof")} `:this.isPartElementCategory(e,n)?`${t.get("part_of")} `:null}createColumnType(t){return t.name===t.group&&t.name===t.type?"base":t.name===t.group?"columnGroup":"columnSubGroup"}}class qt{constructor(t,e,n,o){this.fromExpr="",this.rowCount=0,this.headerRows=[],this.bodyRows=[],this.intervalBuckets=[],this.ruleSet=t||new E,this.db=e,this.dataSetFactory=new Kt(this.ruleSet),this.config=this.initConfig(o),this.i18n=this.initI18n(new Map),this.setSource(n,o.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=u.DIRTY,new Map([...e,...t||new Map])}initConfig(t){this.state=u.DIRTY;const e=t,n=this;return t.scenarios.sort(((t,e)=>n.ruleSet.getScenarioSorIndex(t)-n.ruleSet.getScenarioSorIndex(e))),e}setConfig(t){this.config=this.initConfig(t)}setSource(t,e){var n,o;if(this.state=u.DIRTY,this.fromExpr=B(this.db,t,e),!this.fromExpr)return void(this.rowCount=0);const i=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(o=null===(n=i[0])||void 0===n?void 0:n.cnt)&&void 0!==o?o: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,Math.min(this.categoryIntervalPosition(),this.intervalBuckets.length)*this.config.scenarios.length),this.bodyRows=0!==this.rowCount&&this.fromExpr?this.dataSetFactory.createBodyRows(this.config,this.i18n,this.db,this.fromExpr):[],this.state=u.UP_TO_DATE}getHeader(){return this.state===u.DIRTY&&this.update(),this.headerRows}getBody(){return this.state===u.DIRTY&&this.update(),this.bodyRows}getColumns(){return this.state===u.DIRTY&&this.update(),this.dataSetFactory.getNormalizedHeader()}prepareIntervalBuckets(){this.intervalBuckets=[],this.config.interval===Q||!this.fromExpr||this.config.categoryThereOf.size>0?this.config.interval=Q:(this.config.interval=function(t,e,n){var o;if(n!==P.AUTO)return n;const i=t.exec(`SELECT [date] as d FROM ${e}`);let s,r;for(const t of i){const e=null===(o=tt(t.d))||void 0===o?void 0:o.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?P.DAY:(new A).calculateDistanceType(T.fromMillis(s),T.fromMillis(r))}(this.db,this.fromExpr,this.config.interval),this.intervalBuckets=function(t,e,n,o){if(n===K){const o=t.exec(`SELECT ${q(n)} as __interval, COALESCE([setnameIndex],[setNameIndex]) as __index FROM ${e}`),i=new Set,s=new Map,r=[];for(const t of o){const e=J(t.__interval);i.has(e)||(i.add(e),r.push({key:e,label:0===e.length?"-":e}));const n=Z(t.__index),o=s.get(e);void 0!==n&&(void 0===o||n<o)&&s.set(e,n)}if(s.size>0){const t=t=>{var e;return null!==(e=s.get(t.key))&&void 0!==e?e:Number.POSITIVE_INFINITY};r.sort(((e,n)=>t(e)===t(n)?0:t(e)<t(n)?-1:1))}return r}const i=t.exec(`SELECT ${q(n)} as __interval FROM ${e}`),s=new Set,r=[];for(const t of i){const e=tt(t.__interval);if(!e)continue;const n=e.toISO();s.has(n)||(s.add(n),r.push(e))}r.sort(((t,e)=>t.toMillis()-e.toMillis()));const l=new A;return l.setLocale(o),r.map((t=>({key:t.toISO(),label:l.getDateString(t,n)})))}(this.db,this.fromExpr,this.config.interval,this.config.locale),0===this.intervalBuckets.length&&(this.config.interval=Q))}normalizeScenarios(t,e,n,o=[]){var i;const s=[],r=null===(i=null==n?void 0:n.hierarchy)||void 0===i?void 0:i.map((t=>W(t))).find((t=>"dim"!==(null==t?void 0:t.kind))),l=this.config.interval===K?null==r?void 0:r.bucket:void 0,a=(t,e)=>{var o;return null==r||(null===(o=W(t))||void 0===o?void 0:o.column)!==r.column||void 0!==l&&l!==e?void 0:n.direction};if(o.length>0){for(const e of o)for(const n of t)s.push({name:n,group:n,type:n,order:a(n,e.key),bucket:e.key,bucketLabel:e.label});return s}for(const n of t){if(null==e?void 0:e.has(n)){const t=e.get(n);for(const e of t){s.push({name:e.name,group:e.name,type:n,order:void 0});for(const t of e.subGroups)s.push({name:t,group:e.name,type:n,order:void 0})}s.push({name:"REST",group:"REST",type:n,order:void 0})}s.push({name:n,group:n,type:n,order:a(n)})}return s}hasNoData(){return 0===this.rowCount}orderBucketWarning(){var t,e;if(this.hasNoData()||this.state!==u.UP_TO_DATE)return;const n=(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=W(t))||void 0===e?void 0:e.bucket})).filter((t=>void 0!==t));if(0===n.length)return;if(this.config.interval!==K)return`order: '@${n[0]}' needs interval setname, the bucket is ignored.`;const o=n.find((t=>!this.intervalBuckets.some((e=>e.key===t))));return void 0===o?void 0:`order: setname '${o}' not found, the rows are not sorted by it.`}categoryIntervalPosition(){const t=this.config.categoryIntervalPosition;return Number.isInteger(t)&&t>0?t:0}categoryIntervalPositionWarning(){const t=this.categoryIntervalPosition();if(t<=0||this.hasNoData()||this.state!==u.UP_TO_DATE)return;const e=this.intervalBuckets.length;return 0===e?{id:"WARN_categoryIntervalPositionNoInterval",message:"categoryIntervalPosition: needs an active interval, the value is ignored."}:t>e?{id:"WARN_categoryIntervalPositionRange",message:`categoryIntervalPosition: '${t}' is greater than the number of interval groups, ${e} is used.`}:void 0}hasBlankRowGroup(){return this.dataSetFactory.hasBlankRowGroup}}class Zt{constructor(){this.title="",this.scenarios=[],this.scenariosUnitType=_.DECIMAL,this.grouped=!1,this.showGroupTitle=!0,this.runningSum=!1,this.varianceWaterfall=!1,this.thereOf=[],this.thereOfPosition=h.BELOW,this.categoryThereOf=new Map,this.partOf=[],this.attributes=[],this.sortOrder=new D(new z).default(),this.type=l.LIST,this.limit=0,this.i18n=x.ALL,this.categoryWidth=k.W25,this.measureScale=new X,this.measureUnit="",this.measureType=G.VOLUME,this.showMeasureScale=!0,this.filter="",this.barColumns=[],this.interval="none",this.categoryIntervalPosition=0,this.locale="de"}}class Jt{constructor(t,e,n,o,i,s){this.tableDrillGroupAdapter=t,this.stringAdapter=e,this.orderAdapter=n,this.db=o,this.fromExpr=i,this.onQueryError=s}adapt(t){const e=new Zt;return N.isString(t.title)&&(e.title=t.title),N.isArray(t.scenarios)&&(e.scenarios=j.adaptArray(t.scenarios,this.stringAdapter)),N.isExisting(t.scenariosUnitType)&&(e.scenariosUnitType=t.scenariosUnitType),N.isBoolean(t.grouped)&&(e.grouped=t.grouped),N.isBoolean(t.showGroupTitle)&&(e.showGroupTitle=t.showGroupTitle),N.isBoolean(t.runningSum)&&(e.runningSum=t.runningSum),N.isBoolean(t.varianceWaterfall)&&(e.varianceWaterfall=t.varianceWaterfall),t.thereOfPosition===h.ABOVE&&(e.thereOfPosition=h.ABOVE),N.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),N.isArray(t.thereOf)&&(e.thereOf=j.adaptArray(t.thereOf,this.tableDrillGroupAdapter)),N.isExisting(t.categoryThereOf)&&(e.categoryThereOf=t.categoryThereOf),N.isArray(t.partOf)&&(e.partOf=j.adaptArray(t.partOf,this.tableDrillGroupAdapter)),N.isArray(t.attributes)&&(e.attributes=t.attributes),N.isExisting(t.order)&&(e.sortOrder=this.orderAdapter.adapt(t.order)),N.isExisting(t.type)&&(e.type=t.type),N.isNumber(t.limit)&&(e.limit=t.limit),N.isExisting(t.i18n)&&(e.i18n=t.i18n),N.isExisting(t.categoryWidth)&&(e.categoryWidth=t.categoryWidth),N.isExisting(t.measureScale)&&(e.measureScale=H.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale,this.onQueryError)),N.isExisting(t.measureType)&&(e.measureType=t.measureType),N.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),N.isString(t.filter)&&(e.filter=t.filter.trim()),N.isArray(t.barColumns)&&(e.barColumns=t.barColumns),N.isString(t.interval)&&(e.interval=t.interval),N.isNumber(t.categoryIntervalPosition)&&(e.categoryIntervalPosition=t.categoryIntervalPosition),N.isString(t.locale)&&(e.locale=t.locale),e}default(){return new Zt}}class te{constructor(){this.rowGroup="",this.category="",this.subCategory="",this.partOf=""}}class ee{constructor(){}adapt(t){const e=new te;return N.isString(t.rowGroup)&&(e.rowGroup=t.rowGroup),N.isString(t.category)&&(e.category=t.category),N.isString(t.subCategory)&&(e.subCategory=t.subCategory),N.isString(t.partOf)&&(e.partOf=t.partOf),e}default(){return new te}}const ne=e(class extends n{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.sumTitle="SUM_TOTAL",this.scenarios=[],this.scenariosDataFormat=_.DECIMAL,this.grouped=!1,this.limit=0,this.showGroupTitle=!0,this.runningSum=!1,this.varianceWaterfall=!1,this.thereof=[],this.thereofPosition=h.BELOW,this.partof=[],this.order={hierarchy:[],direction:c.ASC},this.categorythereof=new Map,this.attributeColumns=[],this.type=l.LIST,this.categoryWidth=k.INF,this.dataFormatDigits={percent:2,decimal:1},this.i18n=new Map,this.i18nMode=x.ALL,this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.measureType=G.VOLUME,this.filter="",this.barColumns=[],this.interval="none",this.categoryIntervalPosition=0,this.barColumnMaxWidth=30,this.unitScaling=.01,this.percentageScaling=.5,this.scaleFactor=1,this.componentDataFormatDigits=new I,this.blockStarts=new Set,this.barColumnLayouts=new Map,this.waterfallGeometries=new Map,this.relayout=()=>{(this.barColumnLayouts.size>0||this.waterfallGeometries.size>0)&&o(this)},L(this),this.componentStyle=V(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 n,o,i;const s={regions:[],metadata:{},diagnostics:[]},r=null===(n=this.element.shadowRoot)||void 0===n?void 0:n.querySelector("table");if(s.metadata.hasNoData=null===(i=null===(o=this.table)||void 0===o?void 0:o.hasNoData())||void 0===i||i,!this.table||!r)return s;const l=r.querySelector("thead"),a=r.querySelector("tbody");l&&s.regions.push({id:"header",rect:d(l,t)}),a&&s.regions.push({id:"body",rect:d(a,t)});const c=this.table.getHeader(),h=this.table.getBody(),u=this.table.getColumns();if(s.metadata.headerRowCount=c.length,s.metadata.rowCount=h.length,s.metadata.columnCount=u.length,s.metadata.cellCount=h.reduce(((t,e)=>t+e.getCells().length),0),"full"!==e)return s;const v=[],m=[],g=(e,n,o)=>{const i=o?Array.from(o.children).filter((t=>"tr"===t.localName)):[];n.forEach(((n,o)=>{const r=i[o];if(!r)return;v.push({section:e,index:o,type:n.type,rect:d(r,t),point:$(r)});const l=n.getCells(),a=Array.from(r.children);l.length===a.length?l.forEach(((n,i)=>{var s,r;const l=a[i],c={kind:"header"===e?"headerCell":"cell",row:o,column:n.index,key:n.key||void 0,colSpan:n.colSpan,value:null!==(s=n.value)&&void 0!==s?s:void 0,text:(null===(r=l.textContent)||void 0===r?void 0:r.trim())||void 0,type:n.type||void 0,rect:d(l,t),point:$(l)};c.point&&(c.content=f(l,t),c.contentSign=p(l)||void 0);const h=l.querySelector("svg.cell-bar-chart");h&&(c.bar={variant:h.classList.contains("waterfall-bar")?"waterfall":h.classList.contains("relative-variance")?"relative":"absolute",rect:d(h,t)}),m.push(c)})):s.diagnostics.push({id:`WARN_layout_cell_pairing_${e}_${o}`,type:"warning",message:`layout-state: model/DOM cell count mismatch in ${e} row ${o} (${l.length} vs ${a.length}); cell details skipped for this row.`})}))};return g("header",c,l),g("body",h,a),s.elements=m,s.table={rows:v,columns:u.map(((t,e)=>({index:e,key:t.name,group:t.group,type:t.type,bucket:t.bucket})))},s}render(){var e;return t(i,{class:{"no-data":!0===(null===(e=this.table)||void 0===e?void 0:e.hasNoData())}},(()=>{var e,n,o,i;if(void 0===this.table)return;if(this.table.hasNoData()){const n=null!==(e=this.i18n.get("no-data"))&&void 0!==e?e:"No Data";return t("div",{class:"empty-state"},n)}const s=null===(i=null===(o=null===(n=this.stores)||void 0===n?void 0:n.context)||void 0===o?void 0:o.state)||void 0===i?void 0:i.locale;return t("table",{class:{"grouped-list":this.groupedList()},style:{"--bn-block-gap":.6*this.emPx()+"px"}},t("thead",null,this.table.getHeader().map((e=>t("tr",{class:e.cssStyle},e.getCells().map(((e,n,o)=>t("th",{colSpan:e.colSpan,class:`${e.cssStyle}${this.isBarColumn(e.key)?" barColumn":""}${this.blockStartClass(o,n)}`},e.getAsHeaderList().map(((n,o,i)=>t("span",null,o===i.length-1?t("span",{class:" "===n?"table-footer":""},n,e.drawPrefix()," "):t("span",null,n,e.drawPrefix(),t("br",null)))))))))))),t("tbody",null,this.table.getBody().map((e=>t("tr",Object.assign({class:e.cssStyle},g(e.key,"element")),null==e?void 0:e.getCells().map(((n,o,i)=>{var l,a,c,h,u;return t("td",Object.assign({colSpan:n.colSpan,class:(n.type?`${this.cellClass(n,s)} ${n.type}`:n.cssStyle)+this.blockStartClass(i,o)},e.key&&null!=n.value&&""!==n.value&&"-"!==n.value?g(Object.assign(Object.assign({},e.key),{date:n.date,scenario:n.key}),"element"):{}),null!=n.prefix?t("span",{class:this.cellClass(n,s)+" "+n.prefixStyle},n.drawPrefix()):"",!n.isBarChart||!n.columnStats||n.value===U||!this.showGroupTitle&&e.type===r.HEADER||void 0===n.waterfall&&e.type===r.SUM||void 0!==n.direction&&n.waterfall&&n.waterfall.max===n.waterfall.min?n.draw(this.componentDataFormatDigits,s):void 0!==n.waterfall?t(Wt,{value:n.value,scenario:n.key,columnStats:n.columnStats,height:18*this.scaleFactor,isRelative:!1,isPositiveGood:"pos"===n.direction,measureScale:ie(n),locale:s,decimalDigits:se(n,this.componentDataFormatDigits),columnWidthEm:this.barColumnMaxWidth,styles:this.barChartStyles,waterfall:n.waterfall,geometry:this.waterfallGeometries.get(n.key),bold:oe(e),connectorReach:this.connectorReach(e)}):t(Pt,{value:n.value,scenario:n.key,columnStats:n.columnStats,height:18*this.scaleFactor,isRelative:n.key.startsWith("dr"),isPositiveGood:"pos"===n.direction,measureScale:ie(n),locale:s,decimalDigits:se(n,this.componentDataFormatDigits),percentDigits:null!==(a=null===(l=this.barColumnLayouts.get(n.key))||void 0===l?void 0:l.percentDigits)&&void 0!==a?a:this.componentDataFormatDigits.percent,percentSign:null===(c=this.barColumnLayouts.get(n.key))||void 0===c?void 0:c.percentSign,columnWidthEm:this.barColumnMaxWidth,labelWidths:null===(h=this.barColumnLayouts.get(n.key))||void 0===h?void 0:h.labels,sideMax:null===(u=this.barColumnLayouts.get(n.key))||void 0===u?void 0:u.sideMax,bold:oe(e),styles:this.barChartStyles}))})))))))})())}componentWillRender(){var t,e,n,o,i,s,r,l,a,c,h;this.stores||(this.stores=F(this.element));const u=this.stores.db.db;this.componentDataFormatDigits=(new Y).adapt(this.dataFormatDigits);try{const e=this.prepareConfig(u);this.table=new qt(new E(this.ruleSetConfig),u,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===(n=this.table)||void 0===n?void 0:n.hasBlankRowGroup())?null===(o=this.errors)||void 0===o||o.addOrReplace({id:"WARN_blankRowGroup",type:"warning",message:"grouped: rows with blank rowGroup found, they are grouped under '-'."}):null===(i=this.errors)||void 0===i||i.remove("WARN_blankRowGroup");const d=null===(s=this.table)||void 0===s?void 0:s.orderBucketWarning();d?null===(r=this.errors)||void 0===r||r.addOrReplace({id:"WARN_orderBucket",type:"warning",message:d}):null===(l=this.errors)||void 0===l||l.remove("WARN_orderBucket");const f=null===(a=this.table)||void 0===a?void 0:a.categoryIntervalPositionWarning();for(const t of["WARN_categoryIntervalPositionNoInterval","WARN_categoryIntervalPositionRange"])(null==f?void 0:f.id)===t?null===(c=this.errors)||void 0===c||c.addOrReplace({id:t,type:"warning",message:f.message}):null===(h=this.errors)||void 0===h||h.remove(t);this.blockStarts=this.collectBlockStarts(),this.barColumnLayouts=this.collectBarColumnLayouts(),this.waterfallGeometries=this.collectWaterfallGeometries(),this.barChartStyles=this.prepareBarChartStyles()}collectBlockStarts(){const t=new Set;if(!this.table||this.table.hasNoData())return t;const e=this.table.getColumns().map((t=>{var e;const n=new w(t.type),o=n.isValid?`${n.base}_${n.delta}`:/^(ac|pp|fc|pl)\d/i.test(t.type)?"scenario":"rowheader";return`${null!==(e=t.bucket)&&void 0!==e?e:""}|${o}`}));return e.forEach(((n,o)=>{o>0&&n!==e[o-1]&&t.add(o)})),t}blockStartClass(t,e){let n=0;for(let o=0;o<e;o++)n+=t[o].colSpan;return this.blockStarts.has(n)?" block-start":""}groupedList(){return!0===this.grouped&&this.type!==l.OPT&&this.type!==l.OPTNOTOTAL}isBarColumn(t){return this.barColumns.includes(t)}cellClass(t,e){return void 0!==t.direction&&t.roundsToZero(this.componentDataFormatDigits,e)?t.cssStyle.replace(/^(pos|neg)_\w+/,"zero"):t.cssStyle}prepareConfig(t){var e,n,o;const i=B(t,this.tableName,this.filter);return new Jt(new ee,new z,new D(new z,!0),t,i,(t=>{throw t})).adapt({title:this.sumTitle,scenarios:this.scenarios,scenariosUnitType:this.scenariosDataFormat,grouped:this.grouped,showGroupTitle:this.showGroupTitle,runningSum:this.runningSum,varianceWaterfall:this.varianceWaterfall,thereOf:this.thereof,thereOfPosition:this.thereofPosition,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,categoryIntervalPosition:this.categoryIntervalPosition,locale:(null===(o=null===(n=null===(e=this.stores)||void 0===e?void 0:e.context)||void 0===n?void 0:n.state)||void 0===o?void 0:o.locale)||"de"})}prepareBarChartStyles(){var t;const e=!(this.unitScaling>0),n=!(this.percentageScaling>0),o=e?this.autoUnitScaling():this.unitScaling,i=n?this.autoPercentageScaling():this.percentageScaling;return(e||n)&&(null===(t=this.reportAutoScaling)||void 0===t||t.call(this,{unit:e?o:void 0,percentage:n?i:void 0})),this.componentStyle((t=>{var e,n,s,r,l,a,c,h,u,d,f,p,v,$,g,b,w,y,S,R,O,_,x,N,k,G;const U=null===(e=t["bn-chart-time"])||void 0===e?void 0:e.varianceStyles,C=null===(n=t["bn-chart-time"])||void 0===n?void 0:n.barStyles;return{positive:{stroke:(null===(s=null==U?void 0:U.pos)||void 0===s?void 0:s.stroke)||"#008f96",fill:(null===(r=null==U?void 0:U.pos)||void 0===r?void 0:r.fill)||"#008f96",fillpattern:m(null===(l=null==U?void 0:U.pos)||void 0===l?void 0:l.fillpattern)||"solid"},negative:{stroke:(null===(a=null==U?void 0:U.neg)||void 0===a?void 0:a.stroke)||"#ff0000",fill:(null===(c=null==U?void 0:U.neg)||void 0===c?void 0:c.fill)||"#ff0000",fillpattern:m(null===(h=null==U?void 0:U.neg)||void 0===h?void 0:h.fillpattern)||"solid"},neutral:{stroke:(null===(u=null==U?void 0:U.neu)||void 0===u?void 0:u.stroke)||"#808080",fill:(null===(d=null==U?void 0:U.neu)||void 0===d?void 0:d.fill)||"#808080",fillpattern:m(null===(f=null==U?void 0:U.neu)||void 0===f?void 0:f.fillpattern)||"outlined"},scenarios:M({ac:{stroke:(null===(p=null==C?void 0:C.ac)||void 0===p?void 0:p.stroke)||"#404040",fill:(null===(v=null==C?void 0:C.ac)||void 0===v?void 0:v.fill)||"#404040",fillpattern:m(null===($=null==C?void 0:C.ac)||void 0===$?void 0:$.fillpattern)||"solid"},pp:{stroke:(null===(g=null==C?void 0:C.pp)||void 0===g?void 0:g.stroke)||"#A6A6A6",fill:(null===(b=null==C?void 0:C.pp)||void 0===b?void 0:b.fill)||"#A6A6A6",fillpattern:m(null===(w=null==C?void 0:C.pp)||void 0===w?void 0:w.fillpattern)||"solid"},fc:{stroke:(null===(y=null==C?void 0:C.fc)||void 0===y?void 0:y.stroke)||"#404040",fill:(null===(S=null==C?void 0:C.fc)||void 0===S?void 0:S.fill)||"#ffffff",fillpattern:m(null===(R=null==C?void 0:C.fc)||void 0===R?void 0:R.fillpattern)||"hatched"},pl:{stroke:(null===(O=null==C?void 0:C.pl)||void 0===O?void 0:O.stroke)||"#404040",fill:(null===(_=null==C?void 0:C.pl)||void 0===_?void 0:_.fill)||"#ffffff",fillpattern:m(null===(x=null==C?void 0:C.pl)||void 0===x?void 0:x.fillpattern)||"outlined"}},new E(this.ruleSetConfig)),fontColor:(null===(N=t.global)||void 0===N?void 0:N.fontColor)||"#000000",fontSize:((null===(k=t.global)||void 0===k?void 0:k.fontSizePx)||13.3333)*it*this.scaleFactor,emPx:((null===(G=t.global)||void 0===G?void 0:G.fontSizePx)||13.3333)*this.scaleFactor,fontFamily:this.labelFontFamily(),unitScaling:o,percentageScaling:i,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(),n=e*it;let o=1/0;for(const{isRelative:i,absMax:s,labels:r,sideMax:l}of this.barColumnLayouts.values()){if(i||s<=0)continue;const a=mt(this.barColumnMaxWidth,e,r,l);for(const e of["neg","pos"]){const i=null!==(t=l[e])&&void 0!==t?t:0;if(i<=0)continue;const{maxBarWidth:s,cutWidth:r}=a[e];o=Math.min(o,Math.min(.8*s,r)/(i*n))}}return Number.isFinite(o)&&n>0?o:.01}autoPercentageScaling(){var t,e;const n=this.emPx(),o=n*it;let i=1/0;for(const{isRelative:s,absMax:r,labels:l,sideMax:a}of this.barColumnLayouts.values()){if(!s||r<=0)continue;const c=8*this.scaleFactor,{negPinLength:h,posPinLength:u}=$t(this.barColumnMaxWidth,n,l,c),d=100*((null!==(t=a.neg)&&void 0!==t?t:0)+(null!==(e=a.pos)&&void 0!==e?e:0));i=Math.min(i,(h+u)/(d*o))}return Number.isFinite(i)&&o>0?i:.5}collectBarColumnLayouts(){var t,e,n,o;const i=new Map;if(!this.table||this.table.hasNoData())return i;const s=new Map;for(const e of this.table.getBody())if(e.type!==r.SUM)for(const n of e.getCells())n.isBarChart&&n.columnStats&&void 0===n.waterfall&&("number"!=typeof n.value||isNaN(n.value)||s.set(n.key,[...null!==(t=s.get(n.key))&&void 0!==t?t:[],{cell:n,bold:oe(e)}]));const l=this.emPx(),a=l*it,c=8*this.scaleFactor,h=null===(o=null===(n=null===(e=this.stores)||void 0===e?void 0:e.context)||void 0===n?void 0:n.state)||void 0===o?void 0:o.locale,u=this.labelFontFamily();for(const[t,e]of s){const n=t.startsWith("dr"),o=e.map((({cell:t})=>t.value)),s=(t,i)=>{var s;const r={neg:o.some((t=>t<0))?0:void 0,pos:o.some((t=>t>0))?0:void 0},l=Nt(r);for(const{cell:o,bold:c}of e){const e=o.value,d=e>0||0===e&&l?"pos":"neg",f=Et(e,n,ie(o),h,t,i,se(o,this.componentDataFormatDigits));r[d]=Math.max(null!==(s=r[d])&&void 0!==s?s:0,ht(f,a,u,n,c))}return r};let r=Math.min(20,Math.max(0,Math.trunc(this.componentDataFormatDigits.percent)||0)),d=!0,f=s(r,d);for(;n&&(r>0||d)&&!pt(this.barColumnMaxWidth,l,f,c);)r>0?r--:d=!1,f=s(r,d);const p=Math.max(...o.map(Math.abs))*(n?100:1),v={neg:void 0===f.neg?void 0:Math.max(0,...o.map((t=>-t))),pos:void 0===f.pos?void 0:Math.max(0,...o)};i.set(t,{isRelative:n,absMax:p,labels:f,sideMax:v,percentDigits:r,percentSign:d})}return i}connectorReach(t){const e=this.emPx(),n=this.groupedList()?1:.5;return{top:.1*e,bottom:t.type===r.SUM?n*e:0}}collectWaterfallGeometries(){var t,e,n,o;const i=new Map;if(!this.table||this.table.hasNoData())return i;const s=this.emPx(),r=s*it,l=null===(n=null===(e=null===(t=this.stores)||void 0===t?void 0:t.context)||void 0===e?void 0:e.state)||void 0===n?void 0:n.locale,a=this.labelFontFamily(),c=new Map;for(const t of this.table.getBody())for(const e of t.getCells()){if(!e.isBarChart||!e.columnStats||void 0===e.waterfall)continue;if("number"!=typeof e.value||isNaN(e.value))continue;const{start:n,end:i,min:s,max:h,kind:u}=e.waterfall,d=At(e.value,u,ie(e),l,se(e,this.componentDataFormatDigits),void 0!==e.direction),f=null!==(o=c.get(e.key))&&void 0!==o?o:{min:s,max:h,labels:[]};f.labels.push({end:i,pointsLeft:i<n,width:ht(d,r,a,!1,oe(t))}),c.set(e.key,f)}for(const[t,e]of c)i.set(t,gt(this.barColumnMaxWidth,s,e));return i}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,td.zero{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}tr.partof td.percentpoint{font-style:italic}tr.partof td.percentpoint:after{content:"%p"}th.share,tr.share,td.share{font-size:0.6em;font-style:italic}th.barColumn{text-align:center}td.block-start,th.block-start{border-left:var(--bn-block-gap, 0) solid transparent;clip-path:inset(-100em -100em -100em var(--bn-block-gap, 0))}.category-w100.block-start{min-width:calc(100em + var(--bn-block-gap, 0px));max-width:calc(100em + var(--bn-block-gap, 0px))}.category-w50.block-start{min-width:calc(50em + var(--bn-block-gap, 0px));max-width:calc(50em + var(--bn-block-gap, 0px))}.category-w25.block-start{min-width:calc(25em + var(--bn-block-gap, 0px));max-width:calc(25em + var(--bn-block-gap, 0px))}.category-w20.block-start{min-width:calc(20em + var(--bn-block-gap, 0px));max-width:calc(20em + var(--bn-block-gap, 0px))}.category-w15.block-start{min-width:calc(15em + var(--bn-block-gap, 0px));max-width:calc(15em + var(--bn-block-gap, 0px))}.category-w10.block-start{min-width:calc(10em + var(--bn-block-gap, 0px));max-width:calc(10em + var(--bn-block-gap, 0px))}.category-w5.block-start{min-width:calc(5em + var(--bn-block-gap, 0px));max-width:calc(5em + var(--bn-block-gap, 0px))}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}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}table.grouped-list tr.sum td{padding-bottom:1em}tr.ofit-above td[class^=category]{padding-left:1em}tr.ofit-sum td{border-top:0.1em solid black;font-weight:bold}tr.sum td.pos_pos,tr.sum td.pos_neg,tr.sum td.neg_pos,tr.sum td.neg_neg,tr.ofit-sum td.pos_pos,tr.ofit-sum td.pos_neg,tr.ofit-sum td.neg_pos,tr.ofit-sum td.neg_neg{color:inherit}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 solid #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(.variance-waterfall){overflow:visible}td:has(.cell-bar-chart){padding:0 0.25em;vertical-align:middle}tr.ofit td:has(.cell-bar-chart),tr.partof td:has(.cell-bar-chart),tr.share td:has(.cell-bar-chart){padding:0 0.4166666667em}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"],runningSum:[4,"running-sum"],varianceWaterfall:[4,"variance-waterfall"],thereof:[16],thereofPosition:[1,"thereof-position"],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],categoryIntervalPosition:[2,"category-interval-position"],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 oe(t){return t.type===r.SUM||"ofit-sum"===t.cssStyle}function ie(t){return"percentpoint"===t.type?.01:t.measureScale}function se(t,e){return"percentpoint"===t.type?e.percent:"decimal"===t.type?e.decimal:void 0}function re(){"undefined"!=typeof customElements&&["bn-table-renderer"].forEach((t=>{"bn-table-renderer"===t&&(customElements.get(s(t))||customElements.define(s(t),ne))}))}export{ne as B,Q as I,K as a,Z as c,re as d}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{p as t,H as s,h as e,t as i}from"./p-BnmylmXF.js";import{I as n,C as r}from"./p-DguYWLBj.js";import{b as o,D as a,a as c}from"./p-ja0FCkHB.js";import{F as h,I as l}from"./p-CmvpJzLd.js";import{A as p}from"./p-DsC0ew4j.js";import{D as u,w as d}from"./p-BrQCbmG0.js";import{a as f,c as m}from"./p-BBdzTx8V.js";import{S as b}from"./p-Do-IGHJk.js";import{s as w}from"./p-CyUmrWfW.js";class _{constructor(){}createMeasures(t,s,e){if(this.allMeasuresUseSameUnit(t)){const i=t.length;let r="",o="";for(let a=0;a<i;a++){let c="";a>0&&(c=s.get("SEPARATOR_WS")),i>1&&a===i-1&&(c=s.get("CONNECTOR_WS")),e===n.ALL?(r=(s.get(r)||r)+c+(s.get(t[a].name)||t[a].name),o=s.get(t[a].unit)||t[a].unit):(r=r+c+t[a].name,o=t[a].unit)}return[{name:r,unit:o}]}return t}createDimension(t,s,e,i,n,r="de"){let a="";if(void 0!==s){const t=new o;t.setLocale(r),a=t.getDateLinkString(s.start,s.end,s.link,s.format,n)}return a+t.map((t=>{let s="";return null!=e&&null!=e.hierarchy&&e.hierarchy.find((s=>s===t))&&(s=i.get("asc"===e.direction?"ORDER_asc":"ORDER_desc")),"".concat(" ",h.translateScenarioLabel(t,i),s)})).toString()}allMeasuresUseSameUnit(t){const s=new Map;return t.forEach((function(t){s.set(t.unit,!0)})),1===s.size}}class C{constructor(){this.businessunit="",this.measures=[],this.scenarios=[],this.i18nMode=n.ALL,this.intervalSpanLimit=32,this.locale="de"}}class v{constructor(t,s,e,i){this.measureEntryAdapter=t,this.timePeriodAdapter=s,this.orderAdapter=e,this.stringAdapter=i}adapt(t){const s=new C;return r.isString(t.businessunit)&&(s.businessunit=t.businessunit),r.isArray(t.measures)&&(s.measures=p.adaptArray(t.measures,this.measureEntryAdapter)),r.isArray(t.scenarios)&&(s.scenarios=p.adaptArray(t.scenarios,this.stringAdapter)),r.isExisting(t.timeperiod)&&(s.timeperiod=this.timePeriodAdapter.adapt(t.timeperiod)),r.isNumber(t.intervalSpanLimit)&&(s.intervalSpanLimit=t.intervalSpanLimit),r.isExisting(t.i18nMode)&&(s.i18nMode=t.i18nMode),r.isExisting(t.order)&&(s.order=this.orderAdapter.adapt(t.order)),r.isString(t.locale)&&(s.locale=t.locale),s}default(){return new C}}var R;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(R||(R={}));class y{constructor(t){this.i18n=new Map,this.unit="",this.measures=[],this.dimension="",this.config=new C,this.state=R.DIRTY,this.ruleSet=t||new l,this.dataSetFactory=new _,this.state=R.DIRTY,this.setI18n(new Map)}setRuleSet(t){this.ruleSet=t||new l}setI18n(t){this.state=R.DIRTY;const s=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","❖"],["CONNECTOR_WS"," und "]]);this.i18n=new Map([...s,...t||new Map])}update(){return R.DIRTY===this.state&&(this.unit=this.config.businessunit,this.measures=this.dataSetFactory.createMeasures(this.config.measures,this.i18n,this.config.i18nMode),this.dimension=this.dataSetFactory.createDimension(this.config.scenarios,this.config.timeperiod,this.config.order,this.i18n,this.config.intervalSpanLimit,this.config.locale),this.state=R.UP_TO_DATE),this}setConfig(t){this.config=this.initConfig(t)}initConfig(t){this.state=R.DIRTY;const s=t,e=this;return t.scenarios.sort(((t,s)=>e.ruleSet.getScenarioSorIndex(t)-e.ruleSet.getScenarioSorIndex(s))),s}}class S{constructor(t="",s=""){this.name=t,this.unit=s}}class E{construnctor(){}adapt(t){const s=new S;return r.isString(t.name)&&(s.name=t.name),r.isString(t.unit)&&(s.unit=t.unit),s}default(){return new S("","")}}class g{constructor(t=u.now(),s=u.now(),e=a.AUTO,i=c.AUTO){this.start=t,this.end=s,this.format=e,this.link=i}}class A{construnctor(){}adapt(t){const s=new g;return r.isDate(t.start)&&(s.start=t.start),r.isDate(t.end)&&(s.end=t.end),r.isExisting(t.format)&&(s.format=t.format),r.isExisting(t.link)&&(s.link=t.link),s}default(){return new g}}const M=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.businessUnit="",this.scenarios=[],this.measures=[],this.intervalSpanLimit=28,this.order={hierarchy:[],direction:f.ASC},this.i18n=new Map,this.i18nMode=n.ALL,this.locale="de",this.title=new y(new l),d(this)}render(){return e("div",{key:"ecc33a660538732ceea3e4620afabfcb8ffbce95"},e("div",{key:"cb1c3b074817a4c0647419fdc0f2b94c113ebc09",innerHTML:w(this.title.unit)}),e("div",{key:"92b6ef66f67d33bd3bff6a760d1fc1bee605105d"},this.title.measures.map(((t,s)=>e("span",null,this.isFirstElement(s)?this.title.i18n.get("SEPARATOR_WS"):"",e("span",{class:"measure"},t.name)," ",t.unit?this.title.i18n.get("in"):""," ",t.unit)))),e("div",{key:"74cc33e0e63592e5422b3c0e5c7a52715210c486"},this.title.dimension))}componentWillLoad(){const t=this.prepareConfig();this.title=new y(new l(this.ruleSetConfig)),this.title.setI18n(this.i18n),this.title.setConfig(t)}componentWillUpdate(){const t=this.prepareConfig();this.title.setI18n(this.i18n),this.title.setRuleSet(new l(this.ruleSetConfig)),this.title.setConfig(t)}componentWillRender(){this.title.update()}isFirstElement(t){return 0!==t}prepareConfig(){return new v(new E,new A,new m(new b),new b).adapt({businessunit:this.businessUnit,measures:this.measures,scenarios:this.scenarios,timeperiod:this.timeperiod,intervalSpanLimit:this.intervalSpanLimit,i18nMode:this.i18nMode,order:this.order,locale:this.locale})}static get style(){return':host{display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.measure{font-weight:bold}div{background-color:var(--bn-font-background, white);color:var(--bn-font-color, black)}p{margin:0}'}},[1,"bn-title-renderer",{businessUnit:[1537,"business-unit"],scenarios:[16],measures:[16],timeperiod:[16],intervalSpanLimit:[2,"interval-span-limit"],order:[16],i18n:[1040],i18nMode:[1,"i18n-mode"],locale:[1],ruleSetConfig:[16]}]);function O(){"undefined"!=typeof customElements&&["bn-title-renderer"].forEach((t=>{"bn-title-renderer"===t&&(customElements.get(i(t))||customElements.define(i(t),M))}))}export{M as B,O as d}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{p as t,H as i,h as s,d as h,t as e}from"./p-BnmylmXF.js";import{S as n,F as r,a as o,P as a}from"./p-CSJCkHEL.js";import{C as l,A as c,g as u,e as d}from"./p-DguYWLBj.js";import{D as f,b as p}from"./p-keKnrAVS.js";import{c as v,O as g,a as b}from"./p-BBdzTx8V.js";import{S as m}from"./p-CeE4_3wQ.js";import{a as w,F as P,I as y,C as S,b as x,V as L,s as k}from"./p-CmvpJzLd.js";import{g as C,a as M,I as T}from"./p-4q8nRcWC.js";import{d as O,l as $,S as A}from"./p-DHX92KDP.js";import{N,r as _}from"./p-fCjsrD7I.js";import{s as E,c as D,a as W,l as B,b as R,d as j,M as X}from"./p-BTnRaHPb.js";import{d as V,g as Y}from"./p-6242qMx1.js";import{e as z,r as F}from"./p-ClruFZD_.js";import{S as H}from"./p-Do-IGHJk.js";import{w as G}from"./p-BrQCbmG0.js";import{S as U}from"./p-CJ0-xdfZ.js";import{A as I}from"./p-DsC0ew4j.js";class K{constructor(t,i,s,h,e,n,r,o,a=!1){this.categoryPosition={x:0,y:0},this.spacings={scenarioOffset:0,markerOffset:0,scenarioLabelToBar:0,labelToBar:0,labelToAxis:0,needleWidth:0,needleHeadWidth:0,barWidth:0,varianceAxisLineWidth:0,axisLineWidth:0,auxiliaryLineWidth:0,scenarioLineWidth:0,markerWidth:0,categoryWidth:0,axisTickLength:0},this.categoriesBoxOffset={width:0,height:0},this.padding=t,this.scaleFactors=i,this.fontSize=s,this.axisPosition={x:0,y:0},this.numberOfColumns=h,this.leftSideLengthSync=e,this.topSideLabelHeight=n>0?this.fontSize:0,this.hasStackedHeaders=a,this.leftSideLabelLength=this.calculateSideLabelLength(n,r,o),this.calculateSpacings(),this.calculateCategoryPosition(),this.calculateAxisPosition()}getBarPositionX(){return this.axisPosition.x}getBarCenterPositionY(t){return this.categoryPosition.y+this.spacings.scenarioOffset+t*this.spacings.categoryWidth}getBarPositionY(t,i){return i?this.getBarCenterPositionY(t):this.getBarCenterPositionY(t)-this.spacings.scenarioOffset}getCategoryPositionX(t){let i=this.spacings.labelToAxis;return t&&(i=-this.spacings.labelToAxis),this.getAxisPositionX()+i}getAxisTitlePositionX(){return this.axisPosition.x}getAxisTitlePositionY(){return this.axisPosition.y-this.spacings.labelToAxis-this.getTopLabelOverhang()}getStackedHeaderPositionY(){return this.getBarCenterPositionY(0)-.5*this.spacings.barWidth-this.spacings.scenarioLabelToBar}getNeedleWidth(){return this.spacings.needleWidth}getAxisPositionX(){return this.leftSideLabelLength+this.padding.left+this.spacings.labelToAxis}getAxisPositionY(){return this.padding.top+this.getAxisTitleOffset()}loadCategoriesBox(t){this.categoriesBoxOffset=t,this.calculateAxisPosition()}addOffsetByNegativeDataPoints(t,i,s,h){null!=t&&null!=t.value&&t.value<0&&(s&&t.isClipped()?this.axisPosition.x+=Math.abs(t.getClippedValue()*t.pixelPerUnit):this.axisPosition.x+=Math.abs(t.value*t.pixelPerUnit),this.axisPosition.x+=i,this.axisPosition.x+=this.spacings.labelToBar),this.axisPosition.x<h/2&&(this.axisPosition.x=h/2+this.spacings.labelToBar)}getLabelPositionX(t){let i=this.spacings.labelToBar;return t<0&&(i*=-1),this.axisPosition.x+t+i}getLabelPositionY(t){return this.axisPosition.y+t+this.spacings.labelToBar}getCategoryToAxisSpaceing(){return this.spacings.labelToAxis}getCategoryToTopSpaceing(){return this.spacings.scenarioOffset}getCategoryToBottomSpaceing(){return this.spacings.scenarioOffset}getAxisEndPositionY(){return this.getAxisPositionY()+(this.numberOfColumns+.5)*this.spacings.categoryWidth}getScenarioLabelPositionOffsetY(t){if(t){const t=.5*this.getBarWidth()+this.spacings.scenarioLabelToBar;return Math.max(t,this.spacings.categoryWidth-this.spacings.scenarioOffset+this.spacings.labelToAxis)}return-(.5*this.getBarWidth()+this.spacings.scenarioLabelToBar)}getBarWidth(){return this.spacings.barWidth}getMarkerPositionY(t,i){return i?this.getBarCenterPositionY(t)-this.spacings.markerOffset-.5*this.getBarWidth():this.getBarCenterPositionY(t)+this.spacings.markerOffset+.5*this.getBarWidth()}getMarkerPositionX(){return this.getBarPositionX()}getMarkerScenarioLabelPositionOffsetY(t){return t?-(.5*this.spacings.markerWidth+this.spacings.scenarioLabelToBar):this.spacings.scenarioLabelToBar+.5*this.spacings.markerWidth}getAxisEndPositionX(){return this.getAxisPositionX()}calculateSpacings(){this.spacings={scenarioOffset:this.fontSize*this.scaleFactors.scenarioOffset,markerOffset:this.fontSize*this.scaleFactors.markerOffset,scenarioLabelToBar:this.fontSize*this.scaleFactors.scenarioLabelToBar,labelToBar:this.fontSize*this.scaleFactors.labelToBar,labelToAxis:this.fontSize*this.scaleFactors.labelToAxis,needleWidth:this.fontSize*this.scaleFactors.needleWidth,needleHeadWidth:this.fontSize*this.scaleFactors.needleHeadWidth,barWidth:this.fontSize*this.scaleFactors.barWidth,varianceAxisLineWidth:this.fontSize*this.scaleFactors.varianceAxisLineWidth,axisLineWidth:this.fontSize*this.scaleFactors.axisLineWidth,auxiliaryLineWidth:this.fontSize*this.scaleFactors.auxiliaryLineWidth,scenarioLineWidth:this.fontSize*this.scaleFactors.scenarioLineWidth,markerWidth:this.fontSize*this.scaleFactors.markerWidth,categoryWidth:this.fontSize*this.scaleFactors.categoryWidth,axisTickLength:this.fontSize*this.scaleFactors.axisTickLength}}calculateCategoryPosition(){this.categoryPosition={x:this.padding.left,y:this.getAxisPositionY()+.5*this.spacings.categoryWidth}}calculateAxisPosition(){this.axisPosition={x:this.getAxisPositionX(),y:this.getAxisPositionY()}}recalculatePositions(){this.calculateCategoryPosition(),this.calculateAxisPosition()}getAxisTitleOffset(){return this.topSideLabelHeight+this.spacings.labelToAxis+this.getTopLabelOverhang()}getTopLabelOverhang(){return this.hasStackedHeaders?this.getStackedHeaderOverhang():this.getTopScenarioLabelOverhang()}getStackedHeaderOverhang(){return Math.max(0,this.fontSize+this.spacings.scenarioLabelToBar+.5*this.spacings.barWidth-(.5*this.spacings.categoryWidth+this.spacings.scenarioOffset))}getTopScenarioLabelOverhang(){return Math.max(0,this.fontSize+.5*this.spacings.barWidth+this.spacings.scenarioLabelToBar-.5*this.spacings.categoryWidth,this.fontSize+.5*this.spacings.markerWidth+this.spacings.scenarioLabelToBar+this.spacings.markerOffset+.5*this.spacings.barWidth-(.5*this.spacings.categoryWidth+this.spacings.scenarioOffset))}calculateSideLabelLength(t,i,s){if(this.leftSideLengthSync)return this.leftSideLengthSync;const h=t/2;let e=i;return h>e&&(e=h),s>e&&(e=s),e}}class Q{constructor(t){this.top=t.top,this.bottom=t.bottom,this.left=t.left,this.right=t.right}addBoxTopLeft(t){return this.top+=t.height|this.top,this.left+=t.width|this.top,this}}class Z{constructor(t){const i=1*t,s=.7*t;this.bgOffset=(i-s)/2,this.markerUp={top:s/2+",0",left:"0,"+s,right:s+","+s},this.markerUpBackground={top:i/2+",0",left:"0,"+i,right:i+","+i},this.markerDown={bottom:s/2+","+s,left:"0,0",right:s+",0"},this.markerDownBackground={bottom:i/2+","+i,left:"0,0",right:i+",0"}}upMarkerPatternStrings(){return{background:this.markerUpBackground.left+" "+this.markerUpBackground.right+" "+this.markerUpBackground.top+" "+this.markerUpBackground.left,foreground:this.markerUp.left+" "+this.markerUp.right+" "+this.markerUp.top+" "+this.markerUp.left,bgOffset:this.bgOffset}}downMarkerPatternStrings(){return{background:this.markerDownBackground.left+" "+this.markerDownBackground.right+" "+this.markerDownBackground.bottom+" "+this.markerDownBackground.left,foreground:this.markerDown.left+" "+this.markerDown.right+" "+this.markerDown.bottom+" "+this.markerDown.left,bgOffset:this.bgOffset}}createPatternMapForStructureBar(){const t=new Map;return t.set("marker-up",this.upMarkerPatternStrings()),t.set("marker-down",this.downMarkerPatternStrings()),t}}class q{constructor(t){this.container=new n,this.pattern=this.createFCPattern(this.container.group(),t),this.styles=t;let i=10;null!=t&&null!=t.fontStyles&&t.fontStyles.size&&(i=t.fontStyles.size),this.bgOffset=(1*i-.7*i)/2}createFCPattern(t,i){const s=i;return t.pattern(10,10,(function(t){t.rect(10,10).fill(s.barStyles.fc.fill),t.line(0,5,5,0).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"}),t.line(5,10,10,5).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"})})).id("pattern-structure-fc")}getFCPolygonPattern(){return{background:"",foreground:"",bgOffset:0,pattern:this.pattern}}toString(){return this.container.svg()}}var J,tt,it,st,ht;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(J||(J={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(tt||(tt={}));class et{constructor(t,i){this.data=t,this.scenarios=i,this.variances=[],this.title="",this.hideCategories=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.sortOrder=new v(new H).default(),this.level=c.CATEGORY,this.filter="",this.measureScale=new m,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.stackConfig=null}}class nt{constructor(t,i,s,h,e,n,r){this.dataRowAdapter=t,this.orderAdapter=i,this.stringAdapter=s,this.dataFormatDigitsAdapter=h,this.db=e,this.fromExpr=n,this.onQueryError=r}adapt(t){const i=I.adaptArray(t.data,this.dataRowAdapter),s=I.adaptArray(t.scenarios,this.stringAdapter),h=new et(i,s);return l.isArray(t.variances)&&(h.variances=I.adaptArray(t.variances,this.stringAdapter)),l.isString(t.title)&&(h.title=t.title),l.isBoolean(t.hideCategories)&&(h.hideCategories=t.hideCategories),l.isNumber(t.pixelPerUnit)&&(h.pixelPerUnit=t.pixelPerUnit),l.isNumber(t.pixelPerPercentage)&&(h.pixelPerPercentage=t.pixelPerPercentage),l.isNumber(t.limit)&&(h.limit=t.limit),l.isExisting(t.sortOrder)&&(h.sortOrder=this.orderAdapter.adapt(t.sortOrder)),l.isExisting(t.level)&&(h.level=t.level),l.isString(t.filter)&&(h.filter=t.filter.trim()),l.isExisting(t.measureScale)&&(h.measureScale=f.calculateMeasureScale(this.db,this.fromExpr,h.scenarios,t.measureScale,this.onQueryError)),l.isString(t.measureUnit)&&(h.measureUnit=t.measureUnit),l.isBoolean(t.showMeasureScale)&&(h.showMeasureScale=t.showMeasureScale),l.isExisting(t.dataFormatDigits)&&(h.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),l.isExisting(t.stackConfig)&&(h.stackConfig=t.stackConfig),h}default(){return new et([],[])}}class rt{constructor(t,i,s,h){this.value=t,this.scenario=i,this.pixelPerUnit=s||1;const e="string"==typeof h?w(h,null,!0):h;this.variance="neg"===e||e===it.NEG?it.NEG:"pos"===e||e===it.POS?it.POS:it.NEU}isEmpty(){return null==this.value||null==this.scenario}getScaledUnit(){return null==this.value?0:this.value*this.pixelPerUnit}getScaledPercentUnit(){return null==this.value?0:Math.abs(this.value)>1.45?this.value>=0?1.45*this.pixelPerUnit:-1.45*this.pixelPerUnit:this.value*this.pixelPerUnit}getVarianceStyle(){return null==this.value||this.value>=0?this.variance:it.NEU===this.variance?it.NEU:it.POS===this.variance?it.NEG:it.POS}isClipped(){return null!=this.value&&Math.abs(this.value)>1.45}getClippedValue(){return 145}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}class ot{constructor(){this.operation="+"}addRowGroup(t,i){this.rowGroup=t,this.rowGroupIndex=i}addCategory(t,i){this.category=t,this.categoryIndex=i}addSubCategory(t,i){this.subCategory=t,this.subCategoryIndex=i}addColumnGroup(t,i){this.columnGroup=t,this.columnGroupIndex=i}addSubColumnGroup(t,i){this.columnSubGroup=t,this.columnSubGroupIndex=i}}class at{constructor(){}adapt(t){const i=new ot;return l.isOperator(t.operation)&&(i.operation=t.operation),l.isNumber(t.rowGroupIndex)&&l.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),l.isNumber(t.categoryIndex)&&l.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),l.isNumber(t.subCategoryIndex)&&l.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),l.isNumber(t.columnGroupIndex)&&l.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),l.isNumber(t.columnSubGroupIndex)&&l.isString(t.columnSubGroup)&&i.addSubColumnGroup(t.columnSubGroup,t.columnSubGroupIndex),this.setActualValues(t,i),this.setPlanValues(t,i),this.setPreviousPeriodValues(t,i),this.setForecastValues(t,i),i}default(){return new ot}setActualValues(t,i){l.isNumber(t.ac1)&&(i.ac1=t.ac1),l.isNumber(t.ac2)&&(i.ac2=t.ac2),l.isNumber(t.ac3)&&(i.ac3=t.ac3),l.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){l.isNumber(t.pl1)&&(i.pl1=t.pl1),l.isNumber(t.pl2)&&(i.pl2=t.pl2),l.isNumber(t.pl3)&&(i.pl3=t.pl3),l.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){l.isNumber(t.pp1)&&(i.pp1=t.pp1),l.isNumber(t.pp2)&&(i.pp2=t.pp2),l.isNumber(t.pp3)&&(i.pp3=t.pp3),l.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){l.isNumber(t.fc1)&&(i.fc1=t.fc1),l.isNumber(t.fc2)&&(i.fc2=t.fc2),l.isNumber(t.fc3)&&(i.fc3=t.fc3),l.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class lt{constructor(t,i,s,h,e,n){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=h,this.varianceStyles=e,this.padding=n,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"],this.locale="de"}}class ct{constructor(t,i,s,h,e){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=h,this.paddingadapter=e}adapt(t){const i=new lt(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return l.isExisting(t)&&(l.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),l.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),l.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),l.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),l.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),l.isExisting(t.padding)&&(i.padding=this.paddingadapter.adapt(t.padding)),Array.isArray(t.stackColors)&&t.stackColors.length>0&&(i.stackColors=t.stackColors),i.pattern=new Z(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new lt(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}class ut{constructor(){this.scenarioOffset=.3,this.scenarioLabelToBar=.1,this.labelToBar=.3,this.labelToAxis=.3,this.needleWidth=.3,this.needleHeadWidth=.6,this.barWidth=1.2,this.varianceAxisLineWidth=.3,this.axisLineWidth=.1,this.auxiliaryLineWidth=.1,this.scenarioLineWidth=.2,this.markerWidth=.7,this.markerOffset=0,this.categoryWidth=1.9,this.axisTickLength=.3}}class dt{adapt(t){const i=new ut;return l.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),l.isNumber(t.scenarioLabelToBar)&&(i.scenarioLabelToBar=t.scenarioLabelToBar),l.isNumber(t.labelToBar)&&(i.labelToBar=t.labelToBar),l.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),l.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),l.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),l.isNumber(t.barWidth)&&(i.barWidth=t.barWidth),l.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),l.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),l.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),l.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),l.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),l.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),l.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),l.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new ut}}!function(t){t.AC1="ac1",t.PP1="pp1",t.FC1="fc1",t.PL1="pl1",t.AC2="ac2",t.PP2="pp2",t.FC2="fc2",t.PL2="pl2",t.AC3="ac3",t.PP3="pp3",t.FC3="fc3",t.PL3="pl3",t.AC4="ac4",t.PP4="pp4",t.FC4="fc4",t.PL4="pl4",t.POS="pos",t.NEG="neg",t.NEU="neu"}(it||(it={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(st||(st={})),function(t){t[t.Left=0]="Left",t[t.Center=1]="Center",t[t.Right=2]="Right",t[t.Top=3]="Top",t[t.Bottom=4]="Bottom"}(ht||(ht={}));class ft{constructor(t,i,s,h,e,n,r,o){this.group=null,this.segmentFillColor=null,this.maxWidth=null,this.ID_SCENARIOLABEL="Label",this.CSS_CATEGORIES="categories",this.pointPart="label",this.x=i,this.y=s,this.value=e,null!=t&&(this.group=t.group().id(this.createElementID(t.toString(),h))),this.styles=n,this.isVarianceLabel=!1,this.isRelativeLabel=!1,this.verticalHookLocation=r||ht.Top,this.horizontalHookLocation=o||ht.Left}setToVarianceLabel(){return this.isVarianceLabel=!0,this}setToRelativeVarianceLabel(){return this.isVarianceLabel=!0,this.isRelativeLabel=!0,this}setSegmentFill(t){return this.segmentFillColor=t,this}setMaxWidth(t){return this.maxWidth=t,this}setPoint(t,i="label"){return this.pointKey=t,this.pointPart=i,this}updateGroup(t){return this.group=t,this}createElementID(t,i){return t+"_"+i+"_"+this.ID_SCENARIOLABEL}draw(t={percent:2,decimal:1},i=new m){var s;if(this.isEmpty())return this;const h=this.group;let e;const n=this.styles.fontStyles.background||"#ffffff";let r="",o="start";if(!1===Number.isNaN(Number(this.value))){let s=t.percent,h=t.percent,n=1,a="percent";!1===this.isRelativeLabel&&(s=t.decimal,h=t.decimal,n=i.value,a="decimal"),e=P.number(Number(this.value),a,s,h,n,this.styles.locale),Number(this.value)<0&&(o="end");const l=P.number(0,a,s,h,n,this.styles.locale);this.isVarianceLabel&&Number(this.value)>0&&e!==l&&(r="+")}else e=""+this.value,o="start";const a=h.text(r+e);a.move(this.x,this.y);const l=a.bbox(),c=l.w,u=l.h;return null!=this.maxWidth&&c>this.maxWidth?(null===(s=this.group)||void 0===s||s.remove(),this.group=null,this):(this.horizontalHookLocation===ht.Right?(o="end",a.move(a.x()-a.length(),a.y())):this.horizontalHookLocation===ht.Center&&(o="middle",a.move(a.x()-a.length()/2,a.y())),this.verticalHookLocation===ht.Center?a.move(a.x(),a.y()-u/2):this.verticalHookLocation===ht.Bottom&&a.move(a.x(),a.y()-u),a.font({anchor:o}),null!=this.segmentFillColor?a.fill(C(this.segmentFillColor)):null==h||h.rect(c,.9*u).stroke(n).fill(n).opacity(.7).move(a.x(),a.y()+.1*u).insertBefore(a),this.pointKey&&(null==h||h.attr(O(this.pointKey,this.pointPart))),this)}isEmpty(){return null==this.value||""===this.value}setPos(t,i){return this.x=t,this.y=i,this}}class pt{constructor(t,i,s,h){this.height=0,this.ID_AXIS="axis",this.ID_AXIS_TITLE="axis-title",this.CSS_AXIS_TITLE="categories",this.scenarioType=t.scenarioType,this.labelText=t.labelText||null,this.position=i,this.style=h,this.label=new ft(s,this.position.getAxisTitlePositionX(),this.position.getAxisTitlePositionY(),this.ID_AXIS_TITLE,this.labelText,this.style,ht.Bottom,ht.Center),this.svgGroup=s.group().id(this.ID_AXIS)}draw(){return this.labelText&&this.label.draw(),this.svgGroup.line(this.position.getAxisPositionX(),this.position.getAxisPositionY(),this.position.getAxisEndPositionX(),this.position.getAxisEndPositionY()).addClass(this.ID_AXIS+"-"+this.convertScenarioType()),this.height=this.svgGroup.height(),this}convertScenarioType(){return void 0===this.scenarioType||null==this.scenarioType?"default":`${this.scenarioType}`.slice(0,2)}}class vt{constructor(t,i,s,h,e,n,r,o=null){if(this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.scenarioLabel=null,this.barGroup=null,this.isVarianceBar=!1,this.overflowConfig=null,this.isOverflowing=!1,this.overdriveWidth=0,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=h,this.isPrimaryBar=e,this.position=t,this.barStyles=i.barStyles,this.overflowConfig=o,this.scenarioGroup=n,this.styles=i,null!=n&&(this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT)),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0;let i=ht.Left;s.value<0&&(i=ht.Right),this.dimensions=this.createDimensions(t,s,h,e),this.label=new ft(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,ht.Center,i).setPoint(s.key),this.scenarioLabel=this.getScenarioLabel(r)}}setAsVariance(){var t;return this.isVarianceBar=!0,null===(t=this.label)||void 0===t||t.setToVarianceLabel(),this}isRelativeVariance(){var t;return this.isVarianceBar=!0,null===(t=this.label)||void 0===t||t.setToRelativeVarianceLabel(),this}updateLabelGroup(t){var i;return this.isEmpty()||null==t||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1},i=new m){var s,h;if(this.isEmpty()||null==this.dataPoint.getScenario())return this;let e=this.barStyles.getSVGStyle(this.dataPoint.getScenario());this.isVarianceBar&&(e=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()));const n=this.convertToSVGStyle(e,"stroke");let r=this.convertToSVGStyle(e,"fill");const o=this.barStyles.getSVGStyle(this.dataPoint.getScenario()).fillpattern;if(null!=o){const t=this.styles.pattern.get(o);null!=t&&(r=t.pattern)}null===(s=this.scenarioGroup)||void 0===s||s.attr(O(this.dataPoint.key)),null===(h=this.barGroup)||void 0===h||h.attr(O(this.dataPoint.key,"element")),null!=this.barGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(r,n):this.barGroup.rect(this.dimensions.barLength,this.position.getBarWidth()).fill(r).stroke(n).cy(this.dimensions.yPos).x(this.dimensions.xPos)),this.drawBarDataLabel(t,i),this.drawScenarioLabel()}drawOverdriveBar(t,i){if(!this.barGroup||!this.overflowConfig)return;const s=this.position.getBarPositionX(),h=this.position.getBarWidth(),e=this.dimensions.barLength,{breakGap:n}=this.overflowConfig;this.dataPoint.getScaledUnit()<0?(this.barGroup.rect(e,h).fill(t).stroke(i).x(s-e).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,h).fill(t).stroke(i).x(s-e-n-this.overdriveWidth).cy(this.dimensions.yPos),this.drawBreakIndicator(s-e-n,n)):(this.barGroup.rect(e,h).fill(t).stroke(i).x(s).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,h).fill(t).stroke(i).x(s+e+n).cy(this.dimensions.yPos),this.drawBreakIndicator(s+e,n))}drawBreakIndicator(t,i){if(!this.barGroup)return;const s=this.position.getBarWidth(),h=this.dimensions.yPos-s/2,e=t+i/2,n=.35*i,r=s/3;let o=`M ${e-n} ${h}`;for(let t=0;t<3;t++)o+=` L ${e-n-.3*i} ${h+r*(t+.5)} L ${e-n} ${h+r*(t+1)}`;let a=`M ${e+n} ${h}`;for(let t=0;t<3;t++)a+=` L ${e+n+.3*i} ${h+r*(t+.5)} L ${e+n} ${h+r*(t+1)}`;this.barGroup.rect(i,s+2).fill("#ffffff").stroke("none").x(t).cy(this.dimensions.yPos),this.barGroup.path(o).fill("none").stroke({color:"#000000",width:1}),this.barGroup.path(a).fill("none").stroke({color:"#000000",width:1})}createDimensions(t,i,s,h){const e=i.getScaledUnit(),n=Math.abs(e);if(this.overflowConfig&&n>0){const r="ac"===i.getScenario()?this.overflowConfig.cutWidth:this.overflowConfig.cutWidth-this.overflowConfig.scenarioCutOffset;if(n>r){this.isOverflowing=!0;const{breakGap:i,overdriveZoneWidth:o,maxOverflow:a}=this.overflowConfig;this.overdriveWidth=a>0?(n-r)/a*o:0;const l=r+i+this.overdriveWidth;return e<0?{clipped:!1,barLength:r,xPos:t.getBarPositionX()-r,yPos:t.getBarPositionY(s,h),labelXPos:t.getLabelPositionX(-l),scenarioLabelXPos:t.getBarPositionX()-.5*r,scenarioLabelYPos:t.getBarPositionY(s,h)+t.getScenarioLabelPositionOffsetY(h)}:{clipped:!1,barLength:r,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,h),labelXPos:t.getLabelPositionX(l),scenarioLabelXPos:t.getBarPositionX()+.5*r,scenarioLabelYPos:t.getBarPositionY(s,h)+t.getScenarioLabelPositionOffsetY(h)}}}return e<0?{clipped:!1,barLength:n,xPos:t.getBarPositionX()+e,yPos:t.getBarPositionY(s,h),labelXPos:this.position.getLabelPositionX(e),scenarioLabelXPos:this.position.getBarPositionX()-.5*n,scenarioLabelYPos:this.position.getBarPositionY(s,h)+this.position.getScenarioLabelPositionOffsetY(h)}:{clipped:!1,barLength:e,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,h),labelXPos:this.position.getLabelPositionX(e),scenarioLabelXPos:this.position.getBarPositionX()+.5*n,scenarioLabelYPos:this.position.getBarPositionY(s,h)+this.position.getScenarioLabelPositionOffsetY(h)}}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.isVarianceBar||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw()}drawBarDataLabel(t,i=new m){var s;this.isPrimaryBar&&(null===(s=this.label)||void 0===s||s.draw(t,i))}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getScenarioLabel(t){return new ft(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,this.isPrimaryBar?ht.Top:ht.Bottom,ht.Center)}}class gt{constructor(t,i,s,h,e,n,r,o,a){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.FALLBACK_COLOUR="#000000",this.scenarioLabel=null,this._defaultMarkerPattern=null,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.position=t,this.markerGroup=i||null,this.markerPattern=s||this._defaultMarkerPattern,this.styles=e,this.barStyles=e?e.barStyles:null,this.scenario=h,!0!==(null==n?void 0:n.isEmpty())&&(this.hasData=!0,this.pointKey=n.key,this.dimensions=this.createMarkerDimensions(n,r,a),this.scenarioLabel=this.getScenarioLabel(o,e,a))}createMarkerDimensions(t,i,s){return t.getScaledUnit()<0?{clipped:!1,labelXPos:0,barLength:Math.abs(t.getScaledUnit()),xPos:this.position.getMarkerPositionX()-Math.abs(t.getScaledUnit()),yPos:this.position.getMarkerPositionY(i,s),scenarioLabelXPos:this.position.getMarkerPositionX()-Math.abs(t.getScaledUnit()),scenarioLabelYPos:this.position.getMarkerPositionY(i,s)+this.position.getMarkerScenarioLabelPositionOffsetY(s)}:{clipped:!1,labelXPos:0,barLength:t.getScaledUnit(),xPos:this.position.getMarkerPositionX()+t.getScaledUnit(),yPos:this.position.getMarkerPositionY(i,s),scenarioLabelXPos:this.position.getMarkerPositionX()+t.getScaledUnit(),scenarioLabelYPos:this.position.getMarkerPositionY(i,s)+this.position.getMarkerScenarioLabelPositionOffsetY(s)}}getScenarioLabel(t,i,s){return null==this.markerGroup?null:new ft(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,s?ht.Bottom:ht.Top,ht.Center)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}draw(){if(this.isEmpty())return this;const t=this.convertToSVGStyle(this.barStyles[this.getScenario()],"stroke");let i=this.convertToSVGStyle(this.barStyles[this.getScenario()],"fill");const s=this.barStyles[this.getScenario()];if(null!=s&&s.fillpattern){const t=this.styles.pattern.get(s.fillpattern);null!=t&&(i=t.pattern)}return this.markerGroup.attr(O(this.pointKey)),this.markerGroup.polygon(this.markerPattern.background).fill("#ffffff").cy(this.dimensions.yPos).cx(this.dimensions.xPos),this.markerGroup.polygon(this.markerPattern.foreground).fill(i).stroke(t).cy(this.dimensions.yPos).cx(this.dimensions.xPos).attr(O(this.pointKey,"element")),null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(),this}isEmpty(){return!1===this.hasData}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}class bt{constructor(t,i,s,h,e){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=h,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=e,this.styles=i,this.barGroup=e.group().id(e.toString()+"_"+this.ID_RECT);const n=void 0===(null==s?void 0:s.value)&&null!=(null==s?void 0:s.scenario);if(!0!==(null==s?void 0:s.isEmpty())&&null!=s.value||n){this.hasData=!0,this.dimensions=this.createDimensions(t,s,h);let i=ht.Left;s.value<0&&(i=ht.Right),this.label=new ft(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,n?N:s.value,this.styles,ht.Center,i),this.label.setToRelativeVarianceLabel().setPoint(s.key)}}updateLabelGroup(t){var i;return this.isEmpty()||null==t||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1}){var i,s,h;if(void 0===(null===(i=this.dataPoint)||void 0===i?void 0:i.value))return null===(s=this.label)||void 0===s||s.draw(t),this;if(this.isEmpty())return this;if(null==this.dimensions)return this;this.scenarioGroup.attr(O(this.dataPoint.key)),this.barGroup.attr(O(this.dataPoint.key,"element"));const e=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()),n=e.stroke;let r=e.fill;const o=this.barStyles[this.dataPoint.getScenario()];if(null!=o&&o.fillpattern){const t=this.styles.pattern.get(o.fillpattern);null!=t&&null!=t.pattern&&(r=t.pattern)}this.drawNeedleHead(r,n),this.barGroup.rect(this.dimensions.barLength,this.position.getNeedleWidth()).fill(r).stroke(n).cy(this.dimensions.yPos).x(this.dimensions.xPos),null===(h=this.label)||void 0===h||h.draw(t)}createDimensions(t,i,s){return i.getScaledPercentUnit()<0?{barLength:Math.abs(i.getScaledPercentUnit()),xPos:t.getBarPositionX()+i.getScaledPercentUnit(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()-this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}:{barLength:i.getScaledPercentUnit(),xPos:t.getBarPositionX(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()+this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}}drawNeedleHead(t,i){if(null===this.dimensions)return;const s=this.styles.varianceStyles.needleHeadColour,h=this.styles.varianceStyles.needleHeadColour;if(this.dimensions.clipped){let s="13,0 4,-5 4,5 13,0 8,0 0,-5 0,5 8,0";null!=this.dataPoint.value&&this.dataPoint.value<0&&(s="0,0 9,-5 9,5 0,0 5,0 13,-5 13,5 5,0"),this.barGroup.polygon(s).fill(t).cx(this.getHeadXPosition()).cy(this.dimensions.yPos).fill(t).stroke(i)}else this.barGroup.rect(2*this.position.getNeedleWidth(),2*this.position.getNeedleWidth()).cx(this.getHeadXPosition()).cy(this.dimensions.yPos).fill(s).stroke(h)}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getHeadXPosition(){let t=this.dimensions.xPos;return null!=this.dataPoint.value&&this.dataPoint.value>0&&(t+=this.dimensions.barLength),t}}class mt{constructor(t,i,s,h,e,n,r,o,a,l,c){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=h,this.segment=e,this.segmentIndex=r,this.stackMode=o,this.stack=a,this.group=c,this.barGroup=c.group().id(`stacked_bar_${h}_seg_${r}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new m){if(!this.hasData||!Number.isFinite(this.dataPoint.value))return;const s=this.dataPoint.value,h=this.dataPoint.pixelPerUnit,e=this.position.getBarPositionX(),n=this.position.getBarWidth(),r=Math.abs(this.segment.end-this.segment.start)*h,o=e+Math.min(this.segment.start,this.segment.end)*h,a=this.position.getBarPositionY(this.index,!0),l=this.styles.stackColors,c=l[this.segmentIndex%l.length],d={color:c},f={color:c,width:.5};this.barGroup.attr(O(this.dataPoint.key,"element")),this.barGroup.rect(Math.max(r,.5),n).fill(d).stroke(f).cy(a).x(o);const p=r-6;if(p>0){const h=o+r/2;if(this.stackMode===u.RELATIVE||this.stackMode===u.ABSOLUTE_RELATIVE){const i=P.number(this.segment.share,"percent",t.percent,t.percent,1,this.styles.locale);new ft(this.group,h,a,"STACK_SEG",i,this.styles,ht.Center,ht.Center).setSegmentFill(c).setMaxWidth(p).setPoint(this.dataPoint.key).draw()}else new ft(this.group,h,a,"STACK_SEG",s,this.styles,ht.Center,ht.Center).setSegmentFill(c).setMaxWidth(p).setPoint(this.dataPoint.key).draw(t,i)}}drawTotalLabel(t={percent:2,decimal:1},i=new m,s){if(this.stackMode===u.RELATIVE)return;const h=this.stack.total<0,e=this.position.getLabelPositionX((h?0-this.stack.negative:this.stack.positive)*this.dataPoint.pixelPerUnit),n=this.position.getBarPositionY(this.index,!0);new ft(this.group,e,n,"STACK_TOTAL",this.stack.total,this.styles,ht.Center,h?ht.Right:ht.Left).setPoint(s,"total").draw(t,i)}}class wt{constructor(t,i,s,h,e){this.overflowConfig=null,this.i18n=e;const n=i.group().id("Scenario1"),r=i.group().id("Scenario2").insertBefore(n);this.svgGroups={parent:i,scenario1:n,scenario2:r,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=h}setOverflowConfig(t){this.overflowConfig=t}isLastDataPoint(t){return this.elementCnt-1===t}isFirsttDataPoint(t){return 0===t}createPrimaryBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new vt(this.position,this.styles,t,i,!0,r,a,this.overflowConfig).updateLabelGroup(o)}createVarianceBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new vt(this.position,this.styles,t,i,!0,r,a,this.overflowConfig).updateLabelGroup(o).setAsVariance()}createRelativeVarianceBar(t,i){var s,h,e,n;const r=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===h?void 0:h.group().id(""+i),o=null===(n=null===(e=this.svgGroups)||void 0===e?void 0:e.scenario1Label)||void 0===n?void 0:n.group().id(""+i);return new bt(this.position,this.styles,t,i,r).updateLabelGroup(o)}createSecondaryBar(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario2)||void 0===h?void 0:h.group().id(""+i);let n=null;return this.isFirsttDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new vt(this.position,this.styles,t,i,!1,e,n,this.overflowConfig)}createPrimaryMarker(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario3)||void 0===h?void 0:h.group().id(""+i),n=this.styles.pattern.get("marker-down")||{foreground:"0,0 1,0 1,1 0,1",background:"0,0 1,0 1,1 0,1",bgOffset:0};let r=null;return this.isFirstDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new gt(this.position,e,n,t.scenario,this.styles,t,i,r,!0)}createSecondaryMarker(t,i){var s,h;const e=null===(h=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario4)||void 0===h?void 0:h.group().id(""+i),n=this.styles.pattern.get("marker-up")||{foreground:"0,0 1,0 1,1 0,1",background:"0,0 1,0 1,1 0,1",bgOffset:0};let r=null;return this.isLastDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new gt(this.position,e,n,t.scenario,this.styles,t,i,r,!1)}isFirstDataPoint(t){return 0===t}}class Pt{constructor(t,i,s,h,e){this.dataModel=[],this.variancesDataModel=[],this.title="",this.configTitle="",this.configVariances=[],this.smallestDataPointValue=new rt(0,it.AC1,1,it.NEU),this.highestDataPointValue=new rt(0,it.AC1,1,it.NEU),this.smallestVarianceDataPointValue=new rt(0,it.AC1,1,it.NEU),this.highestVarianceDataPointValue=new rt(0,it.AC1,1,it.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.level=c.CATEGORY,this.hideCategories=!1,this.axisScenario=it.AC1,this.CSS_CATEGORIES="categories",this.state=J.DIRTY,this.titleLength=0,this.leftSideOffsetForHorizontalSync=0,this.limit=0,this.measureScale=new m,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.scenarioPropOrder=[],this.overflowConfig=null,this.stackSides=E([]),this.stackLabelClearance={left:0,right:0},this.fromExpr="",this.rowCount=0,this.db=i,this.tableName=s,this.ruleSet=t||new y,this.i18n=this.createI18n(new Map),this.styles=e,this.setConfig(h),this.position=this.createElementPosition()}updatePosition(){this.position=this.createElementPosition()}createElementPosition(){this.titleLength=this.calculateTitleLength(0);let t=this.calculateLeftSideWidth(this.getVarianceType());const i=this.calculateCategoryWidth();return this.titleLength>t&&(t=this.titleLength),new K(new Q(this.styles.padding),this.styles.scaleFactors,this.styles.fontStyles.size,this.dataModel.length,this.leftSideOffsetForHorizontalSync,this.titleLength,t,i,!!this.stackConfig&&0===this.variancesDataModel.length)}setStyles(t){this.styles=t}setRuleSet(t){this.ruleSet=t||new y}setConfig(t){var i,s;this.state=J.DIRTY,this.scenarioPropOrder=[...t.scenarios];const h=this.sortScenariosbyVisualisationRules(t.scenarios);this.hideCategories=t.hideCategories||!1,this.limit=t.limit,this.pixelPerUnit=t.pixelPerUnit||1,this.pixelPerPercentage=t.pixelPerPercentage||100,this.setSource(t.filter),this.level=t.level,this.dataModel=this.populateModel(h,t.level,t.sortOrder);for(const t of this.dataModel)for(const s of[t.scenario1,t.scenario2,t.scenario3,t.scenario4])null==s.value||Number.isNaN(s.value)||(s.key=Object.assign(Object.assign({},$(this.level,t.category)),{scenario:null!==(i=s.scenario)&&void 0!==i?i:void 0}));t.stackConfig&&t.stackConfig.by!==d.SCENARIOS&&this.populateDimensionStackSegments(h,t.stackConfig,t.level),this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.configTitle=t.title,this.configVariances=null!==(s=null==t?void 0:t.variances)&&void 0!==s?s:[],this.updateTitle(),this.smallestDataPointValue=this.findSmallestDataPointValue(this.dataModel),this.smallestVarianceDataPointValue=this.findSmallestDataPointValue(this.variancesDataModel),this.highestDataPointValue=this.findHighestDataPointValue(this.dataModel),this.highestVarianceDataPointValue=this.findHighestDataPointValue(this.variancesDataModel),this.axisScenario=this.setAxisScenario(t.variances),this.measureScale=t.measureScale,this.measureUnit=t.measureUnit,this.dataFormatDigits=t.dataFormatDigits,this.stackConfig=t.stackConfig,this.measureStacks(),this.updatePosition()}sortScenariosbyVisualisationRules(t){const i=this;return[...t].sort(((t,s)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(s))).reverse()}setI18n(t){this.i18n=this.createI18n(t),this.updateTitle()}updateTitle(){var t;this.title=this.configTitle||P.translateScenarioLabel(null===(t=this.configVariances)||void 0===t?void 0:t.toString(),this.i18n)}createI18n(t){this.state=J.DIRTY;const i=new Map([["SEPARATOR_WS",", "],["in","in"],["ORDER_asc","↑"],["ORDER_desc","↓"],["ac1","AC"],["pp1","PY"],["fc1","FC"],["pl1","PL"],["ac2","AC2"],["pp2","PY2"],["fc2","FC2"],["pl2","PL2"],["ac3","AC3"],["pp3","PY3"],["fc3","FC3"],["pl3","PL3"],["ac4","AC4"],["pp4","PY4"],["fc4","FC4"],["pl4","PL4"],["category"," "],["operation"," "],["thereof","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"]]);return new Map([...i,...t])}setSource(t){var i,s;if(this.state=J.DIRTY,this.queryError=void 0,this.fromExpr=V(this.db,this.tableName,t),this.fromExpr)try{const t=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(s=null===(i=t[0])||void 0===i?void 0:i.cnt)&&void 0!==s?s:0}catch(t){this.rowCount=0,this.failQuery(t)}else this.rowCount=0}getQueryError(){return this.queryError}failQuery(t){var i;null!==(i=this.queryError)&&void 0!==i||(this.queryError=z(t))}getUnitBarExtent(){var t,i;const s=this.isStacked(),h=this.getVarianceType(),e=h!==tt.NONE,n=e?this.highestVarianceDataPointValue:this.highestDataPointValue,r=e?this.smallestVarianceDataPointValue:this.smallestDataPointValue;return D({fixedDomain:s?this.stackSides.positive+this.stackSides.negative:void 0,relativeVariance:h===tt.RELATIVE,maxPositive:null!==(t=null==n?void 0:n.value)&&void 0!==t?t:0,minNegative:null!==(i=null==r?void 0:r.value)&&void 0!==i?i:0})}getPercentBarExtent(){var t,i,s,h;return W({relativeVariance:this.getVarianceType()===tt.RELATIVE,maxPositive:null!==(i=null===(t=this.highestVarianceDataPointValue)||void 0===t?void 0:t.value)&&void 0!==i?i:0,minNegative:null!==(h=null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&void 0!==h?h:0})}getAllocatedCanvasWidth(){const t=this.position.getAxisPositionX(),i=this.calculateRightSideWidth(this.getVarianceType());let s=t+i+ +this.styles.padding.left+this.styles.padding.right;return i<this.titleLength/2&&(s+=this.titleLength/2),t<this.titleLength/2&&(s+=this.titleLength/2),s}getAllocatedCanvasHeight(){return this.position.getAxisEndPositionY()+this.position.spacings.labelToAxis+this.position.fontSize+this.styles.padding.bottom}patternToString(){return"<svg></svg>"}layout(){this.draw(new n)}toString(){const t=new n;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.svg()}applyFontToContainer(t){t.attr({"font-size":this.styles.fontStyles.size,"font-family":this.styles.fontStyles.family})}draw(t){this.cleanSVGforRedraw(t),this.applyFontToContainer(t),this.state===J.DIRTY&&(this.state=J.UP_TO_DATE),this.variancesDataModel&&this.variancesDataModel.length>0?(this.drawVarianceScenario(this.variancesDataModel,t),this.drawAxisAndLabels(this.variancesDataModel,t)):null!=this.stackConfig?(this.drawStackedScenarios(this.dataModel,t),this.drawStackedHeaders(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t,!0)):(this.drawScenarios(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t))}setPattern(t,i){this.styles.pattern.set(t,i)}calculateTitleLength(t){const i=S(this.title.length>7?this.title:"_______",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;return i<t?t:i/2}getFooter(){return 1===this.measureScale.value&&""===this.measureUnit?" ":P.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}scenarioStyles(){const t=x(this.styles.barStyles,this.ruleSet);return t===this.styles.barStyles?this.styles:Object.assign(Object.create(Object.getPrototypeOf(this.styles)),this.styles,{barStyles:t})}setAxisScenario(t){let i=it.AC1;if(null!=t&&t.length>0){const s=new L(t.toString());s.isValid&&(i=k(this.ruleSet.getScenarioColorIndex(s.delta))+s.delta.slice(2))}return null===i&&(i=it.AC1),i}populateModel(t,i,s){if(0===this.rowCount||!this.fromExpr)return[];const h=[],e=this.createOrderStr(i,s),n=this.createSelectString(i,s),r=this.createGroupByStr(i,s);let o;try{o=this.db.exec(`SELECT ${n} ${t.length>0?","+t.map((t=>`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`)).join(","):""}\n FROM ${this.fromExpr}\n GROUP BY ${r}\n ORDER BY ${e}`)}catch(t){return this.failQuery(t),[]}return this.detectNaNCells(t,o),this.createDataRows(this.limit>0?o.slice(0,this.limit):o,h,t),this.crateRESTRow(o,t,h),h}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new L(t);!0===s.isValid?0!==i[s.base+"_cnt"]&&0!==i[s.delta+"_cnt"]||(i[t]=Number.NaN):0===i[t+"_cnt"]&&(i[t]=Number.NaN)})),i)))}crateRESTRow(t,i,s){if(this.limit<=0||this.limit>=t.length)return;const h=[];this.createDataRows(t.slice(this.limit),h,i);const e=(t,i)=>Number.isFinite(i)?(Number.isFinite(t)?t:0)+i:t,n=h.reduce((function(t,s){return{id:t.id,category:t.category,type:t.type,scenario1:new rt(e(t.scenario1.value,s.scenario1.value),i[0],t.scenario1.pixelPerUnit,it.NEU),scenario2:new rt(e(t.scenario2.value,s.scenario2.value),i[1],t.scenario2.pixelPerUnit,it.NEU),scenario3:new rt(e(t.scenario3.value,s.scenario3.value),i[2],t.scenario3.pixelPerUnit,it.NEU),scenario4:new rt(e(t.scenario4.value,s.scenario4.value),i[3],t.scenario4.pixelPerUnit,it.NEU)}}),{id:9999,category:"REST",type:tt.NONE,scenario1:new rt(NaN,i[0],this.pixelPerUnit,it.NEU),scenario2:new rt(NaN,i[1],this.pixelPerUnit,it.NEU),scenario3:new rt(NaN,i[2],this.pixelPerUnit,it.NEU),scenario4:new rt(NaN,i[3],this.pixelPerUnit,it.NEU)});s.push(n)}createDataRows(t,i,s){t.forEach(((t,h)=>{i.push({id:h,category:t.category,type:tt.NONE,scenario1:new rt(t[s[0]],s[0],this.pixelPerUnit,it.NEU),scenario2:new rt(t[s[1]],s[1],this.pixelPerUnit,it.NEU),scenario3:new rt(t[s[2]],s[2],this.pixelPerUnit,it.NEU),scenario4:new rt(t[s[3]],s[3],this.pixelPerUnit,it.NEU)})}))}createOrderStr(t,i){let s=`${t.toLowerCase()}`;return i.hierarchy.length>=1&&(s=i.hierarchy.map((t=>`${t} ${i.direction}`)).toString()),s}createSelectString(t,i){return t===c.CATEGORY&&i.hierarchy.includes(g.CATEGORYINDEX)?`${g.CATEGORYINDEX}, ${c.CATEGORY} as category`:t===c.ROWGROUP&&i.hierarchy.includes(g.ROWGROUPINDEX)?`${g.ROWGROUPINDEX}, ${c.ROWGROUP} as category`:t===c.SUBCATEGORY&&i.hierarchy.includes(g.SUBCATEGORYINDEX)?`${g.SUBCATEGORYINDEX}, ${c.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===c.CATEGORY&&i.hierarchy.includes(g.CATEGORYINDEX)?`${g.CATEGORYINDEX}, ${c.CATEGORY}`:t===c.ROWGROUP&&i.hierarchy.includes(g.ROWGROUPINDEX)?`${g.ROWGROUPINDEX}, ${c.ROWGROUP}`:t===c.SUBCATEGORY&&i.hierarchy.includes(g.SUBCATEGORYINDEX)?`${g.SUBCATEGORYINDEX}, ${c.SUBCATEGORY}`:`${t.toString()}`}calculateCategoryWidth(){if(this.hideCategories)return 5;let t=0;for(const i of this.dataModel){const s=S(i.category,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"});s.width>t&&(t=s.width)}return 1.1125*t}findSmallestDataPointValue(t){let i=new rt(0,"default",this.pixelPerUnit,null);for(const s of t)for(const t of[s.scenario1,s.scenario2,s.scenario3,s.scenario4])null!=t&&null!=i.value&&t.value<i.value&&(i=t);return i}findHighestDataPointValue(t){let i=new rt(0,"default",this.pixelPerUnit,null);for(const s of t)for(const t of[s.scenario1,s.scenario2,s.scenario3,s.scenario4])null!=t&&null!=i.value&&t.value>i.value&&(i=t);return i}stackGroups(t){if(!this.stackConfig)return[];const i=this.stackConfig.by===d.SCENARIOS;let s=[];for(const h of i?["scenario1","scenario2","scenario3","scenario4"]:["scenario1"]){const i=t[h];i&&!i.isEmpty()&&null!=i.value&&s.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0===s.length)return[];const h=this.stackConfig.mode===u.RELATIVE?1:0,e=(t,i)=>({prefix:t,segments:i,layout:B(i.map((t=>t.value)),h),hasValue:i.some((t=>Number.isFinite(t.value)))});if(i){this.sortSegmentsByPropOrder(s);const t=new Map;for(const i of s){const s=M(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}if(t.size>1){const i=[];for(const s of T)t.has(s)&&(i.push(e(s,t.get(s))),t.delete(s));for(const[s,h]of t)i.push(e(s,h));return i}}else t.stackSegments&&t.stackSegments.length>0&&(s=t.stackSegments.map((t=>({value:t.value,scenario:t.label,dataPoint:t.dataPoint}))));const n=t=>Number.isFinite(t.value)?t.value:0;return"asc"===this.stackConfig.order?s.sort(((t,i)=>n(t)-n(i))):"desc"===this.stackConfig.order&&s.sort(((t,i)=>n(i)-n(t))),[e("",s)]}measureStacks(){const t=[];this.stackLabelClearance={left:0,right:0};for(const i of this.dataModel){const{flipped:s,clearance:h}=this.stackLabelPlace(i),e=this.drawnStackLayouts(i),n=s?"right":"left";this.stackLabelClearance[n]=Math.max(this.stackLabelClearance[n],h),t.push(...e)}this.stackSides=E(t)}stackLabelPlace(t){const i=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;return R(this.drawnStackLayouts(t),(t=>{var s;return(null===(s=this.stackConfig)||void 0===s?void 0:s.mode)===u.RELATIVE?0:(i+this.calculateTotalLabelWidth(t.total))/this.pixelPerUnit}))}drawnStackLayouts(t){return this.stackGroups(t).filter((t=>t.hasValue)).map((t=>t.layout))}calculateTotalLabelWidth(t){const i=this.dataFormatDigits.decimal;return S(P.number(t,"decimal",i,i,this.measureScale.value,this.styles.locale),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width}isStacked(){return null!=this.stackConfig&&this.stackSides.positive+this.stackSides.negative>0}populateVarianceModel(t,i){const s=[];if(0===t.length)return s;let h=null;null!=i&&i.length>0&&(h=i[0]);for(const e in t){const n=new L(t[e]);if(n.isValid){const r=this.mapScenarios(n,h),o=n.direction;let a=this.pixelPerUnit;"dr"===n.type&&(a=this.pixelPerPercentage);for(const h in i){const l=new rt(this.calculateVariance(n,i[h],r),n.base,a,o);null===l.value||Number.isNaN(l.value)||(l.key=Object.assign(Object.assign({},$(this.level,i[h].category)),{scenario:t[e]})),s.push({id:Number(h),category:i[h].category,type:"dr"===n.type?tt.RELATIVE:tt.ABSOLUTE,scenario1:l,scenario2:new rt(null,null,null,null),scenario3:new rt(null,null,null,null),scenario4:new rt(null,null,null,null)})}}}return s}calculateVariance(t,i,s){const h=s.get(t.base),e=s.get(t.delta);return null==h||null==e?null:t.type===tt.RELATIVE?_(i[h].value-i[e].value,i[e].value):i[h].value-i[e].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((h=>{i[h].scenario===t.delta?s.set(t.delta,h):i[h].scenario===t.base&&s.set(t.base,h)})),s}calculateTextBoxWidth(t){return S(P.number(t,"decimal",1,0,1,this.styles.locale),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width}calculatePercentageTextBoxWidth(t){let i=0;const s=this.dataFormatDigits.percent,h=t=>P.number(t,"percent",s,s,1,this.styles.locale);return t>0&&h(t)!==h(0)&&(i+=S("+",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width),i+=S(" %",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,S(P.number(t,"decimal",1,1,1,this.styles.locale),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width+i+i}cleanSVGforRedraw(t){t.clear()}drawAxisAndLabels(t,i,s=!1){const h=i.group().id("AxisAndDateLables");let e=!1;this.hideCategories||t.forEach(((t,i)=>{t.type===tt.RELATIVE&&(e=!0);let n=ht.Right,r=!0,o=0;if(s){const i=this.stackLabelPlace(t);r=!i.flipped,o=i.clearance*this.pixelPerUnit*(i.flipped?1:-1)}else t.scenario1.value<0&&(r=!1);r||(n=ht.Left),new ft(h,this.position.getCategoryPositionX(r)+o,this.position.getBarCenterPositionY(i),"",this.i18n.get(t.category)||t.category,this.styles,ht.Center,n).draw()})),new pt({scenarioType:this.axisScenario,labelText:this.title,isRelative:e},this.position,h,this.styles).draw()}drawScenarios(t,i){const s=i.group().id("Scenarios"),h=new wt(this.position,s,this.scenarioStyles(),t.length,this.i18n);h.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{h.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),h.createSecondaryBar(t.scenario2,i).draw(),h.createPrimaryMarker(t.scenario3,i).draw(),h.createSecondaryMarker(t.scenario4,i).draw()}))}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),h=new wt(this.position,s,this.scenarioStyles(),t.length,this.i18n);return h.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.type===tt.RELATIVE?h.createRelativeVarianceBar(t.scenario1,i).draw(this.dataFormatDigits):h.createVarianceBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale)})),s}sortSegmentsByPropOrder(t){if(0===this.scenarioPropOrder.length)return;const i=this.scenarioPropOrder;t.sort(((t,s)=>{const h=i.indexOf(t.scenario),e=i.indexOf(s.scenario);return(-1===h?i.length:h)-(-1===e?i.length:e)}))}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),h=this.stackConfig.by===d.SCENARIOS;t.forEach(((t,i)=>{const e=this.stackGroups(t);e.forEach(((n,r)=>{let o=null;n.segments.forEach(((t,a)=>{const l=new mt(this.position,this.styles,t.dataPoint,i,n.layout.segments[a],t.scenario,e.length>1?e.length-1-r:a,this.stackConfig.mode,n.layout,h,s);l.draw(this.dataFormatDigits,this.measureScale),o=l})),o&&n.hasValue&&o.drawTotalLabel(this.dataFormatDigits,this.measureScale,Object.assign(Object.assign({},$(this.level,t.category)),{scenario:e.length>1?n.prefix:void 0}))}))}))}drawStackedHeaders(t,i){if(!this.stackConfig||0===t.length)return;const s=t[0];if(this.stackConfig.by!==d.SCENARIOS&&(!s.stackSegments||0===s.stackSegments.length))return;const h=this.stackGroups(s);if(0===h.length)return;const e=i.group().id("StackedHeaders"),n=this.position.getBarPositionX(),r=this.position.getStackedHeaderPositionY(),o=(t,i)=>{new ft(e,t,r,"STACK_HEADER",i,this.styles,ht.Bottom,ht.Center).draw()};if(h.length>1)return void h.forEach((t=>{o(n+(t.layout.positive-t.layout.negative)/2*t.segments[0].dataPoint.pixelPerUnit,this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase())}));const[a]=h;a.segments.forEach(((t,i)=>{const{start:s,end:h}=a.layout.segments[i];o(n+(s+h)/2*t.dataPoint.pixelPerUnit,this.i18n.get(t.scenario)||t.scenario)}))}getVarianceType(){return this.variancesDataModel.length>0?this.variancesDataModel[0].type:tt.NONE}calculateLeftSideWidth(t){var i,s,h;let e=0;const n=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(tt.NONE===t&&this.isStacked())this.stackSides.negative>0&&(e=this.stackSides.negative*this.pixelPerUnit,this.stackSides.minTotal<0&&(e+=n+this.calculateTotalLabelWidth(this.stackSides.minTotal))),this.stackLabelClearance.left>0&&(e=Math.max(e,this.stackLabelClearance.left*this.pixelPerUnit+this.calculateCategoryWidth()));else if(tt.NONE===t&&null!=(null===(i=this.smallestDataPointValue)||void 0===i?void 0:i.value)&&this.smallestDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestDataPointValue.value);e=Math.abs(this.smallestDataPointValue.getScaledUnit())+n+t}else if(tt.RELATIVE===t&&null!=(null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculatePercentageTextBoxWidth(this.smallestVarianceDataPointValue.value);e=Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit())+n+t}else if(tt.ABSOLUTE===t&&null!=(null===(h=this.smallestVarianceDataPointValue)||void 0===h?void 0:h.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value);e=Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())+n+t}return e<=this.titleLength?this.titleLength:e}calculateRightSideWidth(t){var i,s,h;if(this.isStacked()){const t=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar,i=this.calculateTextBoxWidth(this.stackSides.maxTotal);let s=this.stackSides.positive*this.pixelPerUnit+t+i;return this.stackSides.minTotal<0&&(s=Math.max(s,this.stackLabelClearance.right*this.pixelPerUnit+this.position.getCategoryToAxisSpaceing()+this.calculateCategoryWidth())),Math.max(s,this.titleLength)}let e=0;const n=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(tt.NONE===t&&null!=(null===(i=this.highestDataPointValue)||void 0===i?void 0:i.value)&&this.highestDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestDataPointValue.value);e=Math.abs(this.highestDataPointValue.getScaledUnit())+n+t}else if(tt.RELATIVE===t&&null!=(null===(s=this.highestVarianceDataPointValue)||void 0===s?void 0:s.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculatePercentageTextBoxWidth(this.highestVarianceDataPointValue.value);e=Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit())+n+t}else if(tt.ABSOLUTE===t&&null!=(null===(h=this.highestVarianceDataPointValue)||void 0===h?void 0:h.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value);e=Math.abs(this.highestVarianceDataPointValue.getScaledUnit())+n+t}return e<=this.titleLength?this.titleLength:e}populateDimensionStackSegments(t,i,s){if(0===this.rowCount||!this.fromExpr||0===t.length)return;const h={[c.ROWGROUP]:"category",[c.ROWGROUPINDEX]:"category",[c.CATEGORY]:"subCategory",[c.CATEGORYINDEX]:"subCategory"}[s];if(!h)return;const e=s.toString(),n=t[0];let r;try{r=this.db.exec(`SELECT [${e}] as displayGroup, [${h}] as stackLabel, SUM([${n}] * transformOperator(operation)) as stackValue FROM ${this.fromExpr} GROUP BY [${e}], [${h}]`)}catch(t){return void this.failQuery(t)}const o=new Map;for(const t of r){const i=t.displayGroup;o.has(i)||o.set(i,[]),null!=t.stackValue&&null!=t.stackLabel&&o.get(i).push({label:t.stackLabel,value:t.stackValue})}for(const t of this.dataModel){const i=o.get(t.category);t.stackSegments=i&&i.length>0?i.map((i=>{const s=new rt(i.value,n,this.pixelPerUnit,it.NEU);return s.key=Object.assign(Object.assign({},$(this.level,t.category)),{[h]:i.label,scenario:n}),{label:i.label,value:i.value,dataPoint:s}})):[]}}hasNoData(){return 0===this.dataModel.length}setAvailableWidth(t){if(this.pixelPerUnit<=0||t<=0)this.overflowConfig=null;else if(null==this.stackConfig){if(this.overflowConfig=this.calculateOverflowConfig(t),this.overflowConfig){const{cutWidth:t,overdriveZoneWidth:i,breakGap:s}=this.overflowConfig,h=t+i+s;this.variancesDataModel&&this.variancesDataModel.length>0?(this.highestVarianceDataPointValue.getScaledUnit()>t&&(this.highestVarianceDataPointValue=new rt(h,this.highestVarianceDataPointValue.scenario,1,this.highestVarianceDataPointValue.variance)),null!=this.smallestVarianceDataPointValue.value&&Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())>t&&(this.smallestVarianceDataPointValue=new rt(-h,this.smallestVarianceDataPointValue.scenario,1,this.smallestVarianceDataPointValue.variance))):(this.highestDataPointValue.getScaledUnit()>t&&(this.highestDataPointValue=new rt(h,this.highestDataPointValue.scenario,1,this.highestDataPointValue.variance)),null!=this.smallestDataPointValue.value&&Math.abs(this.smallestDataPointValue.getScaledUnit())>t&&(this.smallestDataPointValue=new rt(-h,this.smallestDataPointValue.scenario,1,this.smallestDataPointValue.variance))),this.updatePosition()}}else this.overflowConfig=null}calculateOverflowConfig(t){const i=this.variancesDataModel&&this.variancesDataModel.length>0;if(this.getVarianceType()===tt.RELATIVE)return null;const s=i?this.highestVarianceDataPointValue:this.highestDataPointValue,h=i?this.smallestVarianceDataPointValue:this.smallestDataPointValue,e=s.getScaledUnit(),n=null!=h.value?Math.abs(h.getScaledUnit()):0,r=Math.max(e,n);if(r<=0)return null;const o=this.styles.fontStyles.size,a=o*this.styles.scaleFactors.labelToBar,l=1.5*o,c=.3*o,u=.8*o,d=t-this.position.getAxisPositionX()-this.styles.padding.left-this.styles.padding.right-a-this.calculateTextBoxWidth(s.value||0)-l-c;if(d<=u)return null;const f=d-u;return r<=f?null:{cutWidth:d,overdriveZoneWidth:l,breakGap:c,maxOverflow:r-f,scenarioCutOffset:u}}}const yt=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.chartTitle="",this.scenarios=[],this.variances=[],this.hideCategories=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.i18n=new Map,this.order={hierarchy:[],direction:b.ASC},this.level=c.CATEGORY,this.filter="",this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.parentDimensions={width:0,height:0},G(this)}getDb(){return this.stores||(this.stores=Y(this.element)),this.stores.db.db}render(){var t,i,e,n;if(void 0===this.chart||void 0!==this.queryError)return s(h,null);if(this.chart.hasNoData()){const i=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return s(h,{class:"no-data"},s("div",{class:"empty-state"},i))}return s(h,null,s("div",{innerHTML:null===(i=this.pattern)||void 0===i?void 0:i.toString(),class:"hidePatternContainer",style:{width:"0",height:"0",overflow:"hidden"}}),s("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(e=this.chart)||void 0===e?void 0:e.getFooter()),s("div",{innerHTML:null===(n=this.chart)||void 0===n?void 0:n.toString()}))}syncQueryError(){var t,i;this.queryError=null!==(t=this.measureScaleError)&&void 0!==t?t:null===(i=this.chart)||void 0===i?void 0:i.getQueryError(),F(this.errors,this.queryError)}async componentWillLoad(){var t;const i=this.getDb(),s=this.prepareConfig(),h=this.prepareStyle();this.chart=new Pt(new y(this.ruleSetConfig),i,this.tableName,s,h),this.chart.setI18n(this.i18n);const e=s.pixelPerUnit<=0;this.autoFitScaling(s,h),this.chart.setAvailableWidth(e?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new q(this.chart.styles),this.chart.setPattern("hatched",this.pattern.getFCPolygonPattern()),this.syncQueryError()}async componentWillUpdate(){var t;if(null==this.chart)return;const i=this.prepareConfig(),s=this.prepareStyle();this.chart.setI18n(this.i18n),this.chart.setStyles(s),this.chart.setRuleSet(new y(this.ruleSetConfig)),this.chart.setConfig(i);const h=i.pixelPerUnit<=0;this.autoFitScaling(i,s),this.chart.setAvailableWidth(h?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new q(this.chart.styles),this.chart.setPattern("hatched",this.pattern.getFCPolygonPattern()),this.syncQueryError()}autoFitScaling(t,i){var s;const h=t.pixelPerUnit<=0,e=t.pixelPerPercentage<=0;if(!h&&!e)return;const n=()=>{var i;null===(i=this.reportAutoScaling)||void 0===i||i.call(this,{unit:h?t.pixelPerUnit:void 0,percentage:e?t.pixelPerPercentage:void 0})},r=null===(s=this.parentDimensions)||void 0===s?void 0:s.width,o=this.getDb(),a=()=>{this.chart=new Pt(new y(this.ruleSetConfig),o,this.tableName,t,i),this.chart.setI18n(this.i18n)},l=()=>(this.chart.layout(),this.chart.getAllocatedCanvasWidth());if(!r||r<=0)return h&&(t.pixelPerUnit=1),e&&(t.pixelPerPercentage=50),a(),void n();h&&(t.pixelPerUnit=1),e&&(t.pixelPerPercentage=1),a();let c=l();if(c<=0)return void n();const u=Math.max(X,.9*r/c);let d=!1,f=!1,p=null;for(let i=0;i<=3;i++){const i=j({target:r,measured:c,unitExtent:h?this.chart.getUnitBarExtent():0,pctExtent:e?this.chart.getPercentBarExtent():0,currentPpu:t.pixelPerUnit,currentPpp:t.pixelPerPercentage});if(void 0===i.ppu&&void 0===i.ppp)break;if(h&&void 0!==i.ppu&&(t.pixelPerUnit=i.ppu,d=!0),e&&void 0!==i.ppp&&(t.pixelPerPercentage=i.ppp,f=!0),a(),c=l(),c<=r+.5&&(p={ppu:t.pixelPerUnit,ppp:t.pixelPerPercentage},c>=.98*r))break}let v=!1;if(h&&!d&&(t.pixelPerUnit=u,v=!0),e&&!f&&(t.pixelPerPercentage=u,v=!0),c>r+.5){if(p)d&&(t.pixelPerUnit=p.ppu),f&&(t.pixelPerPercentage=p.ppp);else{const i=r/c;h&&(t.pixelPerUnit=Math.max(X,t.pixelPerUnit*i)),e&&(t.pixelPerPercentage=Math.max(X,t.pixelPerPercentage*i))}v=!0}v&&a(),n()}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){const t=this.getDb(),i=V(t,this.tableName,this.filter);return this.measureScaleError=void 0,new nt(new at,new v(new H),new H,new p,t,i,(t=>{this.measureScaleError=z(t)})).adapt({scenarios:this.scenarios,variances:this.variances,title:this.chartTitle,hideCategories:this.hideCategories,pixelPerUnit:this.pixelPerUnit,pixelPerPercentage:this.pixelPerPercentage,level:this.level,limit:this.limit,sortOrder:this.order,filter:this.filter,measureScale:this.measureScale,measureUnit:this.measureUnit,showMeasureScale:this.showMeasureScale,dataFormatDigits:this.dataFormatDigits,stackConfig:this.stackConfig})}prepareStyle(){var t,i;const s=new ct(new dt,new r,new o(new A),new U(new A),new a).adapt(this.styles);return s.locale=(null===(i=null===(t=Y(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}get element(){return this}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}svg#drawCanvas{display:block}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}'}},[1,"bn-chart-structure-renderer",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],chartTitle:[1,"chart-title"],scenarios:[16],variances:[16],hideCategories:[4,"hide-categories"],pixelPerUnit:[2,"pixel-per-unit"],pixelPerPercentage:[2,"pixel-per-percentage"],reportAutoScaling:[16],errors:[16],limit:[2],styles:[1040],i18n:[1040],order:[16],level:[1],filter:[1],measureScale:[1,"measure-scale"],measureUnit:[1,"measure-unit"],showMeasureScale:[4,"show-measure-scale"],dataFormatDigits:[16],stackConfig:[16],parentDimensions:[16],ruleSetConfig:[16]}]);function St(){"undefined"!=typeof customElements&&["bn-chart-structure-renderer"].forEach((t=>{"bn-chart-structure-renderer"===t&&(customElements.get(e(t))||customElements.define(e(t),yt))}))}export{yt as B,St as d}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{p as t,H as i,h as s,d as e,t as h}from"./p-BnmylmXF.js";import{g as n,d as r}from"./p-6242qMx1.js";import{A as a,C as o}from"./p-DguYWLBj.js";import{C as l,F as d,s as u,I as c}from"./p-CmvpJzLd.js";import{w as m}from"./p-BrQCbmG0.js";import{S as p,F as g,a as f,P as v}from"./p-CSJCkHEL.js";import{d as b,l as w,S as y}from"./p-DHX92KDP.js";import{S as $}from"./p-CJ0-xdfZ.js";import{e as M,r as S}from"./p-ClruFZD_.js";import{O as x}from"./p-BBdzTx8V.js";import{N as j}from"./p-BJmwHV0a.js";import{s as E}from"./p-Xb6Ilq8u.js";import{B as C}from"./p-JofGXz75.js";class N{constructor(t,i,s,e,h,n){this.ruleSet=t,this.config=e,this.styles=h,this.availableWidth=n,this.rows=[],this.warnings=[],this.i18nMap=new Map,this.populateModel(i,s),this.normalized="target"===this.config.normalize&&this.rows.some((t=>null!==t.fraction)),null!==this.config.target&&this.rows.length>0&&!this.rows.some((t=>null!==t.target))&&this.warnings.push({code:"bullet-target-none",data:{}})}populateModel(t,i){var s,e,h;if(""===i)return;const n=this.config.level,r=this.config.order,a=this.config.actual.measure,o=null!==(e=null===(s=this.config.target)||void 0===s?void 0:s.measure)&&void 0!==e?e:null,l="transformOperator(operation)",d=[a,...null!==o?[o]:[]].map((t=>`CASE WHEN MIN(${l}) = MAX(${l}) THEN SUM(${t}) ELSE SUM(${t} * ${l}) END as ${t}, SUM(ABS(${t})) as ${t}_gross, COUNT(ISNULL(${t})) as ${t}_cnt`)).join(", ");let u;try{u=t.exec(`SELECT ${this.createSelectString(n,r)}, ${d},\n MIN(transformOperator(operation)) as opMin, MAX(transformOperator(operation)) as opMax\n FROM ${i}\n GROUP BY ${this.createGroupByStr(n,r)}\n ORDER BY ${this.createOrderStr(n,r)}`)}catch(t){return void(this.queryError=M(t))}let c=null!=u?u:[];this.config.limit>0&&(c=c.slice(0,this.config.limit));let m=0,p=0,g=0,f=0;for(const t of c){const i="number"==typeof t.opMin?t.opMin:1,s="number"==typeof t.opMax?t.opMax:1;let e=-1===i&&-1===s?"-":"+";i!==s&&(e="+",m++);const n=this.readValue(t,a),r=null!==o?this.readValue(t,o):null;null!==n&&n<0&&f++;let l=null;"target"===this.config.normalize&&(null===r?null!==o&&p++:r<=0?g++:null!==n&&n>=0&&(l=n/r)),this.rows.push({category:String(null!==(h=t.category)&&void 0!==h?h:""),actual:n,target:r,operation:e,sentiment:this.sentiment(n,r,e),fraction:l})}m>0&&this.warnings.push({code:"bullet-mixed-operation",data:{count:String(m)}}),p>0&&this.warnings.push({code:"bullet-target-missing",data:{count:String(p)}}),g>0&&this.warnings.push({code:"bullet-target-invalid",data:{count:String(g)}}),f>0&&this.warnings.push({code:"bullet-actual-negative",data:{count:String(f)}})}readValue(t,i){if(0===t[`${i}_cnt`])return null;const s=t[i],e=t[`${i}_gross`];return"number"==typeof s&&"number"==typeof e&&Math.abs(s)<=1e-9*e?0:"number"==typeof s&&isFinite(s)?s:null}sentiment(t,i,s){return null===t||null===i||t===i?"neu":t>i!=("-"===s)?"pos":"neg"}createSelectString(t,i){return t===a.CATEGORY&&i.hierarchy.includes(x.CATEGORYINDEX)?`${x.CATEGORYINDEX}, ${a.CATEGORY} as category`:t===a.ROWGROUP&&i.hierarchy.includes(x.ROWGROUPINDEX)?`${x.ROWGROUPINDEX}, ${a.ROWGROUP} as category`:t===a.SUBCATEGORY&&i.hierarchy.includes(x.SUBCATEGORYINDEX)?`${x.SUBCATEGORYINDEX}, ${a.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===a.CATEGORY&&i.hierarchy.includes(x.CATEGORYINDEX)?`${x.CATEGORYINDEX}, ${a.CATEGORY}`:t===a.ROWGROUP&&i.hierarchy.includes(x.ROWGROUPINDEX)?`${x.ROWGROUPINDEX}, ${a.ROWGROUP}`:t===a.SUBCATEGORY&&i.hierarchy.includes(x.SUBCATEGORYINDEX)?`${x.SUBCATEGORYINDEX}, ${a.SUBCATEGORY}`:`${t.toString()}`}createOrderStr(t,i){let s=`${t.toLowerCase()}`;return i.hierarchy.length>=1&&(s=i.hierarchy.map((t=>`${t} ${i.direction}`)).toString()),s}get em(){return this.styles.fontStyles.size}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,i=!1){const s=l(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:i?"bold":"normal"}).width;return Number.isFinite(s)&&s>0?s:.6*t.length*this.em}drawText(t,i,s,e,h={}){var n,r,a;return t.text(i).font({size:null!==(n=h.size)&&void 0!==n?n:this.styles.fontStyles.size,weight:h.bold?"bold":"normal",anchor:null!==(r=h.anchor)&&void 0!==r?r:"start"}).fill(null!==(a=h.color)&&void 0!==a?a:this.styles.fontStyles.color).attr({x:s,y:e,"font-family":this.fontFamily()})}setI18n(t){this.i18nMap=t}hasNoData(){return 0===this.rows.length}getWarnings(){return this.warnings}getQueryError(){return this.queryError}getAllocatedCanvasWidth(){return this.availableWidth}getAllocatedCanvasHeight(){return this.styles.padding.top+this.titleHeight()+this.headerHeight()+this.rows.length*this.rowBlockHeight()+this.styles.padding.bottom}titleHeight(){return""!==this.config.chartTitle?1.6*this.em:0}headerHeight(){return this.rows.length>0?1.2*this.em:0}rowBlockHeight(){const t=this.em,i=this.styles.scaleFactors.rowHeight*t;return this.normalized?i:i+this.styles.scaleFactors.tickStripHeight*t}valueLabel(t){return null===t||"none"===this.config.labels.show?"":d.number(t,"decimal",this.config.labels.decimals,0,1,this.styles.locale)}targetFamily(){var t,i;const s=null!==(i=null===(t=this.config.target)||void 0===t?void 0:t.measure)&&void 0!==i?i:"pl1";return u(this.ruleSet.getScenarioColorIndex(s))}actualLabel(){var t;return null!==(t=this.config.actual.label)&&void 0!==t?t:d.translateScenarioLabel(this.config.actual.measure,this.i18nMap)}targetLabel(){return null===this.config.target?"":void 0!==this.config.target.label?this.config.target.label:this.normalized?this.i18nMap.get("target")||"Target":d.translateScenarioLabel(this.config.target.measure,this.i18nMap)}toString(){const t=new p;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}draw(t){var i,s;const e=this.em,h=this.styles.scaleFactors,n=this.styles.padding,r=t.group();if(""!==this.config.chartTitle&&this.drawText(r,this.config.chartTitle,n.left,n.top+e,{bold:!0}),0===this.rows.length)return void t.group().addClass("annotations");const a=h.rowHeight*e,o=this.rowBlockHeight(),l=n.top+this.titleHeight()+this.headerHeight(),d=l+(this.rows.length-1)*o+a,u=Math.max(...this.rows.map((t=>this.textWidth(t.category,!0))),e),c=this.rows.map((t=>this.valueLabel(t.actual))),m="none"===this.config.labels.show?0:Math.max(...c.map((t=>this.textWidth(t))),0),p=n.left+u+h.labelToAxis*e,g=Math.max(10,this.availableWidth-p-n.right-m-(m>0?h.labelToBar*e:0)),f=null!==(i=this.config.actual.unit)&&void 0!==i?i:null===(s=this.config.target)||void 0===s?void 0:s.unit,v=this.i18nMap.get("axis.in")||"in",b=l-.35*e;void 0!==f&&""!==f&&this.drawText(r,`${v} ${f}`,n.left,b,{}),this.drawText(r,this.actualLabel(),p+.2*e,b,{}),this.normalized?this.drawNormalized(r,p,g,l,d,a,o,c):this.drawClassic(r,p,g,l,a,o,c),this.rows.forEach(((t,i)=>{this.drawText(r,t.category,p-h.labelToAxis*e,l+i*o+a/2+.35*e,{anchor:"end",bold:!0})})),r.line(p,l-.2*e,p,d+.2*e).stroke({color:this.styles.axisStyles.ac.stroke,width:E(h.axisLineWidth,this.em)}).attr(C,"axis"),t.group().addClass("annotations")}drawNormalized(t,i,s,e,h,n,r,a){const o=this.em,l=this.styles.scaleFactors,d=1.05*Math.max(1,...this.rows.map((t=>{var i;return null!==(i=t.fraction)&&void 0!==i?i:0}))),u=t=>i+t/d*s,c=u(1),m=this.styles.barStyles.getSVGStyle(this.targetFamily()),p=t.line(c,e-.3*o,c,h+.3*o).stroke({color:m.stroke,width:E(l.targetLineWidth,this.em)});void 0!==m.dasharray&&p.attr("stroke-dasharray",m.dasharray),this.drawText(t,this.targetLabel(),c,e-.35*o,{anchor:"middle",bold:!0}),this.rows.forEach(((s,h)=>{const d=e+h*r+n/2;if(null===s.fraction)return void this.drawValueText(t,a[h],i+l.labelToBar*o,d,s);const m=l.barHeight*o,p=u(s.fraction);if(t.rect(Math.max(0,p-i),m).move(i,d-m/2).fill(this.styles.barStyles.ac.fill).stroke({color:this.styles.barStyles.ac.stroke,width:this.styles.barStyles.ac.width}).attr(b(this.rowKey(s),"element")).attr("data-bn-index",String(h)),this.config.showVariances&&"neu"!==s.sentiment){const i=l.varianceHeight*o,e=this.styles.varianceStyles.getSVGStyle(s.sentiment);t.rect(Math.abs(p-c),i).move(Math.min(p,c),d-i/2).fill(e.fill).stroke({color:e.stroke,width:e.width})}this.drawValueText(t,a[h],Math.max(p,c)+l.labelToBar*o,d,s)}))}drawClassic(t,i,s,e,h,n,r){const a=this.em,o=this.styles.scaleFactors,l=o.barHeight*a,u=this.config.ranges.length>0;this.rows.forEach(((c,m)=>{var p,g;const f=e+m*n,v=f+h/2,w=u&&null!==c.target?this.config.ranges.map((t=>t*c.target)):[],y=Math.max(null!==(p=c.actual)&&void 0!==p?p:0,null!==(g=c.target)&&void 0!==g?g:0,...w);if(y<=0)return void this.drawValueText(t,r[m],i+o.labelToBar*a,v,c);const $=j.niceStep(y,4),M=Math.ceil(y/$-1e-9*$)*$,S=new j(0,M,i,i+s);let x=i;w.forEach(((i,s)=>{const e=.8*h;t.rect(Math.max(0,S.scale(i)-x),e).move(x,v-e/2).fill(this.styles.rangeColors[Math.min(s,this.styles.rangeColors.length-1)]).stroke("none"),x=S.scale(i)}));let C=i;if(null!==c.actual&&c.actual>0){const s=S.scale(c.actual);t.rect(s-i,l).move(i,v-l/2).fill(this.styles.barStyles.ac.fill).stroke({color:this.styles.barStyles.ac.stroke,width:this.styles.barStyles.ac.width}).attr(b(this.rowKey(c),"element")).attr("data-bn-index",String(m)),C=s}if(null!==c.target&&c.target>0){const i=S.scale(c.target),s=o.targetTickHeight*a,h=this.styles.barStyles.getSVGStyle(this.targetFamily()),n=t.line(i,v-s/2,i,v+s/2).stroke({color:h.stroke,width:E(o.targetLineWidth,this.em)});void 0!==h.dasharray&&n.attr("stroke-dasharray",h.dasharray),0===m&&this.drawText(t,this.targetLabel(),i,e-.35*a,{anchor:"middle"}),C=Math.max(C,i)}C=Math.max(C,x),this.drawValueText(t,r[m],C+o.labelToBar*a,v,c);const N=S.ticks(4),z=j.tickDecimals(N),B=f+h;for(const i of N){const s=S.scale(i);t.line(s,B,s,B+o.axisTickLength*a).stroke({color:this.styles.axisStyles.ac.stroke,width:E(o.axisLineWidth,this.em)}),this.drawText(t,d.number(i,"decimal",z,z,1,this.styles.locale),s,B+o.tickStripHeight*a-.2*a,{anchor:"middle"})}}))}drawValueText(t,i,s,e,h){""!==i&&this.drawText(t,i,s,e+.35*this.em,{}).attr(b(this.rowKey(h),"label"))}rowKey(t){return Object.assign(Object.assign({},w(this.config.level,t.category)),{scenario:this.config.actual.measure})}}class z{constructor(){this.rowHeight=1.9,this.barHeight=.66,this.varianceHeight=.4,this.targetTickHeight=1.1,this.targetLineWidth=.15,this.axisLineWidth=.075,this.labelToBar=.3,this.labelToAxis=.3,this.axisTickLength=.35,this.tickStripHeight=1.2}}class B{adapt(t){const i=new z;return o.isNumber(t.rowHeight)&&(i.rowHeight=t.rowHeight),o.isNumber(t.barHeight)&&(i.barHeight=t.barHeight),o.isNumber(t.varianceHeight)&&(i.varianceHeight=t.varianceHeight),o.isNumber(t.targetTickHeight)&&(i.targetTickHeight=t.targetTickHeight),o.isNumber(t.targetLineWidth)&&(i.targetLineWidth=t.targetLineWidth),o.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),o.isNumber(t.labelToBar)&&(i.labelToBar=t.labelToBar),o.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),o.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),o.isNumber(t.tickStripHeight)&&(i.tickStripHeight=t.tickStripHeight),i}default(){return new z}}class D{constructor(t,i,s,e,h,n){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=e,this.varianceStyles=h,this.padding=n,this.rangeColors=["#D9D9D9","#EFEFEF"],this.locale="de"}}class L{constructor(t,i,s,e,h){this.scaleFactorsBulletChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=e,this.paddingAdapter=h}adapt(t){const i=this.default();return o.isExisting(t)&&(o.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsBulletChartAdapter.adapt(t.scaleFactors)),o.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),o.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),o.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),o.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),o.isExisting(t.padding)&&(i.padding=this.paddingAdapter.adapt(t.padding)),Array.isArray(t.rangeColors)&&t.rangeColors.length>0&&(i.rangeColors=t.rangeColors)),i}default(){return new D(this.scaleFactorsBulletChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingAdapter.default())}}const F=["bullet-target-missing","bullet-target-invalid","bullet-actual-negative","bullet-mixed-operation","bullet-target-none"],O=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.chartTitle="",this.target=null,this.ranges=[],this.normalizeMode="target",this.showVariances=!0,this.level=a.CATEGORY,this.limit=0,this.filter="",this.i18n=new Map,this.containerWidth=0,this.svgMarkup="",m(this)}getDb(){return this.stores||(this.stores=n(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=r(this.getDb(),this.tableName,this.filter);this.chart=new N(new c(this.ruleSetConfig),this.getDb(),i,{chartTitle:this.chartTitle,actual:this.actual,target:this.target,ranges:this.ranges,normalize:this.normalizeMode,showVariances:this.showVariances,level:this.level,order:this.order,limit:this.limit,labels:this.labels},t,this.containerWidth||0),this.chart.setI18n(this.i18n),this.svgMarkup=this.chart.hasNoData()?"":this.chart.toString(),this.syncWarnings(this.chart.getWarnings()),S(this.errors,this.chart.getQueryError())}syncWarnings(t){if(void 0===this.errors)return;const i=new Map(t.map((t=>[t.code,t.data])));for(const t of F){const s=`WARN_${t.replace(/-/g,"_")}`;if(i.has(t)){const e=void 0!==this.translator?this.translator(`.${t}`,i.get(t)):t;this.errors.addOrReplace({id:s,type:"warning",message:e})}else this.errors.remove(s)}}prepareStyle(){var t,i;const s=new L(new B,new g,new f(new y),new $(new y),new v).adapt(this.styles);return s.locale=(null===(i=null===(t=n(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}render(){var t;if(void 0===this.chart||void 0!==this.chart.getQueryError())return s(e,null);if(this.chart.hasNoData()){const i=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return s(e,{class:"no-data"},s("div",{class:"empty-state"},i))}return s(e,null,s("div",{innerHTML:this.svgMarkup}))}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}'}},[1,"bn-chart-bullet-renderer",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],chartTitle:[1,"chart-title"],actual:[16],target:[16],ranges:[16],normalizeMode:[1,"normalize-mode"],showVariances:[4,"show-variances"],level:[1],order:[16],limit:[2],labels:[16],filter:[1],styles:[16],i18n:[16],containerWidth:[2,"container-width"],ruleSetConfig:[16],errors:[16],translator:[16]}]);function W(){"undefined"!=typeof customElements&&["bn-chart-bullet-renderer"].forEach((t=>{"bn-chart-bullet-renderer"===t&&(customElements.get(h(t))||customElements.define(h(t),O))}))}export{O as B,W as d}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as t,g as n}from"./p-BrQCbmG0.js";import{m as o}from"./p-B2NXsfMz.js";class r{constructor(t){this.type="",this.base="",this.delta="",this.direction="",this.isValid=!1;const n=/(d|dr)(pl\d|ac\d|fc\d|pp\d)_(pl\d|ac\d|fc\d|pp\d)_(pos|neg|neu|opinv|op)/;if(n.test(t)){const o=n.exec(t);null!=o&&(this.type=String(o[1]),this.base=String(o[2]),this.delta=String(o[3]),this.direction=String(o[4]),this.isValid=!0)}}}function e(t,n,o){return"op"!==t&&"opinv"!==t?t:"op"===t!=(!o&&"-"===n)?"pos":"neg"}function i(t){const n=[];for(const o of t){const t=new r(o);for(const o of t.isValid?[t.base,t.delta]:[])n.includes(o)||n.push(o)}return n}const s=["ac","pp","fc","pl"],c={10:"ac",20:"pp",30:"fc",50:"pl"};function a(t){var n;return null!==(n=c[t])&&void 0!==n?n:"ac"}function u(t,n){const o=s.map((t=>a(n.getScenarioColorIndex(`${t}1`))));if(o.every(((t,n)=>t===s[n])))return t;const r=Object.assign(Object.create(Object.getPrototypeOf(t)),t);return s.forEach(((n,e)=>{r[n]=t[o[e]]})),r}function l(t){var n,o;const r=new Map;for(const e of s){const i=null===(o=null===(n=null==t?void 0:t.scenarios)||void 0===n?void 0:n[e])||void 0===o?void 0:o.name;if(i)for(const t of[1,2,3,4])r.set(`${e}${t}`,1===t?i:`${i}${t}`)}return r}class p{constructor(n){this._dateFormat={year:"YYYY",quarter:"Q[Q] YYYY",month:"MMM YYYY",locale:"[KW]WW YYYY",day:"DD.MM.YYYY"},this._dateLinkFormat={avg:"Ø[DATE]",interval:"[DATE]..[DATE]",start:".[DATE]",end:"[DATE].",ytd:"_[DATE]",ytg:"[DATE]_",cum:"[DATE]_[DATE]",mat:"~[DATE]",none:"[DATE]"},this._scenarioMap=new Map;const r=o([t,null!=n?n:{}]);Object.entries(r.scenarios).forEach((([t,n])=>{var o,r,e;this.createScenarioMapEntry(t,null!==(o=n.name)&&void 0!==o?o:t,null!==(r=n.colorIndex)&&void 0!==r?r:10,null!==(e=n.sortIndex)&&void 0!==e?e:0)})),this._fallBackScenario=r.fallback}createScenarioMapEntry(t,n,o,r){const e=n,i=o;[1,2,3,4].forEach((o=>{this._scenarioMap.set(t+o,{name:n+o,group:e,colorIndex:i,sortIndex:r+10*o})}))}getScenario(t){return this._scenarioMap.has(t)?this._scenarioMap.get(t):this._fallBackScenario}getScenarioGroup(t){return this._scenarioMap.has(t)?this._scenarioMap.get(t).name:this._fallBackScenario.name}getScenarioColorIndex(t){return this._scenarioMap.has(t)?this._scenarioMap.get(t).colorIndex:this._fallBackScenario.colorIndex}getScenarioSorIndex(t){const n=this.normalizeVarianceScenario(t);return this._scenarioMap.has(n)?this._scenarioMap.get(n).sortIndex:this._fallBackScenario.sortIndex}normalizeVarianceScenario(t){if(null==t)return"";const n=new r(t);return n.isValid?n.type+n.delta:t}}var d,f,h={},m=n(function(){if(d)return h;d=1;var t={};return Object.defineProperty(h,"__esModule",{value:!0}),h.default=function(n,o){void 0===o&&(o={});var r=JSON.stringify({text:n,options:o});if(t[r])return t[r];o.font=o.font||"Times",o.fontSize=o.fontSize||"16px",o.fontWeight=o.fontWeight||"normal",o.width=o.width||"auto";var e=function(t,n){var o=document.createElement("div"),r=document.createTextNode(t);return o.appendChild(r),o.style.fontFamily=n.font,o.style.fontSize=n.fontSize,o.style.fontWeight=n.fontWeight,o.style.position="absolute",o.style.visibility="hidden",o.style.left="-999px",o.style.top="-999px",o.style.width=n.width,o.style.height="auto",document.body.appendChild(o),o}(n,o),i={width:e.offsetWidth,height:e.offsetHeight};return function(t){t.parentNode.removeChild(t)}(e),t[r]=i,i},h}());!function(t){t.OPERATION="operation",t.ROWGROUP="rowGroup",t.ROWGROUPINDEX="rowGroupIndex",t.CURRENTROW="currentRow",t.CATEGORY="category",t.CATEGORYINDEX="categoryIndex",t.SUBCATEGORY="subCategory",t.SUBCATEGORYINDEX="subCategoryIndex",t.COLUMNGROUP="columnGroup",t.COLUMNGROUPINDEX="columnIndex",t.COLUMNSUBGROUP="columnSubGroup",t.COLUMNSUBGROUPINDEX="columnSubGroupIndex",t.AC1="ac1",t.AC2="ac2",t.AC3="ac3",t.AC4="ac4",t.PP1="pp1",t.PP2="pp2",t.PP3="pp3",t.PP4="pp4",t.FC1="fc1",t.FC2="fc2",t.FC3="fc3",t.FC4="fc4",t.PL1="pl1",t.PL2="pl2",t.PL3="pl3",t.PL4="pl4",t.TOTALROWCOUNT="totalRowCnt",t.ROWNR="rowNr",t.TYPE="type"}(f||(f={}));class v{static number(t,n="decimal",o=1,r=0,e=1,i="de"){const s=`${i}|${n}|${o}|${r}`;let c=this.formats.get(s);if(!c){const t={style:n,useGrouping:!0,maximumFractionDigits:o,minimumFractionDigits:r};try{c=new Intl.NumberFormat([i,"de-DE"],t)}catch(n){c=new Intl.NumberFormat("de-DE",t)}this.formats.set(s,c)}const a=c.format(t/e);return(a===c.format(-0)?c.format(0):a).replace(/\s+(%)/g,"$1")}static translateScenarioLabel(t,n){if(null==t)return"";const o=new r(t);if(!o.isValid)return`${n.get(t)||t}`;let e,i;return f.AC1===o.base?(e=n.get("dr"===o.type?"ibcssymbol_delta_ac_relative":"ibcssymbol_delta_ac"),i=n.get(o.delta)||o.delta):(e=n.get("dr"===o.type?"ibcssymbol_delta_generic_relative":"ibcssymbol_delta_generic"),i=`${n.get(o.base)||o.base} - ${n.get(o.delta)||o.delta}`),void 0===e&&(e="{%}"),`${e.replace("{%}",i)}`}static getMaxWidthOfArrayItems(t,n,o){return m(t.map((t=>v.translateScenarioLabel(t,n))).reduce(((t,n)=>t.length<n.length?n:t),""),{font:o.fontStyles.font,fontSize:o.fontStyles.size+"px"}).width}}v.formats=new Map;export{m as C,v as F,p as I,f as Q,r as V,e as a,u as b,l as r,a as s,i as v}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{p as t,H as s,h as i,d as n,t as e}from"./p-BnmylmXF.js";import{r as h,m as o,g as r,d as a}from"./p-6242qMx1.js";import{C as l,I as d}from"./p-CmvpJzLd.js";import{w as c}from"./p-BrQCbmG0.js";import{e as u,r as m}from"./p-ClruFZD_.js";import{S as v,F as f,a as p,P as w}from"./p-CSJCkHEL.js";import{d as y,S as g}from"./p-DHX92KDP.js";import{X as x,r as b,a as M,x as $,f as L,b as S,c as j,P as C,F as P,d as k,S as T}from"./p-Blre9f28.js";import{N as W}from"./p-BJmwHV0a.js";import{a as D,r as z,i as E}from"./p-YSRTB0jS.js";import{s as N}from"./p-Xb6Ilq8u.js";class B{constructor(t,s){this.xScale=t,this.yScale=s}isPositiveDomain(){return this.xScale.domainMin>0&&this.yScale.domainMin>0}static autoK(t){const s=t.filter((t=>t>0)).sort(((t,s)=>t-s));if(0===s.length)return[];const i=t=>s[Math.min(s.length-1,Math.floor(t*s.length))];let n=B.ladderValues(i(.25),i(.75));if(n.length<2&&(n=B.ladderValues(s[0],s[s.length-1])),0===n.length)return[];if(1===n.length)return n;if(n.length<=4)return n;const e=[];for(let t=0;t<4;t++)e.push(n[Math.round(t*(n.length-1)/3)]);return[...new Set(e)]}static ladderValues(t,s){if(t<=0||s<t)return[];const i=[];for(let n=Math.floor(Math.log10(t))-1;n<=Math.ceil(Math.log10(s));n++)for(const e of[1,2,5]){const h=e*Math.pow(10,n);h>=t&&h<=s&&i.push(h)}return i}visibleRange(t){if(!this.isPositiveDomain()||t<=0)return null;const s=Math.max(this.xScale.domainMin,t/this.yScale.domainMax),i=Math.min(this.xScale.domainMax,t/this.yScale.domainMin);return s>=i?null:[s,i]}samples(t){const s=this.visibleRange(t);if(null===s)return null;const[i,n]=s,e=[];for(let s=0;s<64;s++){const h=i*Math.pow(n/i,s/63);e.push({x:this.xScale.scale(h),y:this.yScale.scale(t/h)})}return e}path(t){const s=this.samples(t);return null===s?null:s.map(((t,s)=>`${0===s?"M":"L"} ${t.x} ${t.y}`)).join(" ")}exitPoint(t){const s=this.visibleRange(t);if(null===s)return null;const i=s[1],n=i>=this.xScale.domainMax-1e-9*Math.abs(this.xScale.domainMax);return{x:this.xScale.scale(i),y:this.yScale.scale(t/i),edge:n?"right":"bottom"}}regionPath(t){if(!this.isPositiveDomain()||t<=0)return null;const s=this.xScale.domainMin,i=this.xScale.domainMax,n=this.yScale.domainMin,e=this.yScale.domainMax,h=this.xScale.scale(s),o=this.xScale.scale(i),r=this.yScale.scale(e),a=this.yScale.scale(n);if(t>=i*e)return null;if(t<=s*n)return`M ${h} ${r} L ${o} ${r} L ${o} ${a} L ${h} ${a} Z`;const l=this.samples(t),[d,c]=this.visibleRange(t),u=d>s,m=c>=i-1e-9*Math.abs(i),v=l.map(((t,s)=>`${0===s?"M":"L"} ${t.x} ${t.y}`));return m||v.push(`L ${o} ${a}`),v.push(`L ${o} ${r}`),u||v.push(`L ${h} ${r}`),v.push("Z"),v.join(" ")}}class F{constructor(t,s,i,n,e,h){var o,r;this.ruleSet=t,this.config=n,this.styles=e,this.availableWidth=h,this.warnings=[],this.canvasHeight=0,this.i18nMap=new Map,this.config=Object.assign(Object.assign({},n),{x:D(n.x),y:D(n.y)});const a=new x;let l=[];try{""!==i&&(l=s.exec(`SELECT * FROM ${i}`))}catch(t){this.queryError=u(t)}const d=(null!=l?l:[]).map((t=>a.adapt(t)));this.data=b(d,{pointLevel:n.pointLevel,seriesLevel:n.seriesLevel,facetLevel:null!==n.facet?"rowgroup"===n.facet.level?"rowGroup":"category":null,measures:{x:null!==(o=z(n.x.measure))&&void 0!==o?o:{kind:"scenario",slot:"ac1"},y:null!==(r=z(n.y.measure))&&void 0!==r?r:{kind:"scenario",slot:"ac2"}},domains:{x:{min:this.config.x.min,max:this.config.x.max},y:{min:this.config.y.min,max:this.config.y.max}},limit:n.limit,limitBy:"order"}),this.warnings.push(...this.data.warnings)}get em(){return this.styles.fontStyles.size}get xPercent(){return E(this.config.x.measure)}get yPercent(){return E(this.config.y.measure)}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,s=!1){const i=l(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:s?"bold":"normal"}).width;return Number.isFinite(i)&&i>0?i:.6*t.length*this.em}drawText(t,s,i,n,e={}){var h,o,r;return t.text(s).font({size:null!==(h=e.size)&&void 0!==h?h:this.styles.fontStyles.size,weight:e.bold?"bold":"normal",anchor:null!==(o=e.anchor)&&void 0!==o?o:"start"}).fill(null!==(r=e.color)&&void 0!==r?r:this.styles.fontStyles.color).attr({x:i,y:n,"font-family":this.fontFamily()})}hasNoData(){return 0===this.data.totalPoints}getWarnings(){return this.warnings}getQueryError(){return this.queryError}getAllocatedCanvasWidth(){return this.availableWidth}getAllocatedCanvasHeight(){return this.canvasHeight}axisTitle(t,s){var i;const n=null!==(i=t.label)&&void 0!==i?i:"";return""===n?"":void 0===t.unit||""===t.unit?n:`${n} ${s} ${t.unit}`}setI18n(t){this.i18nMap=t}legendModel(){const t=this.data.series.map((t=>{var s;return{label:""===t.key?null!==(s=this.ruleSet.getScenario("").name)&&void 0!==s?s:"Series":t.key,treatment:this.seriesTreatment(t.index)}}));return{sizeCaption:[],title:this.i18nMap.get("legend.title")||null,compareEntries:[],entries:t}}primaryColorIndex(){const t=z(this.config.x.measure);return null===t||"variance"===t.kind?10:this.ruleSet.getScenarioColorIndex(t.slot)}seriesTreatment(t){const{color:s,overflowed:i}=h(t,this.styles.seriesColors);return i&&this.addWarningOnce("xy-series-overflow",{}),o(this.primaryColorIndex(),s,"dot")}addWarningOnce(t,s){this.warnings.some((s=>s.code===t))||this.warnings.push({code:t,data:s})}toString(){const t=new v;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}draw(t){var s,i,n,e,h,o,r,a,l,d;this.warnings=this.data.warnings.slice();const c=this.em,u=this.styles.padding,m=this.i18nMap.get("axis.in")||"in",v=t.group(),f=new M(this.styles),p=this.legendModel(),w=this.config.legend.show&&p.entries.length>0,y=w?f.measure(p,this.config.legend.position):{width:0,height:0},g=null!==this.config.iso,x=g?Math.max(3*c,...this.isoValueLabels().map((t=>this.textWidth(t)+c)),this.textWidth(null!==(s=this.config.iso.label)&&void 0!==s?s:"",!0)+c,this.textWidth(void 0!==this.config.iso.unit&&""!==this.config.iso.unit?`${m} ${this.config.iso.unit}`:"")+c):0,b="right"===this.config.legend.position?Math.max(w?y.width+c:0,x):x,S=""!==this.config.chartTitle?1.6*c:0,j=this.axisTitle(this.config.y,m),C=this.axisTitle(this.config.x,m),k=""!==j?1.4*c:.4*c,T=1.4*c+(""!==C?1.3*c:0);let D,z=3*c,E={x:0,y:0,width:0,height:0},N=[];const B=Math.max(1,this.data.facets.length),F=null===(i=this.config.facet)||void 0===i?void 0:i.columns,X=W.domain(null!==(e=null===(n=this.data.extents)||void 0===n?void 0:n.xMin)&&void 0!==e?e:0,null!==(o=null===(h=this.data.extents)||void 0===h?void 0:h.xMax)&&void 0!==o?o:1,{min:this.config.x.min,max:this.config.x.max}),H=W.domain(null!==(a=null===(r=this.data.extents)||void 0===r?void 0:r.yMin)&&void 0!==a?a:0,null!==(d=null===(l=this.data.extents)||void 0===l?void 0:l.yMax)&&void 0!==d?d:1,{min:this.config.y.min,max:this.config.y.max});for(let t=0;t<2;t++){const t=Math.max(10,this.availableWidth-u.left-u.right-z-b);E={x:u.left+z,y:u.top+S+k,width:t,height:t/this.config.aspect},D=new P(B,F,E,this.styles.scaleFactors.panelGap*c);const s=D.panelRect(0).height,i=Math.max(4,Math.min(8,Math.round(s/(4*c)))),n=new W(H[0],H[1],s,0);N=n.ticks(i);const e=$(N,this.yPercent);z=Math.max(...N.map((t=>this.textWidth(L(t,e,this.styles.locale,this.yPercent)))),c)+this.styles.scaleFactors.axisTickLength*c+.4*c}this.canvasHeight=E.y+E.height+T+("bottom"===this.config.legend.position&&w?y.height+c:0)+u.bottom,""!==this.config.chartTitle&&this.drawText(v,this.config.chartTitle,u.left,u.top+c,{bold:!0}),""!==j&&this.drawAxisTitleText(v,this.config.y,m,u.left,E.y-.6*c,"start");const I=this.buildPanels(D,X,H),V=I[0].xScale.ticks(Math.max(3,Math.min(8,Math.round(I[0].rect.width/(7*c))))),A=$(V,this.xPercent),O=$(N,this.yPercent);let R=!1;g&&(X[0]>0&&H[0]>0?R=!0:this.addWarningOnce("xy-iso-domain",{})),0===this.data.facets.length?this.drawPanel(v,I[0],{key:"",points:[]},V,N,A,O,!0,!0,R):this.data.facets.forEach(((t,s)=>{this.drawPanel(v,I[s],t,V,N,A,O,D.isOuterLeft(s),D.isOuterBottom(s),R,this.data.facets.length>1?t.key:"")})),""!==C&&this.drawAxisTitleText(v,this.config.x,m,E.x+E.width,E.y+E.height+2.6*c,"end"),w&&("right"===this.config.legend.position?f.draw(v,p,E.x+E.width+c,E.y,"right"):f.draw(v,p,E.x,E.y+E.height+T,"bottom")),t.group().addClass("annotations")}drawAxisTitleText(t,s,i,n,e,h){var o;const r=null!==(o=s.label)&&void 0!==o?o:"",a=void 0!==s.unit&&""!==s.unit?`${i} ${s.unit}`:"",l=.3*this.em;"start"===h?(this.drawText(t,r,n,e,{bold:!0}),""!==a&&this.drawText(t,a,n+this.textWidth(r,!0)+l,e,{})):""!==a?(this.drawText(t,a,n,e,{anchor:"end"}),this.drawText(t,r,n-this.textWidth(a)-l,e,{anchor:"end",bold:!0})):this.drawText(t,r,n,e,{anchor:"end",bold:!0})}buildPanels(t,s,i){const n=[];for(let e=0;e<t.count;e++){const h=t.panelRect(e),o=new W(s[0],s[1],h.x,h.x+h.width),r=new W(i[0],i[1],h.y+h.height,h.y);n.push({rect:h,xScale:o,yScale:r,frame:new S(o,r,h,this.styles)})}return n}drawPanel(t,s,i,n,e,h,o,r,a,l,d=""){var c,u;const m=t.group(),v=this.em;s.frame.drawBands(m,this.config.x.highlight,this.config.y.highlight),s.frame.drawGrid(m,e,void 0===this.config.x.refLine&&void 0===this.config.y.refLine&&s.rect.width>30*v?n:void 0),l&&null!==this.config.iso&&this.drawIso(m,s),s.frame.drawRefLines(m,this.config.x.refLine,this.config.y.refLine),s.frame.drawFrame(m);const f=this.styles.scaleFactors.pointRadius*v,p=new C(s.rect,this.styles.scaleFactors.labelToMark*v),w=[];for(const t of i.points){const n=null!==(u=null===(c=this.data.series.find((s=>s.key===t.seriesKey)))||void 0===c?void 0:c.index)&&void 0!==u?u:0,e=this.seriesTreatment(n),h=s.xScale.scale(t.x),o=s.yScale.scale(t.y);w.push({point:t,cx:h,cy:o,treatment:e});const r=m.circle(2*f).center(h,o).fill(e.fill).stroke({color:e.stroke,width:e.strokeWidth}).attr(y(j(t,i.key,this.config),"element"));void 0!==e.dasharray&&r.attr("stroke-dasharray",e.dasharray),p.registerMark(h,o,f)}this.drawPointLabels(m,p,w,f,i.key),s.frame.drawTickLabels(m,{ticksX:n,ticksY:e,xDecimals:h,yDecimals:o,xPercent:this.xPercent,yPercent:this.yPercent,showXLabels:a,showYLabels:r}),""!==d&&s.frame.drawPanelTitle(m,d)}drawPointLabels(t,s,i,n,e){const h=i.reduce(((t,s)=>t+s.cx),0)/Math.max(1,i.length),o=i.reduce(((t,s)=>t+s.cy),0)/Math.max(1,i.length),r=[...i].sort(((t,s)=>Math.hypot(s.cx-h,s.cy-o)-Math.hypot(t.cx-h,t.cy-o))),{selected:a,unknownNames:l}=s.selectCandidates(r,this.config.labels.points,this.config.labels.max,(t=>t.point.name));l.length>0&&this.addWarningOnce("xy-label-unknown",{names:l.join(", ")});const d=new Map,c=a.map((t=>{const s={name:t.point.name,cx:t.cx,cy:t.cy,r:n,width:this.textWidth(t.point.name),height:1.1*this.em};return d.set(s,t.point),s}));for(const i of s.place(c))this.drawText(t,i.candidate.name,i.x,i.y+.9*i.candidate.height,{}).attr(y(j(d.get(i.candidate),e,this.config),"label"))}drawIso(t,s){const i=this.config.iso,n=new B(s.xScale,s.yScale),e=this.i18nMap.get("axis.in")||"in",h=this.isoValues(),o=this.isoValueLabels();if(void 0!==i.highlight){const s=n.regionPath(i.highlight.from);null!==s&&t.path(s).fill(this.styles.axisStyles.pl.fill).stroke("none")}const r={color:this.styles.axisStyles.fc.stroke,width:N(this.styles.scaleFactors.gridLineWidth,this.em)};let a=null;for(const[s,i]of h.entries()){const e=n.path(i);if(null===e)continue;t.path(e).fill("none").stroke(r);const h=n.exitPoint(i);null!==h&&(this.drawText(t,o[s],h.x+.4*this.em,"right"===h.edge?h.y+.35*this.em:h.y-.5*this.em,{}),(null===a||h.y<a.y)&&(a=h))}if(null!==a&&void 0!==i.label&&""!==i.label){const s=void 0!==i.unit&&""!==i.unit?`${e} ${i.unit}`:"";this.drawText(t,i.label,a.x+.4*this.em,a.y-1.6*this.em,{bold:!0}),""!==s&&this.drawText(t,s,a.x+.4*this.em,a.y-.5*this.em,{})}}isoValues(){const t=this.config.iso;return"auto"!==t.values?t.values:B.autoK(this.data.facets.flatMap((t=>t.points.map((t=>t.x*t.y)))))}isoValueLabels(){const t=this.isoValues(),s=Math.max(0,...t.map((t=>W.stepDecimals(Math.abs(t)))));return t.map((t=>L(t,s,this.styles.locale)))}}const X=["xy-duplicate-point","xy-point-clipped","xy-variance-nodata","xy-iso-domain","xy-label-unknown","xy-series-overflow","xy-point-budget"],H=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.chartTitle="",this.iso=null,this.facet=null,this.pointLevel="category",this.seriesLevel=null,this.aspect=16/9,this.limit=0,this.filter="",this.i18n=new Map,this.containerWidth=0,this.svgMarkup="",c(this)}getDb(){return this.stores||(this.stores=r(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),s=a(this.getDb(),this.tableName,this.filter);this.chart=new F(new d(this.ruleSetConfig),this.getDb(),s,{chartTitle:this.chartTitle,x:this.x,y:this.y,iso:this.iso,labels:this.labels,legend:this.legend,facet:this.facet,pointLevel:this.pointLevel,seriesLevel:this.seriesLevel,aspect:this.aspect,limit:this.limit},t,this.containerWidth||0),this.chart.setI18n(this.i18n),this.svgMarkup=this.chart.hasNoData()?"":this.chart.toString(),this.syncWarnings(this.chart.getWarnings()),m(this.errors,this.chart.getQueryError())}syncWarnings(t){if(void 0===this.errors)return;const s=new Map(t.map((t=>[t.code,t.data])));for(const t of X){const i=`WARN_${t.replace(/-/g,"_")}`;if(s.has(t)){const n=void 0!==this.translator?this.translator(`.${t}`,s.get(t)):t;this.errors.addOrReplace({id:i,type:"warning",message:n})}else this.errors.remove(i)}}prepareStyle(){var t,s;const i=new k(new T,new f,new p(new g),new w).adapt(this.styles);return i.locale=(null===(s=null===(t=r(this.element).context)||void 0===t?void 0:t.state)||void 0===s?void 0:s.locale)||"de",i}render(){var t;if(void 0===this.chart||void 0!==this.chart.getQueryError())return i(n,null);if(this.chart.hasNoData()){const s=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return i(n,{class:"no-data"},i("div",{class:"empty-state"},s))}return i(n,null,i("div",{innerHTML:this.svgMarkup}))}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}'}},[1,"bn-chart-scatter-renderer",{tableName:[1,"table-name"],dataVersion:[2,"data-version"],chartTitle:[1,"chart-title"],x:[16],y:[16],iso:[16],labels:[16],legend:[16],facet:[16],pointLevel:[1,"point-level"],seriesLevel:[1,"series-level"],aspect:[2],limit:[2],filter:[1],styles:[16],i18n:[16],containerWidth:[2,"container-width"],ruleSetConfig:[16],errors:[16],translator:[16]}]);function I(){"undefined"!=typeof customElements&&["bn-chart-scatter-renderer"].forEach((t=>{"bn-chart-scatter-renderer"===t&&(customElements.get(e(t))||customElements.define(e(t),H))}))}export{H as B,I as d}
|