@bino-bi/bn-template-engine 1.0.0-next.39 → 1.0.0-next.40
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-9a61f59d.entry.js → p-8b28c9bd.entry.js} +1 -1
- package/dist/bn-template-engine/{p-DyupX-Z-.js → p-BjozxTTW.js} +1 -1
- package/dist/bn-template-engine/p-EcC0qLtU.js +1 -0
- package/dist/bn-template-engine/{p-eea538f1.entry.js → p-a4b76176.entry.js} +1 -1
- package/dist/bn-template-engine/p-aa0fd797.entry.js +1 -0
- package/dist/bn-template-engine/{p-93b8387f.entry.js → p-ce764078.entry.js} +1 -1
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +785 -378
- 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-DfE0aW7D.js → withStyled-BZb6snOx.js} +74 -0
- package/dist/cjs/{withTranslation-0gkn9xoC.js → withTranslation-FxXGUB3H.js} +1 -1
- package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +4 -1
- package/dist/collection/components/bn-chart-structure/utils/elements/Label.js +3 -1
- package/dist/collection/components/bn-chart-time/utils/elements/Label.js +3 -1
- package/dist/collection/components/bn-table/bn-table-renderer/bn-table-renderer.css +22 -1
- package/dist/collection/components/bn-table/bn-table-renderer/bn-table-renderer.js +156 -11
- package/dist/collection/components/bn-table/bn-table.js +134 -5
- package/dist/collection/components/bn-table/utils/elements/Cell.js +10 -1
- package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +25 -10
- package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +50 -12
- package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +44 -14
- package/dist/collection/components/bn-table/utils/helper/DataQuery.js +63 -2
- package/dist/collection/components/bn-table/utils/helper/WaterfallCalculator.js +123 -11
- package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +57 -9
- package/dist/collection/components/bn-table/utils/model/TableComponentConfig.js +16 -1
- package/dist/collection/components/bn-table/utils/model/index.js +6 -0
- package/dist/collection/utils/validate.js +4 -0
- 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.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-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.js +1 -1
- package/dist/components/bn-tree.js +1 -1
- package/dist/components/p-1B_s8oPY.js +1 -0
- package/dist/components/{p-BqUB56k1.js → p-B4L069XF.js} +1 -1
- package/dist/components/p-BC4MwlnX.js +1 -0
- package/dist/components/p-BZXiWkDS.js +1 -0
- package/dist/components/p-BiSytXUy.js +1 -0
- package/dist/components/p-Bn7J1pgl.js +1 -0
- package/dist/components/{p-BmOWXYHF.js → p-CEf5X8MZ.js} +1 -1
- package/dist/components/{p-Cyf5ZEXs.js → p-CUSAlS2o.js} +1 -1
- package/dist/components/p-CvEdUq8i.js +1 -0
- package/dist/components/{p-OquycEMA.js → p-D40Am1Ap.js} +1 -1
- package/dist/components/{p-B4Cf0cVi.js → p-DM4Up10X.js} +1 -1
- package/dist/components/{p-Bo_R7f_T.js → p-DwuXVo2h.js} +1 -1
- package/dist/components/{p-DTmqMQpw.js → p-Y9bth2Y_.js} +1 -1
- package/dist/components/{p-BU_53KVT.js → p-xIWChKGS.js} +1 -1
- package/dist/esm/bn-annotation-layer_30.entry.js +903 -496
- 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-CIoJ86RM.js → withStyled-CzzXg64f.js} +77 -4
- package/dist/esm/{withTranslation-BX9T3dfm.js → withTranslation-Daq2JXkv.js} +1 -1
- package/dist/types/components/bn-table/bn-table-renderer/bn-table-renderer.d.ts +20 -1
- package/dist/types/components/bn-table/bn-table.d.ts +49 -1
- package/dist/types/components/bn-table/utils/elements/Cell.d.ts +3 -0
- package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +26 -0
- package/dist/types/components/bn-table/utils/elements/WaterfallBar.d.ts +22 -2
- package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +13 -0
- package/dist/types/components/bn-table/utils/helper/WaterfallCalculator.d.ts +30 -2
- package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +24 -4
- package/dist/types/components/bn-table/utils/model/TableComponentConfig.d.ts +7 -1
- package/dist/types/components/bn-table/utils/model/index.d.ts +5 -0
- package/dist/types/components.d.ts +49 -4
- package/dist/types/utils/validate.d.ts +1 -0
- package/package.json +1 -1
- package/dist/bn-template-engine/p-8c84d57e.entry.js +0 -1
- package/dist/bn-template-engine/p-BVU4bIsi.js +0 -1
- package/dist/components/p-BsJOvfIg.js +0 -1
- package/dist/components/p-DCPLGEs_.js +0 -1
- package/dist/components/p-DT04Cka0.js +0 -1
- package/dist/components/p-Dm6EAaJ9.js +0 -1
- package/dist/components/p-dRPJiQB6.js +0 -1
- package/dist/components/p-tkB96Ena.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as e,h as n,a as i,t as s}from"./p-D6YGOYV1.js";import{n as o}from"./p-DT04Cka0.js";import{LAYOUT_STATE_VERSION as r}from"./index.js";import{o as l,m as a}from"./p-DaOm9YwQ.js";import{r as d,a as c}from"./p-CckAR27O.js";import{w as u}from"./p-Dq9dG0Kr.js";import{w as h}from"./p-Bo_R7f_T.js";import{w as f}from"./p-DjPWZfry.js";import{w as p}from"./p-4vVbchX2.js";import{g,a as v}from"./p-DD1zlev_.js";import{o as y}from"./p-B6kka9sT.js";const m=["*","/","+","-","x","÷","none"];function b(t){switch(t){case"*":case"x":return"×";case"/":case"÷":return"÷";case"+":return"+";case"-":return"−";default:return""}}function x(t,e,n){return t.find((t=>t.from===e&&t.to===n))}function w(t){return 2*(t-1)+1}function $(t){return 2*(t-1)+1}function S(t){return t<=1?1:2*(t-1)+1}function k(t){return S(t)}function M(t,e){const n=t.getBoundingClientRect(),i=n.left-e.left,s=n.top-e.top;return{left:i,top:s,width:n.width,height:n.height,centerX:i+n.width/2,centerY:s+n.height/2}}function R(t,e,n){switch(n){case"ltr":return e?{x:t.left+t.width,y:t.centerY}:{x:t.left,y:t.centerY};case"rtl":return e?{x:t.left,y:t.centerY}:{x:t.left+t.width,y:t.centerY};case"ttb":return e?{x:t.centerX,y:t.top+t.height}:{x:t.centerX,y:t.top};case"btt":return e?{x:t.centerX,y:t.top}:{x:t.centerX,y:t.top+t.height}}}function A(t,e,n,i,s=8){const o=-(i-1)*s/2+n*s;switch(e){case"ltr":return{x:t.left,y:t.centerY+o};case"rtl":return{x:t.left+t.width,y:t.centerY+o};case"ttb":return{x:t.centerX+o,y:t.top};case"btt":return{x:t.centerX+o,y:t.top+t.height}}}function j(t,e,n,i,s){switch(n){case"straight":return function(t,e){return{path:`M ${t.x} ${t.y} L ${e.x} ${e.y}`,midpoint:{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}}(t,e);case"curved":return function(t,e,n){let i,s;if("ltr"===n||"rtl"===n){const n=(t.x+e.x)/2;i={x:n,y:t.y},s={x:n,y:e.y}}else{const n=(t.y+e.y)/2;i={x:t.x,y:n},s={x:e.x,y:n}}return{path:`M ${t.x} ${t.y} C ${i.x} ${i.y}, ${s.x} ${s.y}, ${e.x} ${e.y}`,midpoint:{x:.125*t.x+.375*i.x+.375*s.x+.125*e.x,y:.125*t.y+.375*i.y+.375*s.y+.125*e.y}}}(t,e,i);default:return function(t,e,n,i){let s,o;if("ltr"===n||"rtl"===n){const n=null!=i?i:t.x+.7*(e.x-t.x);s=`M ${t.x} ${t.y} L ${n} ${t.y} L ${n} ${e.y} L ${e.x} ${e.y}`,o={x:n,y:(t.y+e.y)/2}}else{const n=null!=i?i:t.y+.7*(e.y-t.y);s=`M ${t.x} ${t.y} L ${t.x} ${n} L ${e.x} ${n} L ${e.x} ${e.y}`,o={x:(t.x+e.x)/2,y:n}}return{path:s,midpoint:o}}(t,e,i,s)}}function C(t,e,n){let i,s,o;switch(n){case"ltr":i=t.left+t.width,s=e.map((t=>t.left)),o=1;break;case"rtl":i=t.left,s=e.map((t=>t.left+t.width)),o=-1;break;case"ttb":i=t.top+t.height,s=e.map((t=>t.top)),o=1;break;case"btt":i=t.top,s=e.map((t=>t.top+t.height)),o=-1}const r=s.map((t=>(t-i)*o)).filter((t=>t>=0));if(0!==r.length)return i+Math.min(...r)*o*.7}function L(t,e,n,i){return"ltr"===i||"rtl"===i?{x:t,y:(e.centerY+n.centerY)/2}:{x:(e.centerX+n.centerX)/2,y:t}}function N(t,e,n){var i,s;return Object.assign({stroke:null!==(i=null==n?void 0:n.color)&&void 0!==i?i:t,strokeWidth:null!==(s=null==n?void 0:n.width)&&void 0!==s?s:e},(null==n?void 0:n.dasharray)?{strokeDasharray:n.dasharray}:{})}const T=t(class extends e{validateEdgesProp(t){const e="ERR_edges",n=function(t){const e=[];if(!t||""===t.trim())return e.push("edges: value is required"),e;let n;try{n=JSON.parse(t)}catch(t){return e.push("edges: invalid JSON structure"),e}if(!Array.isArray(n))return e.push("edges: must be an array"),e;if(0===n.length)return e.push("edges: array must not be empty"),e;const i=new Set,s=new Set,o=new Map;n.forEach(((t,n)=>{if("object"!=typeof t||null===t)return void e.push(`edges[${n}]: must be an object`);const r=t;if("string"!=typeof r.from||""===r.from.trim()?e.push(`edges[${n}]: 'from' is required and must be a non-empty string`):i.add(r.from),"string"!=typeof r.to||""===r.to.trim()?e.push(`edges[${n}]: 'to' is required and must be a non-empty string`):(i.add(r.to),s.add(r.to),"string"==typeof r.from&&o.set(r.from,[...o.get(r.from)||[],r.to])),void 0!==r.operator&&("string"==typeof r.operator&&m.includes(r.operator)||e.push(`edges[${n}]: 'operator' must be one of: ${m.join(", ")}`)),void 0!==r.label&&"string"!=typeof r.label&&e.push(`edges[${n}]: 'label' must be a string`),void 0!==r.style)if("object"!=typeof r.style||null===r.style)e.push(`edges[${n}]: 'style' must be an object`);else{const t=r.style;void 0!==t.color&&"string"!=typeof t.color&&e.push(`edges[${n}]: 'style.color' must be a string`),void 0!==t.width&&"number"!=typeof t.width&&e.push(`edges[${n}]: 'style.width' must be a number`),void 0!==t.dasharray&&"string"!=typeof t.dasharray&&e.push(`edges[${n}]: 'style.dasharray' must be a string`)}}));const r=Array.from(i).filter((t=>!s.has(t)));return 0===r.length?e.push("edges: tree has no root node (circular reference detected)"):r.length>1?e.push("edges: tree has multiple root nodes: "+r.join(", ")):e.push(...function(t,e,n){const i=[],s=new Set,o=new Set,r=t=>{o.add(t),s.add(t);for(const n of e.get(t)||[])s.has(n)?i.push(`edges: circular reference, the edge from '${t}' to '${n}' leads back`):o.has(n)||r(n);s.delete(t)};r(t);const l=Array.from(n).filter((t=>!o.has(t)));return l.length>0&&i.push(`edges: nodes not connected to the root '${t}': ${l.join(", ")}`),i}(r[0],o,i)),e}(t);n.length>0?(this.errors.addOrReplace({id:e,type:"error",message:"edges: "+n.join("; ")}),this.treeConfig=null):(this.errors.remove(e),this.treeConfig=function(t){if(!t||""===t.trim())return null;try{const e=JSON.parse(t);if(!Array.isArray(e))return null;const n=e,i=function(t){const e=new Map;for(const n of t){const t=e.get(n.from)||[];t.push(n.to),e.set(n.from,t)}return e}(n),s=function(t){const e=new Set;for(const n of t)e.add(n.from),e.add(n.to);return e}(n),o=function(t,e){const n=new Set;for(const e of t)n.add(e.to);const i=Array.from(e).filter((t=>!n.has(t)));return 1===i.length?i[0]:null}(n,s);return{edges:n,adjacencyList:i,rootNode:o,allNodes:s}}catch(t){return console.error("parseTreeConfig: failed to parse tree configuration",t),null}}(t)),this.recalculateLayout()}validateDirection(t){const e="WARN_direction",n=["ltr","rtl","ttb","btt"];n.includes(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`direction: invalid value '${t}', must be one of: ${n.join(", ")}`}),this.recalculateLayout()}validateLevelSpacing(t){const e="WARN_levelSpacing";!o(t)||t<0?this.errors.addOrReplace({id:e,type:"warning",message:`level-spacing: invalid value '${t}', must be a non-negative number`}):this.errors.remove(e),this.recalculateLayout()}validateNodeSpacing(t){const e="WARN_nodeSpacing";!o(t)||t<0?this.errors.addOrReplace({id:e,type:"warning",message:`node-spacing: invalid value '${t}', must be a non-negative number`}):this.errors.remove(e),this.recalculateLayout()}validateEdgeStyle(t){const e="WARN_edgeStyle",n=["straight","orthogonal","curved"];n.includes(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`edge-style: invalid value '${t}', must be one of: ${n.join(", ")}`})}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.treeConfig=null,this.layout=null,this.nodeRects=new Map,this.svgWidth=0,this.svgHeight=0,this.resizeObserver=null,this.gridContainer=null,this.observed=new Set,this.parentObserver=null,this.direction="ltr",this.levelSpacing=60,this.nodeSpacing=20,this.edgeStyle="orthogonal",this.showOperators=!0,h(this),u(this),this.errors=p(this),this.componentStyle=f(this)}async getLayoutState(t){var e,n,i,s,o,u,h,f,p,g,v;const y=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",m=l(this.element),b=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333})),x={version:r,tag:this.element.localName,id:c(this.element),slot:null!==(n=this.element.getAttribute("slot"))&&void 0!==n?n:void 0,rect:a(this.element,m),em:{fontSizePx:b,appliedScaleFactor:1},regions:[],metadata:{nodeCount:null!==(s=null===(i=this.treeConfig)||void 0===i?void 0:i.allNodes.size)&&void 0!==s?s:0,edgeCount:null!==(u=null===(o=this.treeConfig)||void 0===o?void 0:o.edges.length)&&void 0!==u?u:0},diagnostics:d(this.element)},w=null===(h=this.element.shadowRoot)||void 0===h?void 0:h.querySelector(".tree-grid");if(w&&x.regions.push({id:"grid",rect:a(w,m)}),"full"!==y||!this.treeConfig)return x;const $=[];for(const t of this.treeConfig.allNodes){const e=this.element.querySelector(`[slot="${t}"]`);if(!e)continue;const n={kind:"node",nodeId:t,rect:a(e,m)};$.push(n)}const S=Array.from(null!==(p=null===(f=this.element.shadowRoot)||void 0===f?void 0:f.querySelectorAll("svg.edge-layer path"))&&void 0!==p?p:[]);let k=0;for(const t of this.treeConfig.edges){if(!this.nodeRects.get(t.from)||!this.nodeRects.get(t.to))continue;const e=S[k++];if(!e)break;const n={kind:"edge",from:t.from,to:t.to,operator:t.operator,path:null!==(g=e.getAttribute("d"))&&void 0!==g?g:void 0,rect:a(e,m)};$.push(n)}return null===(v=this.element.shadowRoot)||void 0===v||v.querySelectorAll("svg.edge-layer g.operator-group").forEach((t=>{var e,n;const i=null!==(n=null===(e=t.textContent)||void 0===e?void 0:e.trim())&&void 0!==n?n:"";if(!i)return;const s={kind:"label",role:"operator",text:i,rect:a(t,m)};$.push(s)})),x.elements=$,x}getTreeStyle(){return this.componentStyle((t=>({edgeColor:t["bn-tree"].edgeColor,edgeWidth:t["bn-tree"].edgeWidth,operatorCircleRadius:t["bn-tree"].operatorCircleRadius,operatorFontSize:t.global.fontSizePx*t["bn-tree"].operatorFontSizeScale,operatorColor:t["bn-tree"].operatorColor})))}componentWillLoad(){this.validateEdgesProp(this.edges),this.validateDirection(this.direction),this.validateLevelSpacing(this.levelSpacing),this.validateNodeSpacing(this.nodeSpacing),this.validateEdgeStyle(this.edgeStyle)}connectedCallback(){this.observeLayout(),this.updateNodeRects()}componentDidLoad(){var t;null===(t=this.element.shadowRoot)||void 0===t||t.addEventListener("slotchange",(()=>{this.observeLayout(),this.updateNodeRects()})),requestAnimationFrame((()=>{this.updateNodeRects()}))}componentDidRender(){this.observeLayout(),this.updateNodeRects()}disconnectedCallback(){var t;this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.observed.clear(),null===(t=this.parentObserver)||void 0===t||t.disconnect(),this.parentObserver=null}observeLayout(){var t,e,n;const i=null!==(e=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelector(".tree-grid"))&&void 0!==e?e:null;if(i!==this.gridContainer&&(null===(n=this.resizeObserver)||void 0===n||n.disconnect(),this.observed.clear(),this.gridContainer=i),i){this.resizeObserver||(this.resizeObserver=new ResizeObserver((()=>{this.updateNodeRects()}))),this.parentObserver||(this.parentObserver=y(this.element,(()=>this.checkOverflow())));for(const t of[i,...Array.from(this.element.querySelectorAll("[slot]"))])this.observed.has(t)||(this.resizeObserver.observe(t),this.observed.add(t))}}recalculateLayout(){this.layout=this.treeConfig?function(t,e,n,i){if(!t.rootNode)return{positions:new Map,gridTemplateColumns:"",gridTemplateRows:"",maxLevel:0,maxIndex:0};const s=function(t){const e=new Map;if(!t.rootNode)return e;const n=[{node:t.rootNode,level:0}],i=new Set;for(;n.length>0;){const{node:s,level:o}=n.shift();if(i.has(s))continue;i.add(s),e.set(s,o);const r=t.adjacencyList.get(s)||[];for(const t of r)i.has(t)||n.push({node:t,level:o+1})}return e}(t),o=function(t){const e=new Map;if(!t.rootNode)return e;let n=0;return function i(s){const o=e.get(s);if(o)return o;const r=t.adjacencyList.get(s)||[];if(e.set(s,{startIndex:n,endIndex:n}),0===r.length){const t={startIndex:n,endIndex:n};return e.set(s,t),n++,t}let l=1/0,a=-1/0;for(const t of r){const e=i(t);l=Math.min(l,e.startIndex),a=Math.max(a,e.endIndex)}const d={startIndex:l,endIndex:a};return e.set(s,d),d}(t.rootNode),e}(t),r=function(t,e,n,i){var s,o;const r=new Map,l=Math.max(...Array.from(e.values()));for(const a of t.allNodes){const d=null!==(s=e.get(a))&&void 0!==s?s:0,c=null!==(o=n.get(a))&&void 0!==o?o:{startIndex:0,endIndex:0};let u,h,f=1,p=1;const g=c.endIndex-c.startIndex+1,v=Array.from(t.allNodes).some((t=>{var i;const s=n.get(t);return t!==a&&void 0!==s&&(null!==(i=e.get(t))&&void 0!==i?i:0)===d&&s.startIndex<=c.endIndex&&c.startIndex<=s.endIndex})),y=v?1:g;switch(i){case"ltr":u=d+1,h=c.startIndex+1,f=g;break;case"rtl":u=l-d+1,h=c.startIndex+1,f=g;break;case"ttb":h=d+1,u=c.startIndex+1,p=y;break;case"btt":h=l-d+1,u=c.startIndex+1,p=y}r.set(a,{nodeId:a,level:d,index:c.startIndex,gridColumn:u,gridRow:h,gridRowSpan:f,gridColumnSpan:p})}return r}(t,s,o,e),l=Math.max(...Array.from(s.values())),a=Math.max(...Array.from(o.values()).map((t=>t.endIndex))),{gridTemplateColumns:d,gridTemplateRows:c}=function(t,e,n,i,s){const o=t+1,r=e+1;if("ltr"===n||"rtl"===n){const t=[];for(let e=0;e<o;e++)t.push("auto"),e<o-1&&t.push(i+"px");const e=[];for(let t=0;t<r;t++)e.push("auto"),t<r-1&&e.push(s+"px");return{gridTemplateColumns:t.join(" "),gridTemplateRows:e.join(" ")}}{const t=[];for(let e=0;e<o;e++)t.push("auto"),e<o-1&&t.push(i+"px");const e=[];for(let t=0;t<r;t++)e.push("auto"),t<r-1&&e.push(s+"px");return{gridTemplateColumns:e.join(" "),gridTemplateRows:t.join(" ")}}}(l,a,e,n,i);return{positions:r,gridTemplateColumns:d,gridTemplateRows:c,maxLevel:l,maxIndex:a}}(this.treeConfig,this.direction,this.levelSpacing,this.nodeSpacing):null}updateNodeRects(){var t;if(!this.treeConfig||!this.gridContainer)return void(null===(t=this.errors)||void 0===t||t.remove("WARN_overflow"));const e=this.gridContainer.getBoundingClientRect(),n=new Map;for(const t of this.treeConfig.allNodes){const i=this.element.querySelector(`[slot="${t}"]`);i&&n.set(t,M(i,e))}(function(t,e){if(t.size!==e.size)return!1;for(const[n,i]of t){const t=e.get(n);if(!t||t.left!==i.left||t.top!==i.top||t.width!==i.width||t.height!==i.height)return!1}return!0})(this.nodeRects,n)||(this.nodeRects=n),this.svgWidth=e.width,this.svgHeight=e.height,this.checkOverflow()}checkOverflow(){var t,e;const n="WARN_overflow",i=g(this.element),s=(null===(t=this.gridContainer)||void 0===t?void 0:t.scrollWidth)||0,o=(null===(e=this.gridContainer)||void 0===e?void 0:e.scrollHeight)||0,r=[];i.width>0&&s>i.width+1&&r.push(`width (${Math.round(s)}px > ${Math.round(i.width)}px)`);const l=v(this.element,o);l>1&&r.push(`height (${Math.round(o)}px > ${Math.round(o-l)}px)`),0!==r.length?this.errors.addOrReplace({id:n,type:"warning",message:`Tree exceeds available ${r.join(" and ")} and will be cut off. Reduce level-spacing, node-spacing or the node content, or enlarge the container.`}):this.errors.remove(n)}getSlotStyle(t){if(!this.layout)return{};const e=this.layout.positions.get(t);return e?"ltr"===this.direction||"rtl"===this.direction?{"grid-column":w(e.gridColumn)+"","grid-row":`${$(e.gridRow)} / span ${S(e.gridRowSpan)}`,"align-self":"center"}:{"grid-row":$(e.gridRow)+"","grid-column":`${w(e.gridColumn)} / span ${k(e.gridColumnSpan)}`,"justify-self":"center"}:{}}renderEdges(){var t;if(!this.treeConfig||0===this.nodeRects.size)return null;const e=this.getTreeStyle(),i=[],s=[],o=new Map;for(const t of this.treeConfig.edges){const e=o.get(t.to)||[];e.push(t.from),o.set(t.to,e)}const r=new Map;for(const[t,e]of this.treeConfig.adjacencyList.entries()){const n=this.nodeRects.get(t),i=e.map((t=>this.nodeRects.get(t))).filter((t=>void 0!==t)),s=n?C(n,i,this.direction):void 0;void 0!==s&&r.set(t,s)}for(const t of this.treeConfig.edges){const s=this.nodeRects.get(t.from),l=this.nodeRects.get(t.to);if(!s||!l)continue;const a=R(s,!0,this.direction),d=o.get(t.to)||[];let c;if(d.length>1){const e=d.indexOf(t.from);c=A(l,this.direction,e,d.length)}else c=R(l,!1,this.direction);const{path:u}=j(a,c,this.edgeStyle,this.direction,r.get(t.from)),h=N(e.edgeColor,e.edgeWidth,t.style);i.push(n("path",{key:`edge-${t.from}-${t.to}`,d:u,fill:"none",stroke:h.stroke,"stroke-width":h.strokeWidth,"stroke-dasharray":h.strokeDasharray}))}if(this.showOperators)for(const[i,o]of this.treeConfig.adjacencyList.entries()){const l=r.get(i);if(void 0!==l)for(let r=0;r<o.length-1;r++){const a=o[r],d=o[r+1],c=x(this.treeConfig.edges,i,a);if(!(null==c?void 0:c.operator)||"none"===c.operator)continue;const u=this.nodeRects.get(a),h=this.nodeRects.get(d);if(!u||!h)continue;const f=null!==(t=c.label)&&void 0!==t?t:b(c.operator),p=L(l,u,h,this.direction);s.push(n("g",{key:`operator-${i}-${a}`,class:"operator-group"},n("circle",{cx:p.x,cy:p.y,r:e.operatorCircleRadius,fill:"white",stroke:e.edgeColor,"stroke-width":e.edgeWidth}),n("text",{x:p.x,y:p.y,"text-anchor":"middle","dominant-baseline":"central",style:{fontSize:e.operatorFontSize+"px",fill:e.operatorColor,fontWeight:"bold"}},f)))}}return n("svg",{class:"edge-layer",width:this.svgWidth,height:this.svgHeight,style:{position:"absolute",top:"0",left:"0",pointerEvents:"none"}},i,s)}renderSlots(){return this.treeConfig&&this.layout?Array.from(this.treeConfig.allNodes).map((t=>n("div",{key:t,class:"tree-node",style:this.getSlotStyle(t)},n("slot",{name:t})))):null}getFontStyles(){return this.componentStyle((t=>{var e,n,i,s;return{"--bn-font-family":(null===(e=t.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":((null===(n=t.global)||void 0===n?void 0:n.fontSizePx)||13.3333)+"px","--bn-font-color":(null===(i=t.global)||void 0===i?void 0:i.fontColor)||"#000000","--bn-font-background":(null===(s=t.global)||void 0===s?void 0:s.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles();return n(i,{style:t},this.treeConfig&&this.layout?n("div",{class:"tree-container"},n("div",{class:"tree-grid",style:{display:"grid","grid-template-columns":this.layout.gridTemplateColumns,"grid-template-rows":this.layout.gridTemplateRows,position:"relative"}},this.renderEdges(),this.renderSlots())):n("div",{class:"tree-container tree-error"},n("slot",null)))}get element(){return this}static get watchers(){return{edges:[{validateEdgesProp:0}],direction:[{validateDirection:0}],levelSpacing:[{validateLevelSpacing:0}],nodeSpacing:[{validateNodeSpacing:0}],edgeStyle:[{validateEdgeStyle:0}]}}static get style(){return':host{display:inline-block;position:relative;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.tree-container{position:relative;display:inline-block}.tree-grid{position:relative;display:grid;align-items:center}.tree-node{position:relative;z-index:1;border:1px solid #404040;background:var(--bn-font-background, white)}.edge-layer{position:absolute;top:0;left:0;z-index:0;pointer-events:none;overflow:visible}.tree-error{display:flex;flex-wrap:wrap;gap:20px}'}},[257,"bn-tree",{selectedStyle:[513,"selected-style"],edges:[1],direction:[1],levelSpacing:[2,"level-spacing"],nodeSpacing:[2,"node-spacing"],edgeStyle:[1,"edge-style"],i18nNamespace:[513,"i18n-namespace"],showOperators:[4,"show-operators"],treeConfig:[32],layout:[32],nodeRects:[32],svgWidth:[32],svgHeight:[32],getLayoutState:[64]},void 0,{edges:[{validateEdgesProp:0}],direction:[{validateDirection:0}],levelSpacing:[{validateLevelSpacing:0}],nodeSpacing:[{validateNodeSpacing:0}],edgeStyle:[{validateEdgeStyle:0}]}]),D=T,E=function(){"undefined"!=typeof customElements&&["bn-tree"].forEach((t=>{"bn-tree"===t&&(customElements.get(s(t))||customElements.define(s(t),T))}))};export{D as BnTree,E as defineCustomElement}
|
|
1
|
+
import{p as t,H as e,h as n,a as i,t as s}from"./p-D6YGOYV1.js";import{n as o}from"./p-BiSytXUy.js";import{LAYOUT_STATE_VERSION as r}from"./index.js";import{o as l,m as a}from"./p-DaOm9YwQ.js";import{r as d,a as c}from"./p-CckAR27O.js";import{w as u}from"./p-Dq9dG0Kr.js";import{w as h}from"./p-DwuXVo2h.js";import{w as f}from"./p-DjPWZfry.js";import{w as p}from"./p-4vVbchX2.js";import{g,a as v}from"./p-DD1zlev_.js";import{o as y}from"./p-B6kka9sT.js";const m=["*","/","+","-","x","÷","none"];function b(t){switch(t){case"*":case"x":return"×";case"/":case"÷":return"÷";case"+":return"+";case"-":return"−";default:return""}}function x(t,e,n){return t.find((t=>t.from===e&&t.to===n))}function w(t){return 2*(t-1)+1}function $(t){return 2*(t-1)+1}function S(t){return t<=1?1:2*(t-1)+1}function k(t){return S(t)}function M(t,e){const n=t.getBoundingClientRect(),i=n.left-e.left,s=n.top-e.top;return{left:i,top:s,width:n.width,height:n.height,centerX:i+n.width/2,centerY:s+n.height/2}}function R(t,e,n){switch(n){case"ltr":return e?{x:t.left+t.width,y:t.centerY}:{x:t.left,y:t.centerY};case"rtl":return e?{x:t.left,y:t.centerY}:{x:t.left+t.width,y:t.centerY};case"ttb":return e?{x:t.centerX,y:t.top+t.height}:{x:t.centerX,y:t.top};case"btt":return e?{x:t.centerX,y:t.top}:{x:t.centerX,y:t.top+t.height}}}function A(t,e,n,i,s=8){const o=-(i-1)*s/2+n*s;switch(e){case"ltr":return{x:t.left,y:t.centerY+o};case"rtl":return{x:t.left+t.width,y:t.centerY+o};case"ttb":return{x:t.centerX+o,y:t.top};case"btt":return{x:t.centerX+o,y:t.top+t.height}}}function j(t,e,n,i,s){switch(n){case"straight":return function(t,e){return{path:`M ${t.x} ${t.y} L ${e.x} ${e.y}`,midpoint:{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}}(t,e);case"curved":return function(t,e,n){let i,s;if("ltr"===n||"rtl"===n){const n=(t.x+e.x)/2;i={x:n,y:t.y},s={x:n,y:e.y}}else{const n=(t.y+e.y)/2;i={x:t.x,y:n},s={x:e.x,y:n}}return{path:`M ${t.x} ${t.y} C ${i.x} ${i.y}, ${s.x} ${s.y}, ${e.x} ${e.y}`,midpoint:{x:.125*t.x+.375*i.x+.375*s.x+.125*e.x,y:.125*t.y+.375*i.y+.375*s.y+.125*e.y}}}(t,e,i);default:return function(t,e,n,i){let s,o;if("ltr"===n||"rtl"===n){const n=null!=i?i:t.x+.7*(e.x-t.x);s=`M ${t.x} ${t.y} L ${n} ${t.y} L ${n} ${e.y} L ${e.x} ${e.y}`,o={x:n,y:(t.y+e.y)/2}}else{const n=null!=i?i:t.y+.7*(e.y-t.y);s=`M ${t.x} ${t.y} L ${t.x} ${n} L ${e.x} ${n} L ${e.x} ${e.y}`,o={x:(t.x+e.x)/2,y:n}}return{path:s,midpoint:o}}(t,e,i,s)}}function L(t,e,n){let i,s,o;switch(n){case"ltr":i=t.left+t.width,s=e.map((t=>t.left)),o=1;break;case"rtl":i=t.left,s=e.map((t=>t.left+t.width)),o=-1;break;case"ttb":i=t.top+t.height,s=e.map((t=>t.top)),o=1;break;case"btt":i=t.top,s=e.map((t=>t.top+t.height)),o=-1}const r=s.map((t=>(t-i)*o)).filter((t=>t>=0));if(0!==r.length)return i+Math.min(...r)*o*.7}function C(t,e,n,i){return"ltr"===i||"rtl"===i?{x:t,y:(e.centerY+n.centerY)/2}:{x:(e.centerX+n.centerX)/2,y:t}}function N(t,e,n){var i,s;return Object.assign({stroke:null!==(i=null==n?void 0:n.color)&&void 0!==i?i:t,strokeWidth:null!==(s=null==n?void 0:n.width)&&void 0!==s?s:e},(null==n?void 0:n.dasharray)?{strokeDasharray:n.dasharray}:{})}const T=t(class extends e{validateEdgesProp(t){const e="ERR_edges",n=function(t){const e=[];if(!t||""===t.trim())return e.push("edges: value is required"),e;let n;try{n=JSON.parse(t)}catch(t){return e.push("edges: invalid JSON structure"),e}if(!Array.isArray(n))return e.push("edges: must be an array"),e;if(0===n.length)return e.push("edges: array must not be empty"),e;const i=new Set,s=new Set,o=new Map;n.forEach(((t,n)=>{if("object"!=typeof t||null===t)return void e.push(`edges[${n}]: must be an object`);const r=t;if("string"!=typeof r.from||""===r.from.trim()?e.push(`edges[${n}]: 'from' is required and must be a non-empty string`):i.add(r.from),"string"!=typeof r.to||""===r.to.trim()?e.push(`edges[${n}]: 'to' is required and must be a non-empty string`):(i.add(r.to),s.add(r.to),"string"==typeof r.from&&o.set(r.from,[...o.get(r.from)||[],r.to])),void 0!==r.operator&&("string"==typeof r.operator&&m.includes(r.operator)||e.push(`edges[${n}]: 'operator' must be one of: ${m.join(", ")}`)),void 0!==r.label&&"string"!=typeof r.label&&e.push(`edges[${n}]: 'label' must be a string`),void 0!==r.style)if("object"!=typeof r.style||null===r.style)e.push(`edges[${n}]: 'style' must be an object`);else{const t=r.style;void 0!==t.color&&"string"!=typeof t.color&&e.push(`edges[${n}]: 'style.color' must be a string`),void 0!==t.width&&"number"!=typeof t.width&&e.push(`edges[${n}]: 'style.width' must be a number`),void 0!==t.dasharray&&"string"!=typeof t.dasharray&&e.push(`edges[${n}]: 'style.dasharray' must be a string`)}}));const r=Array.from(i).filter((t=>!s.has(t)));return 0===r.length?e.push("edges: tree has no root node (circular reference detected)"):r.length>1?e.push("edges: tree has multiple root nodes: "+r.join(", ")):e.push(...function(t,e,n){const i=[],s=new Set,o=new Set,r=t=>{o.add(t),s.add(t);for(const n of e.get(t)||[])s.has(n)?i.push(`edges: circular reference, the edge from '${t}' to '${n}' leads back`):o.has(n)||r(n);s.delete(t)};r(t);const l=Array.from(n).filter((t=>!o.has(t)));return l.length>0&&i.push(`edges: nodes not connected to the root '${t}': ${l.join(", ")}`),i}(r[0],o,i)),e}(t);n.length>0?(this.errors.addOrReplace({id:e,type:"error",message:"edges: "+n.join("; ")}),this.treeConfig=null):(this.errors.remove(e),this.treeConfig=function(t){if(!t||""===t.trim())return null;try{const e=JSON.parse(t);if(!Array.isArray(e))return null;const n=e,i=function(t){const e=new Map;for(const n of t){const t=e.get(n.from)||[];t.push(n.to),e.set(n.from,t)}return e}(n),s=function(t){const e=new Set;for(const n of t)e.add(n.from),e.add(n.to);return e}(n),o=function(t,e){const n=new Set;for(const e of t)n.add(e.to);const i=Array.from(e).filter((t=>!n.has(t)));return 1===i.length?i[0]:null}(n,s);return{edges:n,adjacencyList:i,rootNode:o,allNodes:s}}catch(t){return console.error("parseTreeConfig: failed to parse tree configuration",t),null}}(t)),this.recalculateLayout()}validateDirection(t){const e="WARN_direction",n=["ltr","rtl","ttb","btt"];n.includes(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`direction: invalid value '${t}', must be one of: ${n.join(", ")}`}),this.recalculateLayout()}validateLevelSpacing(t){const e="WARN_levelSpacing";!o(t)||t<0?this.errors.addOrReplace({id:e,type:"warning",message:`level-spacing: invalid value '${t}', must be a non-negative number`}):this.errors.remove(e),this.recalculateLayout()}validateNodeSpacing(t){const e="WARN_nodeSpacing";!o(t)||t<0?this.errors.addOrReplace({id:e,type:"warning",message:`node-spacing: invalid value '${t}', must be a non-negative number`}):this.errors.remove(e),this.recalculateLayout()}validateEdgeStyle(t){const e="WARN_edgeStyle",n=["straight","orthogonal","curved"];n.includes(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`edge-style: invalid value '${t}', must be one of: ${n.join(", ")}`})}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.treeConfig=null,this.layout=null,this.nodeRects=new Map,this.svgWidth=0,this.svgHeight=0,this.resizeObserver=null,this.gridContainer=null,this.observed=new Set,this.parentObserver=null,this.direction="ltr",this.levelSpacing=60,this.nodeSpacing=20,this.edgeStyle="orthogonal",this.showOperators=!0,h(this),u(this),this.errors=p(this),this.componentStyle=f(this)}async getLayoutState(t){var e,n,i,s,o,u,h,f,p,g,v;const y=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",m=l(this.element),b=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333})),x={version:r,tag:this.element.localName,id:c(this.element),slot:null!==(n=this.element.getAttribute("slot"))&&void 0!==n?n:void 0,rect:a(this.element,m),em:{fontSizePx:b,appliedScaleFactor:1},regions:[],metadata:{nodeCount:null!==(s=null===(i=this.treeConfig)||void 0===i?void 0:i.allNodes.size)&&void 0!==s?s:0,edgeCount:null!==(u=null===(o=this.treeConfig)||void 0===o?void 0:o.edges.length)&&void 0!==u?u:0},diagnostics:d(this.element)},w=null===(h=this.element.shadowRoot)||void 0===h?void 0:h.querySelector(".tree-grid");if(w&&x.regions.push({id:"grid",rect:a(w,m)}),"full"!==y||!this.treeConfig)return x;const $=[];for(const t of this.treeConfig.allNodes){const e=this.element.querySelector(`[slot="${t}"]`);if(!e)continue;const n={kind:"node",nodeId:t,rect:a(e,m)};$.push(n)}const S=Array.from(null!==(p=null===(f=this.element.shadowRoot)||void 0===f?void 0:f.querySelectorAll("svg.edge-layer path"))&&void 0!==p?p:[]);let k=0;for(const t of this.treeConfig.edges){if(!this.nodeRects.get(t.from)||!this.nodeRects.get(t.to))continue;const e=S[k++];if(!e)break;const n={kind:"edge",from:t.from,to:t.to,operator:t.operator,path:null!==(g=e.getAttribute("d"))&&void 0!==g?g:void 0,rect:a(e,m)};$.push(n)}return null===(v=this.element.shadowRoot)||void 0===v||v.querySelectorAll("svg.edge-layer g.operator-group").forEach((t=>{var e,n;const i=null!==(n=null===(e=t.textContent)||void 0===e?void 0:e.trim())&&void 0!==n?n:"";if(!i)return;const s={kind:"label",role:"operator",text:i,rect:a(t,m)};$.push(s)})),x.elements=$,x}getTreeStyle(){return this.componentStyle((t=>({edgeColor:t["bn-tree"].edgeColor,edgeWidth:t["bn-tree"].edgeWidth,operatorCircleRadius:t["bn-tree"].operatorCircleRadius,operatorFontSize:t.global.fontSizePx*t["bn-tree"].operatorFontSizeScale,operatorColor:t["bn-tree"].operatorColor})))}componentWillLoad(){this.validateEdgesProp(this.edges),this.validateDirection(this.direction),this.validateLevelSpacing(this.levelSpacing),this.validateNodeSpacing(this.nodeSpacing),this.validateEdgeStyle(this.edgeStyle)}connectedCallback(){this.observeLayout(),this.updateNodeRects()}componentDidLoad(){var t;null===(t=this.element.shadowRoot)||void 0===t||t.addEventListener("slotchange",(()=>{this.observeLayout(),this.updateNodeRects()})),requestAnimationFrame((()=>{this.updateNodeRects()}))}componentDidRender(){this.observeLayout(),this.updateNodeRects()}disconnectedCallback(){var t;this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.observed.clear(),null===(t=this.parentObserver)||void 0===t||t.disconnect(),this.parentObserver=null}observeLayout(){var t,e,n;const i=null!==(e=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelector(".tree-grid"))&&void 0!==e?e:null;if(i!==this.gridContainer&&(null===(n=this.resizeObserver)||void 0===n||n.disconnect(),this.observed.clear(),this.gridContainer=i),i){this.resizeObserver||(this.resizeObserver=new ResizeObserver((()=>{this.updateNodeRects()}))),this.parentObserver||(this.parentObserver=y(this.element,(()=>this.checkOverflow())));for(const t of[i,...Array.from(this.element.querySelectorAll("[slot]"))])this.observed.has(t)||(this.resizeObserver.observe(t),this.observed.add(t))}}recalculateLayout(){this.layout=this.treeConfig?function(t,e,n,i){if(!t.rootNode)return{positions:new Map,gridTemplateColumns:"",gridTemplateRows:"",maxLevel:0,maxIndex:0};const s=function(t){const e=new Map;if(!t.rootNode)return e;const n=[{node:t.rootNode,level:0}],i=new Set;for(;n.length>0;){const{node:s,level:o}=n.shift();if(i.has(s))continue;i.add(s),e.set(s,o);const r=t.adjacencyList.get(s)||[];for(const t of r)i.has(t)||n.push({node:t,level:o+1})}return e}(t),o=function(t){const e=new Map;if(!t.rootNode)return e;let n=0;return function i(s){const o=e.get(s);if(o)return o;const r=t.adjacencyList.get(s)||[];if(e.set(s,{startIndex:n,endIndex:n}),0===r.length){const t={startIndex:n,endIndex:n};return e.set(s,t),n++,t}let l=1/0,a=-1/0;for(const t of r){const e=i(t);l=Math.min(l,e.startIndex),a=Math.max(a,e.endIndex)}const d={startIndex:l,endIndex:a};return e.set(s,d),d}(t.rootNode),e}(t),r=function(t,e,n,i){var s,o;const r=new Map,l=Math.max(...Array.from(e.values()));for(const a of t.allNodes){const d=null!==(s=e.get(a))&&void 0!==s?s:0,c=null!==(o=n.get(a))&&void 0!==o?o:{startIndex:0,endIndex:0};let u,h,f=1,p=1;const g=c.endIndex-c.startIndex+1,v=Array.from(t.allNodes).some((t=>{var i;const s=n.get(t);return t!==a&&void 0!==s&&(null!==(i=e.get(t))&&void 0!==i?i:0)===d&&s.startIndex<=c.endIndex&&c.startIndex<=s.endIndex})),y=v?1:g;switch(i){case"ltr":u=d+1,h=c.startIndex+1,f=g;break;case"rtl":u=l-d+1,h=c.startIndex+1,f=g;break;case"ttb":h=d+1,u=c.startIndex+1,p=y;break;case"btt":h=l-d+1,u=c.startIndex+1,p=y}r.set(a,{nodeId:a,level:d,index:c.startIndex,gridColumn:u,gridRow:h,gridRowSpan:f,gridColumnSpan:p})}return r}(t,s,o,e),l=Math.max(...Array.from(s.values())),a=Math.max(...Array.from(o.values()).map((t=>t.endIndex))),{gridTemplateColumns:d,gridTemplateRows:c}=function(t,e,n,i,s){const o=t+1,r=e+1;if("ltr"===n||"rtl"===n){const t=[];for(let e=0;e<o;e++)t.push("auto"),e<o-1&&t.push(i+"px");const e=[];for(let t=0;t<r;t++)e.push("auto"),t<r-1&&e.push(s+"px");return{gridTemplateColumns:t.join(" "),gridTemplateRows:e.join(" ")}}{const t=[];for(let e=0;e<o;e++)t.push("auto"),e<o-1&&t.push(i+"px");const e=[];for(let t=0;t<r;t++)e.push("auto"),t<r-1&&e.push(s+"px");return{gridTemplateColumns:e.join(" "),gridTemplateRows:t.join(" ")}}}(l,a,e,n,i);return{positions:r,gridTemplateColumns:d,gridTemplateRows:c,maxLevel:l,maxIndex:a}}(this.treeConfig,this.direction,this.levelSpacing,this.nodeSpacing):null}updateNodeRects(){var t;if(!this.treeConfig||!this.gridContainer)return void(null===(t=this.errors)||void 0===t||t.remove("WARN_overflow"));const e=this.gridContainer.getBoundingClientRect(),n=new Map;for(const t of this.treeConfig.allNodes){const i=this.element.querySelector(`[slot="${t}"]`);i&&n.set(t,M(i,e))}(function(t,e){if(t.size!==e.size)return!1;for(const[n,i]of t){const t=e.get(n);if(!t||t.left!==i.left||t.top!==i.top||t.width!==i.width||t.height!==i.height)return!1}return!0})(this.nodeRects,n)||(this.nodeRects=n),this.svgWidth=e.width,this.svgHeight=e.height,this.checkOverflow()}checkOverflow(){var t,e;const n="WARN_overflow",i=g(this.element),s=(null===(t=this.gridContainer)||void 0===t?void 0:t.scrollWidth)||0,o=(null===(e=this.gridContainer)||void 0===e?void 0:e.scrollHeight)||0,r=[];i.width>0&&s>i.width+1&&r.push(`width (${Math.round(s)}px > ${Math.round(i.width)}px)`);const l=v(this.element,o);l>1&&r.push(`height (${Math.round(o)}px > ${Math.round(o-l)}px)`),0!==r.length?this.errors.addOrReplace({id:n,type:"warning",message:`Tree exceeds available ${r.join(" and ")} and will be cut off. Reduce level-spacing, node-spacing or the node content, or enlarge the container.`}):this.errors.remove(n)}getSlotStyle(t){if(!this.layout)return{};const e=this.layout.positions.get(t);return e?"ltr"===this.direction||"rtl"===this.direction?{"grid-column":w(e.gridColumn)+"","grid-row":`${$(e.gridRow)} / span ${S(e.gridRowSpan)}`,"align-self":"center"}:{"grid-row":$(e.gridRow)+"","grid-column":`${w(e.gridColumn)} / span ${k(e.gridColumnSpan)}`,"justify-self":"center"}:{}}renderEdges(){var t;if(!this.treeConfig||0===this.nodeRects.size)return null;const e=this.getTreeStyle(),i=[],s=[],o=new Map;for(const t of this.treeConfig.edges){const e=o.get(t.to)||[];e.push(t.from),o.set(t.to,e)}const r=new Map;for(const[t,e]of this.treeConfig.adjacencyList.entries()){const n=this.nodeRects.get(t),i=e.map((t=>this.nodeRects.get(t))).filter((t=>void 0!==t)),s=n?L(n,i,this.direction):void 0;void 0!==s&&r.set(t,s)}for(const t of this.treeConfig.edges){const s=this.nodeRects.get(t.from),l=this.nodeRects.get(t.to);if(!s||!l)continue;const a=R(s,!0,this.direction),d=o.get(t.to)||[];let c;if(d.length>1){const e=d.indexOf(t.from);c=A(l,this.direction,e,d.length)}else c=R(l,!1,this.direction);const{path:u}=j(a,c,this.edgeStyle,this.direction,r.get(t.from)),h=N(e.edgeColor,e.edgeWidth,t.style);i.push(n("path",{key:`edge-${t.from}-${t.to}`,d:u,fill:"none",stroke:h.stroke,"stroke-width":h.strokeWidth,"stroke-dasharray":h.strokeDasharray}))}if(this.showOperators)for(const[i,o]of this.treeConfig.adjacencyList.entries()){const l=r.get(i);if(void 0!==l)for(let r=0;r<o.length-1;r++){const a=o[r],d=o[r+1],c=x(this.treeConfig.edges,i,a);if(!(null==c?void 0:c.operator)||"none"===c.operator)continue;const u=this.nodeRects.get(a),h=this.nodeRects.get(d);if(!u||!h)continue;const f=null!==(t=c.label)&&void 0!==t?t:b(c.operator),p=C(l,u,h,this.direction);s.push(n("g",{key:`operator-${i}-${a}`,class:"operator-group"},n("circle",{cx:p.x,cy:p.y,r:e.operatorCircleRadius,fill:"white",stroke:e.edgeColor,"stroke-width":e.edgeWidth}),n("text",{x:p.x,y:p.y,"text-anchor":"middle","dominant-baseline":"central",style:{fontSize:e.operatorFontSize+"px",fill:e.operatorColor,fontWeight:"bold"}},f)))}}return n("svg",{class:"edge-layer",width:this.svgWidth,height:this.svgHeight,style:{position:"absolute",top:"0",left:"0",pointerEvents:"none"}},i,s)}renderSlots(){return this.treeConfig&&this.layout?Array.from(this.treeConfig.allNodes).map((t=>n("div",{key:t,class:"tree-node",style:this.getSlotStyle(t)},n("slot",{name:t})))):null}getFontStyles(){return this.componentStyle((t=>{var e,n,i,s;return{"--bn-font-family":(null===(e=t.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":((null===(n=t.global)||void 0===n?void 0:n.fontSizePx)||13.3333)+"px","--bn-font-color":(null===(i=t.global)||void 0===i?void 0:i.fontColor)||"#000000","--bn-font-background":(null===(s=t.global)||void 0===s?void 0:s.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles();return n(i,{style:t},this.treeConfig&&this.layout?n("div",{class:"tree-container"},n("div",{class:"tree-grid",style:{display:"grid","grid-template-columns":this.layout.gridTemplateColumns,"grid-template-rows":this.layout.gridTemplateRows,position:"relative"}},this.renderEdges(),this.renderSlots())):n("div",{class:"tree-container tree-error"},n("slot",null)))}get element(){return this}static get watchers(){return{edges:[{validateEdgesProp:0}],direction:[{validateDirection:0}],levelSpacing:[{validateLevelSpacing:0}],nodeSpacing:[{validateNodeSpacing:0}],edgeStyle:[{validateEdgeStyle:0}]}}static get style(){return':host{display:inline-block;position:relative;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.tree-container{position:relative;display:inline-block}.tree-grid{position:relative;display:grid;align-items:center}.tree-node{position:relative;z-index:1;border:1px solid #404040;background:var(--bn-font-background, white)}.edge-layer{position:absolute;top:0;left:0;z-index:0;pointer-events:none;overflow:visible}.tree-error{display:flex;flex-wrap:wrap;gap:20px}'}},[257,"bn-tree",{selectedStyle:[513,"selected-style"],edges:[1],direction:[1],levelSpacing:[2,"level-spacing"],nodeSpacing:[2,"node-spacing"],edgeStyle:[1,"edge-style"],i18nNamespace:[513,"i18n-namespace"],showOperators:[4,"show-operators"],treeConfig:[32],layout:[32],nodeRects:[32],svgWidth:[32],svgHeight:[32],getLayoutState:[64]},void 0,{edges:[{validateEdgesProp:0}],direction:[{validateDirection:0}],levelSpacing:[{validateLevelSpacing:0}],nodeSpacing:[{validateNodeSpacing:0}],edgeStyle:[{validateEdgeStyle:0}]}]),D=T,E=function(){"undefined"!=typeof customElements&&["bn-tree"].forEach((t=>{"bn-tree"===t&&(customElements.get(s(t))||customElements.define(s(t),T))}))};export{D as BnTree,E as defineCustomElement}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p as t,H as i,h as s,a as h,t as e}from"./p-D6YGOYV1.js";import{S as n,F as r,a as o,P as a}from"./p-eWxolPDU.js";import{C as l,A as c,g as u,e as d}from"./p-B5tixDPM.js";import{D as f,b as v}from"./p-7ieJFBUk.js";import{c as p,O as g,a as b}from"./p-16rjcQ0t.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 L,V as x,s as k}from"./p-CniN8ALm.js";import{g as M,a as C,I as T}from"./p-4q8nRcWC.js";import{d as O,l as A,S as $}from"./p-BzjGUtYh.js";import{N,r as _}from"./p-fCjsrD7I.js";import{s as D,c as E,a as W,l as B,b as R,d as j,M as Y}from"./p-BTnRaHPb.js";import{d as X,g as V}from"./p-DDvWTgk1.js";import{e as G,r as F}from"./p-ClruFZD_.js";import{S as U}from"./p-BPGLOHUe.js";import{w as z}from"./p-Dq9dG0Kr.js";import{S as H}from"./p-NBaq67dL.js";import{A as I}from"./p-BXg3v5AO.js";class q{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 K{constructor(t){this.top=t.top,this.bottom=t.bottom,this.left=t.left,this.right=t.right}addBoxTopLeft(t){return this.top+=t.height|this.top,this.left+=t.width|this.top,this}}class Q{constructor(t){const i=1*t,s=.7*t;this.bgOffset=(i-s)/2,this.markerUp={top:s/2+",0",left:"0,"+s,right:s+","+s},this.markerUpBackground={top:i/2+",0",left:"0,"+i,right:i+","+i},this.markerDown={bottom:s/2+","+s,left:"0,0",right:s+",0"},this.markerDownBackground={bottom:i/2+","+i,left:"0,0",right:i+",0"}}upMarkerPatternStrings(){return{background:this.markerUpBackground.left+" "+this.markerUpBackground.right+" "+this.markerUpBackground.top+" "+this.markerUpBackground.left,foreground:this.markerUp.left+" "+this.markerUp.right+" "+this.markerUp.top+" "+this.markerUp.left,bgOffset:this.bgOffset}}downMarkerPatternStrings(){return{background:this.markerDownBackground.left+" "+this.markerDownBackground.right+" "+this.markerDownBackground.bottom+" "+this.markerDownBackground.left,foreground:this.markerDown.left+" "+this.markerDown.right+" "+this.markerDown.bottom+" "+this.markerDown.left,bgOffset:this.bgOffset}}createPatternMapForStructureBar(){const t=new Map;return t.set("marker-up",this.upMarkerPatternStrings()),t.set("marker-down",this.downMarkerPatternStrings()),t}}class Z{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 p(new U).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 Q(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(M(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 vt{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 pt{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(){var t,i,s;if(void 0===(null===(t=this.dataPoint)||void 0===t?void 0:t.value))return null===(i=this.label)||void 0===i||i.draw(),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 h=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()),e=h.stroke;let n=h.fill;const r=this.barStyles[this.dataPoint.getScenario()];if(null!=r&&r.fillpattern){const t=this.styles.pattern.get(r.fillpattern);null!=t&&null!=t.pattern&&(n=t.pattern)}this.drawNeedleHead(n,e),this.barGroup.rect(this.dimensions.barLength,this.position.getNeedleWidth()).fill(n).stroke(e).cy(this.dimensions.yPos).x(this.dimensions.xPos),null===(s=this.label)||void 0===s||s.draw()}createDimensions(t,i,s){return i.getScaledPercentUnit()<0?{barLength:Math.abs(i.getScaledPercentUnit()),xPos:t.getBarPositionX()+i.getScaledPercentUnit(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()-this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}:{barLength:i.getScaledPercentUnit(),xPos:t.getBarPositionX(),yPos:t.getBarCenterPositionY(s),labelXPos:this.position.getLabelPositionX(i.getScaledPercentUnit()+this.position.getNeedleWidth()),clipped:i.isClipped(),scenarioLabelXPos:0,scenarioLabelYPos:0}}drawNeedleHead(t,i){if(null===this.dimensions)return;const s=this.styles.varianceStyles.needleHeadColour,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 v=r-6;if(v>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(v).setPoint(this.dataPoint.key).draw()}else new ft(this.group,h,a,"STACK_SEG",s,this.styles,ht.Center,ht.Center).setSegmentFill(c).setMaxWidth(v).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 pt(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 pt(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 pt(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=D([]),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 q(new K(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({},A(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=X(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=G(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 E({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=L(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 x(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 x(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=C(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=D(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 x(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({},A(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 vt({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():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({},A(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({},A(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},z(this)}getDb(){return this.stores||(this.stores=V(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 Z(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 Z(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(Y,.9*r/c);let d=!1,f=!1,v=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&&(v={ppu:t.pixelPerUnit,ppp:t.pixelPerPercentage},c>=.98*r))break}let p=!1;if(h&&!d&&(t.pixelPerUnit=u,p=!0),e&&!f&&(t.pixelPerPercentage=u,p=!0),c>r+.5){if(v)d&&(t.pixelPerUnit=v.ppu),f&&(t.pixelPerPercentage=v.ppp);else{const i=r/c;h&&(t.pixelPerUnit=Math.max(Y,t.pixelPerUnit*i)),e&&(t.pixelPerPercentage=Math.max(Y,t.pixelPerPercentage*i))}p=!0}p&&a(),n()}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){const t=this.getDb(),i=X(t,this.tableName,this.filter);return this.measureScaleError=void 0,new nt(new at,new p(new U),new U,new v,t,i,(t=>{this.measureScaleError=G(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 $),new H(new $),new a).adapt(this.styles);return s.locale=(null===(i=null===(t=V(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 +1 @@
|
|
|
1
|
-
import{p as t,H as e,h as i,a,t as
|
|
1
|
+
import{p as t,H as e,h as i,a as s,t as a}from"./p-D6YGOYV1.js";import{v as r,a as n,b as o,c as d,d as l,e as h,i as u,f as v,g as p}from"./p-BiSytXUy.js";import{w as m,D as c}from"./p-Dq9dG0Kr.js";import{w as f}from"./p-xIWChKGS.js";import{a as b,g}from"./p-DDvWTgk1.js";import{w as D}from"./p-DwuXVo2h.js";import{w as y}from"./p-DjPWZfry.js";import{r as S}from"./p-CniN8ALm.js";import{w}from"./p-D40Am1Ap.js";import{w as k}from"./p-4vVbchX2.js";import{I as j}from"./p-B5tixDPM.js";import{a as N}from"./p-16rjcQ0t.js";import{a as W,D as A}from"./p-sLbQ7yZ1.js";import{d as E}from"./p-C3gYq-HU.js";const R=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.businessUnit="",this.order="category",this.orderDirection="asc",this.dateFormat="none",this.dateLink="none",D(this),m(this),this.t=f(this).t,this.errors=k(this),this.componentStyle=y(this),this.ruleSetConfig=w(this)}validateScenario(t){const e="WARN_scenarios",i=r(t);i.length>0?this.errors.addOrReplace({id:e,type:"warning",message:"scenarios: invalid value(s) '"+(null==i?void 0:i.toString())+"' are not supported."}):this.errors.remove(e)}validateVariances(t){const e="WARN_variances",i=n(t);i.length>0?this.errors.addOrReplace({id:e,type:"warning",message:"variances: invalid value(s) '"+(null==i?void 0:i.toString())+"' are not supported."}):this.errors.remove(e)}validateOrder(t){const e=o(t),i="WARN_order";e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+(null==e?void 0:e.toString())+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const e="WARN_orderDirection";d(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasures(t){const e="WARN_measures",i=l(t);i.length>0?this.errors.addOrReplace({id:e,type:"warning",message:"measures: invalid value(s) '"+(null==i?void 0:i.toString())+'\' are not supported. Valid format example: [{"name": "Bruttoumsatz", "unit": "mEUR"}]'}):this.errors.remove(e)}validateDateStart(t){const e="WARN_dateStart";h(t)||u(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:"dateStart: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateEnd(t){const e="WARN_dateEnd";h(t)||u(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:"dateStart: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateFormat(t){const e="WARN_dateFormat";v(t)||u(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:"dateFormat: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateLink(t){const e="WARN_dateLink";p(t)||u(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:"dateLink: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateMeasures(this.measures),this.validateDateStart(this.dateStart),this.validateDateEnd(this.dateEnd),this.validateDateFormat(this.dateFormat),this.validateDateLink(this.dateLink),this.validateOrderDirection(this.orderDirection),this.validateOrder(this.order)}prepareI18n(){const t=b,e=new Map(["SEPARATOR_WS","in","CONNECTOR_WS"].map((t=>[t,this.t(".".concat(t))]))),i=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...i.entries(),...e.entries(),...S(this.ruleSetConfig("user"))])}prepareI18nMode(){return j.META}prepareLocale(){return g(this.element).context.state.locale||"de"}prepareTitleOrder(){var t;return u(this.order)||u(this.orderDirection)?null:{hierarchy:this.order.split(",").map((t=>t.trim())),direction:N[null===(t=this.orderDirection)||void 0===t?void 0:t.toUpperCase()]}}prepareTitleTimePeriod(){var t,e;return u(this.dateStart)&&u(this.dateEnd)||u(this.dateLink)?null:{start:c.fromISO(this.dateStart,{zone:"utc"}),end:c.fromISO(this.dateEnd,{zone:"utc"}),format:A[null===(t=this.dateFormat)||void 0===t?void 0:t.toUpperCase()],link:W[null===(e=this.dateLink)||void 0===e?void 0:e.toUpperCase()]}}prepareMeasures(){if(u(this.measures))return[];try{return JSON.parse(this.measures)}catch(t){return[]}}prepareScenarios(){var t,e,i,s;if(u(this.scenarios)&&u(this.variances))return[];let a=[];return(null===(t=this.scenarios)||void 0===t?void 0:t.trim().length)>0&&(a=a.concat(null===(e=this.scenarios)||void 0===e?void 0:e.split(","))),(null===(i=this.variances)||void 0===i?void 0:i.trim().length)>0&&(a=a.concat(null===(s=this.variances)||void 0===s?void 0:s.split(","))),a.map((t=>t.trim()))}prepareBusinessUnit(){return u(this.businessUnit)||"null"===this.businessUnit?null:this.businessUnit}getFontStyles(){return this.componentStyle((t=>{var e,i,s,a;return{"--bn-font-family":(null===(e=t.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(s=t.global)||void 0===s?void 0:s.fontColor)||"#000000","--bn-font-background":(null===(a=t.global)||void 0===a?void 0:a.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles();return i(s,{key:"3fab16c08a9023801ce8d6cf2bea9a87945fd1d0",style:t},i("bn-title-renderer",{key:"056569256646abf17f0aaf4151f5add7065439a4",businessUnit:this.prepareBusinessUnit(),scenarios:this.prepareScenarios(),measures:this.prepareMeasures(),timeperiod:this.prepareTitleTimePeriod(),order:this.prepareTitleOrder(),i18n:this.prepareI18n(),"i18n-mode":this.prepareI18nMode(),locale:this.prepareLocale(),ruleSetConfig:this.ruleSetConfig()}))}get element(){return this}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],measures:[{validateMeasures:0}],dateStart:[{validateDateStart:0}],dateEnd:[{validateDateEnd:0}],dateFormat:[{validateDateFormat:0}],dateLink:[{validateDateLink:0}]}}static get style(){return':host{padding:0.5em;margin-bottom:0.5em;box-sizing:border-box;-webkit-box-sizing:border-box;width:100%;display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}'}},[1,"bn-title",{selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],businessUnit:[1,"business-unit"],scenarios:[1],variances:[1],order:[1],orderDirection:[1,"order-direction"],measures:[1],dateStart:[1,"date-start"],dateEnd:[1,"date-end"],dateFormat:[1,"date-format"],dateLink:[1,"date-link"]},void 0,{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],measures:[{validateMeasures:0}],dateStart:[{validateDateStart:0}],dateEnd:[{validateDateEnd:0}],dateFormat:[{validateDateFormat:0}],dateLink:[{validateDateLink:0}]}]);function L(){"undefined"!=typeof customElements&&["bn-title","bn-title-renderer"].forEach((t=>{switch(t){case"bn-title":customElements.get(a(t))||customElements.define(a(t),R);break;case"bn-title-renderer":customElements.get(a(t))||E()}}))}export{R as T,L as d}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as t,p as e,H as i,f as n,a as o,t as s}from"./p-D6YGOYV1.js";import{b as r,a as l,F as a,O as h,T as c,c as u}from"./p-BZXiWkDS.js";import{m as d,a as f,b as p}from"./p-DaOm9YwQ.js";import{p as v,n as m,r as $,d as g}from"./p-BzjGUtYh.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-CniN8ALm.js";import{S as O,I as N,D as _,C as G,d as U,M as x}from"./p-B5tixDPM.js";import{N as T,r as k}from"./p-fCjsrD7I.js";import{D as L,w as C}from"./p-Dq9dG0Kr.js";import{D as P,b as A}from"./p-sLbQ7yZ1.js";import{p as W,c as D}from"./p-16rjcQ0t.js";import{d as B,g as F}from"./p-DDvWTgk1.js";import{D as H,a as I,b as Y}from"./p-7ieJFBUk.js";import{A as j}from"./p-BXg3v5AO.js";import{S as z}from"./p-BPGLOHUe.js";import{S as Q}from"./p-CeE4_3wQ.js";import{w as X}from"./p-DjPWZfry.js";const V="none",Z="setname";function q(t){return t===Z?"COALESCE([setname],[setName])":`normalizeDate([date], '${t}')`}function K(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=L.fromISO(t,{zone:"utc"});return e.isValid?e:void 0}if("number"==typeof t){const e=L.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 it{constructor(t,e,i,n,o,s,r,l,a){this.prefixStyle="prefix",this.isBarChart=!1,this.key=t,this.index=e,this.value=i,this.prefix=s||"",this.cssStyle=n||"",this.prefixStyle=r||"prefix",this.type=o,this.mark=void 0,this.colSpan=l||1,this.measureScale=a||1}getAsHeaderList(){if(null==this.value)return[""];const t=[];for(const e of this.value.toString().split("<br/>"))t.push(e);return t}draw(t,e){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,i){let n=t;if("undefined"===n||void 0===n||null==n)return"";if(Number.isNaN(Number(n)))return n;if(""===this.type||void 0===this.type||null==this.type)return n;let o=e.percent,s=e.percent;return"percentpoint"===this.type?b.number(Number(n),"percent",o,s,1,i).replace(et,""):("decimal"===this.type&&(n=+n/this.measureScale,o=e.decimal,s=e.decimal),b.number(Number(n),this.type,o,s,1,i))}drawPrefix(){return null==this.prefix?"":this.prefix}}class nt{constructor(t,e,i){this.index=t,this.groupindex=e,this.type=i,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,i,n,o,s,l,a,h,c=!1,u,d=1,f){let p=s;"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&&("percent"===n&&(t="-"),"category"!==e&&"operation"!==e&&(n="percent",p="")),("-"===t||t===T&&"percent"===n)&&(p="");let v="prefix-first";l&&(v="prefix-second"),i&&(p=`${p} ${i}`);const m=new it(e,this.elements.length,t,p,n,o,v,d,h);m.isBarChart=c,m.columnStats=u,m.waterfall=f,this.elements.push(m)}}const ot=.85,st=.3,rt=.25,lt={".":.28,",":.28,"-":.34,"%":.89," ":.28," ":.28," ":.28,M:.9};let at;function ht(t,e,i,n,o=!1){const s=()=>function(t,e){var i;let n=0;for(const e of t)n+=null!==(i=lt[e])&&void 0!==i?i:/[0-9+]/.test(e)?.59:.72;return n*e*1.1}(t,e)*(o?1.08:1),r=function(){var t,e,i;if(void 0===at)try{at="undefined"==typeof document?null:null!==(i=null===(e=(t=document.createElement("canvas")).getContext)||void 0===e?void 0:e.call(t,"2d"))&&void 0!==i?i:null}catch(t){at=null}return at}();if(r){r.font="1px __bn_font_sentinel__";const l=r.font;if(r.font=`${n?"italic ":""}${o?"bold ":""}${e}px ${i}`,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 ct(t,e){return Math.max(0,(t-.5)*e)}function ut(t,e,i){const n=void 0!==t.neg,o=void 0!==t.pos||!n,s=(t,n)=>t?e+i+(null!=n?n:0):0;return{sides:(n?1:0)+(o?1:0),neg:s(n,t.neg),pos:s(o,t.pos)}}function dt(t,e,i,n){const{sides:o,neg:s,pos:r}=ut(e,i,n),l=s+r>0?Math.min(1,t/(s+r)):1,a=Math.max(0,(t-(s+r)*l)/o);return{extent:a,axisX:void 0!==e.neg?s*l+a:0}}function ft(t,e,i,n){const o=ct(t,e),{sides:s,neg:r,pos:l}=ut(i,n/2,st*e);return r+l+s*function(t,e,i){return Math.min(1*e,t/(2*i))}(o,e,s)<=o+1e-6}function pt(t,e){const i=.15*t;return{maxBarWidth:t,breakGap:e,overdriveZoneWidth:i,cutWidth:Math.max(0,t-e-i)}}function vt(t,e,i,n){var o,s;const r=ct(t,e),l=st*e,{extent:a,axisX:h}=dt(r,i,rt*e/2,l),c=Math.min(.3*e,.2*a),u=void 0!==i.neg,d=void 0!==i.pos||!u;let f=u?a:0;const p=Math.max(0,null!==(o=null==n?void 0:n.neg)&&void 0!==o?o:0),v=Math.max(0,null!==(s=null==n?void 0:n.pos)&&void 0!==s?s:0);u&&d&&p+v>0&&(f=(c+(2*a*.85-2*c)*p/(p+v))/.85);const m=d?u?2*a-f:a:0;return{totalWidth:r,neg:pt(f,c),pos:pt(m,c),axisX:u?h-a+f:0,labelGap:l}}function mt(t,e,i,n,o){var s,r;const l=ct(t,e),a=st*e,{extent:h,axisX:c}=dt(l,i,n/2,a),u=void 0!==i.neg,d=void 0!==i.pos||!u;let f=u?h:0,p=d?h:0;if(o&&u&&d){const t=2*h,e=Math.max(0,null!==(s=o.neg)&&void 0!==s?s:0),i=Math.max(0,null!==(r=o.pos)&&void 0!==r?r:0);e+i<=t+1e-6?(f=e+(t-e-i)/2,p=t-f):e<h?(f=e,p=t-f):i<h&&(p=i,f=t-p)}return{totalWidth:l,maxPinLength:Math.max(f,p),negPinLength:f,posPinLength:p,axisX:u?c-h+f:0,labelGap:a}}function $t(t,e,i){const n=ct(t,e),o=st*e,s=Math.min(2.85*e,n/4);let r=s,l=s;const a=i?i.max-i.min:0;if(i&&a>0){const t=(t,e)=>Math.max(0,...i.labels.filter((e=>e.pointsLeft===t)).map((n=>n.width+o-(t?n.end-i.min:i.max-n.end)*e)));r=t(!0,0),l=t(!1,0);const e=n/2;for(let i=0;i<8;i++){const i=Math.max(0,n-r-l)/a,o=Math.min(r,t(!0,i)),s=Math.min(l,t(!1,i)),h=o+s<=e||o===r&&s===l;if(r=o,l=s,h)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:n,labelAreaLeft:r,labelAreaRight:l,barAreaWidth:n-r-l,labelGap:o}}const gt={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},bt="#666666";function wt(t,e){return`pattern-${t}-${e.replace("#","")}`}const yt=({styles:e})=>{const i=e.scaleFactor,n=6*i,o=[{id:wt("pos",e.positive.stroke),stroke:e.positive.stroke,fill:e.positive.fill},{id:wt("neg",e.negative.stroke),stroke:e.negative.stroke,fill:e.negative.fill},{id:wt("neu",e.neutral.stroke),stroke:e.neutral.stroke,fill:e.neutral.fill},...["ac","pp","fc","pl"].map((t=>({id:wt(t,e.scenarios[t].stroke),stroke:e.scenarios[t].stroke,fill:e.scenarios[t].fill})))];return t("defs",null,o.map((e=>t("pattern",{id:e.id,patternUnits:"userSpaceOnUse",width:n,height:n},t("rect",{width:n,height:n,fill:"#ffffff"}),t("line",{x1:"0",y1:n,x2:n,y2:"0",stroke:e.stroke,"stroke-width":1.5*i})))))};function St(t,e,i=1,n,o=0,s=!0,r){const l=(e,i)=>(t>0&&e!==i?"+":"")+e;if(e){const e=(t,e)=>s?b.number(t,"percent",e,e,1,n):b.number(100*t,"decimal",e,e,1,n),i=i=>l(e(t,i),e(0,i));let r=Math.min(20,Math.max(0,Math.trunc(o)||0));for(;r>0&&i(r).length>7;)r--;return i(r)}const a=t/i;if(void 0!==r){const t=t=>b.number(t,"decimal",r,r,1,n);return l(t(a),t(0))}const h=Math.abs(a);let c=1,u="";h>=9995e5?(c=1e9,u="B"):h>=999500?(c=1e6,u="M"):h>=999.5&&(c=1e3,u="K");const d=h>=10*c?0:1;return l(b.number(a/c,"decimal",d,0,1,n),b.number(0,"decimal",d,0,1,n))+u}function Rt(t){const e=t.slice(0,2).toLowerCase();return["ac","pp","fc","pl"].includes(e)}function Et(t){const e=t.slice(0,2).toLowerCase();return"pp"===e?"pp":"fc"===e?"fc":"pl"===e?"pl":"ac"}function Mt(t,e){if(Rt(t))return null;const i=new w(t);if(!i.isValid)return null;const n=Et(i.base),o=Et(i.delta);return{minuend:e.scenarios[n],minuendSlot:n,reference:e.scenarios[o],referenceSlot:o}}const Ot=({x:e,height:i,look:n,styles:o})=>{const s=o.scaleFactor,r=rt*o.emPx,{reference:l,referenceSlot:a}=n;let h;if("outlined"===l.fillpattern){const n=r/2-.5*s;h=[e-n,e+n].map((e=>t("line",{x1:e,y1:0,x2:e,y2:i,stroke:l.stroke,"stroke-width":1*s})))}else h=t("line","hatched"===l.fillpattern?{x1:e,y1:0,x2:e,y2:i,stroke:l.stroke,"stroke-width":r,"stroke-dasharray":""+2*s}:{x1:e,y1:0,x2:e,y2:i,stroke:l.fill,"stroke-width":r});return t("g",{class:`variance-axis axis-${a}`},h)};function Nt(t){return void 0!==t.pos||void 0===t.neg}function _t(t,e){return{neg:t.min<0?e:void 0,pos:t.max>0?e:void 0}}function Gt(t,e,i,n){return Rt(t)?function(t,e){const i=Et(t);return e.scenarios[i]}(t,n):function(t,e,i){const n=t>=0;return e?n?i.positive:i.negative:n?i.negative:i.positive}(e,i,n)}function Ut(t,e){const i=t.fillpattern;return"hatched"===i?`url(#${wt(e,t.stroke)})`:"outlined"===i?"transparent":t.fill}function xt(t){return"outlined"===t.fillpattern?{stroke:t.stroke,strokeWidth:1.5}:{stroke:"none",strokeWidth:0}}const Tt=e=>{const{value:i,scenario:n,columnStats:o,height:s,isPositiveGood:r,formattedValue:l,measureScale:a,locale:h,decimalDigits:c,columnWidthEm:u=10,labelWidths:d,sideMax:f,bold:p,styles:v=gt}=e,m=v.scaleFactor,$=v.fontSize,g=l||St(i,!1,a,h,0,!0,c),b=null!=d?d:_t(o,ht(g,$,v.fontFamily,!1,p)),w=i>0||0===i&&Nt(b),{neg:y=Math.max(0,-o.min),pos:S=Math.max(0,o.max)}=null!=f?f:{},R=vt(u,v.emPx,b,{neg:y,pos:S}),{totalWidth:E,axisX:M,labelGap:O}=R,{breakGap:N,overdriveZoneWidth:_,cutWidth:G}=w?R.pos:R.neg,U=Math.abs(i)*v.unitScaling*$,x=U-G>1e-6,T=Math.max(0,(w?S:y)*v.unitScaling*$-G),k=Math.max(0,U-G),L=T>0?k/T*_:0,C=2*m,P=s-2*C,A=C,W=Mt(n,v),D=Gt(n,i,r,v),B=null==W?void 0:W.minuend.fillpattern,F="hatched"===B||"outlined"===B?Object.assign(Object.assign({},D),{fillpattern:B}):D,H=Ut(F,Rt(n)?Et(n):r?w?"pos":"neg":w?"neg":"pos"),{stroke:I,strokeWidth:Y}=W&&"hatched"===F.fillpattern?{stroke:F.stroke,strokeWidth:1}:xt(F),j=W?rt*v.emPx/2:0,z=w?M+j:M-j,Q=x?G:U,X=x?G+N+L:U,V=w?z+X+O:z-X-O,Z=w?"start":"end";return t("svg",{width:E,height:s,class:"cell-bar-chart absolute-variance",style:{overflow:"visible"}},t(yt,{styles:v}),!W&&t("line",{x1:M,y1:0,x2:M,y2:s,stroke:bt,"stroke-width":1*m}),Q>0&&t("rect",{x:w?z:z-Q,y:A,width:Q,height:P,fill:H,stroke:I,"stroke-width":Y*m}),x&&L>0&&t("rect",{x:w?z+G+N:z-G-N-L,y:A,width:L,height:P,fill:H,stroke:I,"stroke-width":Y*m}),x&&function(e,i,n,o,s){const r=e+i/2,l=.35*i,a=o/3,h=.3*i;let c=`M ${r-l} ${n}`;for(let t=0;t<3;t++)c+=` L ${r-l-h} ${n+a*(t+.5)} L ${r-l} ${n+a*(t+1)}`;let u=`M ${r+l} ${n}`;for(let t=0;t<3;t++)u+=` L ${r+l+h} ${n+a*(t+.5)} L ${r+l} ${n+a*(t+1)}`;return[t("rect",{x:e,y:n-1,width:i,height:o+2,fill:"#ffffff"}),t("path",{d:c,fill:"none",stroke:"#000000","stroke-width":1*s}),t("path",{d:u,fill:"none",stroke:"#000000","stroke-width":1*s})]}(w?z+G:z-G-N,N,A,P,m),W&&t(Ot,{x:M,height:s,look:W,styles:v}),t("text",{x:V,y:s/2,dy:"0.35em","text-anchor":Z,fill:v.fontColor,"font-size":$,"font-family":v.fontFamily},g))},kt=e=>{var i,n;const{value:o,scenario:s,columnStats:r,height:l,isPositiveGood:a,formattedValue:h,measureScale:c,locale:u,percentDigits:d,percentSign:f,columnWidthEm:p=10,labelWidths:v,sideMax:m,bold:$,styles:g=gt}=e,b=g.scaleFactor,w=g.fontSize,y=10*b,S=100*g.percentageScaling*w,R=h||St(o,!0,c,u,d,f),E=ht(R,w,g.fontFamily,!0,$),M=null!=v?v:_t(r,E),{neg:O=Math.max(0,-r.min),pos:N=Math.max(0,r.max)}=null!=m?m:{},{totalWidth:_,negPinLength:G,posPinLength:U,axisX:x,labelGap:T}=mt(p,g.emPx,M,y,{neg:O*S,pos:N*S}),k=l/2,L=Math.abs(o)*S,C=o>0||0===o&&Nt(M),P=C?U:G,A=L-P>1e-6,W=C?1:-1,D=x+W*Math.min(L,P),B=Gt(s,o,a,g),F=Mt(s,g),H=null!==(i=null==F?void 0:F.minuend)&&void 0!==i?i:g.scenarios.ac,I=x+W*(P+y/2),Y=1.2*y,j=I-W*Y,z=.2*w,Q=E+2*z,X=Math.abs(j-x)-rt*g.emPx/2,V=A&&X>=Q+2*z,Z=j-W*(z+Q/2)-Q/2,q=V?Z+Q/2:(A?I:D+W*(y/2))+W*T;return t("svg",{width:_,height:l,class:"cell-bar-chart relative-variance",style:{overflow:"visible"}},t(yt,{styles:g}),F?t(Ot,{x,height:l,look:F,styles:g}):t("line",{x1:x,y1:0,x2:x,y2:l,stroke:bt,"stroke-width":1*b}),t("line",{x1:x,y1:k,x2:A?j:D,y2:k,stroke:B.fill,"stroke-width":3*b}),A?t("polygon",{points:`${I},${k} ${j},${k-Y/2} ${j},${k+Y/2}`,fill:B.fill}):t("rect",{x:D-y/2,y:k-y/2,width:y,height:y,fill:"outlined"===H.fillpattern?"#ffffff":Ut(H,null!==(n=null==F?void 0:F.minuendSlot)&&void 0!==n?n:"ac"),stroke:H.stroke,"stroke-width":1*b}),V&&t("rect",{class:"pin-label-band",x:Z,y:k-3*b/2,width:Q,height:3*b,fill:"#ffffff","fill-opacity":"0.5"}),t("text",{x:q,y:l/2,dy:"0.35em","text-anchor":V?"middle":C?"start":"end",fill:g.fontColor,"font-size":w,"font-style":"italic","font-family":g.fontFamily},R))},Lt=e=>{const{value:i,columnStats:n,isRelative:o,styles:s=gt}=e;return null==i||isNaN(i)||!n||0===n.absMax?t("span",{class:"bar-chart-empty",style:{color:s.fontColor,fontStyle:"italic"}},"-"):t(o?kt:Tt,Object.assign({},e))};function Ct(t,e,i,n,o,s=!1){const r=St(t,"partof"===e,i,n,0,!0,o);return s?r:r.replace(/^\+/,"")}const Pt=e=>{var i;const{value:n,scenario:o,height:s,isPositiveGood:r,measureScale:l,locale:a,decimalDigits:h,columnWidthEm:c=10,styles:u=gt,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==n||isNaN(n)||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:$t(c,u.emPx),R=y/g,E=t=>w+(t-d.min)*R,M=2*m,O=s-2*M,N=M,_=E(0),G=E(d.start),U=E(d.end),x=Math.min(G,U),T=Math.abs(U-G),k=Mt(o,u),L=Gt(o,n,r,u),C=null==k?void 0:k.minuend.fillpattern,P="hatched"===C||"outlined"===C?Object.assign(Object.assign({},L),{fillpattern:C}):L,A=Ut(P,k?L===u.positive?"pos":"neg":Et(o)),{stroke:W,strokeWidth:D}=k&&"hatched"===P.fillpattern?{stroke:P.stroke,strokeWidth:1}:xt(P),B=Ct(n,d.kind,l,a,h,null!==k),F=U<G,H=F?x-S:x+T+S,I=F?"end":"start",Y=ht(B,$,u.fontFamily,!1,p),j=S/2,z=(F?H-Y:H)-j,Q=(F?H:H+Y)+j,X=t=>t>z&&t<Q,V=void 0!==d.parentEnd?E(d.parentEnd):void 0,Z=s/2-$/2,q=s/2+$/2,K=(t,e,i,n=0)=>t+n>z&&t-n<Q?[[e,Math.min(i,Z)],[Math.max(e,q),i]].filter((([t,e])=>e>t)):[[e,i]],J=-v.top,tt=s+v.bottom;return t("svg",{width:b,height:s,class:"cell-bar-chart waterfall-bar"+(k?" variance-waterfall":""),style:{overflow:"visible"}},t(yt,{styles:u}),!k&&!X(_)&&t("line",{x1:_,y1:0,x2:_,y2:s,stroke:bt,"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:bt,"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:bt,"stroke-width":1*m,"stroke-dasharray":`${2*m},${2*m}`}),null===(i=d.connectors)||void 0===i?void 0:i.map((({at:e,part:i})=>K(E(e),"bottom"===i?N+O:J,"top"===i?N:tt).map((([i,n])=>t("line",{class:"waterfall-connector",x1:E(e),y1:i,x2:E(e),y2:n,stroke:bt,"stroke-width":1*m}))))),T>0&&t("rect",{x,y:N,width:T,height:O,fill:A,stroke:W,"stroke-width":D*m}),k&&K(_,J,tt,rt*u.emPx/2).map((([e,i])=>t("g",{transform:`translate(0,${e})`},t(Ot,{x:_,height:i-e,look:k,styles:u})))),t("text",{x:H,y:s/2,dy:"0.35em","text-anchor":I,fill:u.fontColor,"font-size":$,"font-family":u.fontFamily},B))},At=`IFNULL(${y.ROWGROUP}, '')`;class Wt{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?At:t)).toString()}select(){return this.groups.map((t=>t===y.ROWGROUP?`${At} as ${t}`:t)).toString()}noCategory(){return this.groups.filter((t=>t!==y.CATEGORY))}toArray(){return this.groups}}function Dt(t,e){return Math.abs(t-e)<=1e-9*Math.max(1,Math.abs(t),Math.abs(e))}function Bt(t,e){const i=(t,e,i)=>{var n;t.connectors=[...null!==(n=t.connectors)&&void 0!==n?n:[],{at:e,part:i}]},n=(t,e,n,o)=>{i(t,o,"bottom"),e.forEach((t=>i(t,o,"through"))),i(n,o,"top")};let o=null;for(const i of t){if(null===i){o=null;continue}const{main:t,children:s}=i,r="anchor"===t.kind?t.end:t.start;if(o&&!i.gapAbove&&Dt(o.main.end,r)&&n(o.main,e?s:o.children,t,r),!i.gapAbove&&!i.gapBelow&&(s.forEach(((t,e)=>{e>0&&n(s[e-1],[],t,t.start)})),s.length>0)){const i=s[s.length-1];e?Dt(i.end,t.end)&&n(i,[],t,t.end):n(t,[],s[0],t.start)}o=i.gapBelow?null:i}}class Ft{constructor(){this.geometry=new Map,this.columns=new Set}set(t,e,i){let n=this.geometry.get(t);n||(n=new Map,this.geometry.set(t,n)),n.set(e,i),this.columns.add(e)}get(t,e){var i;return null===(i=this.geometry.get(t))||void 0===i?void 0:i.get(e)}has(t){return this.columns.has(t)}}function Ht(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 It(t){return`${t}__signed`}function Yt(t){var e;return"-"===(null!==(e=t[y.OPERATION])&&void 0!==e?e:t.restOperation)?-1:1}function jt(t,e,i){const n=t[e];if(null==n)return null;const o=Number(n);if(isNaN(o))return null;if((i===l.OPT||i===l.OPTNOTOTAL)&&t[y.TYPE]===r.ENTRY){const i=t[It(e)];return"number"==typeof i?i:Yt(t)*o}return o}function zt(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 i;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 n=[],o=[],s=[],r=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),l=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),h=this.getRelativeScenarios(),c=this.config.attributes.map((t=>this.translateAttributeSQL(t))).toString(),u=new Wt(this.config),d=this.config.interval===Z?this.config.sortOrder:{hierarchy:this.config.sortOrder.hierarchy.map((t=>{var e,i;return null!==(i=null===(e=W(t))||void 0===e?void 0:e.column)&&void 0!==i?i: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?`, ${At} as ${y.ROWGROUP}, FIRST(${y.ROWGROUPINDEX}) as ${y.ROWGROUPINDEX}${$}`:""}\n FROM ${e} ${this.config.grouped?`GROUP BY ${At} ORDER BY ${g}`:""}`);return 0===b.length||1===b.length&&0===(null!==(i=b[0][y.TOTALROWCOUNT])&&void 0!==i?i:0)&&!this.config.grouped?[]:(this.hasBlankRowGroup=this.config.grouped&&b.some((t=>""===t.rowGroup)),b.forEach((t=>{const e=this.config.grouped?""===t.rowGroup?`WHERE (${y.ROWGROUP} IS NULL OR ${y.ROWGROUP} = '')`:`WHERE ${y.ROWGROUP} = ${this.bind(t.rowGroup)}`:"";let i="";this.config.limit&&(i=`LIMIT ${this.config.limit}`),this.createGroupHeaderRow(t,n),this.createDataRow(n,t,u,r,c,e,f,i),this.createRestRow(t,n,u,r,e,f),this.createGroupSumRow(n,o,t,l,e,f)})),this.createTotalSumRow(n,o,l),n.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,c,f,s),this.createPartOfDrillRows(r,f,o,s),this.createIntervalColumns(s),this.createThereOfDrillColumns(this.config.categoryThereOf,s),this.calculateColumnGroupRest(s,this.config.categoryThereOf),this.calculateRelativeVariances(s,h),s)}detectNaNCells(t,e){e.forEach((e=>{e.map((e=>(t.forEach((t=>{const i=new w(t);!0===i.isValid?0!==e[i.base+"_cnt"]&&0!==e[i.delta+"_cnt"]||(e[t]=Number.NaN):0===e[t+"_cnt"]&&(e[t]=Number.NaN)})),e)))}))}createPartOfDrillRows(t,e,i,n){if(null==this.config.partOf||0===this.config.partOf.length||this.config.type===l.LIST)return;const o=this.createPartOfQuery(t,e);let s=[];const r=this.db,a=this.params;o.forEach((t=>{s.push(...this.exec(t))}));const h=this.exctractScenarioNames(t),c=[];i.forEach((function(t){c.push(...r.exec(t,a))}));const u=new Map;c.forEach((t=>u.set(t[y.ROWGROUP],t))),s=this.reduceResDrillByCategoryGroups(s,h),s.forEach((function(t){h.forEach((e=>{try{t[e]=t[e]/u.get(t[y.ROWGROUP])[e]}catch(i){console.error("DataQuery: partOf drill row calculation failed",e,i),t[e]=Number.NaN}}))})),this.injectDrillRowsToResultRows(s,n)}createRestRow(t,e,i,n,o,s){var r;if(t.totalRowCnt-this.config.limit>0&&0!==this.config.limit){const a=this.exctractScenarioNames(n).map((t=>`SUM(${t}) as ${t}`)).join(", "),h=this.exctractScenarioNames(n).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 ${It(t)}`)).join(""),c=l.OPT===this.config.type||l.OPTNOTOTAL===this.config.type?`, CASE WHEN MAX(transformOperator(operation)) = -1 THEN '-' ELSE '+' END as restOperation${h}`:"";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}${c} ${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}, ${i.select()} ${n.length>0?",".concat(n):""}${this.sortSelect} FROM ${this.fromExpr} ${o} GROUP BY ${i} ORDER BY ${s[0]}) t WHERE t.rowNr > ${this.config.limit}`)}}createDataRow(t,e,i,n,o,s,r,l){t.push(`SELECT ROWNUM() AS ${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 ${i.select()} ${n.length>0?",".concat(n):""} ${o.length>0?",".concat(o):""}${this.sortSelect}\n FROM ${this.fromExpr} ${s}\n GROUP BY ${i}\n ORDER BY ${r[0]} ${l}`)}createGroupHeaderRow(t,e){if(!0===this.config.grouped&&(this.config.showGroupTitle||!this.hasGroupSum())){const i=this.bind(String(t.rowGroup)),n=""===t.rowGroup?this.bind("-"):i;e.push(`SELECT ROWNUM() AS ${y.ROWNR},\n ${e.length} as ${y.ROWGROUPINDEX},\n 'GROUPHEAD' as ${y.TYPE},\n ${i} as ${y.ROWGROUP} ${this.config.showGroupTitle?`,${n} 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 i={};for(const n of t)for(const t of n)if("GROUP_SUM"===t[y.TYPE])for(const n of e)i[n]=zt(i[n],t[n]),t[n]=i[n]}createGroupSumRow(t,e,i,n,o,s){if(!0===this.config.grouped&&this.hasGroupSum()){const r=this.bind(String(i.rowGroup));t.push(`SELECT ${t.length} as ${y.ROWGROUPINDEX},\n '=' as ${y.OPERATION},\n ${r} as ${y.ROWGROUP},\n ROWNUM() AS ${y.ROWNR},\n 'GROUP_SUM' as ${y.TYPE} ${n.length>0?",".concat(n):""}\n FROM ${this.fromExpr} ${o}\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} ${n.length>0?",".concat(n):""}\n FROM ${this.fromExpr} ${o}\n ORDER BY ${s[0]} `)}}createTotalSumRow(t,e,i){var n;if(l.SUM===this.config.type||l.OPT===this.config.type){const e=(null===(n=this.config.title)||void 0===n?void 0:n.trim())||"SUM_TOTAL",o=this.hasPartOf&&!1===this.config.grouped&&"SUM_TOTAL"!==e?`${this.i18n.get("SUM_TOTAL")||"SUM_TOTAL"} ${e}`:e;t.push(`SELECT ${t.length} as ${y.ROWGROUPINDEX},\n ${this.bind(o)} as ${y.ROWGROUP},\n '=' as ${y.OPERATION},\n 'SUM' as ${y.TYPE} ${i.length>0?",".concat(i):""}\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} ${i.length>0?",".concat(i):""}\n FROM ${this.fromExpr} `)}reduceResDrillByCategoryGroups(t,e){const i=new Map;return t.forEach((function(t){const n=t.rowNr+t.rowGroup+t.type+t.category;if(i.has(n)){const o=i.get(n);e.forEach((e=>{try{o[e]+=t[e]}catch(t){console.error("DataQuery: drill row aggregation failed",e,t)}}))}else i.set(n,t)})),[...i.values()]}injectDrillRowsToResultRows(t,e){const i=new Map;if(!0===this.config.grouped)t.forEach((function(t){e.forEach((function(e){const n=e.findIndex((e=>e.category===t.category&&e.rowGroup===t.rowGroup));if(n>=0){if(i.has(`${t.category}_${t.rowGroup}`)){const e=i.get(`${t.category}_${t.rowGroup}`)||0;i.set(`${t.category}_${t.rowGroup}`,e+1)}else i.set(`${t.category}_${t.rowGroup}`,1);t[y.ROWNR]=i.get(`${t.category}_${t.rowGroup}`),e.splice(n+t[y.ROWNR],0,t)}}))}));else{const n=this.findDuplicateSubCategories(t);t.forEach((function(t){e.forEach((function(e){const o=e.findIndex((e=>null!=e.category&&e.category===t.category));if(o>=0){if(i.has(`${t.category}`)){const e=i.get(`${t.category}`)||0;i.set(`${t.category}`,e+1)}else i.set(`${t.category}`,1);null!=t.rowGroup&&""!==t.rowGroup&&n.includes(`${t.category}##${t.subCategory}`)&&(t.rawSubCategory=t.subCategory,t.subCategory=`${t.subCategory} (${t.rowGroup})`),e.splice(o+t[y.ROWNR],0,t)}}))}))}}createThereOfDrillRows(t,e,i,n){if(void 0===this.config.thereOf||0===this.config.thereOf.length)return;const o=[],s=[];this.config.thereOf.forEach((n=>{let s=!0,r="1 <> 1 OR ( ";null!=n.category&&0!==n.category.length&&n.category.trim()&&(r+=` ${y.CATEGORY} = ${this.bind(n.category)}`,s=!1),null!=n.rowGroup&&0!==n.rowGroup.length&&n.rowGroup.trim()&&(r+=` ${s?"":"AND"} ${y.ROWGROUP} = ${this.bind(n.rowGroup)}`,s=!1),null!=n.subCategory&&0!==n.subCategory.length&&n.subCategory.trim()&&(r+=` ${s?"":"AND"} ${y.SUBCATEGORY} = ${this.bind(n.subCategory)}`),r+=")",o.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 ${i[1]}`)})),o.forEach((t=>{s.push(...this.exec(t))})),this.injectDrillRowsToResultRows(s,n)}calculateRelativeVariances(t,e){t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[y.TYPE]&&e.forEach(((e,i)=>{var n;t[i]=null!==(n=k(t[i],t[e]))&&void 0!==n?n:T}))}))}))}calculateColumnGroupRest(t,e){if(null==e||0===e.size)return;const i=new Map,n=new Map;e.forEach(((t,e)=>{const o=t,s=[];for(const t of o)s.push(`${e}##${t.name}`);i.set(e,s),n.set(`${e}##REST`,!1)})),t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[y.TYPE]&&i.forEach(((e,i)=>{let o=0;e.forEach((e=>{void 0!==t[e]&&(o+=t[e])})),t[`${i}##REST`]=t[i]-o,0!==t[`${i}##REST`]&&n.set(`${i}##REST`,!0)}))}))}));const o=Array.from(n.entries()).filter((([t,e])=>!e)).map((([t])=>t));t.forEach((t=>{t.forEach((t=>{for(const e of o)delete t[e]}))}))}createIntervalColumns(t){var e,i,n,o,s;if(this.config.interval===V||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`,h=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),c=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),u=[...new Set(this.exctractScenarioNames(h))],d=this.getRelativeScenarios(),f=new Wt(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 i=new w(e);!0===i.isValid?0!==t[i.base+"_cnt"]&&0!==t[i.delta+"_cnt"]||(t[e]=Number.NaN):0===t[e+"_cnt"]&&(t[e]=Number.NaN)})),d.forEach(((e,i)=>{var n;t[i]=null!==(n=k(t[i],t[e]))&&void 0!==n?n:T})),t),b=(t,e,i)=>{for(const n of this.config.scenarios)t[n+r+i]=e[n]},S=$(`SELECT ${f.select()}, __interval ${h.length>0?",".concat(h):""}\n FROM ${a}\n GROUP BY ${f}, __interval`),R=t=>"ENTRY"===t.type&&null!=t.restRowGroup;if(this.config.limit>0)for(let n=0;n<t.length;n++){const o=t[n].find(R);if(!o)continue;let s;for(let e=n-1;e>=0&&!s;e--){const i=t[e].filter((t=>"ENTRY"===t.type&&!R(t)));i.length>0&&(s=i)}if(!s)continue;const r=new Set(s.map((t=>t.category))),l=s[0].rowGroup,a=new Map;for(const t of S){if(this.config.grouped&&t.rowGroup!==l)continue;if(r.has(t.category))continue;const n=J(t.__interval);let o=a.get(n);o||(o={},a.set(n,o));for(const n of u)o[n]=(null!==(e=o[n])&&void 0!==e?e:0)+(null!==(i=t[n])&&void 0!==i?i:0)}a.forEach(((t,e)=>{b(o,g(t),e)}))}for(const e of S){const i=J(e.__interval);g(e);for(const n of t)for(const t of n)"ENTRY"!==t.type||R(t)||t.category!==e.category||this.config.grouped&&t.rowGroup!==e.rowGroup||p&&t.operation!==e.operation||b(t,e,i)}const E=v||m&&this.config.grouped?$(`SELECT ${At} as ${y.ROWGROUP}, __interval ${c.length>0?",".concat(c):""}\n FROM ${a}\n GROUP BY ${At}, __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(c))],i=t.flat().filter((t=>"GROUP_SUM"===t.type));for(const t of new Set(E.map((t=>J(t.__interval))))){let n;for(const o of i){const i=M.get(`${o.rowGroup}${r}${t}`);if(i){null!=n||(n={});for(const t of e)n[t]=zt(n[t],i[t])}n&&b(o,g(Object.assign({},n)),t)}}}else if(v)for(const e of E){const i=J(e.__interval),n=g(Object.assign({},e));for(const o of t)for(const t of o)"GROUP_SUM"===t.type&&t.rowGroup===e.rowGroup&&b(t,n,i)}const O=l.SUM===this.config.type||l.OPT===this.config.type,N=O||m&&!this.config.grouped?$(`SELECT __interval ${c.length>0?",".concat(c):""}\n FROM ${a}\n GROUP BY __interval`):[],_=new Map;if(N.forEach((t=>_.set(J(t.__interval),t))),O)for(const e of N){const i=J(e.__interval),n=g(Object.assign({},e));for(const e of t)for(const t of e)"SUM"===t.type&&b(t,n,i)}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 ${h.length>0?",".concat(h):""}\n FROM ${a}\n WHERE ${this.createThereOfWhereClause(t)}\n GROUP BY ${this.drillRowGroup}, ${y.CATEGORY}, ${y.SUBCATEGORY}, __interval`))}));for(const i of e){const e=J(i.__interval);g(i);for(const n of t)for(const t of n)"DRILLELEMENT"===t.type&&t.category===i.category&&t.rowGroup===i.rowGroup&&(t.subCategory!==i.subCategory&&t.subCategory!==`${i.subCategory} (${i.rowGroup})`||b(t,i,e))}}if(m){let e="1 <> 1 ";null===(n=this.config.partOf)||void 0===n||n.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 i=$(`SELECT ${y.CATEGORY}, ${this.config.grouped?`${y.ROWGROUP}`:`'SUM_TOTAL' as ${y.ROWGROUP}`}, __interval ${h.length>0?",".concat(h):""}\n FROM ${a}\n WHERE ${e}\n GROUP BY ${y.ROWGROUP}, ${y.CATEGORY}, __interval`),l=new Map;for(const t of i){const e=`${t.rowGroup}${r}${t.category}${r}${J(t.__interval)}`,i=l.get(e);if(i)for(const e of u)i[e]=(null!==(o=i[e])&&void 0!==o?o:0)+(null!==(s=t[e])&&void 0!==s?s:0);else l.set(e,t)}l.forEach((e=>{const i=J(e.__interval),n=this.config.grouped?M.get(`${e.rowGroup}${r}${i}`):_.get(i);for(const t of u)e[t]=e[t]/(n?n[t]:Number.NaN);g(e);for(const n of t)for(const t of n)"PARTELEMENT"===t.type&&t.category===e.category&&t.rowGroup===e.rowGroup&&b(t,e,i)}))}}createThereOfWhereClause(t){let e=!0,i="1 <> 1 OR ( ";return null!=t.category&&0!==t.category.length&&t.category.trim()&&(i+=` ${y.CATEGORY} = ${this.bind(t.category)}`,e=!1),null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(i+=` ${e?"":"AND"} ${y.ROWGROUP} = ${this.bind(t.rowGroup)}`,e=!1),null!=t.subCategory&&0!==t.subCategory.length&&t.subCategory.trim()&&(i+=` ${e?"":"AND"} ${y.SUBCATEGORY} = ${this.bind(t.subCategory)}`),i+")"}getRelativeScenarios(){const t=new Map;return this.config.scenarios.forEach((e=>{const i=this.createRelativeScenario(e);null!=i&&t.set(i.key,i.value)})),t}translateScenarioSQL(t,e,i){const n=new w(t);if(l.OPT===i||l.OPTNOTOTAL===i){if(n.isValid){const i=e?" * transformOperator(operation)":"",o=e?`SUM((${n.base} - ${n.delta})${i}) as ${t}`:`SUM(${n.base} - ${n.delta}) as ${t}`;return"dr"===n.type?`${o}, SUM(${n.delta}${i}) as dr_${n.delta}`:o}return e?`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`:`SUM(${t}) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}return n.isValid?"dr"===n.type?`SUM((${n.base} * transformOperator(operation)) - (${n.delta} * transformOperator(operation))) as ${t}, SUM(${n.delta} * transformOperator(operation)) as dr_${n.delta}`:`SUM((${n.base} * transformOperator(operation))- (${n.delta} * transformOperator(operation))) as ${t}`:`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}translateAttributeSQL(t){const e=`[${t.arg}]`,i=/^(ac|pp|fc|pl)[1-4]$/.test(t.arg)&&this.config.type!==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 i?`AVG(${e} * transformOperator(operation)) as ${t.alias}`:`AVG(${e}) as ${t.alias}`;case"sum":return i?`SUM(${e} * transformOperator(operation)) as ${t.alias}`:`SUM(${e}) as ${t.alias}`;case"lit":{const e=t.arg;return`${this.bind(""===e||Number.isNaN(Number(e))?e:Number(e))} as ${t.alias}`}}}get drillRowGroup(){return this.config.grouped?At: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=h.ASC===t.direction?h.DESC:h.ASC,i=new Map;t.hierarchy.forEach(((t,e)=>{const n=W(t),o=null==n?void 0:n.bucket;("variance"===(null==n?void 0:n.kind)||"scenario"===(null==n?void 0:n.kind)&&void 0!==o)&&i.set(e,this.translateSortKeySQL(n,o,e))})),this.sortSelect=[...i.values()].map((t=>`, ${t}`)).join("");const n=t.hierarchy.some((t=>{var e;const i=null===(e=W(t))||void 0===e?void 0:e.kind;return"scenario"===i||"variance"===i}));n&&(this.sortSelect+=`, CASE WHEN ${y.CATEGORY} = 'REST' THEN 1 ELSE 0 END as __sortrest`);const o=(t,e,n)=>i.has(e)?`__sortnull${e} asc, __sort${e} ${n}`:`${t} ${n}`,s=t.hierarchy.map(((e,i)=>o(e,i,t.direction))).toString(),r=t.hierarchy.map(((t,i)=>o(t,i,e))).toString();return n?[`__sortrest asc, ${s}`,`__sortrest desc, ${r}`]:[s,r]}translateSortKeySQL(t,e,i){const n=l.OPT===this.config.type||l.OPTNOTOTAL===this.config.type?"":" * transformOperator(operation)",o=void 0===e?"":`TRIM(CAST(${q(Z)} AS STRING)) = ${this.bind(e)}`,s=t=>`SUM(${o?`(CASE WHEN ${o} THEN ${t} ELSE 0 END)`:t}${n})`,r=t=>`SUM(CASE WHEN ${o?`${o} AND `:""}${t} IS NOT NULL THEN 1 ELSE 0 END) = 0`;if("scenario"===t.kind)return`${s(t.column)} as __sort${i}, CASE WHEN ${r(t.column)} THEN 1 ELSE 0 END as __sortnull${i}`;const a=`(${s(t.base)} - ${s(t.delta)})`;let h=a,c=`${r(t.base)} OR ${r(t.delta)}`;if("dr"===t.type){const e=s(t.delta),i=`ABS(${e}) <= ABS(${a}) * 0.000000001`;h=`CASE WHEN ${i} THEN 0 ELSE ${a} / ABS(${e}) END`,c+=` OR ${i}`}return`${h} as __sort${i}, CASE WHEN ${c} THEN 1 ELSE 0 END as __sortnull${i}`}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 i;const n=[];let o="1 <> 1 ",s=` ${this.drillRowGroup} as ${y.ROWGROUP}`,r="ROWNUM()";return null===(i=this.config.partOf)||void 0===i||i.forEach((t=>{o+=`OR (${y.CATEGORY} = ${this.bind(t.category)}`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(o+=`and ${y.ROWGROUP} = ${this.bind(t.rowGroup)}`),!1===this.config.grouped&&(s=` 'SUM_TOTAL' as ${y.ROWGROUP} `,r="1"),o+=")"})),n.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 ${o}\n GROUP BY ${this.drillRowGroup}, ${y.CATEGORY}, ${y.TYPE}\n ORDER BY ${e[1]}`),n}checkConfigForPartOf(){return null!=this.config.partOf&&0!==this.config.partOf.length}createThereOfDrillColumns(t,e){if(null==t||0===t.size)return;const i=[],n=[],o=this.fromExpr;t.forEach(((t,e)=>{let n="1 <> 1 ";t.forEach((t=>{n+=` or columnGroup = ${this.bind(String(t.name))} `})),i.push(`SELECT 'ENTRY' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, category, columnGroup, scenario`),i.push(`SELECT 'ENTRY' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, category, columnGroup, columnSubGroup, scenario`),i.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, scenario`),i.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, columnSubGroup, scenario`),i.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, columnGroup, scenario`),i.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, rowGroup, columnGroup, columnSubGroup, scenario`),i.push(`SELECT 'SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n columnGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, columnGroup, scenario`),i.push(`SELECT 'SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n columnGroup,\n columnSubGroup,\n '${e}' as scenario,\n sum(${e} * transformOperator(operation)) as val\n FROM ${o}\n WHERE ${n}\n GROUP BY rowlevel, columnGroup, columnSubGroup, scenario`)}));for(const t of i)n.push(...this.db.exec(t,this.params));this.injectDrillColumnsToResultRows(n,e)}injectDrillColumnsToResultRows(t,e){const i="##";for(const n of t)for(const t of e)for(const e of t)if(e.type===n.rowlevel)if("ENTRY"===n.rowlevel)"COLUMNGROUP"===n.columnlevel&&e.category===n.category?e[n.scenario+i+n.columnGroup]=n.val:"SUBGROUP"===n.columnlevel&&e.category===n.category&&(e[n.scenario+i+n.columnGroup+i+n.columnSubGroup]=n.val);else if("DRILLELEMENT"===n.rowlevel){if(!this.config.grouped&&e.rowGroup!==n.rowGroup)continue;"COLUMNGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory?e[n.scenario+i+n.columnGroup]=n.val:"SUBGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory?e[n.scenario+i+n.columnGroup+i+n.columnSubGroup]=n.val:"COLUMNGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===`${n.subCategory} (${n.rowGroup})`?e[n.scenario+i+n.columnGroup]=n.val:"SUBGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===`${n.subCategory} (${n.rowGroup})`&&(e[n.scenario+i+n.columnGroup+i+n.columnSubGroup]=n.val)}else("SUM"===n.rowlevel||"GROUP_SUM"===n.rowlevel)&&("COLUMNGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory&&(e[n.scenario+i+n.columnGroup]=n.val),"SUBGROUP"===n.columnlevel&&e.category===n.category&&e.subCategory===n.subCategory&&(e[n.scenario+i+n.columnGroup+i+n.columnSubGroup]=n.val))}}class Xt{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,i,n,o,s,l=[],a=0){const h=[];this.attributesByAlias=new Map(l.map((t=>[t.alias,t]))),this.normalizedHeader=this.normalizeHeader(t,e,l,a);const c=this.normalizedHeader.some((t=>void 0!==t.bucket));c&&h.push(this.createIntervalBandRow());const u=new nt(c?1:0,0,r.HEADER),d=new nt(c?2:1,0,r.SEPERATORLINE);for(const t of this.normalizedHeader){const e=this.attributesByAlias.get(t.name);u.createElement(e?i.get(e.label)||e.label:b.translateScenarioLabel(t.name,i),t.type,this.createColumnType(t),null,this.setHeaderPrefix(t,i,n,o,s),null,null,null,null),d.createElement(null,t.type,this.createColumnType(t),null,null,this.underlineClass(t.type),null,null,null)}return h.push(u),h.push(d),h}createIntervalBandRow(){const t=new nt(0,0,r.HEADER);let e=0;for(;e<this.normalizedHeader.length;){const i=this.normalizedHeader[e];if(void 0===i.bucket){t.createElement(null,i.type,"filler",null,null,null,null,null,null),e+=1;continue}let n=1;for(;e+n<this.normalizedHeader.length&&this.normalizedHeader[e+n].bucket===i.bucket;)n+=1;t.createElement(i.bucketLabel,i.type,"intervalGroup",null,null,null,null,null,null,!1,void 0,n),e+=n}return t}setHeaderPrefix(t,e,i,n,o){let s="";return"category"===t.name&&o&&(0===i.prefix.length&&0===n.length||(s=b.translateScenarioLabel("in",e)+" "+i.prefix+n)),t.order&&(s+=b.translateScenarioLabel("ORDER_"+t.order,e)),s}normalizeHeader(t,e,i,n=0){let o=[{name:y.CATEGORY,group:y.CATEGORY,type:y.CATEGORY,order:void 0}];l.OPT!==t&&l.OPTNOTOTAL!==t||(o=[{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=i.map((t=>({name:t.alias,group:t.alias,type:t.alias,order:void 0})));return[...e.slice(0,n),...o,...s,...e.slice(n)]}createBodyRows(t,e,i,n){var o;const s=[];let a=-1;const h=new Qt(t,e);var u;this.dateBuckets=(u=t.interval)!==V&&u!==Z,this.unsignedEntries=l.OPT===t.type||l.OPTNOTOTAL===t.type;const d=h.execute(i,n);this.hasBlankRowGroup=h.hasBlankRowGroup;const f=this.calculateColumnStatistics(d,t.barColumns,t.interval!==V),p=t.thereOfPosition===c.ABOVE,v=null!==(o=t.barColumns)&&void 0!==o?o:[],m=v.filter((t=>t.toUpperCase().trim()in O)),$=[...m.length>0&&Ht(d)?m:[],...t.varianceWaterfall?v.filter((t=>"d"===new w(t).type)):[]],g=$.length>0&&t.interval===V&&0===t.categoryThereOf.size?function(t,e,i,n=!1,o=!1){const s=new Ft,a=i===l.OPT||i===l.OPTNOTOTAL;for(const l of e){const e=new w(l).isValid;let h,c=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){n||(c=0),h=void 0,m(null);continue}const d=jt(t,l,i);if(s===r.ENTRY){if(null===d){h=void 0,m(null);continue}m(v(t,{start:c,end:c+d,min:0,max:0,kind:"cascade"})),h={start:c,end:c+d,sign:a?Yt(t):1},u=h.start,c+=d}else if(s===r.SUM||s===r.GROUPSUM){if(null===d){h=void 0,m(null);continue}m(v(t,{start:0,end:d,min:0,max:0,kind:"anchor"})),h={start:0,end:d,sign:1},u=0,c=s!==r.GROUPSUM||n?d:0}else if(!e||s!==r.DRILLELEMENT&&s!==r.PARTELEMENT){if(s===r.DRILLELEMENT){if(null===d||void 0===h)continue;const e=u+(Math.sign(h.end-h.start)||1)*Math.abs(d);v(t,{start:u,end:e,min:0,max:0,kind:"thereof",parentStart:h.start,parentEnd:h.end}),u=e}else if(s===r.PARTELEMENT){if(null===d||void 0===h)continue;const e=u+d*(h.end-h.start);v(t,{start:u,end:e,min:0,max:0,kind:"partof",parentStart:h.start,parentEnd:h.end}),u=e}}else if(s===r.DRILLELEMENT&&null!==d&&void 0!==h&&p){const e=u+h.sign*d;p.children.push(v(t,{start:u,end:e,min:0,max:0,kind:"thereof"})),u=e}else p&&(o&&s===r.DRILLELEMENT?p.gapAbove=!0:p.gapBelow=!0)}e&&Bt(f,o);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,h.hasRunningSum(),p):void 0;for(const i of d)a+=1,s.push(...this.createRow(t.i18n,e,t.scenariosUnitType,i,a,-1,t.categoryWidth,t.measureScale,t.barColumns,f,g,p));return s}calculateColumnStatistics(t,e,i=!1){const n=new Map;if(!e||0===e.length)return n;const o=new Map;for(const t of e)n.set(t,{min:1/0,max:-1/0,absMax:0,median:0}),o.set(t,[]);for(const s of t)for(const t of s){const s=t[y.TYPE];if(s!==r.SUM&&s!==r.GROUPSUM)for(const s of e){const e=i?this.extractIntervalColumnValues(t,s):[this.extractColumnValue(t,s)];for(const t of e)if(null!==t&&!isNaN(t)){const e=n.get(s);e.min=Math.min(e.min,t),e.max=Math.max(e.max,t),o.get(s).push(Math.abs(t))}}}for(const[t,e]of n){e.min!==1/0&&e.max!==-1/0||(e.min=0,e.max=0),e.absMax=Math.max(Math.abs(e.min),Math.abs(e.max));const i=o.get(t);if(i.length>0){i.sort(((t,e)=>t-e));const t=Math.floor(i.length/2);e.median=i.length%2==0?(i[t-1]+i[t])/2:i[t]}n.set(t,e)}return n}extractIntervalColumnValues(t,e){const i=e+"##",n=[];for(const e of Object.keys(t))if(e.startsWith(i)){const i=Number(t[e]);n.push(isNaN(i)?null:i)}return n}extractColumnValue(t,e){if(void 0!==t[e]){const i=Number(t[e]);return isNaN(i)?null:i}for(const i of Object.keys(t))if(i===e||i.endsWith("##"+e)||i===e+"##"+e){const e=Number(t[i]);if(!isNaN(e))return e}return null}createRow(t,e,i,n,o,s,l,a,h,c,u,d=!1){var f,p,m;const $=[];let g,b,S=-1;for(const R of n){const E=R[y.ROWGROUP],M=""===E?"-":E,O=R[y.SUBCATEGORY],N=R[y.TYPE],_=R[y.ROWNR]>=2;b=null!==(p=null!==(f=R.operation)&&void 0!==f?f:R.restOperation)&&void 0!==p?p:b;const G=d&&N===r.DRILLELEMENT&&void 0!==g&&g[y.CATEGORY]===R[y.CATEGORY]&&("NO_GROUP"===g[y.ROWGROUP]||g[y.ROWGROUP]===E),U=this.createDetailRow(N,s+=1,o,n.length);U.key=this.rowKey(R);for(const n of this.normalizedHeader){const o=this.getRawDataRowElement(R,n),s=null!==(m=null==h?void 0:h.includes(n.type))&&void 0!==m&&m,d=s&&void 0===n.bucket&&n.name===n.group&&n.name===n.type?null==u?void 0:u.get(R,n.type):void 0,f=s&&!(N===r.PARTELEMENT&&new w(n.type).isValid&&(null==u?void 0:u.has(n.type))),p=f?null==c?void 0:c.get(n.type):void 0;U.createElement(this.translateSumCellLabel(t,e,o,M,O,N,n.type),n.type,this.createColumnType(n),this.setCellType(n.type,i),G?null:this.translateCellPrefix(e,N,n.type),this.translateScenarioCSS(n.type,o,b),_,l,null==a?void 0:a.value,f,p,1,d);const $=U.elements[U.elements.length-1];this.dateBuckets&&void 0!==n.bucket&&($.date=v(n.bucket));const g=new w(n.type);g.isValid&&($.direction=this.resolveDirection(g,b))}G?(U.cssStyle="ofit-above",$[S].cssStyle="ofit-sum",$.splice(S,0,U),S+=1):(N===r.ENTRY&&(S=$.length,g=R),$.push(U))}return $}rowKey(t){var e;const i=null!=t.restRowGroup?t.restRowGroup:"NO_GROUP"===t.rowGroup?void 0:t.rowGroup;switch(t.type){case r.ENTRY:return{rowGroup:i,category:t.category,subCategory:t.subCategory};case r.DRILLELEMENT:return{rowGroup:i,category:t.category,subCategory:null!==(e=t.rawSubCategory)&&void 0!==e?e:t.subCategory};case r.GROUPSUM:return{rowGroup:i,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,i,n){switch(t){case r.GROUPHEAD:return new nt(e,i,r.HEADER);case r.SUM:case r.GROUPSUM:return new nt(n+2,i,r.SUM);case r.DRILLELEMENT:return new nt(n+2,i,r.DRILLELEMENT);case r.PARTELEMENT:return new nt(n+2,i,r.PARTELEMENT);default:return new nt(e,i,r.STANDARD)}}translateSumCellLabel(t,e,i,n,o,s,r){return this.attributesByAlias.has(r)||!1===Number.isNaN(Number(i))||this.isOperationColumn(r)?i:this.isGroupHeadCategory(s,r)?t===N.ALL?`${e.get(i)||i}`:i:this.isEntryCategory(s,r)?t===N.ALL||"REST"===i?`${e.get(i)||i}`:i:this.isDrillElementCategory(s,r)?t===N.ALL?`${e.get(o)||o}`:`${o}`:this.isPartElementCategory(s,r)?t===N.ALL||"SUM_TOTAL"===n?`${e.get(n)||n}`:`${n}`:this.isSumElementCategory(s,r)?t===N.ALL||"SUM_TOTAL"===n?`${e.get(n)||n}`:n:"GROUPHEAD"===s&&null==i||i===T?i:Number.isNaN(Number(i))?"-":Number(i)}isOperationColumn(t){return"operation"===t}translateScenarioCSS(t,e,i){if(this.attributesByAlias.has(t))return"attribute";const n=new w(t);let o="pos";return e<0&&(o="neg"),n.isValid?o+"_"+this.resolveDirection(n,i)+("dr"===n.type?" relative_variance":""):t}resolveDirection(t,e){return R(t.direction,e,!this.unsignedEntries)}setCellType(t,e){if("category"===t)return"";const i=this.attributesByAlias.get(t);if(i)return i.isNumeric?"decimal":"";let n;const o=new w(t);return e===_.PERCENT?(n="percent",o.isValid&&"d"===o.type&&(n="percentpoint")):(n="decimal",o.isValid&&"dr"===o.type&&(n="percent")),n}isDrillElementCategory(t,e){return"DRILLELEMENT"===t&&"category"===e}isPartElementCategory(t,e){return"PARTELEMENT"===t&&"category"===e}isSumElementCategory(t,e){return("GROUP_SUM"===t||"SUM"===t)&&"category"===e}isEntryCategory(t,e){return"ENTRY"===t&&"category"===e}isGroupHeadCategory(t,e){return"GROUPHEAD"===t&&"category"===e}translateCellPrefix(t,e,i){return this.isOperationColumn(i)||this.isGroupHeadCategory(e,i)||this.isEntryCategory(e,i)?null:this.isDrillElementCategory(e,i)?`${t.get("thereof")} `:this.isPartElementCategory(e,i)?`${t.get("part_of")} `:null}createColumnType(t){return t.name===t.group&&t.name===t.type?"base":t.name===t.group?"columnGroup":"columnSubGroup"}}class Vt{constructor(t,e,i,n){this.fromExpr="",this.rowCount=0,this.headerRows=[],this.bodyRows=[],this.intervalBuckets=[],this.ruleSet=t||new E,this.db=e,this.dataSetFactory=new Xt(this.ruleSet),this.config=this.initConfig(n),this.i18n=this.initI18n(new Map),this.setSource(i,n.filter)}setI18n(t){this.i18n=this.initI18n(t)}initI18n(t){const e=new Map([["",""],["SEPARATOR_WS",", "],["in","in"],["ORDER_asc","↑"],["ORDER_desc","↓"],["ac1","AC"],["pp1","PY"],["fc1","FC"],["pl1","PL"],["ac2","AC2"],["pp2","PY2"],["fc2","FC2"],["pl2","PL2"],["ac3","AC3"],["pp3","PY3"],["fc3","FC3"],["pl3","PL3"],["ac4","AC4"],["pp4","PY4"],["fc4","FC4"],["pl4","PL4"],["category"," "],["operation"," "],["thereof","davon"],["part_of","in % von"],["ibcssymbol_delta_ac","Δ{%}"],["ibcssymbol_delta_generic","Δ({%})"],["ibcssymbol_delta_ac_relative","Δ{%}%"],["ibcssymbol_delta_generic_relative","Δ({%})%"],["SUM_TOTAL","❖"]]);return this.state=u.DIRTY,new Map([...e,...t||new Map])}initConfig(t){this.state=u.DIRTY;const e=t,i=this;return t.scenarios.sort(((t,e)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(e))),e}setConfig(t){this.config=this.initConfig(t)}setSource(t,e){var i,n;if(this.state=u.DIRTY,this.fromExpr=B(this.db,t,e),!this.fromExpr)return void(this.rowCount=0);const o=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(n=null===(i=o[0])||void 0===i?void 0:i.cnt)&&void 0!==n?n:0}update(){this.prepareIntervalBuckets();const t=this.normalizeScenarios(this.config.scenarios,this.config.categoryThereOf,this.config.sortOrder,this.intervalBuckets);this.headerRows=this.dataSetFactory.createHeader(this.config.type,t,this.i18n,this.config.measureScale,this.config.measureUnit,this.config.showMeasureScale,this.config.attributes,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===V||!this.fromExpr||this.config.categoryThereOf.size>0?this.config.interval=V:(this.config.interval=function(t,e,i){var n;if(i!==P.AUTO)return i;const o=t.exec(`SELECT [date] as d FROM ${e}`);let s,r;for(const t of o){const e=null===(n=tt(t.d))||void 0===n?void 0:n.toMillis();void 0!==e&&(s=void 0===s?e:Math.min(s,e),r=void 0===r?e:Math.max(r,e))}return void 0===s||void 0===r?P.DAY:(new A).calculateDistanceType(L.fromMillis(s),L.fromMillis(r))}(this.db,this.fromExpr,this.config.interval),this.intervalBuckets=function(t,e,i,n){if(i===Z){const n=t.exec(`SELECT ${q(i)} as __interval, COALESCE([setnameIndex],[setNameIndex]) as __index FROM ${e}`),o=new Set,s=new Map,r=[];for(const t of n){const e=J(t.__interval);o.has(e)||(o.add(e),r.push({key:e,label:0===e.length?"-":e}));const i=K(t.__index),n=s.get(e);void 0!==i&&(void 0===n||i<n)&&s.set(e,i)}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,i)=>t(e)===t(i)?0:t(e)<t(i)?-1:1))}return r}const o=t.exec(`SELECT ${q(i)} as __interval FROM ${e}`),s=new Set,r=[];for(const t of o){const e=tt(t.__interval);if(!e)continue;const i=e.toISO();s.has(i)||(s.add(i),r.push(e))}r.sort(((t,e)=>t.toMillis()-e.toMillis()));const l=new A;return l.setLocale(n),r.map((t=>({key:t.toISO(),label:l.getDateString(t,i)})))}(this.db,this.fromExpr,this.config.interval,this.config.locale),0===this.intervalBuckets.length&&(this.config.interval=V))}normalizeScenarios(t,e,i,n=[]){var o;const s=[],r=null===(o=null==i?void 0:i.hierarchy)||void 0===o?void 0:o.map((t=>W(t))).find((t=>"dim"!==(null==t?void 0:t.kind))),l=this.config.interval===Z?null==r?void 0:r.bucket:void 0,a=(t,e)=>{var n;return null==r||(null===(n=W(t))||void 0===n?void 0:n.column)!==r.column||void 0!==l&&l!==e?void 0:i.direction};if(n.length>0){for(const e of n)for(const i of t)s.push({name:i,group:i,type:i,order:a(i,e.key),bucket:e.key,bucketLabel:e.label});return s}for(const i of t){if(null==e?void 0:e.has(i)){const t=e.get(i);for(const e of t){s.push({name:e.name,group:e.name,type:i,order:void 0});for(const t of e.subGroups)s.push({name:t,group:e.name,type:i,order:void 0})}s.push({name:"REST",group:"REST",type:i,order:void 0})}s.push({name:i,group:i,type:i,order:a(i)})}return s}hasNoData(){return 0===this.rowCount}orderBucketWarning(){var t,e;if(this.hasNoData()||this.state!==u.UP_TO_DATE)return;const i=(null!==(e=null===(t=this.config.sortOrder)||void 0===t?void 0:t.hierarchy)&&void 0!==e?e:[]).map((t=>{var e;return null===(e=W(t))||void 0===e?void 0:e.bucket})).filter((t=>void 0!==t));if(0===i.length)return;if(this.config.interval!==Z)return`order: '@${i[0]}' needs interval setname, the bucket is ignored.`;const n=i.find((t=>!this.intervalBuckets.some((e=>e.key===t))));return void 0===n?void 0:`order: setname '${n}' not found, the rows are not sorted by it.`}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=c.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=N.ALL,this.categoryWidth=U.W25,this.measureScale=new Q,this.measureUnit="",this.measureType=x.VOLUME,this.showMeasureScale=!0,this.filter="",this.barColumns=[],this.interval="none",this.categoryIntervalPosition=0,this.locale="de"}}class qt{constructor(t,e,i,n,o,s){this.tableDrillGroupAdapter=t,this.stringAdapter=e,this.orderAdapter=i,this.db=n,this.fromExpr=o,this.onQueryError=s}adapt(t){const e=new Zt;return G.isString(t.title)&&(e.title=t.title),G.isArray(t.scenarios)&&(e.scenarios=j.adaptArray(t.scenarios,this.stringAdapter)),G.isExisting(t.scenariosUnitType)&&(e.scenariosUnitType=t.scenariosUnitType),G.isBoolean(t.grouped)&&(e.grouped=t.grouped),G.isBoolean(t.showGroupTitle)&&(e.showGroupTitle=t.showGroupTitle),G.isBoolean(t.runningSum)&&(e.runningSum=t.runningSum),G.isBoolean(t.varianceWaterfall)&&(e.varianceWaterfall=t.varianceWaterfall),t.thereOfPosition===c.ABOVE&&(e.thereOfPosition=c.ABOVE),G.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),G.isArray(t.thereOf)&&(e.thereOf=j.adaptArray(t.thereOf,this.tableDrillGroupAdapter)),G.isExisting(t.categoryThereOf)&&(e.categoryThereOf=t.categoryThereOf),G.isArray(t.partOf)&&(e.partOf=j.adaptArray(t.partOf,this.tableDrillGroupAdapter)),G.isArray(t.attributes)&&(e.attributes=t.attributes),G.isExisting(t.order)&&(e.sortOrder=this.orderAdapter.adapt(t.order)),G.isExisting(t.type)&&(e.type=t.type),G.isNumber(t.limit)&&(e.limit=t.limit),G.isExisting(t.i18n)&&(e.i18n=t.i18n),G.isExisting(t.categoryWidth)&&(e.categoryWidth=t.categoryWidth),G.isExisting(t.measureScale)&&(e.measureScale=H.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale,this.onQueryError)),G.isExisting(t.measureType)&&(e.measureType=t.measureType),G.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),G.isString(t.filter)&&(e.filter=t.filter.trim()),G.isArray(t.barColumns)&&(e.barColumns=t.barColumns),G.isString(t.interval)&&(e.interval=t.interval),G.isNumber(t.categoryIntervalPosition)&&(e.categoryIntervalPosition=t.categoryIntervalPosition),G.isString(t.locale)&&(e.locale=t.locale),e}default(){return new Zt}}class Kt{constructor(){this.rowGroup="",this.category="",this.subCategory="",this.partOf=""}}class Jt{constructor(){}adapt(t){const e=new Kt;return G.isString(t.rowGroup)&&(e.rowGroup=t.rowGroup),G.isString(t.category)&&(e.category=t.category),G.isString(t.subCategory)&&(e.subCategory=t.subCategory),G.isString(t.partOf)&&(e.partOf=t.partOf),e}default(){return new Kt}}const te=e(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.tableName="",this.dataVersion=0,this.sumTitle="SUM_TOTAL",this.scenarios=[],this.scenariosDataFormat=_.DECIMAL,this.grouped=!1,this.limit=0,this.showGroupTitle=!0,this.runningSum=!1,this.varianceWaterfall=!1,this.thereof=[],this.thereofPosition=c.BELOW,this.partof=[],this.order={hierarchy:[],direction:h.ASC},this.categorythereof=new Map,this.attributeColumns=[],this.type=l.LIST,this.categoryWidth=U.INF,this.dataFormatDigits={percent:2,decimal:1},this.i18n=new Map,this.i18nMode=N.ALL,this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.measureType=x.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.barColumnLayouts=new Map,this.waterfallGeometries=new Map,this.relayout=()=>{(this.barColumnLayouts.size>0||this.waterfallGeometries.size>0)&&n(this)},C(this),this.componentStyle=X(this)}connectedCallback(){var t;null===(t=document.fonts)||void 0===t||t.addEventListener("loadingdone",this.relayout)}disconnectedCallback(){var t;null===(t=document.fonts)||void 0===t||t.removeEventListener("loadingdone",this.relayout)}async getLayoutDetail(t,e){var i,n,o;const s={regions:[],metadata:{},diagnostics:[]},r=null===(i=this.element.shadowRoot)||void 0===i?void 0:i.querySelector("table");if(s.metadata.hasNoData=null===(o=null===(n=this.table)||void 0===n?void 0:n.hasNoData())||void 0===o||o,!this.table||!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 h=this.table.getHeader(),c=this.table.getBody(),u=this.table.getColumns();if(s.metadata.headerRowCount=h.length,s.metadata.rowCount=c.length,s.metadata.columnCount=u.length,s.metadata.cellCount=c.reduce(((t,e)=>t+e.getCells().length),0),"full"!==e)return s;const v=[],m=[],g=(e,i,n)=>{const o=n?Array.from(n.children).filter((t=>"tr"===t.localName)):[];i.forEach(((i,n)=>{const r=o[n];if(!r)return;v.push({section:e,index:n,type:i.type,rect:d(r,t),point:$(r)});const l=i.getCells(),a=Array.from(r.children);l.length===a.length?l.forEach(((i,o)=>{var s,r;const l=a[o],h={kind:"header"===e?"headerCell":"cell",row:n,column:i.index,key:i.key||void 0,colSpan:i.colSpan,value:null!==(s=i.value)&&void 0!==s?s:void 0,text:(null===(r=l.textContent)||void 0===r?void 0:r.trim())||void 0,type:i.type||void 0,rect:d(l,t),point:$(l)};h.point&&(h.content=f(l,t),h.contentSign=p(l)||void 0);const c=l.querySelector("svg.cell-bar-chart");c&&(h.bar={variant:c.classList.contains("waterfall-bar")?"waterfall":c.classList.contains("relative-variance")?"relative":"absolute",rect:d(c,t)}),m.push(h)})):s.diagnostics.push({id:`WARN_layout_cell_pairing_${e}_${n}`,type:"warning",message:`layout-state: model/DOM cell count mismatch in ${e} row ${n} (${l.length} vs ${a.length}); cell details skipped for this row.`})}))};return g("header",h,l),g("body",c,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(o,{class:{"no-data":!0===(null===(e=this.table)||void 0===e?void 0:e.hasNoData())}},(()=>{var e,i,n,o;if(void 0===this.table)return;if(this.table.hasNoData()){const i=null!==(e=this.i18n.get("no-data"))&&void 0!==e?e:"No Data";return t("div",{class:"empty-state"},i)}const s=null===(o=null===(n=null===(i=this.stores)||void 0===i?void 0:i.context)||void 0===n?void 0:n.state)||void 0===o?void 0:o.locale;return t("table",null,t("thead",null,this.table.getHeader().map((e=>t("tr",{class:e.cssStyle},e.getCells().map((e=>t("th",{colSpan:e.colSpan,class:e.cssStyle},e.getAsHeaderList().map(((i,n,o)=>t("span",null,n===o.length-1?t("span",{class:" "===i?"table-footer":""},i,e.drawPrefix()," "):t("span",null,i,e.drawPrefix(),t("br",null)))))))))))),t("tbody",null,this.table.getBody().map((e=>t("tr",Object.assign({class:e.cssStyle},g(e.key,"element")),null==e?void 0:e.getCells().map((i=>{var n,o,l,a,h;return t("td",Object.assign({colSpan:i.colSpan,class:i.type?`${this.cellClass(i,s)} ${i.type}`:i.cssStyle},e.key&&null!=i.value&&""!==i.value&&"-"!==i.value?g(Object.assign(Object.assign({},e.key),{date:i.date,scenario:i.key}),"element"):{}),null!=i.prefix?t("span",{class:this.cellClass(i,s)+" "+i.prefixStyle},i.drawPrefix()):"",!i.isBarChart||!i.columnStats||i.value===T||!this.showGroupTitle&&e.type===r.HEADER||void 0===i.waterfall&&e.type===r.SUM||void 0!==i.direction&&i.waterfall&&i.waterfall.max===i.waterfall.min?i.draw(this.componentDataFormatDigits,s):void 0!==i.waterfall?t(Pt,{value:i.value,scenario:i.key,columnStats:i.columnStats,height:18*this.scaleFactor,isRelative:!1,isPositiveGood:"pos"===i.direction,measureScale:ie(i),locale:s,decimalDigits:ne(i,this.componentDataFormatDigits),columnWidthEm:this.barColumnMaxWidth,styles:this.barChartStyles,waterfall:i.waterfall,geometry:this.waterfallGeometries.get(i.key),bold:ee(e),connectorReach:this.connectorReach(e)}):t(Lt,{value:i.value,scenario:i.key,columnStats:i.columnStats,height:18*this.scaleFactor,isRelative:i.key.startsWith("dr"),isPositiveGood:"pos"===i.direction,measureScale:ie(i),locale:s,decimalDigits:ne(i,this.componentDataFormatDigits),percentDigits:null!==(o=null===(n=this.barColumnLayouts.get(i.key))||void 0===n?void 0:n.percentDigits)&&void 0!==o?o:this.componentDataFormatDigits.percent,percentSign:null===(l=this.barColumnLayouts.get(i.key))||void 0===l?void 0:l.percentSign,columnWidthEm:this.barColumnMaxWidth,labelWidths:null===(a=this.barColumnLayouts.get(i.key))||void 0===a?void 0:a.labels,sideMax:null===(h=this.barColumnLayouts.get(i.key))||void 0===h?void 0:h.sideMax,bold:ee(e),styles:this.barChartStyles}))})))))))})())}componentWillRender(){var t,e,i,n,o,s,r,l,a,h,c;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 Vt(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===(i=this.table)||void 0===i?void 0:i.hasBlankRowGroup())?null===(n=this.errors)||void 0===n||n.addOrReplace({id:"WARN_blankRowGroup",type:"warning",message:"grouped: rows with blank rowGroup found, they are grouped under '-'."}):null===(o=this.errors)||void 0===o||o.remove("WARN_blankRowGroup");const 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===(h=this.errors)||void 0===h||h.addOrReplace({id:t,type:"warning",message:f.message}):null===(c=this.errors)||void 0===c||c.remove(t);this.barColumnLayouts=this.collectBarColumnLayouts(),this.waterfallGeometries=this.collectWaterfallGeometries(),this.barChartStyles=this.prepareBarChartStyles()}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,i,n;const o=B(t,this.tableName,this.filter);return new qt(new Jt,new z,new D(new z,!0),t,o,(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===(n=null===(i=null===(e=this.stores)||void 0===e?void 0:e.context)||void 0===i?void 0:i.state)||void 0===n?void 0:n.locale)||"de"})}prepareBarChartStyles(){var t;const e=!(this.unitScaling>0),i=!(this.percentageScaling>0),n=e?this.autoUnitScaling():this.unitScaling,o=i?this.autoPercentageScaling():this.percentageScaling;return(e||i)&&(null===(t=this.reportAutoScaling)||void 0===t||t.call(this,{unit:e?n:void 0,percentage:i?o:void 0})),this.componentStyle((t=>{var e,i,s,r,l,a,h,c,u,d,f,p,v,$,g,b,w,y,S,R,O,N,_,G,U,x;const T=null===(e=t["bn-chart-time"])||void 0===e?void 0:e.varianceStyles,k=null===(i=t["bn-chart-time"])||void 0===i?void 0:i.barStyles;return{positive:{stroke:(null===(s=null==T?void 0:T.pos)||void 0===s?void 0:s.stroke)||"#008f96",fill:(null===(r=null==T?void 0:T.pos)||void 0===r?void 0:r.fill)||"#008f96",fillpattern:m(null===(l=null==T?void 0:T.pos)||void 0===l?void 0:l.fillpattern)||"solid"},negative:{stroke:(null===(a=null==T?void 0:T.neg)||void 0===a?void 0:a.stroke)||"#ff0000",fill:(null===(h=null==T?void 0:T.neg)||void 0===h?void 0:h.fill)||"#ff0000",fillpattern:m(null===(c=null==T?void 0:T.neg)||void 0===c?void 0:c.fillpattern)||"solid"},neutral:{stroke:(null===(u=null==T?void 0:T.neu)||void 0===u?void 0:u.stroke)||"#808080",fill:(null===(d=null==T?void 0:T.neu)||void 0===d?void 0:d.fill)||"#808080",fillpattern:m(null===(f=null==T?void 0:T.neu)||void 0===f?void 0:f.fillpattern)||"outlined"},scenarios:M({ac:{stroke:(null===(p=null==k?void 0:k.ac)||void 0===p?void 0:p.stroke)||"#404040",fill:(null===(v=null==k?void 0:k.ac)||void 0===v?void 0:v.fill)||"#404040",fillpattern:m(null===($=null==k?void 0:k.ac)||void 0===$?void 0:$.fillpattern)||"solid"},pp:{stroke:(null===(g=null==k?void 0:k.pp)||void 0===g?void 0:g.stroke)||"#A6A6A6",fill:(null===(b=null==k?void 0:k.pp)||void 0===b?void 0:b.fill)||"#A6A6A6",fillpattern:m(null===(w=null==k?void 0:k.pp)||void 0===w?void 0:w.fillpattern)||"solid"},fc:{stroke:(null===(y=null==k?void 0:k.fc)||void 0===y?void 0:y.stroke)||"#404040",fill:(null===(S=null==k?void 0:k.fc)||void 0===S?void 0:S.fill)||"#ffffff",fillpattern:m(null===(R=null==k?void 0:k.fc)||void 0===R?void 0:R.fillpattern)||"hatched"},pl:{stroke:(null===(O=null==k?void 0:k.pl)||void 0===O?void 0:O.stroke)||"#404040",fill:(null===(N=null==k?void 0:k.pl)||void 0===N?void 0:N.fill)||"#ffffff",fillpattern:m(null===(_=null==k?void 0:k.pl)||void 0===_?void 0:_.fillpattern)||"outlined"}},new E(this.ruleSetConfig)),fontColor:(null===(G=t.global)||void 0===G?void 0:G.fontColor)||"#000000",fontSize:((null===(U=t.global)||void 0===U?void 0:U.fontSizePx)||13.3333)*ot*this.scaleFactor,emPx:((null===(x=t.global)||void 0===x?void 0:x.fontSizePx)||13.3333)*this.scaleFactor,fontFamily:this.labelFontFamily(),unitScaling:n,percentageScaling:o,scaleFactor:this.scaleFactor}}))}labelFontFamily(){return this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif"}))}emPx(){return this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*this.scaleFactor}autoUnitScaling(){var t;const e=this.emPx(),i=e*ot;let n=1/0;for(const{isRelative:o,absMax:s,labels:r,sideMax:l}of this.barColumnLayouts.values()){if(o||s<=0)continue;const a=vt(this.barColumnMaxWidth,e,r,l);for(const e of["neg","pos"]){const o=null!==(t=l[e])&&void 0!==t?t:0;if(o<=0)continue;const{maxBarWidth:s,cutWidth:r}=a[e];n=Math.min(n,Math.min(.8*s,r)/(o*i))}}return Number.isFinite(n)&&i>0?n:.01}autoPercentageScaling(){var t,e;const i=this.emPx(),n=i*ot;let o=1/0;for(const{isRelative:s,absMax:r,labels:l,sideMax:a}of this.barColumnLayouts.values()){if(!s||r<=0)continue;const h=10*this.scaleFactor,{negPinLength:c,posPinLength:u}=mt(this.barColumnMaxWidth,i,l,h),d=100*((null!==(t=a.neg)&&void 0!==t?t:0)+(null!==(e=a.pos)&&void 0!==e?e:0));o=Math.min(o,(c+u)/(d*n))}return Number.isFinite(o)&&n>0?o:.5}collectBarColumnLayouts(){var t,e,i,n;const o=new Map;if(!this.table||this.table.hasNoData())return o;const s=new Map;for(const e of this.table.getBody())if(e.type!==r.SUM)for(const i of e.getCells())i.isBarChart&&i.columnStats&&void 0===i.waterfall&&("number"!=typeof i.value||isNaN(i.value)||s.set(i.key,[...null!==(t=s.get(i.key))&&void 0!==t?t:[],{cell:i,bold:ee(e)}]));const l=this.emPx(),a=l*ot,h=10*this.scaleFactor,c=null===(n=null===(i=null===(e=this.stores)||void 0===e?void 0:e.context)||void 0===i?void 0:i.state)||void 0===n?void 0:n.locale,u=this.labelFontFamily();for(const[t,e]of s){const i=t.startsWith("dr"),n=e.map((({cell:t})=>t.value)),s=(t,o)=>{var s;const r={neg:n.some((t=>t<0))?0:void 0,pos:n.some((t=>t>0))?0:void 0},l=Nt(r);for(const{cell:n,bold:h}of e){const e=n.value,d=e>0||0===e&&l?"pos":"neg",f=St(e,i,ie(n),c,t,o,ne(n,this.componentDataFormatDigits));r[d]=Math.max(null!==(s=r[d])&&void 0!==s?s:0,ht(f,a,u,i,h))}return r};let r=Math.min(20,Math.max(0,Math.trunc(this.componentDataFormatDigits.percent)||0)),d=!0,f=s(r,d);for(;i&&(r>0||d)&&!ft(this.barColumnMaxWidth,l,f,h);)r>0?r--:d=!1,f=s(r,d);const p=Math.max(...n.map(Math.abs))*(i?100:1),v={neg:void 0===f.neg?void 0:Math.max(0,...n.map((t=>-t))),pos:void 0===f.pos?void 0:Math.max(0,...n)};o.set(t,{isRelative:i,absMax:p,labels:f,sideMax:v,percentDigits:r,percentSign:d})}return o}connectorReach(t){const e=this.emPx();return{top:.1*e,bottom:t.type===r.SUM?.5*e:0}}collectWaterfallGeometries(){var t,e,i,n;const o=new Map;if(!this.table||this.table.hasNoData())return o;const s=this.emPx(),r=s*ot,l=null===(i=null===(e=null===(t=this.stores)||void 0===t?void 0:t.context)||void 0===e?void 0:e.state)||void 0===i?void 0:i.locale,a=this.labelFontFamily(),h=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:i,end:o,min:s,max:c,kind:u}=e.waterfall,d=Ct(e.value,u,ie(e),l,ne(e,this.componentDataFormatDigits),void 0!==e.direction),f=null!==(n=h.get(e.key))&&void 0!==n?n:{min:s,max:c,labels:[]};f.labels.push({end:o,pointsLeft:o<i,width:ht(d,r,a,!1,ee(t))}),h.set(e.key,f)}for(const[t,e]of h)o.set(t,$t(this.barColumnMaxWidth,s,e));return o}get element(){return this}static get style(){return':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{position:relative;display:inline-block}table{background-color:var(--bn-font-background, white);font-size:var(--bn-font-size, 1em);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);border-spacing:0.3em 0}thead{border-style:none}tr:first-child td{border-top:none;padding-top:0.5em}td.ac1,td.ac2,td.ac3,td.ac4,td.pp1,td.pp2,td.pp3,td.pp4,td.pl1,td.pl2,td.pl3,td.pl4,td.fc1,td.fc2,td.fc3,td.fc4,td.share,td.variance,td.pos_pos,td.pos_neg,td.neg_pos,td.neg_neg,td.pos_neutral,td.neg_neutral,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}th.share,tr.share,td.share{font-size:0.6em;font-style:italic}th.filler{border-bottom:0em solid black;text-align:right}td.filler{border-top:0em none !important;border-bottom:0em none;text-align:right}th.group{text-align:center;border-spacing:1em 0}th.headerlabel{border-bottom:0em none black;padding-bottom:0em}th.intervalGroup{border-bottom:0.1em solid black;text-align:center;font-weight:bold}td.variance:after{content:"%"}td.relative_variance{font-style:italic}td.percent{font-style:italic;text-align:right}td.decimal,td.percentpoint{text-align:right}td.pos_pos{color:#008f96}td.neg_pos{color:#ff0000}td.pos_neg{color:#ff0000}td.neg_neg{color:#008f96}td.pos_pos:before{content:"+"}td.pos_neg:before{content:"+"}td.pos_neu:before{content:"+"}th.ac1,th.ac2,th.ac3,th.ac4{padding-top:0em;border-bottom:0.3em solid black}th.pp1,th.pp2,th.pp3,th.pp4{padding-top:0em;border-bottom:0.3em solid grey}th.pl1,th.pl2,th.pl3,th.pl4{padding-top:0em;border-bottom:0.3em double black}th.fc1,th.fc2,th.fc3,th.fc4{border-bottom:0.3em solid;border-image:repeating-linear-gradient(-45deg, white, white, black, white, white 0.3em) 2}td.colsum{font-weight:bold}th.colsum{padding-top:0em;font-weight:bold}tr.sum td{border-top:0.1em solid black;font-weight:bold;padding-bottom:0.5em}tr.ofit-above td[class^=category]{padding-left:1em}tr.ofit-sum td{border-top:0.1em solid black;font-weight:bold}tr.groupheader td{border-top:0em dotted #ddd;padding-top:0.5em;font-weight:bold;font-style:italic}tr.begingroup td{border-top:0em dotted #ddd;padding-top:0.5em}th.begin-group{padding-left:0.75em}th.end-group{padding-left:0.75em}td{box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em dashed #ddd;padding-left:0.5em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.table-footer{font-size:0.6em}.cell-bar-chart{display:inline-block;vertical-align:middle}.bar-chart-empty{color:#999}td:has(.variance-waterfall){overflow:visible}td:has(.cell-bar-chart){padding:0 0.25em;vertical-align:middle}tr.ofit td:has(.variance-waterfall){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 ee(t){return t.type===r.SUM||"ofit-sum"===t.cssStyle}function ie(t){return"percentpoint"===t.type?.01:t.measureScale}function ne(t,e){return"percentpoint"===t.type?e.percent:"decimal"===t.type?e.decimal:void 0}function oe(){"undefined"!=typeof customElements&&["bn-table-renderer"].forEach((t=>{"bn-table-renderer"===t&&(customElements.get(s(t))||customElements.define(s(t),te))}))}export{te as B,V as I,Z as a,K as c,oe as d}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t,s,n,i,o,a;!function(t){t[t.ALL=-1]="ALL"}(t||(t={})),function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(s||(s={})),function(t){t.LIST="list",t.SUM="sum",t.SUMNOTOTAL="sumnototal",t.OPT="opt",t.OPTNOTOTAL="optnototal"}(n||(n={})),function(t){t.BELOW="below",t.ABOVE="above"}(i||(i={})),function(t){t.ASC="asc",t.DESC="desc"}(o||(o={})),function(t){t.HEADER="HEADER",t.GROUPHEAD="GROUPHEAD",t.SEPERATORLINE="SEPERATORLINE",t.SUM="SUM",t.GROUPSUM="GROUP_SUM",t.DRILLELEMENT="DRILLELEMENT",t.STANDARD="STANDARD",t.PARTELEMENT="PARTELEMENT",t.ENTRY="ENTRY"}(a||(a={}));const u=/^\s*(set|first|last|min|max|avg|sum|lit)\(\s*(.*?)\s*\)\s*$/,c=/^[A-Za-z_][A-Za-z0-9_]*$/,r=["min","max","avg","sum"];class e{constructor(t,s,n,i){this.label=t,this.alias=s,this.fn=n,this.arg=i}get isNumeric(){return r.includes(this.fn)}}function E(t){if("string"!=typeof t)return!1;const s=u.exec(t);if(!s)return!1;const[,n,i]=s;return"lit"===n?i.length>0:c.test(i)}function f(t,s,n){if(!E(n))return null;const[,i,o]=u.exec(n);return new e(t,s,i,o)}export{c as F,o as O,i as T,n as a,a as b,s as c,E as i,f as p}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as n,a as t,A as r,b as o,T as u,D as e,c as i,M as a,d as s}from"./p-B5tixDPM.js";import{T as c,i as l}from"./p-BZXiWkDS.js";import{D as f,a as d}from"./p-sLbQ7yZ1.js";import{O as v,a as m,p as S}from"./p-16rjcQ0t.js";import{r as p}from"./p-BXXjh6We.js";function b(n){return null==n||""===n||"null"===n}function y(t){return b(t)||"auto"===t.trim().toLowerCase()?[]:N((null==t?void 0:t.split(",").filter((t=>!(t.toUpperCase().trim()in n)))).toString())}function N(r){return b(r)?[]:r.replace(";",",").split(",").filter((r=>{var o,u,e;const i=r.split("_"),a=null===(o=i[0])||void 0===o?void 0:o.replace(/^dr|^d/,"").toUpperCase().trim(),s=null===(u=i[1])||void 0===u?void 0:u.toUpperCase().trim(),c=null===(e=i[2])||void 0===e?void 0:e.toUpperCase().trim();return 3!==i.length||!(a in n)||!(s in n)||!(c in t)}))}function O(t){return b(t)?[]:N(t.split(",").filter((t=>!(t.toUpperCase().trim()in n))).toString())}function J(n){return b(n)||"auto"===n.trim().toLowerCase()?[]:N(n.split(",").filter((n=>!(n.toUpperCase()in v))).toString())}function j(n){return b(n)||"auto"===n.trim().toLowerCase()?[]:n.split(",").filter((n=>void 0===S(n)))}function h(n){return!b(n)&&Number.isInteger(Number(n))}function A(n){return!b(n)&&!Number.isNaN(Number(n))}function k(n){return!b(n)&&(null==n?void 0:n.toUpperCase())in m}function T(n){return"auto"===(null==n?void 0:n.toLowerCase())||(null==n?void 0:n.toUpperCase())in r}function g(n){if(b(n))return[];try{const t=JSON.parse(n);if(t instanceof Array)return t.filter((n=>!(n.hasOwnProperty("name")&&n.hasOwnProperty("unit"))))}catch(n){console.error("validateMeasureList: failed to parse JSON",n)}return["Invalid JSON structure"]}function D(n){const t=Date.parse(n);return Number.isInteger(t)}function G(n){return(null==n?void 0:n.toUpperCase())in d}function I(n){return(null==n?void 0:n.toUpperCase())in f}function $(n){return(null==n?void 0:n.toUpperCase())in o}function B(n){return!b(n)&&(null==n?void 0:n.toUpperCase())in e}function E(n){return!b(n)&&(null==n?void 0:n.toUpperCase())in i}function M(n){return(null==n?void 0:n.toUpperCase())in c}function w(n){if(b(n))return[];try{const t=JSON.parse(n);if(t instanceof Array)return t.filter((n=>!(n.hasOwnProperty("rowGroup")&&n.hasOwnProperty("category")&&n.hasOwnProperty("subCategory"))))}catch(n){console.error("validateThereOfJsonStr: failed to parse JSON",n)}return["Invalid JSON structure"]}function x(n){if(b(n))return[];try{const t=JSON.parse(n);if(null!==t&&"object"==typeof t&&!(t instanceof Array))return Object.entries(t).filter((([,n])=>"string"!=typeof n||!l(n))).map((([n,t])=>`${n}: ${t}`))}catch(n){console.error("validateAttributesJsonStr: failed to parse JSON",n)}return["Invalid JSON structure"]}function L(n){if(b(n))return[];try{const t=JSON.parse(n);if(t instanceof Array)return t.filter((n=>!(n.hasOwnProperty("rowGroup")&&n.hasOwnProperty("category"))))}catch(n){console.error("validatePartOfJsonStr: failed to parse JSON",n)}return["Invalid JSON structure"]}function P(n){return(null==n?void 0:n.trim().toUpperCase())in a}function X(n){return["_","k","M","G","T","P","E","Z","Y","m","my","μ","n","p","f","a","z","y"].includes(null==n?void 0:n.trim())||["GREATEST","LEAST"].includes(null==n?void 0:n.trim().toUpperCase())}function Z(n){return(null==n?void 0:n.toUpperCase().trim())in s}function q(n){return(null==n?void 0:n.toUpperCase().trim())in u}function z(n){if(b(n))return[];try{return JSON.parse(n).filter((n=>!(n.hasOwnProperty("scenario")&&n.hasOwnProperty("name")&&n.hasOwnProperty("subGroups"))))}catch(n){console.error("validateColumnThereOfJsonStr: failed to parse JSON",n)}return["Invalid JSON structure"]}function C(n){if(b(n))return[];try{const t=JSON.parse(n);if("object"!=typeof t||null===t||Array.isArray(t))return["stack: must be a JSON object"];const r=[];if(t.hasOwnProperty("by")){const n=["scenarios","dimensions"];n.includes(t.by)||r.push(`stack: 'by' must be one of: ${n.join(", ")}`)}else r.push("stack: 'by' is required");if(t.hasOwnProperty("mode")){const n=["absolute","relative","absolute-relative"];n.includes(t.mode)||r.push(`stack: 'mode' must be one of: ${n.join(", ")}`)}if(t.hasOwnProperty("order")){const n=["asc","desc","dataset"];n.includes(t.order)||r.push(`stack: 'order' must be one of: ${n.join(", ")}`)}return r}catch(n){return["stack: invalid JSON"]}}function Q(n){return!b(n)&&null!==p(n)}export{z as A,x as B,N as a,J as b,k as c,g as d,D as e,I as f,G as g,h,b as i,Q as j,T as k,X as l,C as m,A as n,$ as o,O as p,q,B as r,E as s,w as t,M as u,y as v,L as w,j as x,P as y,Z as z}
|