@bino-bi/bn-template-engine 1.0.0-next.38 → 1.0.0-next.39

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.
Files changed (43) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/{p-e15ccc4a.entry.js → p-8c84d57e.entry.js} +1 -1
  3. package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +167 -22
  4. package/dist/cjs/bn-template-engine.cjs.js +1 -1
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/collection/components/bn-table/bn-table-renderer/bn-table-renderer.js +36 -1
  7. package/dist/collection/components/bn-table/bn-table.js +89 -4
  8. package/dist/collection/components/bn-table/utils/Table.js +33 -2
  9. package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +15 -7
  10. package/dist/collection/components/bn-table/utils/helper/IntervalColumns.js +30 -6
  11. package/dist/collection/components/bn-table/utils/model/TableComponentConfig.js +5 -0
  12. package/dist/collection/utils/layoutState/baseline.js +6 -5
  13. package/dist/components/bn-chart-bubble-renderer.js +1 -1
  14. package/dist/components/bn-chart-bubble.js +1 -1
  15. package/dist/components/bn-chart-bullet-renderer.js +1 -1
  16. package/dist/components/bn-chart-bullet.js +1 -1
  17. package/dist/components/bn-chart-scatter-renderer.js +1 -1
  18. package/dist/components/bn-chart-scatter.js +1 -1
  19. package/dist/components/bn-chart-structure.js +1 -1
  20. package/dist/components/bn-chart-time.js +1 -1
  21. package/dist/components/bn-table-renderer.js +1 -1
  22. package/dist/components/bn-table.js +1 -1
  23. package/dist/components/{p-CQVAHG6w.js → p-B4Cf0cVi.js} +1 -1
  24. package/dist/components/{p-C-KX1_tw.js → p-BsJOvfIg.js} +1 -1
  25. package/dist/components/p-ChaSU4fh.js +1 -0
  26. package/dist/components/{p-BhEdmPjm.js → p-Cyf5ZEXs.js} +1 -1
  27. package/dist/components/{p-t4xPltK2.js → p-XFZYX7DZ.js} +1 -1
  28. package/dist/components/{p-C_6KHDYv.js → p-chnyMHJT.js} +1 -1
  29. package/dist/components/p-dRPJiQB6.js +1 -0
  30. package/dist/esm/bn-annotation-layer_30.entry.js +167 -22
  31. package/dist/esm/bn-template-engine.js +1 -1
  32. package/dist/esm/loader.js +1 -1
  33. package/dist/types/components/bn-table/bn-table-renderer/bn-table-renderer.d.ts +2 -0
  34. package/dist/types/components/bn-table/bn-table.d.ts +23 -0
  35. package/dist/types/components/bn-table/utils/Table.d.ts +11 -1
  36. package/dist/types/components/bn-table/utils/factories/tableDataSetFactory.d.ts +7 -4
  37. package/dist/types/components/bn-table/utils/helper/IntervalColumns.d.ts +7 -0
  38. package/dist/types/components/bn-table/utils/model/TableComponentConfig.d.ts +2 -0
  39. package/dist/types/components.d.ts +17 -2
  40. package/dist/types/utils/layoutState/baseline.d.ts +4 -2
  41. package/package.json +1 -1
  42. package/dist/components/p--HIZm_2v.js +0 -1
  43. package/dist/components/p-sar8m7th.js +0 -1
@@ -1 +1 @@
1
- import{r as t,h as i,a as s,g as e,f as n,d as r,F as o}from"./p-CCZcKl0Q.js";import{S as h,w as a,a as l,g as c,C as u,r as d,c as f,h as v,d as p,e as g,X as m,i as b,D as y,j as w,m as x,s as S,k as $,l as M,u as _,n as O}from"./p-D0tNATZq.js";import{a as k,m as A,C as R,i as N,b as L,w as E,c as T,r as C,s as P,d as W,e as D,f as z,v as U,g as F,A as G,O as j,h as I,j as Y,k as B,l as H,n as V,o as X,p as J,S as q,q as K,t as Q,u as Z,x as tt,N as it,y as st,z as et,B as nt,D as rt,E as ot,F as ht,G as at,H as lt,R as ct,I as ut,J as dt,K as ft,L as vt,M as pt,P as gt,Q as mt,T as bt,U as yt,V as wt,W as xt,X as St,Y as $t,Z as Mt,_ as _t,$ as Ot,a0 as kt,a1 as At,a2 as Rt,a3 as Nt,a4 as Lt,a5 as Et,a6 as Tt,a7 as Ct,a8 as Pt,a9 as Wt,aa as Dt}from"./p-BVU4bIsi.js";import{s as zt,g as Ut,b as Ft,i as Gt,f as jt,r as It,a as Yt,w as Bt,p as Ht,c as Vt,d as Xt,e as Jt,h as qt,j as Kt}from"./p-DyupX-Z-.js";import{w as Qt}from"./p-DF9sfwBN.js";import{r as Zt,m as ti,a as ii,l as si,o as ei,b as ni,c as ri,t as oi,d as hi,e as ai}from"./p-qpZjVnX5.js";import{LAYOUT_STATE_VERSION as li}from"./index.esm.js";import{e as ci,r as ui}from"./p-ClruFZD_.js";const di=/^[a-z][a-z0-9-]*$/i;function fi(t,i){var s,e;const n=null!==(s=null==i?void 0:i.color)&&void 0!==s?s:h["bn-annotation"].color,r=null!==(e=null==i?void 0:i.colors)&&void 0!==e?e:{},o=`var(--bn-annotation-color, ${n})`;if(!t||!di.test(t))return o;const a=Object.prototype.hasOwnProperty.call(r,t)?r[t]:void 0;return`var(--bn-annotation-color-${t}, ${null!=a?a:o})`}const vi=t=>"string"==typeof t||"number"==typeof t?String(t):void 0;function pi(t){if(null==t||""===t.trim())return[];try{const i=JSON.parse(t);if(Array.isArray(i)&&i.every((t=>null!==t&&"object"==typeof t)))return i}catch(t){}}const gi=new WeakMap;let mi=1;function bi(t){const i=t.closest("bn-layout-page");if(!i)return"";let s=gi.get(i);return s||(s="page-"+mi++,gi.set(i,s)),s}const yi=t=>({x:t.x+t.width/2,y:t.y+t.height/2});function wi(t,i){const s=yi(t),e=i.x-s.x,n=i.y-s.y,r=Math.min(0===e?1/0:t.width/2/Math.abs(e),0===n?1/0:t.height/2/Math.abs(n));return Number.isFinite(r)?{x:s.x+e*r,y:s.y+n*r}:s}function xi(t,i){return i?Object.assign(Object.assign({},t),{cx:Math.max(t.r,Math.min(t.cx,i.width-t.r)),cy:Math.max(t.r,Math.min(t.cy,i.height-t.r))}):t}const Si=(t,i)=>t.x<i.x+i.width&&i.x<t.x+t.width&&t.y<i.y+i.height&&i.y<t.y+t.height;function $i(t,i,s,e){var n,r,o;const h=.25*s,a=t.y+t.height/2,l=null!==(n=e.obstacles)&&void 0!==n?n:[],c=t=>{const s={x:t-i,y:a-i,width:2*i,height:2*i},n=e.area;return(!n||s.x>=0&&s.x+s.width<=n.width)&&!l.some((t=>Si(s,t)))},u=t.x+t.width,d=t.x-h-i,f=u+h+i;if(c(d))return{x:d,y:a,r:i};if(c(f))return{x:f,y:a,r:i};const v=2*(i+h),p=l.filter((t=>t.y<a&&t.y+t.height>a)),g=Math.max(0,t.x-v,...p.filter((i=>i.x+i.width<=t.x)).map((t=>t.x+t.width))),m=Math.min(null!==(o=null===(r=e.area)||void 0===r?void 0:r.width)&&void 0!==o?o:1/0,u+v,...p.filter((t=>t.x>=u)).map((t=>t.x))),b=t.x-g,y=m-u,w=Math.max(b,y);return{x:y>=b?u+y/2:t.x-b/2,y:a,r:Math.min(i,Math.max(w/2,.3*s))}}function Mi(t,i,s,e,n={}){var r;const{label:o,color:h}=t,{whole:a,area:l,text:c}=n,u=!a&&!c&&null!=n.obstacles,d=((t,i)=>t?Math.min(i,t.height/1.3):i)(null!=c?c:u?i:void 0,e);if("arrow"===t.mark){if(!s)return;const t=yi(i),n=yi(s);if(t.x===n.x&&t.y===n.y)return;let r=wi(i,n),a=wi(s,t);(a.x-r.x)*(n.x-t.x)+(a.y-r.y)*(n.y-t.y)<=0&&(r=t,a=n);const c=Math.hypot(a.x-r.x,a.y-r.y),u=Math.min(.8*e,c),d=(a.x-r.x)/c,f=(a.y-r.y)/c,v=a.x-d*u,p=a.y-f*u,g=.35*e;return{kind:"arrow",color:h,x1:r.x,y1:r.y,x2:v,y2:p,head:[`${a.x},${a.y}`,`${v-f*g},${p+d*g}`,`${v+f*g},${p-d*g}`].join(" "),badge:null!=o?xi({cx:r.x,cy:r.y,r:.65*e,label:o},l):void 0}}if("frame"===t.mark){const s=null!=c?c:i,n=null===(r=t.point)||void 0===r?void 0:r.part,u=!a&&(null!=c||"label"===n||"total"===n),f=(u?.45:.2)*d,v=(u?.1:.2)*d,p=u?Math.max(s.width,s.height):s.width,g=s.x+s.width/2,m=1,b=Math.max(l?m:-1/0,g-p/2-f),y=Math.max(l?m:-1/0,s.y-v),w=Math.min(l?l.width-m:1/0,g+p/2+f),x=Math.min(l?l.height-m:1/0,s.y+s.height+v),S=Math.min(w-b,x-y)/2,$=a?.25*e:S,M=a?.25*e:u?Math.min((w-b)/2,1.6*S):S,_=1-Math.SQRT1_2,O=.65*d,k=u?.6*O:0;return{kind:"frame",color:h,x:b,y,width:w-b,height:x-y,rx:M,ry:$,badge:null!=o?xi({cx:w-M*_+k,cy:y+$*_-k,r:O,label:o},l):void 0}}if(c&&!a){const t=$i(c,(null==o?.4:.65)*d,d,n);return{kind:"marker",color:h,badge:xi({cx:t.x,cy:t.y,r:t.r,label:o},l)}}const f=(null==o?.4:.75)*d,v=u?Math.min(f,i.height/2):f,p=a?{x:i.x+i.width-v,y:i.y+v}:yi(i);if(u){const t={x:p.x-v,y:p.y-v,width:2*v,height:2*v},i=n.obstacles.find((i=>Si(t,i)));if(i){const t=$i(i,v,d,n);return{kind:"marker",color:h,badge:xi({cx:t.x,cy:t.y,r:t.r,label:o},l)}}}return{kind:"marker",color:h,badge:xi({cx:p.x,cy:p.y,r:v,label:o},l)}}const _i=["rowGroup","category","subCategory","date","scenario","row"];function Oi(t,i){const s=i.getBoundingClientRect();if(0===s.width||0===s.height)return!0;const e=t.x+t.width/2,n=t.y+t.height/2;return e>=s.left&&e<=s.right&&n>=s.top&&n<=s.bottom}const ki=new Set(["bn-asset","bn-component-style","bn-dataset","bn-datasource","bn-internationalization","bn-ruleset","bn-scaling-group"]);function Ai(t,i){const s=i.getBoundingClientRect();return 0===s.width||0===s.height||t.x<s.right&&t.x+t.width>s.left&&t.y<s.bottom&&t.y+t.height>s.top}const Ri=class{constructor(i){t(this,i),this.marks=[],this.pageKey="",this.parsedItems=[],this.scheduled=!1,this.run=0,this.observed=new WeakSet,this.reported=new Set,this.schedule=()=>{this.scheduled||(this.scheduled=!0,this.holdStatus(new Promise((t=>{requestAnimationFrame((()=>{this.scheduled=!1,this.place().catch((t=>console.error("bn-annotation-layer: placing the marks failed",t))).finally(t)}))}))))},this.holdStatus=a(this),this.errors=l(this),this.componentStyle=k(this)}connectedCallback(){var t;this.stores=c(this.element),this.pageKey=bi(this.element),this.observed=new WeakSet,this.resizeObserver=new ResizeObserver(this.schedule),this.mutationObserver=new MutationObserver(this.schedule),this.observeSize(this.element);const i=this.element.closest("bn-layout-page");i&&this.mutationObserver.observe(i,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["slot","data-bino-annotation-target"]}),null===(t=document.fonts)||void 0===t||t.addEventListener("loadingdone",this.schedule)}disconnectedCallback(){var t,i,s,e;null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(i=this.mutationObserver)||void 0===i||i.disconnect(),null===(s=document.fonts)||void 0===s||s.removeEventListener("loadingdone",this.schedule),this.run++,(null===(e=this.stores)||void 0===e?void 0:e.annotationsUnplaced.state[this.pageKey])&&this.stores.annotationsUnplaced.set(this.pageKey,void 0)}componentWillLoad(){this.parseItems()}componentDidLoad(){this.schedule()}onItemsChange(){this.parseItems(),this.schedule()}parseItems(){const t=function(t){var i;return null===(i=pi(t))||void 0===i?void 0:i.map((t=>{var i;return Object.assign(Object.assign({},t),{label:vi(t.label),color:vi(t.color),target:null!==(i=vi(t.target))&&void 0!==i?i:"",to:vi(t.to)})}))}(this.items);t?this.errors.remove("ERR_items"):this.errors.addOrReplace({id:"ERR_items",type:"error",message:"items: not a JSON array of objects."}),this.parsedItems=null!=t?t:[]}async place(){var t;const i=++this.run;if(!this.element.isConnected||!this.svg)return;const s=this.element.closest("bn-layout-page"),e=new Map,n=new Map;null==s||s.querySelectorAll("[data-bino-annotation-target]").forEach((t=>{const i=Array.from(t.querySelectorAll("*")).find((t=>t.localName.startsWith("bn-")&&!ki.has(t.localName))),s=null!=i?i:t;e.set(t.getAttribute("data-bino-annotation-target"),s),n.set(s,t)})),null==s||s.querySelectorAll("[slot]").forEach((t=>this.observeSize(t)));const r=new Set(this.parsedItems.flatMap((t=>[t.target,t.to]))),o=[...e].filter((([t])=>r.has(t))).map((([,t])=>t));if(await Promise.all(o.map((t=>{var i;return null===(i=t.componentOnReady)||void 0===i?void 0:i.call(t)}))),i!==this.run)return;o.forEach((t=>this.observe(t)));const h=new Map;if(await Promise.all(o.map((async t=>{var i;h.set(t,await(null===(i=t.getLayoutState)||void 0===i?void 0:i.call(t,{detail:"full"}).catch((()=>{}))))}))),i!==this.run)return;const a=(t,i)=>{var s;const r=null!=t?e.get(t):void 0;if(!r)return{problem:`no target "${t}" on this page`};const o=r.getBoundingClientRect();if(function(t){return!t||_i.every((i=>null==t[i]))&&null==t.part}(i)){const i={x:o.left,y:o.top,width:o.width,height:o.height};return function(t,i,s){if(0===t.width||0===t.height||!Ai(t,s))return!0;for(let s=i;s&&"bn-layout-page"!==s.localName;s=s.parentElement)if(!Ai(t,s))return!0;return!1}(i,n.get(r),this.element)?{problem:`"${t}" cannot be seen`}:{box:i,whole:!0}}const a=h.get(r),l=a?function(t,i){var s;const e=t.table&&null==i.scenario?t.table.rows:null!==(s=t.elements)&&void 0!==s?s:[],n=null!=t.table&&null==i.subCategory;return e.filter((t=>function(t,i){var s;return!(!t||t.part!==(null!==(s=i.part)&&void 0!==s?s:"element"))&&_i.every((s=>null==i[s]||String(i[s])===t[s]))}(t.point,i)&&!(n&&null!=t.point.subCategory))).map((({rect:t,content:i,contentSign:s})=>({rect:t,content:i,contentSign:s})))}(a,i):[];if(1!==l.length)return{problem:`${l.length} elements match the point ${JSON.stringify(i)} in "${t}"`};const c=({component:{x:t,y:i,width:s,height:e}})=>({x:o.left+t,y:o.top+i,width:s,height:e}),u=c(l[0].rect);if(function(t,i){for(let s=i;s&&"bn-layout-page"!==s.localName;s=s.parentElement)if(!Oi(t,s))return!0;return!1}(u,n.get(r))||!Oi(u,this.element))return{problem:`the point ${JSON.stringify(i)} in "${t}" is cut off`};const d=l[0].content;if(!a.table)return{box:u,whole:!1};const f=(null!==(s=a.elements)&&void 0!==s?s:[]).flatMap((t=>"cell"===t.kind&&t.content?[{box:c(t.content),sign:t.contentSign}]:[]));return{box:u,whole:!1,text:d&&{box:c(d),sign:l[0].contentSign},obstacles:f}},l=this.toLocalSpace(),c=({box:t,sign:i=0})=>{const s=l(t);return Object.assign(Object.assign({},s),{x:s.x-i,width:s.width+i})},u=parseFloat(getComputedStyle(this.svg).fontSize)||13.3333,d={width:this.element.clientWidth,height:this.element.clientHeight},f=[],v=[];for(const i of this.parsedItems){const s=a(i.target,i.point),e="arrow"===i.mark?a(i.to,i.toPoint):void 0,n="problem"in s?s:e&&"problem"in e?e:void 0;if(n){v.push({item:i,problem:n.problem});continue}const r=s,o=e,h=Mi(i,l(r.box),o&&l(o.box),u,{whole:r.whole,area:d,text:r.text&&c(r.text),obstacles:null===(t=r.obstacles)||void 0===t?void 0:t.map(c)});h?f.push(h):v.push({item:i,problem:"an arrow needs two ends at different places"})}this.marks=f,this.storeUnplaced(v.flatMap((({item:t})=>null!=t.label?[t.label]:[]))),v.length>0&&this.reportWhenQuiet(i,v)}async reportWhenQuiet(t,i){let s=0;for(let i=0;i<50&&s<2;i++){if(await new Promise((t=>window.setTimeout(t,200))),t!==this.run)return;s=0===u.componentRegisterStatus().running?s+1:0}this.report(i)}report(t){var i,s;for(const{item:e,problem:n}of t){const t=`bn-annotation-layer: ${null!==(i=e.mark)&&void 0!==i?i:"marker"} ${null!==(s=e.label)&&void 0!==s?s:"without a number"} is not drawn: ${n}.`;this.reported.has(t)||(this.reported.add(t),console.warn(t))}}toLocalSpace(){var t;const i=null===(t=this.svg.getScreenCTM())||void 0===t?void 0:t.inverse();return t=>{if(!i)return t;const s=[[t.x,t.y],[t.x+t.width,t.y+t.height]].map((([t,s])=>new DOMPoint(t,s).matrixTransform(i)));return{x:Math.min(s[0].x,s[1].x),y:Math.min(s[0].y,s[1].y),width:Math.abs(s[1].x-s[0].x),height:Math.abs(s[1].y-s[0].y)}}}storeUnplaced(t){var i,s;const e=null===(i=this.stores)||void 0===i?void 0:i.annotationsUnplaced,n=null!==(s=null==e?void 0:e.state[this.pageKey])&&void 0!==s?s:[];e&&JSON.stringify(n)!==JSON.stringify(t)&&e.set(this.pageKey,t)}observe(t){this.observeSize(t);const i=t=>{var s;t&&(this.observed.has(t)||(this.observed.add(t),null===(s=this.mutationObserver)||void 0===s||s.observe(t,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["x","y","width","height","transform","style","class"]})),t.querySelectorAll("*").forEach((t=>i(t.shadowRoot))))};i(t.shadowRoot)}observeSize(t){var i;this.observed.has(t)||(this.observed.add(t),null===(i=this.resizeObserver)||void 0===i||i.observe(t))}renderBadge(t,s){return t?i("g",null,i("circle",{cx:t.cx,cy:t.cy,r:t.r,style:{fill:s}}),null!=t.label?i("text",{class:"badge-text",x:t.cx,y:t.cy,style:{fontSize:1.1*t.r+"px"}},t.label):null):null}renderMark(t){var s,e;const n=fi(t.color,this.componentStyle((t=>t["bn-annotation"])));return"marker"===t.kind?i("g",{class:"mark marker","data-label":t.badge.label},this.renderBadge(t.badge,n)):"frame"===t.kind?i("g",{class:"mark frame","data-label":null===(s=t.badge)||void 0===s?void 0:s.label},i("rect",{x:t.x,y:t.y,width:t.width,height:t.height,rx:t.rx,ry:t.ry,style:{fill:"none",stroke:n,strokeWidth:"1.5"}}),this.renderBadge(t.badge,n)):i("g",{class:"mark arrow","data-label":null===(e=t.badge)||void 0===e?void 0:e.label},i("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,style:{stroke:n,strokeWidth:"1.5"}}),i("polygon",{points:t.head,style:{fill:n}}),this.renderBadge(t.badge,n))}render(){return i(s,{key:"05ca564aeeaf190a45cd42020b307891990e04fe"},i("svg",{key:"995c55b16803107766bf2c394d8d799c0de5765d",ref:t=>this.svg=t},this.marks.map((t=>this.renderMark(t)))))}get element(){return e(this)}static get watchers(){return{items:[{onItemsChange:0}]}}};Ri.style=':host{position:absolute;inset:0;z-index:1;display:block;pointer-events:none;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px)}svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}.badge-text{fill:#ffffff;font-weight:bold;text-anchor:middle;dominant-baseline:central}';const Ni=class{constructor(i){t(this,i),this.pageKey="",a(this),this.errors=l(this),this.componentStyle=k(this)}connectedCallback(){this.stores=c(this.element),this.pageKey=bi(this.element),this.unsubscribe=this.stores.annotationsUnplaced.on("set",(t=>{t===this.pageKey&&n(this.element)})),n(this.element)}disconnectedCallback(){var t;null===(t=this.unsubscribe)||void 0===t||t.call(this)}render(){var t,e;const n=function(t){var i;return null===(i=pi(t))||void 0===i?void 0:i.map((t=>({label:vi(t.label),title:vi(t.title),html:vi(t.html)})))}(this.items);n?this.errors.remove("ERR_items"):this.errors.addOrReplace({id:"ERR_items",type:"error",message:"items: not a JSON array of objects."});const r=fi(void 0,this.componentStyle((t=>t["bn-annotation"]))),o=null!==(e=null===(t=this.stores)||void 0===t?void 0:t.annotationsUnplaced.state[this.pageKey])&&void 0!==e?e:[];return i(s,{key:"69a1cb7ec4623dd722328638b93fa2ac05775dcf"},i("ol",{key:"cc7925db54a9015cd774242487967e25d0eb1dc0"},(null!=n?n:[]).map((t=>i("li",null,null==t.label||o.includes(t.label)?null!=t.label?i("div",{class:"badge-space"}):null:i("div",{class:"badge",style:{background:r}},i("span",null,t.label)),i("div",{class:"text"},t.title?i("span",{class:"title"},t.title," "):null,t.html?i("span",{innerHTML:zt(t.html)}):null))))))}get element(){return e(this)}};Ni.style=':host{display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}ol{margin:0;padding:0;list-style:none}li{display:flex;gap:0.5em;margin-bottom:0.6em;align-items:flex-start}.badge-space{flex:none;width:1.5em;height:1.5em}.badge{flex:none;display:flex;align-items:center;justify-content:center;width:1.5em;height:1.5em;border-radius:50%;color:#ffffff;font-weight:bold;line-height:1}.badge span{font-size:0.825em}.title{font-weight:bold}';const Li=class{constructor(i){t(this,i),a(this),this.errors=l(this),Qt(this,(t=>{this.stores||(this.stores=c(this.element));try{const i=t.replace(/\s/g,"");this.stores.assets.set(this.name,i)}catch(i){console.error("Error parsing asset",i,t),this.stores.assets.set(this.name,void 0)}}))}render(){return i(s,{key:"9df81e3697e02833b8cb1fad7ea06a5f446852be"})}get element(){return e(this)}};Li.style=":host{display:none}";const Ei=class{constructor(i){t(this,i),a(this),this.errors=l(this),this.componentStyle=k(this)}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){return i(s,{key:"fb9799f1ea3fadbf10dbc88aa668cad9d3e63853",style:this.getFontStyles()},i("slot",{key:"e08e29cdcac02cdd5caab034b0398b78de8951bf"}))}get element(){return e(this)}};Ei.style=':host{flex:1;min-height:0;position:relative;overflow:hidden;display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}';const Ti=class{constructor(i){t(this,i),a(this),this.errors=l(this),this.componentStyle=k(this)}render(){return i(s,{key:"66b35f747b56462ca898e7f475edf580eeb5edc0",style:this.prepareStyle()},i("slot",{key:"deaa11cb68cffbdba8b6a4508417c32c0a949d6b"}))}prepareStyle(){return{"font-family":this.componentStyle((t=>t.global.fontFamily)),"font-size":`${this.componentStyle((t=>t.global.fontSizePx))}px`,"--bn-font-family":this.componentStyle((t=>t.global.fontFamily))||"'Noto Sans', sans-serif","--bn-font-size":`${this.componentStyle((t=>t.global.fontSizePx))||13.3333}px`,"--bn-font-color":this.componentStyle((t=>t.global.fontColor))||"#000000","--bn-font-background":this.componentStyle((t=>t.global.fontBackgroundColor))||"#ffffff"}}get element(){return e(this)}};function Ci(t){if("function"==typeof getComputedStyle){const i=parseFloat(getComputedStyle(t).fontSize);if(Number.isFinite(i)&&i>0)return i}return h.global.fontSizePx}function Pi(t,i){var s;return{version:li,tag:t.localName,id:ii(t),slot:null!==(s=t.getAttribute("slot"))&&void 0!==s?s:void 0,rect:ti(t,i),em:{fontSizePx:Ci(t),appliedScaleFactor:1},regions:[],metadata:{},diagnostics:Zt(t)}}Ti.style=':host{display:flex;flex-direction:column;justify-content:space-between;flex:1;min-height:0;padding:0.25em;margin:0.5em;background-origin:content-box;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}:host(.border){box-sizing:border-box;-webkit-box-sizing:border-box;border:0.1em solid #ddd}div{color:var(--bn-font-color, black)}';const Wi="data-bn-baseline",Di=t=>Math.round(100*t)/100;function zi(t,i){const s=t.querySelector(`[${Wi}]`),e=null!=s?s:t.querySelector('g[id="axis"] line');if(!e)return{};const n=si(i);return"frame"===e.getAttribute(Wi)?function(t,i){const s=i.toLocal(t.getBoundingClientRect());return{x:Di(s.x),y:Di(s.y+s.height)}}(e,n):function(t,i){const s=i.toLocal(t.getBoundingClientRect());return s.width>=s.height?{x:Di(s.x),y:Di(s.y+s.height/2)}:{x:Di(s.x+s.width/2),y:Di(s.y)}}(e,n)}function Ui(t,i){var s,e,n;const r=null===(n=null===(e=null===(s=t.shadowRoot)||void 0===s?void 0:s.querySelector(i))||void 0===e?void 0:e.shadowRoot)||void 0===n?void 0:n.querySelector("svg#drawCanvas");return r?zi(r,t):{}}const Fi=[["rowGroup","data-bn-row-group"],["category","data-bn-category"],["subCategory","data-bn-sub-category"],["date","data-bn-date"],["scenario","data-bn-scenario"],["row","data-bn-row"]],Gi="data-bn-part";function ji(t,i){const s={};if(!t)return s;for(const[i,e]of Fi){const n=t[i];null!=n&&""!==n&&(s[e]=String(n))}return i&&(s[Gi]=i),s}function Ii(t){const i=t.getAttribute(Gi);if(!i)return;const s={part:i};for(const[i,e]of Fi){const n=t.getAttribute(e);null!=n&&(s[i]=n)}return s}function Yi(t){if(!t)return;const i=/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})/.exec(t);return i?"00:00:00"===i[2]?i[1]:`${i[1]}T${i[2]}`:t}function Bi(t,i){return null==i?{}:t.startsWith("rowGroup")?{rowGroup:String(i)}:t.startsWith("subCategory")?{subCategory:String(i)}:{category:String(i)}}const Hi=/^Scenario([1-4])$/,Vi=/^stacked_(?:col|bar)_(\d+)_seg_\d+$/,Xi='g[id^="stacked_col_"], g[id^="stacked_bar_"]';function Ji(t,i){var s;let e=t.parentElement;for(;e&&e!==i;){const t=Hi.exec(null!==(s=e.id)&&void 0!==s?s:"");if(t)return`scenario${t[1]}`;e=e.parentElement}}function qi(t){if(""===t)return;const i=Number(t.split("_")[0]);return Number.isFinite(i)?i:void 0}function Ki(t){const i=t.getAttribute("data-bn-index");return null===i?void 0:Number(i)}function Qi(t,i){var s;return(null!==(s=t.getAttribute("class"))&&void 0!==s?s:"").split(/\s+/).includes(i)}function Zi(t,i,s,e,n){var r,o;const h={regions:[],barCount:0,baseline:{}},a=[];return Array.from(null!==(o=null===(r=t.shadowRoot)||void 0===r?void 0:r.querySelectorAll(i))&&void 0!==o?o:[]).forEach(((i,r)=>{var o,l,c,u;const d=null!==(o=s[r])&&void 0!==o?o:`segment${r}`,f=null===(l=i.shadowRoot)||void 0===l?void 0:l.querySelector("svg#drawCanvas");if(f&&(h.regions.push({id:`canvas:${d}`,rect:ti(f,e)}),0===r&&(h.barCount=function(t){const i=t.querySelector('g[id="Scenario1"]');if(i)return Array.from(i.children).filter((t=>{var i;return/^\d+$/.test(null!==(i=t.id)&&void 0!==i?i:"")})).length;const s=new Set;return t.querySelectorAll(Xi).forEach((t=>{const i=Vi.exec(t.id);i&&t.querySelector("rect")&&s.add(i[1])})),s.size}(f),h.baseline=zi(f,t)),"full"===n&&a.push(...function(t,i,s){const e=[],n=new Set;return t.querySelectorAll('g[id$="_RECT"]').forEach(((r,o)=>{var h;n.add(r);const a={kind:"bar",id:r.id,segment:i,scenario:Ji(r,t),index:null!==(h=qi(r.id))&&void 0!==h?h:o,rect:ti(r,s),point:Ii(r)};e.push(a)})),t.querySelectorAll(Xi).forEach((t=>{var r,o,h;const a=Vi.exec(t.id);if(!a||!t.querySelector("rect"))return;n.add(t);const l=Ii(t),c={kind:"bar",id:t.id,segment:i,scenario:`stack:${null!==(h=null!==(o=null!==(r=null==l?void 0:l.scenario)&&void 0!==r?r:null==l?void 0:l.subCategory)&&void 0!==o?o:null==l?void 0:l.category)&&void 0!==h?h:""}`,index:Number(a[1]),rect:ti(t,s),point:l};e.push(c)})),["DATA","SCENARIO"].forEach((r=>{t.querySelectorAll(`g[id$="_${r}_Label"]`).forEach(((t,o)=>{var h,a,l;if(Qi(t,"hide"))return;const c=null!==(a=null===(h=t.textContent)||void 0===h?void 0:h.trim())&&void 0!==a?a:"";if(!c)return;n.add(t);const u={kind:"label",id:t.id,role:"DATA"===r?"data":"scenario",text:c,segment:i,index:null!==(l=qi(t.id))&&void 0!==l?l:o,rect:ti(t,s),point:Ii(t)};e.push(u)}))})),t.querySelectorAll("[data-bn-part]").forEach(((r,o)=>{var h,a,l;if(n.has(r))return;const c=Ii(r),u=null!==(h=Ki(r))&&void 0!==h?h:function(t,i){var s;for(let e=t;e&&e!==i;e=e.parentElement){const t=qi(null!==(s=e.id)&&void 0!==s?s:"");if(void 0!==t)return t}}(r,t);if("element"===c.part){const t={kind:"point",series:c.scenario,index:null!=u?u:o,rect:ti(r,s),point:c};return void e.push(t)}const d={kind:"label",id:r.id||void 0,role:"data",text:null!==(l=null===(a=r.textContent)||void 0===a?void 0:a.trim())&&void 0!==l?l:"",segment:i,index:u,rect:ti(r,s),point:c};e.push(d)})),t.querySelectorAll('g[id="axis"] line').forEach((t=>{var n;const r=(null!==(n=t.getAttribute("class"))&&void 0!==n?n:"").split(/\s+/).find((t=>t.startsWith("axis-"))),o=ti(t,s),h={kind:"axis",style:null==r?void 0:r.slice(5),orientation:o.context.width>=o.context.height?"horizontal":"vertical",segment:i,rect:o};e.push(h)})),t.querySelectorAll('g[id="AxisAndDateLables"] text, g[id="AxisAndDateLabelsLine"] text').forEach((n=>{var r,o;if(Qi(n,"hide")||function(t,i){var s;let e=t.parentElement;for(;e&&e!==i;){if((null!==(s=e.id)&&void 0!==s?s:"").endsWith("_Label"))return!0;e=e.parentElement}return!1}(n,t))return;const h=null!==(o=null===(r=n.textContent)||void 0===r?void 0:r.trim())&&void 0!==o?o:"";if(!h)return;const a={kind:"label",role:Qi(n,"categories")?"title":"category",text:h,segment:i,rect:ti(n,s)};e.push(a)})),e}(f,d,e))),"full"===n){const t=null===(c=i.shadowRoot)||void 0===c?void 0:c.querySelector(".footer"),s=null===(u=null==t?void 0:t.textContent)||void 0===u?void 0:u.trim();s&&a.push({kind:"label",role:"footer",text:s,segment:d,rect:ti(t,e)})}})),"full"===n&&(h.elements=a),h}function ts(t,i,s,e,n,r){var o,h,a,l;const c={version:li,tag:t.localName,id:ii(t),slot:null!==(o=t.getAttribute("slot"))&&void 0!==o?o:void 0,rect:ti(t,n),em:e,regions:[],metadata:{title:s},diagnostics:Zt(t)},u=null===(l=null===(a=null===(h=t.shadowRoot)||void 0===h?void 0:h.querySelector(i))||void 0===a?void 0:a.shadowRoot)||void 0===l?void 0:l.querySelector("svg#drawCanvas");return u&&(c.regions.push({id:"canvas",rect:ti(u,n)}),c.metadata.pointCount=u.querySelectorAll("circle, ellipse").length,c.baseline=zi(u,t),"full"===r&&(c.elements=function(t,i){const s=[];return t.querySelectorAll("circle, ellipse").forEach(((t,e)=>{const n={kind:"point",index:e,rect:ti(t,i),point:Ii(t)};s.push(n)})),t.querySelectorAll('rect[data-bn-part="element"]').forEach(((t,e)=>{var n;const r=Ii(t),o={kind:"bar",segment:"base",scenario:null==r?void 0:r.scenario,index:null!==(n=Ki(t))&&void 0!==n?n:e,rect:ti(t,i),point:r};s.push(o)})),t.querySelectorAll("text").forEach((t=>{var e,n;const r=null!==(n=null===(e=t.textContent)||void 0===e?void 0:e.trim())&&void 0!==n?n:"";if(!r)return;const o={kind:"label",role:"data",text:r,rect:ti(t,i),point:Ii(t)};s.push(o)})),s}(u,n))),c}function is(t,i,s){var e,n,r,o,h;const a="WARN_overflow",l=Ut(t),c=parseFloat(null!==(h=null===(o=null===(r=null===(n=null===(e=t.shadowRoot)||void 0===e?void 0:e.querySelector(i))||void 0===n?void 0:n.shadowRoot)||void 0===r?void 0:r.querySelector("svg#drawCanvas"))||void 0===o?void 0:o.getAttribute("height"))&&void 0!==h?h:""),u=Math.max(Number.isNaN(c)?0:Math.floor(c),t.scrollHeight||0),d=t.scrollWidth||0,f=[];l.width>0&&d>l.width+1&&f.push(`width (${Math.round(d)}px > ${Math.round(l.width)}px)`);const v=Ft(t,u);v>1&&f.push(`height (${Math.round(u)}px > ${Math.round(u-v)}px)`),0!==f.length?s.addOrReplace({id:a,type:"warning",message:`Chart exceeds available ${f.join(" and ")} and will be cut off. Check the scale and aspect values or enlarge the container.`}):s.remove(a)}function ss(t,i,s=80){let e=null,n=!1,r=-1,o=-1;const h=function(t){var i;const s=t.parentElement;return(null===(i=null==s?void 0:s.assignedSlot)||void 0===i?void 0:i.parentElement)?s.assignedSlot.parentElement:s}(t);if(!h)return{disconnect(){}};const a=new ResizeObserver((t=>{var a;if(n)return;let l,c;const u=t[0];if(null===(a=null==u?void 0:u.contentBoxSize)||void 0===a?void 0:a.length){const t=u.contentBoxSize[0];l=t.inlineSize,c=t.blockSize}else l=h.clientWidth,c=h.clientHeight;Math.abs(l-r)<=2&&Math.abs(c-o)<=2||(r=l,o=c,null!=e&&clearTimeout(e),e=setTimeout((()=>{n||i()}),s))}));return a.observe(h),{disconnect(){n=!0,null!=e&&clearTimeout(e),a.disconnect()}}}const es=t=>{let i,s,r,o,h,a=null;const l=()=>{const t=s.ruleSets.state;h=A([t._default||{},t[r]||{}]),o=A([t._system||{},h])},u=()=>{const i=e(t),s=i.getAttribute("ruleset");if(a&&(a.disconnect(),a=null),s&&Gt(s)){const e=jt(i,s);if(r=It(e,"ruleset"),e.length>0){a=new MutationObserver((()=>{r=It(e,"ruleset"),l(),n(t)}));for(const t of e)a.observe(t,{attributes:!0,attributeFilter:["ruleset"]})}}else r=s},v=new MutationObserver((i=>{i.forEach((i=>{"ruleset"===i.attributeName&&(u(),l(),n(t))}))})),p=t.connectedCallback;t.connectedCallback=()=>{const h=e(t);s=c(h),o=s.ruleSets.state._system,v.observe(h,{attributes:!0,attributeFilter:["ruleset"]}),u(),l(),i=s.ruleSets.on("set",(i=>{i!==r&&"_default"!==i||(u(),l(),n(e(t)))})),d(p,t)};const g=t.disconnectedCallback;return t.disconnectedCallback=()=>{v.disconnect(),a&&(a.disconnect(),a=null),d(i),f(e(t)),d(g,t)},(t="all")=>"user"===t?h:o},ns=t=>{let i,s;const r=()=>{"function"==typeof t.validateUnitScaling&&t.validateUnitScaling(t.unitScaling),"function"==typeof t.validatePercentageScaling&&t.validatePercentageScaling(t.percentageScaling),"function"==typeof t.validateSizeScaling&&t.validateSizeScaling()},o=t.connectedCallback;t.connectedCallback=()=>{const h=e(t);s=c(h),(()=>{const i=s.scalingGroups.state;for(const s of Object.keys(i))void 0!==i[s]?t.pixelPerUnitGroupMap.set(s,i[s]):t.pixelPerUnitGroupMap.delete(s)})(),r(),i=s.scalingGroups.on("set",((i,s)=>{void 0!==s?t.pixelPerUnitGroupMap.set(i,s):t.pixelPerUnitGroupMap.delete(i),r(),n(e(t))})),d(o,t)};const h=t.disconnectedCallback;t.disconnectedCallback=()=>{d(i),f(e(t)),d(h,t)}};function rs(t,i){var s;const e=null!==(s=null==t?void 0:t.trim())&&void 0!==s?s:"";if(""===e||"null"===e)return{data:null,parseError:!1};if(e.startsWith("{")||e.startsWith("["))try{const t=JSON.parse(e);return"object"!=typeof t||null===t||Array.isArray(t)?{data:null,parseError:!0}:{data:t,parseError:!1}}catch(t){return{data:null,parseError:!0}}return null!==i?{data:{[i]:e},parseError:!1}:{data:null,parseError:!0}}function os(t,i){return Object.keys(t).filter((t=>!i.includes(t)))}function hs(t,i,s){if(R.isExisting(t[i]))return R.isString(t[i])?t[i]:void s.push(i)}function as(t,i,s){if(R.isExisting(t[i]))return R.isNumber(t[i])?t[i]:void s.push(i)}const ls=["measure","label","unit","min","max","refLine","highlight"];function cs(t){const i=[],s=hs(t,"measure",i);if(void 0===s||""===s.trim())return i.push("measure"),{config:null,unknownKeys:os(t,ls),invalidFields:i};const e={measure:s.trim()};return e.label=hs(t,"label",i),e.unit=hs(t,"unit",i),e.min=as(t,"min",i),e.max=as(t,"max",i),e.refLine=as(t,"refLine",i),e.highlight=function(t,i){if(!R.isExisting(t.highlight))return;if(!R.isObject(t.highlight)||Array.isArray(t.highlight))return void i.push("highlight");const s=t.highlight,e={},n=as(s,"from",i),r=as(s,"to",i);return void 0!==n&&(e.from=n),void 0!==r&&(e.to=r),e}(t,i),{config:e,unknownKeys:os(t,ls),invalidFields:i}}const us=["measure","label","unit","group"];function ds(t){const i=[],s=hs(t,"measure",i);if(void 0===s||""===s.trim())return i.push("measure"),{config:null,unknownKeys:os(t,us),invalidFields:i};const e={measure:s.trim()};return e.label=hs(t,"label",i),e.unit=hs(t,"unit",i),e.group=hs(t,"group",i),{config:e,unknownKeys:os(t,us),invalidFields:i}}const fs=["measure"];function vs(t){const i=[],s=hs(t,"measure",i);return void 0===s||""===s.trim()?(i.push("measure"),{config:null,unknownKeys:os(t,fs),invalidFields:i}):{config:{measure:s.trim()},unknownKeys:os(t,fs),invalidFields:i}}const ps=["values","label","unit","highlight"];function gs(t){const i=[];let s=null;if("auto"===t.values?s="auto":R.isArray(t.values)&&t.values.every((t=>R.isNumber(t)))?s=t.values:i.push("values"),null===s)return{config:null,unknownKeys:os(t,ps),invalidFields:i};const e={values:s};if(e.label=hs(t,"label",i),e.unit=hs(t,"unit",i),R.isExisting(t.highlight))if(R.isObject(t.highlight)&&!Array.isArray(t.highlight)){const s=as(t.highlight,"from",i);void 0!==s&&(e.highlight={from:s})}else i.push("highlight");return{config:e,unknownKeys:os(t,ps),invalidFields:i}}const ms=["points","values","max"];function bs(t,i){const s=[],e={points:i.points,values:i.values,max:i.max};return R.isExisting(t.points)&&("auto"===t.points||"none"===t.points||"all"===t.points||R.isArray(t.points)&&t.points.every((t=>R.isString(t)))?e.points=t.points:s.push("points")),R.isExisting(t.values)&&(R.isBoolean(t.values)?e.values=t.values:s.push("values")),R.isExisting(t.max)&&(R.isNumber(t.max)&&t.max>0?e.max=Math.floor(t.max):s.push("max")),{config:e,unknownKeys:os(t,ms),invalidFields:s}}const ys=["level","columns"];function ws(t){const i=[],s=R.isString(t.level)?t.level.toLowerCase():null;if("rowgroup"!==s&&"category"!==s)return i.push("level"),{config:null,unknownKeys:os(t,ys),invalidFields:i};const e={level:s};return R.isExisting(t.columns)&&(R.isNumber(t.columns)&&t.columns>=1?e.columns=Math.floor(t.columns):i.push("columns")),{config:e,unknownKeys:os(t,ys),invalidFields:i}}const xs=["show","position"];function Ss(t){const i=[],s={show:!0,position:"right"};return R.isExisting(t.show)&&(R.isBoolean(t.show)?s.show=t.show:i.push("show")),R.isExisting(t.position)&&("right"===t.position||"bottom"===t.position?s.position=t.position:i.push("position")),{config:s,unknownKeys:os(t,xs),invalidFields:i}}function $s(t,i){var s,e;const n=Array.from(null!==(e=null===(s=t.shadowRoot)||void 0===s?void 0:s.querySelectorAll(i))&&void 0!==e?e:[]);n.length>0&&n.every((t=>t.classList.contains("no-data")))?t.classList.add("no-data"):t.classList.remove("no-data")}const Ms={rowGroup:0,category:1,subCategory:2},_s=["ac","pp","fc","pl"],Os=class{validateFilter(t){const i="ERR_filter";v(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateX(t){this.validateMeasureSpec("x",t,!0,(t=>cs(t)))}validateY(t){this.validateMeasureSpec("y",t,!0,(t=>cs(t)))}validateSize(t){this.validateMeasureSpec("size",t,!0,(t=>ds(t))),this.validateSizeScaling()}validateShare(t){this.validateMeasureSpec("share",t,!1,(t=>vs(t)))}validateCompareWith(t){const i="WARN_compareWith";N(t)||_s.includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`compare-with: invalid value '${t}' - expected ${_s.join("/")}; ignored.`})}validateLevel(t){const i="WARN_level",s=["auto","category","subcategory"];N(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateSeriesLevel(t){const i="WARN_seriesLevel",s=["auto","rowgroup","category","none"];N(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`series-level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateFacet(t){this.validateObjectSpec("facet",t,(t=>ws(t)))}validateLabels(t){this.validateObjectSpec("labels",t,(t=>bs(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,(t=>Ss(t)))}validateAspect(t){const i="WARN_aspect";N(t)||null!==this.parseAspect(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`aspect: invalid value '${t}' - expected "w:h" (e.g. "16:9"); using the default.`})}validateLimit(t){const i="WARN_limit";L(t)&&Number(t)>=0?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`limit: invalid value '${t}' - expected a non-negative integer; using 0.`})}validateScale(t){const i="WARN_scale";if(N(t))return void this.errors.remove(i);const{mode:s,factor:e}=Ht(t);"factor"===s&&(void 0===e||e<=0)?this.errors.addOrReplace({id:i,type:"warning",message:`scale: invalid value '${t}' - expected none/auto or a positive number.`}):this.errors.remove(i)}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.pixelPerUnitGroupMap=new Map,this.chartTitle="",this.filter="",this.share="",this.compareWith="",this.level="auto",this.seriesLevel="auto",this.facet="",this.labels="",this.legend="",this.aspect="16:9",this.limit=0,this._autoScaleGuard=!1,this._lastObservedWidth=0,this.translateForInner=(t,i)=>this.t(t,i),E(this),a(this),Yt(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.errors=l(this),ns(this),this.componentStyle=k(this),this.ruleSetConfig=es(this),this.t=Bt(this).t}componentWillLoad(){this.validateFilter(this.filter),this.validateX(this.x),this.validateY(this.y),this.validateSize(this.size),this.validateShare(this.share),this.validateCompareWith(this.compareWith),this.validateLevel(this.level),this.validateSeriesLevel(this.seriesLevel),this.validateFacet(this.facet),this.validateLabels(this.labels),this.validateLegend(this.legend),this.validateAspect(this.aspect),this.validateLimit(this.limit),this.validateScale(this.scale)}componentDidRender(){$s(this.element,"bn-chart-bubble-renderer");const{mode:t}=Ht(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{width:s}=Ut(i);if(s<=0)return void this.checkOverflow();this._lastObservedWidth=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),n=i.scrollWidth,o=this.appliedScaleFactor;if(!Number.isFinite(n)||n<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const h=Math.max(.3,o*(s-1)/n);Math.abs(h-o)<.01||(i.style.setProperty("--bn-font-size",e*h+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${h.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,r((()=>{this.appliedScaleFactor=h}))),this.checkOverflow()}checkOverflow(){is(this.element,"bn-chart-bubble-renderer",this.errors)}componentDidLoad(){this.layoutObserver=ss(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=Ut(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2?(this._lastObservedWidth=t,n(this)):this.checkOverflow()})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=Ut(this.element);this._lastObservedWidth=t,n(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{points:"all",values:!0,max:12}}setBlockingError(t,i){null===i?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:i}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateSizeScaling(){var t;const i=null===(t=this.prepareSize())||void 0===t?void 0:t.group;this.setBlockingError("ERR_xy_scale_group",void 0===i||this.pixelPerUnitGroupMap.has(i)?null:this.t(".bubble-scale-group-unknown",{group:i}))}validateMeasureSpec(t,i,s,e){var n;const r=`ERR_xy_json_${t}`,o=`ERR_xy_measure_${t}`,h=`WARN_xy_fields_${t}`,{data:a,parseError:l}=rs(i,"measure");if(l)return this.setBlockingError(r,this.t(".xy-prop-json",{prop:t})),this.setBlockingError(o,null),void this.errors.remove(h);if(this.setBlockingError(r,null),null===a)return this.setBlockingError(o,s?this.t(".xy-measure-invalid",{prop:t,measure:""}):null),void this.errors.remove(h);const c=null!==(n=a.measure)&&void 0!==n?n:"";T(c)?this.setBlockingError(o,null):this.setBlockingError(o,this.t(".xy-measure-invalid",{prop:t,measure:c})),this.reportSpecIssues(h,t,e(a))}validateObjectSpec(t,i,s){const e=`ERR_xy_json_${t}`,n=`WARN_xy_fields_${t}`,{data:r,parseError:o}=rs(i,null);if(o)return this.setBlockingError(e,this.t(".xy-prop-json",{prop:t})),void this.errors.remove(n);this.setBlockingError(e,null),null!==r?this.reportSpecIssues(n,t,s(r)):this.errors.remove(n)}reportSpecIssues(t,i,s){const e=[];null!==s&&s.invalidFields.length>0&&e.push(`invalid: ${s.invalidFields.join(", ")}`),null!==s&&s.unknownKeys.length>0&&e.push(`unknown: ${s.unknownKeys.join(", ")}`),e.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${i}: ignored sub-fields (${e.join("; ")}).`}):this.errors.remove(t)}prepareAxis(t,i){const{data:s,parseError:e}=rs(i,"measure");if(e||null===s)return null;const{config:n}=cs(s);return null!==n&&T(n.measure)?(void 0!==n.min&&void 0!==n.max&&n.min>=n.max?(this.errors.addOrReplace({id:`WARN_xy_domain_${t}`,type:"warning",message:`${t}: min must be smaller than max; the override is ignored.`}),n.min=void 0,n.max=void 0):this.errors.remove(`WARN_xy_domain_${t}`),n):null}prepareSize(){const{data:t,parseError:i}=rs(this.size,"measure");if(i||null===t)return null;const{config:s}=ds(t);return null!==s&&T(s.measure)?s:null}prepareShare(){const{data:t,parseError:i}=rs(this.share,"measure");if(i||null===t)return null;const{config:s}=vs(t);return null!==s&&T(s.measure)?s:null}prepareCompareFamily(){var t;const i=null===(t=this.compareWith)||void 0===t?void 0:t.trim().toLowerCase();return _s.includes(i)?i:null}prepareLabels(){const t=this.labelDefaults(),{data:i,parseError:s}=rs(this.labels,null);return s||null===i?{points:t.points,values:t.values,max:t.max}:bs(i,t).config}prepareLegend(){const{data:t,parseError:i}=rs(this.legend,null);return i||null===t?{show:!0,position:"right"}:Ss(t).config}prepareFacet(){const{data:t,parseError:i}=rs(this.facet,null);return i||null===t?null:ws(t).config}preparePointLevel(){var t,i;const s=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("category"===s)return"category";if("subcategory"===s)return"subCategory";const e=null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel;return"rowGroup"===e||"category"===e||"subCategory"===e?e:"category"}prepareSeriesLevel(t){var i;const s=null===(i=this.seriesLevel)||void 0===i?void 0:i.trim().toLowerCase();return"none"===s?null:"rowgroup"===s?"rowGroup":"category"===s||"subCategory"===t?"category":"category"===t?"rowGroup":null}validateCrossProp(t,i){const s=new Set;let e=!1;for(const i of t){if(void 0===i)continue;const t=C(i);null!==t&&("scenario"===t.kind?s.add(P(t.slot)):e=!0)}this.setBlockingError("ERR_xy_family",s.size>1?this.t(".xy-family-mixed",{families:[...s].join(", ")}):null);const n=this.prepareCompareFamily();this.setBlockingError("ERR_xy_compare_variance",null!==n&&e?this.t(".xy-compare-variance"):null),this.setBlockingError("ERR_xy_compare_family",null!==n&&1===s.size&&s.has(n)?`compare-with: '${n}' is already the primary scenario family.`:null);const r=this.preparePointLevel(),o=this.prepareSeriesLevel(r),h=null!==i?"rowgroup"===i.level?"rowGroup":"category":null;let a=null;if(null!==o&&Ms[o]>=Ms[r]&&(a=`series '${o}' vs point '${r}'`),null!==h){const t=null!=o?o:r;Ms[h]>=Ms[t]&&(a=`facet '${h}' vs '${t}'`)}this.setBlockingError("ERR_xy_level_order",null!==a?this.t(".xy-level-order",{detail:a}):null)}parseAspect(t){const i=/^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/.exec(null!=t?t:"");if(null===i)return null;const s=Number(i[1]),e=Number(i[2]);return s<=0||e<=0?null:s/e}prepareAspect(){var t;return null!==(t=this.parseAspect(this.aspect))&&void 0!==t?t:16/9}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}prepareSizeAreaPerUnit(){var t;const i=null===(t=this.prepareSize())||void 0===t?void 0:t.group;if(void 0===i||!this.pixelPerUnitGroupMap.has(i))return 0;const s=this.pixelPerUnitGroupMap.get(i);if(!(s>0))return 0;const e=this.getEffectiveFontPx();return e*e/s}i18nLocalKeys(){return["no-data","axis.in","legend.title","legend.size","legend.compare"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),i=new Map(p.map((t=>[t,this.t("global.".concat(t))])));return new Map([...i.entries(),...t.entries()])}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const s=i.global.fontSizePx*t;return{scaleFactors:i["bn-chart-bubble"].scaleFactors,fontStyles:{font:`${s}px ${i.global.fontFamily}`,size:s,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-bubble"].axisStyles,seriesColors:i["bn-chart-bubble"].seriesColors,padding:i["bn-chart-bubble"].padding}}))}async getBaseline(){return Ui(this.element,"bn-chart-bubble-renderer")}async getLayoutState(t){var i;const s=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",e=ei(this.element),n=this.getEffectiveScaleFactor(),r=Number.isFinite(n)&&n>0?n:1,o=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*r;return ts(this.element,"bn-chart-bubble-renderer",this.chartTitle||void 0,{fontSizePx:o,appliedScaleFactor:r},e,s)}getEffectiveScaleFactor(){const{mode:t,factor:i}=Ht(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){const t=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}));return t*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const o=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":o*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const i of["ac","pp","fc","pl"])for(const s of[1,2,3,4])t[`${i}${s}`]={type:"number",isOptional:!0,description:""};const i={x:this.prepareAxis("x",this.x),y:this.prepareAxis("y",this.y),size:this.prepareSize(),share:this.prepareShare()};for(const[s,e]of Object.entries(i)){if(null===e)continue;const i=C(e.measure);null!==i&&("scenario"===i.kind?t[i.slot].description=`${s}: ${void 0!==e.label?e.label:e.measure}`:(t[i.measure.base].description=`${s}: ${e.measure} (base)`,t[i.measure.delta].description=`${s}: ${e.measure} (delta)`))}const s=this.prepareCompareFamily();if(null!==s)for(const[e,n]of Object.entries(i)){if(null===n||"share"===e)continue;const i=C(n.measure);if(null!==i&&"scenario"===i.kind){const n=s+i.slot.replace(/^[a-z]+/,"");""===t[n].description&&(t[n].description=`${e}: compareWith`)}}return{IBubbleChartDataRow:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}chartTemplate(){const t=this.prepareAxis("x",this.x),s=this.prepareAxis("y",this.y),e=this.prepareSize(),n=this.prepareShare(),r=this.prepareFacet();if(this.validateCrossProp([null==t?void 0:t.measure,null==s?void 0:s.measure,null==e?void 0:e.measure,null==n?void 0:n.measure],r),this.validateSizeScaling(),this.hasBlockingErrors()||null===t||null===s||null===e)return null;const o=this.preparePointLevel(),h=this.prepareI18n(),a=this.prepareStyle(),l=Ut(this.element).width;return i("bn-chart-bubble-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,x:t,y:s,size:e,share:n,compareFamily:this.prepareCompareFamily(),labels:this.prepareLabels(),legend:this.prepareLegend(),facet:r,pointLevel:o,seriesLevel:this.prepareSeriesLevel(o),aspect:this.prepareAspect(),limit:this.prepareLimit(),filter:this.filter,sizeAreaPerUnit:this.prepareSizeAreaPerUnit(),styles:a,i18n:h,containerWidth:l,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return i(s,{key:"2b15b5b4fc32db48b951e82ecc87f25b0afcc9f8",style:this.getFontStyles()},i("div",{key:"210d8622e1785b8c882f9c9a2fa2072af0e857b6",class:"container"},this.chartTemplate()))}get element(){return e(this)}static get watchers(){return{filter:[{validateFilter:0}],x:[{validateX:0}],y:[{validateY:0}],size:[{validateSize:0}],share:[{validateShare:0}],compareWith:[{validateCompareWith:0}],level:[{validateLevel:0}],seriesLevel:[{validateSeriesLevel:0}],facet:[{validateFacet:0}],labels:[{validateLabels:0}],legend:[{validateLegend:0}],aspect:[{validateAspect:0}],limit:[{validateLimit:0}],scale:[{validateScale:0}]}}};Os.style=':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:column}';class ks{constructor(t){this.type="",this.base="",this.delta="",this.direction="",this.isValid=!1;const i=/(d|dr)(pl\d|ac\d|fc\d|pp\d)_(pl\d|ac\d|fc\d|pp\d)_(pos|neg|neu|opinv|op)/;if(i.test(t)){const s=i.exec(t);null!=s&&(this.type=String(s[1]),this.base=String(s[2]),this.delta=String(s[3]),this.direction=String(s[4]),this.isValid=!0)}}}function As(t,i,s){return"op"!==t&&"opinv"!==t?t:"op"===t!=(!s&&"-"===i)?"pos":"neg"}const Rs=["ac","pp","fc","pl"],Ns={10:"ac",20:"pp",30:"fc",50:"pl"};function Ls(t){var i;return null!==(i=Ns[t])&&void 0!==i?i:"ac"}function Es(t,i){const s=Rs.map((t=>Ls(i.getScenarioColorIndex(`${t}1`))));if(s.every(((t,i)=>t===Rs[i])))return t;const e=Object.assign(Object.create(Object.getPrototypeOf(t)),t);return Rs.forEach(((i,n)=>{e[i]=t[s[n]]})),e}function Ts(t){var i,s;const e=new Map;for(const n of Rs){const r=null===(s=null===(i=null==t?void 0:t.scenarios)||void 0===i?void 0:i[n])||void 0===s?void 0:s.name;if(r)for(const t of[1,2,3,4])e.set(`${n}${t}`,1===t?r:`${r}${t}`)}return e}class Cs{constructor(t){this._dateFormat={year:"YYYY",quarter:"Q[Q] YYYY",month:"MMM YYYY",locale:"[KW]WW YYYY",day:"DD.MM.YYYY"},this._dateLinkFormat={avg:"Ø[DATE]",interval:"[DATE]..[DATE]",start:".[DATE]",end:"[DATE].",ytd:"_[DATE]",ytg:"[DATE]_",cum:"[DATE]_[DATE]",mat:"~[DATE]",none:"[DATE]"},this._scenarioMap=new Map;const i=A([g,null!=t?t:{}]);Object.entries(i.scenarios).forEach((([t,i])=>{var s,e,n;this.createScenarioMapEntry(t,null!==(s=i.name)&&void 0!==s?s:t,null!==(e=i.colorIndex)&&void 0!==e?e:10,null!==(n=i.sortIndex)&&void 0!==n?n:0)})),this._fallBackScenario=i.fallback}createScenarioMapEntry(t,i,s,e){const n=i,r=s;[1,2,3,4].forEach((s=>{this._scenarioMap.set(t+s,{name:i+s,group:n,colorIndex:r,sortIndex:e+10*s})}))}getScenario(t){return this._scenarioMap.has(t)?this._scenarioMap.get(t):this._fallBackScenario}getScenarioGroup(t){return this._scenarioMap.has(t)?this._scenarioMap.get(t).name:this._fallBackScenario.name}getScenarioColorIndex(t){return this._scenarioMap.has(t)?this._scenarioMap.get(t).colorIndex:this._fallBackScenario.colorIndex}getScenarioSorIndex(t){const i=this.normalizeVarianceScenario(t);return this._scenarioMap.has(i)?this._scenarioMap.get(i).sortIndex:this._fallBackScenario.sortIndex}normalizeVarianceScenario(t){if(null==t)return"";const i=new ks(t);return i.isValid?i.type+i.delta:t}}class Ps{constructor(){this.font="16px Arial",this.family="Arial",this.size=16,this.color="#000000",this.background="#ffffff",this.leading=1.8}}class Ws{adapt(t){const i=new Ps;return R.isString(t.font)&&(i.font=t.font),R.isString(t.family)&&(i.family=t.family),R.isNumber(t.size)&&(i.size=t.size),R.isString(t.color)&&(i.color=t.color),R.isString(t.background)&&(i.background=t.background),R.isNumber(t.leading)&&(i.leading=t.leading),i}default(){return new Ps}}let Ds=class{constructor(){this.top=10,this.left=10,this.right=10,this.bottom=10}};class zs{adapt(t){const i=new Ds;return R.isNumber(t.top)&&(i.top=t.top),R.isNumber(t.left)&&(i.left=t.left),R.isNumber(t.right)&&(i.right=t.right),R.isNumber(t.bottom)&&(i.bottom=t.bottom),i}default(){return new Ds}}function Us(t){return"fc"===t||"hatched"===t?"hatched":"solid"===t||"outlined"===t?t:void 0}class Fs{constructor(t="#000000",i="#000000",s=.1){this.stroke=t,this.fill=i,this.width=s}}class Gs{adapt(t){const i=new Fs(t.stroke,t.fill,t.width);return i.fillpattern=Us(t.fillpattern),"outlined"===i.fillpattern&&(i.fill="transparent"),R.isString(t.dasharray)&&(i.dasharray=t.dasharray),i}default(){return new Fs("#000000","#000000",.3)}defaultAC(){return new Fs("#000000","#000000",.3)}defaultFC(){const t=new Fs("#000000","#000000",.3);return t.dasharray="10 5 5 5",t.fillpattern="hatched",t}defaultPP(){return new Fs("#999999","#999999",.3)}defaultPL(){return new Fs("#000000","#ffffff",.3)}defaultPos(){return new Fs("#00ff00","#00ff00",.3)}defaultNeg(){return new Fs("#ff0000","#ff0000",.3)}defaultNeu(){return new Fs("#999999","#999999",.3)}}class js{constructor(t,i,s,e){this.ac=t,this.fc=i,this.pp=s,this.pl=e}getSVGStyle(t){return"ac"===t?this.ac:"fc"===t?this.fc:"pp"===t?this.pp:"pl"===t?this.pl:this.ac}}class Is{constructor(t){this.svgStyleAdapter=t}adapt(t){const i=new js(this.svgStyleAdapter.defaultAC(),this.svgStyleAdapter.defaultFC(),this.svgStyleAdapter.defaultPP(),this.svgStyleAdapter.defaultPL());return R.isExisting(t.ac)&&(i.ac=this.svgStyleAdapter.adapt(t.ac)),R.isExisting(t.fc)&&(i.fc=this.svgStyleAdapter.adapt(t.fc)),R.isExisting(t.pp)&&(i.pp=this.svgStyleAdapter.adapt(t.pp)),R.isExisting(t.pl)&&(i.pl=this.svgStyleAdapter.adapt(t.pl)),i}default(){return new js(this.svgStyleAdapter.defaultAC(),this.svgStyleAdapter.defaultFC(),this.svgStyleAdapter.defaultPP(),this.svgStyleAdapter.defaultPL())}}class Ys{constructor(t,i,s,e){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.padding=e,this.seriesColors=[...m],this.locale="de"}}class Bs{constructor(t,i,s,e){this.scaleFactorsXYChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.paddingAdapter=e}adapt(t){const i=this.default();return R.isExisting(t)&&(R.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsXYChartAdapter.adapt(t.scaleFactors)),R.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),R.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),R.isExisting(t.padding)&&(i.padding=this.paddingAdapter.adapt(t.padding)),Array.isArray(t.seriesColors)&&t.seriesColors.length>0&&(i.seriesColors=t.seriesColors)),i}default(){return new Ys(this.scaleFactorsXYChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.paddingAdapter.default())}}class Hs{constructor(){this.pointRadius=.4,this.bubbleMaxRadius=3.2,this.bubbleMinRadius=.35,this.axisTickLength=.35,this.labelToMark=.3,this.legendSwatch=.9,this.panelGap=1.6,this.refLineWidth=.075,this.gridLineWidth=.075}}class Vs{adapt(t){const i=new Hs;return R.isNumber(t.pointRadius)&&(i.pointRadius=t.pointRadius),R.isNumber(t.bubbleMaxRadius)&&(i.bubbleMaxRadius=t.bubbleMaxRadius),R.isNumber(t.bubbleMinRadius)&&(i.bubbleMinRadius=t.bubbleMinRadius),R.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),R.isNumber(t.labelToMark)&&(i.labelToMark=t.labelToMark),R.isNumber(t.legendSwatch)&&(i.legendSwatch=t.legendSwatch),R.isNumber(t.panelGap)&&(i.panelGap=t.panelGap),R.isNumber(t.refLineWidth)&&(i.refLineWidth=t.refLineWidth),R.isNumber(t.gridLineWidth)&&(i.gridLineWidth=t.gridLineWidth),i}default(){return new Hs}}var Xs=Object.create,Js=Object.defineProperty,qs=Object.getOwnPropertyDescriptor,Ks=Object.getOwnPropertyNames,Qs=Object.getPrototypeOf,Zs=Object.prototype.hasOwnProperty,te=(t,i)=>()=>(i||(t((i={exports:{}}).exports,i),t=null),i.exports),ie=t=>{let i={};for(var s in t)Js(i,s,{get:t[s],enumerable:!0});return Js(i,Symbol.toStringTag,{value:"Module"}),i},se=(t,i,s)=>(s=null!=t?Xs(Qs(t)):{},((t,i,s,e)=>{if(i&&"object"==typeof i||"function"==typeof i)for(var n,r=Ks(i),o=0,h=r.length;o<h;o++)Zs.call(t,n=r[o])||undefined===n||Js(t,n,{get:(t=>i[t]).bind(null,n),enumerable:!(e=qs(i,n))||e.enumerable});return t})(Js(s,"default",{value:t,enumerable:!0}),t));const ee={},ne=[];function re(t,i){if(Array.isArray(t))for(const s of t)re(s,i);else if("object"!=typeof t)he(Object.getOwnPropertyNames(i)),ee[t]=Object.assign(ee[t]||{},i);else for(const i in t)re(i,t[i])}function oe(t){return ee[t]||{}}function he(t){ne.push(...t)}var ae=te(((t,i)=>{i.exports=function(t){try{return!!t()}catch(t){return!0}}})),le=te(((t,i)=>{var s=ae();i.exports=!s((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))})),ce=te(((t,i)=>{var s=le(),e=Function.prototype,n=e.call,r=s&&e.bind.bind(n,n);i.exports=s?r:function(t){return function(){return n.apply(t,arguments)}}})),ue=te(((t,i)=>{var s=ce();i.exports=s({}.isPrototypeOf)})),de=te(((t,i)=>{var s=function(t){return t&&t.Math===Math&&t};i.exports=s("object"==typeof globalThis&&globalThis)||s("object"==typeof window&&window)||s("object"==typeof self&&self)||s("object"==typeof global&&global)||s("object"==typeof t&&t)||function(){return this}()||Function("return this")()})),fe=te(((t,i)=>{var s=le(),e=Function.prototype,n=e.apply,r=e.call;i.exports="object"==typeof Reflect&&Reflect.apply||(s?r.bind(n):function(){return r.apply(n,arguments)})})),ve=te(((t,i)=>{var s=ce(),e=s({}.toString),n=s("".slice);i.exports=function(t){return n(e(t),8,-1)}})),pe=te(((t,i)=>{var s=ve(),e=ce();i.exports=function(t){if("Function"===s(t))return e(t)}})),ge=te(((t,i)=>{var s="object"==typeof document&&document.all;i.exports=void 0===s&&void 0!==s?function(t){return"function"==typeof t||t===s}:function(t){return"function"==typeof t}})),me=te(((t,i)=>{var s=ae();i.exports=!s((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}))})),be=te(((t,i)=>{var s=le(),e=Function.prototype.call;i.exports=s?e.bind(e):function(){return e.apply(e,arguments)}})),ye=te((t=>{var i={}.propertyIsEnumerable,s=Object.getOwnPropertyDescriptor,e=s&&!i.call({1:2},1);t.f=e?function(t){var i=s(this,t);return!!i&&i.enumerable}:i})),we=te(((t,i)=>{i.exports=function(t,i){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:i}}})),xe=te(((t,i)=>{var s=ce(),e=ae(),n=ve(),r=Object,o=s("".split);i.exports=e((function(){return!r("z").propertyIsEnumerable(0)}))?function(t){return"String"===n(t)?o(t,""):r(t)}:r})),Se=te(((t,i)=>{i.exports=function(t){return null==t}})),$e=te(((t,i)=>{var s=Se(),e=TypeError;i.exports=function(t){if(s(t))throw new e("Can't call method on "+t);return t}})),Me=te(((t,i)=>{var s=xe(),e=$e();i.exports=function(t){return s(e(t))}})),_e=te(((t,i)=>{var s=ge();i.exports=function(t){return"object"==typeof t?null!==t:s(t)}})),Oe=te(((t,i)=>{i.exports={}})),ke=te(((t,i)=>{var s=Oe(),e=de(),n=ge(),r=function(t){return n(t)?t:void 0};i.exports=function(t,i){return arguments.length<2?r(s[t])||r(e[t]):s[t]&&s[t][i]||e[t]&&e[t][i]}})),Ae=te(((t,i)=>{var s=de().navigator,e=s&&s.userAgent;i.exports=e?String(e):""})),Re=te(((t,i)=>{var s,e,n=de(),r=Ae(),o=n.process,h=n.Deno,a=o&&o.versions||h&&h.version,l=a&&a.v8;l&&(e=(s=l.split("."))[0]>0&&s[0]<4?1:+(s[0]+s[1])),!e&&r&&(!(s=r.match(/Edge\/(\d+)/))||s[1]>=74)&&(s=r.match(/Chrome\/(\d+)/))&&(e=+s[1]),i.exports=e})),Ne=te(((t,i)=>{var s=Re(),e=ae(),n=de().String;i.exports=!!Object.getOwnPropertySymbols&&!e((function(){var t=Symbol("symbol detection");return!n(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&s&&s<41}))})),Le=te(((t,i)=>{var s=Ne();i.exports=s&&!Symbol.sham&&"symbol"==typeof Symbol.iterator})),Ee=te(((t,i)=>{var s=ke(),e=ge(),n=ue(),r=Le(),o=Object;i.exports=r?function(t){return"symbol"==typeof t}:function(t){var i=s("Symbol");return e(i)&&n(i.prototype,o(t))}})),Te=te(((t,i)=>{var s=String;i.exports=function(t){try{return s(t)}catch(t){return"Object"}}})),Ce=te(((t,i)=>{var s=ge(),e=Te(),n=TypeError;i.exports=function(t){if(s(t))return t;throw new n(e(t)+" is not a function")}})),Pe=te(((t,i)=>{var s=Ce(),e=Se();i.exports=function(t,i){var n=t[i];return e(n)?void 0:s(n)}})),We=te(((t,i)=>{var s=be(),e=ge(),n=_e(),r=TypeError;i.exports=function(t,i){var o,h;if("string"===i&&e(o=t.toString)&&!n(h=s(o,t)))return h;if(e(o=t.valueOf)&&!n(h=s(o,t)))return h;if("string"!==i&&e(o=t.toString)&&!n(h=s(o,t)))return h;throw new r("Can't convert object to primitive value")}})),De=te(((t,i)=>{i.exports=!0})),ze=te(((t,i)=>{var s=de(),e=Object.defineProperty;i.exports=function(t,i){try{e(s,t,{value:i,configurable:!0,writable:!0})}catch(e){s[t]=i}return i}})),Ue=te(((t,i)=>{var s=De(),e=de(),n=ze(),r="__core-js_shared__",o=i.exports=e[r]||n(r,{});(o.versions||(o.versions=[])).push({version:"3.49.0",mode:s?"pure":"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.49.0/LICENSE",source:"https://github.com/zloirock/core-js"})})),Fe=te(((t,i)=>{var s=Ue();i.exports=function(t,i){return s[t]||(s[t]=i||{})}})),Ge=te(((t,i)=>{var s=$e(),e=Object;i.exports=function(t){return e(s(t))}})),je=te(((t,i)=>{var s=ce(),e=Ge(),n=s({}.hasOwnProperty);i.exports=Object.hasOwn||function(t,i){return n(e(t),i)}})),Ie=te(((t,i)=>{var s=ce(),e=0,n=Math.random(),r=s(1.1.toString);i.exports=function(t){return"Symbol("+(void 0===t?"":t)+")_"+r(++e+n,36)}})),Ye=te(((t,i)=>{var s=de(),e=Fe(),n=je(),r=Ie(),o=Ne(),h=Le(),a=s.Symbol,l=e("wks"),c=h?a.for||a:a&&a.withoutSetter||r;i.exports=function(t){return n(l,t)||(l[t]=o&&n(a,t)?a[t]:c("Symbol."+t)),l[t]}})),Be=te(((t,i)=>{var s=be(),e=_e(),n=Ee(),r=Pe(),o=We(),h=Ye(),a=TypeError,l=h("toPrimitive");i.exports=function(t,i){if(!e(t)||n(t))return t;var h,c=r(t,l);if(c){if(void 0===i&&(i="default"),h=s(c,t,i),!e(h)||n(h))return h;throw new a("Can't convert object to primitive value")}return void 0===i&&(i="number"),o(t,i)}})),He=te(((t,i)=>{var s=Be(),e=Ee();i.exports=function(t){var i=s(t,"string");return e(i)?i:i+""}})),Ve=te(((t,i)=>{var s=de(),e=_e(),n=s.document,r=e(n)&&e(n.createElement);i.exports=function(t){return r?n.createElement(t):{}}})),Xe=te(((t,i)=>{var s=me(),e=ae(),n=Ve();i.exports=!s&&!e((function(){return 7!==Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a}))})),Je=te((t=>{var i=me(),s=be(),e=ye(),n=we(),r=Me(),o=He(),h=je(),a=Xe(),l=Object.getOwnPropertyDescriptor;t.f=i?l:function(t,i){if(t=r(t),i=o(i),a)try{return l(t,i)}catch(t){}if(h(t,i))return n(!s(e.f,t,i),t[i])}})),qe=te(((t,i)=>{var s=ae(),e=ge(),n=/#|\.prototype\./,r=function(t,i){var n=h[o(t)];return n===l||n!==a&&(e(i)?s(i):!!i)},o=r.normalize=function(t){return String(t).replace(n,".").toLowerCase()},h=r.data={},a=r.NATIVE="N",l=r.POLYFILL="P";i.exports=r})),Ke=te(((t,i)=>{var s=pe(),e=Ce(),n=le(),r=s(s.bind);i.exports=function(t,i){return e(t),void 0===i?t:n?r(t,i):function(){return t.apply(i,arguments)}}})),Qe=te(((t,i)=>{var s=me(),e=ae();i.exports=s&&e((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))})),Ze=te(((t,i)=>{var s=_e(),e=String,n=TypeError;i.exports=function(t){if(s(t))return t;throw new n(e(t)+" is not an object")}})),tn=te((t=>{var i=me(),s=Xe(),e=Qe(),n=Ze(),r=He(),o=TypeError,h=Object.defineProperty,a=Object.getOwnPropertyDescriptor,l="enumerable",c="configurable",u="writable";t.f=i?e?function(t,i,s){if(n(t),i=r(i),n(s),"function"==typeof t&&"prototype"===i&&"value"in s&&u in s&&!s[u]){var e=a(t,i);e&&e[u]&&(t[i]=s.value,s={configurable:c in s?s[c]:e[c],enumerable:l in s?s[l]:e[l],writable:!1})}return h(t,i,s)}:h:function(t,i,e){if(n(t),i=r(i),n(e),s)try{return h(t,i,e)}catch(t){}if("get"in e||"set"in e)throw new o("Accessors not supported");return"value"in e&&(t[i]=e.value),t}})),sn=te(((t,i)=>{var s=me(),e=tn(),n=we();i.exports=s?function(t,i,s){return e.f(t,i,n(1,s))}:function(t,i,s){return t[i]=s,t}})),en=te(((t,i)=>{var s=de(),e=fe(),n=pe(),r=ge(),o=Je().f,h=qe(),a=Oe(),l=Ke(),c=sn(),u=je();Ue();var d=function(t){var i=function(s,n,r){if(this instanceof i){switch(arguments.length){case 0:return new t;case 1:return new t(s);case 2:return new t(s,n)}return new t(s,n,r)}return e(t,this,arguments)};return i.prototype=t.prototype,i};i.exports=function(t,i){var e,f,v,p,g,m,b,y,w,x=t.target,S=t.global,$=t.stat,M=t.proto,_=S?s:$?s[x]:s[x]&&s[x].prototype,O=S?a:a[x]||c(a,x,{})[x],k=O.prototype;for(p in i)f=!(e=h(S?p:x+($?".":"#")+p,t.forced))&&_&&u(_,p),m=O[p],f&&(b=t.dontCallGetSet?(w=o(_,p))&&w.value:_[p]),g=f&&b?b:i[p],(e||M||typeof m!=typeof g)&&(y=t.bind&&f?l(g,s):t.wrap&&f?d(g):M&&r(g)?n(g):g,(t.sham||g&&g.sham||m&&m.sham)&&c(y,"sham",!0),c(O,p,y),M&&(u(a,v=x+"Prototype")||c(a,v,{}),c(a[v],p,g),t.real&&k&&(e||!k[p])&&c(k,p,g)))}})),nn=te(((t,i)=>{var s=Math.ceil,e=Math.floor;i.exports=Math.trunc||function(t){var i=+t;return(i>0?e:s)(i)}})),rn=te(((t,i)=>{var s=nn();i.exports=function(t){var i=+t;return i!=i||0===i?0:s(i)}})),on=te(((t,i)=>{var s=rn(),e=Math.max,n=Math.min;i.exports=function(t,i){var r=s(t);return r<0?e(r+i,0):n(r,i)}})),hn=te(((t,i)=>{var s=rn(),e=Math.min;i.exports=function(t){var i=s(t);return i>0?e(i,9007199254740991):0}})),an=te(((t,i)=>{var s=hn();i.exports=function(t){return s(t.length)}})),ln=te(((t,i)=>{var s=Me(),e=on(),n=an(),r=function(t){return function(i,r,o){var h=s(i),a=n(h);if(0===a)return!t&&-1;var l,c=e(o,a);if(t&&r!=r){for(;a>c;)if((l=h[c++])!=l)return!0}else for(;a>c;c++)if((t||c in h)&&h[c]===r)return t||c||0;return!t&&-1}};i.exports={includes:r(!0),indexOf:r(!1)}})),cn=te(((t,i)=>{i.exports=function(){}})),un=te((()=>{var t=en(),i=ln().includes,s=ae(),e=cn(),n=s((function(){return!Array(1).includes()})),r=s((function(){return[,1].includes(void 0,1)}));t({target:"Array",proto:!0,forced:n||r},{includes:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),e("includes")})),dn=te(((t,i)=>{var s=de(),e=Oe();i.exports=function(t,i){var n=e[t+"Prototype"],r=n&&n[i];if(r)return r;var o=s[t],h=o&&o.prototype;return h&&h[i]}})),fn=te(((t,i)=>{un();var s=dn();i.exports=s("Array","includes")})),vn=te(((t,i)=>{var s=_e(),e=ve(),n=Ye()("match");i.exports=function(t){var i;return s(t)&&(void 0!==(i=t[n])?!!i:"RegExp"===e(t))}})),pn=te(((t,i)=>{var s=vn(),e=TypeError;i.exports=function(t){if(s(t))throw new e("The method doesn't accept regular expressions");return t}})),gn=te(((t,i)=>{var s={};s[Ye()("toStringTag")]="z",i.exports="[object z]"===String(s)})),mn=te(((t,i)=>{var s=gn(),e=ge(),n=ve(),r=Ye()("toStringTag"),o=Object,h="Arguments"===n(function(){return arguments}());i.exports=s?n:function(t){var i,s,a;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(s=function(t,i){try{return t[i]}catch(t){}}(i=o(t),r))?s:h?n(i):"Object"===(a=n(i))&&e(i.callee)?"Arguments":a}})),bn=te(((t,i)=>{var s=mn(),e=String;i.exports=function(t){if("Symbol"===s(t))throw new TypeError("Cannot convert a Symbol value to a string");return e(t)}})),yn=te(((t,i)=>{var s=Ye()("match");i.exports=function(t){var i=/./;try{"/./"[t](i)}catch(e){try{return i[s]=!1,"/./"[t](i)}catch(t){}}return!1}})),wn=te((()=>{var t=en(),i=ce(),s=pn(),e=$e(),n=bn(),r=yn(),o=i("".indexOf);t({target:"String",proto:!0,forced:!r("includes")},{includes:function(t){return!!~o(n(e(this)),n(s(t)),arguments.length>1?arguments[1]:void 0)}})})),xn=te(((t,i)=>{wn();var s=dn();i.exports=s("String","includes")})),Sn=te(((t,i)=>{var s=ue(),e=fn(),n=xn(),r=Array.prototype,o=String.prototype;i.exports=function(t){var i=t.includes;return t===r||s(r,t)&&i===r.includes?e:"string"==typeof t||t===o||s(o,t)&&i===o.includes?n:i}})),$n=se(te(((t,i)=>{var s=Sn();i.exports=s}))());function Mn(t,i){let s;const e=t.length,n=[];for(s=0;s<e;s++)n.push(i(t[s]));return n}function _n(t){return t%360*Math.PI/180}function On(t){return t.replace(/([A-Z])/g,(function(t,i){return"-"+i.toLowerCase()}))}function kn(t){return t.charAt(0).toUpperCase()+t.slice(1)}function An(t,i,s,e){return null!=i&&null!=s||(e=e||t.bbox(),null==i?i=e.width/e.height*s:null==s&&(s=e.height/e.width*i)),{width:i,height:s}}function Rn(t,i){const s=t.origin;let e=null!=t.ox?t.ox:null!=t.originX?t.originX:"center",n=null!=t.oy?t.oy:null!=t.originY?t.originY:"center";null!=s&&([e,n]=Array.isArray(s)?s:"object"==typeof s?[s.x,s.y]:[s,s]);const r="string"==typeof e,o="string"==typeof n;if(r||o){const{height:t,width:s,x:h,y:a}=i.bbox();r&&(e=(0,$n.default)(e).call(e,"left")?h:(0,$n.default)(e).call(e,"right")?h+s:h+s/2),o&&(n=(0,$n.default)(n).call(n,"top")?a:(0,$n.default)(n).call(n,"bottom")?a+t:a+t/2)}return[e,n]}const Nn=new Set(["desc","metadata","title"]),Ln=t=>Nn.has(t.nodeName),En="http://www.w3.org/2000/svg",Tn="http://www.w3.org/2000/xmlns/",Cn="http://www.w3.org/1999/xlink",Pn={window:"undefined"==typeof window?null:window,document:"undefined"==typeof document?null:document};var Wn=class{};const Dn={},zn="___SYMBOL___ROOT___";function Un(t,i=En){return Pn.document.createElementNS(i,t)}function Fn(t,i=!1){if(t instanceof Wn)return t;if("object"==typeof t)return In(t);if(null==t)return new Dn[zn];if("string"==typeof t&&"<"!==t.trim().charAt(0))return In(Pn.document.querySelector(t));const s=i?Pn.document.createElement("div"):Un("svg");return s.innerHTML=t.trim(),t=In(s.firstElementChild),s.removeChild(s.firstElementChild),t}function Gn(t,i){return i&&(i instanceof Pn.window.Node||i.ownerDocument&&i instanceof i.ownerDocument.defaultView.Node)?i:Un(t)}function jn(t){if(!t)return null;if(t.instance instanceof Wn)return t.instance;if("#document-fragment"===t.nodeName)return new Dn.Fragment(t);let i=kn(t.nodeName||"Dom");return"LinearGradient"===i||"RadialGradient"===i?i="Gradient":Dn[i]||(i="Dom"),new Dn[i](t)}let In=jn;function Yn(t,i=t.name,s=!1){return Dn[i]=t,s&&(Dn[zn]=t),he(Object.getOwnPropertyNames(t.prototype)),t}let Bn=1e3;function Hn(t){return"Svgjs"+kn(t)+Bn++}function Vn(t){for(let i=t.children.length-1;i>=0;i--)Vn(t.children[i]);return t.id?(t.id=Hn(t.nodeName),t):t}function Xn(t,i){let s,e;for(e=(t=Array.isArray(t)?t:[t]).length-1;e>=0;e--)for(s in i)t[e].prototype[s]=i[s]}function Jn(t){return function(...i){const s=i[i.length-1];return!s||s.constructor!==Object||s instanceof Array?t.apply(this,i):t.apply(this,i.slice(0,-1)).attr(s)}}re("Dom",{siblings:function(){return this.parent().children()},position:function(){return this.parent().index(this)},next:function(){return this.siblings()[this.position()+1]},prev:function(){return this.siblings()[this.position()-1]},forward:function(){const t=this.position();return this.parent().add(this.remove(),t+1),this},backward:function(){const t=this.position();return this.parent().add(this.remove(),t?t-1:0),this},front:function(){return this.parent().add(this.remove()),this},back:function(){return this.parent().add(this.remove(),0),this},before:function(t){(t=Fn(t)).remove();const i=this.position();return this.parent().add(t,i),this},after:function(t){(t=Fn(t)).remove();const i=this.position();return this.parent().add(t,i+1),this},insertBefore:function(t){return(t=Fn(t)).before(this),this},insertAfter:function(t){return(t=Fn(t)).after(this),this}});const qn=/^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i,Kn=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,Qn=/rgb\((\d+),(\d+),(\d+)\)/,Zn=/^(#[^\s]+)$/,tr=/\)\s*,?\s*/,ir=/\s/g,sr=/^#[a-f0-9]{3}$|^#[a-f0-9]{6}$/i,er=/^rgb\(/,nr=/^(\s+)?$/,rr=/^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,or=/\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i,hr=/[\s,]+/,ar=/[MLHVCSQTAZ]/i;re("Dom",{classes:function(){const t=this.attr("class");return null==t?[]:t.trim().split(hr)},hasClass:function(t){return-1!==this.classes().indexOf(t)},addClass:function(t){if(!this.hasClass(t)){const i=this.classes();i.push(t),this.attr("class",i.join(" "))}return this},removeClass:function(t){return this.hasClass(t)&&this.attr("class",this.classes().filter((function(i){return i!==t})).join(" ")),this},toggleClass:function(t){return this.hasClass(t)?this.removeClass(t):this.addClass(t)}});const lr=t=>t.startsWith("--")?t:On(t);function cr(t){const i=Math.max(0,Math.min(255,Math.round(t))).toString(16);return 1===i.length?"0"+i:i}function ur(t,i){for(let s=i.length;s--;)if(null==t[i[s]])return!1;return!0}function dr(t,i,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(i-t)*s:s<.5?i:s<2/3?t+(i-t)*(2/3-s)*6:t}re("Dom",{css:function(t,i){const s={};if(0===arguments.length){const t=this.node.style;for(let i=0;i<t.length;i++){const e=t.item(i),n=t.getPropertyValue(e),r=t.getPropertyPriority(e);s[e]=r?`${n} !${r}`:n}return s}if(arguments.length<2){if(Array.isArray(t)){for(const i of t){const t=lr(i);s[i]=this.node.style.getPropertyValue(t)}return s}if("string"==typeof t)return this.node.style.getPropertyValue(lr(t));if("object"==typeof t)for(const i in t)this.node.style.setProperty(lr(i),null==t[i]||nr.test(t[i])?"":t[i])}return 2===arguments.length&&this.node.style.setProperty(lr(t),null==i||nr.test(i)?"":i),this},show:function(){return this.css("display","")},hide:function(){return this.css("display","none")},visible:function(){return"none"!==this.css("display")}}),re("Dom",{data:function(t,i,s){if(null==t)return this.data(Mn(function(t){let i;const s=t.length,e=[];for(i=0;i<s;i++)0===t[i].nodeName.indexOf("data-")&&e.push(t[i]);return e}(this.node.attributes),(t=>t.nodeName.slice(5))));if(t instanceof Array){const i={};for(const s of t)i[s]=this.data(s);return i}if("object"==typeof t)for(i in t)this.data(i,t[i]);else if(arguments.length<2)try{return JSON.parse(this.attr("data-"+t))}catch(i){return this.attr("data-"+t)}else this.attr("data-"+t,null===i?null:!0===s||"string"==typeof i||"number"==typeof i?i:JSON.stringify(i));return this}}),re("Dom",{remember:function(t,i){if("object"==typeof arguments[0])for(const i in t)this.remember(i,t[i]);else{if(1===arguments.length)return this.memory()[t];this.memory()[t]=i}return this},forget:function(){if(0===arguments.length)this._memory={};else for(let t=arguments.length-1;t>=0;t--)delete this.memory()[arguments[t]];return this},memory:function(){return this._memory=this._memory||{}}});var fr=class t{constructor(...t){this.init(...t)}static isColor(i){return i&&(i instanceof t||this.isRgb(i)||this.test(i))}static isRgb(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b}static random(i="vibrant",s){const{random:e,round:n,sin:r,PI:o}=Math;if("vibrant"===i){const i=24*e()+57,s=38*e()+45,n=360*e();return new t(i,s,n,"lch")}if("sine"===i){const i=n(80*r(2*o*(s=null==s?e():s)/.5+.01)+150),h=n(50*r(2*o*s/.5+4.6)+200),a=n(100*r(2*o*s/.5+2.3)+150);return new t(i,h,a)}if("pastel"===i){const i=8*e()+86,s=17*e()+9,n=360*e();return new t(i,s,n,"lch")}if("dark"===i){const i=10+10*e(),s=50*e()+86,n=360*e();return new t(i,s,n,"lch")}if("rgb"===i){const i=255*e(),s=255*e(),n=255*e();return new t(i,s,n)}if("lab"===i){const i=100*e(),s=256*e()-128,n=256*e()-128;return new t(i,s,n,"lab")}if("grey"===i){const i=255*e();return new t(i,i,i)}throw new Error("Unsupported random color mode")}static test(t){return"string"==typeof t&&(sr.test(t)||er.test(t))}cmyk(){const{_a:i,_b:s,_c:e}=this.rgb(),[n,r,o]=[i,s,e].map((t=>t/255)),h=Math.min(1-n,1-r,1-o);return 1===h?new t(0,0,0,1,"cmyk"):new t((1-n-h)/(1-h),(1-r-h)/(1-h),(1-o-h)/(1-h),h,"cmyk")}hsl(){const{_a:i,_b:s,_c:e}=this.rgb(),[n,r,o]=[i,s,e].map((t=>t/255)),h=Math.max(n,r,o),a=Math.min(n,r,o),l=(h+a)/2,c=h===a,u=h-a;return new t(360*(c?0:h===n?((r-o)/u+(r<o?6:0))/6:h===r?((o-n)/u+2)/6:h===o?((n-r)/u+4)/6:0),100*(c?0:l>.5?u/(2-h-a):u/(h+a)),100*l,"hsl")}init(t=0,i=0,s=0,e=0,n="rgb"){if(t=t||0,this.space)for(const t in this.space)delete this[this.space[t]];if("number"==typeof t)n="string"==typeof e?e:n,e="string"==typeof e?0:e,Object.assign(this,{_a:t,_b:i,_c:s,_d:e,space:n});else if(t instanceof Array)this.space=i||("string"==typeof t[3]?t[3]:t[4])||"rgb",Object.assign(this,{_a:t[0],_b:t[1],_c:t[2],_d:t[3]||0});else if(t instanceof Object){const s=function(t,i){const s=ur(t,"rgb")?{_a:t.r,_b:t.g,_c:t.b,_d:0,space:"rgb"}:ur(t,"xyz")?{_a:t.x,_b:t.y,_c:t.z,_d:0,space:"xyz"}:ur(t,"hsl")?{_a:t.h,_b:t.s,_c:t.l,_d:0,space:"hsl"}:ur(t,"lab")?{_a:t.l,_b:t.a,_c:t.b,_d:0,space:"lab"}:ur(t,"lch")?{_a:t.l,_b:t.c,_c:t.h,_d:0,space:"lch"}:ur(t,"cmyk")?{_a:t.c,_b:t.m,_c:t.y,_d:t.k,space:"cmyk"}:{_a:0,_b:0,_c:0,space:"rgb"};return s.space=i||s.space,s}(t,i);Object.assign(this,s)}else if("string"==typeof t)if(er.test(t)){const i=t.replace(ir,""),[s,e,n]=Qn.exec(i).slice(1,4).map((t=>parseInt(t)));Object.assign(this,{_a:s,_b:e,_c:n,_d:0,space:"rgb"})}else{if(!sr.test(t))throw Error("Unsupported string format, can't construct Color");{const i=t=>parseInt(t,16),[,s,e,n]=Kn.exec(function(t){return 4===t.length?["#",t.substring(1,2),t.substring(1,2),t.substring(2,3),t.substring(2,3),t.substring(3,4),t.substring(3,4)].join(""):t}(t)).map(i);Object.assign(this,{_a:s,_b:e,_c:n,_d:0,space:"rgb"})}}const{_a:r,_b:o,_c:h,_d:a}=this;Object.assign(this,"rgb"===this.space?{r,g:o,b:h}:"xyz"===this.space?{x:r,y:o,z:h}:"hsl"===this.space?{h:r,s:o,l:h}:"lab"===this.space?{l:r,a:o,b:h}:"lch"===this.space?{l:r,c:o,h}:"cmyk"===this.space?{c:r,m:o,y:h,k:a}:{})}lab(){const{x:i,y:s,z:e}=this.xyz();return new t(116*s-16,500*(i-s),200*(s-e),"lab")}lch(){const{l:i,a:s,b:e}=this.lab(),n=Math.sqrt(s**2+e**2);let r=180*Math.atan2(e,s)/Math.PI;return r<0&&(r*=-1,r=360-r),new t(i,n,r,"lch")}rgb(){if("rgb"===this.space)return this;if("lab"===(i=this.space)||"xyz"===i||"lch"===i){let{x:i,y:s,z:e}=this;if("lab"===this.space||"lch"===this.space){let{l:t,a:n,b:r}=this;if("lch"===this.space){const{c:t,h:i}=this,s=Math.PI/180;n=t*Math.cos(s*i),r=t*Math.sin(s*i)}const o=(t+16)/116,h=n/500+o,a=o-r/200,l=16/116,c=.008856,u=7.787;i=.95047*(h**3>c?h**3:(h-l)/u),s=1*(o**3>c?o**3:(o-l)/u),e=1.08883*(a**3>c?a**3:(a-l)/u)}const n=3.2406*i+-1.5372*s+-.4986*e,r=-.9689*i+1.8758*s+.0415*e,o=.0557*i+-.204*s+1.057*e,h=Math.pow,a=.0031308,l=n>a?1.055*h(n,1/2.4)-.055:12.92*n,c=r>a?1.055*h(r,1/2.4)-.055:12.92*r,u=o>a?1.055*h(o,1/2.4)-.055:12.92*o;return new t(255*l,255*c,255*u)}if("hsl"===this.space){let{h:i,s,l:e}=this;if(i/=360,s/=100,e/=100,0===s)return e*=255,new t(e,e,e);const n=e<.5?e*(1+s):e+s-e*s,r=2*e-n,o=255*dr(r,n,i+1/3),h=255*dr(r,n,i),a=255*dr(r,n,i-1/3);return new t(o,h,a)}if("cmyk"===this.space){const{c:i,m:s,y:e,k:n}=this,r=255*(1-Math.min(1,i*(1-n)+n)),o=255*(1-Math.min(1,s*(1-n)+n)),h=255*(1-Math.min(1,e*(1-n)+n));return new t(r,o,h)}return this;var i}toArray(){const{_a:t,_b:i,_c:s,_d:e,space:n}=this;return[t,i,s,e,n]}toHex(){const[t,i,s]=this._clamped().map(cr);return`#${t}${i}${s}`}toRgb(){const[t,i,s]=this._clamped();return`rgb(${t},${i},${s})`}toString(){return this.toHex()}xyz(){const{_a:i,_b:s,_c:e}=this.rgb(),[n,r,o]=[i,s,e].map((t=>t/255)),h=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92,a=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,l=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92,c=(.4124*h+.3576*a+.1805*l)/.95047,u=(.2126*h+.7152*a+.0722*l)/1,d=(.0193*h+.1192*a+.9505*l)/1.08883,f=c>.008856?Math.pow(c,1/3):7.787*c+16/116,v=u>.008856?Math.pow(u,1/3):7.787*u+16/116,p=d>.008856?Math.pow(d,1/3):7.787*d+16/116;return new t(f,v,p,"xyz")}_clamped(){const{_a:t,_b:i,_c:s}=this.rgb(),{max:e,min:n,round:r}=Math;return[t,i,s].map((t=>e(0,n(r(t),255))))}},vr=class t{constructor(...t){this.init(...t)}clone(){return new t(this)}init(t,i){const s=Array.isArray(t)?{x:t[0],y:t[1]}:"object"==typeof t?{x:t.x,y:t.y}:{x:t,y:i};return this.x=null==s.x?0:s.x,this.y=null==s.y?0:s.y,this}toArray(){return[this.x,this.y]}transform(t){return this.clone().transformO(t)}transformO(t){gr.isMatrixLike(t)||(t=new gr(t));const{x:i,y:s}=this;return this.x=t.a*i+t.c*s+t.e,this.y=t.b*i+t.d*s+t.f,this}};function pr(t,i){return Math.abs(i-t)<1e-6}var gr=class t{constructor(...t){this.init(...t)}static formatTransforms(t){const i="both"===t.flip||!0===t.flip,s=t.flip&&(i||"x"===t.flip)?-1:1,e=t.flip&&(i||"y"===t.flip)?-1:1,n=t.skew&&t.skew.length?t.skew[0]:isFinite(t.skew)?t.skew:isFinite(t.skewX)?t.skewX:0,r=t.skew&&t.skew.length?t.skew[1]:isFinite(t.skew)?t.skew:isFinite(t.skewY)?t.skewY:0,o=t.scale&&t.scale.length?t.scale[0]*s:isFinite(t.scale)?t.scale*s:isFinite(t.scaleX)?t.scaleX*s:s,h=t.scale&&t.scale.length?t.scale[1]*e:isFinite(t.scale)?t.scale*e:isFinite(t.scaleY)?t.scaleY*e:e,a=t.shear||0,l=t.rotate||t.theta||0,c=new vr(t.origin||t.around||t.ox||t.originX,t.oy||t.originY),u=c.x,d=c.y,f=new vr(t.position??t.px??t.positionX??NaN,t.py??t.positionY??NaN),v=f.x,p=f.y,g=new vr(t.translate||t.tx||t.translateX,t.ty||t.translateY),m=g.x,b=g.y,y=new vr(t.relative||t.rx||t.relativeX,t.ry||t.relativeY);return{scaleX:o,scaleY:h,skewX:n,skewY:r,shear:a,theta:l,rx:y.x,ry:y.y,tx:m,ty:b,ox:u,oy:d,px:v,py:p}}static fromArray(t){return{a:t[0],b:t[1],c:t[2],d:t[3],e:t[4],f:t[5]}}static isMatrixLike(t){return null!=t.a||null!=t.b||null!=t.c||null!=t.d||null!=t.e||null!=t.f}static matrixMultiply(t,i,s){const e=t.b*i.a+t.d*i.b,n=t.a*i.c+t.c*i.d,r=t.b*i.c+t.d*i.d,o=t.e+t.a*i.e+t.c*i.f,h=t.f+t.b*i.e+t.d*i.f;return s.a=t.a*i.a+t.c*i.b,s.b=e,s.c=n,s.d=r,s.e=o,s.f=h,s}around(t,i,s){return this.clone().aroundO(t,i,s)}aroundO(t,i,s){const e=t||0,n=i||0;return this.translateO(-e,-n).lmultiplyO(s).translateO(e,n)}clone(){return new t(this)}decompose(t=0,i=0){const s=this.a,e=this.b,n=this.c,r=this.d,o=this.e,h=this.f,a=s*r-e*n,l=a>0?1:-1,c=l*Math.sqrt(s*s+e*e),u=Math.atan2(l*e,l*s),d=(s*n+e*r)/a;return{scaleX:c,scaleY:n*c/(d*s-e)||r*c/(d*e+s),shear:d,rotate:180/Math.PI*u,translateX:o-t+t*s+i*n,translateY:h-i+t*e+i*r,originX:t,originY:i,a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f}}equals(i){if(i===this)return!0;const s=new t(i);return pr(this.a,s.a)&&pr(this.b,s.b)&&pr(this.c,s.c)&&pr(this.d,s.d)&&pr(this.e,s.e)&&pr(this.f,s.f)}flip(t,i){return this.clone().flipO(t,i)}flipO(t,i){return"x"===t?this.scaleO(-1,1,i,0):"y"===t?this.scaleO(1,-1,0,i):this.scaleO(-1,-1,t,i||t)}init(i){const s=t.fromArray([1,0,0,1,0,0]);return i=i instanceof jr?i.matrixify():"string"==typeof i?t.fromArray(i.split(hr).map(parseFloat)):Array.isArray(i)?t.fromArray(i):"object"==typeof i&&t.isMatrixLike(i)?i:"object"==typeof i?(new t).transform(i):6===arguments.length?t.fromArray([].slice.call(arguments)):s,this.a=null!=i.a?i.a:s.a,this.b=null!=i.b?i.b:s.b,this.c=null!=i.c?i.c:s.c,this.d=null!=i.d?i.d:s.d,this.e=null!=i.e?i.e:s.e,this.f=null!=i.f?i.f:s.f,this}inverse(){return this.clone().inverseO()}inverseO(){const t=this.a,i=this.b,s=this.c,e=this.d,n=this.e,r=this.f,o=t*e-i*s;if(!o)throw new Error("Cannot invert "+this);const h=e/o,a=-i/o,l=-s/o,c=t/o,u=-(h*n+l*r),d=-(a*n+c*r);return this.a=h,this.b=a,this.c=l,this.d=c,this.e=u,this.f=d,this}lmultiply(t){return this.clone().lmultiplyO(t)}lmultiplyO(i){const s=i instanceof t?i:new t(i);return t.matrixMultiply(s,this,this)}multiply(t){return this.clone().multiplyO(t)}multiplyO(i){const s=i instanceof t?i:new t(i);return t.matrixMultiply(this,s,this)}rotate(t,i,s){return this.clone().rotateO(t,i,s)}rotateO(t,i=0,s=0){t=_n(t);const e=Math.cos(t),n=Math.sin(t),{a:r,b:o,c:h,d:a,e:l,f:c}=this;return this.a=r*e-o*n,this.b=o*e+r*n,this.c=h*e-a*n,this.d=a*e+h*n,this.e=l*e-c*n+s*n-i*e+i,this.f=c*e+l*n-i*n-s*e+s,this}scale(){return this.clone().scaleO(...arguments)}scaleO(t,i=t,s=0,e=0){3===arguments.length&&(e=s,s=i,i=t);const{a:n,b:r,c:o,d:h,e:a,f:l}=this;return this.a=n*t,this.b=r*i,this.c=o*t,this.d=h*i,this.e=a*t-s*t+s,this.f=l*i-e*i+e,this}shear(t,i,s){return this.clone().shearO(t,i,s)}shearO(t,i=0,s=0){const{a:e,b:n,c:r,d:o,e:h,f:a}=this;return this.a=e+n*t,this.c=r+o*t,this.e=h+a*t-s*t,this}skew(){return this.clone().skewO(...arguments)}skewO(t,i=t,s=0,e=0){3===arguments.length&&(e=s,s=i,i=t),t=_n(t),i=_n(i);const n=Math.tan(t),r=Math.tan(i),{a:o,b:h,c:a,d:l,e:c,f:u}=this;return this.a=o+h*n,this.b=h+o*r,this.c=a+l*n,this.d=l+a*r,this.e=c+u*n-e*n,this.f=u+c*r-s*r,this}skewX(t,i,s){return this.skew(t,0,i,s)}skewY(t,i,s){return this.skew(0,t,i,s)}toArray(){return[this.a,this.b,this.c,this.d,this.e,this.f]}toString(){return"matrix("+this.a+","+this.b+","+this.c+","+this.d+","+this.e+","+this.f+")"}transform(i){if(t.isMatrixLike(i))return new t(i).multiplyO(this);const s=t.formatTransforms(i),{x:e,y:n}=new vr(s.ox,s.oy).transform(this),r=(new t).translateO(s.rx,s.ry).lmultiplyO(this).translateO(-e,-n).scaleO(s.scaleX,s.scaleY).skewO(s.skewX,s.skewY).shearO(s.shear).rotateO(s.theta).translateO(e,n);if(isFinite(s.px)||isFinite(s.py)){const t=new vr(e,n).transform(r),i=isFinite(s.px)?s.px-t.x:0,o=isFinite(s.py)?s.py-t.y:0;r.translateO(i,o)}return r.translateO(s.tx,s.ty),r}translate(t,i){return this.clone().translateO(t,i)}translateO(t,i){return this.e+=t||0,this.f+=i||0,this}valueOf(){return{a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f}}};function mr(){if(!mr.nodes||mr.nodes.svg.node.ownerDocument!==Pn.document){const t=Fn().size(2,0);t.node.style.cssText=["opacity: 0","position: absolute","left: -100%","top: -100%","overflow: hidden"].join(";"),t.attr("focusable","false"),t.attr("aria-hidden","true"),mr.nodes={svg:t,path:t.path().node}}return mr.nodes.svg.node.parentNode||mr.nodes.svg.addTo(Pn.document.body||Pn.document.documentElement),mr.nodes}function br(t){return!(t.width||t.height||t.x||t.y)}Yn(gr,"Matrix");var yr=class t{constructor(...t){this.init(...t)}addOffset(){return this.x+=Pn.window.pageXOffset,this.y+=Pn.window.pageYOffset,new t(this)}init(t){return t="string"==typeof t?t.split(hr).map(parseFloat):Array.isArray(t)?t:"object"==typeof t?[null!=t.left?t.left:t.x,null!=t.top?t.top:t.y,t.width,t.height]:4===arguments.length?[].slice.call(arguments):[0,0,0,0],this.x=t[0]||0,this.y=t[1]||0,this.width=this.w=t[2]||0,this.height=this.h=t[3]||0,this.x2=this.x+this.w,this.y2=this.y+this.h,this.cx=this.x+this.w/2,this.cy=this.y+this.h/2,this}isNulled(){return br(this)}merge(i){const s=Math.min(this.x,i.x),e=Math.min(this.y,i.y),n=Math.max(this.x+this.width,i.x+i.width)-s,r=Math.max(this.y+this.height,i.y+i.height)-e;return new t(s,e,n,r)}toArray(){return[this.x,this.y,this.width,this.height]}toString(){return this.x+" "+this.y+" "+this.width+" "+this.height}transform(i){i instanceof gr||(i=new gr(i));let s=1/0,e=-1/0,n=1/0,r=-1/0;return[new vr(this.x,this.y),new vr(this.x2,this.y),new vr(this.x,this.y2),new vr(this.x2,this.y2)].forEach((function(t){t=t.transform(i),s=Math.min(s,t.x),e=Math.max(e,t.x),n=Math.min(n,t.y),r=Math.max(r,t.y)})),new t(s,n,e-s,r-n)}};function wr(t,i,s){let e;try{if(e=i(t.node),br(e)&&(n=t.node)!==Pn.document&&!(Pn.document.documentElement.contains||function(t){for(;t.parentNode;)t=t.parentNode;return t===Pn.document}).call(Pn.document.documentElement,n))throw new Error("Element not in the dom")}catch(i){e=s(t)}var n;return e}re({viewbox:{viewbox(t,i,s,e){return null==t?new yr(this.attr("viewBox")):this.attr("viewBox",new yr(t,i,s,e))},zoom(t,i){let{width:s,height:e}=this.attr(["width","height"]);if((s||e)&&"string"!=typeof s&&"string"!=typeof e||(s=this.node.clientWidth,e=this.node.clientHeight),!s||!e)throw new Error("Impossible to get absolute width and height. Please provide an absolute width and height attribute on the zooming element");const n=this.viewbox(),r=s/n.width,o=e/n.height,h=Math.min(r,o);if(null==t)return h;let a=h/t;a===1/0&&(a=Number.MAX_SAFE_INTEGER/100),i=i||new vr(s/2/r+n.x,e/2/o+n.y);const l=new yr(n).transform(new gr({scale:a,origin:i}));return this.viewbox(l)}}}),Yn(yr,"Box");var xr=class extends Array{constructor(t=[],...i){if(super(t,...i),"number"==typeof t)return this;this.length=0,this.push(...t)}};Xn([xr],{each(t,...i){return this.map("function"==typeof t?(i,s,e)=>t.call(i,i,s,e):s=>s[t](...i))},toArray(){return Array.prototype.concat.apply([],this)}});const Sr=["toArray","constructor","each"];function $r(t){let i=(t+"").trim();const s=i.match(/^url\((.*)\)$/i);if(s){i=s[1].trim();const t=i[0];if('"'===t||"'"===t){if(i[i.length-1]!==t)return null;i=i.slice(1,-1)}}const e=i.match(Zn);return e?e[1].slice(1):null}function Mr(t,i){const s=`#${Pn.window.CSS.escape(i)}`;return 1===t.nodeType&&t.matches(s)?t:t.querySelector(s)}function _r(t,i,s=`[${i}]`){const e=t.getAttribute("id"),n=t.getRootNode();if(!e||Mr(n,e)!==t)return new xr;const r=[];1===n.nodeType&&n.matches(s)&&$r(n.getAttribute(i))===e&&r.push(jn(n));for(const t of n.querySelectorAll(s))$r(t.getAttribute(i))===e&&r.push(jn(t));return new xr(r)}xr.extend=function(t){t=t.reduce(((t,i)=>((0,$n.default)(Sr).call(Sr,i)||"_"===i[0]||(i in Array.prototype&&(t["$"+i]=Array.prototype[i]),t[i]=function(...t){return this.each(i,...t)}),t)),{}),Xn([xr],t)};let Or=0;const kr=new WeakMap,Ar=new WeakMap,Rr=()=>Object.create(null);function Nr(t){const i=t.getEventHolder();let s=kr.get(i);return s||(s=Rr(),kr.set(i,s)),s}function Lr(t){return t.getEventTarget()}function Er(t,i,s,e,n){const r=s.bind(e||t),o=n||!1,h=Fn(t),a=Nr(h),l=Lr(h);i=Array.isArray(i)?i:i.split(hr);let c=Ar.get(s);c||(c=++Or,Ar.set(s,c)),i.forEach((function(t){const i=t.split(".")[0],s=t.split(".")[1]||"*";a[i]=a[i]||Rr(),a[i][s]=a[i][s]||Rr(),a[i][s][c]=a[i][s][c]||[],a[i][s][c].push({listener:r,options:o}),l.addEventListener(i,r,o)}))}function Tr(t,i,s,e){const n=Fn(t),r=Nr(n),o=Lr(n);("function"!=typeof s||(s=Ar.get(s)))&&(i=Array.isArray(i)?i:(i||"").split(hr)).forEach((function(t){const i=t&&t.split(".")[0],h=t&&t.split(".")[1];let a,l;if(s){if(r[i]&&r[i][h||"*"]){const t=r[i][h||"*"][s];if(!t)return;t.forEach((function(t){o.removeEventListener(i,t.listener,t.options??e??!1)})),delete r[i][h||"*"][s]}}else if(i&&h){if(r[i]&&r[i][h]){for(l in r[i][h])Tr(o,[i,h].join("."),l);delete r[i][h]}}else if(h)for(t in r)for(a in r[t])h===a&&Tr(o,[t,h].join("."));else if(i){if(r[i]){for(a in r[i])Tr(o,[i,a].join("."));delete r[i]}}else{for(t in r)Tr(o,t);!function(t){kr.delete(t.getEventHolder())}(n)}}))}var Cr=class extends Wn{addEventListener(){}dispatch(t,i,s){return function(t,i,s,e){const n=Lr(t);return i instanceof Pn.window.Event||(i=new Pn.window.CustomEvent(i,{detail:s,cancelable:!0,...e})),n.dispatchEvent(i),i}(this,t,i,s)}dispatchEvent(t){const i=Nr(this)[t.type];if(!i)return!0;for(const s in i)for(const e in i[s])i[s][e].forEach((function(i){i.listener(t)}));return!t.defaultPrevented}fire(t,i,s){return this.dispatch(t,i,s),this}getEventHolder(){return this}getEventTarget(){return this}off(t,i,s){return Tr(this,t,i,s),this}on(t,i,s,e){return Er(this,t,i,s,e),this}removeEventListener(){}};function Pr(){}Yn(Cr,"EventTarget");const Wr={"fill-opacity":1,"stroke-opacity":1,"stroke-width":0,"stroke-linejoin":"miter","stroke-linecap":"butt",fill:"#000000",stroke:"#000000",opacity:1,x:0,y:0,cx:0,cy:0,width:0,height:0,r:0,rx:0,ry:0,offset:0,"stop-opacity":1,"stop-color":"#000000","text-anchor":"start"};var Dr=class extends Array{constructor(...t){super(...t),this.init(...t)}clone(){return new this.constructor(this)}init(t){return"number"==typeof t||(this.length=0,this.push(...this.parse(t))),this}parse(t=[]){return t instanceof Array?t:t.trim().split(hr).map(parseFloat)}toArray(){return Array.prototype.concat.apply([],this)}toSet(){return new Set(this)}toString(){return this.join(" ")}valueOf(){const t=[];return t.push(...this),t}},zr=class t{constructor(...t){this.init(...t)}convert(i){return new t(this.value,i)}divide(i){return i=new t(i),new t(this/i,this.unit||i.unit)}init(i,s){return s=Array.isArray(i)?i[1]:s,i=Array.isArray(i)?i[0]:i,this.value=0,this.unit=s||"","number"==typeof i?this.value=isNaN(i)?0:isFinite(i)?i:i<0?-34e37:34e37:"string"==typeof i?(s=i.match(qn))&&(this.value=parseFloat(s[1]),"%"===s[5]?this.value/=100:"s"===s[5]&&(this.value*=1e3),this.unit=s[5]):i instanceof t&&(this.value=i.valueOf(),this.unit=i.unit),this}minus(i){return i=new t(i),new t(this-i,this.unit||i.unit)}plus(i){return i=new t(i),new t(this+i,this.unit||i.unit)}times(i){return i=new t(i),new t(this*i,this.unit||i.unit)}toArray(){return[this.value,this.unit]}toJSON(){return this.toString()}toString(){return("%"===this.unit?~~(1e8*this.value)/1e6:"s"===this.unit?this.value/1e3:this.value)+this.unit}valueOf(){return this.value}};const Ur=new Set(["fill","stroke","color","bgcolor","stop-color","flood-color","lighting-color"]),Fr=[];var Gr=class t extends Cr{constructor(t,i){super(),this.node=t,this.type=t.nodeName,i&&t!==i&&this.attr(i)}add(t,i){return(t=Fn(t)).removeNamespace&&this.node instanceof Pn.window.SVGElement&&t.removeNamespace(),null==i?this.node.appendChild(t.node):t.node!==this.node.childNodes[i]&&this.node.insertBefore(t.node,this.node.childNodes[i]),this}addTo(t,i){return Fn(t).put(this,i)}children(){return new xr(Mn(this.node.children,(function(t){return jn(t)})))}clear(){for(;this.node.hasChildNodes();)this.node.removeChild(this.node.lastChild);return this}clone(t=!0,i=!0){this.writeDataToDom();let s=this.node.cloneNode(t);return i&&(s=Vn(s)),new this.constructor(s)}each(t,i){const s=this.children();let e,n;for(e=0,n=s.length;e<n;e++)t.apply(s[e],[e,s]),i&&s[e].each(t,i);return this}element(i,s){return this.put(new t(Un(i),s))}first(){return jn(this.node.firstChild)}get(t){return jn(this.node.childNodes[t])}getEventHolder(){return this.node}getEventTarget(){return this.node}has(t){return this.index(t)>=0}html(t,i){return this.xml(t,i,"http://www.w3.org/1999/xhtml")}id(t){return void 0!==t||this.node.id||(this.node.id=Hn(this.type)),this.attr("id",t)}index(t){return[].slice.call(this.node.childNodes).indexOf(t.node)}last(){return jn(this.node.lastChild)}matches(t){const i=this.node,s=i.matches||i.matchesSelector||i.msMatchesSelector||i.mozMatchesSelector||i.webkitMatchesSelector||i.oMatchesSelector||null;return s&&s.call(i,t)}parent(t){let i=this;if(!i.node.parentNode)return null;if(i=jn(i.node.parentNode),!t)return i;do{if("string"==typeof t?i.matches(t):i instanceof t)return i}while(i=jn(i.node.parentNode));return i}put(t,i){return t=Fn(t),this.add(t,i),t}putIn(t,i){return Fn(t).add(this,i)}remove(){return this.parent()&&this.parent().removeElement(this),this}removeElement(t){return this.node.removeChild(t.node),this}replace(t){return t=Fn(t),this.node.parentNode&&this.node.parentNode.replaceChild(t.node,this.node),t}round(t=2,i=null){const s=10**t,e=this.attr(i);for(const t in e)"number"==typeof e[t]&&(e[t]=Math.round(e[t]*s)/s);return this.attr(e),this}svg(t,i){return this.xml(t,i,En)}toString(){return this.id()}words(t){return this.node.textContent=t,this}wrap(t){const i=this.parent();if(!i)return this.addTo(t);const s=i.index(this);return i.put(t,s).put(this)}writeDataToDom(){return this.each((function(){this.writeDataToDom()})),this}xml(t,i,s){if("boolean"==typeof t&&(s=i,i=t,t=null),null==t||"function"==typeof t){i=null==i||i,this.writeDataToDom();let s=this;if(null!=t){if(s=jn(s.node.cloneNode(!0)),i){const i=t(s);if(s=i||s,!1===i)return""}s.each((function(){const i=t(this),s=i||this;!1===i?this.remove():i&&this!==s&&this.replace(s)}),!0)}return i?s.node.outerHTML:s.node.innerHTML}i=null!=i&&i;const e=Un("wrapper",s),n=Pn.document.createDocumentFragment();e.innerHTML=t;for(let t=e.children.length;t--;)n.appendChild(e.firstElementChild);const r=this.parent();return i?this.replace(n)&&r:this.add(n)}};Xn(Gr,{attr:function(t,i,s){if(null==t){t={},i=this.node.attributes;for(const s of i)t[s.nodeName]=rr.test(s.nodeValue)?parseFloat(s.nodeValue):s.nodeValue;return t}if(t instanceof Array)return t.reduce(((t,i)=>(t[i]=this.attr(i),t)),{});if("object"==typeof t&&t.constructor===Object)for(i in t)this.attr(i,t[i]);else if(null===i)this.node.removeAttribute(t);else{if(null==i)return null==(i=this.node.getAttribute(t))?Wr[t]:rr.test(i)?parseFloat(i):i;"number"==typeof(i=Fr.reduce(((i,s)=>s(t,i,this)),i))?i=new zr(i):Ur.has(t)&&fr.isColor(i)?i=new fr(i):i.constructor===Array&&(i=new Dr(i)),"leading"===t?this.leading&&this.leading(i):"string"==typeof s?this.node.setAttributeNS(s,t,i.toString()):this.node.setAttribute(t,i.toString()),!this.rebuild||"font-size"!==t&&"x"!==t||this.rebuild()}return this},find:function(t){return function(t,i){return new xr(Mn((i||Pn.document).querySelectorAll(t),(function(t){return jn(t)})))}(t,this.node)},findOne:function(t){return jn(this.node.querySelector(t))}}),Yn(Gr,"Dom");var jr=class extends Gr{constructor(t,i){super(t,i),this.dom={},this.node.instance=this,(t.hasAttribute("data-svgjs")||t.hasAttribute("svgjs:data"))&&this.setData(JSON.parse(t.getAttribute("data-svgjs"))??JSON.parse(t.getAttribute("svgjs:data"))??{})}center(t,i){return this.cx(t).cy(i)}cx(t){return null==t?this.x()+this.width()/2:this.x(t-this.width()/2)}cy(t){return null==t?this.y()+this.height()/2:this.y(t-this.height()/2)}defs(){const t=this.root();return t&&t.defs()}dmove(t,i){return this.dx(t).dy(i)}dx(t=0){return this.x(new zr(t).plus(this.x()))}dy(t=0){return this.y(new zr(t).plus(this.y()))}getEventHolder(){return this}height(t){return this.attr("height",t)}move(t,i){return this.x(t).y(i)}parents(t=this.root()){const i="string"==typeof t,s=this.root(),e=s&&s.node;i||(t=t&&Fn(t).node);const n=new xr;let r=this;for(;(r=r.parent())&&r.node!==Pn.document&&"#document-fragment"!==r.node.nodeName&&(n.push(r),i||r.node!==t)&&(!i||!r.matches(t));)if(e&&r.node===e)return null;return n}reference(t){if(!(t=this.attr(t)))return null;const i=function(t,i){const s=$r(i);return s?Mr(t.getRootNode(),s):null}(this.node,t);return i?Fn(i):null}root(){const t=this.parent(Dn[zn]);return t&&t.root()}setData(t){return this.dom=t,this}size(t,i){const s=An(this,t,i);return this.width(new zr(s.width)).height(new zr(s.height))}width(t){return this.attr("width",t)}writeDataToDom(t){return((t,i,s={})=>{const e={...this.dom};for(const t in e)e[t].valueOf()===s[t]&&delete e[t];Object.keys(e).length?t.node.setAttribute("data-svgjs",JSON.stringify(e)):(t.node.removeAttribute("data-svgjs"),t.node.removeAttribute("svgjs:data"))})(this,0,t),super.writeDataToDom()}x(t){return this.attr("x",t)}y(t){return this.attr("y",t)}};Xn(jr,{bbox:function(){const t=wr(this,(t=>t.getBBox()),(t=>{try{const i=t.clone().addTo(mr().svg).show(),s=i.node.getBBox();return i.remove(),s}catch(i){throw new Error(`Getting bbox of element "${t.node.nodeName}" is not possible: ${i.toString()}`)}}));return new yr(t)},rbox:function(t){const i=wr(this,(t=>t.getBoundingClientRect()),(t=>{throw new Error(`Getting rbox of element "${t.node.nodeName}" is not possible`)})),s=new yr(i);return t?s.transform(t.screenCTM().inverseO()):s.addOffset()},inside:function(t,i){const s=this.bbox();return t>s.x&&i>s.y&&t<s.x+s.width&&i<s.y+s.height},point:function(t,i){return new vr(t,i).transformO(this.screenCTM().inverseO())},ctm:function(){return new gr(this.node.getCTM())},screenCTM:function(){try{if("function"==typeof this.isRoot&&!this.isRoot()){const t=this.rect(1,1),i=t.node.getScreenCTM();return t.remove(),new gr(i)}return new gr(this.node.getScreenCTM())}catch(t){return console.warn(`Cannot get CTM from SVG node ${this.node.nodeName}. Is the element rendered?`),new gr}}}),Yn(jr,"Element");const Ir={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,i){return"color"===i?t:t+"-"+i}};["fill","stroke"].forEach((function(t){const i={};let s;i[t]=function(i){if(void 0===i)return this.attr(t);if("string"==typeof i||i instanceof fr||fr.isRgb(i)||i instanceof jr)this.attr(t,i);else for(s=Ir[t].length-1;s>=0;s--)null!=i[Ir[t][s]]&&this.attr(Ir.prefix(t,Ir[t][s]),i[Ir[t][s]]);return this},re(["Element","Runner"],i)})),re(["Element","Runner"],{matrix:function(t,i,s,e,n,r){return null==t?new gr(this):this.attr("transform",new gr(t,i,s,e,n,r))},rotate:function(t,i,s){return this.transform({rotate:t,ox:i,oy:s},!0)},skew:function(t,i,s,e){return this.transform(1===arguments.length||3===arguments.length?{skew:t,ox:i,oy:s}:{skew:[t,i],ox:s,oy:e},!0)},shear:function(t,i,s){return this.transform({shear:t,ox:i,oy:s},!0)},scale:function(t,i,s,e){return this.transform(1===arguments.length||3===arguments.length?{scale:t,ox:i,oy:s}:{scale:[t,i],ox:s,oy:e},!0)},translate:function(t,i){return this.transform({translate:[t,i]},!0)},relative:function(t,i){return this.transform({relative:[t,i]},!0)},flip:function(t="both",i="center"){return-1==="xybothtrue".indexOf(t)&&(i=t,t="both"),this.transform({flip:t,origin:i},!0)},opacity:function(t){return this.attr("opacity",t)}}),re("radius",{radius:function(t,i=t){return"radialGradient"===(this._element||this).type?this.attr("r",new zr(t)):this.rx(t).ry(i)}}),re("Path",{length:function(){return this.node.getTotalLength()},pointAt:function(t){return new vr(this.node.getPointAtLength(t))}}),re(["Element","Runner"],{font:function(t,i){if("object"==typeof t){for(i in t)this.font(i,t[i]);return this}return"leading"===t?this.leading(i):this.attr("anchor"===t?"text-anchor":"size"===t||"family"===t||"weight"===t||"stretch"===t||"variant"===t||"style"===t?"font-"+t:t,i)}}),re("Element",["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","touchstart","touchmove","touchleave","touchend","touchcancel","contextmenu","wheel","pointerdown","pointermove","pointerup","pointerleave","pointercancel"].reduce((function(t,i){return t[i]=function(t){return null===t?this.off(i):this.on(i,t),this},t}),{})),re("Element",{untransform:function(){return this.attr("transform",null)},matrixify:function(){return(this.attr("transform")||"").split(tr).slice(0,-1).map((function(t){const i=t.trim().split("(");return[i[0].trim(),i[1].split(hr).map((function(t){return parseFloat(t)}))]})).reverse().reduce((function(t,i){return"matrix"===i[0]?t.lmultiply(gr.fromArray(i[1])):t[i[0]].apply(t,i[1])}),new gr)},toParent:function(t,i){if(this===t)return this;if(Ln(this.node))return this.addTo(t,i);const s=this.screenCTM(),e=t.screenCTM().inverse();return this.addTo(t,i).untransform().transform(e.multiply(s)),this},toRoot:function(t){return this.toParent(this.root(),t)},transform:function(t,i){if(null==t||"string"==typeof t){const i=new gr(this).decompose();return null==t?i:i[t]}gr.isMatrixLike(t)||(t={...t,origin:Rn(t,this)});const s=new gr(!0===i?this:i||!1).transform(t);return this.attr("transform",s)}});var Yr=class t extends jr{flatten(){return this.each((function(){if(this instanceof t)return this.flatten().ungroup()})),this}ungroup(t=this.parent(),i=t.index(this)){return i=-1===i?t.children().length:i,this.each((function(s,e){return e[e.length-s-1].toParent(t,i)})),this.remove()}};Yn(Yr,"Container");var Br=class extends Yr{constructor(t,i=t){super(Gn("defs",t),i)}flatten(){return this}ungroup(){return this}};Yn(Br,"Defs");var Hr=class extends jr{};Yn(Hr,"Shape");var Vr=ie({cx:()=>Qr,cy:()=>Zr,height:()=>io,rx:()=>Xr,ry:()=>Jr,width:()=>to,x:()=>qr,y:()=>Kr});function Xr(t){return this.attr("rx",t)}function Jr(t){return this.attr("ry",t)}function qr(t){return null==t?this.cx()-this.rx():this.cx(t+this.rx())}function Kr(t){return null==t?this.cy()-this.ry():this.cy(t+this.ry())}function Qr(t){return this.attr("cx",t)}function Zr(t){return this.attr("cy",t)}function to(t){return null==t?2*this.rx():this.rx(new zr(t).divide(2))}function io(t){return null==t?2*this.ry():this.ry(new zr(t).divide(2))}var so=class extends Hr{constructor(t,i=t){super(Gn("ellipse",t),i)}size(t,i){const s=An(this,t,i);return this.rx(new zr(s.width).divide(2)).ry(new zr(s.height).divide(2))}};Xn(so,Vr),re("Container",{ellipse:Jn((function(t=0,i=t){return this.put(new so).size(t,i).move(0,0)}))}),Yn(so,"Ellipse");var eo=class extends Gr{constructor(t=Pn.document.createDocumentFragment()){super(t)}xml(t,i,s){if("boolean"==typeof t&&(s=i,i=t,t=null),null==t||"function"==typeof t){const t=new Gr(Un("wrapper",s));return t.add(this.node.cloneNode(!0)),t.xml(!1,s)}return super.xml(t,!1,s)}};Yn(eo,"Fragment");var no=ie({from:()=>ro,to:()=>oo});function ro(t,i){return this.attr("radialGradient"===(this._element||this).type?{fx:new zr(t),fy:new zr(i)}:{x1:new zr(t),y1:new zr(i)})}function oo(t,i){return this.attr("radialGradient"===(this._element||this).type?{cx:new zr(t),cy:new zr(i)}:{x2:new zr(t),y2:new zr(i)})}var ho=class extends Yr{constructor(t,i){super(Gn(t+"Gradient","string"==typeof t?null:t),i)}attr(t,i,s){return"transform"===t&&(t="gradientTransform"),super.attr(t,i,s)}bbox(){return new yr}targets(){return _r(this.node,"fill")}toString(){return this.url()}update(t){return this.clear(),"function"==typeof t&&t.call(this,this),this}url(){return"url(#"+this.id()+")"}};Xn(ho,no),re({Container:{gradient(...t){return this.defs().gradient(...t)}},Defs:{gradient:Jn((function(t,i){return this.put(new ho(t)).update(i)}))}}),Yn(ho,"Gradient");var ao=class extends Yr{constructor(t,i=t){super(Gn("pattern",t),i)}attr(t,i,s){return"transform"===t&&(t="patternTransform"),super.attr(t,i,s)}bbox(){return new yr}targets(){return _r(this.node,"fill")}toString(){return this.url()}update(t){return this.clear(),"function"==typeof t&&t.call(this,this),this}url(){return"url(#"+this.id()+")"}};re({Container:{pattern(...t){return this.defs().pattern(...t)}},Defs:{pattern:Jn((function(t,i,s){return this.put(new ao).update(s).attr({x:0,y:0,width:t,height:i,patternUnits:"userSpaceOnUse"})}))}}),Yn(ao,"Pattern");var lo=class extends Hr{constructor(t,i=t){super(Gn("image",t),i)}load(t,i){if(!t)return this;const s=new Pn.window.Image;return Er(s,"load",(function(t){const e=this.parent(ao);0===this.width()&&0===this.height()&&this.size(s.width,s.height),e instanceof ao&&0===e.width()&&0===e.height()&&e.size(this.width(),this.height()),"function"==typeof i&&i.call(this,t)}),this),Er(s,"load error",(function(){Tr(s)})),this.attr("href",s.src=t,Cn)}};Fr.push((function(t,i,s){return"fill"!==t&&"stroke"!==t||or.test(i)&&(i=s.root().defs().image(i)),i instanceof lo&&(i=s.root().defs().pattern(0,0,(t=>{t.add(i)}))),i})),re({Container:{image:Jn((function(t,i){return this.put(new lo).size(0,0).load(t,i)}))}}),Yn(lo,"Image");var co=class extends Dr{bbox(){let t=-1/0,i=-1/0,s=1/0,e=1/0;return this.forEach((function(n){t=Math.max(n[0],t),i=Math.max(n[1],i),s=Math.min(n[0],s),e=Math.min(n[1],e)})),new yr(s,e,t-s,i-e)}move(t,i){const s=this.bbox();if(t-=s.x,i-=s.y,!isNaN(t)&&!isNaN(i))for(let s=this.length-1;s>=0;s--)this[s]=[this[s][0]+t,this[s][1]+i];return this}parse(t=[0,0]){const i=[];(t=t instanceof Array?Array.prototype.concat.apply([],t):t.trim().split(hr).map(parseFloat)).length%2!=0&&t.pop();for(let s=0,e=t.length;s<e;s+=2)i.push([t[s],t[s+1]]);return i}size(t,i){let s;const e=this.bbox();for(s=this.length-1;s>=0;s--)e.width&&(this[s][0]=(this[s][0]-e.x)*t/e.width+e.x),e.height&&(this[s][1]=(this[s][1]-e.y)*i/e.height+e.y);return this}toLine(){return{x1:this[0][0],y1:this[0][1],x2:this[1][0],y2:this[1][1]}}toString(){const t=[];for(let i=0,s=this.length;i<s;i++)t.push(this[i].join(","));return t.join(" ")}transform(t){return this.clone().transformO(t)}transformO(t){gr.isMatrixLike(t)||(t=new gr(t));for(let i=this.length;i--;){const[s,e]=this[i];this[i][0]=t.a*s+t.c*e+t.e,this[i][1]=t.b*s+t.d*e+t.f}return this}},uo=ie({MorphArray:()=>fo,height:()=>mo,width:()=>go,x:()=>vo,y:()=>po});const fo=co;function vo(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)}function po(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)}function go(t){const i=this.bbox();return null==t?i.width:this.size(t,i.height)}function mo(t){const i=this.bbox();return null==t?i.height:this.size(i.width,t)}var bo=class extends Hr{constructor(t,i=t){super(Gn("line",t),i)}array(){return new co([[this.attr("x1"),this.attr("y1")],[this.attr("x2"),this.attr("y2")]])}move(t,i){return this.attr(this.array().move(t,i).toLine())}plot(t,i,s,e){return null==t?this.array():(t=void 0!==i?{x1:t,y1:i,x2:s,y2:e}:new co(t).toLine(),this.attr(t))}size(t,i){const s=An(this,t,i);return this.attr(this.array().size(s.width,s.height).toLine())}};Xn(bo,uo),re({Container:{line:Jn((function(...t){return bo.prototype.plot.apply(this.put(new bo),null!=t[0]?t:[0,0,0,0])}))}}),Yn(bo,"Line");var yo=class extends Yr{constructor(t,i=t){super(Gn("marker",t),i)}height(t){return this.attr("markerHeight",t)}orient(t){return this.attr("orient",t)}ref(t,i){return this.attr("refX",t).attr("refY",i)}toString(){return"url(#"+this.id()+")"}update(t){return this.clear(),"function"==typeof t&&t.call(this,this),this}width(t){return this.attr("markerWidth",t)}};function wo(t,i){return function(s){return null==s?this[t]:(this[t]=s,i&&i.call(this),this)}}re({Container:{marker(...t){return this.defs().marker(...t)}},Defs:{marker:Jn((function(t,i,s){return this.put(new yo).size(t,i).ref(t/2,i/2).viewbox(0,0,t,i).attr("orient","auto").update(s)}))},marker:{marker(t,i,s,e){let n=["marker"];return"all"!==t&&n.push(t),n=n.join("-"),t=arguments[1]instanceof yo?arguments[1]:this.defs().marker(i,s,e),this.attr(n,t)}}}),Yn(yo,"Marker");const xo={"-":function(t){return t},"<>":function(t){return-Math.cos(t*Math.PI)/2+.5},">":function(t){return Math.sin(t*Math.PI/2)},"<":function(t){return 1-Math.cos(t*Math.PI/2)},bezier:function(t,i,s,e){return function(n){return n<0?t>0?i/t*n:s>0?e/s*n:0:n>1?s<1?(1-e)/(1-s)*n+(e-s)/(1-s):t<1?(1-i)/(1-t)*n+(i-t)/(1-t):1:3*n*(1-n)**2*i+3*n**2*(1-n)*e+n**3}},steps:function(t,i="end"){i=i.split("-").reverse()[0];let s=t;return"none"===i?--s:"both"===i&&++s,(e,n=!1)=>{let r=Math.floor(e*t);const o=e*r%1==0;return"start"!==i&&"both"!==i||++r,n&&o&&--r,e>=0&&r<0&&(r=0),e<=1&&r>s&&(r=s),r/s}}};var So=class{done(){return!1}},$o=class extends So{constructor(t=">"){super(),this.ease=xo[t]||t}step(t,i,s){return"number"!=typeof t?s<1?t:i:t+(i-t)*this.ease(s)}},Mo=class extends So{constructor(t){super(),this.stepper=t}done(t){return t.done}step(t,i,s,e){return this.stepper(t,i,s,e)}};function _o(){const t=(this._duration||500)/1e3,i=Math.PI,s=Math.log((this._overshoot||0)/100+1e-10),e=-s/Math.sqrt(i*i+s*s),n=3.9/(e*t);this.d=2*e*n,this.k=n*n}Xn(class extends Mo{constructor(t=500,i=0){super(),this.duration(t).overshoot(i)}step(t,i,s,e){if("string"==typeof t)return t;if(e.done=s===1/0,s===1/0)return i;if(0===s)return t;s>100&&(s=16);const n=e.velocity||0,r=-this.d*n-this.k*(t-i),o=t+n*(s/=1e3)+r*s*s/2;return e.velocity=n+r*s,e.done=Math.abs(i-o)+Math.abs(n)<.002,e.done?i:o}},{duration:wo("_duration",_o),overshoot:wo("_overshoot",_o)}),Xn(class extends Mo{constructor(t=.1,i=.01,s=0,e=1e3){super(),this.p(t).i(i).d(s).windup(e)}step(t,i,s,e){if("string"==typeof t)return t;if(e.done=s===1/0,s===1/0)return i;if(0===s)return t;const n=i-t;let r=(e.integral||0)+n*s;const o=(n-(e.error||0))/s,h=this._windup;return!1!==h&&(r=Math.max(-h,Math.min(r,h))),e.error=n,e.integral=r,e.done=Math.abs(n)<.001,e.done?i:t+(this.P*n+this.I*r+this.D*o)}},{windup:wo("_windup"),p:wo("P"),i:wo("I"),d:wo("D")});const Oo={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0},ko={M:function(t,i,s){return i.x=s.x=t[0],i.y=s.y=t[1],["M",i.x,i.y]},L:function(t,i){return i.x=t[0],i.y=t[1],["L",t[0],t[1]]},H:function(t,i){return i.x=t[0],["H",t[0]]},V:function(t,i){return i.y=t[0],["V",t[0]]},C:function(t,i){return i.x=t[4],i.y=t[5],["C",t[0],t[1],t[2],t[3],t[4],t[5]]},S:function(t,i){return i.x=t[2],i.y=t[3],["S",t[0],t[1],t[2],t[3]]},Q:function(t,i){return i.x=t[2],i.y=t[3],["Q",t[0],t[1],t[2],t[3]]},T:function(t,i){return i.x=t[0],i.y=t[1],["T",t[0],t[1]]},Z:function(t,i,s){return i.x=s.x,i.y=s.y,["Z"]},A:function(t,i){return i.x=t[5],i.y=t[6],["A",t[0],t[1],t[2],t[3],t[4],t[5],t[6]]}},Ao="mlhvqtcsaz".split("");for(let t=0,i=Ao.length;t<i;++t)ko[Ao[t]]=function(t){return function(i,s,e){if("H"===t)i[0]=i[0]+s.x;else if("V"===t)i[0]=i[0]+s.y;else if("A"===t)i[5]=i[5]+s.x,i[6]=i[6]+s.y;else for(let t=0,e=i.length;t<e;++t)i[t]=i[t]+(t%2?s.y:s.x);return ko[t](i,s,e)}}(Ao[t].toUpperCase());function Ro(t){return t.segment.length&&t.segment.length-1===Oo[t.segment[0].toUpperCase()]}function No(t,i){t.inNumber&&Lo(t,!1);const s=ar.test(i);if(s)t.segment=[i];else{const i=t.lastCommand,s=i.toLowerCase();t.segment=["m"===s?i===s?"l":"L":i]}return t.inSegment=!0,t.lastCommand=t.segment[0],s}function Lo(t,i){if(!t.inNumber)throw new Error("Parser Error");t.number&&t.segment.push(parseFloat(t.number)),t.inNumber=i,t.number="",t.pointSeen=!1,t.hasExponent=!1,Ro(t)&&Eo(t)}function Eo(t){t.inSegment=!1,t.absolute&&(t.segment=function(t){return ko[t.segment[0]](t.segment.slice(1),t.p,t.p0)}(t)),t.segments.push(t.segment)}function To(t){if(!t.segment.length)return!1;const i="A"===t.segment[0].toUpperCase(),s=t.segment.length;return i&&(4===s||5===s)}function Co(t){return"E"===t.lastToken.toUpperCase()}const Po=new Set([" ",",","\t","\n","\r","\f"]);var Wo=class extends Dr{bbox(){return mr().path.setAttribute("d",this.toString()),new yr(mr.nodes.path.getBBox())}move(t,i){const s=this.bbox();if(t-=s.x,i-=s.y,!isNaN(t)&&!isNaN(i))for(let s,e=this.length-1;e>=0;e--)s=this[e][0],"M"===s||"L"===s||"T"===s?(this[e][1]+=t,this[e][2]+=i):"H"===s?this[e][1]+=t:"V"===s?this[e][1]+=i:"C"===s||"S"===s||"Q"===s?(this[e][1]+=t,this[e][2]+=i,this[e][3]+=t,this[e][4]+=i,"C"===s&&(this[e][5]+=t,this[e][6]+=i)):"A"===s&&(this[e][6]+=t,this[e][7]+=i);return this}parse(t="M0 0"){return Array.isArray(t)&&(t=Array.prototype.concat.apply([],t).toString()),function(t,i=!0){let s=0,e="";const n={segment:[],inNumber:!1,number:"",lastToken:"",inSegment:!1,segments:[],pointSeen:!1,hasExponent:!1,absolute:i,p0:new vr,p:new vr};for(;n.lastToken=e,e=t.charAt(s++);)if(n.inSegment||!No(n,e))if("."!==e)if(isNaN(parseInt(e)))if(Po.has(e))n.inNumber&&Lo(n,!1);else if("-"!==e&&"+"!==e)if("E"!==e.toUpperCase()){if(ar.test(e)){if(n.inNumber)Lo(n,!1);else{if(!Ro(n))throw new Error("parser Error");Eo(n)}--s}}else n.number+=e,n.hasExponent=!0;else{if(n.inNumber&&!Co(n)){Lo(n,!1),--s;continue}n.number+=e,n.inNumber=!0}else{if("0"===n.number||To(n)){n.inNumber=!0,n.number=e,Lo(n,!0);continue}n.inNumber=!0,n.number+=e}else{if(n.pointSeen||n.hasExponent){Lo(n,!1),--s;continue}n.inNumber=!0,n.pointSeen=!0,n.number+=e}return n.inNumber&&Lo(n,!1),n.inSegment&&Ro(n)&&Eo(n),n.segments}(t)}size(t,i){const s=this.bbox();let e,n;for(s.width=0===s.width?1:s.width,s.height=0===s.height?1:s.height,e=this.length-1;e>=0;e--)n=this[e][0],"M"===n||"L"===n||"T"===n?(this[e][1]=(this[e][1]-s.x)*t/s.width+s.x,this[e][2]=(this[e][2]-s.y)*i/s.height+s.y):"H"===n?this[e][1]=(this[e][1]-s.x)*t/s.width+s.x:"V"===n?this[e][1]=(this[e][1]-s.y)*i/s.height+s.y:"C"===n||"S"===n||"Q"===n?(this[e][1]=(this[e][1]-s.x)*t/s.width+s.x,this[e][2]=(this[e][2]-s.y)*i/s.height+s.y,this[e][3]=(this[e][3]-s.x)*t/s.width+s.x,this[e][4]=(this[e][4]-s.y)*i/s.height+s.y,"C"===n&&(this[e][5]=(this[e][5]-s.x)*t/s.width+s.x,this[e][6]=(this[e][6]-s.y)*i/s.height+s.y)):"A"===n&&(this[e][1]=this[e][1]*t/s.width,this[e][2]=this[e][2]*i/s.height,this[e][6]=(this[e][6]-s.x)*t/s.width+s.x,this[e][7]=(this[e][7]-s.y)*i/s.height+s.y);return this}toString(){return function(t){let i="";for(let s=0,e=t.length;s<e;s++)i+=t[s][0],null!=t[s][1]&&(i+=t[s][1],null!=t[s][2]&&(i+=" ",i+=t[s][2],null!=t[s][3]&&(i+=" ",i+=t[s][3],i+=" ",i+=t[s][4],null!=t[s][5]&&(i+=" ",i+=t[s][5],i+=" ",i+=t[s][6],null!=t[s][7]&&(i+=" ",i+=t[s][7])))));return i+" "}(this)}};const Do=t=>{const i=typeof t;return"number"===i?zr:"string"===i?fr.isColor(t)?fr:hr.test(t)?ar.test(t)?Wo:Dr:qn.test(t)?zr:Uo:Io.indexOf(t.constructor)>-1?t.constructor:Array.isArray(t)?Dr:"object"===i?jo:Uo};var zo=class{constructor(t){this._stepper=t||new $o("-"),this._from=null,this._to=null,this._type=null,this._context=null,this._morphObj=null}at(t){return this._morphObj.morph(this._from,this._to,t,this._stepper,this._context)}done(){return this._context.map(this._stepper.done).reduce((function(t,i){return t&&i}),!0)}from(t){return null==t?this._from:(this._from=this._set(t),this)}stepper(t){return null==t?this._stepper:(this._stepper=t,this)}to(t){return null==t?this._to:(this._to=this._set(t),this)}type(t){return null==t?this._type:(this._type=t,this)}_set(t){this._type||this.type(Do(t));let i=new this._type(t);return this._type===fr&&(i=this._to?i[this._to[4]]():this._from?i[this._from[4]]():i),this._type===jo&&(i=this._to?i.align(this._to):this._from?i.align(this._from):i),i=i.toConsumable(),this._morphObj=this._morphObj||new this._type,this._context=this._context||Array.apply(null,Array(i.length)).map(Object).map((function(t){return t.done=!0,t})),i}},Uo=class{constructor(...t){this.init(...t)}init(t){return t=Array.isArray(t)?t[0]:t,this.value=t,this}toArray(){return[this.value]}valueOf(){return this.value}},Fo=class t{constructor(...t){this.init(...t)}init(i){return Array.isArray(i)&&(i={scaleX:i[0],scaleY:i[1],shear:i[2],rotate:i[3],translateX:i[4],translateY:i[5],originX:i[6],originY:i[7]}),Object.assign(this,t.defaults,i),this}toArray(){const t=this;return[t.scaleX,t.scaleY,t.shear,t.rotate,t.translateX,t.translateY,t.originX,t.originY]}};Fo.defaults={scaleX:1,scaleY:1,shear:0,rotate:0,translateX:0,translateY:0,originX:0,originY:0};const Go=(t,i)=>t[0]<i[0]?-1:t[0]>i[0]?1:0;var jo=class{constructor(...t){this.init(...t)}align(t){const i=this.values;for(let s=0,e=i.length;s<e;++s){if(i[s+1]===t[s+1]){if(i[s+1]===fr&&t[s+7]!==i[s+7]){const i=t[s+7],e=new fr(this.values.splice(s+3,5))[i]().toArray();this.values.splice(s+3,0,...e)}s+=i[s+2]+2;continue}if(!t[s+1])return this;const e=(new t[s+1]).toArray();i.splice(s,i[s+2]+3,t[s],t[s+1],t[s+2],...e),s+=i[s+2]+2}return this}init(t){if(this.values=[],Array.isArray(t))return void(this.values=t.slice());t=t||{};const i=[];for(const s in t){const e=Do(t[s]),n=new e(t[s]).toArray();i.push([s,e,n.length,...n])}return i.sort(Go),this.values=i.reduce(((t,i)=>t.concat(i)),[]),this}toArray(){return this.values}valueOf(){const t={},i=this.values;for(;i.length;){const s=i.shift(),e=i.shift(),n=i.shift();t[s]=new e(i.splice(0,n))}return t}};const Io=[Uo,Fo,jo];var Yo=class extends Hr{constructor(t,i=t){super(Gn("path",t),i)}array(){return this._array||(this._array=new Wo(this.attr("d")))}clear(){return delete this._array,this}height(t){return null==t?this.bbox().height:this.size(this.bbox().width,t)}move(t,i){return this.attr("d",this.array().move(t,i))}plot(t){return null==t?this.array():this.clear().attr("d","string"==typeof t?t:this._array=new Wo(t))}size(t,i){const s=An(this,t,i);return this.attr("d",this.array().size(s.width,s.height))}width(t){return null==t?this.bbox().width:this.size(t,this.bbox().height)}x(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)}y(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)}};Yo.prototype.MorphArray=Wo,re({Container:{path:Jn((function(t){return this.put(new Yo).plot(t||new Wo)}))}}),Yn(Yo,"Path");var Bo=ie({array:()=>Ho,clear:()=>Vo,move:()=>Xo,plot:()=>Jo,size:()=>qo});function Ho(){return this._array||(this._array=new co(this.attr("points")))}function Vo(){return delete this._array,this}function Xo(t,i){return this.attr("points",this.array().move(t,i))}function Jo(t){return null==t?this.array():this.clear().attr("points","string"==typeof t?t:this._array=new co(t))}function qo(t,i){const s=An(this,t,i);return this.attr("points",this.array().size(s.width,s.height))}var Ko=class extends Hr{constructor(t,i=t){super(Gn("polygon",t),i)}};re({Container:{polygon:Jn((function(t){return this.put(new Ko).plot(t||new co)}))}}),Xn(Ko,uo),Xn(Ko,Bo),Yn(Ko,"Polygon");var Qo=class extends Hr{constructor(t,i=t){super(Gn("polyline",t),i)}};re({Container:{polyline:Jn((function(t){return this.put(new Qo).plot(t||new co)}))}}),Xn(Qo,uo),Xn(Qo,Bo),Yn(Qo,"Polyline");var Zo=class extends Hr{constructor(t,i=t){super(Gn("rect",t),i)}};Xn(Zo,{rx:Xr,ry:Jr}),re({Container:{rect:Jn((function(t,i){return this.put(new Zo).size(t,i)}))}}),Yn(Zo,"Rect");var th=class{constructor(){this._first=null,this._last=null}first(){return this._first&&this._first.value}last(){return this._last&&this._last.value}push(t){const i=void 0!==t.next?t:{value:t,next:null,prev:null};return this._last?(i.prev=this._last,this._last.next=i,this._last=i):(this._last=i,this._first=i),i}remove(t){t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t===this._last&&(this._last=t.prev),t===this._first&&(this._first=t.next),t.prev=null,t.next=null}shift(){const t=this._first;return t?(this._first=t.next,this._first&&(this._first.prev=null),this._last=this._first?this._last:null,t.value):null}};const ih={nextDraw:null,frames:new th,timeouts:new th,immediates:new th,timer:()=>Pn.window.performance||Pn.window.Date,transforms:[],frame(t){const i=ih.frames.push({run:t});return null===ih.nextDraw&&(ih.nextDraw=Pn.window.requestAnimationFrame(ih._draw)),i},timeout(t,i){i=i||0;const s=ih.timer().now()+i,e=ih.timeouts.push({run:t,time:s});return null===ih.nextDraw&&(ih.nextDraw=Pn.window.requestAnimationFrame(ih._draw)),e},immediate(t){const i=ih.immediates.push(t);return null===ih.nextDraw&&(ih.nextDraw=Pn.window.requestAnimationFrame(ih._draw)),i},cancelFrame(t){null!=t&&ih.frames.remove(t)},clearTimeout(t){null!=t&&ih.timeouts.remove(t)},cancelImmediate(t){null!=t&&ih.immediates.remove(t)},_draw(t){try{let i=null;const s=ih.timeouts.last();for(;(i=ih.timeouts.shift())&&(t>=i.time?i.run():ih.timeouts.push(i),i!==s););let e=null;const n=ih.frames.last();for(;e!==n&&(e=ih.frames.shift());)e.run(t);let r=null;for(;r=ih.immediates.shift();)r()}finally{const t=ih.timeouts.first()||ih.frames.first()||ih.immediates.first();ih.nextDraw=t?Pn.window.requestAnimationFrame(ih._draw):null}}},sh=function(t){const i=t.start,s=t.runner.duration();return{start:i,duration:s,end:i+s,runner:t.runner}},eh=function(){const t=Pn.window;return(t.performance||t.Date).now()};var nh=class extends Cr{constructor(t=eh){super(),this._timeSource=t,this.terminate()}active(){return!!this._nextFrame}finish(){return this.time(this.getEndTimeOfTimeline()+1),this.pause()}getEndTime(){const t=this.getLastRunnerInfo(),i=t?t.runner.duration():0;return(t?t.start:this._time)+i}getEndTimeOfTimeline(){const t=this._runners.map((t=>t.start+t.runner.duration()));return Math.max(0,...t)}getLastRunnerInfo(){return this.getRunnerInfoById(this._lastRunnerId)}getRunnerInfoById(t){return this._runners[this._runnerIds.indexOf(t)]||null}pause(){return this._paused=!0,this._continue()}persist(t){return null==t?this._persist:(this._persist=t,this)}play(){return this._paused=!1,this.updateTime()._continue()}reverse(t){const i=this.speed();if(null==t)return this.speed(-i);const s=Math.abs(i);return this.speed(t?-s:s)}schedule(t,i,s){if(null==t)return this._runners.map(sh);let e=0;const n=this.getEndTime();if(i=i||0,null==s||"last"===s||"after"===s)e=n;else if("absolute"===s||"start"===s)e=i,i=0;else if("now"===s)e=this._time;else if("relative"===s){const s=this.getRunnerInfoById(t.id);s&&(e=s.start+i,i=0)}else{if("with-last"!==s)throw new Error('Invalid value for the "when" parameter');{const t=this.getLastRunnerInfo();e=t?t.start:this._time}}t.unschedule(),t.timeline(this);const r=t.persist(),o={persist:null===r?this._persist:r,start:e+i,runner:t};return this._lastRunnerId=t.id,this._runners.push(o),this._runners.sort(((t,i)=>t.start-i.start)),this._runnerIds=this._runners.map((t=>t.runner.id)),this.updateTime()._continue(),this}seek(t){return this.time(this._time+t)}source(t){return null==t?this._timeSource:(this._timeSource=t,this)}speed(t){return null==t?this._speed:(this._speed=t,this)}stop(){return this.time(0),this.pause()}time(t){return null==t?this._time:(this._time=t,this._continue(!0))}unschedule(t){const i=this._runnerIds.indexOf(t.id);return i<0||(this._runners.splice(i,1),this._runnerIds.splice(i,1),t.timeline(null)),this}updateTime(){return this.active()||(this._lastSourceTime=this._timeSource()),this}_continue(t=!1){return ih.cancelFrame(this._nextFrame),this._nextFrame=null,t?this._stepImmediate():(this._paused||(this._nextFrame=ih.frame(this._step)),this)}_stepFn(t=!1){const i=this._timeSource();let s=i-this._lastSourceTime;t&&(s=0);const e=this._speed*s+(this._time-this._lastStepTime);this._lastSourceTime=i,t||(this._time+=e,this._time=this._time<0?0:this._time),this._lastStepTime=this._time,this.fire("time",this._time);for(let t=this._runners.length;t--;){const i=this._runners[t];this._time-i.start<=0&&i.runner.reset()}let n=!1;for(let t=0,i=this._runners.length;t<i;t++){const s=this._runners[t],r=s.runner;let o=e;const h=this._time-s.start;h<=0?n=!0:(h<o&&(o=h),r.active()&&(r.step(o).done?!0!==s.persist&&r.duration()-r.time()+this._time+s.persist<this._time&&(r.unschedule(),--t,--i):n=!0))}return n&&!(this._speed<0&&0===this._time)||this._runnerIds.length&&this._speed<0&&this._time>0?this._continue():(this.pause(),this.fire("finished")),this}terminate(){this._startTime=0,this._speed=1,this._persist=0,this._nextFrame=null,this._paused=!0,this._runners=[],this._runnerIds=[],this._lastRunnerId=-1,this._time=0,this._lastSourceTime=0,this._lastStepTime=0,this._step=this._stepFn.bind(this,!1),this._stepImmediate=this._stepFn.bind(this,!0)}};re({Element:{timeline:function(t){return null==t?(this._timeline=this._timeline||new nh,this._timeline):(this._timeline=t,this)}}});var rh=class t extends Cr{constructor(i){super(),this.id=t.id++,i="function"==typeof(i=null==i?400:i)?new Mo(i):i,this._element=null,this._timeline=null,this.done=!1,this._queue=[],this._duration="number"==typeof i&&i,this._isDeclarative=i instanceof Mo,this._stepper=this._isDeclarative?i:new $o,this._history={},this.enabled=!0,this._time=0,this._lastTime=0,this._reseted=!0,this.transforms=new gr,this.transformId=1,this._haveReversed=!1,this._reverse=!1,this._loopsDone=0,this._swing=!1,this._wait=0,this._times=1,this._frameId=null,this._persist=!!this._isDeclarative||null}static sanitise(t,i,s){let e=1,n=!1,r=0;return i=i??0,s=s||"last","object"!=typeof(t=t??400)||t instanceof So||(i=t.delay??i,s=t.when??s,n=t.swing||n,e=t.times??e,r=t.wait??r,t=t.duration??400),{duration:t,delay:i,swing:n,times:e,wait:r,when:s}}active(t){return null==t?this.enabled:(this.enabled=t,this)}addTransform(t){return this.transforms.lmultiplyO(t),this}after(t){return this.on("finished",t)}animate(i,s,e){const n=t.sanitise(i,s,e),r=new t(n.duration);return this._timeline&&r.timeline(this._timeline),this._element&&r.element(this._element),r.loop(n).schedule(n.delay,n.when)}clearTransform(){return this.transforms=new gr,this}clearTransformsFromQueue(){var t;this.done&&this._timeline&&(0,$n.default)(t=this._timeline._runnerIds).call(t,this.id)||(this._queue=this._queue.filter((t=>!t.isTransform)))}delay(t){return this.animate(0,t)}duration(){return this._times*(this._wait+this._duration)-this._wait}during(t){return this.queue(null,t)}ease(t){return this._stepper=new $o(t),this}element(t){return null==t?this._element:(this._element=t,t._prepareRunner(),this)}finish(){return this.step(1/0)}loop(t,i,s){return"object"==typeof t&&(i=t.swing,s=t.wait,t=t.times),this._times=t||1/0,this._swing=i||!1,this._wait=s||0,!0===this._times&&(this._times=1/0),this}loops(t){const i=this._duration+this._wait;if(null==t){const t=Math.floor(this._time/i);return Math.min(t+(this._time-t*i)/this._duration,this._times)}const s=Math.floor(t);return this.time(i*s+this._duration*(t%1))}persist(t){return null==t?this._persist:(this._persist=t,this)}position(t){const i=this._time,s=this._duration,e=this._wait,n=this._swing,r=this._reverse;let o;if(null==t){const t=function(t){const i=n*Math.floor(t%(2*(e+s))/(e+s)),o=i&&!r||!i&&r,h=Math.pow(-1,o)*(t%(e+s))/s+o;return Math.max(Math.min(h,1),0)},h=this._times*(e+s)-e;return o=i<=0?Math.round(t(1e-5)):i<h?t(i):Math.round(t(h-1e-5)),o}const h=Math.floor(this.loops()),a=n&&h%2==0;return o=h+(a&&!r||r&&a?t:1-t),this.loops(o)}progress(t){return null==t?Math.min(1,this._time/this.duration()):this.time(t*this.duration())}queue(t,i,s,e){return this._queue.push({initialiser:t||Pr,runner:i||Pr,retarget:s,isTransform:e,initialised:!1,finished:!1}),this.timeline()&&this.timeline()._continue(),this}reset(){return this._reseted||(this.time(0),this._reseted=!0),this}reverse(t){return this._reverse=null==t?!this._reverse:t,this}schedule(t,i,s){if(t instanceof nh||(s=i,i=t,t=this.timeline()),!t)throw Error("Runner cannot be scheduled without timeline");return t.schedule(this,i,s),this}step(t){if(!this.enabled)return this;this._time+=t=null==t?16:t;const i=this.position(),s=this._lastPosition!==i&&this._time>=0;this._lastPosition=i;const e=this.duration(),n=this._lastTime<=0&&this._time>0,r=this._lastTime<e&&this._time>=e;this._lastTime=this._time,n&&this.fire("start",this);const o=this._isDeclarative;this.done=!o&&!r&&this._time>=e,this._reseted=!1;let h=!1;return(s||o)&&(this._initialise(s),this.transforms=new gr,h=this._run(o?t:i),this.fire("step",this)),this.done=this.done||h&&o,r&&this.fire("finished",this),this}time(t){return null==t?this._time:(this.step(t-this._time),this)}timeline(t){return void 0===t?this._timeline:(this._timeline=t,this)}unschedule(){const t=this.timeline();return t&&t.unschedule(this),this}_initialise(t){if(t||this._isDeclarative)for(let i=0,s=this._queue.length;i<s;++i){const s=this._queue[i],e=this._isDeclarative||!s.initialised&&t;t=!s.finished,e&&t&&(s.initialiser.call(this),s.initialised=!0)}}_rememberMorpher(t,i){if(this._history[t]={morpher:i,caller:this._queue[this._queue.length-1]},this._isDeclarative){const t=this.timeline();t&&t.play()}}_run(t){let i=!0;for(let s=0,e=this._queue.length;s<e;++s){const e=this._queue[s],n=e.runner.call(this,t);e.finished=e.finished||!0===n,i=i&&e.finished}return i}_tryRetarget(t,i,s){if(this._history[t]){if(!this._history[t].caller.initialised){const i=this._queue.indexOf(this._history[t].caller);return this._queue.splice(i,1),!1}this._history[t].caller.retarget?this._history[t].caller.retarget.call(this,i,s):this._history[t].morpher.to(i),this._history[t].caller.finished=!1;const e=this.timeline();return e&&e.play(),!0}return!1}};rh.id=0;var oh=class{constructor(t=new gr,i=-1,s=!0){this.transforms=t,this.id=i,this.done=s}clearTransformsFromQueue(){}};Xn([rh,oh],{mergeWith(t){return new oh(t.transforms.lmultiply(this.transforms),t.id)}});const hh=(t,i)=>t.lmultiplyO(i),ah=t=>t.transforms;function lh(){const t=this._transformationRunners.runners.map(ah).reduce(hh,new gr);this.transform(t),this._transformationRunners.merge(),1===this._transformationRunners.length()&&(this._frameId=null)}var ch=class{constructor(){this.runners=[],this.ids=[]}add(t){var i;if((0,$n.default)(i=this.runners).call(i,t))return;const s=t.id+1;return this.runners.push(t),this.ids.push(s),this}clearBefore(t){const i=this.ids.indexOf(t+1)||1;return this.ids.splice(0,i,0),this.runners.splice(0,i,new oh).forEach((t=>t.clearTransformsFromQueue())),this}edit(t,i){const s=this.ids.indexOf(t+1);return this.ids.splice(s,1,t+1),this.runners.splice(s,1,i),this}getByID(t){return this.runners[this.ids.indexOf(t+1)]}length(){return this.ids.length}merge(){let t=null;for(let e=0;e<this.runners.length;++e){var i,s;const n=this.runners[e];if(!(t&&n.done&&t.done)||n._timeline&&(0,$n.default)(i=n._timeline._runnerIds).call(i,n.id)||t._timeline&&(0,$n.default)(s=t._timeline._runnerIds).call(s,t.id))t=n;else{this.remove(n.id);const i=n.mergeWith(t);this.edit(t.id,i),t=i,--e}}return this}remove(t){const i=this.ids.indexOf(t+1);return this.ids.splice(i,1),this.runners.splice(i,1),this}};re({Element:{animate(t,i,s){const e=rh.sanitise(t,i,s),n=this.timeline();return new rh(e.duration).loop(e).element(this).timeline(n.play()).schedule(e.delay,e.when)},delay(t,i){return this.animate(0,t,i)},_clearTransformRunnersBefore(t){this._transformationRunners.clearBefore(t.id)},_currentTransform(t){return this._transformationRunners.runners.filter((i=>i.id<=t.id)).map(ah).reduce(hh,new gr)},_addRunner(t){this._transformationRunners.add(t),ih.cancelImmediate(this._frameId),this._frameId=ih.immediate(lh.bind(this))},_prepareRunner(){null==this._frameId&&(this._transformationRunners=(new ch).add(new oh(new gr(this))))}}}),Xn(rh,{attr(t,i){return this.styleAttr("attr",t,i)},css(t,i){return this.styleAttr("css",t,i)},styleAttr(t,i,s){if("string"==typeof i)return this.styleAttr(t,{[i]:s});const e=i,n=this._history[t];if(n&&!n.caller.initialised&&n.caller.retarget)return n.caller.retarget.call(this,e),this;if(this._tryRetarget(t,e))return this;let r=new zo(this._stepper).to(e),o=Object.keys(e);return this.queue((function(){r=r.from(this.element()[t](o))}),(function(i){return this.element()[t](r.at(i).valueOf()),r.done()}),(function(i){const s=(e=Object.keys(i),n=o,e.filter((t=>!(0,$n.default)(n).call(n,t))));var e,n;if(s.length&&null!=r.from()){const i=this.element()[t](s),e=new jo(r.from()).valueOf();Object.assign(e,i),r.from(e)}const h=new jo(r.to()).valueOf();Object.assign(h,i),r.to(h),o=Object.keys(h)})),this._rememberMorpher(t,r),this},zoom(t,i){if(this._tryRetarget("zoom",t,i))return this;let s=new zo(this._stepper).to(new zr(t));return this.queue((function(){s=s.from(this.element().zoom())}),(function(t){return this.element().zoom(s.at(t),i),s.done()}),(function(t,e){i=e,s.to(t)})),this._rememberMorpher("zoom",s),this},transform(t,i,s){if(i=t.relative||i,this._isDeclarative&&!i&&this._tryRetarget("transform",t))return this;const e=gr.isMatrixLike(t);s=null!=t.affine?t.affine:null!=s?s:!e;const n=new zo(this._stepper).type(s?Fo:gr);let r,o,h,a,l;return this.queue((function(){o=o||this.element(),r=r||Rn(t,o),l=new gr(i?void 0:o),o._addRunner(this),i||o._clearTransformRunnersBefore(this)}),(function(c){i||this.clearTransform();const{x:u,y:d}=new vr(r).transform(o._currentTransform(this)),f={...t,origin:[u,d]};!0===f.relative&&delete f.relative;let v=new gr(f),p=this._isDeclarative&&h?h:l;if(s){v=v.decompose(u,d),p=p.decompose(u,d);const t=v.rotate,i=p.rotate,s=[t-360,t,t+360],e=s.map((t=>Math.abs(t-i))),n=Math.min(...e),r=e.indexOf(n);v.rotate=s[r]}i&&(e||(v.rotate=t.rotate||0),this._isDeclarative&&a&&(p.rotate=a)),n.from(p),n.to(v);const g=n.at(c);return a=g.rotate,h=new gr(g),this.addTransform(h),o._addRunner(this),n.done()}),(function(i){(i.origin||"center").toString()!==(t.origin||"center").toString()&&(r=Rn(i,o)),t={...i,origin:r}}),!0),this._isDeclarative&&this._rememberMorpher("transform",n),this},x(t){return this._queueNumber("x",t)},y(t){return this._queueNumber("y",t)},ax(t){return this._queueNumber("ax",t)},ay(t){return this._queueNumber("ay",t)},dx(t=0){return this._queueNumberDelta("x",t)},dy(t=0){return this._queueNumberDelta("y",t)},dmove(t,i){return this.dx(t).dy(i)},_queueNumberDelta(t,i){if(i=new zr(i),this._tryRetarget(t,i))return this;const s=new zo(this._stepper).to(i);let e=null;return this.queue((function(){e=this.element()[t](),s.from(e),s.to(e+i)}),(function(i){return this.element()[t](s.at(i)),s.done()}),(function(t){s.to(e+new zr(t))})),this._rememberMorpher(t,s),this},_queueObject(t,i){if(this._tryRetarget(t,i))return this;const s=new zo(this._stepper).to(i);return this.queue((function(){s.from(this.element()[t]())}),(function(i){return this.element()[t](s.at(i)),s.done()})),this._rememberMorpher(t,s),this},_queueNumber(t,i){return this._queueObject(t,new zr(i))},cx(t){return this._queueNumber("cx",t)},cy(t){return this._queueNumber("cy",t)},move(t,i){return this.x(t).y(i)},amove(t,i){return this.ax(t).ay(i)},center(t,i){return this.cx(t).cy(i)},size(t,i){const s=An(this._element,t,i);return this.width(s.width).height(s.height)},width(t){return this._queueNumber("width",t)},height(t){return this._queueNumber("height",t)},plot(t,i,s,e){if(4===arguments.length)return this.plot([t,i,s,e]);if(this._tryRetarget("plot",t))return this;const n=new zo(this._stepper).type(this._element.MorphArray).to(t);return this.queue((function(){n.from(this._element.array())}),(function(t){return this._element.plot(n.at(t)),n.done()})),this._rememberMorpher("plot",n),this},leading(t){return this._queueNumber("leading",t)},viewbox(t,i,s,e){return this._queueObject("viewbox",new yr(t,i,s,e))},update(t){return"object"!=typeof t?this.update({offset:arguments[0],color:arguments[1],opacity:arguments[2]}):(null!=t.opacity&&this.attr("stop-opacity",t.opacity),null!=t.color&&this.attr("stop-color",t.color),null!=t.offset&&this.attr("offset",t.offset),this)}}),Xn(rh,{rx:Xr,ry:Jr,from:ro,to:oo}),Yn(rh,"Runner");var uh=class extends Yr{constructor(t,i=t){super(Gn("svg",t),i),this.namespace()}defs(){return this.isRoot()?jn(this.node.querySelector("defs"))||this.put(new Br):this.root().defs()}isRoot(){return!this.node.parentNode||!(this.node.parentNode instanceof Pn.window.SVGElement)&&"#document-fragment"!==this.node.parentNode.nodeName}namespace(){return this.isRoot()?this.attr({xmlns:En,version:"1.1"}).attr("xmlns:xlink",Cn,Tn):this.root().namespace()}removeNamespace(){return this.attr({xmlns:null,version:null}).attr("xmlns:xlink",null,Tn).attr("xmlns:svgjs",null,Tn)}root(){return this.isRoot()?this:super.root()}};re({Container:{nested:Jn((function(){return this.put(new uh)}))}}),Yn(uh,"Svg",!0);var dh=class extends Yr{constructor(t,i=t){super(Gn("symbol",t),i)}};re({Container:{symbol:Jn((function(){return this.put(new dh)}))}}),Yn(dh,"Symbol");var fh=ie({amove:()=>Mh,ax:()=>Sh,ay:()=>$h,build:()=>_h,center:()=>xh,cx:()=>yh,cy:()=>wh,length:()=>ph,move:()=>bh,plain:()=>vh,x:()=>gh,y:()=>mh});function vh(t){return!1===this._build&&this.clear(),this.node.appendChild(Pn.document.createTextNode(t)),this}function ph(){return this.node.getComputedTextLength()}function gh(t,i=this.bbox()){return null==t?i.x:this.attr("x",this.attr("x")+t-i.x)}function mh(t,i=this.bbox()){return null==t?i.y:this.attr("y",this.attr("y")+t-i.y)}function bh(t,i,s=this.bbox()){return this.x(t,s).y(i,s)}function yh(t,i=this.bbox()){return null==t?i.cx:this.attr("x",this.attr("x")+t-i.cx)}function wh(t,i=this.bbox()){return null==t?i.cy:this.attr("y",this.attr("y")+t-i.cy)}function xh(t,i,s=this.bbox()){return this.cx(t,s).cy(i,s)}function Sh(t){return this.attr("x",t)}function $h(t){return this.attr("y",t)}function Mh(t,i){return this.ax(t).ay(i)}function _h(t){return this._build=!!t,this}var Oh=class extends Hr{constructor(t,i=t){super(Gn("text",t),i),this.dom.leading=this.dom.leading??new zr(1.3),this._rebuild=!0,this._build=!1}leading(t){return null==t?this.dom.leading:(this.dom.leading=new zr(t),this.rebuild())}rebuild(t){if("boolean"==typeof t&&(this._rebuild=t),this._rebuild){const t=this;let i=0;const s=this.dom.leading;this.each((function(e){if(Ln(this.node))return;const n=Pn.window.getComputedStyle(this.node).getPropertyValue("font-size"),r=s*new zr(n);this.dom.newLined&&(this.attr("x",t.attr("x")),"\n"===this.text()?i+=r:(this.attr("dy",e?r+i:0),i=0))})),this.fire("rebuild")}return this}setData(t){return this.dom=t,this.dom.leading=new zr(t.leading||1.3),this}writeDataToDom(){return super.writeDataToDom({leading:1.3})}text(t){if(void 0===t){const i=this.node.childNodes;let s=0;t="";for(let e=0,n=i.length;e<n;++e)"textPath"===i[e].nodeName||Ln(i[e])?0===e&&(s=e+1):(e!==s&&3!==i[e].nodeType&&!0===jn(i[e]).dom.newLined&&(t+="\n"),t+=i[e].textContent);return t}if(this.clear().build(!0),"function"==typeof t)t.call(this,this);else for(let i=0,s=(t=(t+"").split("\n")).length;i<s;i++)this.newLine(t[i]);return this.build(!1).rebuild()}};Xn(Oh,fh),re({Container:{text:Jn((function(t=""){return this.put(new Oh).text(t)})),plain:Jn((function(t=""){return this.put(new Oh).plain(t)}))}}),Yn(Oh,"Text");var kh=class extends Hr{constructor(t,i=t){super(Gn("tspan",t),i),this._build=!1}dx(t){return this.attr("dx",t)}dy(t){return this.attr("dy",t)}newLine(){this.dom.newLined=!0;const t=this.parent();if(!(t instanceof Oh))return this;const i=t.index(this),s=Pn.window.getComputedStyle(this.node).getPropertyValue("font-size"),e=t.dom.leading*new zr(s);return this.dy(i?e:0).attr("x",t.x())}text(t){return null==t?this.node.textContent+(this.dom.newLined?"\n":""):("function"==typeof t?(this.clear().build(!0),t.call(this,this),this.build(!1)):this.plain(t),this)}};Xn(kh,fh),re({Tspan:{tspan:Jn((function(t=""){const i=new kh;return this._build||this.clear(),this.put(i).text(t)}))},Text:{newLine:function(t=""){return this.tspan(t).newLine()}}}),Yn(kh,"Tspan");var Ah=class extends Hr{constructor(t,i=t){super(Gn("circle",t),i)}radius(t){return this.attr("r",t)}rx(t){return this.attr("r",t)}ry(t){return this.rx(t)}size(t){return this.radius(new zr(t).divide(2))}};Xn(Ah,{x:qr,y:Kr,cx:Qr,cy:Zr,width:to,height:io}),re({Container:{circle:Jn((function(t=0){return this.put(new Ah).size(t).move(0,0)}))}}),Yn(Ah,"Circle");var Rh=class extends Yr{constructor(t,i=t){super(Gn("clipPath",t),i)}remove(){return this.targets().forEach((function(t){t.unclip()})),super.remove()}targets(){return _r(this.node,"clip-path")}};re({Container:{clip:Jn((function(){return this.defs().put(new Rh)}))},Element:{clipper(){return this.reference("clip-path")},clipWith(t){const i=t instanceof Rh?t:this.parent().clip().add(t);return this.attr("clip-path","url(#"+i.id()+")")},unclip(){return this.attr("clip-path",null)}}}),Yn(Rh,"ClipPath");var Nh=class extends jr{constructor(t,i=t){super(Gn("foreignObject",t),i)}};re({Container:{foreignObject:Jn((function(t,i){return this.put(new Nh).size(t,i)}))}}),Yn(Nh,"ForeignObject");var Lh=ie({dmove:()=>Eh,dx:()=>Th,dy:()=>Ch,height:()=>Ph,move:()=>Wh,size:()=>Dh,width:()=>zh,x:()=>Uh,y:()=>Fh});function Eh(t,i){return this.children().forEach((s=>{let e;try{e=s.node instanceof Pn.window.SVGSVGElement?new yr(s.attr(["x","y","width","height"])):s.bbox()}catch(t){return}const n=new gr(s),r=n.translate(t,i).transform(n.inverse()),o=new vr(e.x,e.y).transform(r);s.dmove(o.x-e.x,o.y-e.y)})),this}function Th(t){return this.dmove(t,0)}function Ch(t){return this.dmove(0,t)}function Ph(t,i=this.bbox()){return null==t?i.height:this.size(i.width,t,i)}function Wh(t=0,i=0,s=this.bbox()){return this.dmove(t-s.x,i-s.y)}function Dh(t,i,s=this.bbox()){const e=An(this,t,i,s),n=e.width/s.width,r=e.height/s.height;return this.children().forEach((t=>{const i=new vr(s).transform(new gr(t).inverse());t.scale(n,r,i.x,i.y)})),this}function zh(t,i=this.bbox()){return null==t?i.width:this.size(t,i.height,i)}function Uh(t,i=this.bbox()){return null==t?i.x:this.move(t,i.y,i)}function Fh(t,i=this.bbox()){return null==t?i.y:this.move(i.x,t,i)}var Gh=class extends Yr{constructor(t,i=t){super(Gn("g",t),i)}};Xn(Gh,Lh),re({Container:{group:Jn((function(){return this.put(new Gh)}))}}),Yn(Gh,"G");var jh=class extends Yr{constructor(t,i=t){super(Gn("a",t),i)}target(t){return this.attr("target",t)}to(t){return this.attr("href",t,Cn)}};Xn(jh,Lh),re({Container:{link:Jn((function(t){return this.put(new jh).to(t)}))},Element:{unlink(){const t=this.linker();if(!t)return this;const i=t.parent();if(!i)return this.remove();const s=i.index(t);return i.add(this,s),t.remove(),this},linkTo(t){let i=this.linker();return i||(i=new jh,this.wrap(i)),"function"==typeof t?t.call(i,i):i.to(t),this},linker(){const t=this.parent();return t&&"a"===t.node.nodeName.toLowerCase()?t:null}}}),Yn(jh,"A");var Ih=class extends Yr{constructor(t,i=t){super(Gn("mask",t),i)}remove(){return this.targets().forEach((function(t){t.unmask()})),super.remove()}targets(){return _r(this.node,"mask")}};re({Container:{mask:Jn((function(){return this.defs().put(new Ih)}))},Element:{masker(){return this.reference("mask")},maskWith(t){const i=t instanceof Ih?t:this.parent().mask().add(t);return this.attr("mask","url(#"+i.id()+")")},unmask(){return this.attr("mask",null)}}}),Yn(Ih,"Mask");var Yh=class extends jr{constructor(t,i=t){super(Gn("stop",t),i)}update(t){return("number"==typeof t||t instanceof zr)&&(t={offset:arguments[0],color:arguments[1],opacity:arguments[2]}),null!=t.opacity&&this.attr("stop-opacity",t.opacity),null!=t.color&&this.attr("stop-color",t.color),null!=t.offset&&this.attr("offset",new zr(t.offset)),this}};re({Gradient:{stop:function(t,i,s){return this.put(new Yh).update(t,i,s)}}}),Yn(Yh,"Stop");var Bh=class extends jr{constructor(t,i=t){super(Gn("style",t),i)}addText(t=""){return this.node.textContent+=t,this}font(t,i,s={}){return this.rule("@font-face",{fontFamily:t,src:i,...s})}rule(t,i){return this.addText(function(t,i){if(!t)return"";if(!i)return t;let s=t+"{";for(const t in i)s+=On(t)+":"+i[t]+";";return s+="}",s}(t,i))}};re("Dom",{style(t,i){return this.put(new Bh).rule(t,i)},fontface(t,i,s){return this.put(new Bh).font(t,i,s)}}),Yn(Bh,"Style");var Hh=class extends Oh{constructor(t,i=t){super(Gn("textPath",t),i)}array(){const t=this.track();return t?t.array():null}plot(t){const i=this.track();let s=null;return i&&(s=i.plot(t)),null==t?s:this}track(){return this.reference("href")}};re({Container:{textPath:Jn((function(t,i){return t instanceof Oh||(t=this.text(t)),t.path(i)}))},Text:{path:Jn((function(t,i=!0){const s=new Hh;let e;if(t instanceof Yo||(t=this.defs().path(t)),s.attr("href","#"+t,Cn),i)for(;e=this.node.firstChild;)s.node.appendChild(e);return this.put(s)})),textPath(){return this.findOne("textPath")}},Path:{text:Jn((function(t){return t instanceof Oh||(t=(new Oh).addTo(this.parent()).text(t)),t.path(this)})),targets(){return _r(this.node,"href","textPath")}}}),Hh.prototype.MorphArray=Wo,Yn(Hh,"TextPath");var Vh=class extends Hr{constructor(t,i=t){super(Gn("use",t),i)}use(t,i){return this.attr("href",(i||"")+"#"+t,Cn)}};function Xh(t,i,s){const e={[s.pointLevel]:t.name};return null!==s.seriesLevel&&""!==t.seriesKey&&(e[s.seriesLevel]=t.seriesKey),null!==s.facet&&""!==i&&(e["rowgroup"===s.facet.level?"rowGroup":"category"]=i),e}re({Container:{use:Jn((function(t,i){return this.put(new Vh).use(t,i)}))}}),Yn(Vh,"Use"),Xn([uh,dh,lo,ao,yo],oe("viewbox")),Xn([bo,Qo,Ko,Yo],oe("marker")),Xn(Oh,oe("Text")),Xn(Yo,oe("Path")),Xn(Br,oe("Defs")),Xn([Oh,kh],oe("Tspan")),Xn([Zo,so,ho,rh],oe("radius")),Xn(Cr,oe("EventTarget")),Xn(Gr,oe("Dom")),Xn(jr,oe("Element")),Xn(Hr,oe("Shape")),Xn([Yr,eo],oe("Container")),Xn(ho,oe("Gradient")),Xn(rh,oe("Runner")),xr.extend([...new Set(ne)]),function(t=[]){Io.push(...[].concat(t))}([zr,fr,yr,gr,Dr,co,Wo,vr]),Xn(Io,{to(t){return(new zo).type(this.constructor).from(this.toArray()).to(t)},fromArray(t){return this.init(t),this},toConsumable(){return this.toArray()},morph(t,i,s,e,n){return this.fromArray(t.map((function(t,r){return e.step(t,i[r],s,n[r],n)})))}});var Jh,qh={},Kh=function(){if(Jh)return qh;Jh=1;var t={};return Object.defineProperty(qh,"__esModule",{value:!0}),qh.default=function(i,s){void 0===s&&(s={});var e=JSON.stringify({text:i,options:s});if(t[e])return t[e];s.font=s.font||"Times",s.fontSize=s.fontSize||"16px",s.fontWeight=s.fontWeight||"normal",s.width=s.width||"auto";var n=function(t,i){var s=document.createElement("div"),e=document.createTextNode(t);return s.appendChild(e),s.style.fontFamily=i.font,s.style.fontSize=i.fontSize,s.style.fontWeight=i.fontWeight,s.style.position="absolute",s.style.visibility="hidden",s.style.left="-999px",s.style.top="-999px",s.style.width=i.width,s.style.height="auto",document.body.appendChild(s),s}(i,s),r={width:n.offsetWidth,height:n.offsetHeight};return function(t){t.parentNode.removeChild(t)}(n),t[e]=r,r},qh}(),Qh=b(Kh);const Zh=["pl","fc","pp","ac"];function ta(t){return t.replace(/\d+$/,"")}function ia(t){const i=function(t){const i=/^#([0-9a-f]+)$/i.exec(t.trim());if(i){const t=i[1];return 3===t.length||4===t.length?[0,1,2].map((i=>parseInt(t[i]+t[i],16))):6===t.length||8===t.length?[0,2,4].map((i=>parseInt(t.slice(i,i+2),16))):null}const s=/^rgba?\(\s*([\d.]+%?)[\s,]+([\d.]+%?)[\s,]+([\d.]+%?)/i.exec(t.trim());return s?s.slice(1,4).map((t=>t.endsWith("%")?2.55*parseFloat(t):parseFloat(t))):null}(t);if(null===i)return"#000000";const[s,e,n]=i;return.299*s+.587*e+.114*n>128?"#000000":"#ffffff"}class sa{constructor(t,i,s,e){this.count=t,this.drawingRect=s,this.panelGapPx=e,this.columns=Math.max(1,Math.min(null!=i?i:t,t)),this.rows=Math.max(1,Math.ceil(t/this.columns))}panelRect(t){const i=t%this.columns,s=Math.floor(t/this.columns),e=(this.drawingRect.width-(this.columns-1)*this.panelGapPx)/this.columns,n=(this.drawingRect.height-(this.rows-1)*this.panelGapPx)/this.rows;return{x:this.drawingRect.x+i*(e+this.panelGapPx),y:this.drawingRect.y+s*(n+this.panelGapPx),width:e,height:n}}isOuterLeft(t){return t%this.columns==0}isOuterBottom(t){return t+this.columns>=this.count}}var ea,na;!function(t){t.OPERATION="operation",t.ROWGROUP="rowGroup",t.ROWGROUPINDEX="rowGroupIndex",t.CURRENTROW="currentRow",t.CATEGORY="category",t.CATEGORYINDEX="categoryIndex",t.SUBCATEGORY="subCategory",t.SUBCATEGORYINDEX="subCategoryIndex",t.COLUMNGROUP="columnGroup",t.COLUMNGROUPINDEX="columnIndex",t.COLUMNSUBGROUP="columnSubGroup",t.COLUMNSUBGROUPINDEX="columnSubGroupIndex",t.AC1="ac1",t.AC2="ac2",t.AC3="ac3",t.AC4="ac4",t.PP1="pp1",t.PP2="pp2",t.PP3="pp3",t.PP4="pp4",t.FC1="fc1",t.FC2="fc2",t.FC3="fc3",t.FC4="fc4",t.PL1="pl1",t.PL2="pl2",t.PL3="pl3",t.PL4="pl4",t.TOTALROWCOUNT="totalRowCnt",t.ROWNR="rowNr",t.TYPE="type"}(ea||(ea={}));class ra{static number(t,i="decimal",s=1,e=0,n=1,r="de"){const o=`${r}|${i}|${s}|${e}`;let h=this.formats.get(o);if(!h){const t={style:i,useGrouping:!0,maximumFractionDigits:s,minimumFractionDigits:e};try{h=new Intl.NumberFormat([r,"de-DE"],t)}catch(i){h=new Intl.NumberFormat("de-DE",t)}this.formats.set(o,h)}const a=h.format(t/n);return(a===h.format(-0)?h.format(0):a).replace(/\s+(%)/g,"$1")}static translateScenarioLabel(t,i){if(null==t)return"";const s=new ks(t);if(!s.isValid)return`${i.get(t)||t}`;let e,n;return ea.AC1===s.base?(e=i.get("dr"===s.type?"ibcssymbol_delta_ac_relative":"ibcssymbol_delta_ac"),n=i.get(s.delta)||s.delta):(e=i.get("dr"===s.type?"ibcssymbol_delta_generic_relative":"ibcssymbol_delta_generic"),n=`${i.get(s.base)||s.base} - ${i.get(s.delta)||s.delta}`),void 0===e&&(e="{%}"),`${e.replace("{%}",n)}`}static getMaxWidthOfArrayItems(t,i,s){return Qh(t.map((t=>ra.translateScenarioLabel(t,i))).reduce(((t,i)=>t.length<i.length?i:t),""),{font:s.fontStyles.font,fontSize:s.fontStyles.size+"px"}).width}}ra.formats=new Map;class oa{constructor(t,i,s,e){this.domainMin=t,this.domainMax=i,this.rangeMin=s,this.rangeMax=e}scale(t){const i=this.domainMax-this.domainMin;return 0===i?(this.rangeMin+this.rangeMax)/2:this.rangeMin+(t-this.domainMin)/i*(this.rangeMax-this.rangeMin)}static domain(t,i,s,e=.04){let n=i-t;if(0===n){const s=0===t?1:.1*Math.abs(t);n=(i+=s)-(t-=s)}return[void 0!==(null==s?void 0:s.min)?s.min:t-n*e,void 0!==(null==s?void 0:s.max)?s.max:i+n*e]}static niceStep(t,i){if(t<=0||i<=0)return 1;const s=t/i,e=Math.pow(10,Math.floor(Math.log10(s))),n=s/e;let r;return r=n<=1?1:n<=2?2:n<=2.5?2.5:n<=5?5:10,r*e}ticks(t){const i=this.domainMax-this.domainMin;if(i<=0)return[this.domainMin];const s=oa.niceStep(i,t),e=Math.ceil(this.domainMin/s)*s;if(e+s===e||s<Math.pow(10,-15))return[this.domainMin];const n=oa.stepDecimals(s),r=Math.floor((this.domainMax+1e-9*s-e)/s)+1,o=[];for(let t=0;t<r;t++){const i=Number((e+t*s).toFixed(n)),r=0===i?0:i;0!==o.length&&r===o[o.length-1]||o.push(r)}return o}static stepDecimals(t){if(!Number.isFinite(t)||t<=0)return 0;for(let i=0;i<15;i++){const s=t*Math.pow(10,i),e=Math.round(s);if(e>=1&&Math.abs(s-e)<1e-9*e)return i}return 15}static tickDecimals(t){return 0===t.length?0:oa.stepDecimals(1===t.length?Math.abs(t[0]):(t[t.length-1]-t[0])/(t.length-1))}}function ha(t,i,s,e=!1){return ra.number(t,e?"percent":"decimal",i,i,1,s)}function aa(t,i){return oa.tickDecimals(i?t.map((t=>100*t)):t)}class la{constructor(t="",i=1){this.prefix=t,this.value=i}}!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"}(na||(na={}));let ca=class{constructor(t,i,s,e,n,r,o,h){this.ID_SCENARIOLABEL="Label",this.CSS_CATEGORIES="categories",this.isRelativeLabel=!1,this.segmentFillColor=null,this.pointPart="label",this.x=i,this.y=s,this.value=n,this.group=t.group().id(this.createElementID(t.toString(),e)),this.styles=r,this.isVarianceLabel=!1,this.verticalHookLocation=o||na.Top,this.horizontalHookLocation=h||na.Left}setToVarianceLabel(){return this.isVarianceLabel=!0,this}setToRelativeVarianceLabel(){return this.isVarianceLabel=!0,this.isRelativeLabel=!0,this}setSegmentFill(t){return this.segmentFillColor=t,this}setPoint(t,i="label"){return this.pointKey=t,this.pointPart=i,this}updateGroup(t){return this.group=t,this}draw(t=!0,i={percent:2,decimal:1},s=new la){if(this.isEmpty())return this;const e=this.group;let n,r="";if(!1===Number.isNaN(Number(this.value))){let t="percent",e=i.percent,o=i.percent,h=1;!1===this.isRelativeLabel&&(e=i.decimal,o=i.decimal,h=s.value,t="decimal"),n=ra.number(Number(this.value),t,e,o,h,this.styles.locale),this.isVarianceLabel&&Number(this.value)>=0&&(r="+")}else n=""+this.value;const o=this.drawLabel(e,r+n);return!1===t?(o.addClass("hide"),e.addClass("hide")):this.pointKey&&e.attr(ji(this.pointKey,this.pointPart)),this}isEmpty(){return null==this.value||""===this.value}setPos(t,i){return this.x=t,this.y=i,this}forceStringTypeDraw(){const t=this.group;return this.drawLabel(t,""+this.value),this.pointKey&&t.attr(ji(this.pointKey,this.pointPart)),this}drawLabel(t,i){const s=this.styles.fontStyles.background||"#ffffff";let e="start";const n=t.text(i);n.move(this.x,this.y);const r=n.bbox(),o=r.w,h=r.h;let a=0,l=0;const c=n.x();let u=n.y();return this.horizontalHookLocation===na.Left?(e="left",a=n.x()):this.horizontalHookLocation===na.Center?(e="middle",a=n.x()-(o+2)/2):this.horizontalHookLocation===na.Right&&(e="end",a=n.x()-o),this.verticalHookLocation===na.Center?(u=n.y()-1.2*h/2,l=u+.2*h):this.verticalHookLocation===na.Top?(u-=h/4,l=u+.2*h):this.verticalHookLocation===na.Bottom&&(u-=h,l=u+.2*h),n.move(c,u),n.font({anchor:e}),null!=this.segmentFillColor?n.fill(ia(this.segmentFillColor)):t.rect(o+2,.8*h).stroke(s).fill(s).opacity(.9).move(a-1,l).insertBefore(n),n}createElementID(t,i){return t+"_"+i+"_"+this.ID_SCENARIOLABEL}};const ua={ac:1,pp:2,fc:3,pl:4};var da;!function(t){t[t.Above=0]="Above",t[t.Below=1]="Below",t[t.Left=2]="Left",t[t.Right=3]="Right"}(da||(da={}));class fa{constructor(){this.labels=[],this.scenarioLabels=[]}clear(){this.labels=[],this.scenarioLabels=[]}register(t){this.labels.push(t)}hasCollision(t){return this.labels.some((i=>this.intersects(t,i)))}getOptimalPlacement(t,i,s,e,n,r,o,h){const a=ua[o]||99,l=r/2;for(const r of h){const o=this.calculatePlacementForDirection(t,i,s,e,n,l,8,r);if(!this.hasCollision(o.bounds))return o}for(const r of h){const o=this.calculatePlacementForDirection(t,i,s,e,n,l,8,r);if(!this.collidesWithHigherPriority(o.bounds,a))return o}return null}calculatePlacementForDirection(t,i,s,e,n,r,o,h){let a,l,c,u,d,f;switch(h){case da.Above:a=t,l=i-r-o,c=na.Bottom,u=na.Center,d=t-s/2,f=i-r-o-e;break;case da.Below:a=t,l=i+r+o,c=na.Top,u=na.Center,d=t-s/2,f=i+r+o-e/4;break;case da.Left:a=t-r-o,l=i,c=na.Center,u=na.Right,d=t-r-o-s,f=i-.6*e;break;case da.Right:a=t+r+o,l=i,c=na.Center,u=na.Left,d=t+r+o,f=i-.6*e}return{labelX:a,labelY:l,verticalHook:c,horizontalHook:u,bounds:{x:d,y:f,width:s,height:e,pointIndex:n,preferredHook:c}}}collidesWithHigherPriority(t,i){return this.labels.some((s=>!!s.scenarioType&&((ua[s.scenarioType]||99)<i&&this.intersects(t,s))))}shouldHideScenarioLabel(t,i,s,e=20){const n=ua[s]||99;return!(n<=1)&&this.scenarioLabels.some((s=>{if((ua[s.scenarioType]||99)>=n)return!1;const r=Math.abs(i-s.y),o=Math.abs(t-s.x);return r<e&&o<e}))}registerScenarioLabel(t,i,s){this.scenarioLabels.push({x:t,y:i,scenarioType:s})}intersects(t,i){return!(t.x+t.width<i.x||i.x+i.width<t.x||t.y+t.height<i.y||i.y+i.height<t.y)}getLabelCount(){return this.labels.length}}const va=["n","ne","e","se","s","sw","w","nw"],pa=Math.SQRT1_2;class ga{constructor(t,i,s=new fa){this.frame=t,this.gapPx=i,this.manager=s}registerMark(t,i,s){this.manager.register(this.bounds(t-s,i-s,2*s,2*s))}selectCandidates(t,i,s,e){if("none"===i)return{selected:[],unknownNames:[]};if("all"===i)return{selected:[...t],unknownNames:[]};if("auto"===i)return{selected:t.slice(0,s),unknownNames:[]};const n=new Set(i),r=t.filter((t=>n.has(e(t)))),o=new Set(r.map((t=>e(t))));return{selected:r,unknownNames:i.filter((t=>!o.has(t)))}}place(t){const i=[];for(const s of t)for(const t of va){const e=this.anchorBox(s,t);if(!this.insideFrame(e.x,e.y,s.width,s.height))continue;const n=this.bounds(e.x,e.y,s.width,s.height);if(!this.manager.hasCollision(n)){this.manager.register(n),i.push({candidate:s,x:e.x,y:e.y,anchor:t});break}}return i}anchorBox(t,i){const s=t.r+this.gapPx,e=t.r*pa+.5*this.gapPx;switch(i){case"n":return{x:t.cx-t.width/2,y:t.cy-s-t.height};case"ne":return{x:t.cx+e,y:t.cy-e-t.height};case"e":return{x:t.cx+s,y:t.cy-t.height/2};case"se":return{x:t.cx+e,y:t.cy+e};case"s":return{x:t.cx-t.width/2,y:t.cy+s};case"sw":return{x:t.cx-e-t.width,y:t.cy+e};case"w":return{x:t.cx-s-t.width,y:t.cy-t.height/2};case"nw":return{x:t.cx-e-t.width,y:t.cy-e-t.height}}}insideFrame(t,i,s,e){return t>=this.frame.x&&i>=this.frame.y&&t+s<=this.frame.x+this.frame.width&&i+e<=this.frame.y+this.frame.height}bounds(t,i,s,e){return{x:t,y:i,width:s,height:e,pointIndex:0,preferredHook:na.Center}}}class ma{constructor(t,i,s,e,n){this.mode=t,this.vMax=i,this.rMaxPx=s,this.rMinPx=e,this.areaPerUnitPx2=n}static local(t,i,s){return new ma("local",t,i,s,0)}static grouped(t){return new ma("grouped",0,0,0,t)}radius(t){return"grouped"===this.mode?t<=0?0:Math.sqrt(this.areaPerUnitPx2*t/Math.PI):this.vMax<=0||t<=0?this.rMinPx:Math.max(this.rMinPx,this.rMaxPx*Math.sqrt(t/this.vMax))}}class ba{constructor(t,i,s,e){this.xScale=t,this.yScale=i,this.rect=s,this.styles=e}get em(){return this.styles.fontStyles.size}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}drawBands(t,i,s){var e,n,r,o;const h=this.styles.axisStyles.pl.fill;if(void 0!==i&&(void 0!==i.from||void 0!==i.to)){const s=this.xScale.scale(null!==(e=i.from)&&void 0!==e?e:this.xScale.domainMin),r=this.xScale.scale(null!==(n=i.to)&&void 0!==n?n:this.xScale.domainMax);t.rect(Math.abs(r-s),this.rect.height).move(Math.min(s,r),this.rect.y).fill(h)}if(void 0!==s&&(void 0!==s.from||void 0!==s.to)){const i=this.yScale.scale(null!==(r=s.from)&&void 0!==r?r:this.yScale.domainMin),e=this.yScale.scale(null!==(o=s.to)&&void 0!==o?o:this.yScale.domainMax);t.rect(this.rect.width,Math.abs(i-e)).move(this.rect.x,Math.min(i,e)).fill(h)}}drawGrid(t,i,s){const e={color:this.styles.axisStyles.pp.stroke,width:Vt(this.styles.scaleFactors.gridLineWidth,this.em)};for(const s of i){const i=this.yScale.scale(s);t.line(this.rect.x,i,this.rect.x+this.rect.width,i).stroke(e)}if(void 0!==s)for(const i of s){const s=this.xScale.scale(i);t.line(s,this.rect.y,s,this.rect.y+this.rect.height).stroke(e)}}drawRefLines(t,i,s){const e={color:this.styles.axisStyles.fc.stroke,width:Vt(this.styles.scaleFactors.refLineWidth,this.em)};if(void 0!==i){const s=this.xScale.scale(i);t.line(s,this.rect.y,s,this.rect.y+this.rect.height).stroke(e)}if(void 0!==s){const i=this.yScale.scale(s);t.line(this.rect.x,i,this.rect.x+this.rect.width,i).stroke(e)}}drawFrame(t){t.rect(this.rect.width,this.rect.height).move(this.rect.x,this.rect.y).fill("none").stroke({color:this.styles.axisStyles.ac.stroke,width:Vt(this.styles.scaleFactors.gridLineWidth,this.em)}).attr(Wi,"frame")}drawTickLabels(t,i){const s=this.styles.scaleFactors.axisTickLength*this.em,e={size:this.styles.fontStyles.size,anchor:"start"},n=this.fontFamily(),r=this.styles.fontStyles.color;if(i.showXLabels)for(const o of i.ticksX){const h=this.xScale.scale(o);t.text(ha(o,i.xDecimals,this.styles.locale,i.xPercent)).font(Object.assign(Object.assign({},e),{anchor:"middle"})).fill(r).attr({x:h,y:this.rect.y+this.rect.height+s+.8*this.em,"font-family":n})}if(i.showYLabels)for(const o of i.ticksY){const h=this.yScale.scale(o);t.text(ha(o,i.yDecimals,this.styles.locale,i.yPercent)).font(Object.assign(Object.assign({},e),{anchor:"end"})).fill(r).attr({x:this.rect.x-s,y:h+.35*this.em,"font-family":n})}}drawPanelTitle(t,i){""!==i&&t.text(i).font({size:this.styles.fontStyles.size,weight:"bold",anchor:"start"}).fill(this.styles.fontStyles.color).attr({x:this.rect.x+.5*this.em,y:this.rect.y+1.2*this.em,"font-family":this.fontFamily()})}}class ya{constructor(t){this.styles=t}get em(){return this.styles.fontStyles.size}get rowHeight(){return 1.5*this.em}get swatchSize(){return this.styles.scaleFactors.legendSwatch*this.em}textWidth(t,i=!1){const s=Qh(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:i?"bold":"normal"}).width;return Number.isFinite(s)&&s>0?s:.6*t.length*this.em}rows(t){const i=[];t.sizeCaption.forEach(((t,s)=>{i.push({text:t,bold:0===s,treatment:null})})),null!==t.title&&""!==t.title&&i.push({text:t.title,bold:!0,treatment:null});for(const s of[...t.compareEntries,...t.entries])i.push({text:s.label,bold:!1,treatment:s.treatment,fill:s.fill});return i}measure(t,i){const s=this.rows(t);if(0===s.length)return{width:0,height:0};const e=this.swatchSize+.4*this.em;if("bottom"===i){let t=0;for(const i of s)t+=(null!==i.treatment?e:0)+this.textWidth(i.text,i.bold)+1.5*this.em;return{width:t,height:this.rowHeight}}let n=0;for(const t of s)n=Math.max(n,(null!==t.treatment?e:0)+this.textWidth(t.text,t.bold));return{width:n,height:s.length*this.rowHeight}}draw(t,i,s,e,n){var r;const o=this.rows(i),h=this.swatchSize+.4*this.em;let a=s,l=e;for(const i of o){let s=a;if(null!==i.treatment){const e=t.circle(this.swatchSize).move(a,l+(this.rowHeight-this.swatchSize)/2).fill(null!==(r=i.fill)&&void 0!==r?r:i.treatment.hatch?"#ffffff":i.treatment.fill).stroke({color:"#ffffff"===i.treatment.stroke?i.treatment.fill:i.treatment.stroke,width:i.treatment.strokeWidth});void 0!==i.treatment.dasharray&&e.attr("stroke-dasharray",i.treatment.dasharray),s+=h}t.text(i.text).font({size:this.styles.fontStyles.size,weight:i.bold?"bold":"normal",anchor:"start"}).fill(this.styles.fontStyles.color).attr({x:s,y:l+this.rowHeight/2+.35*this.em,"font-family":this.fontFamily()}),"bottom"===n?a=s+this.textWidth(i.text,i.bold)+1.5*this.em:l+=this.rowHeight}}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}}class wa{constructor(){this.operation="+",this.custom={},this.counts={}}slotValue(t){const i=this[t];return R.isNumber(i)?i:null}slotHasNoData(t){return 0===this.counts[t]}}const xa=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"];class Sa{adapt(t){const i=new wa;if(R.isOperator(t.operation)&&(i.operation=t.operation),R.isString(t.date)){const s=y.fromISO(t.date);i.date=s.isValid?s:void 0}R.isString(t.rowGroup)&&R.isNumber(t.rowGroupIndex)&&(i.rowGroup=t.rowGroup,i.rowGroupIndex=t.rowGroupIndex),R.isString(t.category)&&R.isNumber(t.categoryIndex)&&(i.category=t.category,i.categoryIndex=t.categoryIndex),R.isString(t.subCategory)&&R.isNumber(t.subCategoryIndex)&&(i.subCategory=t.subCategory,i.subCategoryIndex=t.subCategoryIndex),R.isString(t.columnGroup)&&R.isNumber(t.columnGroupIndex)&&(i.columnGroup=t.columnGroup,i.columnGroupIndex=t.columnGroupIndex),R.isString(t.columnSubGroup)&&R.isNumber(t.columnSubGroupIndex)&&(i.columnSubGroup=t.columnSubGroup,i.columnSubGroupIndex=t.columnSubGroupIndex);for(const s of xa){R.isNumber(t[s])&&(i[s]=t[s]);const e=t[`${s}_cnt`];R.isNumber(e)&&(i.counts[s]=e)}for(const s of Object.keys(t))s.startsWith("_")&&(i.custom[s]=t[s]);return i}default(){return new wa}}const $a={rowGroup:"rowGroupIndex",category:"categoryIndex",subCategory:"subCategoryIndex"};function Ma(t,i){if("scenario"===i.kind)return{value:t.slotValue(i.slot),varianceNoData:!1};if(t.slotHasNoData(i.measure.base)||t.slotHasNoData(i.measure.delta))return{value:null,varianceNoData:!0};const s=i.measure.compute(t.slotValue(i.measure.base),t.slotValue(i.measure.delta));return{value:s,varianceNoData:null===s}}function _a(t,i){return void 0!==i&&(void 0!==i.min&&t<i.min||void 0!==i.max&&t>i.max)}function Oa(t,i){return"scenario"!==t.kind?null:i+W(t.slot)}function ka(t,i){var s,e,n,r,o,h,a,l,c;const u=[],d=new Set,f=[];let v=0,p=0,g=0,m=0,b=0;const y=new Map,w=new Map,x=new Map,S=null!==(s=i.compareFamily)&&void 0!==s?s:null,$=null!==S?Oa(i.measures.x,S):null,M=null!==S?Oa(i.measures.y,S):null,_=null!==S&&void 0!==i.measures.size?Oa(i.measures.size,S):null;for(const s of t){const t=s[i.pointLevel];if(null==t||""===t)continue;const u=null!==(e=null!==i.facetLevel?s[i.facetLevel]:"")&&void 0!==e?e:"",S=null!==(n=null!==i.seriesLevel?s[i.seriesLevel]:"")&&void 0!==n?n:"",O=`${u}\0${S}\0${t}`;if(d.has(O)){v++,f.length<5&&!f.includes(t)&&f.push(t);continue}const k=Ma(s,i.measures.x),A=Ma(s,i.measures.y);if(null===k.value||null===A.value){(k.varianceNoData||A.varianceNoData)&&p++;continue}if(_a(k.value,null===(r=i.domains)||void 0===r?void 0:r.x)||_a(A.value,null===(o=i.domains)||void 0===o?void 0:o.y)){g++;continue}const R={name:t,seriesKey:S,facetKey:u,x:k.value,y:A.value,row:s};if(void 0!==i.measures.size){const t=Ma(s,i.measures.size).value;if(null===t)continue;if(t<0){m++;continue}R.size=t}if(void 0!==i.measures.share){const t=Ma(s,i.measures.share).value;null!==t&&(t<0||t>1?(b++,R.share=Math.min(1,Math.max(0,t))):R.share=t)}if(null!==$&&null!==M){const t=s.slotValue($),e=s.slotValue(M),n=null!==_?s.slotValue(_):null;null===t||null===e||null!==_&&null===n?R.compare=null:_a(t,null===(h=i.domains)||void 0===h?void 0:h.x)||_a(e,null===(a=i.domains)||void 0===a?void 0:a.y)?(g++,R.compare=null):(R.compare={x:t,y:e},null!==n&&(R.compare.size=n))}if(d.add(O),x.has(u)||x.set(u,[]),x.get(u).push(R),null!==i.facetLevel){const t=s[$a[i.facetLevel]];null!=t&&t<(null!==(l=y.get(u))&&void 0!==l?l:Number.POSITIVE_INFINITY)&&y.set(u,t)}if(null!==i.seriesLevel){const t=s[$a[i.seriesLevel]];null!=t&&t<(null!==(c=w.get(S))&&void 0!==c?c:Number.POSITIVE_INFINITY)&&w.set(S,t)}}const O=[...x.keys()].sort(((t,i)=>{var s,e;return(null!==(s=y.get(t))&&void 0!==s?s:Number.MAX_SAFE_INTEGER)-(null!==(e=y.get(i))&&void 0!==e?e:Number.MAX_SAFE_INTEGER)})),k=O.map((t=>{let s=x.get(t);return i.limit>0&&s.length>i.limit&&(s="size"===i.limitBy?[...s].sort(((t,i)=>{var s,e;return(null!==(s=i.size)&&void 0!==s?s:0)-(null!==(e=t.size)&&void 0!==e?e:0)})).slice(0,i.limit):s.slice(0,i.limit)),{key:t,points:s}})),A=new Set;for(const t of k)for(const i of t.points)A.add(i.seriesKey);const R=[...A].sort(((t,i)=>{var s,e;return(null!==(s=w.get(t))&&void 0!==s?s:Number.MAX_SAFE_INTEGER)-(null!==(e=w.get(i))&&void 0!==e?e:Number.MAX_SAFE_INTEGER)})).map(((t,i)=>({key:t,index:i})));let N=null,L=0;for(const t of k)for(const i of t.points){L++;const t=[i.x],s=[i.y],e=void 0!==i.size?[i.size]:[];null!=i.compare&&(t.push(i.compare.x),s.push(i.compare.y),void 0!==i.compare.size&&e.push(i.compare.size)),null===N&&(N={xMin:t[0],xMax:t[0],yMin:s[0],yMax:s[0],sizeMax:0});for(const i of t)N.xMin=Math.min(N.xMin,i),N.xMax=Math.max(N.xMax,i);for(const t of s)N.yMin=Math.min(N.yMin,t),N.yMax=Math.max(N.yMax,t);for(const t of e)N.sizeMax=Math.max(N.sizeMax,t)}return v>0&&u.push({code:"xy-duplicate-point",data:{count:String(v),names:f.join(", ")}}),p>0&&u.push({code:"xy-variance-nodata",data:{count:String(p)}}),g>0&&u.push({code:"xy-point-clipped",data:{count:String(g)}}),m>0&&u.push({code:"bubble-size-negative",data:{count:String(m)}}),b>0&&u.push({code:"bubble-share-range",data:{count:String(b)}}),L>5e3&&u.push({code:"xy-point-budget",data:{count:String(L)}}),{facets:k,series:R,extents:N,warnings:u,totalPoints:L}}class Aa{constructor(t,i,s,e,n,r){var o,h,a,l;this.ruleSet=t,this.config=e,this.styles=n,this.availableWidth=r,this.warnings=[],this.canvasHeight=0,this.i18nMap=new Map,this.hatchPatterns=new Set,this.scaleOverflowCount=0,this.svgRoot=null,this.config=Object.assign(Object.assign({},e),{x:D(e.x),y:D(e.y)});const c=new Sa;let u=[];try{""!==s&&(u=i.exec(`SELECT * FROM ${s}`))}catch(t){this.queryError=ci(t)}const d=(null!=u?u:[]).map((t=>c.adapt(t)));this.data=ka(d,{pointLevel:e.pointLevel,seriesLevel:e.seriesLevel,facetLevel:null!==e.facet?"rowgroup"===e.facet.level?"rowGroup":"category":null,measures:{x:null!==(o=C(e.x.measure))&&void 0!==o?o:{kind:"scenario",slot:"ac1"},y:null!==(h=C(e.y.measure))&&void 0!==h?h:{kind:"scenario",slot:"ac2"},size:null!==(a=C(e.size.measure))&&void 0!==a?a:{kind:"scenario",slot:"ac3"},share:null!==e.share&&null!==(l=C(e.share.measure))&&void 0!==l?l:void 0},compareFamily:e.compareFamily,domains:{x:{min:this.config.x.min,max:this.config.x.max},y:{min:this.config.y.min,max:this.config.y.max}},limit:e.limit,limitBy:"size"}),this.warnings.push(...this.data.warnings)}get em(){return this.styles.fontStyles.size}get xPercent(){return z(this.config.x.measure)}get yPercent(){return z(this.config.y.measure)}get sizePercent(){return z(this.config.size.measure)}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,i=!1){const s=Qh(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:i?"bold":"normal"}).width;return Number.isFinite(s)&&s>0?s:.6*t.length*this.em}drawText(t,i,s,e,n={}){var r,o;return t.text(i).font({size:this.styles.fontStyles.size,weight:n.bold?"bold":"normal",anchor:null!==(r=n.anchor)&&void 0!==r?r:"start"}).fill(null!==(o=n.color)&&void 0!==o?o:this.styles.fontStyles.color).attr({x:s,y:e,"font-family":this.fontFamily()})}hasNoData(){return 0===this.data.totalPoints}getWarnings(){return this.warnings}getQueryError(){return this.queryError}getAllocatedCanvasWidth(){return this.availableWidth}getAllocatedCanvasHeight(){return this.canvasHeight}setI18n(t){this.i18nMap=t}addWarningOnce(t,i){this.warnings.some((i=>i.code===t))||this.warnings.push({code:t,data:i})}primaryColorIndex(){const t=C(this.config.size.measure);return null===t||"variance"===t.kind?10:this.ruleSet.getScenarioColorIndex(t.slot)}compareColorIndex(){return this.ruleSet.getScenarioColorIndex(`${this.config.compareFamily}1`)}seriesHue(t){const{color:i,overflowed:s}=w(t,this.styles.seriesColors);return s&&this.addWarningOnce("xy-series-overflow",{}),i}familyDisplayName(t){return this.ruleSet.getScenario(`${t}1`).group}legendModel(){var t,i;const s=[],e=null!==(i=null!==(t=this.config.size.label)&&void 0!==t?t:this.i18nMap.get("legend.size"))&&void 0!==i?i:"";""!==e&&(s.push(e),void 0!==this.config.size.unit&&""!==this.config.size.unit&&s.push(`${this.i18nMap.get("axis.in")||"in"} ${this.config.size.unit}`));const n=[];if(null!==this.config.compareFamily){const t=C(this.config.size.measure),i=null!==t&&"scenario"===t.kind?t.slot.replace(/\d+$/,""):"ac";n.push(this.legendEntry(this.familyDisplayName(this.config.compareFamily),this.compareColorIndex(),0)),n.push(this.legendEntry(this.familyDisplayName(i),this.primaryColorIndex(),0))}const r=this.data.series.map((t=>{var i;return this.legendEntry(""===t.key?null!==(i=this.ruleSet.getScenario("").name)&&void 0!==i?i:"Series":t.key,this.primaryColorIndex(),t.index)}));return{sizeCaption:s,title:this.i18nMap.get("legend.title")||null,compareEntries:n,entries:r}}legendEntry(t,i,s){const e=this.seriesHue(s),n=x(i,e,"bubble");return{label:t,treatment:n,fill:this.treatmentFill(n,s,e)}}toString(){const t=new uh;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}axisTitle(t,i){var s;const e=null!==(s=t.label)&&void 0!==s?s:"";return""===e?"":void 0===t.unit||""===t.unit?e:`${e} ${i} ${t.unit}`}draw(t){var i,s,e,n,r,o,h,a,l,c,u;this.warnings=this.data.warnings.slice(),this.hatchPatterns.clear(),this.scaleOverflowCount=0,this.svgRoot=t;const d=this.em,f=this.styles.padding,v=this.i18nMap.get("axis.in")||"in",p=t.group(),g=new ya(this.styles),m=this.legendModel(),b=this.config.legend.show&&(m.entries.length>0||m.sizeCaption.length>0),y=b?g.measure(m,this.config.legend.position):{width:0,height:0},w="right"===this.config.legend.position&&b?y.width+d:0,x=""!==this.config.chartTitle?1.6*d:0,S=this.axisTitle(this.config.y,v),$=this.axisTitle(this.config.x,v),M=""!==S?1.4*d:.4*d,_=1.4*d+(""!==$?1.3*d:0);let O,k=3*d,A={x:0,y:0,width:0,height:0},R=[];const N=Math.max(1,this.data.facets.length),L=null===(i=this.config.facet)||void 0===i?void 0:i.columns,E=oa.domain(null!==(e=null===(s=this.data.extents)||void 0===s?void 0:s.xMin)&&void 0!==e?e:0,null!==(r=null===(n=this.data.extents)||void 0===n?void 0:n.xMax)&&void 0!==r?r:1,{min:this.config.x.min,max:this.config.x.max}),T=oa.domain(null!==(h=null===(o=this.data.extents)||void 0===o?void 0:o.yMin)&&void 0!==h?h:0,null!==(l=null===(a=this.data.extents)||void 0===a?void 0:a.yMax)&&void 0!==l?l:1,{min:this.config.y.min,max:this.config.y.max});for(let t=0;t<2;t++){const t=Math.max(10,this.availableWidth-f.left-f.right-k-w);A={x:f.left+k,y:f.top+x+M,width:t,height:t/this.config.aspect},O=new sa(N,L,A,this.styles.scaleFactors.panelGap*d);const i=O.panelRect(0).height,s=Math.max(4,Math.min(8,Math.round(i/(4*d)))),e=new oa(T[0],T[1],i,0);R=e.ticks(s);const n=aa(R,this.yPercent);k=Math.max(...R.map((t=>this.textWidth(ha(t,n,this.styles.locale,this.yPercent)))),d)+this.styles.scaleFactors.axisTickLength*d+.4*d}this.canvasHeight=A.y+A.height+_+("bottom"===this.config.legend.position&&b?y.height+d:0)+f.bottom,""!==this.config.chartTitle&&this.drawText(p,this.config.chartTitle,f.left,f.top+d,{bold:!0}),""!==S&&this.drawAxisTitleText(p,this.config.y,v,f.left,A.y-.6*d,"start");const C=this.buildPanels(O,E,T),P=C[0].xScale.ticks(Math.max(3,Math.min(8,Math.round(C[0].rect.width/(7*d))))),W=aa(P,this.xPercent),D=aa(R,this.yPercent),z=this.config.sizeAreaPerUnit>0?ma.grouped(this.config.sizeAreaPerUnit):ma.local(null!==(u=null===(c=this.data.extents)||void 0===c?void 0:c.sizeMax)&&void 0!==u?u:0,this.styles.scaleFactors.bubbleMaxRadius*d,this.styles.scaleFactors.bubbleMinRadius*d);0===this.data.facets.length?this.drawPanel(p,C[0],{key:"",points:[]},z,P,R,W,D,!0,!0):this.data.facets.forEach(((t,i)=>{this.drawPanel(p,C[i],t,z,P,R,W,D,O.isOuterLeft(i),O.isOuterBottom(i),this.data.facets.length>1?t.key:"")})),""!==$&&this.drawAxisTitleText(p,this.config.x,v,A.x+A.width,A.y+A.height+2.6*d,"end"),b&&("right"===this.config.legend.position?g.draw(p,m,A.x+A.width+d,A.y,"right"):g.draw(p,m,A.x,A.y+A.height+_,"bottom")),this.scaleOverflowCount>0&&this.addWarningOnce("bubble-scale-overflow",{count:String(this.scaleOverflowCount)}),t.group().addClass("annotations")}drawAxisTitleText(t,i,s,e,n,r){var o;const h=null!==(o=i.label)&&void 0!==o?o:"",a=void 0!==i.unit&&""!==i.unit?`${s} ${i.unit}`:"",l=.3*this.em;"start"===r?(this.drawText(t,h,e,n,{bold:!0}),""!==a&&this.drawText(t,a,e+this.textWidth(h,!0)+l,n,{})):""!==a?(this.drawText(t,a,e,n,{anchor:"end"}),this.drawText(t,h,e-this.textWidth(a)-l,n,{anchor:"end",bold:!0})):this.drawText(t,h,e,n,{anchor:"end",bold:!0})}buildPanels(t,i,s){const e=[];for(let n=0;n<t.count;n++){const r=t.panelRect(n),o=new oa(i[0],i[1],r.x,r.x+r.width),h=new oa(s[0],s[1],r.y+r.height,r.y);e.push({rect:r,xScale:o,yScale:h,frame:new ba(o,h,r,this.styles)})}return e}treatmentFill(t,i,s){return!0!==t.hatch?t.fill:(this.ensureHatchPattern(i,s),`url(#xy-fc-${i})`)}ensureHatchPattern(t,i){this.hatchPatterns.has(t)||null===this.svgRoot||(this.hatchPatterns.add(t),this.svgRoot.defs().pattern(10,10,(t=>{t.rect(10,10).fill("#ffffff"),t.line(0,10,10,0).stroke({color:i,width:2}),t.line(-2.5,2.5,2.5,-2.5).stroke({color:i,width:2}),t.line(7.5,12.5,12.5,7.5).stroke({color:i,width:2})})).id(`xy-fc-${t}`))}drawPanel(t,i,s,e,n,r,o,h,a,l,c=""){var u,d,f,v,p,g;const m=t.group(),b=this.em;i.frame.drawBands(m,this.config.x.highlight,this.config.y.highlight),i.frame.drawGrid(m,r,void 0===this.config.x.refLine&&void 0===this.config.y.refLine&&i.rect.width>30*b?n:void 0),i.frame.drawRefLines(m,this.config.x.refLine,this.config.y.refLine),i.frame.drawFrame(m);const y=m.group().id("compare"),w=m.group().id("primary"),$=new ga(i.rect,this.styles.scaleFactors.labelToMark*b),M=[...s.points].sort(((t,i)=>{var s,e;return(null!==(s=i.size)&&void 0!==s?s:0)-(null!==(e=t.size)&&void 0!==e?e:0)})),_=[];for(const t of M){const n=null!==(d=null===(u=this.data.series.find((i=>i.key===t.seriesKey)))||void 0===u?void 0:u.index)&&void 0!==d?d:0,r=this.seriesHue(n),o=x(this.primaryColorIndex(),r,"bubble"),h=i.xScale.scale(t.x),a=i.yScale.scale(t.y),l=e.radius(null!==(f=t.size)&&void 0!==f?f:0);if(this.config.sizeAreaPerUnit>0&&this.bubbleExceedsPanel(i.rect,h,a,l)&&this.scaleOverflowCount++,null!=t.compare){const s=x(this.compareColorIndex(),r,"bubble"),o=i.xScale.scale(t.compare.x),h=i.yScale.scale(t.compare.y),a=e.radius(null!==(v=t.compare.size)&&void 0!==v?v:0);this.drawBubble(y,o,h,a,s,n,r),$.registerMark(o,h,a),this.config.labels.values&&void 0!==t.compare.size&&a>=1.2*b&&this.drawValueLabel(y,o,h,a,t.compare.size,s.fill)}const c=Xh(t,s.key,this.config);null===(p=this.drawBubble(w,h,a,l,o,n,r))||void 0===p||p.attr(ji(c,"element")),$.registerMark(h,a,l),void 0!==t.share&&l>0&&(null===(g=this.drawShareSlice(w,h,a,l,t.share,S(r)))||void 0===g||g.attr(ji(c))),this.config.labels.values&&void 0!==t.size&&this.drawValueLabel(w,h,a,l,t.size,!0===o.hatch?"#ffffff":o.fill),_.push({point:t,cx:h,cy:a,r:l,seriesIndex:n,hue:r,treatment:o})}this.drawNameLabels(m,$,_,s.key),i.frame.drawTickLabels(m,{ticksX:n,ticksY:r,xDecimals:o,yDecimals:h,xPercent:this.xPercent,yPercent:this.yPercent,showXLabels:l,showYLabels:a}),""!==c&&i.frame.drawPanelTitle(m,c)}bubbleExceedsPanel(t,i,s,e){return i-e<t.x||i+e>t.x+t.width||s-e<t.y||s+e>t.y+t.height}drawBubble(t,i,s,e,n,r,o){if(!(e<=0))return t.circle(2*e).center(i,s).fill(this.treatmentFill(n,r,o)).stroke({color:n.stroke,width:n.strokeWidth})}drawShareSlice(t,i,s,e,n,r){if(n<=0)return;if(n>=1)return t.circle(2*e).center(i,s).fill(r);const o=2*n*Math.PI,h=i+e*Math.sin(o),a=s-e*Math.cos(o),l=o>Math.PI?1:0;return t.path(`M ${i} ${s} L ${i} ${s-e} A ${e} ${e} 0 ${l} 1 ${h} ${a} Z`).fill(r).stroke("none")}drawValueLabel(t,i,s,e,n,r){const o=ha(n,this.valueDecimals(),this.styles.locale,this.sizePercent);this.textWidth(o)+.4*this.em>2*e||this.drawText(t,o,i,s+.35*this.em,{anchor:"middle",color:ia(r)})}drawNameLabels(t,i,s,e){const n=[...s].sort(((t,i)=>{var s,e;return(null!==(s=i.point.size)&&void 0!==s?s:0)-(null!==(e=t.point.size)&&void 0!==e?e:0)})),{selected:r,unknownNames:o}=i.selectCandidates(n,this.config.labels.points,this.config.labels.max,(t=>t.point.name));o.length>0&&this.addWarningOnce("xy-label-unknown",{names:o.join(", ")});const h=new Map,a=r.map((t=>{const i={name:t.point.name,cx:t.cx,cy:t.cy,r:t.r,width:this.textWidth(t.point.name),height:1.1*this.em};return h.set(i,t.point),i}));for(const s of i.place(a))this.drawText(t,s.candidate.name,s.x,s.y+.9*s.candidate.height,{}).attr(ji(Xh(h.get(s.candidate),e,this.config),"label"))}valueDecimals(){var t,i,s;let e=0;for(const n of this.data.facets)for(const r of n.points)e=Math.max(e,Math.abs(null!==(t=r.size)&&void 0!==t?t:0),Math.abs(null!==(s=null===(i=r.compare)||void 0===i?void 0:i.size)&&void 0!==s?s:0));return e>0&&Number.isFinite(e)?(this.sizePercent&&(e*=100),oa.stepDecimals(Math.pow(10,Math.floor(Math.log10(e))-2))):1}}const Ra=["xy-duplicate-point","xy-point-clipped","xy-variance-nodata","xy-label-unknown","xy-series-overflow","xy-point-budget","bubble-size-negative","bubble-share-range","bubble-scale-overflow"],Na=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.chartTitle="",this.share=null,this.compareFamily=null,this.facet=null,this.pointLevel="category",this.seriesLevel=null,this.aspect=16/9,this.limit=0,this.filter="",this.sizeAreaPerUnit=0,this.i18n=new Map,this.containerWidth=0,this.svgMarkup="",a(this)}getDb(){return this.stores||(this.stores=c(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=$(this.getDb(),this.tableName,this.filter);this.chart=new Aa(new Cs(this.ruleSetConfig),this.getDb(),i,{chartTitle:this.chartTitle,x:this.x,y:this.y,size:this.size,share:this.share,compareFamily:this.compareFamily,labels:this.labels,legend:this.legend,facet:this.facet,pointLevel:this.pointLevel,seriesLevel:this.seriesLevel,aspect:this.aspect,limit:this.limit,sizeAreaPerUnit:this.sizeAreaPerUnit},t,this.containerWidth||0),this.chart.setI18n(this.i18n),this.svgMarkup=this.chart.hasNoData()?"":this.chart.toString(),this.syncWarnings(this.chart.getWarnings()),ui(this.errors,this.chart.getQueryError())}syncWarnings(t){if(void 0===this.errors)return;const i=new Map(t.map((t=>[t.code,t.data])));for(const t of Ra){const s=`WARN_${t.replace(/-/g,"_")}`;if(i.has(t)){const e=void 0!==this.translator?this.translator(`.${t}`,i.get(t)):t;this.errors.addOrReplace({id:s,type:"warning",message:e})}else this.errors.remove(s)}}prepareStyle(){var t,i;const s=new Bs(new Vs,new Ws,new Is(new Gs),new zs).adapt(this.styles);return s.locale=(null===(i=null===(t=c(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}render(){var t;if(void 0===this.chart||void 0!==this.chart.getQueryError())return i(s,null);if(this.chart.hasNoData()){const e=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return i(s,{class:"no-data"},i("div",{class:"empty-state"},e))}return i(s,null,i("div",{innerHTML:this.svgMarkup}))}get element(){return e(this)}};Na.style=':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}';const La=["measure","label","unit"];function Ea(t){const i=[],s=Da(t,"measure",i);if(void 0===s||""===s.trim())return i.push("measure"),{config:null,unknownKeys:Wa(t,La),invalidFields:i};const e={measure:s.trim()};return e.label=Da(t,"label",i),e.unit=Da(t,"unit",i),{config:e,unknownKeys:Wa(t,La),invalidFields:i}}const Ta=["show","decimals"];function Ca(t,i){const s=[],e={show:i.show,decimals:i.decimals};return R.isExisting(t.show)&&("auto"===t.show||"none"===t.show?e.show=t.show:s.push("show")),R.isExisting(t.decimals)&&(R.isNumber(t.decimals)&&t.decimals>=0&&t.decimals<=4?e.decimals=Math.floor(t.decimals):s.push("decimals")),{config:e,unknownKeys:Wa(t,Ta),invalidFields:s}}function Pa(t){var i;const s=null!==(i=null==t?void 0:t.trim())&&void 0!==i?i:"";if(""===s||"null"===s)return{ranges:[],parseError:!1,issues:[]};let e;try{e=JSON.parse(s)}catch(t){return{ranges:[],parseError:!0,issues:[]}}if(!Array.isArray(e)||0===e.length)return{ranges:[],parseError:!0,issues:[]};if(!e.every((t=>R.isNumber(t)&&isFinite(t)&&t>0)))return{ranges:[],parseError:!0,issues:[]};const n=[];let r=e;const o=[...r].sort(((t,i)=>t-i));return o.some(((t,i)=>t!==r[i]))&&n.push("not ascending, sorted"),r=o,r.length>2&&(n.push(`${r.length} entries, first 2 kept`),r=r.slice(0,2)),{ranges:r,parseError:!1,issues:n}}function Wa(t,i){return Object.keys(t).filter((t=>!i.includes(t)))}function Da(t,i,s){if(R.isExisting(t[i]))return R.isString(t[i])?t[i]:void s.push(i)}const za=["pl1","pp1","fc1"],Ua=class{validateFilter(t){const i="ERR_filter";v(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateActual(t){this.validateMeasureSpec("actual",t)}validateTarget(t){this.validateMeasureSpec("target",t)}validateRanges(t){const i="ERR_bullet_json_ranges",s="WARN_bullet_ranges",e=Pa(t);if(e.parseError)return this.setBlockingError(i,this.t(".bullet-prop-json",{prop:"ranges"})),void this.errors.remove(s);this.setBlockingError(i,null),e.issues.length>0?this.errors.addOrReplace({id:s,type:"warning",message:this.t(".bullet-ranges-invalid",{detail:e.issues.join("; ")})}):this.errors.remove(s)}validateNormalize(t){this.validateEnum("normalize","WARN_normalize",t,["target","none"],"target")}validateVariances(t){this.validateEnum("variances","WARN_variances",t,["auto","none"],"auto")}validateLevel(t){this.validateEnum("level","WARN_level",t,["auto","rowgroup","category","subcategory"],"auto")}validateOrder(t){const i="WARN_order",s=U(t).filter((t=>""!==t));0===s.length?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`order: invalid value(s) '${s.join(", ")}'; using the dataset order.`})}validateOrderDirection(t){const i="WARN_orderDirection";N(t)||F(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`order-direction: invalid value '${t}' - expected asc/desc; using asc.`})}validateLimit(t){const i="WARN_limit";L(t)&&Number(t)>=0?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`limit: invalid value '${t}' - expected a non-negative integer; using 0.`})}validateLabels(t){const i="ERR_bullet_json_labels",s="WARN_bullet_fields_labels",{data:e,parseError:n}=rs(t,null);if(n)return this.setBlockingError(i,this.t(".bullet-prop-json",{prop:"labels"})),void this.errors.remove(s);this.setBlockingError(i,null),null!==e?this.reportSpecIssues(s,"labels",Ca(e,this.labelDefaults())):this.errors.remove(s)}validateScale(t){const i="WARN_scale";if(N(t))return void this.errors.remove(i);const{mode:s,factor:e}=Ht(t);"factor"===s&&(void 0===e||e<=0)?this.errors.addOrReplace({id:i,type:"warning",message:`scale: invalid value '${t}' - expected none/auto or a positive number.`}):this.errors.remove(i)}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.chartTitle="",this.filter="",this.actual="",this.target="",this.ranges="",this.normalizeMode="target",this.variances="auto",this.level="auto",this.order="",this.orderDirection="",this.limit=0,this.labels="",this._autoScaleGuard=!1,this._lastScaledParentHeight=0,this.translateForInner=(t,i)=>this.t(t,i),E(this),a(this),Yt(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.errors=l(this),this.componentStyle=k(this),this.ruleSetConfig=es(this),this.t=Bt(this).t}componentWillLoad(){this.validateFilter(this.filter),this.validateActual(this.actual),this.validateTarget(this.target),this.validateRanges(this.ranges),this.validateNormalize(this.normalizeMode),this.validateVariances(this.variances),this.validateLevel(this.level),this.validateOrder(this.order),this.validateOrderDirection(this.orderDirection),this.validateLimit(this.limit),this.validateLabels(this.labels),this.validateScale(this.scale)}componentDidRender(){$s(this.element,"bn-chart-bullet-renderer");const{mode:t}=Ht(this.scale);if("auto"!==t&&"empty"!==t)return void(this._autoScaleGuard=!1);if(this._autoScaleGuard)return void(this._autoScaleGuard=!1);const i=this.element,{height:s}=Ut(i);if(s<=0)return;this._lastScaledParentHeight=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),n=i.scrollHeight,o=this.appliedScaleFactor;if(n<=s+1)return void this.errors.remove("AUTO_scale");const h=Math.max(.3,o*(s-1)/n);Math.abs(h-o)<.01||(i.style.setProperty("--bn-font-size",e*h+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${h.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,r((()=>{this.appliedScaleFactor=h})))}componentDidLoad(){this.layoutObserver=ss(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=Ut(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,n(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=Ut(this.element);this._lastScaledParentHeight=t,n(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{show:"auto",decimals:1}}setBlockingError(t,i){null===i?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:i}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateMeasureSpec(t,i){var s;const e=`ERR_bullet_json_${t}`,n=`ERR_bullet_measure_${t}`,r=`WARN_bullet_fields_${t}`,{data:o,parseError:h}=rs(i,"measure");if(h)return this.setBlockingError(e,this.t(".bullet-prop-json",{prop:t})),this.setBlockingError(n,null),void this.errors.remove(r);if(this.setBlockingError(e,null),null===o)return this.setBlockingError(n,null),void this.errors.remove(r);const a=(null!==(s=o.measure)&&void 0!==s?s:"").trim(),l=C(a);"auto"===a.toLowerCase()||null!==l&&"scenario"===l.kind?this.setBlockingError(n,null):this.setBlockingError(n,this.t(".bullet-measure-invalid",{prop:t,measure:a})),this.reportSpecIssues(r,t,Ea(o))}validateEnum(t,i,s,e,n){N(s)||e.includes(s.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`${t}: invalid value '${s}' - expected ${e.join("/")}; using '${n}'.`})}reportSpecIssues(t,i,s){const e=[];null!==s&&s.invalidFields.length>0&&e.push(`invalid: ${s.invalidFields.join(", ")}`),null!==s&&s.unknownKeys.length>0&&e.push(`unknown: ${s.unknownKeys.join(", ")}`),e.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${i}: ignored sub-fields (${e.join("; ")}).`}):this.errors.remove(t)}prepareActual(){var t,i,s,e,n;const{data:r,parseError:o}=rs(this.actual,"measure");if(o)return null;const h=null!==r?Ea(r).config:null;if(null===h||"auto"===h.measure.toLowerCase()){const n=null!==h,r=null!==(i=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==i?i:[],o=null!==(e=r.includes("ac1")?"ac1":null!==(s=r.find((t=>t.startsWith("ac"))))&&void 0!==s?s:r[0])&&void 0!==e?e:"ac1";return n||null===this.datasetMeta?this.errors.remove("AUTO_actual"):this.errors.addOrReplace({id:"AUTO_actual",type:"warning",message:`actual: not set, auto-detected: ${o}`}),null===h?{measure:o}:Object.assign(Object.assign({},h),{measure:o})}return this.errors.remove("AUTO_actual"),"scenario"===(null===(n=C(h.measure))||void 0===n?void 0:n.kind)?h:null}prepareTarget(){var t,i,s;const{data:e,parseError:n}=rs(this.target,"measure");if(n)return null;const r=null!==e?Ea(e).config:null;if(null===r||"auto"===r.measure.toLowerCase()){const s=null!==r,e=null!==(i=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==i?i:[],n=za.find((t=>e.includes(t)));return void 0===n?(this.errors.remove("AUTO_target"),null!==this.datasetMeta?this.errors.addOrReplace({id:"WARN_bullet_target_unavailable",type:"warning",message:this.t(".bullet-target-none")}):this.errors.remove("WARN_bullet_target_unavailable"),null):(this.errors.remove("WARN_bullet_target_unavailable"),s||null===this.datasetMeta?this.errors.remove("AUTO_target"):this.errors.addOrReplace({id:"AUTO_target",type:"warning",message:`target: not set, auto-detected: ${n}`}),null===r?{measure:n}:Object.assign(Object.assign({},r),{measure:n}))}return this.errors.remove("AUTO_target"),this.errors.remove("WARN_bullet_target_unavailable"),"scenario"===(null===(s=C(r.measure))||void 0===s?void 0:s.kind)?r:null}prepareNormalize(){var t;return"none"===(null===(t=this.normalizeMode)||void 0===t?void 0:t.trim().toLowerCase())?"none":"target"}prepareShowVariances(){var t;return"none"!==(null===(t=this.variances)||void 0===t?void 0:t.trim().toLowerCase())}prepareLevel(){var t,i;const s=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("rowgroup"===s)return G.ROWGROUP;if("category"===s)return G.CATEGORY;if("subcategory"===s)return G.SUBCATEGORY;const e=null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel;if(void 0!==e&&""!==e){const t=G[e.toUpperCase()];if(void 0!==t)return t}return G.CATEGORY}prepareOrder(){var t,i,s,e;const n="auto"===(null===(t=this.order)||void 0===t?void 0:t.trim().toLowerCase());let r;N(this.order)||n?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedOrder)?(n?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:`order: not set, auto-detected: ${this.datasetMeta.suggestedOrder}`}),r=this.datasetMeta.suggestedOrder):(this.errors.remove("AUTO_order"),r=""):(this.errors.remove("AUTO_order"),r=this.order);const o=null!==(e=j[null===(s=this.orderDirection)||void 0===s?void 0:s.toUpperCase()])&&void 0!==e?e:j.ASC;if(N(r))return new I([Y.CATEGORYINDEX],o);const h=r.split(",").map((t=>Y[t.trim().toUpperCase()])).filter((t=>void 0!==t));return new I(h.length>0?h:[Y.CATEGORYINDEX],o)}prepareLabels(){const t=this.labelDefaults(),{data:i,parseError:s}=rs(this.labels,null);return s||null===i?{show:t.show,decimals:t.decimals}:Ca(i,t).config}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}i18nLocalKeys(){return["no-data","target","axis.in"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),i=new Map(p.map((t=>[t,this.t("global.".concat(t))])));return new Map([...i.entries(),...t.entries(),...Ts(this.ruleSetConfig("user"))])}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const s=i.global.fontSizePx*t;return{scaleFactors:i["bn-chart-bullet"].scaleFactors,fontStyles:{font:`${s}px ${i.global.fontFamily}`,size:s,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-bullet"].axisStyles,barStyles:i["bn-chart-bullet"].barStyles,varianceStyles:i["bn-chart-bullet"].varianceStyles,rangeColors:i["bn-chart-bullet"].rangeColors,padding:i["bn-chart-bullet"].padding}}))}async getBaseline(){return Ui(this.element,"bn-chart-bullet-renderer")}async getLayoutState(t){var i;const s=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",e=ei(this.element),n=this.getEffectiveScaleFactor(),r=Number.isFinite(n)&&n>0?n:1,o=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*r;return ts(this.element,"bn-chart-bullet-renderer",this.chartTitle||void 0,{fontSizePx:o,appliedScaleFactor:r},e,s)}getEffectiveScaleFactor(){const{mode:t,factor:i}=Ht(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const o=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":o*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const i of["ac","pp","fc","pl"])for(const s of[1,2,3,4])t[`${i}${s}`]={type:"number",isOptional:!0,description:""};const i={actual:this.prepareActual(),target:this.prepareTarget()};for(const[s,e]of Object.entries(i))null!==e&&void 0!==t[e.measure]&&(t[e.measure].description=`${s}: ${void 0!==e.label?e.label:e.measure}`);return{IBulletChartDataRow:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}chartTemplate(){const t=this.prepareActual(),s=this.prepareTarget(),e=Pa(this.ranges).ranges,n=this.prepareNormalize();return this.setBlockingError("ERR_bullet_measure_same",null!==t&&null!==s&&t.measure===s.measure?this.t(".bullet-measure-same",{measure:t.measure}):null),e.length>0&&"target"===n?this.errors.addOrReplace({id:"WARN_bullet_ranges_ignored",type:"warning",message:this.t(".bullet-ranges-ignored")}):this.errors.remove("WARN_bullet_ranges_ignored"),this.hasBlockingErrors()||null===t?null:i("bn-chart-bullet-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,actual:t,target:s,ranges:e,normalizeMode:n,showVariances:this.prepareShowVariances(),level:this.prepareLevel(),order:this.prepareOrder(),limit:this.prepareLimit(),labels:this.prepareLabels(),filter:this.filter,styles:this.prepareStyle(),i18n:this.prepareI18n(),containerWidth:Ut(this.element).width,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return i(s,{key:"cdd2404977255a330652806671d1bea76c796769",style:this.getFontStyles()},i("div",{key:"0b8cfeb6209083f9144c5824bceecb9b02578f02",class:"container"},this.chartTemplate()))}get element(){return e(this)}static get watchers(){return{filter:[{validateFilter:0}],actual:[{validateActual:0}],target:[{validateTarget:0}],ranges:[{validateRanges:0}],normalizeMode:[{validateNormalize:0}],variances:[{validateVariances:0}],level:[{validateLevel:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],labels:[{validateLabels:0}],scale:[{validateScale:0}]}}};Ua.style=':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:column}';class Fa{constructor(t,i,s){this.pos=t,this.neg=i,this.neu=s,this.needleHeadColour="#000000"}getSVGStyle(t){return"pos"===t?this.pos:"neg"===t?this.neg:this.neu}}class Ga{constructor(t){this.svgStyleAdapter=t}adapt(t){const i=new Fa(this.svgStyleAdapter.defaultPos(),this.svgStyleAdapter.defaultNeg(),this.svgStyleAdapter.defaultNeu());return R.isExisting(t.pos)&&(i.pos=this.svgStyleAdapter.adapt(t.pos)),R.isExisting(t.neg)&&(i.neg=this.svgStyleAdapter.adapt(t.neg)),R.isExisting(t.pp)&&(i.neu=this.svgStyleAdapter.adapt(t.neu)),R.isString(t.needleHeadColour)&&(i.needleHeadColour=t.needleHeadColour),i}default(){return new Fa(this.svgStyleAdapter.defaultPos(),this.svgStyleAdapter.defaultNeg(),this.svgStyleAdapter.defaultNeu())}}class ja{constructor(t,i,s,e,n,r){this.ruleSet=t,this.config=e,this.styles=n,this.availableWidth=r,this.rows=[],this.warnings=[],this.i18nMap=new Map,this.populateModel(i,s),this.normalized="target"===this.config.normalize&&this.rows.some((t=>null!==t.fraction)),null!==this.config.target&&this.rows.length>0&&!this.rows.some((t=>null!==t.target))&&this.warnings.push({code:"bullet-target-none",data:{}})}populateModel(t,i){var s,e,n;if(""===i)return;const r=this.config.level,o=this.config.order,h=this.config.actual.measure,a=null!==(e=null===(s=this.config.target)||void 0===s?void 0:s.measure)&&void 0!==e?e:null,l="transformOperator(operation)",c=[h,...null!==a?[a]:[]].map((t=>`CASE WHEN MIN(${l}) = MAX(${l}) THEN SUM(${t}) ELSE SUM(${t} * ${l}) END as ${t}, SUM(ABS(${t})) as ${t}_gross, COUNT(ISNULL(${t})) as ${t}_cnt`)).join(", ");let u;try{u=t.exec(`SELECT ${this.createSelectString(r,o)}, ${c},\n MIN(transformOperator(operation)) as opMin, MAX(transformOperator(operation)) as opMax\n FROM ${i}\n GROUP BY ${this.createGroupByStr(r,o)}\n ORDER BY ${this.createOrderStr(r,o)}`)}catch(t){return void(this.queryError=ci(t))}let d=null!=u?u:[];this.config.limit>0&&(d=d.slice(0,this.config.limit));let f=0,v=0,p=0,g=0;for(const t of d){const i="number"==typeof t.opMin?t.opMin:1,s="number"==typeof t.opMax?t.opMax:1;let e=-1===i&&-1===s?"-":"+";i!==s&&(e="+",f++);const r=this.readValue(t,h),o=null!==a?this.readValue(t,a):null;null!==r&&r<0&&g++;let l=null;"target"===this.config.normalize&&(null===o?null!==a&&v++:o<=0?p++:null!==r&&r>=0&&(l=r/o)),this.rows.push({category:String(null!==(n=t.category)&&void 0!==n?n:""),actual:r,target:o,operation:e,sentiment:this.sentiment(r,o,e),fraction:l})}f>0&&this.warnings.push({code:"bullet-mixed-operation",data:{count:String(f)}}),v>0&&this.warnings.push({code:"bullet-target-missing",data:{count:String(v)}}),p>0&&this.warnings.push({code:"bullet-target-invalid",data:{count:String(p)}}),g>0&&this.warnings.push({code:"bullet-actual-negative",data:{count:String(g)}})}readValue(t,i){if(0===t[`${i}_cnt`])return null;const s=t[i],e=t[`${i}_gross`];return"number"==typeof s&&"number"==typeof e&&Math.abs(s)<=1e-9*e?0:"number"==typeof s&&isFinite(s)?s:null}sentiment(t,i,s){return null===t||null===i||t===i?"neu":t>i!=("-"===s)?"pos":"neg"}createSelectString(t,i){return t===G.CATEGORY&&i.hierarchy.includes(Y.CATEGORYINDEX)?`${Y.CATEGORYINDEX}, ${G.CATEGORY} as category`:t===G.ROWGROUP&&i.hierarchy.includes(Y.ROWGROUPINDEX)?`${Y.ROWGROUPINDEX}, ${G.ROWGROUP} as category`:t===G.SUBCATEGORY&&i.hierarchy.includes(Y.SUBCATEGORYINDEX)?`${Y.SUBCATEGORYINDEX}, ${G.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===G.CATEGORY&&i.hierarchy.includes(Y.CATEGORYINDEX)?`${Y.CATEGORYINDEX}, ${G.CATEGORY}`:t===G.ROWGROUP&&i.hierarchy.includes(Y.ROWGROUPINDEX)?`${Y.ROWGROUPINDEX}, ${G.ROWGROUP}`:t===G.SUBCATEGORY&&i.hierarchy.includes(Y.SUBCATEGORYINDEX)?`${Y.SUBCATEGORYINDEX}, ${G.SUBCATEGORY}`:`${t.toString()}`}createOrderStr(t,i){let s=`${t.toLowerCase()}`;return i.hierarchy.length>=1&&(s=i.hierarchy.map((t=>`${t} ${i.direction}`)).toString()),s}get em(){return this.styles.fontStyles.size}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,i=!1){const s=Qh(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:i?"bold":"normal"}).width;return Number.isFinite(s)&&s>0?s:.6*t.length*this.em}drawText(t,i,s,e,n={}){var r,o,h;return t.text(i).font({size:null!==(r=n.size)&&void 0!==r?r:this.styles.fontStyles.size,weight:n.bold?"bold":"normal",anchor:null!==(o=n.anchor)&&void 0!==o?o:"start"}).fill(null!==(h=n.color)&&void 0!==h?h:this.styles.fontStyles.color).attr({x:s,y:e,"font-family":this.fontFamily()})}setI18n(t){this.i18nMap=t}hasNoData(){return 0===this.rows.length}getWarnings(){return this.warnings}getQueryError(){return this.queryError}getAllocatedCanvasWidth(){return this.availableWidth}getAllocatedCanvasHeight(){return this.styles.padding.top+this.titleHeight()+this.headerHeight()+this.rows.length*this.rowBlockHeight()+this.styles.padding.bottom}titleHeight(){return""!==this.config.chartTitle?1.6*this.em:0}headerHeight(){return this.rows.length>0?1.2*this.em:0}rowBlockHeight(){const t=this.em,i=this.styles.scaleFactors.rowHeight*t;return this.normalized?i:i+this.styles.scaleFactors.tickStripHeight*t}valueLabel(t){return null===t||"none"===this.config.labels.show?"":ra.number(t,"decimal",this.config.labels.decimals,0,1,this.styles.locale)}targetFamily(){var t,i;const s=null!==(i=null===(t=this.config.target)||void 0===t?void 0:t.measure)&&void 0!==i?i:"pl1";return Ls(this.ruleSet.getScenarioColorIndex(s))}actualLabel(){var t;return null!==(t=this.config.actual.label)&&void 0!==t?t:ra.translateScenarioLabel(this.config.actual.measure,this.i18nMap)}targetLabel(){return null===this.config.target?"":void 0!==this.config.target.label?this.config.target.label:this.normalized?this.i18nMap.get("target")||"Target":ra.translateScenarioLabel(this.config.target.measure,this.i18nMap)}toString(){const t=new uh;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}draw(t){var i,s;const e=this.em,n=this.styles.scaleFactors,r=this.styles.padding,o=t.group();if(""!==this.config.chartTitle&&this.drawText(o,this.config.chartTitle,r.left,r.top+e,{bold:!0}),0===this.rows.length)return void t.group().addClass("annotations");const h=n.rowHeight*e,a=this.rowBlockHeight(),l=r.top+this.titleHeight()+this.headerHeight(),c=l+(this.rows.length-1)*a+h,u=Math.max(...this.rows.map((t=>this.textWidth(t.category,!0))),e),d=this.rows.map((t=>this.valueLabel(t.actual))),f="none"===this.config.labels.show?0:Math.max(...d.map((t=>this.textWidth(t))),0),v=r.left+u+n.labelToAxis*e,p=Math.max(10,this.availableWidth-v-r.right-f-(f>0?n.labelToBar*e:0)),g=null!==(i=this.config.actual.unit)&&void 0!==i?i:null===(s=this.config.target)||void 0===s?void 0:s.unit,m=this.i18nMap.get("axis.in")||"in",b=l-.35*e;void 0!==g&&""!==g&&this.drawText(o,`${m} ${g}`,r.left,b,{}),this.drawText(o,this.actualLabel(),v+.2*e,b,{}),this.normalized?this.drawNormalized(o,v,p,l,c,h,a,d):this.drawClassic(o,v,p,l,h,a,d),this.rows.forEach(((t,i)=>{this.drawText(o,t.category,v-n.labelToAxis*e,l+i*a+h/2+.35*e,{anchor:"end",bold:!0})})),o.line(v,l-.2*e,v,c+.2*e).stroke({color:this.styles.axisStyles.ac.stroke,width:Vt(n.axisLineWidth,this.em)}).attr(Wi,"axis"),t.group().addClass("annotations")}drawNormalized(t,i,s,e,n,r,o,h){const a=this.em,l=this.styles.scaleFactors,c=Math.max(1,...this.rows.map((t=>{var i;return null!==(i=t.fraction)&&void 0!==i?i:0}))),u=1.05*c,d=t=>i+t/u*s,f=d(1),v=this.styles.barStyles.getSVGStyle(this.targetFamily()),p=t.line(f,e-.3*a,f,n+.3*a).stroke({color:v.stroke,width:Vt(l.targetLineWidth,this.em)});void 0!==v.dasharray&&p.attr("stroke-dasharray",v.dasharray),this.drawText(t,this.targetLabel(),f,e-.35*a,{anchor:"middle",bold:!0}),this.rows.forEach(((s,n)=>{const c=e+n*o+r/2;if(null===s.fraction)return void this.drawValueText(t,h[n],i+l.labelToBar*a,c,s);const u=l.barHeight*a,v=d(s.fraction);if(t.rect(Math.max(0,v-i),u).move(i,c-u/2).fill(this.styles.barStyles.ac.fill).stroke({color:this.styles.barStyles.ac.stroke,width:this.styles.barStyles.ac.width}).attr(ji(this.rowKey(s),"element")).attr("data-bn-index",String(n)),this.config.showVariances&&"neu"!==s.sentiment){const i=l.varianceHeight*a,e=this.styles.varianceStyles.getSVGStyle(s.sentiment);t.rect(Math.abs(v-f),i).move(Math.min(v,f),c-i/2).fill(e.fill).stroke({color:e.stroke,width:e.width})}this.drawValueText(t,h[n],Math.max(v,f)+l.labelToBar*a,c,s)}))}drawClassic(t,i,s,e,n,r,o){const h=this.em,a=this.styles.scaleFactors,l=a.barHeight*h,c=this.config.ranges.length>0;this.rows.forEach(((u,d)=>{var f,v;const p=e+d*r,g=p+n/2,m=c&&null!==u.target?this.config.ranges.map((t=>t*u.target)):[],b=Math.max(null!==(f=u.actual)&&void 0!==f?f:0,null!==(v=u.target)&&void 0!==v?v:0,...m);if(b<=0)return void this.drawValueText(t,o[d],i+a.labelToBar*h,g,u);const y=oa.niceStep(b,4),w=Math.ceil(b/y-1e-9*y)*y,x=new oa(0,w,i,i+s);let S=i;m.forEach(((i,s)=>{const e=.8*n;t.rect(Math.max(0,x.scale(i)-S),e).move(S,g-e/2).fill(this.styles.rangeColors[Math.min(s,this.styles.rangeColors.length-1)]).stroke("none"),S=x.scale(i)}));let $=i;if(null!==u.actual&&u.actual>0){const s=x.scale(u.actual);t.rect(s-i,l).move(i,g-l/2).fill(this.styles.barStyles.ac.fill).stroke({color:this.styles.barStyles.ac.stroke,width:this.styles.barStyles.ac.width}).attr(ji(this.rowKey(u),"element")).attr("data-bn-index",String(d)),$=s}if(null!==u.target&&u.target>0){const i=x.scale(u.target),s=a.targetTickHeight*h,n=this.styles.barStyles.getSVGStyle(this.targetFamily()),r=t.line(i,g-s/2,i,g+s/2).stroke({color:n.stroke,width:Vt(a.targetLineWidth,this.em)});void 0!==n.dasharray&&r.attr("stroke-dasharray",n.dasharray),0===d&&this.drawText(t,this.targetLabel(),i,e-.35*h,{anchor:"middle"}),$=Math.max($,i)}$=Math.max($,S),this.drawValueText(t,o[d],$+a.labelToBar*h,g,u);const M=x.ticks(4),_=oa.tickDecimals(M),O=p+n;for(const i of M){const s=x.scale(i);t.line(s,O,s,O+a.axisTickLength*h).stroke({color:this.styles.axisStyles.ac.stroke,width:Vt(a.axisLineWidth,this.em)}),this.drawText(t,ra.number(i,"decimal",_,_,1,this.styles.locale),s,O+a.tickStripHeight*h-.2*h,{anchor:"middle"})}}))}drawValueText(t,i,s,e,n){""!==i&&this.drawText(t,i,s,e+.35*this.em,{}).attr(ji(this.rowKey(n),"label"))}rowKey(t){return Object.assign(Object.assign({},Bi(this.config.level,t.category)),{scenario:this.config.actual.measure})}}class Ia{constructor(){this.rowHeight=1.9,this.barHeight=.66,this.varianceHeight=.4,this.targetTickHeight=1.1,this.targetLineWidth=.15,this.axisLineWidth=.075,this.labelToBar=.3,this.labelToAxis=.3,this.axisTickLength=.35,this.tickStripHeight=1.2}}class Ya{adapt(t){const i=new Ia;return R.isNumber(t.rowHeight)&&(i.rowHeight=t.rowHeight),R.isNumber(t.barHeight)&&(i.barHeight=t.barHeight),R.isNumber(t.varianceHeight)&&(i.varianceHeight=t.varianceHeight),R.isNumber(t.targetTickHeight)&&(i.targetTickHeight=t.targetTickHeight),R.isNumber(t.targetLineWidth)&&(i.targetLineWidth=t.targetLineWidth),R.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),R.isNumber(t.labelToBar)&&(i.labelToBar=t.labelToBar),R.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),R.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),R.isNumber(t.tickStripHeight)&&(i.tickStripHeight=t.tickStripHeight),i}default(){return new Ia}}class Ba{constructor(t,i,s,e,n,r){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=e,this.varianceStyles=n,this.padding=r,this.rangeColors=["#D9D9D9","#EFEFEF"],this.locale="de"}}class Ha{constructor(t,i,s,e,n){this.scaleFactorsBulletChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=e,this.paddingAdapter=n}adapt(t){const i=this.default();return R.isExisting(t)&&(R.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsBulletChartAdapter.adapt(t.scaleFactors)),R.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),R.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),R.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),R.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),R.isExisting(t.padding)&&(i.padding=this.paddingAdapter.adapt(t.padding)),Array.isArray(t.rangeColors)&&t.rangeColors.length>0&&(i.rangeColors=t.rangeColors)),i}default(){return new Ba(this.scaleFactorsBulletChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingAdapter.default())}}const Va=["bullet-target-missing","bullet-target-invalid","bullet-actual-negative","bullet-mixed-operation","bullet-target-none"],Xa=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.chartTitle="",this.target=null,this.ranges=[],this.normalizeMode="target",this.showVariances=!0,this.level=G.CATEGORY,this.limit=0,this.filter="",this.i18n=new Map,this.containerWidth=0,this.svgMarkup="",a(this)}getDb(){return this.stores||(this.stores=c(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=$(this.getDb(),this.tableName,this.filter);this.chart=new ja(new Cs(this.ruleSetConfig),this.getDb(),i,{chartTitle:this.chartTitle,actual:this.actual,target:this.target,ranges:this.ranges,normalize:this.normalizeMode,showVariances:this.showVariances,level:this.level,order:this.order,limit:this.limit,labels:this.labels},t,this.containerWidth||0),this.chart.setI18n(this.i18n),this.svgMarkup=this.chart.hasNoData()?"":this.chart.toString(),this.syncWarnings(this.chart.getWarnings()),ui(this.errors,this.chart.getQueryError())}syncWarnings(t){if(void 0===this.errors)return;const i=new Map(t.map((t=>[t.code,t.data])));for(const t of Va){const s=`WARN_${t.replace(/-/g,"_")}`;if(i.has(t)){const e=void 0!==this.translator?this.translator(`.${t}`,i.get(t)):t;this.errors.addOrReplace({id:s,type:"warning",message:e})}else this.errors.remove(s)}}prepareStyle(){var t,i;const s=new Ha(new Ya,new Ws,new Is(new Gs),new Ga(new Gs),new zs).adapt(this.styles);return s.locale=(null===(i=null===(t=c(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}render(){var t;if(void 0===this.chart||void 0!==this.chart.getQueryError())return i(s,null);if(this.chart.hasNoData()){const e=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return i(s,{class:"no-data"},i("div",{class:"empty-state"},e))}return i(s,null,i("div",{innerHTML:this.svgMarkup}))}get element(){return e(this)}};Xa.style=':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}';const Ja={rowGroup:0,category:1,subCategory:2},qa=class{validateFilter(t){const i="ERR_filter";v(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateX(t){this.validateAxisSpec("x",t)}validateY(t){this.validateAxisSpec("y",t)}validateIso(t){this.validateObjectSpec("iso",t,null,(t=>gs(t)))}validateLevel(t){const i="WARN_level",s=["auto","category","subcategory"];N(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateSeriesLevel(t){const i="WARN_seriesLevel",s=["auto","rowgroup","category","none"];N(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`series-level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateFacet(t){this.validateObjectSpec("facet",t,null,(t=>ws(t)))}validateLabels(t){this.validateObjectSpec("labels",t,null,(t=>bs(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,null,(t=>Ss(t)))}validateAspect(t){const i="WARN_aspect";N(t)||null!==this.parseAspect(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`aspect: invalid value '${t}' - expected "w:h" (e.g. "16:9"); using the default.`})}validateLimit(t){const i="WARN_limit";L(t)&&Number(t)>=0?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`limit: invalid value '${t}' - expected a non-negative integer; using 0.`})}validateScale(t){const i="WARN_scale";if(N(t))return void this.errors.remove(i);const{mode:s,factor:e}=Ht(t);"factor"===s&&(void 0===e||e<=0)?this.errors.addOrReplace({id:i,type:"warning",message:`scale: invalid value '${t}' - expected none/auto or a positive number.`}):this.errors.remove(i)}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.chartTitle="",this.filter="",this.iso="",this.level="auto",this.seriesLevel="auto",this.facet="",this.labels="",this.legend="",this.aspect="16:9",this.limit=0,this._autoScaleGuard=!1,this._lastObservedWidth=0,this.translateForInner=(t,i)=>this.t(t,i),E(this),a(this),Yt(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.errors=l(this),this.componentStyle=k(this),this.ruleSetConfig=es(this),this.t=Bt(this).t}componentWillLoad(){this.validateFilter(this.filter),this.validateX(this.x),this.validateY(this.y),this.validateIso(this.iso),this.validateLevel(this.level),this.validateSeriesLevel(this.seriesLevel),this.validateFacet(this.facet),this.validateLabels(this.labels),this.validateLegend(this.legend),this.validateAspect(this.aspect),this.validateLimit(this.limit),this.validateScale(this.scale)}componentDidRender(){$s(this.element,"bn-chart-scatter-renderer");const{mode:t}=Ht(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{width:s}=Ut(i);if(s<=0)return void this.checkOverflow();this._lastObservedWidth=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),n=i.scrollWidth,o=this.appliedScaleFactor;if(!Number.isFinite(n)||n<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const h=Math.max(.3,o*(s-1)/n);Math.abs(h-o)<.01||(i.style.setProperty("--bn-font-size",e*h+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${h.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,r((()=>{this.appliedScaleFactor=h}))),this.checkOverflow()}checkOverflow(){is(this.element,"bn-chart-scatter-renderer",this.errors)}componentDidLoad(){this.layoutObserver=ss(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=Ut(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2?(this._lastObservedWidth=t,n(this)):this.checkOverflow()})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=Ut(this.element);this._lastObservedWidth=t,n(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{points:"auto",values:!1,max:12}}setBlockingError(t,i){null===i?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:i}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateAxisSpec(t,i){var s;const e=`ERR_xy_json_${t}`,n=`ERR_xy_measure_${t}`,r=`WARN_xy_fields_${t}`,o="x"===t||"y"===t||"size"===t,{data:h,parseError:a}=rs(i,"measure");if(a)return this.setBlockingError(e,this.t(".xy-prop-json",{prop:t})),this.setBlockingError(n,null),void this.errors.remove(r);if(this.setBlockingError(e,null),null===h)return this.setBlockingError(n,o?this.t(".xy-measure-invalid",{prop:t,measure:""}):null),void this.errors.remove(r);const l="share"===t?null:cs(h),c=null!==(s=h.measure)&&void 0!==s?s:"";T(c)?this.setBlockingError(n,null):this.setBlockingError(n,this.t(".xy-measure-invalid",{prop:t,measure:c})),this.reportSpecIssues(r,t,l)}validateObjectSpec(t,i,s,e){const n=`ERR_xy_json_${t}`,r=`WARN_xy_fields_${t}`,{data:o,parseError:h}=rs(i,s);if(h)return this.setBlockingError(n,this.t(".xy-prop-json",{prop:t})),void this.errors.remove(r);this.setBlockingError(n,null),null!==o?this.reportSpecIssues(r,t,e(o)):this.errors.remove(r)}reportSpecIssues(t,i,s){const e=[];null!==s&&s.invalidFields.length>0&&e.push(`invalid: ${s.invalidFields.join(", ")}`),null!==s&&s.unknownKeys.length>0&&e.push(`unknown: ${s.unknownKeys.join(", ")}`),e.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${i}: ignored sub-fields (${e.join("; ")}).`}):this.errors.remove(t)}prepareAxis(t,i){const{data:s,parseError:e}=rs(i,"measure");if(e||null===s)return null;const{config:n}=cs(s);return null!==n&&T(n.measure)?(void 0!==n.min&&void 0!==n.max&&n.min>=n.max?(this.errors.addOrReplace({id:`WARN_xy_domain_${t}`,type:"warning",message:`${t}: min must be smaller than max; the override is ignored.`}),n.min=void 0,n.max=void 0):this.errors.remove(`WARN_xy_domain_${t}`),n):null}prepareIso(){const{data:t,parseError:i}=rs(this.iso,null);return i||null===t?null:gs(t).config}prepareLabels(){const t=this.labelDefaults(),{data:i,parseError:s}=rs(this.labels,null);return s||null===i?{points:t.points,values:t.values,max:t.max}:bs(i,t).config}prepareLegend(){const{data:t,parseError:i}=rs(this.legend,null);return i||null===t?{show:!0,position:"right"}:Ss(t).config}prepareFacet(){const{data:t,parseError:i}=rs(this.facet,null);return i||null===t?null:ws(t).config}preparePointLevel(){var t,i;const s=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("category"===s)return"category";if("subcategory"===s)return"subCategory";const e=null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel;return"rowGroup"===e||"category"===e||"subCategory"===e?e:"category"}prepareSeriesLevel(t){var i;const s=null===(i=this.seriesLevel)||void 0===i?void 0:i.trim().toLowerCase();return"none"===s?null:"rowgroup"===s?"rowGroup":"category"===s||"subCategory"===t?"category":"category"===t?"rowGroup":null}validateCrossProp(t,i){const s=new Set;for(const i of t){if(void 0===i)continue;const t=C(i);null!==t&&"scenario"===t.kind&&s.add(P(t.slot))}this.setBlockingError("ERR_xy_family",s.size>1?this.t(".xy-family-mixed",{families:[...s].join(", ")}):null);const e=this.preparePointLevel(),n=this.prepareSeriesLevel(e),r=null!==i?"rowgroup"===i.level?"rowGroup":"category":null;let o=null;if(null!==n&&Ja[n]>=Ja[e]&&(o=`series '${n}' vs point '${e}'`),null!==r){const t=null!=n?n:e;Ja[r]>=Ja[t]&&(o=`facet '${r}' vs '${t}'`)}this.setBlockingError("ERR_xy_level_order",null!==o?this.t(".xy-level-order",{detail:o}):null)}parseAspect(t){const i=/^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/.exec(null!=t?t:"");if(null===i)return null;const s=Number(i[1]),e=Number(i[2]);return s<=0||e<=0?null:s/e}prepareAspect(){var t;return null!==(t=this.parseAspect(this.aspect))&&void 0!==t?t:16/9}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}i18nLocalKeys(){return["no-data","axis.in","legend.title"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),i=new Map(p.map((t=>[t,this.t("global.".concat(t))])));return new Map([...i.entries(),...t.entries()])}prepareStyle(){const t=this.getEffectiveScaleFactor(),i=this.element.localName;return this.componentStyle((s=>{const e=s.global.fontSizePx*t;return{scaleFactors:s[i].scaleFactors,fontStyles:{font:`${e}px ${s.global.fontFamily}`,size:e,color:s.global.fontColor,background:s.global.fontBackgroundColor,leading:1.8},axisStyles:s[i].axisStyles,seriesColors:s[i].seriesColors,padding:s[i].padding}}))}async getBaseline(){return Ui(this.element,"bn-chart-scatter-renderer")}async getLayoutState(t){var i;const s=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",e=ei(this.element),n=this.getEffectiveScaleFactor(),r=Number.isFinite(n)&&n>0?n:1,o=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*r;return ts(this.element,"bn-chart-scatter-renderer",this.chartTitle||void 0,{fontSizePx:o,appliedScaleFactor:r},e,s)}getEffectiveScaleFactor(){const{mode:t,factor:i}=Ht(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const o=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":o*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const i of["ac","pp","fc","pl"])for(const s of[1,2,3,4])t[`${i}${s}`]={type:"number",isOptional:!0,description:""};for(const[i,s]of Object.entries(this.mappedAxes())){if(null===s)continue;const e=C(s.measure);null!==e&&("scenario"===e.kind?t[e.slot].description=`${i}: ${"label"in s&&void 0!==s.label?s.label:s.measure}`:(t[e.measure.base].description=`${i}: ${s.measure} (base)`,t[e.measure.delta].description=`${i}: ${s.measure} (delta)`))}return{[this.dataStructureName()]:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}mappedAxes(){return{x:this.prepareAxis("x",this.x),y:this.prepareAxis("y",this.y)}}dataStructureName(){return"IScatterChartDataRow"}chartTemplate(){const t=this.prepareAxis("x",this.x),s=this.prepareAxis("y",this.y),e=this.prepareFacet();if(this.validateCrossProp([null==t?void 0:t.measure,null==s?void 0:s.measure],e),this.hasBlockingErrors()||null===t||null===s)return null;const n=this.preparePointLevel(),r=this.prepareI18n(),o=this.prepareStyle(),h=Ut(this.element).width;return i("bn-chart-scatter-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,x:t,y:s,iso:this.prepareIso(),labels:this.prepareLabels(),legend:this.prepareLegend(),facet:e,pointLevel:n,seriesLevel:this.prepareSeriesLevel(n),aspect:this.prepareAspect(),limit:this.prepareLimit(),filter:this.filter,styles:o,i18n:r,containerWidth:h,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return i(s,{key:"4947af836a9c76b089bc07fb1f4df8c248aa4f62",style:this.getFontStyles()},i("div",{key:"16abbc30d255d224aefecf9e337d3b23d449828a",class:"container"},this.chartTemplate()))}get element(){return e(this)}static get watchers(){return{filter:[{validateFilter:0}],x:[{validateX:0}],y:[{validateY:0}],iso:[{validateIso:0}],level:[{validateLevel:0}],seriesLevel:[{validateSeriesLevel:0}],facet:[{validateFacet:0}],labels:[{validateLabels:0}],legend:[{validateLegend:0}],aspect:[{validateAspect:0}],limit:[{validateLimit:0}],scale:[{validateScale:0}]}}};qa.style=':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:column}';class Ka{constructor(t,i){this.xScale=t,this.yScale=i}isPositiveDomain(){return this.xScale.domainMin>0&&this.yScale.domainMin>0}static autoK(t){const i=t.filter((t=>t>0)).sort(((t,i)=>t-i));if(0===i.length)return[];const s=t=>i[Math.min(i.length-1,Math.floor(t*i.length))];let e=Ka.ladderValues(s(.25),s(.75));if(e.length<2&&(e=Ka.ladderValues(i[0],i[i.length-1])),0===e.length)return[];if(1===e.length)return e;if(e.length<=4)return e;const n=[];for(let t=0;t<4;t++)n.push(e[Math.round(t*(e.length-1)/3)]);return[...new Set(n)]}static ladderValues(t,i){if(t<=0||i<t)return[];const s=[];for(let e=Math.floor(Math.log10(t))-1;e<=Math.ceil(Math.log10(i));e++)for(const n of[1,2,5]){const r=n*Math.pow(10,e);r>=t&&r<=i&&s.push(r)}return s}visibleRange(t){if(!this.isPositiveDomain()||t<=0)return null;const i=Math.max(this.xScale.domainMin,t/this.yScale.domainMax),s=Math.min(this.xScale.domainMax,t/this.yScale.domainMin);return i>=s?null:[i,s]}samples(t){const i=this.visibleRange(t);if(null===i)return null;const[s,e]=i,n=[];for(let i=0;i<64;i++){const r=s*Math.pow(e/s,i/63);n.push({x:this.xScale.scale(r),y:this.yScale.scale(t/r)})}return n}path(t){const i=this.samples(t);return null===i?null:i.map(((t,i)=>`${0===i?"M":"L"} ${t.x} ${t.y}`)).join(" ")}exitPoint(t){const i=this.visibleRange(t);if(null===i)return null;const s=i[1],e=s>=this.xScale.domainMax-1e-9*Math.abs(this.xScale.domainMax);return{x:this.xScale.scale(s),y:this.yScale.scale(t/s),edge:e?"right":"bottom"}}regionPath(t){if(!this.isPositiveDomain()||t<=0)return null;const i=this.xScale.domainMin,s=this.xScale.domainMax,e=this.yScale.domainMin,n=this.yScale.domainMax,r=this.xScale.scale(i),o=this.xScale.scale(s),h=this.yScale.scale(n),a=this.yScale.scale(e);if(t>=s*n)return null;if(t<=i*e)return`M ${r} ${h} L ${o} ${h} L ${o} ${a} L ${r} ${a} Z`;const l=this.samples(t),[c,u]=this.visibleRange(t),d=c>i,f=u>=s-1e-9*Math.abs(s),v=l.map(((t,i)=>`${0===i?"M":"L"} ${t.x} ${t.y}`));return f||v.push(`L ${o} ${a}`),v.push(`L ${o} ${h}`),d||v.push(`L ${r} ${h}`),v.push("Z"),v.join(" ")}}class Qa{constructor(t,i,s,e,n,r){var o,h;this.ruleSet=t,this.config=e,this.styles=n,this.availableWidth=r,this.warnings=[],this.canvasHeight=0,this.i18nMap=new Map,this.config=Object.assign(Object.assign({},e),{x:D(e.x),y:D(e.y)});const a=new Sa;let l=[];try{""!==s&&(l=i.exec(`SELECT * FROM ${s}`))}catch(t){this.queryError=ci(t)}const c=(null!=l?l:[]).map((t=>a.adapt(t)));this.data=ka(c,{pointLevel:e.pointLevel,seriesLevel:e.seriesLevel,facetLevel:null!==e.facet?"rowgroup"===e.facet.level?"rowGroup":"category":null,measures:{x:null!==(o=C(e.x.measure))&&void 0!==o?o:{kind:"scenario",slot:"ac1"},y:null!==(h=C(e.y.measure))&&void 0!==h?h:{kind:"scenario",slot:"ac2"}},domains:{x:{min:this.config.x.min,max:this.config.x.max},y:{min:this.config.y.min,max:this.config.y.max}},limit:e.limit,limitBy:"order"}),this.warnings.push(...this.data.warnings)}get em(){return this.styles.fontStyles.size}get xPercent(){return z(this.config.x.measure)}get yPercent(){return z(this.config.y.measure)}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,i=!1){const s=Qh(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:i?"bold":"normal"}).width;return Number.isFinite(s)&&s>0?s:.6*t.length*this.em}drawText(t,i,s,e,n={}){var r,o,h;return t.text(i).font({size:null!==(r=n.size)&&void 0!==r?r:this.styles.fontStyles.size,weight:n.bold?"bold":"normal",anchor:null!==(o=n.anchor)&&void 0!==o?o:"start"}).fill(null!==(h=n.color)&&void 0!==h?h:this.styles.fontStyles.color).attr({x:s,y:e,"font-family":this.fontFamily()})}hasNoData(){return 0===this.data.totalPoints}getWarnings(){return this.warnings}getQueryError(){return this.queryError}getAllocatedCanvasWidth(){return this.availableWidth}getAllocatedCanvasHeight(){return this.canvasHeight}axisTitle(t,i){var s;const e=null!==(s=t.label)&&void 0!==s?s:"";return""===e?"":void 0===t.unit||""===t.unit?e:`${e} ${i} ${t.unit}`}setI18n(t){this.i18nMap=t}legendModel(){const t=this.data.series.map((t=>{var i;return{label:""===t.key?null!==(i=this.ruleSet.getScenario("").name)&&void 0!==i?i:"Series":t.key,treatment:this.seriesTreatment(t.index)}}));return{sizeCaption:[],title:this.i18nMap.get("legend.title")||null,compareEntries:[],entries:t}}primaryColorIndex(){const t=C(this.config.x.measure);return null===t||"variance"===t.kind?10:this.ruleSet.getScenarioColorIndex(t.slot)}seriesTreatment(t){const{color:i,overflowed:s}=w(t,this.styles.seriesColors);return s&&this.addWarningOnce("xy-series-overflow",{}),x(this.primaryColorIndex(),i,"dot")}addWarningOnce(t,i){this.warnings.some((i=>i.code===t))||this.warnings.push({code:t,data:i})}toString(){const t=new uh;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}draw(t){var i,s,e,n,r,o,h,a,l,c;this.warnings=this.data.warnings.slice();const u=this.em,d=this.styles.padding,f=this.i18nMap.get("axis.in")||"in",v=t.group(),p=new ya(this.styles),g=this.legendModel(),m=this.config.legend.show&&g.entries.length>0,b=m?p.measure(g,this.config.legend.position):{width:0,height:0},y=null!==this.config.iso,w=y?Math.max(3*u,...this.isoValueLabels().map((t=>this.textWidth(t)+u)),this.textWidth(null!==(i=this.config.iso.label)&&void 0!==i?i:"",!0)+u,this.textWidth(void 0!==this.config.iso.unit&&""!==this.config.iso.unit?`${f} ${this.config.iso.unit}`:"")+u):0,x="right"===this.config.legend.position?Math.max(m?b.width+u:0,w):w,S=""!==this.config.chartTitle?1.6*u:0,$=this.axisTitle(this.config.y,f),M=this.axisTitle(this.config.x,f),_=""!==$?1.4*u:.4*u,O=1.4*u+(""!==M?1.3*u:0);let k,A=3*u,R={x:0,y:0,width:0,height:0},N=[];const L=Math.max(1,this.data.facets.length),E=null===(s=this.config.facet)||void 0===s?void 0:s.columns,T=oa.domain(null!==(n=null===(e=this.data.extents)||void 0===e?void 0:e.xMin)&&void 0!==n?n:0,null!==(o=null===(r=this.data.extents)||void 0===r?void 0:r.xMax)&&void 0!==o?o:1,{min:this.config.x.min,max:this.config.x.max}),C=oa.domain(null!==(a=null===(h=this.data.extents)||void 0===h?void 0:h.yMin)&&void 0!==a?a:0,null!==(c=null===(l=this.data.extents)||void 0===l?void 0:l.yMax)&&void 0!==c?c:1,{min:this.config.y.min,max:this.config.y.max});for(let t=0;t<2;t++){const t=Math.max(10,this.availableWidth-d.left-d.right-A-x);R={x:d.left+A,y:d.top+S+_,width:t,height:t/this.config.aspect},k=new sa(L,E,R,this.styles.scaleFactors.panelGap*u);const i=k.panelRect(0).height,s=Math.max(4,Math.min(8,Math.round(i/(4*u)))),e=new oa(C[0],C[1],i,0);N=e.ticks(s);const n=aa(N,this.yPercent);A=Math.max(...N.map((t=>this.textWidth(ha(t,n,this.styles.locale,this.yPercent)))),u)+this.styles.scaleFactors.axisTickLength*u+.4*u}this.canvasHeight=R.y+R.height+O+("bottom"===this.config.legend.position&&m?b.height+u:0)+d.bottom,""!==this.config.chartTitle&&this.drawText(v,this.config.chartTitle,d.left,d.top+u,{bold:!0}),""!==$&&this.drawAxisTitleText(v,this.config.y,f,d.left,R.y-.6*u,"start");const P=this.buildPanels(k,T,C),W=P[0].xScale.ticks(Math.max(3,Math.min(8,Math.round(P[0].rect.width/(7*u))))),D=aa(W,this.xPercent),z=aa(N,this.yPercent);let U=!1;y&&(T[0]>0&&C[0]>0?U=!0:this.addWarningOnce("xy-iso-domain",{})),0===this.data.facets.length?this.drawPanel(v,P[0],{key:"",points:[]},W,N,D,z,!0,!0,U):this.data.facets.forEach(((t,i)=>{this.drawPanel(v,P[i],t,W,N,D,z,k.isOuterLeft(i),k.isOuterBottom(i),U,this.data.facets.length>1?t.key:"")})),""!==M&&this.drawAxisTitleText(v,this.config.x,f,R.x+R.width,R.y+R.height+2.6*u,"end"),m&&("right"===this.config.legend.position?p.draw(v,g,R.x+R.width+u,R.y,"right"):p.draw(v,g,R.x,R.y+R.height+O,"bottom")),t.group().addClass("annotations")}drawAxisTitleText(t,i,s,e,n,r){var o;const h=null!==(o=i.label)&&void 0!==o?o:"",a=void 0!==i.unit&&""!==i.unit?`${s} ${i.unit}`:"",l=.3*this.em;"start"===r?(this.drawText(t,h,e,n,{bold:!0}),""!==a&&this.drawText(t,a,e+this.textWidth(h,!0)+l,n,{})):""!==a?(this.drawText(t,a,e,n,{anchor:"end"}),this.drawText(t,h,e-this.textWidth(a)-l,n,{anchor:"end",bold:!0})):this.drawText(t,h,e,n,{anchor:"end",bold:!0})}buildPanels(t,i,s){const e=[];for(let n=0;n<t.count;n++){const r=t.panelRect(n),o=new oa(i[0],i[1],r.x,r.x+r.width),h=new oa(s[0],s[1],r.y+r.height,r.y);e.push({rect:r,xScale:o,yScale:h,frame:new ba(o,h,r,this.styles)})}return e}drawPanel(t,i,s,e,n,r,o,h,a,l,c=""){var u,d;const f=t.group(),v=this.em;i.frame.drawBands(f,this.config.x.highlight,this.config.y.highlight),i.frame.drawGrid(f,n,void 0===this.config.x.refLine&&void 0===this.config.y.refLine&&i.rect.width>30*v?e:void 0),l&&null!==this.config.iso&&this.drawIso(f,i),i.frame.drawRefLines(f,this.config.x.refLine,this.config.y.refLine),i.frame.drawFrame(f);const p=this.styles.scaleFactors.pointRadius*v,g=new ga(i.rect,this.styles.scaleFactors.labelToMark*v),m=[];for(const t of s.points){const e=null!==(d=null===(u=this.data.series.find((i=>i.key===t.seriesKey)))||void 0===u?void 0:u.index)&&void 0!==d?d:0,n=this.seriesTreatment(e),r=i.xScale.scale(t.x),o=i.yScale.scale(t.y);m.push({point:t,cx:r,cy:o,treatment:n});const h=f.circle(2*p).center(r,o).fill(n.fill).stroke({color:n.stroke,width:n.strokeWidth}).attr(ji(Xh(t,s.key,this.config),"element"));void 0!==n.dasharray&&h.attr("stroke-dasharray",n.dasharray),g.registerMark(r,o,p)}this.drawPointLabels(f,g,m,p,s.key),i.frame.drawTickLabels(f,{ticksX:e,ticksY:n,xDecimals:r,yDecimals:o,xPercent:this.xPercent,yPercent:this.yPercent,showXLabels:a,showYLabels:h}),""!==c&&i.frame.drawPanelTitle(f,c)}drawPointLabels(t,i,s,e,n){const r=s.reduce(((t,i)=>t+i.cx),0)/Math.max(1,s.length),o=s.reduce(((t,i)=>t+i.cy),0)/Math.max(1,s.length),h=[...s].sort(((t,i)=>Math.hypot(i.cx-r,i.cy-o)-Math.hypot(t.cx-r,t.cy-o))),{selected:a,unknownNames:l}=i.selectCandidates(h,this.config.labels.points,this.config.labels.max,(t=>t.point.name));l.length>0&&this.addWarningOnce("xy-label-unknown",{names:l.join(", ")});const c=new Map,u=a.map((t=>{const i={name:t.point.name,cx:t.cx,cy:t.cy,r:e,width:this.textWidth(t.point.name),height:1.1*this.em};return c.set(i,t.point),i}));for(const s of i.place(u))this.drawText(t,s.candidate.name,s.x,s.y+.9*s.candidate.height,{}).attr(ji(Xh(c.get(s.candidate),n,this.config),"label"))}drawIso(t,i){const s=this.config.iso,e=new Ka(i.xScale,i.yScale),n=this.i18nMap.get("axis.in")||"in",r=this.isoValues(),o=this.isoValueLabels();if(void 0!==s.highlight){const i=e.regionPath(s.highlight.from);null!==i&&t.path(i).fill(this.styles.axisStyles.pl.fill).stroke("none")}const h={color:this.styles.axisStyles.fc.stroke,width:Vt(this.styles.scaleFactors.gridLineWidth,this.em)};let a=null;for(const[i,s]of r.entries()){const n=e.path(s);if(null===n)continue;t.path(n).fill("none").stroke(h);const r=e.exitPoint(s);null!==r&&(this.drawText(t,o[i],r.x+.4*this.em,"right"===r.edge?r.y+.35*this.em:r.y-.5*this.em,{}),(null===a||r.y<a.y)&&(a=r))}if(null!==a&&void 0!==s.label&&""!==s.label){const i=void 0!==s.unit&&""!==s.unit?`${n} ${s.unit}`:"";this.drawText(t,s.label,a.x+.4*this.em,a.y-1.6*this.em,{bold:!0}),""!==i&&this.drawText(t,i,a.x+.4*this.em,a.y-.5*this.em,{})}}isoValues(){const t=this.config.iso;return"auto"!==t.values?t.values:Ka.autoK(this.data.facets.flatMap((t=>t.points.map((t=>t.x*t.y)))))}isoValueLabels(){const t=this.isoValues(),i=Math.max(0,...t.map((t=>oa.stepDecimals(Math.abs(t)))));return t.map((t=>ha(t,i,this.styles.locale)))}}const Za=["xy-duplicate-point","xy-point-clipped","xy-variance-nodata","xy-iso-domain","xy-label-unknown","xy-series-overflow","xy-point-budget"],tl=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.chartTitle="",this.iso=null,this.facet=null,this.pointLevel="category",this.seriesLevel=null,this.aspect=16/9,this.limit=0,this.filter="",this.i18n=new Map,this.containerWidth=0,this.svgMarkup="",a(this)}getDb(){return this.stores||(this.stores=c(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=$(this.getDb(),this.tableName,this.filter);this.chart=new Qa(new Cs(this.ruleSetConfig),this.getDb(),i,{chartTitle:this.chartTitle,x:this.x,y:this.y,iso:this.iso,labels:this.labels,legend:this.legend,facet:this.facet,pointLevel:this.pointLevel,seriesLevel:this.seriesLevel,aspect:this.aspect,limit:this.limit},t,this.containerWidth||0),this.chart.setI18n(this.i18n),this.svgMarkup=this.chart.hasNoData()?"":this.chart.toString(),this.syncWarnings(this.chart.getWarnings()),ui(this.errors,this.chart.getQueryError())}syncWarnings(t){if(void 0===this.errors)return;const i=new Map(t.map((t=>[t.code,t.data])));for(const t of Za){const s=`WARN_${t.replace(/-/g,"_")}`;if(i.has(t)){const e=void 0!==this.translator?this.translator(`.${t}`,i.get(t)):t;this.errors.addOrReplace({id:s,type:"warning",message:e})}else this.errors.remove(s)}}prepareStyle(){var t,i;const s=new Bs(new Vs,new Ws,new Is(new Gs),new zs).adapt(this.styles);return s.locale=(null===(i=null===(t=c(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}render(){var t;if(void 0===this.chart||void 0!==this.chart.getQueryError())return i(s,null);if(this.chart.hasNoData()){const e=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return i(s,{class:"no-data"},i("div",{class:"empty-state"},e))}return i(s,null,i("div",{innerHTML:this.svgMarkup}))}get element(){return e(this)}};tl.style=':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}';const il=class{validateFilter(t){const i="ERR_filter";v(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(Gt(t))return void this.errors.remove(i);const s=B(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(Gt(t))return void this.errors.remove(i);const s=H(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateUnitScaling(t){const i="WARN_unitScaling";N(t)?this.errors.remove(i):"invalid"===Xt(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="WARN_percentageScaling";N(t)?this.errors.remove(i):"invalid"===Xt(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validateLevel(t){const i="WARN_level";N(t)||V(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"level: invalid value(s) '"+t+"' are not supported."})}validateOrderList(t){const i="WARN_order";if(Gt(t))return void this.errors.remove(i);const s=U(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="WARN_orderDirection";Gt(t)||N(t)||F(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateLimit(t){const i="WARN_limit";L(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";X(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateStack(t){const i="WARN_stack",s=J(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:s.join("; ")}):this.errors.remove(i)}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("WARN_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"WARN_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("WARN_scale")}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this._lastScaledParentHeight=0,this.chartTitle="",this.filter="",this.limit=0,this.showCategories=!0,this.measureScale="greatest",this.showMeasureScale=!1,this.measureUnit="",this.stack="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=t=>{var i,s,e,n,r,o;this.lastAutoScalingReport={unit:null!==(i=t.unit)&&void 0!==i?i:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(e=t.percentage)&&void 0!==e?e:null===(n=this.lastAutoScalingReport)||void 0===n?void 0:n.percentage};const h=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),a=this.getEffectiveFontPx();if(void 0!==t.unit&&t.unit>0&&this.autoUnitWarningActive){const i=a/t.unit;h(i,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=i,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${il.describeScalingInput(String(null!==(r=this.unitScaling)&&void 0!==r?r:"").trim())}, auto-fitted to 1 em ≈ ${Jt(i)} units.`}))}if(void 0!==t.percentage&&t.percentage>0&&this.autoPctWarningActive){const i=100*a/t.percentage;h(i,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=i,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${il.describeScalingInput(String(null!==(o=this.percentageScaling)&&void 0!==o?o:"").trim())}, auto-fitted to 1 em ≈ ${Jt(i)} percentage points.`}))}},E(this),a(this),Yt(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=l(this),ns(this),this.componentStyle=k(this),this.ruleSetConfig=es(this),this.t=Bt(this).t,this.resolveInherited=qt(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}],this.errors)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateMeasureScale(this.measureScale),this.validateStack(this.stack),this.validateScaling(this.scale)}componentDidRender(){$s(this.element,"bn-chart-structure-renderer");const{mode:t}=Ht(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{height:s}=Ut(i);if(s<=0)return void this.checkOverflow();this._lastScaledParentHeight=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),n=i.scrollHeight,o=this.appliedScaleFactor;if(n<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const h=Math.max(.3,o*(s-1)/n);Math.abs(h-o)<.01||(i.style.setProperty("--bn-font-size",e*h+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${h.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,r((()=>{this.appliedScaleFactor=h}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=ss(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=Ut(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,n(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=Ut(this.element);this._lastScaledParentHeight=t,n(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}measureContentWidth(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-structure-renderer");let s=0,e=!1;return null==i||i.forEach((t=>{var i,n,r;const o=parseFloat(null!==(r=null===(n=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===n?void 0:n.getAttribute("width"))&&void 0!==r?r:"");Number.isNaN(o)||(s+=o,e=!0)})),e?Math.max(Math.floor(s),this.element.scrollWidth):this.element.scrollWidth}checkOverflow(){const t=Ut(this.element),i=this.measureContentWidth(),s=this.element.scrollHeight,e=t.width>0&&i>t.width+1,n=t.height>0&&s>t.height+1;if(!e&&!n)return void M(this.errors,null);const r=this.prepareVariances().some((t=>t.startsWith("dr"))),o="value"===Xt(this.unitScaling,this.pixelPerUnitGroupMap).kind,h=r&&"value"===Xt(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:a}=Ht(this.scale),l="auto"!==a&&"empty"!==a,c=[];e&&o&&c.push("unit-scaling"),e&&h&&c.push("percentage-scaling"),n&&l&&c.push("scale");const u=[];e&&u.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),n&&u.push(`height (${Math.round(s)}px > ${Math.round(t.height)}px)`),M(this.errors,`Chart exceeds available ${u.join(" and ")}. `+(c.length>0?`Adjust ${c.join(" / ")} or set to "auto".`:"Content does not fit even at minimum auto scaling; enlarge the container."),c.length>0)}prepareDimension(){const t=Ut(this.element),i=this.prepareVariances();return this.canvasWidthSegmented=t.width/(1+i.length),{width:this.canvasWidthSegmented,height:t.height}}prepareScenarios(){var t,i,s,e;const n=this.resolveInherited("scenarios",this.scenarios);if(n.inherited)return this.errors.remove("AUTO_scenarios"),n.value.split(",").map((t=>t.trim()));const r="auto"===(null===(t=n.value)||void 0===t?void 0:t.trim().toLowerCase());return N(n.value)||r?(null===(s=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===s?void 0:s.length)>0?(r||n.unresolved?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(e=n.value)||void 0===e?void 0:e.split(",").map((t=>t.trim())))}prepareVariances(){const t=this.resolveInherited("variances",this.variances).value;return N(t)?[]:null==t?void 0:t.split(",").map((t=>t.trim()))}prepareHideCategories(t){return t>=1||!this.showCategories}prepareI18n(){const t=p,i=new Map(["no-data","REST"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries(),...Ts(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const t=Xt(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/t.value):"auto"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${il.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const t=Xt(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/t.value):"auto"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${il.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}prepareLevel(){var t,i,s;const e="auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase());return N(this.level)||e?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?(e?this.errors.remove("AUTO_level"):this.errors.addOrReplace({id:"AUTO_level",type:"warning",message:`level: not set, auto-detected: ${this.datasetMeta.suggestedLevel}`}),G[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),G[null===(s=this.level)||void 0===s?void 0:s.toUpperCase()])}prepareOrder(){var t;const i=this.resolveInherited("order",this.order),s=i.value,e=this.resolveInherited("orderDirection",this.orderDirection).value,n="auto"===(null==s?void 0:s.trim().toLowerCase());let r;return N(s)||n?(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)?(n||i.unresolved?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:`order: not set, auto-detected: ${this.datasetMeta.suggestedOrder}`}),r=this.datasetMeta.suggestedOrder):r=s:(this.errors.remove("AUTO_order"),r=s),{hierarchy:null==r?void 0:r.split(",").map((t=>Y[null==t?void 0:t.toUpperCase()])),direction:j[null==e?void 0:e.toUpperCase()]}}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const s=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-structure"].scaleFactors.scenarioOffset,scenarioLabelToBar:i["bn-chart-structure"].scaleFactors.scenarioLabelToBar,labelToBar:i["bn-chart-structure"].scaleFactors.labelToBar,labelToAxis:i["bn-chart-structure"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-structure"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-structure"].scaleFactors.needleHeadWidth,barWidth:i["bn-chart-structure"].scaleFactors.barWidth,varianceAxisLineWidth:i["bn-chart-structure"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-structure"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-structure"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-structure"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-structure"].scaleFactors.markerWidth,markerOffset:i["bn-chart-structure"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-structure"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-structure"].scaleFactors.axisTickLength},fontStyles:{font:`${s}px ${i.global.fontFamily}`,family:i.global.fontFamily,size:s,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-structure"].axisStyles,barStyles:i["bn-chart-structure"].barStyles,varianceStyles:i["bn-chart-structure"].varianceStyles,stackColors:i["bn-chart-structure"].stackColors,padding:i["bn-chart-structure"].padding,pattern:null}}))}prepareChartTitle(t){return t>=1?"":this.chartTitle}prepareStackConfig(){if(N(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const t=JSON.parse(this.stack),i=t.by,s="WARN_stack_dimensions_scenarios";if(i===q.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:s,type:"warning",message:`stack by dimensions: only the first scenario "${t[0]}" is used, the rest (${t.slice(1).join(", ")}) are discarded.`}):this.errors.remove(s)}else this.errors.remove(s);return{by:i,mode:t.mode||Q.ABSOLUTE,order:t.order||K.DATASET}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareLimit(){return Math.floor(Number(this.limit)||0)}getDataStructure(){return{IStructureChartDataRow:{operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return N(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}chartTemplate(t,s){const e=this.preparePixelPerUnit(),n=this.preparePixelPerPercentage(),r=this.prepareStackConfig(),o=this.prepareScenarios(),h=(null==r?void 0:r.by)===q.DIMENSIONS?o.slice(0,1):o;return i("bn-chart-structure-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(s),scenarios:h,variances:[t],hideCategories:this.prepareHideCategories(s),pixelPerUnit:e,pixelPerPercentage:n,reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,limit:this.prepareLimit(),styles:this.prepareStyle(),i18n:this.prepareI18n(),order:this.prepareOrder(),level:this.prepareLevel(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(s),stackConfig:r,parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}async getBaseline(){return Ui(this.element,"bn-chart-structure-renderer")}async getLayoutState(t){var i,s,e,n;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",o=ei(this.element),h=this.getEffectiveScaleFactor(),a=Number.isFinite(h)&&h>0?h:1,l=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*a,c=this.prepareVariances(),u=Zi(this.element,"bn-chart-structure-renderer",["base",...c],o,r),d=null===(s=this.element.shadowRoot)||void 0===s?void 0:s.querySelector("bn-chart-structure-renderer"),f={version:li,tag:this.element.localName,id:ii(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:ti(this.element,o),em:{fontSizePx:l,appliedScaleFactor:a},regions:u.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(n=null==d?void 0:d.scenarios)&&void 0!==n?n:[],variances:c,barCount:u.barCount,hasNoData:0===u.barCount},diagnostics:Zt(this.element),scaling:this.resolveScalingInfo(l),baseline:u.baseline};return u.elements&&(f.elements=u.elements),f}resolveScalingInfo(t){var i,s;const e={},n=Xt(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===n.kind)e.unitMode="fixed",e.unitsPerEm=n.value,e.unitPxPerUnit=t/n.value;else{e.unitMode="auto";const s=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==s&&s>0&&(e.unitPxPerUnit=s,e.unitsPerEm=t/s)}const r=Xt(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)e.percentageMode="fixed",e.percentagePointsPerEm=r.value,e.percentagePxPerPoint=t/r.value;else{e.percentageMode="auto";const i=null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.percentage;void 0!==i&&i>0&&(e.percentagePxPerPoint=i/100,e.percentagePointsPerEm=100*t/i)}return e}getEffectiveScaleFactor(){const{mode:t,factor:i}=Ht(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){const t=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}));return t*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const o=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":o*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){let t=[""];const e=this.prepareVariances();e.length>0&&(t=[...t,...e]);const n=this.getFontStyles();return i(s,{key:"467a851c6547b300c71a38e812bfea4718f27775",style:n},i("div",{key:"4b5078608132e047a9404987c65c46f43037c043",class:"container"},t.map(this.chartTemplate)))}get element(){return e(this)}static get watchers(){return{filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],measureScale:[{validateMeasureScale:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}}};il.style=':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}';let sl=class{constructor(t,i,s,e,n,r,o,h,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=e,this.leftSideLengthSync=n,this.topSideLabelHeight=r>0?this.fontSize:0,this.hasStackedHeaders=a,this.leftSideLabelLength=this.calculateSideLabelLength(r,o,h),this.calculateSpacings(),this.calculateCategoryPosition(),this.calculateAxisPosition()}getBarPositionX(){return this.axisPosition.x}getBarCenterPositionY(t){return this.categoryPosition.y+this.spacings.scenarioOffset+t*this.spacings.categoryWidth}getBarPositionY(t,i){return i?this.getBarCenterPositionY(t):this.getBarCenterPositionY(t)-this.spacings.scenarioOffset}getCategoryPositionX(t){let i=this.spacings.labelToAxis;return t&&(i=-this.spacings.labelToAxis),this.getAxisPositionX()+i}getAxisTitlePositionX(){return this.axisPosition.x}getAxisTitlePositionY(){return this.axisPosition.y-this.spacings.labelToAxis-this.getTopLabelOverhang()}getStackedHeaderPositionY(){return this.getBarCenterPositionY(0)-.5*this.spacings.barWidth-this.spacings.scenarioLabelToBar}getNeedleWidth(){return this.spacings.needleWidth}getAxisPositionX(){return this.leftSideLabelLength+this.padding.left+this.spacings.labelToAxis}getAxisPositionY(){return this.padding.top+this.getAxisTitleOffset()}loadCategoriesBox(t){this.categoriesBoxOffset=t,this.calculateAxisPosition()}addOffsetByNegativeDataPoints(t,i,s,e){null!=t&&null!=t.value&&t.value<0&&(s&&t.isClipped()?this.axisPosition.x+=Math.abs(t.getClippedValue()*t.pixelPerUnit):this.axisPosition.x+=Math.abs(t.value*t.pixelPerUnit),this.axisPosition.x+=i,this.axisPosition.x+=this.spacings.labelToBar),this.axisPosition.x<e/2&&(this.axisPosition.x=e/2+this.spacings.labelToBar)}getLabelPositionX(t){let i=this.spacings.labelToBar;return t<0&&(i*=-1),this.axisPosition.x+t+i}getLabelPositionY(t){return this.axisPosition.y+t+this.spacings.labelToBar}getCategoryToAxisSpaceing(){return this.spacings.labelToAxis}getCategoryToTopSpaceing(){return this.spacings.scenarioOffset}getCategoryToBottomSpaceing(){return this.spacings.scenarioOffset}getAxisEndPositionY(){return this.getAxisPositionY()+(this.numberOfColumns+.5)*this.spacings.categoryWidth}getScenarioLabelPositionOffsetY(t){if(t){const t=.5*this.getBarWidth()+this.spacings.scenarioLabelToBar;return Math.max(t,this.spacings.categoryWidth-this.spacings.scenarioOffset+this.spacings.labelToAxis)}return-(.5*this.getBarWidth()+this.spacings.scenarioLabelToBar)}getBarWidth(){return this.spacings.barWidth}getMarkerPositionY(t,i){return i?this.getBarCenterPositionY(t)-this.spacings.markerOffset-.5*this.getBarWidth():this.getBarCenterPositionY(t)+this.spacings.markerOffset+.5*this.getBarWidth()}getMarkerPositionX(){return this.getBarPositionX()}getMarkerScenarioLabelPositionOffsetY(t){return t?-(.5*this.spacings.markerWidth+this.spacings.scenarioLabelToBar):this.spacings.scenarioLabelToBar+.5*this.spacings.markerWidth}getAxisEndPositionX(){return this.getAxisPositionX()}calculateSpacings(){this.spacings={scenarioOffset:this.fontSize*this.scaleFactors.scenarioOffset,markerOffset:this.fontSize*this.scaleFactors.markerOffset,scenarioLabelToBar:this.fontSize*this.scaleFactors.scenarioLabelToBar,labelToBar:this.fontSize*this.scaleFactors.labelToBar,labelToAxis:this.fontSize*this.scaleFactors.labelToAxis,needleWidth:this.fontSize*this.scaleFactors.needleWidth,needleHeadWidth:this.fontSize*this.scaleFactors.needleHeadWidth,barWidth:this.fontSize*this.scaleFactors.barWidth,varianceAxisLineWidth:this.fontSize*this.scaleFactors.varianceAxisLineWidth,axisLineWidth:this.fontSize*this.scaleFactors.axisLineWidth,auxiliaryLineWidth:this.fontSize*this.scaleFactors.auxiliaryLineWidth,scenarioLineWidth:this.fontSize*this.scaleFactors.scenarioLineWidth,markerWidth:this.fontSize*this.scaleFactors.markerWidth,categoryWidth:this.fontSize*this.scaleFactors.categoryWidth,axisTickLength:this.fontSize*this.scaleFactors.axisTickLength}}calculateCategoryPosition(){this.categoryPosition={x:this.padding.left,y:this.getAxisPositionY()+.5*this.spacings.categoryWidth}}calculateAxisPosition(){this.axisPosition={x:this.getAxisPositionX(),y:this.getAxisPositionY()}}recalculatePositions(){this.calculateCategoryPosition(),this.calculateAxisPosition()}getAxisTitleOffset(){return this.topSideLabelHeight+this.spacings.labelToAxis+this.getTopLabelOverhang()}getTopLabelOverhang(){return this.hasStackedHeaders?this.getStackedHeaderOverhang():this.getTopScenarioLabelOverhang()}getStackedHeaderOverhang(){return Math.max(0,this.fontSize+this.spacings.scenarioLabelToBar+.5*this.spacings.barWidth-(.5*this.spacings.categoryWidth+this.spacings.scenarioOffset))}getTopScenarioLabelOverhang(){return Math.max(0,this.fontSize+.5*this.spacings.barWidth+this.spacings.scenarioLabelToBar-.5*this.spacings.categoryWidth,this.fontSize+.5*this.spacings.markerWidth+this.spacings.scenarioLabelToBar+this.spacings.markerOffset+.5*this.spacings.barWidth-(.5*this.spacings.categoryWidth+this.spacings.scenarioOffset))}calculateSideLabelLength(t,i,s){if(this.leftSideLengthSync)return this.leftSideLengthSync;const e=t/2;let n=i;return e>n&&(n=e),s>n&&(n=s),n}},el=class{constructor(t){this.top=t.top,this.bottom=t.bottom,this.left=t.left,this.right=t.right}addBoxTopLeft(t){return this.top+=t.height|this.top,this.left+=t.width|this.top,this}},nl=class{constructor(t){const i=1*t,s=.7*t;this.bgOffset=(i-s)/2,this.markerUp={top:s/2+",0",left:"0,"+s,right:s+","+s},this.markerUpBackground={top:i/2+",0",left:"0,"+i,right:i+","+i},this.markerDown={bottom:s/2+","+s,left:"0,0",right:s+",0"},this.markerDownBackground={bottom:i/2+","+i,left:"0,0",right:i+",0"}}upMarkerPatternStrings(){return{background:this.markerUpBackground.left+" "+this.markerUpBackground.right+" "+this.markerUpBackground.top+" "+this.markerUpBackground.left,foreground:this.markerUp.left+" "+this.markerUp.right+" "+this.markerUp.top+" "+this.markerUp.left,bgOffset:this.bgOffset}}downMarkerPatternStrings(){return{background:this.markerDownBackground.left+" "+this.markerDownBackground.right+" "+this.markerDownBackground.bottom+" "+this.markerDownBackground.left,foreground:this.markerDown.left+" "+this.markerDown.right+" "+this.markerDown.bottom+" "+this.markerDown.left,bgOffset:this.bgOffset}}createPatternMapForStructureBar(){const t=new Map;return t.set("marker-up",this.upMarkerPatternStrings()),t.set("marker-down",this.downMarkerPatternStrings()),t}},rl=class{constructor(t){this.container=new uh,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 ol,hl,al;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(ol||(ol={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(hl||(hl={})),function(t){t[t.Y=1e24]="Y",t[t.Z=1e21]="Z",t[t.E=1e18]="E",t[t.P=1e15]="P",t[t.T=1e12]="T",t[t.G=1e9]="G",t[t.M=1e6]="M",t[t.k=1e3]="k",t[t.h=100]="h",t[t.da=10]="da",t[t.d=.1]="d",t[t.c=.01]="c",t[t.m=.001]="m",t[t.my=1e-6]="my",t[t.n=1e-9]="n",t[t.p=1e-12]="p",t[t.f=1e-15]="f",t[t.a=1e-18]="a",t[t.z=1e-21]="z",t[t.y=1e-24]="y"}(al||(al={}));class ll{static calculateMeasureScale(t,i,s,e,n){var r,o;if("_"===e)return new la;if("μ"===e&&(e="my"),null!=e&&[...this.unitsLeast,...this.unitsGreat].includes(e))return this.lookupPrefix(e);const h=s.filter((t=>3===t.length));if(0===h.length||!i)return new la;const a=`SELECT MAX(GREATEST(${h.map((t=>"ABS("+t+")")).toString()})) as prefixvalue\n FROM ${i}`,l=`SELECT MIN(LEAST(${h.map((t=>"ABS("+t+")")).toString()})) as prefixvalue\n FROM ${i}`;let c,u=a;"LEAST"===(null==e?void 0:e.toUpperCase())&&(u=l);try{c=null!==(o=null===(r=t.exec(u)[0])||void 0===r?void 0:r.prefixvalue)&&void 0!==o?o:0}catch(t){return null==n||n(t),new la}return this.determinePrefix(Math.abs(c))}static determinePrefix(t){if(!Number.isFinite(t)||t<=0)return new la;if(t>=1e3){const i=Math.min(Math.floor(Math.log10(t)/3),this.unitsGreat.length)-1;return new la(this.unitsGreat[i],Math.pow(1e3,i+1))}if(t<=.001){const i=Math.min(-Math.floor(Math.log10(t)/3),this.unitsLeast.length)-1;return new la(this.unitsLeast[i],Math.pow(1e3,-(i+1)))}return new la}static lookupPrefix(t){return new la(t,al[t])}}ll.unitsGreat=["k","M","G","T","P","E","Z","Y"],ll.unitsLeast=["m","my","n","p","f","a","z","y"];class cl{adapt(t){return Z.adaptDefaultString(t)}default(){return""}}class ul{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 tt(new cl).default(),this.level=G.CATEGORY,this.filter="",this.measureScale=new la,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.stackConfig=null}}class dl{constructor(t,i,s,e,n,r,o){this.dataRowAdapter=t,this.orderAdapter=i,this.stringAdapter=s,this.dataFormatDigitsAdapter=e,this.db=n,this.fromExpr=r,this.onQueryError=o}adapt(t){const i=Z.adaptArray(t.data,this.dataRowAdapter),s=Z.adaptArray(t.scenarios,this.stringAdapter),e=new ul(i,s);return R.isArray(t.variances)&&(e.variances=Z.adaptArray(t.variances,this.stringAdapter)),R.isString(t.title)&&(e.title=t.title),R.isBoolean(t.hideCategories)&&(e.hideCategories=t.hideCategories),R.isNumber(t.pixelPerUnit)&&(e.pixelPerUnit=t.pixelPerUnit),R.isNumber(t.pixelPerPercentage)&&(e.pixelPerPercentage=t.pixelPerPercentage),R.isNumber(t.limit)&&(e.limit=t.limit),R.isExisting(t.sortOrder)&&(e.sortOrder=this.orderAdapter.adapt(t.sortOrder)),R.isExisting(t.level)&&(e.level=t.level),R.isString(t.filter)&&(e.filter=t.filter.trim()),R.isExisting(t.measureScale)&&(e.measureScale=ll.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale,this.onQueryError)),R.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),R.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),R.isExisting(t.dataFormatDigits)&&(e.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),R.isExisting(t.stackConfig)&&(e.stackConfig=t.stackConfig),e}default(){return new ul([],[])}}let fl=class{constructor(t,i,s,e){this.value=t,this.scenario=i,this.pixelPerUnit=s||1;const n="string"==typeof e?As(e,null,!0):e;this.variance="neg"===n||n===wl.NEG?wl.NEG:"pos"===n||n===wl.POS?wl.POS:wl.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:wl.NEU===this.variance?wl.NEU:wl.POS===this.variance?wl.NEG:wl.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 vl{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 pl{constructor(){}adapt(t){const i=new vl;return R.isOperator(t.operation)&&(i.operation=t.operation),R.isNumber(t.rowGroupIndex)&&R.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),R.isNumber(t.categoryIndex)&&R.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),R.isNumber(t.subCategoryIndex)&&R.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),R.isNumber(t.columnGroupIndex)&&R.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),R.isNumber(t.columnSubGroupIndex)&&R.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 vl}setActualValues(t,i){R.isNumber(t.ac1)&&(i.ac1=t.ac1),R.isNumber(t.ac2)&&(i.ac2=t.ac2),R.isNumber(t.ac3)&&(i.ac3=t.ac3),R.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){R.isNumber(t.pl1)&&(i.pl1=t.pl1),R.isNumber(t.pl2)&&(i.pl2=t.pl2),R.isNumber(t.pl3)&&(i.pl3=t.pl3),R.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){R.isNumber(t.pp1)&&(i.pp1=t.pp1),R.isNumber(t.pp2)&&(i.pp2=t.pp2),R.isNumber(t.pp3)&&(i.pp3=t.pp3),R.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){R.isNumber(t.fc1)&&(i.fc1=t.fc1),R.isNumber(t.fc2)&&(i.fc2=t.fc2),R.isNumber(t.fc3)&&(i.fc3=t.fc3),R.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class gl{constructor(t,i,s,e,n,r){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=e,this.varianceStyles=n,this.padding=r,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"],this.locale="de"}}class ml{constructor(t,i,s,e,n){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=e,this.paddingadapter=n}adapt(t){const i=new gl(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return R.isExisting(t)&&(R.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),R.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),R.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),R.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),R.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),R.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 nl(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new gl(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}class bl{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 yl{adapt(t){const i=new bl;return R.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),R.isNumber(t.scenarioLabelToBar)&&(i.scenarioLabelToBar=t.scenarioLabelToBar),R.isNumber(t.labelToBar)&&(i.labelToBar=t.labelToBar),R.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),R.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),R.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),R.isNumber(t.barWidth)&&(i.barWidth=t.barWidth),R.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),R.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),R.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),R.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),R.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),R.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),R.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),R.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new bl}}var wl,xl,Sl;!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"}(wl||(wl={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(xl||(xl={})),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"}(Sl||(Sl={}));class $l{constructor(t,i,s,e,n,r,o,h){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=n,null!=t&&(this.group=t.group().id(this.createElementID(t.toString(),e))),this.styles=r,this.isVarianceLabel=!1,this.isRelativeLabel=!1,this.verticalHookLocation=o||Sl.Top,this.horizontalHookLocation=h||Sl.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 la){var s;if(this.isEmpty())return this;const e=this.group;let n;const r=this.styles.fontStyles.background||"#ffffff";let o="",h="start";if(!1===Number.isNaN(Number(this.value))){let s=t.percent,e=t.percent,r=1,a="percent";!1===this.isRelativeLabel&&(s=t.decimal,e=t.decimal,r=i.value,a="decimal"),n=ra.number(Number(this.value),a,s,e,r,this.styles.locale),Number(this.value)<0&&(h="end"),this.isVarianceLabel&&Number(this.value)>=0&&(o="+")}else n=""+this.value,h="start";const a=e.text(o+n);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===Sl.Right?(h="end",a.move(a.x()-a.length(),a.y())):this.horizontalHookLocation===Sl.Center&&(h="middle",a.move(a.x()-a.length()/2,a.y())),this.verticalHookLocation===Sl.Center?a.move(a.x(),a.y()-u/2):this.verticalHookLocation===Sl.Bottom&&a.move(a.x(),a.y()-u),a.font({anchor:h}),null!=this.segmentFillColor?a.fill(ia(this.segmentFillColor)):null==e||e.rect(c,.9*u).stroke(r).fill(r).opacity(.7).move(a.x(),a.y()+.1*u).insertBefore(a),this.pointKey&&(null==e||e.attr(ji(this.pointKey,this.pointPart))),this)}isEmpty(){return null==this.value||""===this.value}setPos(t,i){return this.x=t,this.y=i,this}}let Ml=class{constructor(t,i,s,e){this.height=0,this.ID_AXIS="axis",this.ID_AXIS_TITLE="axis-title",this.CSS_AXIS_TITLE="categories",this.scenarioType=t.scenarioType,this.labelText=t.labelText||null,this.position=i,this.style=e,this.label=new $l(s,this.position.getAxisTitlePositionX(),this.position.getAxisTitlePositionY(),this.ID_AXIS_TITLE,this.labelText,this.style,Sl.Bottom,Sl.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 _l{constructor(t,i,s,e,n,r,o,h=null){if(this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.scenarioLabel=null,this.barGroup=null,this.isVarianceBar=!1,this.overflowConfig=null,this.isOverflowing=!1,this.overdriveWidth=0,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=e,this.isPrimaryBar=n,this.position=t,this.barStyles=i.barStyles,this.overflowConfig=h,this.scenarioGroup=r,this.styles=i,null!=r&&(this.barGroup=r.group().id(r.toString()+"_"+this.ID_RECT)),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0;let i=Sl.Left;s.value<0&&(i=Sl.Right),this.dimensions=this.createDimensions(t,s,e,n),this.label=new $l(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,Sl.Center,i).setPoint(s.key),this.scenarioLabel=this.getScenarioLabel(o)}}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 la){var s,e;if(this.isEmpty()||null==this.dataPoint.getScenario())return this;let n=this.barStyles.getSVGStyle(this.dataPoint.getScenario());this.isVarianceBar&&(n=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()));const r=this.convertToSVGStyle(n,"stroke");let o=this.convertToSVGStyle(n,"fill");const h=this.barStyles.getSVGStyle(this.dataPoint.getScenario()).fillpattern;if(null!=h){const t=this.styles.pattern.get(h);null!=t&&(o=t.pattern)}null===(s=this.scenarioGroup)||void 0===s||s.attr(ji(this.dataPoint.key)),null===(e=this.barGroup)||void 0===e||e.attr(ji(this.dataPoint.key,"element")),null!=this.barGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(o,r):this.barGroup.rect(this.dimensions.barLength,this.position.getBarWidth()).fill(o).stroke(r).cy(this.dimensions.yPos).x(this.dimensions.xPos)),this.drawBarDataLabel(t,i),this.drawScenarioLabel()}drawOverdriveBar(t,i){if(!this.barGroup||!this.overflowConfig)return;const s=this.position.getBarPositionX(),e=this.position.getBarWidth(),n=this.dimensions.barLength,{breakGap:r}=this.overflowConfig;this.dataPoint.getScaledUnit()<0?(this.barGroup.rect(n,e).fill(t).stroke(i).x(s-n).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,e).fill(t).stroke(i).x(s-n-r-this.overdriveWidth).cy(this.dimensions.yPos),this.drawBreakIndicator(s-n-r,r)):(this.barGroup.rect(n,e).fill(t).stroke(i).x(s).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,e).fill(t).stroke(i).x(s+n+r).cy(this.dimensions.yPos),this.drawBreakIndicator(s+n,r))}drawBreakIndicator(t,i){if(!this.barGroup)return;const s=this.position.getBarWidth(),e=this.dimensions.yPos-s/2,n=t+i/2,r=.35*i,o=s/3;let h=`M ${n-r} ${e}`;for(let t=0;t<3;t++)h+=` L ${n-r-.3*i} ${e+o*(t+.5)} L ${n-r} ${e+o*(t+1)}`;let a=`M ${n+r} ${e}`;for(let t=0;t<3;t++)a+=` L ${n+r+.3*i} ${e+o*(t+.5)} L ${n+r} ${e+o*(t+1)}`;this.barGroup.rect(i,s+2).fill("#ffffff").stroke("none").x(t).cy(this.dimensions.yPos),this.barGroup.path(h).fill("none").stroke({color:"#000000",width:1}),this.barGroup.path(a).fill("none").stroke({color:"#000000",width:1})}createDimensions(t,i,s,e){const n=i.getScaledUnit(),r=Math.abs(n);if(this.overflowConfig&&r>0){const o="ac"===i.getScenario()?this.overflowConfig.cutWidth:this.overflowConfig.cutWidth-this.overflowConfig.scenarioCutOffset;if(r>o){this.isOverflowing=!0;const{breakGap:i,overdriveZoneWidth:h,maxOverflow:a}=this.overflowConfig;this.overdriveWidth=a>0?(r-o)/a*h:0;const l=o+i+this.overdriveWidth;return n<0?{clipped:!1,barLength:o,xPos:t.getBarPositionX()-o,yPos:t.getBarPositionY(s,e),labelXPos:t.getLabelPositionX(-l),scenarioLabelXPos:t.getBarPositionX()-.5*o,scenarioLabelYPos:t.getBarPositionY(s,e)+t.getScenarioLabelPositionOffsetY(e)}:{clipped:!1,barLength:o,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,e),labelXPos:t.getLabelPositionX(l),scenarioLabelXPos:t.getBarPositionX()+.5*o,scenarioLabelYPos:t.getBarPositionY(s,e)+t.getScenarioLabelPositionOffsetY(e)}}}return n<0?{clipped:!1,barLength:r,xPos:t.getBarPositionX()+n,yPos:t.getBarPositionY(s,e),labelXPos:this.position.getLabelPositionX(n),scenarioLabelXPos:this.position.getBarPositionX()-.5*r,scenarioLabelYPos:this.position.getBarPositionY(s,e)+this.position.getScenarioLabelPositionOffsetY(e)}:{clipped:!1,barLength:n,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,e),labelXPos:this.position.getLabelPositionX(n),scenarioLabelXPos:this.position.getBarPositionX()+.5*r,scenarioLabelYPos:this.position.getBarPositionY(s,e)+this.position.getScenarioLabelPositionOffsetY(e)}}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.isVarianceBar||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw()}drawBarDataLabel(t,i=new la){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 $l(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,this.isPrimaryBar?Sl.Top:Sl.Bottom,Sl.Center)}}let Ol=class{constructor(t,i,s,e,n,r,o,h,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=n,this.barStyles=n?n.barStyles:null,this.scenario=e,!0!==(null==r?void 0:r.isEmpty())&&(this.hasData=!0,this.pointKey=r.key,this.dimensions=this.createMarkerDimensions(r,o,a),this.scenarioLabel=this.getScenarioLabel(h,n,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 $l(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,s?Sl.Bottom:Sl.Top,Sl.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(ji(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(ji(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)}},kl=class{constructor(t,i,s,e,n){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=e,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=n,this.styles=i,this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT);const r=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||r){this.hasData=!0,this.dimensions=this.createDimensions(t,s,e);let i=Sl.Left;s.value<0&&(i=Sl.Right),this.label=new $l(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,r?it:s.value,this.styles,Sl.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(ji(this.dataPoint.key)),this.barGroup.attr(ji(this.dataPoint.key,"element"));const e=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()),n=e.stroke;let r=e.fill;const o=this.barStyles[this.dataPoint.getScenario()];if(null!=o&&o.fillpattern){const t=this.styles.pattern.get(o.fillpattern);null!=t&&null!=t.pattern&&(r=t.pattern)}this.drawNeedleHead(r,n),this.barGroup.rect(this.dimensions.barLength,this.position.getNeedleWidth()).fill(r).stroke(n).cy(this.dimensions.yPos).x(this.dimensions.xPos),null===(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,e=this.styles.varianceStyles.needleHeadColour;if(this.dimensions.clipped){let s="13,0 4,-5 4,5 13,0 8,0 0,-5 0,5 8,0";null!=this.dataPoint.value&&this.dataPoint.value<0&&(s="0,0 9,-5 9,5 0,0 5,0 13,-5 13,5 5,0"),this.barGroup.polygon(s).fill(t).cx(this.getHeadXPosition()).cy(this.dimensions.yPos).fill(t).stroke(i)}else this.barGroup.rect(2*this.position.getNeedleWidth(),2*this.position.getNeedleWidth()).cx(this.getHeadXPosition()).cy(this.dimensions.yPos).fill(s).stroke(e)}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getHeadXPosition(){let t=this.dimensions.xPos;return null!=this.dataPoint.value&&this.dataPoint.value>0&&(t+=this.dimensions.barLength),t}};class Al{constructor(t,i,s,e,n,r,o,h,a,l,c){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=e,this.segment=n,this.segmentIndex=o,this.stackMode=h,this.stack=a,this.group=c,this.barGroup=c.group().id(`stacked_bar_${e}_seg_${o}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new la){if(!this.hasData||!Number.isFinite(this.dataPoint.value))return;const s=this.dataPoint.value,e=this.dataPoint.pixelPerUnit,n=this.position.getBarPositionX(),r=this.position.getBarWidth(),o=Math.abs(this.segment.end-this.segment.start)*e,h=n+Math.min(this.segment.start,this.segment.end)*e,a=this.position.getBarPositionY(this.index,!0),l=this.styles.stackColors,c=l[this.segmentIndex%l.length],u={color:c},d={color:c,width:.5};this.barGroup.attr(ji(this.dataPoint.key,"element")),this.barGroup.rect(Math.max(o,.5),r).fill(u).stroke(d).cy(a).x(h);const f=o-6;if(f>0){const e=h+o/2;if(this.stackMode===Q.RELATIVE||this.stackMode===Q.ABSOLUTE_RELATIVE){const i=ra.number(this.segment.share,"percent",t.percent,t.percent,1,this.styles.locale);new $l(this.group,e,a,"STACK_SEG",i,this.styles,Sl.Center,Sl.Center).setSegmentFill(c).setMaxWidth(f).setPoint(this.dataPoint.key).draw()}else new $l(this.group,e,a,"STACK_SEG",s,this.styles,Sl.Center,Sl.Center).setSegmentFill(c).setMaxWidth(f).setPoint(this.dataPoint.key).draw(t,i)}}drawTotalLabel(t={percent:2,decimal:1},i=new la,s){if(this.stackMode===Q.RELATIVE)return;const e=this.stack.total<0,n=this.position.getLabelPositionX((e?0-this.stack.negative:this.stack.positive)*this.dataPoint.pixelPerUnit),r=this.position.getBarPositionY(this.index,!0);new $l(this.group,n,r,"STACK_TOTAL",this.stack.total,this.styles,Sl.Center,e?Sl.Right:Sl.Left).setPoint(s,"total").draw(t,i)}}let Rl=class{constructor(t,i,s,e,n){this.overflowConfig=null,this.i18n=n;const r=i.group().id("Scenario1"),o=i.group().id("Scenario2").insertBefore(r);this.svgGroups={parent:i,scenario1:r,scenario2:o,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=e}setOverflowConfig(t){this.overflowConfig=t}isLastDataPoint(t){return this.elementCnt-1===t}isFirsttDataPoint(t){return 0===t}createPrimaryBar(t,i){var s,e,n,r;const o=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===e?void 0:e.group().id(""+i),h=null===(r=null===(n=this.svgGroups)||void 0===n?void 0:n.scenario1Label)||void 0===r?void 0:r.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new _l(this.position,this.styles,t,i,!0,o,a,this.overflowConfig).updateLabelGroup(h)}createVarianceBar(t,i){var s,e,n,r;const o=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===e?void 0:e.group().id(""+i),h=null===(r=null===(n=this.svgGroups)||void 0===n?void 0:n.scenario1Label)||void 0===r?void 0:r.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new _l(this.position,this.styles,t,i,!0,o,a,this.overflowConfig).updateLabelGroup(h).setAsVariance()}createRelativeVarianceBar(t,i){var s,e,n,r;const o=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===e?void 0:e.group().id(""+i),h=null===(r=null===(n=this.svgGroups)||void 0===n?void 0:n.scenario1Label)||void 0===r?void 0:r.group().id(""+i);return new kl(this.position,this.styles,t,i,o).updateLabelGroup(h)}createSecondaryBar(t,i){var s,e;const n=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario2)||void 0===e?void 0:e.group().id(""+i);let r=null;return this.isFirsttDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new _l(this.position,this.styles,t,i,!1,n,r,this.overflowConfig)}createPrimaryMarker(t,i){var s,e;const n=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario3)||void 0===e?void 0:e.group().id(""+i),r=this.styles.pattern.get("marker-down")||{foreground:"0,0 1,0 1,1 0,1",background:"0,0 1,0 1,1 0,1",bgOffset:0};let o=null;return this.isFirstDataPoint(i)&&(o=`${this.i18n.get(t.scenario)||t.scenario}`),new Ol(this.position,n,r,t.scenario,this.styles,t,i,o,!0)}createSecondaryMarker(t,i){var s,e;const n=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario4)||void 0===e?void 0:e.group().id(""+i),r=this.styles.pattern.get("marker-up")||{foreground:"0,0 1,0 1,1 0,1",background:"0,0 1,0 1,1 0,1",bgOffset:0};let o=null;return this.isLastDataPoint(i)&&(o=`${this.i18n.get(t.scenario)||t.scenario}`),new Ol(this.position,n,r,t.scenario,this.styles,t,i,o,!1)}isFirstDataPoint(t){return 0===t}};const Nl=.001;function Ll(t){return null!=t.fixedDomain?Math.max(0,t.fixedDomain):t.relativeVariance?0:Math.max(0,t.maxPositive)+Math.abs(Math.min(0,t.minNegative))}function El(t){var i;if(!t.relativeVariance)return 0;const s=null!==(i=t.sideClamp)&&void 0!==i?i:1.45;return Math.min(s,Math.max(0,t.maxPositive))+Math.min(s,Math.abs(Math.min(0,t.minNegative)))}function Tl(t){const i=t.unitExtent+t.pctExtent;if(i<=0)return{};const s=Math.max(Nl,(t.target-(t.measured-t.unitExtent*t.currentPpu-t.pctExtent*t.currentPpp))/i);return{ppu:t.unitExtent>0?s:void 0,ppp:t.pctExtent>0?s:void 0}}function Cl(t,i=0){let s=0,e=0,n=0;const r=t.map((t=>{const i=Number.isFinite(t)?t:0;if(n+=i,i<0||Object.is(i,-0)){const t=0-e;return e-=i,{value:i,start:t,end:0-e}}const r=s;return s+=i,{value:i,start:r,end:s}})),o=s+e;let h=1;return i>0&&(h=o>0?i/o:0),{segments:r.map((t=>({start:t.start*h,end:t.end*h,share:o>0?t.value/o:0}))),positive:s*h,negative:e*h,total:n}}function Pl(t){const i={positive:0,negative:0,maxTotal:0,minTotal:0};for(const s of t)i.positive=Math.max(i.positive,s.positive),i.negative=Math.max(i.negative,s.negative),i.maxTotal=Math.max(i.maxTotal,s.total),i.minTotal=Math.min(i.minTotal,s.total);return i}function Wl(t,i=()=>0){const s=t[t.length-1],e=null!=s&&s.total<0,n=t.map((t=>(e?t.positive:t.negative)+((e?t.total>=0:t.total<0)?i(t):0)));return{flipped:e,clearance:Math.max(0,...n)}}class Dl{constructor(t,i,s,e,n){this.dataModel=[],this.variancesDataModel=[],this.title="",this.configTitle="",this.configVariances=[],this.smallestDataPointValue=new fl(0,wl.AC1,1,wl.NEU),this.highestDataPointValue=new fl(0,wl.AC1,1,wl.NEU),this.smallestVarianceDataPointValue=new fl(0,wl.AC1,1,wl.NEU),this.highestVarianceDataPointValue=new fl(0,wl.AC1,1,wl.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.level=G.CATEGORY,this.hideCategories=!1,this.axisScenario=wl.AC1,this.CSS_CATEGORIES="categories",this.state=ol.DIRTY,this.titleLength=0,this.leftSideOffsetForHorizontalSync=0,this.limit=0,this.measureScale=new la,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.scenarioPropOrder=[],this.overflowConfig=null,this.stackSides=Pl([]),this.stackLabelClearance={left:0,right:0},this.fromExpr="",this.rowCount=0,this.db=i,this.tableName=s,this.ruleSet=t||new Cs,this.i18n=this.createI18n(new Map),this.styles=n,this.setConfig(e),this.position=this.createElementPosition()}updatePosition(){this.position=this.createElementPosition()}createElementPosition(){this.titleLength=this.calculateTitleLength(0);let t=this.calculateLeftSideWidth(this.getVarianceType());const i=this.calculateCategoryWidth();return this.titleLength>t&&(t=this.titleLength),new sl(new el(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 Cs}setConfig(t){var i,s;this.state=ol.DIRTY,this.scenarioPropOrder=[...t.scenarios];const e=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(e,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({},Bi(this.level,t.category)),{scenario:null!==(i=s.scenario)&&void 0!==i?i:void 0}));t.stackConfig&&t.stackConfig.by!==q.SCENARIOS&&this.populateDimensionStackSegments(e,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||ra.translateScenarioLabel(null===(t=this.configVariances)||void 0===t?void 0:t.toString(),this.i18n)}createI18n(t){this.state=ol.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=ol.DIRTY,this.queryError=void 0,this.fromExpr=$(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=ci(t))}getUnitBarExtent(){var t,i;const s=this.isStacked(),e=this.getVarianceType(),n=e!==hl.NONE,r=n?this.highestVarianceDataPointValue:this.highestDataPointValue,o=n?this.smallestVarianceDataPointValue:this.smallestDataPointValue;return Ll({fixedDomain:s?this.stackSides.positive+this.stackSides.negative:void 0,relativeVariance:e===hl.RELATIVE,maxPositive:null!==(t=null==r?void 0:r.value)&&void 0!==t?t:0,minNegative:null!==(i=null==o?void 0:o.value)&&void 0!==i?i:0})}getPercentBarExtent(){var t,i,s,e;return El({relativeVariance:this.getVarianceType()===hl.RELATIVE,maxPositive:null!==(i=null===(t=this.highestVarianceDataPointValue)||void 0===t?void 0:t.value)&&void 0!==i?i:0,minNegative:null!==(e=null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&void 0!==e?e:0})}getAllocatedCanvasWidth(){const t=this.position.getAxisPositionX(),i=this.calculateRightSideWidth(this.getVarianceType());let s=t+i+ +this.styles.padding.left+this.styles.padding.right;return i<this.titleLength/2&&(s+=this.titleLength/2),t<this.titleLength/2&&(s+=this.titleLength/2),s}getAllocatedCanvasHeight(){return this.position.getAxisEndPositionY()+this.position.spacings.labelToAxis+this.position.fontSize+this.styles.padding.bottom}patternToString(){return"<svg></svg>"}layout(){this.draw(new uh)}toString(){const t=new uh;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===ol.DIRTY&&(this.state=ol.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=Qh(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?" ":ra.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}scenarioStyles(){const t=Es(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=wl.AC1;if(null!=t&&t.length>0){const s=new ks(t.toString());s.isValid&&(i=Ls(this.ruleSet.getScenarioColorIndex(s.delta))+s.delta.slice(2))}return null===i&&(i=wl.AC1),i}populateModel(t,i,s){if(0===this.rowCount||!this.fromExpr)return[];const e=[],n=this.createOrderStr(i,s),r=this.createSelectString(i,s),o=this.createGroupByStr(i,s);let h;try{h=this.db.exec(`SELECT ${r} ${t.length>0?","+t.map((t=>`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`)).join(","):""}\n FROM ${this.fromExpr}\n GROUP BY ${o}\n ORDER BY ${n}`)}catch(t){return this.failQuery(t),[]}return this.detectNaNCells(t,h),this.createDataRows(this.limit>0?h.slice(0,this.limit):h,e,t),this.crateRESTRow(h,t,e),e}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new ks(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 e=[];this.createDataRows(t.slice(this.limit),e,i);const n=(t,i)=>Number.isFinite(i)?(Number.isFinite(t)?t:0)+i:t,r=e.reduce((function(t,s){return{id:t.id,category:t.category,type:t.type,scenario1:new fl(n(t.scenario1.value,s.scenario1.value),i[0],t.scenario1.pixelPerUnit,wl.NEU),scenario2:new fl(n(t.scenario2.value,s.scenario2.value),i[1],t.scenario2.pixelPerUnit,wl.NEU),scenario3:new fl(n(t.scenario3.value,s.scenario3.value),i[2],t.scenario3.pixelPerUnit,wl.NEU),scenario4:new fl(n(t.scenario4.value,s.scenario4.value),i[3],t.scenario4.pixelPerUnit,wl.NEU)}}),{id:9999,category:"REST",type:hl.NONE,scenario1:new fl(NaN,i[0],this.pixelPerUnit,wl.NEU),scenario2:new fl(NaN,i[1],this.pixelPerUnit,wl.NEU),scenario3:new fl(NaN,i[2],this.pixelPerUnit,wl.NEU),scenario4:new fl(NaN,i[3],this.pixelPerUnit,wl.NEU)});s.push(r)}createDataRows(t,i,s){t.forEach(((t,e)=>{i.push({id:e,category:t.category,type:hl.NONE,scenario1:new fl(t[s[0]],s[0],this.pixelPerUnit,wl.NEU),scenario2:new fl(t[s[1]],s[1],this.pixelPerUnit,wl.NEU),scenario3:new fl(t[s[2]],s[2],this.pixelPerUnit,wl.NEU),scenario4:new fl(t[s[3]],s[3],this.pixelPerUnit,wl.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===G.CATEGORY&&i.hierarchy.includes(Y.CATEGORYINDEX)?`${Y.CATEGORYINDEX}, ${G.CATEGORY} as category`:t===G.ROWGROUP&&i.hierarchy.includes(Y.ROWGROUPINDEX)?`${Y.ROWGROUPINDEX}, ${G.ROWGROUP} as category`:t===G.SUBCATEGORY&&i.hierarchy.includes(Y.SUBCATEGORYINDEX)?`${Y.SUBCATEGORYINDEX}, ${G.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===G.CATEGORY&&i.hierarchy.includes(Y.CATEGORYINDEX)?`${Y.CATEGORYINDEX}, ${G.CATEGORY}`:t===G.ROWGROUP&&i.hierarchy.includes(Y.ROWGROUPINDEX)?`${Y.ROWGROUPINDEX}, ${G.ROWGROUP}`:t===G.SUBCATEGORY&&i.hierarchy.includes(Y.SUBCATEGORYINDEX)?`${Y.SUBCATEGORYINDEX}, ${G.SUBCATEGORY}`:`${t.toString()}`}calculateCategoryWidth(){if(this.hideCategories)return 5;let t=0;for(const i of this.dataModel){const s=Qh(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 fl(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 fl(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===q.SCENARIOS;let s=[];for(const e of i?["scenario1","scenario2","scenario3","scenario4"]:["scenario1"]){const i=t[e];i&&!i.isEmpty()&&null!=i.value&&s.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0===s.length)return[];const e=this.stackConfig.mode===Q.RELATIVE?1:0,n=(t,i)=>({prefix:t,segments:i,layout:Cl(i.map((t=>t.value)),e),hasValue:i.some((t=>Number.isFinite(t.value)))});if(i){this.sortSegmentsByPropOrder(s);const t=new Map;for(const i of s){const s=ta(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}if(t.size>1){const i=[];for(const s of Zh)t.has(s)&&(i.push(n(s,t.get(s))),t.delete(s));for(const[s,e]of t)i.push(n(s,e));return i}}else t.stackSegments&&t.stackSegments.length>0&&(s=t.stackSegments.map((t=>({value:t.value,scenario:t.label,dataPoint:t.dataPoint}))));const r=t=>Number.isFinite(t.value)?t.value:0;return"asc"===this.stackConfig.order?s.sort(((t,i)=>r(t)-r(i))):"desc"===this.stackConfig.order&&s.sort(((t,i)=>r(i)-r(t))),[n("",s)]}measureStacks(){const t=[];this.stackLabelClearance={left:0,right:0};for(const i of this.dataModel){const{flipped:s,clearance:e}=this.stackLabelPlace(i),n=this.drawnStackLayouts(i),r=s?"right":"left";this.stackLabelClearance[r]=Math.max(this.stackLabelClearance[r],e),t.push(...n)}this.stackSides=Pl(t)}stackLabelPlace(t){const i=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;return Wl(this.drawnStackLayouts(t),(t=>{var s;return(null===(s=this.stackConfig)||void 0===s?void 0:s.mode)===Q.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 Qh(ra.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 e=null;null!=i&&i.length>0&&(e=i[0]);for(const n in t){const r=new ks(t[n]);if(r.isValid){const o=this.mapScenarios(r,e),h=r.direction;let a=this.pixelPerUnit;"dr"===r.type&&(a=this.pixelPerPercentage);for(const e in i){const l=new fl(this.calculateVariance(r,i[e],o),r.base,a,h);null===l.value||Number.isNaN(l.value)||(l.key=Object.assign(Object.assign({},Bi(this.level,i[e].category)),{scenario:t[n]})),s.push({id:Number(e),category:i[e].category,type:"dr"===r.type?hl.RELATIVE:hl.ABSOLUTE,scenario1:l,scenario2:new fl(null,null,null,null),scenario3:new fl(null,null,null,null),scenario4:new fl(null,null,null,null)})}}}return s}calculateVariance(t,i,s){const e=s.get(t.base),n=s.get(t.delta);return null==e||null==n?null:t.type===hl.RELATIVE?st(i[e].value-i[n].value,i[n].value):i[e].value-i[n].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((e=>{i[e].scenario===t.delta?s.set(t.delta,e):i[e].scenario===t.base&&s.set(t.base,e)})),s}calculateTextBoxWidth(t){return Qh(ra.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;return t>=0&&(i+=Qh("+",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width),i+=Qh(" %",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,Qh(ra.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 e=i.group().id("AxisAndDateLables");let n=!1;this.hideCategories||t.forEach(((t,i)=>{t.type===hl.RELATIVE&&(n=!0);let r=Sl.Right,o=!0,h=0;if(s){const i=this.stackLabelPlace(t);o=!i.flipped,h=i.clearance*this.pixelPerUnit*(i.flipped?1:-1)}else t.scenario1.value<0&&(o=!1);o||(r=Sl.Left),new $l(e,this.position.getCategoryPositionX(o)+h,this.position.getBarCenterPositionY(i),"",this.i18n.get(t.category)||t.category,this.styles,Sl.Center,r).draw()})),new Ml({scenarioType:this.axisScenario,labelText:this.title,isRelative:n},this.position,e,this.styles).draw()}drawScenarios(t,i){const s=i.group().id("Scenarios"),e=new Rl(this.position,s,this.scenarioStyles(),t.length,this.i18n);e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{e.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),e.createSecondaryBar(t.scenario2,i).draw(),e.createPrimaryMarker(t.scenario3,i).draw(),e.createSecondaryMarker(t.scenario4,i).draw()}))}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),e=new Rl(this.position,s,this.scenarioStyles(),t.length,this.i18n);return e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.type===hl.RELATIVE?e.createRelativeVarianceBar(t.scenario1,i).draw():e.createVarianceBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale)})),s}sortSegmentsByPropOrder(t){if(0===this.scenarioPropOrder.length)return;const i=this.scenarioPropOrder;t.sort(((t,s)=>{const e=i.indexOf(t.scenario),n=i.indexOf(s.scenario);return(-1===e?i.length:e)-(-1===n?i.length:n)}))}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),e=this.stackConfig.by===q.SCENARIOS;t.forEach(((t,i)=>{const n=this.stackGroups(t);n.forEach(((r,o)=>{let h=null;r.segments.forEach(((t,a)=>{const l=new Al(this.position,this.styles,t.dataPoint,i,r.layout.segments[a],t.scenario,n.length>1?n.length-1-o:a,this.stackConfig.mode,r.layout,e,s);l.draw(this.dataFormatDigits,this.measureScale),h=l})),h&&r.hasValue&&h.drawTotalLabel(this.dataFormatDigits,this.measureScale,Object.assign(Object.assign({},Bi(this.level,t.category)),{scenario:n.length>1?r.prefix:void 0}))}))}))}drawStackedHeaders(t,i){if(!this.stackConfig||0===t.length)return;const s=t[0];if(this.stackConfig.by!==q.SCENARIOS&&(!s.stackSegments||0===s.stackSegments.length))return;const e=this.stackGroups(s);if(0===e.length)return;const n=i.group().id("StackedHeaders"),r=this.position.getBarPositionX(),o=this.position.getStackedHeaderPositionY(),h=(t,i)=>{new $l(n,t,o,"STACK_HEADER",i,this.styles,Sl.Bottom,Sl.Center).draw()};if(e.length>1)return void e.forEach((t=>{h(r+(t.layout.positive-t.layout.negative)/2*t.segments[0].dataPoint.pixelPerUnit,this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase())}));const[a]=e;a.segments.forEach(((t,i)=>{const{start:s,end:e}=a.layout.segments[i];h(r+(s+e)/2*t.dataPoint.pixelPerUnit,this.i18n.get(t.scenario)||t.scenario)}))}getVarianceType(){return this.variancesDataModel.length>0?this.variancesDataModel[0].type:hl.NONE}calculateLeftSideWidth(t){var i,s,e;let n=0;const r=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(hl.NONE===t&&this.isStacked())this.stackSides.negative>0&&(n=this.stackSides.negative*this.pixelPerUnit,this.stackSides.minTotal<0&&(n+=r+this.calculateTotalLabelWidth(this.stackSides.minTotal))),this.stackLabelClearance.left>0&&(n=Math.max(n,this.stackLabelClearance.left*this.pixelPerUnit+this.calculateCategoryWidth()));else if(hl.NONE===t&&null!=(null===(i=this.smallestDataPointValue)||void 0===i?void 0:i.value)&&this.smallestDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestDataPointValue.value);n=Math.abs(this.smallestDataPointValue.getScaledUnit())+r+t}else if(hl.RELATIVE===t&&null!=(null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculatePercentageTextBoxWidth(this.smallestVarianceDataPointValue.value);n=Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit())+r+t}else if(hl.ABSOLUTE===t&&null!=(null===(e=this.smallestVarianceDataPointValue)||void 0===e?void 0:e.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value);n=Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())+r+t}return n<=this.titleLength?this.titleLength:n}calculateRightSideWidth(t){var i,s,e;if(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 n=0;const r=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(hl.NONE===t&&null!=(null===(i=this.highestDataPointValue)||void 0===i?void 0:i.value)&&this.highestDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestDataPointValue.value);n=Math.abs(this.highestDataPointValue.getScaledUnit())+r+t}else if(hl.RELATIVE===t&&null!=(null===(s=this.highestVarianceDataPointValue)||void 0===s?void 0:s.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculatePercentageTextBoxWidth(this.highestVarianceDataPointValue.value);n=Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit())+r+t}else if(hl.ABSOLUTE===t&&null!=(null===(e=this.highestVarianceDataPointValue)||void 0===e?void 0:e.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value);n=Math.abs(this.highestVarianceDataPointValue.getScaledUnit())+r+t}return n<=this.titleLength?this.titleLength:n}populateDimensionStackSegments(t,i,s){if(0===this.rowCount||!this.fromExpr||0===t.length)return;const e={[G.ROWGROUP]:"category",[G.ROWGROUPINDEX]:"category",[G.CATEGORY]:"subCategory",[G.CATEGORYINDEX]:"subCategory"}[s];if(!e)return;const n=s.toString(),r=t[0];let o;try{o=this.db.exec(`SELECT [${n}] as displayGroup, [${e}] as stackLabel, SUM([${r}] * transformOperator(operation)) as stackValue FROM ${this.fromExpr} GROUP BY [${n}], [${e}]`)}catch(t){return void this.failQuery(t)}const h=new Map;for(const t of o){const i=t.displayGroup;h.has(i)||h.set(i,[]),null!=t.stackValue&&null!=t.stackLabel&&h.get(i).push({label:t.stackLabel,value:t.stackValue})}for(const t of this.dataModel){const i=h.get(t.category);t.stackSegments=i&&i.length>0?i.map((i=>{const s=new fl(i.value,r,this.pixelPerUnit,wl.NEU);return s.key=Object.assign(Object.assign({},Bi(this.level,t.category)),{[e]:i.label,scenario:r}),{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,e=t+i+s;this.variancesDataModel&&this.variancesDataModel.length>0?(this.highestVarianceDataPointValue.getScaledUnit()>t&&(this.highestVarianceDataPointValue=new fl(e,this.highestVarianceDataPointValue.scenario,1,this.highestVarianceDataPointValue.variance)),null!=this.smallestVarianceDataPointValue.value&&Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())>t&&(this.smallestVarianceDataPointValue=new fl(-e,this.smallestVarianceDataPointValue.scenario,1,this.smallestVarianceDataPointValue.variance))):(this.highestDataPointValue.getScaledUnit()>t&&(this.highestDataPointValue=new fl(e,this.highestDataPointValue.scenario,1,this.highestDataPointValue.variance)),null!=this.smallestDataPointValue.value&&Math.abs(this.smallestDataPointValue.getScaledUnit())>t&&(this.smallestDataPointValue=new fl(-e,this.smallestDataPointValue.scenario,1,this.smallestDataPointValue.variance))),this.updatePosition()}}else this.overflowConfig=null}calculateOverflowConfig(t){const i=this.variancesDataModel&&this.variancesDataModel.length>0;if(this.getVarianceType()===hl.RELATIVE)return null;const s=i?this.highestVarianceDataPointValue:this.highestDataPointValue,e=i?this.smallestVarianceDataPointValue:this.smallestDataPointValue,n=s.getScaledUnit(),r=null!=e.value?Math.abs(e.getScaledUnit()):0,o=Math.max(n,r);if(o<=0)return null;const h=this.styles.fontStyles.size,a=h*this.styles.scaleFactors.labelToBar,l=1.5*h,c=.3*h,u=.8*h,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 o<=f?null:{cutWidth:d,overdriveZoneWidth:l,breakGap:c,maxOverflow:o-f,scenarioCutOffset:u}}}class zl{constructor(t=2,i=1){this.percent=t,this.decimal=i}}class Ul{adapt(t){const i=new zl;return R.isNumber(t.percent)&&(i.percent=t.percent),R.isNumber(t.decimal)&&(i.decimal=t.decimal),i}default(){return new zl}}const Fl=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.chartTitle="",this.scenarios=[],this.variances=[],this.hideCategories=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.i18n=new Map,this.order={hierarchy:[],direction:j.ASC},this.level=G.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},a(this)}getDb(){return this.stores||(this.stores=c(this.element)),this.stores.db.db}render(){var t,e,n,r;if(void 0===this.chart||void 0!==this.queryError)return i(s,null);if(this.chart.hasNoData()){const e=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return i(s,{class:"no-data"},i("div",{class:"empty-state"},e))}return i(s,null,i("div",{innerHTML:null===(e=this.pattern)||void 0===e?void 0:e.toString(),class:"hidePatternContainer",style:{width:"0",height:"0",overflow:"hidden"}}),i("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(n=this.chart)||void 0===n?void 0:n.getFooter()),i("div",{innerHTML:null===(r=this.chart)||void 0===r?void 0:r.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(),ui(this.errors,this.queryError)}async componentWillLoad(){var t;const i=this.getDb(),s=this.prepareConfig(),e=this.prepareStyle();this.chart=new Dl(new Cs(this.ruleSetConfig),i,this.tableName,s,e),this.chart.setI18n(this.i18n);const n=s.pixelPerUnit<=0;this.autoFitScaling(s,e),this.chart.setAvailableWidth(n?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new rl(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 Cs(this.ruleSetConfig)),this.chart.setConfig(i);const e=i.pixelPerUnit<=0;this.autoFitScaling(i,s),this.chart.setAvailableWidth(e?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new rl(this.chart.styles),this.chart.setPattern("hatched",this.pattern.getFCPolygonPattern()),this.syncQueryError()}autoFitScaling(t,i){var s;const e=t.pixelPerUnit<=0,n=t.pixelPerPercentage<=0;if(!e&&!n)return;const r=()=>{var i;null===(i=this.reportAutoScaling)||void 0===i||i.call(this,{unit:e?t.pixelPerUnit:void 0,percentage:n?t.pixelPerPercentage:void 0})},o=null===(s=this.parentDimensions)||void 0===s?void 0:s.width,h=this.getDb(),a=()=>{this.chart=new Dl(new Cs(this.ruleSetConfig),h,this.tableName,t,i),this.chart.setI18n(this.i18n)},l=()=>(this.chart.layout(),this.chart.getAllocatedCanvasWidth());if(!o||o<=0)return e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=50),a(),void r();e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=1),a();let c=l();if(c<=0)return void r();const u=Math.max(Nl,.9*o/c);let d=!1,f=!1,v=null;for(let i=0;i<=3;i++){const i=Tl({target:o,measured:c,unitExtent:e?this.chart.getUnitBarExtent():0,pctExtent:n?this.chart.getPercentBarExtent():0,currentPpu:t.pixelPerUnit,currentPpp:t.pixelPerPercentage});if(void 0===i.ppu&&void 0===i.ppp)break;if(e&&void 0!==i.ppu&&(t.pixelPerUnit=i.ppu,d=!0),n&&void 0!==i.ppp&&(t.pixelPerPercentage=i.ppp,f=!0),a(),c=l(),c<=o+.5&&(v={ppu:t.pixelPerUnit,ppp:t.pixelPerPercentage},c>=.98*o))break}let p=!1;if(e&&!d&&(t.pixelPerUnit=u,p=!0),n&&!f&&(t.pixelPerPercentage=u,p=!0),c>o+.5){if(v)d&&(t.pixelPerUnit=v.ppu),f&&(t.pixelPerPercentage=v.ppp);else{const i=o/c;e&&(t.pixelPerUnit=Math.max(Nl,t.pixelPerUnit*i)),n&&(t.pixelPerPercentage=Math.max(Nl,t.pixelPerPercentage*i))}p=!0}p&&a(),r()}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){const t=this.getDb(),i=$(t,this.tableName,this.filter);return this.measureScaleError=void 0,new dl(new pl,new tt(new cl),new cl,new Ul,t,i,(t=>{this.measureScaleError=ci(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 ml(new yl,new Ws,new Is(new Gs),new Ga(new Gs),new zs).adapt(this.styles);return s.locale=(null===(i=null===(t=c(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}get element(){return e(this)}};Fl.style=':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}';const Gl=class{validateFilter(t){const i="ERR_filter";v(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(Gt(t))return void this.errors.remove(i);const s=B(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(Gt(t))return void this.errors.remove(i);const s=H(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateLeftSync(t){const i="WARN_syncSpaceLeft";et(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"syncSpaceLeft: invalid value(s) '"+t+"' are not supported."})}validateUnitScaling(t){const i="WARN_unitScaling";N(t)?this.errors.remove(i):"invalid"===Xt(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="WARN_percentageScaling";N(t)?this.errors.remove(i):"invalid"===Xt(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validateDateInterval(t){const i="WARN_dateInterval";N(t)||nt(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateInterval: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateChartMode(t){const i="WARN_chartMode";["bar","line","auto"].includes(null==t?void 0:t.toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"chartMode: invalid value '"+(null==t?void 0:t.toString())+"' is not supported. Valid values are: bar, line, auto."})}validateMaxBars(t){const i="WARN_maxBars";!L(t)||t<1?this.errors.addOrReplace({id:i,type:"warning",message:"maxBars: invalid value '"+(null==t?void 0:t.toString())+"' is not supported. Must be a positive integer."}):this.errors.remove(i)}validateStack(t){const i="WARN_stack",s=J(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:s.join("; ")}):this.errors.remove(i)}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("WARN_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"WARN_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("WARN_scale")}validateAxisLabelsMode(t){const i="WARN_axisLabelsMode";N(t)||rt(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"axisLabelsMode: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";X(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.chartTitle="",this.filter="",this.syncSpaceLeft=-1,this.chartMode="bar",this.maxBars=28,this.stack="",this.intervalSpanLimit=28,this.lineFullWidth=!0,this.showCategories=!0,this.measureScale="greatest",this.showMeasureScale=!1,this.showOverlayAvg=!0,this.showOverlayMedian=!1,this.measureUnit="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this._lastObservedWidth=0,this._settleTimer=null,this._lastAppliedHeight=0,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=t=>{var i,s,e,n,r,o;this.lastAutoScalingReport={unit:null!==(i=t.unit)&&void 0!==i?i:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(e=t.percentage)&&void 0!==e?e:null===(n=this.lastAutoScalingReport)||void 0===n?void 0:n.percentage};const h=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),a=this.getEffectiveFontPx();if(void 0!==t.unit&&t.unit>0&&this.autoUnitWarningActive){const i=a/t.unit;h(i,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=i,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${Gl.describeScalingInput(String(null!==(r=this.unitScaling)&&void 0!==r?r:"").trim())}, auto-fitted to 1 em ≈ ${Jt(i)} units.`}))}if(void 0!==t.percentage&&t.percentage>0&&this.autoPctWarningActive){const i=100*a/t.percentage;h(i,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=i,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${Gl.describeScalingInput(String(null!==(o=this.percentageScaling)&&void 0!==o?o:"").trim())}, auto-fitted to 1 em ≈ ${Jt(i)} percentage points.`}))}},E(this),a(this),Yt(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=l(this),ns(this),this.componentStyle=k(this),this.ruleSetConfig=es(this),this.t=Bt(this).t,this.resolveInherited=qt(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"}],this.errors)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLeftSync(this.syncSpaceLeft),this.validateDateInterval(this.dateInterval),this.validateAxisLabelsMode(this.axisLabelsMode),this.validateMeasureScale(this.measureScale),this.validateChartMode(this.chartMode),this.validateMaxBars(this.maxBars),this.validateStack(this.stack),this.validateScaling(this.scale)}measureContentWidth(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-time-renderer");let s=0,e=!1;return null==i||i.forEach((t=>{var i,n,r;const o=parseFloat(null!==(r=null===(n=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===n?void 0:n.getAttribute("width"))&&void 0!==r?r:"");Number.isNaN(o)||(s=Math.max(s,o),e=!0)})),e?Math.max(Math.floor(s),this.element.scrollWidth):this.element.scrollWidth}measureContentHeight(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-time-renderer");let s=0,e=!1;return null==i||i.forEach((t=>{var i,n,r;const o=parseFloat(null!==(r=null===(n=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===n?void 0:n.getAttribute("height"))&&void 0!==r?r:"");Number.isNaN(o)||(s+=o,e=!0)})),e?Math.max(Math.floor(s),this.element.scrollHeight):this.element.scrollHeight}checkOverflow(){const t=Ut(this.element),i=this.measureContentWidth(),s=this.measureContentHeight(),e=t.width>0&&i>t.width+1,n=t.height>0&&s>t.height+1;if(!e&&!n)return void M(this.errors,null);const r=this.prepareVariances().some((t=>t.startsWith("dr"))),o="value"===Xt(this.unitScaling,this.pixelPerUnitGroupMap).kind,h=r&&"value"===Xt(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:a}=Ht(this.scale),l="auto"!==a&&"empty"!==a,c=[];n&&o&&c.push("unit-scaling"),n&&h&&c.push("percentage-scaling"),e&&l&&c.push("scale");const u=[];e&&u.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),n&&u.push(`height (${Math.round(s)}px > ${Math.round(t.height)}px)`),M(this.errors,`Chart exceeds available ${u.join(" and ")}. `+(c.length>0?`Adjust ${c.join(" / ")} or set to "auto".`:"Content does not fit even at minimum auto scaling; enlarge the container."),c.length>0)}componentDidRender(){$s(this.element,"bn-chart-time-renderer");const{mode:t}=Ht(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{width:s}=Ut(i);if(s<=0)return void this.checkOverflow();this._lastObservedWidth=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),n=i.scrollWidth,o=this.appliedScaleFactor;if(n<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const h=Math.max(.3,o*(s-1)/n);Math.abs(h-o)<.01||(i.style.setProperty("--bn-font-size",e*h+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${h.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,r((()=>{this.appliedScaleFactor=h}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=ss(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=Ut(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2&&(this._lastObservedWidth=t,n(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=Ut(this.element);this._lastObservedWidth=t,n(this)}))})),this.settleParentHeight()}settleParentHeight(){const t=[150,400,1e3,2500],i=()=>{if(this._settleTimer=null,!this.element.isConnected)return;const{height:s}=Ut(this.element);s>0&&Math.abs(s-this._lastAppliedHeight)>8&&!this._autoScaleGuard&&n(this);const e=t.shift();void 0!==e&&(this._settleTimer=setTimeout(i,e))};this._settleTimer=setTimeout(i,t.shift())}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null,null!=this._settleTimer&&(clearTimeout(this._settleTimer),this._settleTimer=null)}prepareDimension(){const t=Ut(this.element),i=this.prepareScenarios(),s=this.prepareVariances();this.canvasWidthSegmented=t.width/(i.length+s.length||1),this._lastAppliedHeight=t.height;const e=1+s.length,n=this.showMeasureScale?this.getEffectiveFontPx():0;return{width:this.canvasWidthSegmented,height:Math.max(0,t.height-n)/e}}prepareScenarios(){var t,i,s,e;const n=this.resolveInherited("scenarios",this.scenarios);if(n.inherited)return this.errors.remove("AUTO_scenarios"),n.value.split(",").map((t=>t.trim()));const r="auto"===(null===(t=n.value)||void 0===t?void 0:t.trim().toLowerCase());return N(n.value)||r?(null===(s=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===s?void 0:s.length)>0?(r||n.unresolved?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(e=n.value)||void 0===e?void 0:e.split(",").map((t=>t.trim())))}prepareAvg(){return this.showOverlayAvg}prepareMedian(){return this.showOverlayMedian}prepareVariances(){const t=this.resolveInherited("variances",this.variances).value;return N(t)?[]:null==t?void 0:t.split(",").map((t=>t.trim()))}checkVarianceScenarios(t){const i="WARN_variances_scenario",s=this.prepareScenarios(),e=[];for(const i of t){const t=new ks(i);if(t.isValid)for(const n of[t.base,t.delta])s.includes(n)||e.push(`'${i}' needs '${n}'`)}s.length>0&&e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:`variances: ${e.join(", ")}, which is not in scenarios (${s.join(", ")}). The variance has no values.`}):this.errors.remove(i)}prepareHideAxisLabels(t){return t>=1||!this.showCategories}prepareI18n(){const t=p,i=new Map(["no-data"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries(),...Ts(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const t=Xt(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/t.value):"auto"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${Gl.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const t=Xt(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/t.value):"auto"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${Gl.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const s=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-time"].scaleFactors.scenarioOffset,scenarioLabelToColumn:i["bn-chart-time"].scaleFactors.scenarioLabelToColumn,labelToColumn:i["bn-chart-time"].scaleFactors.labelToColumn,labelToAxis:i["bn-chart-time"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-time"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-time"].scaleFactors.needleHeadWidth,columnWidth:i["bn-chart-time"].scaleFactors.columnWidth,varianceAxisLineWidth:i["bn-chart-time"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-time"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-time"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-time"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-time"].scaleFactors.markerWidth,markerOffset:i["bn-chart-time"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-time"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-time"].scaleFactors.axisTickLength},fontStyles:{font:`${s}px ${i.global.fontFamily}`,family:i.global.fontFamily,size:s,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-time"].axisStyles,barStyles:i["bn-chart-time"].barStyles,varianceStyles:i["bn-chart-time"].varianceStyles,stackColors:i["bn-chart-time"].stackColors,padding:i["bn-chart-time"].padding,pattern:null,locale:"de"}}))}prepareLeftSideOffset(t,i){return this.syncSpaceLeft>-1?this.syncSpaceLeft:ra.getMaxWidthOfArrayItems([...this.prepareVariances(),...this.prepareScenarios(),this.chartTitle],t,i)}prepareChartTitle(t){return t>=1?"":this.chartTitle}prepareDateInterval(){var t,i,s;const e="auto"===(null===(t=this.dateInterval)||void 0===t?void 0:t.trim().toLowerCase());return N(this.dateInterval)||e?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedDateInterval)?(e?this.errors.remove("AUTO_dateInterval"):this.errors.addOrReplace({id:"AUTO_dateInterval",type:"warning",message:`dateInterval: not set, auto-detected: ${this.datasetMeta.suggestedDateInterval}`}),ot[this.datasetMeta.suggestedDateInterval.toUpperCase()]):e?ot.AUTO:void 0:(this.errors.remove("AUTO_dateInterval"),ot[null===(s=this.dateInterval)||void 0===s?void 0:s.toUpperCase()])}prepareIntervalSpanLimit(){const t=Number(this.intervalSpanLimit);return t>0?t:28}prepareAxisLabelsMode(){var t;return ht[null===(t=this.axisLabelsMode)||void 0===t?void 0:t.toUpperCase()]}prepareFilter(){return 0===this.filter.length?"":this.filter}getDataStructure(){return{ITimeChartDataRow:{setName:{type:"string",isOptional:!1,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return N(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareStackConfig(){if(N(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const t=JSON.parse(this.stack),i=t.by,s="WARN_stack_dimensions_scenarios";if(i===q.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:s,type:"warning",message:`stack by dimensions: only the first scenario "${t[0]}" is used, the rest (${t.slice(1).join(", ")}) are discarded.`}):this.errors.remove(s)}else this.errors.remove(s);return{by:i,mode:t.mode||Q.ABSOLUTE,order:t.order||K.DATASET}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareLineFullWidth(){return this.lineFullWidth}prepareChartMode(){var t;const i=null===(t=this.chartMode)||void 0===t?void 0:t.toLowerCase();return"line"===i?at.LINE:"auto"===i?at.AUTO:at.BAR}prepareMaxBars(){return Math.floor(Number(this.maxBars)||28)}chartTemplate(t,s){const e=this.prepareI18n(),n=this.prepareStyle(),r=Ut(this.element).width,o=this.preparePixelPerUnit(),h=this.preparePixelPerPercentage(),a=this.prepareStackConfig(),l=this.prepareScenarios(),c=(null==a?void 0:a.by)===q.DIMENSIONS?l.slice(0,1):l;return i("bn-chart-time-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(s),scenarios:c,variances:[t],hideAxisLabels:this.prepareHideAxisLabels(s),pixelPerUnit:o,pixelPerPercentage:h,reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,leftSideOffsetForHorizontalSync:this.prepareLeftSideOffset(e,n),styles:n,i18n:e,dateInterval:this.prepareDateInterval(),intervalSpanLimit:this.prepareIntervalSpanLimit(),axisLabelsMode:this.prepareAxisLabelsMode(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showOverlayAvg:this.prepareAvg(),showOverlayMedian:this.prepareMedian(),showMeasureScale:this.prepareShowMeasureScale(s),chartMode:this.prepareChartMode(),maxBars:this.prepareMaxBars(),stackConfig:a,lineFullWidth:this.prepareLineFullWidth(),containerWidth:r,parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}async getBaseline(){return Ui(this.element,"bn-chart-time-renderer")}async getLayoutState(t){var i,s,e,n;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",o=ei(this.element),h=this.getEffectiveScaleFactor(),a=Number.isFinite(h)&&h>0?h:1,l=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*a,c=this.prepareVariances(),u=Zi(this.element,"bn-chart-time-renderer",["base",...c],o,r),d=null===(s=this.element.shadowRoot)||void 0===s?void 0:s.querySelector("bn-chart-time-renderer"),f={version:li,tag:this.element.localName,id:ii(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:ti(this.element,o),em:{fontSizePx:l,appliedScaleFactor:a},regions:u.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(n=null==d?void 0:d.scenarios)&&void 0!==n?n:[],variances:c,barCount:u.barCount,chartMode:this.chartMode||void 0,hasNoData:0===u.barCount},diagnostics:Zt(this.element),scaling:this.resolveScalingInfo(l),baseline:u.baseline};return u.elements&&(f.elements=u.elements),f}resolveScalingInfo(t){var i,s;const e={},n=Xt(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===n.kind)e.unitMode="fixed",e.unitsPerEm=n.value,e.unitPxPerUnit=t/n.value;else{e.unitMode="auto";const s=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==s&&s>0&&(e.unitPxPerUnit=s,e.unitsPerEm=t/s)}const r=Xt(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)e.percentageMode="fixed",e.percentagePointsPerEm=r.value,e.percentagePxPerPoint=t/r.value;else{e.percentageMode="auto";const i=null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.percentage;void 0!==i&&i>0&&(e.percentagePxPerPoint=i/100,e.percentagePointsPerEm=100*t/i)}return e}getEffectiveScaleFactor(){const{mode:t,factor:i}=Ht(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){const t=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}));return t*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const o=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":o*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){let t=[""];const e=this.prepareVariances();this.checkVarianceScenarios(e),e.length>0&&(t=[...t,...e]);const n=this.getFontStyles();return i(s,{key:"37085b275bb92d716a31f79f15b9f2517f1c596b",style:n},i("div",{key:"93e9eacc22334da1deed871db640d6fd4aafb153",class:"container"},t.map(this.chartTemplate)))}get element(){return e(this)}static get watchers(){return{filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],syncSpaceLeft:[{validateLeftSync:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dateInterval:[{validateDateInterval:0}],chartMode:[{validateChartMode:0}],maxBars:[{validateMaxBars:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}],axisLabelsMode:[{validateAxisLabelsMode:0}],measureScale:[{validateMeasureScale:0}]}}};Gl.style=':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:column-reverse}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}';class jl{constructor(){this.scenarioOffset=.3,this.scenarioLabelToColumn=.3,this.labelToColumn=.3,this.labelToAxis=.3,this.needleWidth=.3,this.needleHeadWidth=.6,this.columnWidth=2,this.varianceAxisLineWidth=.3,this.axisLineWidth=.1,this.auxiliaryLineWidth=.1,this.scenarioLineWidth=.2,this.markerWidth=.7,this.markerOffset=0,this.categoryWidth=3,this.axisTickLength=.3}}class Il{adapt(t){const i=new jl;return R.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),R.isNumber(t.scenarioLabelToColumn)&&(i.scenarioLabelToColumn=t.scenarioLabelToColumn),R.isNumber(t.labelToColumn)&&(i.labelToColumn=t.labelToColumn),R.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),R.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),R.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),R.isNumber(t.columnWidth)&&(i.columnWidth=t.columnWidth),R.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),R.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),R.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),R.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),R.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),R.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),R.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),R.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new jl}}class Yl{constructor(t,i,s,e,n,r,o){this.categoryPosition={x:0,y:0},this.spacings=new jl,this.categoriesBoxOffset={width:0,height:0},this.padding=t,this.scaleFactors=i,this.fontStlye=s,this.dataLabelHeight=this.caluculateDataLabelHeight(),this.axisPosition={x:0,y:0},this.columnValue={min:e,max:n},this.numberOfColumns=r,this.leftSideLabelLength=o,this.calculateSpacings(),this.calculateCategoryPosition(),this.calculateAxisPosition()}caluculateDataLabelHeight(){return 1.1*Qh("123456789",{font:this.fontStlye.font,fontSize:this.fontStlye.size+"px"}).height}getColumnCenterPositionX(t){return this.categoryPosition.y+this.spacings.scenarioOffset+t*this.spacings.categoryWidth+this.leftSideLabelLength+.5*this.spacings.columnWidth}getAxisPositionY(t){let i=this.columnValue.max.getScaledUnit();return t&&(i=this.columnValue.max.getScaledPercentUnit()+this.getNeedleWidth()),i+this.dataLabelHeight+this.spacings.labelToAxis+this.padding.top}getAxisPositionX(){return this.padding.left+this.leftSideLabelLength}getColumnPositionX(t,i){return i?this.getColumnCenterPositionX(t):this.getColumnCenterPositionX(t)-this.spacings.scenarioOffset}getColumnPositionY(){return this.columnValue.max.getScaledUnit()+this.dataLabelHeight+this.spacings.labelToColumn+this.padding.top}getNeedlePositionY(){return this.columnValue.max.getScaledPercentUnit()+this.dataLabelHeight+this.spacings.labelToColumn+this.getNeedleWidth()+this.padding.top}getMarkerPositionX(t,i){return i?this.getColumnCenterPositionX(t)-this.spacings.markerOffset-.5*this.getColumnWidth():this.getColumnCenterPositionX(t)+this.spacings.markerOffset+.5*this.getColumnWidth()}getMarkerPositionY(){return this.getColumnPositionY()}getAxisTitlePositionX(t){const i=t.width();return this.axisPosition.x-i}getAxisTitlePositionY(t,i){let s=this.columnValue.max.getScaledUnit();return i&&(s=this.columnValue.max.getScaledPercentUnit()),t?s+this.dataLabelHeight+this.spacings.labelToAxis:s}getColumnDataLabelPositionY(t){const i=this.spacings.labelToColumn;return t<0?this.getColumnPositionY()+Math.abs(t)+i:this.getColumnPositionY()-t-i}getNeedleDataLabelPositionY(t){const i=this.spacings.labelToColumn;return t<0?this.getNeedlePositionY()+Math.abs(t)+i+2*this.getNeedleWidth():this.getNeedlePositionY()-t-i-2*this.getNeedleWidth()}getAxisEndPositionX(){return this.getAxisPositionX()+(this.numberOfColumns+.5)*this.spacings.categoryWidth}getColumnWidth(){return this.spacings.columnWidth}getNeedleWidth(){return this.spacings.needleWidth}getNeedleHeadWidth(){return this.spacings.needleHeadWidth}getScenarioLabelPositionOffsetX(t){return t?.5*this.getColumnWidth()+this.spacings.scenarioLabelToColumn:-(.5*this.getColumnWidth()+this.spacings.scenarioLabelToColumn)}calculateSpacings(){this.spacings={scenarioOffset:this.fontStlye.size*this.scaleFactors.scenarioOffset,scenarioLabelToColumn:this.fontStlye.size*this.scaleFactors.scenarioLabelToColumn,markerOffset:this.fontStlye.size*this.scaleFactors.markerOffset,labelToColumn:this.fontStlye.size*this.scaleFactors.labelToColumn,labelToAxis:this.fontStlye.size*this.scaleFactors.labelToAxis,needleWidth:this.fontStlye.size*this.scaleFactors.needleWidth,needleHeadWidth:this.fontStlye.size*this.scaleFactors.needleHeadWidth,columnWidth:this.fontStlye.size*this.scaleFactors.columnWidth,varianceAxisLineWidth:this.fontStlye.size*this.scaleFactors.varianceAxisLineWidth,axisLineWidth:this.fontStlye.size*this.scaleFactors.axisLineWidth,auxiliaryLineWidth:this.fontStlye.size*this.scaleFactors.auxiliaryLineWidth,scenarioLineWidth:this.fontStlye.size*this.scaleFactors.scenarioLineWidth,markerWidth:this.fontStlye.size*this.scaleFactors.markerWidth,categoryWidth:this.fontStlye.size*this.scaleFactors.categoryWidth,axisTickLength:this.fontStlye.size*this.scaleFactors.axisTickLength}}calculateCategoryPosition(){this.categoryPosition={x:this.padding.left+.5*this.spacings.columnWidth,y:this.padding.top}}calculateAxisPosition(){this.axisPosition={x:this.getAxisPositionX(),y:this.getAxisPositionY(!1)}}getMarkerScenarioLabelPositionOffsetX(t){return t?this.spacings.labelToColumn-this.fontStlye.size:this.spacings.labelToColumn+.5*this.spacings.markerWidth}}class Bl{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 Hl{constructor(t){const i=1*t,s=.7*t;this.bgOffset=(i-s)/2,this.markerUp={top:s/2+",0",left:"0,"+s,right:s+","+s},this.markerUpBackground={top:i/2+",0",left:"0,"+i,right:i+","+i},this.markerDown={bottom:s/2+","+s,left:"0,0",right:s+",0"},this.markerDownBackground={bottom:i/2+","+i,left:"0,0",right:i+",0"},this.markerRight={bottom:"0,"+s,top:"0,0",right:s+","+s/2},this.markerRightBackground={bottom:"0,"+i,top:"0,0",right:i+","+i/2},this.markerLeft={bottom:s+","+s,top:s+",0",left:"0,"+s/2},this.markerLeftBackground={bottom:i+","+i,top:i+",0",Left:"0,"+i/2}}upMarkerPatternStrings(){return{background:this.markerUpBackground.left+" "+this.markerUpBackground.right+" "+this.markerUpBackground.top+" "+this.markerUpBackground.left,foreground:this.markerUp.left+" "+this.markerUp.right+" "+this.markerUp.top+" "+this.markerUp.left,bgOffset:this.bgOffset}}downMarkerPatternStrings(){return{background:this.markerDownBackground.left+" "+this.markerDownBackground.right+" "+this.markerDownBackground.bottom+" "+this.markerDownBackground.left,foreground:this.markerDown.left+" "+this.markerDown.right+" "+this.markerDown.bottom+" "+this.markerDown.left,bgOffset:this.bgOffset}}rightMarkerPatternStrings(){return{background:this.markerRightBackground.top+" "+this.markerRightBackground.right+" "+this.markerRightBackground.bottom+" "+this.markerRightBackground.top,foreground:this.markerRight.top+" "+this.markerRight.right+" "+this.markerRight.bottom+" "+this.markerRight.top,bgOffset:this.bgOffset}}leftMarkerPatternStrings(){return{background:this.markerLeftBackground.top+" "+this.markerLeftBackground.Left+" "+this.markerLeftBackground.bottom+" "+this.markerLeftBackground.top,foreground:this.markerLeft.top+" "+this.markerLeft.left+" "+this.markerLeft.bottom+" "+this.markerLeft.top,bgOffset:this.bgOffset}}createPatternMapForStructureBar(){const t=new Map;return t.set("marker-up",this.upMarkerPatternStrings()),t.set("marker-down",this.downMarkerPatternStrings()),t.set("marker-right",this.rightMarkerPatternStrings()),t.set("marker-left",this.leftMarkerPatternStrings()),t}}class Vl{constructor(t){this.container=new uh,this.pattern=this.createFCPattern(this.container.group(),t),this.styles=t;let i=10;null!=t&&null!=t.fontStyles&&t.fontStyles.size&&(i=t.fontStyles.size),this.bgOffset=(1*i-.7*i)/2}createFCPattern(t,i){const s=i;return t.pattern(10,10,(function(t){t.rect(10,10).fill(s.barStyles.fc.fill),t.line(0,5,5,0).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"}),t.line(5,10,10,5).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"})})).id("pattern-time-fc")}getFCPolygonPattern(){return{background:"",foreground:"",bgOffset:0,pattern:this.pattern}}toString(){return this.container.svg()}}class Xl{constructor(t,i,s,e){this.value=t,this.scenario=i,this.pixelPerUnit=s||1;const n="string"==typeof e?As(e,null,!0):e;this.variance="neg"===n||n===Zl.NEG?Zl.NEG:"pos"===n||n===Zl.POS?Zl.POS:Zl.NEU}isEmpty(){return void 0===this.value||null==this.scenario}getScaledUnit(){return null==this.value?0:this.value*this.pixelPerUnit}getScaledPercentUnit(){return null==this.value?0:this.value>1.45?1.45*this.pixelPerUnit:this.value<-1.45?-1.45*this.pixelPerUnit:this.value*this.pixelPerUnit}getVarianceStyle(){return null==this.value||this.value>=0?this.variance:Zl.NEU===this.variance?Zl.NEU:Zl.POS===this.variance?Zl.NEG:Zl.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 Jl{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 ql{constructor(){}adapt(t){const i=new Jl;return R.isString(t.date)&&(i.date=this.parseDateString(t.date)),R.isOperator(t.operation)&&(i.operation=t.operation),R.isNumber(t.rowGroupIndex)&&R.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),R.isNumber(t.categoryIndex)&&R.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),R.isNumber(t.subCategoryIndex)&&R.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),R.isNumber(t.columnGroupIndex)&&R.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),R.isNumber(t.columnSubGroupIndex)&&R.isString(t.columnSubGroup)&&i.addSubColumnGroup(t.columnSubGroup,t.columnSubGroupIndex),this.setActualValues(t,i),this.setPlanValues(t,i),this.setPreviousPeriodValues(t,i),this.setForecastValues(t,i),i}parseDateString(t){if("string"!=typeof t)return;const i=y.fromISO(t,{zone:"utc"});if(i.isValid)return i;console.warn(`TimeChartDataRow: invalid date value '${t}' - skipping row`)}default(){return new Jl}setActualValues(t,i){R.isNumber(t.ac1)&&(i.ac1=t.ac1),R.isNumber(t.ac2)&&(i.ac2=t.ac2),R.isNumber(t.ac3)&&(i.ac3=t.ac3),R.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){R.isNumber(t.pl1)&&(i.pl1=t.pl1),R.isNumber(t.pl2)&&(i.pl2=t.pl2),R.isNumber(t.pl3)&&(i.pl3=t.pl3),R.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){R.isNumber(t.pp1)&&(i.pp1=t.pp1),R.isNumber(t.pp2)&&(i.pp2=t.pp2),R.isNumber(t.pp3)&&(i.pp3=t.pp3),R.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){R.isNumber(t.fc1)&&(i.fc1=t.fc1),R.isNumber(t.fc2)&&(i.fc2=t.fc2),R.isNumber(t.fc3)&&(i.fc3=t.fc3),R.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class Kl{constructor(t,i,s,e,n,r){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=e,this.varianceStyles=n,this.padding=r,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"],this.locale="de"}}class Ql{constructor(t,i,s,e,n){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=e,this.paddingadapter=n}adapt(t){const i=new Kl(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return R.isExisting(t)&&(R.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),R.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),R.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),R.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),R.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),R.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 Hl(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new Kl(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}var Zl,tc;!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"}(Zl||(Zl={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(tc||(tc={}));class ic{constructor(t,i,s){this.ID_AXIS="axis",this.CSS_AXIS_TITLE="categories",this.scenarioType=t.scenarioType,this.labelText=t.labelText||null,this.isRelative=t.isRelative||!1,this.position=i,this.svgGroup=s.group().id(this.ID_AXIS)}drawAxisTitle(t,i){null==i&&(i=""),t.text(i).addClass(this.CSS_AXIS_TITLE).attr("text-anchor","middle").move(this.position.getAxisTitlePositionX(t),this.position.getAxisTitlePositionY(!0,this.isRelative))}draw(){return this.labelText&&this.drawAxisTitle(this.svgGroup,this.labelText),this.svgGroup.line(this.position.getAxisPositionX(),this.position.getAxisPositionY(this.isRelative),this.position.getAxisEndPositionX(),this.position.getAxisPositionY(this.isRelative)).addClass(this.ID_AXIS+"-"+this.convertScenarioType()),this}convertScenarioType(){return void 0===this.scenarioType||null==this.scenarioType?"default":`${this.scenarioType}`.slice(0,2)}}class sc{constructor(t,i,s,e,n,r,o,h=null){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.scenarioLabel=null,this.isVarianceColumn=!1,this.overflowConfig=null,this.isOverflowing=!1,this.overdriveHeight=0,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=e,this.isPrimaryColumn=n,this.position=t,this.columnBarStyles=i.barStyles,this.overflowConfig=h,this.scenarioGroup=r,this.styles=i,this.columnGroup=r.group().id(r.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&(this.hasData=!0,this.dimensions=this.createDimensions(s,e,n),this.label=this.getDataLabel(s),this.scenarioLabel=this.getScenarioLabel(o))}setAsVariance(){var t;return this.isVarianceColumn=!0,null===(t=this.label)||void 0===t||t.setToVarianceLabel(),this}updateLabelGroup(t){var i;return this.isEmpty()||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1},i=new la){var s;if(this.isEmpty())return this;const e=this.getScenarioStyle(),n=this.convertToSVGStyle(e,"stroke"),r=this.getFillStyle(e);this.scenarioGroup.attr(ji(this.dataPoint.key)),null===(s=this.columnGroup)||void 0===s||s.attr(ji(this.dataPoint.key,"element")),null!=this.columnGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(r,n):this.columnGroup.rect(this.position.getColumnWidth(),this.dimensions.columnLength).fill(r).stroke(n).y(this.dimensions.yPos).cx(this.dimensions.xPos)),this.drawColumnDataLabel(t,i),this.drawScenarioLabel()}drawOverdriveBar(t,i){if(!this.columnGroup||!this.overflowConfig)return;const s=this.position.getColumnPositionY(),e=this.position.getColumnWidth(),n=this.dimensions.columnLength,{breakGap:r}=this.overflowConfig,o=s-n;this.columnGroup.rect(e,n).fill(t).stroke(i).y(o).cx(this.dimensions.xPos);const h=o-r-this.overdriveHeight;this.columnGroup.rect(e,this.overdriveHeight).fill(t).stroke(i).y(h).cx(this.dimensions.xPos),this.drawBreakIndicator(o,r)}drawBreakIndicator(t,i){if(!this.columnGroup)return;const s=this.position.getColumnWidth(),e=this.dimensions.xPos-s/2,n=t-i/2,r=.35*i,o=s/3;let h=`M ${e} ${n-r}`;for(let t=0;t<3;t++)h+=` L ${e+o*(t+.5)} ${n-r-.3*i} L ${e+o*(t+1)} ${n-r}`;let a=`M ${e} ${n+r}`;for(let t=0;t<3;t++)a+=` L ${e+o*(t+.5)} ${n+r+.3*i} L ${e+o*(t+1)} ${n+r}`;this.columnGroup.rect(s+2,i).fill("#ffffff").stroke("none").y(t-i).cx(this.dimensions.xPos),this.columnGroup.path(h).fill("none").stroke({color:"#000000",width:1}),this.columnGroup.path(a).fill("none").stroke({color:"#000000",width:1})}createDimensions(t,i,s){const e=t.getScaledUnit();if(this.overflowConfig&&e>0){const n="ac"===t.getScenario()?this.overflowConfig.cutHeight:this.overflowConfig.cutHeight-this.overflowConfig.scenarioCutOffset;if(e>n){this.isOverflowing=!0;const{breakGap:t,overdriveZoneHeight:r,maxOverflow:o}=this.overflowConfig;this.overdriveHeight=o>0?(e-n)/o*r:0;const h=n+t+this.overdriveHeight,a=this.position.getColumnPositionY();return{clipped:!1,columnLength:n,xPos:this.position.getColumnPositionX(i,s),yPos:a-n,labelYPos:a-h-this.position.spacings.labelToColumn,scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:a-.5*n}}}return e<0?{clipped:!1,columnLength:Math.abs(e),xPos:this.position.getColumnPositionX(i,s),yPos:this.position.getColumnPositionY(),labelYPos:this.position.getColumnDataLabelPositionY(e),scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getColumnPositionY()+.5*Math.abs(e)}:{clipped:!1,columnLength:e,xPos:this.position.getColumnPositionX(i,s),yPos:this.position.getColumnPositionY()-e,labelYPos:this.position.getColumnDataLabelPositionY(e),scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getColumnPositionY()-.5*Math.abs(e)}}getDataLabel(t){let i=na.Bottom;null!=t.value&&t.value<0&&(i=na.Top);const s=this.isOverflowing?this.dimensions.labelYPos:this.position.getColumnDataLabelPositionY(this.dataPoint.getScaledUnit());return new ca(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),s,this.ID_DATA_PREFIX,t.value,this.styles,i,na.Center).setPoint(t.key)}getScenarioLabel(t){return new ca(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,na.Center,this.isPrimaryColumn?na.Left:na.Right)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.isVarianceColumn||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(!0)}drawColumnDataLabel(t,i=new la){var s;null===(s=this.label)||void 0===s||s.draw(this.isPrimaryColumn,t,i)}getFillStyle(t){var i,s,e,n;const r=this.columnBarStyles[this.dataPoint.getScenario()];return(null==r?void 0:r.fillpattern)&&(null===(i=this.styles.pattern.get(r.fillpattern))||void 0===i?void 0:i.pattern)?null===(n=null===(e=null===(s=this.styles)||void 0===s?void 0:s.pattern)||void 0===e?void 0:e.get(r.fillpattern))||void 0===n?void 0:n.pattern:this.convertToSVGStyle(t,"fill")}getScenarioStyle(){var t;return this.isVarianceColumn?null===(t=this.styles)||void 0===t?void 0:t.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()):this.columnBarStyles[this.dataPoint.getScenario()]}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}}class ec{constructor(t,i,s,e,n,r,o,h,a){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.FALLBACK_COLOUR="#000000",this.scenarioLabel=null,this._defaultMarkerPattern=null,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.position=t,this.markerGroup=i||null,this.markerPattern=s||this._defaultMarkerPattern,this.styles=n,this.barStyles=n?n.barStyles:null,this.scenario=e,!0!==(null==r?void 0:r.isEmpty())&&(this.hasData=!0,this.pointKey=r.key,this.dimensions=this.createMarkerDimensions(r,o,a),this.scenarioLabel=this.getScenarioLabel(h,n,a))}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(ji(this.pointKey)),this.markerGroup.polygon(this.markerPattern.background).fill("#ffffff").cy(this.dimensions.yPos-this.dimensions.columnLength).cx(this.dimensions.xPos),this.markerGroup.polygon(this.markerPattern.foreground).fill(i).stroke(t).cy(this.dimensions.yPos-this.dimensions.columnLength).cx(this.dimensions.xPos).attr(ji(this.pointKey,"element")),null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(),this}createMarkerDimensions(t,i,s){return t.getScaledUnit()<0?{clipped:!1,labelYPos:0,columnLength:t.getScaledUnit(),xPos:this.position.getMarkerPositionX(i,s),yPos:this.position.getMarkerPositionY(),scenarioLabelXPos:this.position.getMarkerPositionX(i,s)+this.position.getMarkerScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getMarkerPositionY()+Math.abs(t.getScaledUnit())}:{clipped:!1,labelYPos:0,columnLength:t.getScaledUnit(),xPos:this.position.getMarkerPositionX(i,s),yPos:this.position.getMarkerPositionY(),scenarioLabelXPos:this.position.getMarkerPositionX(i,s)+this.position.getMarkerScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getMarkerPositionY()-Math.abs(t.getScaledUnit())}}getScenarioLabel(t,i,s){return null==this.markerGroup?null:new ca(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,na.Center,s?na.Right:na.Left)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}isEmpty(){return!1===this.hasData}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}class nc{constructor(t,i,s,e,n){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.dataLabel=null,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=e,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=n,this.styles=i,this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT);const r=void 0===(null==s?void 0:s.value)&&null!=(null==s?void 0:s.scenario);(!0!==(null==s?void 0:s.isEmpty())||r)&&(this.hasData=!0,this.dimensions=this.createDimensions(t,s,e),this.dataLabel=new ca(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),this.position.getNeedleDataLabelPositionY(this.dataPoint.getScaledPercentUnit()),this.ID_DATA_PREFIX,r?it:s.value,this.styles,na.Center,na.Center),this.dataLabel.setToRelativeVarianceLabel().setPoint(s.key))}updateLabelGroup(t){var i;return this.isEmpty()||null===(i=this.dataLabel)||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.dataLabel)||void 0===i||i.draw(),this;if(this.isEmpty())return this;this.scenarioGroup.attr(ji(this.dataPoint.key)),this.barGroup.attr(ji(this.dataPoint.key,"element"));const e=this.styles.varianceStyles[this.dataPoint.getVarianceStyle()],n=this.convertToSVGStyle(e,"stroke");let r=this.convertToSVGStyle(e,"fill");const o=this.convertToSVGStyle(this.styles.varianceStyles.ac,"stroke"),h=this.convertToSVGStyle(this.styles.varianceStyles.ac,"fill"),a=this.barStyles[this.dataPoint.getScenario()];if(null!=a&&a.fillpattern){const t=this.styles.pattern.get(a.fillpattern);null!=t&&(r=t.pattern)}this.dimensions.clipped?this.createClippedNeedleHead(r,n):this.createNeedleHead(o,h),this.barGroup.rect(this.position.getNeedleWidth(),this.dimensions.columnLength).cx(this.dimensions.xPos).y(this.dimensions.yPos).fill(r).stroke(n),null===(s=this.dataLabel)||void 0===s||s.draw()}createDimensions(t,i,s){return i.getScaledPercentUnit()<0?{labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,columnLength:Math.abs(i.getScaledPercentUnit()),xPos:t.getColumnCenterPositionX(s),yPos:t.getNeedlePositionY(),clipped:i.isClipped()}:{columnLength:i.getScaledPercentUnit(),xPos:t.getColumnCenterPositionX(s),yPos:t.getNeedlePositionY()-i.getScaledPercentUnit(),labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:i.isClipped()}}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}createClippedNeedleHead(t,i){const s=this.barGroup.polygon("0,0 5,9 -5,9 0,0 0,5 5,13 -5,13 0,5").fill(t).cx(this.dimensions.xPos).cy(this.getHeadYPosition()).fill(t).stroke(i);null!=this.dataPoint.value&&this.dataPoint.value<0&&s.flip("y")}createNeedleHead(t,i){this.barGroup.rect(2*this.position.getNeedleWidth(),this.position.getNeedleHeadWidth()).cx(this.dimensions.xPos).cy(this.getHeadYPosition()).fill(t).stroke(i)}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getHeadYPosition(){let t=this.dimensions.yPos;return null!=this.dataPoint.value&&this.dataPoint.value<0&&(t+=this.dimensions.columnLength),t}}const rc={ac:{markerFill:"#000000",markerStroke:"#000000",lineColor:"#000000"},pp:{markerFill:"#999999",markerStroke:"#999999",lineColor:"#999999"},fc:{markerFill:"#ffffff",markerStroke:"#000000",lineColor:"#000000",lineDashArray:"4,4"},pl:{markerFill:"#ffffff",markerStroke:"#000000",lineColor:"#000000"}};class oc{constructor(t,i,s,e,n,r,o,h,a=null,l){this.lineSlot=l,this.MARKER_SIZE=8,this.LINE_WIDTH=2,this.ID_LINE_PREFIX="LINE",this.ID_MARKER_PREFIX="MARKER",this.ID_LABEL_PREFIX="LABEL",this.ESTIMATED_LABEL_WIDTH=56,this.ESTIMATED_LABEL_HEIGHT=24,this.position=t,this.styles=i,this.dataPoints=s,this.scenarioGroup=e,this.labelGroup=n,this.scenarioName=r,this.scenarioLabel=o,this.collisionManager=a}draw(t={percent:2,decimal:1},i=new la){return this.drawGeometry(),this.drawLabels(t,i),this}drawGeometry(){if(0===this.dataPoints.length)return this;const t=this.getLineStyle();return this.drawLines(t),this.drawMarkers(t),this}drawLabels(t={percent:2,decimal:1},i=new la){return 0===this.dataPoints.length||(this.drawScenarioLabel(),this.drawValueLabels(t,i)),this}getLineStyle(){var t,i,s;const e=null!==(t=this.lineSlot)&&void 0!==t?t:(null===(s=null===(i=this.scenarioName)||void 0===i?void 0:i.slice(0,2))||void 0===s?void 0:s.toLowerCase())||"ac";return rc[e]||rc.ac}getScenarioVariant(){var t;const i=parseInt((null===(t=this.scenarioName)||void 0===t?void 0:t.slice(-1))||"1",10);return isNaN(i)?1:Math.min(Math.max(i,1),4)}drawSquareMarker(t,i,s,e){const n=this.MARKER_SIZE/2;return t.rect(this.MARKER_SIZE,this.MARKER_SIZE).fill(e.markerFill).stroke({color:e.markerStroke,width:1}).move(i-n,s-n)}drawCircleMarker(t,i,s,e){return t.circle(this.MARKER_SIZE).fill(e.markerFill).stroke({color:e.markerStroke,width:1}).center(i,s)}drawTriangleMarker(t,i,s,e){const n=this.MARKER_SIZE/2;return t.polygon(`${i},${s-n} ${i-n},${s+n} ${i+n},${s+n}`).fill(e.markerFill).stroke({color:e.markerStroke,width:1})}drawDiamondMarker(t,i,s,e){const n=this.MARKER_SIZE/2;return t.polygon(`${i},${s-n} ${i+n},${s} ${i},${s+n} ${i-n},${s}`).fill(e.markerFill).stroke({color:e.markerStroke,width:1})}drawLines(t){const i=this.scenarioGroup.group().id(this.ID_LINE_PREFIX);for(let s=1;s<this.dataPoints.length;s++){const e=this.dataPoints[s-1],n=this.dataPoints[s];if(e.dataPoint.isEmpty()||n.dataPoint.isEmpty())continue;const r=this.position.getColumnCenterPositionX(e.index),o=this.position.getColumnPositionY()-e.dataPoint.getScaledUnit(),h=this.position.getColumnCenterPositionX(n.index),a=this.position.getColumnPositionY()-n.dataPoint.getScaledUnit(),l=i.line([[r,o],[h,a]]).stroke({color:t.lineColor,width:this.LINE_WIDTH,linecap:"round"}).fill("none");t.lineDashArray&&l.attr("stroke-dasharray",t.lineDashArray)}}drawMarkers(t){const i=this.scenarioGroup.group().id(this.ID_MARKER_PREFIX),s=this.getScenarioVariant();for(const e of this.dataPoints){if(e.dataPoint.isEmpty())continue;const n=this.position.getColumnCenterPositionX(e.index),r=this.position.getColumnPositionY()-e.dataPoint.getScaledUnit();let o;switch(s){case 2:o=this.drawCircleMarker(i,n,r,t);break;case 3:o=this.drawTriangleMarker(i,n,r,t);break;case 4:o=this.drawDiamondMarker(i,n,r,t);break;default:o=this.drawSquareMarker(i,n,r,t)}o.attr(ji(e.dataPoint.key,"element")).attr("data-bn-index",String(e.index))}}getLabelPositionPriority(t){const i=this.dataPoints[t];let s=null;for(let i=t+1;i<this.dataPoints.length;i++)if(!this.dataPoints[i].dataPoint.isEmpty()){s=this.dataPoints[i];break}let e=null;for(let i=t-1;i>=0;i--)if(!this.dataPoints[i].dataPoint.isEmpty()){e=this.dataPoints[i];break}const n=i.dataPoint.getScaledUnit();return e&&s&&e.dataPoint.getScaledUnit()>n&&s.dataPoint.getScaledUnit()>n?[da.Below,da.Left,da.Right,da.Above]:[da.Above,da.Left,da.Right,da.Below]}getScenarioType(){var t,i;return(null===(i=null===(t=this.scenarioName)||void 0===t?void 0:t.slice(0,2))||void 0===i?void 0:i.toLowerCase())||"ac"}drawValueLabels(t,i){const s=this.getScenarioType();for(let e=0;e<this.dataPoints.length;e++){const n=this.dataPoints[e];if(n.dataPoint.isEmpty()||null===n.dataPoint.value)continue;const r=this.position.getColumnCenterPositionX(n.index),o=this.position.getColumnPositionY()-n.dataPoint.getScaledUnit();let h=r,a=o-this.MARKER_SIZE/2-2,l=na.Bottom,c=na.Center;if(this.collisionManager){const t=this.getLabelPositionPriority(e),i=this.collisionManager.getOptimalPlacement(r,o,this.ESTIMATED_LABEL_WIDTH,this.ESTIMATED_LABEL_HEIGHT,n.index,this.MARKER_SIZE,s,t);if(null===i)continue;h=i.labelX,a=i.labelY,l=i.verticalHook,c=i.horizontalHook;const u=Object.assign(Object.assign({},i.bounds),{scenarioType:s});this.collisionManager.register(u)}new ca(this.labelGroup,h,a,this.ID_LABEL_PREFIX,n.dataPoint.value,this.styles,l,c).setPoint(n.dataPoint.key).draw(!0,t,i)}}drawScenarioLabel(){if(!this.scenarioLabel)return;let t=null;for(let i=this.dataPoints.length-1;i>=0;i--)if(!this.dataPoints[i].dataPoint.isEmpty()){t=this.dataPoints[i];break}if(!t)return;const i=this.position.getColumnCenterPositionX(t.index)+this.MARKER_SIZE+4,s=this.position.getColumnPositionY()-t.dataPoint.getScaledUnit(),e=this.getScenarioType();if(this.collisionManager){if(this.collisionManager.shouldHideScenarioLabel(i,s,e))return;this.collisionManager.registerScenarioLabel(i,s,e)}new ca(this.labelGroup,i,s,"SCENARIO_LABEL",this.scenarioLabel,this.styles,na.Center,na.Left).forceStringTypeDraw()}}class hc{constructor(t,i,s,e,n,r,o,h,a,l,c){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=e,this.segment=n,this.segmentIndex=o,this.stackMode=h,this.stack=a,this.group=c,this.columnGroup=c.group().id(`stacked_col_${e}_seg_${o}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new la){if(!this.hasData||!Number.isFinite(this.dataPoint.value))return;const s=this.dataPoint.value,e=this.dataPoint.pixelPerUnit,n=this.position.getColumnPositionY(),r=Math.abs(this.segment.end-this.segment.start)*e,o=n-Math.max(this.segment.start,this.segment.end)*e,h=this.position.getColumnCenterPositionX(this.index),a=this.position.getColumnWidth(),l=this.styles.stackColors,c=l[this.segmentIndex%l.length],u={color:c},d={color:c,width:.5};if(this.columnGroup.attr(ji(this.dataPoint.key,"element")),this.columnGroup.rect(a,Math.max(r,.5)).fill(u).stroke(d).y(o).cx(h),r>=18){const e=o+r/2;if(this.stackMode===Q.RELATIVE||this.stackMode===Q.ABSOLUTE_RELATIVE){const i=ra.number(this.segment.share,"percent",t.percent,t.percent,1,this.styles.locale);new ca(this.group,h,e,"STACK_SEG",i,this.styles,na.Center,na.Center).setSegmentFill(c).setPoint(this.dataPoint.key).forceStringTypeDraw()}else new ca(this.group,h,e,"STACK_SEG",s,this.styles,na.Center,na.Center).setSegmentFill(c).setPoint(this.dataPoint.key).draw(!0,t,i)}}drawTotalLabel(t={percent:2,decimal:1},i=new la,s){if(this.stackMode===Q.RELATIVE)return;const e=this.stack.total<0,n=e?0-this.stack.negative:this.stack.positive,r=this.position.getColumnCenterPositionX(this.index),o=this.position.getColumnDataLabelPositionY(n*this.dataPoint.pixelPerUnit);new ca(this.group,r,o,"STACK_TOTAL",this.stack.total,this.styles,e?na.Top:na.Bottom,na.Center).setPoint(s,"total").draw(!0,t,i)}}const ac={ac:{fill:"#000000",opacity:.3,lineColor:"#000000"},pp:{fill:"#999999",opacity:.3,lineColor:"#999999"},fc:{fill:"#000000",opacity:.2,lineColor:"#000000",dashArray:"4,4"},pl:{fill:"#000000",opacity:.1,lineColor:"#000000"}},lc=[{fill:"#000000",opacity:.3},{fill:"#555555",opacity:.25},{fill:"#999999",opacity:.2},{fill:"#bbbbbb",opacity:.15},{fill:"#dddddd",opacity:.1}];class cc{constructor(t,i,s,e,n,r){this.group=t.group().id(`area_fill_${n}`),this.upperPoints=i,this.lowerPoints=s,this.scenarioType=e,this.segmentIndex=n,this.isScenarioStack=r}draw(){if(this.upperPoints.length<2||this.lowerPoints.length<2)return;let t,i,s=`M ${this.upperPoints[0].x},${this.upperPoints[0].y}`;for(let t=1;t<this.upperPoints.length;t++)s+=` L ${this.upperPoints[t].x},${this.upperPoints[t].y}`;for(let t=this.lowerPoints.length-1;t>=0;t--)s+=` L ${this.lowerPoints[t].x},${this.lowerPoints[t].y}`;if(s+=" Z",this.isScenarioStack&&this.scenarioType){const s=this.scenarioType.slice(0,2).toLowerCase(),e=ac[s]||ac.ac;t=e.fill,i=e.opacity}else{const s=Math.min(this.segmentIndex,lc.length-1);t=lc[s].fill,i=lc[s].opacity}this.group.path(s).fill(t).opacity(i).stroke("none")}drawBoundaryLine(){if(this.upperPoints.length<2)return;let t,i="#000000";if(this.isScenarioStack&&this.scenarioType){const s=this.scenarioType.slice(0,2).toLowerCase(),e=ac[s]||ac.ac;i=e.lineColor,t=e.dashArray}const s=this.group.polyline(this.upperPoints.map((t=>[t.x,t.y]))).fill("none").stroke({color:i,width:1.5});t&&s.attr("stroke-dasharray",t)}}class uc{constructor(t,i,s,e,n,r,o,h){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.scenarioLabel=null,this.isVarianceLine=!1,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.previousDimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=n,this.isPrimaryLine=r,this.position=t,this.LineBarStyles=i.barStyles,this.scenarioGroup=o,this.styles=i,this.LineGroup=o.group().id(o.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&(this.hasData=!0,this.dimensions=this.createDimensions(s,n,r),this.label=this.getDataLabel(s),this.scenarioLabel=this.getScenarioLabel(h)),this.previousDimensions=this.createDimensions(e,n-1,r)}setAsVariance(){var t;return this.isVarianceLine=!0,null===(t=this.label)||void 0===t||t.setToVarianceLabel(),this}updateLabelGroup(t){var i;return this.isEmpty()||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1},i=new la){if(this.isEmpty())return this;const s=this.getScenarioStyle(),e=this.getFillStyle(s);null!=this.LineGroup&&this.LineGroup.line([[this.previousDimensions.xPos,this.previousDimensions.yPos],[this.dimensions.xPos,this.dimensions.yPos]]).fill(e).stroke({color:"#f06",width:3,linecap:"round"}),this.drawLineDataLabel(t,i),this.drawScenarioLabel()}createDimensions(t,i,s){return{clipped:!1,columnLength:t.getScaledUnit(),xPos:this.position.getColumnPositionX(i,s),yPos:this.position.getColumnPositionY()-t.getScaledUnit(),labelYPos:this.position.getColumnDataLabelPositionY(t.getScaledUnit()),scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getColumnPositionY()-t.getScaledUnit()}}getDataLabel(t){let i=na.Bottom;return null!=t.value&&t.value<0&&(i=na.Top),new ca(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),this.position.getColumnDataLabelPositionY(this.dataPoint.getScaledUnit()),this.ID_DATA_PREFIX,t.value,this.styles,i,na.Center)}getScenarioLabel(t){return new ca(this.scenarioGroup,0,0,this.ID_SCENARIO_PREFIX,t,this.styles,na.Bottom,na.Left)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.isVarianceLine||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(!0)}drawLineDataLabel(t,i=new la){var s;null===(s=this.label)||void 0===s||s.draw(this.isPrimaryLine,t,i)}getFillStyle(t){var i,s,e,n;const r=this.LineBarStyles[this.dataPoint.getScenario()];return(null==r?void 0:r.fillpattern)&&(null===(i=this.styles.pattern.get(r.fillpattern))||void 0===i?void 0:i.pattern)?null===(n=null===(e=null===(s=this.styles)||void 0===s?void 0:s.pattern)||void 0===e?void 0:e.get(r.fillpattern))||void 0===n?void 0:n.pattern:this.convertToSVGStyle(t,"fill")}getScenarioStyle(){var t;return this.isVarianceLine?null===(t=this.styles)||void 0===t?void 0:t.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()):this.LineBarStyles[this.dataPoint.getScenario()]}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}}class dc{constructor(t,i,s,e,n){this.pixelPerUnit=1,this.collisionManager=null,this.overflowConfig=null,this.i18n=n;const r=i.group().id("Scenario1"),o=i.group().id("Scenario2").insertBefore(r);this.svgGroups={parent:i,scenario1:r,scenario2:o,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=e}setOverflowConfig(t){this.overflowConfig=t}createLine(t,i,s,e){const n=this.svgGroups.scenario1.group().id(""+e),r=this.svgGroups.scenario1Label.group().id(""+e);let o=null;return this.isLastDataPoint(e-1)&&(o=t),new uc(this.position,this.styles,i,s,e,!1,n,o).updateLabelGroup(r)}createPrimaryBar(t,i){const s=this.svgGroups.scenario1.group().id(""+i),e=this.svgGroups.scenario1Label.group().id(""+i);let n=null;return this.isLastDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new sc(this.position,this.styles,t,i,!0,s,n,this.overflowConfig).updateLabelGroup(e)}createVarianceBar(t,i){const s=this.svgGroups.scenario1.group().id(""+i),e=this.svgGroups.scenario1Label.group().id(""+i);let n=null;return this.isLastDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new sc(this.position,this.styles,t,i,!0,s,n,this.overflowConfig).updateLabelGroup(e).setAsVariance()}createRelativeVarianceBar(t,i){const s=this.svgGroups.scenario1.group().id(""+i),e=this.svgGroups.scenario1Label.group().id(""+i);return new nc(this.position,this.styles,t,i,s).updateLabelGroup(e)}createSecondaryBar(t,i){const s=this.svgGroups.scenario2.group().id(""+i);let e=null;return this.isFirstDataPoint(i)&&(e=`${this.i18n.get(t.scenario)||t.scenario}`),new sc(this.position,this.styles,t,i,!1,s,e,this.overflowConfig)}createPrimaryMarker(t,i){const s=this.svgGroups.scenario3.group().id(""+i),e=this.styles.pattern.get("marker-right")||{foreground:"#000000",background:"#ffffff",bgOffset:0};let n=null;return this.isFirstDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new ec(this.position,s,e,t.scenario,this.styles,t,i,n,!0)}createSecondaryMarker(t,i){const s=this.svgGroups.scenario4.group().id(""+i),e=this.styles.pattern.get("marker-left")||{foreground:"#000000",background:"#ffffff",bgOffset:0};let n=null;return this.isLastDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new ec(this.position,s,e,t.scenario,this.styles,t,i,n,!1)}isLastDataPoint(t){return this.elementCnt-1===t}isFirstDataPoint(t){return 0===t}setCollisionManager(t){this.collisionManager=t}moveLabelsToFront(){this.svgGroups.scenario1Label.front()}createLineSeries(t,i,s){const e=this.svgGroups.parent.group().id("LineSeries_"+i),n=this.svgGroups.scenario1Label.group().id("LineSeries_Label_"+i),r=`${this.i18n.get(i)||i}`;return new oc(this.position,this.styles,t,e,n,i,r,this.i18n,this.collisionManager,s)}}const fc="bn-measurement-host";function vc(t,i){const s=function(){if("undefined"==typeof document||!document.body)return null;let t=document.getElementById(fc);return t||(t=document.createElement("div"),t.id=fc,t.style.cssText="opacity:0;position:absolute;left:-100%;top:-100%;overflow:hidden",t.setAttribute("aria-hidden","true"),document.body.appendChild(t)),t}();if(s){s.appendChild(t.node);try{i()}finally{t.node.parentNode===s&&s.removeChild(t.node)}}else i()}var pc,gc;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(pc||(pc={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(gc||(gc={}));class mc{constructor(t,i,s,e,n,r=0){this.CSS_CATEGORIES="categories",this.dataModel=[],this.variancesDataModel=[],this.title="",this.configTitle="",this.configVariances=[],this.smallestDataPointValue=new Xl(0,Zl.AC1,1,Zl.NEU),this.highestDataPointValue=new Xl(0,Zl.AC1,1,Zl.NEU),this.smallestVarianceDataPointValue=new Xl(0,Zl.AC1,1,Zl.NEU),this.highestVarianceDataPointValue=new Xl(0,Zl.AC1,1,Zl.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.hideAxisLabels=!1,this.axisScenario=Zl.AC1,this.fromExpr="",this.rowCount=0,this.axisCategoryArea={width:0,height:0},this.scenariosArea={width:0,height:0},this.state=pc.DIRTY,this.i18n=new Map,this.leftSideOffsetForHorizontalSync=-1,this.dateInterval=ot.DAY,this.locale="de",this.axisLabelsMode=ht.SMART,this.intervalSpanLimit=32,this.measureScale=new la,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.showOverlayMedian=!1,this.showOverlayAvg=!1,this.chartMode=at.BAR,this.maxBars=28,this.stackConfig=null,this.scenarioPropOrder=[],this.lineFullWidth=!0,this.availableWidth=0,this.overflowConfig=null,this.lastScenarios=[],this.db=i,this.tableName=s,this.ruleSet=t||new Cs,this.i18n=this.createI18n(new Map),this.styles=n,this.availableWidth=r,this.setConfig(e),this.position=this.createElementPosition(this.lastScenarios)}updatePosition(t){this.position=this.createElementPosition(t)}setStyles(t){this.styles=t}setRuleSet(t){this.ruleSet=t||new Cs}setAvailableWidth(t){this.availableWidth=t}setAvailableHeight(t){this.pixelPerUnit<=0||t<=0?this.overflowConfig=null:null==this.stackConfig&&this.determineEffectiveChartMode()===at.BAR?(this.overflowConfig=this.calculateOverflowConfig(t),this.overflowConfig&&this.updatePosition(this.lastScenarios)):this.overflowConfig=null}calculateOverflowConfig(t){const i=(this.isVarianceChart()?this.highestVarianceDataPointValue:this.highestDataPointValue).getScaledUnit();if(i<=0)return null;const s=this.styles.fontStyles.size,e=1.5*s,n=.3*s,r=t-(this.position.dataLabelHeight+this.position.spacings.labelToColumn+this.position.padding.top+this.position.padding.bottom+this.position.spacings.labelToAxis+s)-e-n,o=.8*s;if(r<=o)return null;const h=r-o;return i<=h?null:{cutHeight:r,overdriveZoneHeight:e,breakGap:n,maxOverflow:i-h,scenarioCutOffset:o}}setConfig(t){var i;this.state=pc.DIRTY,this.locale=t.locale,this.scenarioPropOrder=[...t.scenarios];const s=this.sortScenariosbyVisualisationRules(t.scenarios);if(this.setSource(t.filter),this.hideAxisLabels=t.hideAxisLabels||!1,this.pixelPerUnit=t.pixelPerUnit,this.pixelPerPercentage=t.pixelPerPercentage,this.axisLabelsMode=t.axisLabelsMode,this.intervalSpanLimit=t.intervalSpanLimit,this.dateInterval=this.findDateInterval(t.dateInterval),this.dataModel=this.populateModel(s,this.dateInterval),this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.configTitle=t.title,this.configVariances=null!==(i=null==t?void 0:t.variances)&&void 0!==i?i:[],this.updateTitle(),this.smallestDataPointValue=this.findSmallestDataPointValue(this.dataModel),this.smallestVarianceDataPointValue=this.findSmallestDataPointValue(this.variancesDataModel),this.highestDataPointValue=this.findHighestDataPointValue(this.dataModel),this.highestVarianceDataPointValue=this.findHighestDataPointValue(this.variancesDataModel),this.axisScenario=this.setAxisScenario(t.variances),this.leftSideOffsetForHorizontalSync=t.leftSideOffsetForHorizontalSync,this.measureScale=t.measureScale,this.measureUnit=t.measureUnit,this.dataFormatDigits=t.dataFormatDigits,this.showOverlayMedian=t.showOverlayMedian,this.showOverlayAvg=t.showOverlayAvg,this.chartMode=t.chartMode,this.maxBars=t.maxBars,this.stackConfig=t.stackConfig,this.lineFullWidth=t.lineFullWidth,this.lastScenarios=s,null!=this.stackConfig){const t=[];for(const i of this.dataModel)t.push(...this.stackGroups(i).map((t=>t.layout)));const i=Pl(t),{scenario:s,variance:e}=this.highestDataPointValue;this.highestDataPointValue=new Xl(i.positive,s,this.pixelPerUnit,e),this.smallestDataPointValue=new Xl(0-i.negative,s,this.pixelPerUnit,e)}this.updatePosition(s)}getFooter(){return 1===this.measureScale.value&&""===this.measureUnit?" ":ra.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}sortScenariosbyVisualisationRules(t){const i=this;return[...t].sort(((t,s)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(s))).reverse()}setI18n(t){this.i18n=this.createI18n(t),this.updateTitle()}updateTitle(){var t;this.title=this.configTitle||ra.translateScenarioLabel(null===(t=this.configVariances)||void 0===t?void 0:t.toString(),this.i18n)}setSource(t){var i,s;if(this.state=pc.DIRTY,this.queryError=void 0,this.fromExpr=$(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=ci(t))}getAllocatedCanvasWidth(){const t=this.position.getAxisEndPositionX(),i=3*this.styles.fontStyles.size,s=Math.max(this.axisCategoryArea.width,this.scenariosArea.width);return Math.max(t+i,s>0?s+this.position.leftSideLabelLength:0)}getAllocatedCanvasHeight(){if(null==this.smallestVarianceDataPointValue.value||null==this.highestVarianceDataPointValue.value||null==this.smallestDataPointValue.value||null==this.highestDataPointValue.value)return 0;const t=this.isVarianceChart()&&this.variancesDataModel.some((t=>t.type===gc.RELATIVE)),i=this.position.getAxisPositionY(t),s=this.position.spacings.labelToAxis+this.position.dataLabelHeight+this.styles.padding.bottom;let e;if(this.isOnSameAxisSide())e=i+s;else{const t=this.isVarianceChart()?this.smallestVarianceDataPointValue:this.smallestDataPointValue;e=i+Math.abs(t.getScaledUnit())+this.position.spacings.labelToColumn+this.position.dataLabelHeight+s}const n=this.isOnSameAxisSide();return Math.max(e,n?this.axisCategoryArea.height+this.scenariosArea.height:this.scenariosArea.height)}getUnitBarExtent(){var t,i;const s=this.isVarianceChart()&&this.variancesDataModel.some((t=>t.type===gc.RELATIVE)),e=this.isVarianceChart(),n=e?this.highestVarianceDataPointValue:this.highestDataPointValue,r=e?this.smallestVarianceDataPointValue:this.smallestDataPointValue;return Ll({relativeVariance:s,maxPositive:null!==(t=null==n?void 0:n.value)&&void 0!==t?t:0,minNegative:this.isOnSameAxisSide()?0:null!==(i=null==r?void 0:r.value)&&void 0!==i?i:0})}getPercentBarExtent(){var t,i,s,e;return El({relativeVariance:this.isVarianceChart()&&this.variancesDataModel.some((t=>t.type===gc.RELATIVE)),maxPositive:null!==(i=null===(t=this.highestVarianceDataPointValue)||void 0===t?void 0:t.value)&&void 0!==i?i:0,minNegative:this.isOnSameAxisSide()?0:null!==(e=null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&void 0!==e?e:0})}layout(){const t=new uh;vc(t,(()=>this.draw(t)))}toString(){const t=new uh;return vc(t,(()=>this.draw(t))),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}applyFontToContainer(t){t.attr({"font-size":this.styles.fontStyles.size,"font-family":this.styles.fontStyles.family})}draw(t){this.cleanSVGforRedraw(t),this.applyFontToContainer(t),this.state===pc.DIRTY&&(this.state=pc.UP_TO_DATE),this.isVarianceChart()?(this.drawVarianceScenario(this.variancesDataModel,t),this.drawAxisAndLabels(this.variancesDataModel,t)):null!=this.stackConfig?this.determineEffectiveChartMode()===at.LINE?(this.drawStackedAreaScenarios(this.dataModel,t),this.drawAxisAndLabelsForLineChart(this.dataModel,t)):(this.drawStackedScenarios(this.dataModel,t),this.drawStackedHeaders(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t)):this.determineEffectiveChartMode()===at.LINE?(this.drawLineScenarios(this.dataModel,t),this.drawAxisAndLabelsForLineChart(this.dataModel,t)):(this.drawScenarios(this.dataModel,t),this.drawOverlayLayer(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t))}determineEffectiveChartMode(){return this.chartMode===at.LINE||this.chartMode===at.AUTO&&this.dataModel.length>this.maxBars?at.LINE:at.BAR}setPattern(t,i){this.styles.pattern.set(t,i)}hasNoData(){return 0===this.dataModel.length}isOnSameAxisSide(){return null!=this.smallestVarianceDataPointValue.value&&null!=this.highestVarianceDataPointValue.value&&null!=this.smallestDataPointValue.value&&null!=this.highestDataPointValue.value&&(this.isVarianceChart()?Math.sign(this.smallestVarianceDataPointValue.value)===Math.sign(this.highestVarianceDataPointValue.value)||0===this.smallestDataPointValue.value&&1===Math.sign(this.highestDataPointValue.value):Math.sign(this.smallestDataPointValue.value)===Math.sign(this.highestDataPointValue.value)||0===this.smallestDataPointValue.value&&1===Math.sign(this.highestDataPointValue.value))}createI18n(t){this.state=pc.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])}createElementPosition(t){let i;const s=Qh(t.filter(((t,i)=>1===i||2===i)).map((t=>ra.translateScenarioLabel(t,this.i18n))).reduce(((t,i)=>t.length<i.length?i:t),""),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,e=this.calculateTitleLength(this.leftSideOffsetForHorizontalSync);let n,r;if(i=s>e?s:e,null!=this.position&&(i+=this.position.spacings.labelToColumn),this.leftSideOffsetForHorizontalSync>-1&&(i=this.leftSideOffsetForHorizontalSync),this.isVarianceChart()?(n=this.smallestVarianceDataPointValue,r=this.highestVarianceDataPointValue):(n=this.smallestDataPointValue,r=this.highestDataPointValue),this.overflowConfig){const{cutHeight:t,overdriveZoneHeight:i,breakGap:s}=this.overflowConfig;r=new Xl(t+i+s,r.scenario,1,r.variance)}let o=this.styles.scaleFactors;const h=this.determineEffectiveChartMode();if(this.lineFullWidth&&this.availableWidth>0&&this.dataModel.length>0&&!this.isVarianceChart()&&h===at.LINE){const t=this.styles.fontStyles.size,s=this.styles.padding,e=this.styles.scaleFactors,n=this.availableWidth-(s.left+s.right+t*e.scenarioOffset+i+t*e.columnWidth);if(n>0){const i=Math.max(n/this.dataModel.length/t,1.2*e.columnWidth),s=new jl;Object.assign(s,e),s.categoryWidth=i,o=s}}return new Yl(new Bl(this.styles.padding),o,this.styles.fontStyles,n,r,this.dataModel.length,i)}calculateTitleLength(t){let i="_______";i.length<this.title.length&&(i=this.title);const s=Qh(i,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;return s<t?t:s}scenarioStyles(){const t=Es(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=Zl.AC1;if(null!=t&&t.length>0){const s=new ks(t.toString());s.isValid&&(i=Ls(this.ruleSet.getScenarioColorIndex(s.delta))+s.delta.slice(2))}return null===i&&(i=Zl.AC1),i}populateModel(t,i){if(0===this.rowCount||!this.fromExpr)return[];let s=this.queryDataSet(i,"","");return this.detectNaNCells(t,s),s=this.leftOuterJoinDates(s,i),this.createDataRows(s,t)}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new ks(t);!0===s.isValid?0!==i[s.base+"_cnt"]&&0!==i[s.delta+"_cnt"]||(i[t]=Number.NaN):0===i[t+"_cnt"]&&(i[t]=Number.NaN)})),i)))}findDateInterval(t){if(t!==ot.AUTO)return t;const i=this.queryDates();if(0===i.length)return ot.DAY;let s=i[0],e=i[0];for(const t of i)t<s&&(s=t),t>e&&(e=t);return(new lt).calculateDistanceType(s,e,this.intervalSpanLimit)}queryDates(){if(0===this.rowCount)return[];let t;try{t=this.db.exec(`SELECT DISTINCT [date] FROM ${this.fromExpr}`)}catch(t){return this.failQuery(t),[]}return t.map((t=>mc.coerceDateTime(t.date))).filter((t=>null!=t))}static coerceDateTime(t){if(null!=t){if("string"==typeof t){const i=y.fromISO(t,{zone:"utc"});return i.isValid?i:void 0}if("number"==typeof t){const i=y.fromMillis(t,{zone:"utc"});return i.isValid?i:void 0}return"boolean"==typeof t.isValid?t:void 0}}queryDataSet(t,i,s){const e=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],n=`normalizeDate([date], '${t}' , '${this.locale}') as calcdate`;let r;try{r=this.db.exec(`SELECT p.calcdate ${i},\n ${e.map((t=>`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`)).join(",")}\n\n FROM (SELECT ${n} ${i},\n ac1,\n ac2,\n ac3,\n ac4,\n pp1,\n pp2,\n pp3,\n pp4,\n fc1,\n fc2,\n fc3,\n fc4,\n pl1,\n pl2,\n pl3,\n pl4\n FROM ${this.fromExpr}) as p\n GROUP BY calcdate ${s}\n ORDER BY calcdate asc`)}catch(t){return this.failQuery(t),[]}return r}createDataRows(t,i){var s;const e=[];t.forEach(((t,s)=>{e.push({id:s,category:t.category,type:gc.NONE,date:t.calcdate,scenario1:new Xl(t[i[0]],i[0],this.pixelPerUnit,Zl.NEU),scenario2:new Xl(t[i[1]],i[1],this.pixelPerUnit,Zl.NEU),scenario3:new Xl(t[i[2]],i[2],this.pixelPerUnit,Zl.NEU),scenario4:new Xl(t[i[3]],i[3],this.pixelPerUnit,Zl.NEU)})}));for(const t of e)for(const i of[t.scenario1,t.scenario2,t.scenario3,t.scenario4])null==i.value||Number.isNaN(i.value)||(i.key={date:mc.pointDate(t.date),scenario:null!==(s=i.scenario)&&void 0!==s?s:void 0});return e}static pointDate(t){var i;return Yi(null===(i=null==t?void 0:t.toISO)||void 0===i?void 0:i.call(t))}findSmallestDataPointValue(t){const i=this.isVarianceChart()?this.pixelPerPercentage:this.pixelPerUnit;let s=new Xl(0,"default",i,Zl.NEU);for(const i of t)for(const t of[i.scenario1,i.scenario2,i.scenario3,i.scenario4])t&&null!=t.value&&t.value<Number(s.value)&&(s=t);return s}findHighestDataPointValue(t){const i=this.isVarianceChart()?this.pixelPerPercentage:this.pixelPerUnit;let s=new Xl(0,"default",i,Zl.NEU);for(const i of t)for(const t of[i.scenario1,i.scenario2,i.scenario3,i.scenario4])null!=t&&t.value>Number(s.value)&&(s=t);return s}populateVarianceModel(t,i){const s=[];if(null==t||0===t.length)return s;let e=null;null!=i&&i.length>0&&(e=i[0]);for(const n in t){const r=new ks(t[n]);if(r.isValid){const o=this.mapScenarios(r,e),h=r.direction,a="dr"===r.type?this.pixelPerPercentage:this.pixelPerUnit;for(const e in i){const l=new Xl(this.calculateVariance(r,i[e],o),r.delta,a,h);null===l.value||Number.isNaN(l.value)||(l.key={date:mc.pointDate(i[e].date),scenario:t[n]}),s.push({id:Number(e),category:i[e].category,type:"dr"===r.type?gc.RELATIVE:gc.ABSOLUTE,date:i[e].date,scenario1:l,scenario2:new Xl(null,null,null,null),scenario3:new Xl(null,null,null,null),scenario4:new Xl(null,null,null,null)})}}}return s}calculateVariance(t,i,s){const e=s.get(t.base),n=s.get(t.delta);return null==e||null==n||null==i[e].value||null==i[n].value?null:t.type===gc.RELATIVE?st(i[e].value-i[n].value,i[n].value):i[e].value-i[n].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((e=>{i[e].scenario===t.delta?s.set(t.delta,e):i[e].scenario===t.base&&s.set(t.base,e)})),s}cleanSVGforRedraw(t){t.clear()}isVarianceChart(){return this.variancesDataModel&&this.variancesDataModel.length>0}createDateFactory(){const t=new lt;return t.setLocale(this.locale),t}dateLabelPlace(t){let i=t.scenario1.value<0,s=this.position.spacings.labelToAxis;if(null!=this.stackConfig&&!this.isVarianceChart()){const e=this.stackConfig.mode!==Q.RELATIVE&&this.determineEffectiveChartMode()!==at.LINE?(this.position.spacings.labelToColumn+this.position.dataLabelHeight)/this.pixelPerUnit:0,n=this.stackGroups(t).filter((t=>t.hasValue)).map((t=>t.layout));let r=Wl(n,(()=>e));r.flipped&&e>0&&n.some((t=>t.total>=0))&&(r={flipped:!1,clearance:Math.max(...n.map((t=>t.negative+(t.total<0?e:0))))}),i=r.flipped,s+=r.clearance*this.pixelPerUnit}return i?{hookLocation:na.Bottom,offset:-s}:{hookLocation:na.Top,offset:s}}drawAxisAndLabels(t,i){const s=this.createDateFactory(),e=i.group().id("AxisAndDateLables");let n=!1;if(!1===this.hideAxisLabels)t.forEach(((t,i)=>{const{hookLocation:r,offset:o}=this.dateLabelPlace(t);t.type===gc.RELATIVE&&(n=!0);let h=s.getDateString(t.date,this.dateInterval);this.axisLabelsMode===ht.SMART?(h=s.getSmartDateString(t.date,this.dateInterval),0===i&&this.dateInterval!==ot.YEAR&&(h=s.getShortDateString(t.date,this.dateInterval))):this.axisLabelsMode===ht.SHORT&&(h=s.getShortDateString(t.date,this.dateInterval)),new ca(e,this.position.getColumnCenterPositionX(i),this.position.getAxisPositionY(n)+o,"",h,this.styles,r,na.Center).forceStringTypeDraw()}));else{const i=null==t?void 0:t[0];i&&i.type===gc.RELATIVE&&(n=!0)}new ic({scenarioType:this.axisScenario,labelText:this.title,isRelative:n},this.position,e).draw();const r=e.bbox();this.axisCategoryArea={height:r.height,width:r.width}}drawScenarios(t,i){const s=i.group().id("Scenarios"),e=new dc(this.position,s,this.scenarioStyles(),t.length,this.i18n);e.setOverflowConfig(this.overflowConfig);let n=!1;t.forEach(((t,i)=>{e.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),e.createSecondaryBar(t.scenario2,i).draw(),e.createPrimaryMarker(t.scenario3,i).draw(),e.createSecondaryMarker(t.scenario4,i).draw(),!1===t.scenario1.isEmpty()&&(n=!0)}));let r=0;!1===n&&(r=this.isOnSameAxisSide()?this.position.dataLabelHeight:2*this.position.dataLabelHeight);const o=s.bbox();this.scenariosArea={height:o.height+this.styles.padding.top+this.styles.padding.bottom+r,width:o.width+this.position.spacings.columnWidth}}drawLineScenarios(t,i){var s,e;const n=i.group().id("LineScenarios"),r=new fa,o=new dc(this.position,n,this.scenarioStyles(),t.length,this.i18n);o.setCollisionManager(r);const h=["ac1","pp1","fc1","pl1"],a=[[],[],[],[]];t.forEach(((t,i)=>{["scenario1","scenario2","scenario3","scenario4"].forEach(((s,e)=>{t[s]&&a[e].push({dataPoint:t[s],index:i})}))}));const l=[];for(let t=0;t<a.length;t++){const i=a[t];if(i.length>0&&i.some((t=>!t.dataPoint.isEmpty()))){const n=(null===(e=null===(s=i[0])||void 0===s?void 0:s.dataPoint)||void 0===e?void 0:e.scenario)||h[t],r=n.slice(0,2).toLowerCase();l.push({points:i,scenarioName:n,scenarioType:r})}}l.sort(((t,i)=>(ua[i.scenarioType]||99)-(ua[t.scenarioType]||99)));const c=[];for(const t of l){const i=o.createLineSeries(t.points,t.scenarioName,Ls(this.ruleSet.getScenarioColorIndex(t.scenarioName)));c.push({series:i,scenarioType:t.scenarioType})}for(const t of c)t.series.drawGeometry();o.moveLabelsToFront();const u=[...c].sort(((t,i)=>(ua[t.scenarioType]||99)-(ua[i.scenarioType]||99)));for(const t of u)t.series.drawLabels(this.dataFormatDigits,this.measureScale);const d=this.position.getColumnPositionY(),f=n.bbox();this.scenariosArea={height:Math.max(f.height+this.styles.padding.top,d)+this.styles.padding.bottom,width:f.width+this.position.spacings.columnWidth}}drawAxisAndLabelsForLineChart(t,i){const s=this.createDateFactory(),e=i.group().id("AxisAndDateLabelsLine"),n=!1,r=t.length-1;!1===this.hideAxisLabels&&t.forEach(((i,o)=>{if(!this.shouldShowLineChartAxisLabel(t,o))return;const{hookLocation:h,offset:a}=this.dateLabelPlace(i);let l;this.lineFullWidth&&this.availableWidth>0?this.axisLabelsMode===ht.SMART?(l=s.getSmartDateString(i.date,this.dateInterval),0===o&&this.dateInterval!==ot.YEAR&&(l=s.getShortDateString(i.date,this.dateInterval))):l=this.axisLabelsMode===ht.SHORT?s.getShortDateString(i.date,this.dateInterval):s.getDateString(i.date,this.dateInterval):l=s.getShortDateString(i.date,this.dateInterval),new ca(e,this.position.getColumnCenterPositionX(o),this.position.getAxisPositionY(n)+a,"",l,this.styles,h,na.Center).forceStringTypeDraw(),o>0&&o<r&&this.isYearChange(t,o)&&this.drawYearSeparatorLine(e,o,n)})),new ic({scenarioType:this.axisScenario,labelText:this.title,isRelative:n},this.position,e).draw();const o=e.bbox();this.axisCategoryArea={height:o.height,width:o.width}}shouldShowLineChartAxisLabel(t,i){return!!(this.lineFullWidth&&this.availableWidth>0)||(0===i||i===t.length-1||this.isYearChange(t,i))}isYearChange(t,i){var s,e;if(0===i)return!1;const n=null===(s=t[i])||void 0===s?void 0:s.date,r=null===(e=t[i-1])||void 0===e?void 0:e.date;return!(!n||!r)&&(this.dateInterval===ot.WEEK?n.weekYear!==r.weekYear:n.year!==r.year)}drawYearSeparatorLine(t,i,s){const e=this.position.getColumnCenterPositionX(i)-this.position.spacings.columnWidth/2,n=this.position.columnValue.max.getScaledUnit()+this.position.dataLabelHeight,r=this.position.getAxisPositionY(s)-n,o=this.position.getAxisPositionY(s);t.line([[e,r],[e,o]]).stroke({color:"#999999",width:1,dasharray:"4,4"}).attr("stroke-dasharray","4,4")}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),e=new dc(this.position,s,this.scenarioStyles(),t.length,this.i18n);e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.type===gc.RELATIVE?e.createRelativeVarianceBar(t.scenario1,i).draw():e.createVarianceBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale)}));const n=s.bbox();return this.scenariosArea={height:n.height+this.styles.padding.top+this.styles.padding.bottom,width:n.width+this.position.spacings.columnWidth},s}sortSegmentsByPropOrder(t){if(0===this.scenarioPropOrder.length)return;const i=this.scenarioPropOrder;t.sort(((t,s)=>{const e=i.indexOf(t.scenario),n=i.indexOf(s.scenario);return(-1===e?i.length:e)-(-1===n?i.length:n)}))}stackGroups(t){if(!this.stackConfig)return[];const i=this.stackConfig.by===q.SCENARIOS,s=this.determineEffectiveChartMode()===at.LINE,e=[];for(const n of i||s?["scenario1","scenario2","scenario3","scenario4"]:["scenario1"]){const i=t[n];i&&!i.isEmpty()&&null!=i.value&&e.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0===e.length)return[];const n=this.stackConfig.mode===Q.RELATIVE?ct:0,r=(t,i)=>({prefix:t,segments:i,layout:Cl(i.map((t=>t.value)),n),hasValue:i.some((t=>Number.isFinite(t.value)))});if(i&&this.sortSegmentsByPropOrder(e),s)return[r("",e)];if(i){const t=new Map;for(const i of e){const s=ta(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}if(t.size>1){const i=[];for(const s of Zh)t.has(s)&&(i.push(r(s,t.get(s))),t.delete(s));for(const[s,e]of t)i.push(r(s,e));return i}}const o=t=>Number.isFinite(t.value)?t.value:0;return"asc"===this.stackConfig.order?e.sort(((t,i)=>o(t)-o(i))):"desc"===this.stackConfig.order&&e.sort(((t,i)=>o(i)-o(t))),[r("",e)]}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),e=this.stackConfig.by===q.SCENARIOS;t.forEach(((t,i)=>{const n=this.stackGroups(t);n.forEach(((r,o)=>{let h=null;r.segments.forEach(((t,a)=>{const l=new hc(this.position,this.styles,t.dataPoint,i,r.layout.segments[a],t.scenario,n.length>1?n.length-1-o:a,this.stackConfig.mode,r.layout,e,s);l.draw(this.dataFormatDigits,this.measureScale),h=l})),h&&r.hasValue&&h.drawTotalLabel(this.dataFormatDigits,this.measureScale,{date:mc.pointDate(t.date),scenario:n.length>1?r.prefix:void 0})}))}));const n=s.bbox();this.scenariosArea={height:n.height+this.styles.padding.top+this.styles.padding.bottom,width:n.width+this.position.spacings.columnWidth}}drawStackedHeaders(t,i){if(!this.stackConfig||0===t.length)return;if(this.stackConfig.by!==q.SCENARIOS)return;const s=i.group().id("StackedHeaders"),e=this.stackGroups(t[0]);if(0===e.length)return;const n=this.position.getColumnPositionY(),r=this.position.getColumnCenterPositionX(0)-this.position.getColumnWidth()/2-this.position.spacings.labelToColumn,o=(t,i)=>{new ca(s,r,t,"STACK_HEADER",i,this.styles,na.Center,na.Right).forceStringTypeDraw()};if(e.length>1)return void e.forEach(((t,i)=>{const{positive:s,negative:r,total:h}=t.layout;o(n-(i===e.length-1?(s-r)/2:h<0?0-r:s)*t.segments[0].dataPoint.pixelPerUnit,this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase())}));const[h]=e;h.segments.forEach(((t,i)=>{const{start:s,end:e}=h.layout.segments[i];o(n-(s+e)/2*t.dataPoint.pixelPerUnit,this.i18n.get(t.scenario)||t.scenario)}))}drawStackedAreaScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedAreaScenarios"),e=this.stackConfig.by===q.SCENARIOS,n=this.stackConfig.mode,r=["scenario1","scenario2","scenario3","scenario4"];if(0===(e?r.filter((i=>t.some((t=>t[i]&&!t[i].isEmpty())))).length:1))return;const o=[],h=[];for(const i of r)t.some((t=>t[i]&&!t[i].isEmpty()))&&h.push(i);if(e&&this.scenarioPropOrder.length>0){const i=this.scenarioPropOrder;h.sort(((s,e)=>{var n,r,o,h;const a=i.indexOf(null!==(r=null===(n=t[0][s])||void 0===n?void 0:n.scenario)&&void 0!==r?r:""),l=i.indexOf(null!==(h=null===(o=t[0][e])||void 0===o?void 0:o.scenario)&&void 0!==h?h:"");return(-1===a?i.length:a)-(-1===l?i.length:l)}))}for(const i of h){const s=t[0][i];o.push((null==s?void 0:s.scenario)||"ac1")}const a=(t,i)=>{const s=t[i];return s&&!s.isEmpty()&&Number.isFinite(s.value)?s.value:0},l=h.map((i=>t.reduce(((t,s)=>t+a(s,i)),0)<0?-0:0)),c=n===Q.RELATIVE?ct:0,u=t.map((t=>Cl(h.map(((i,s)=>a(t,i)||l[s])),c))),d=this.position.getColumnPositionY(),f=this.pixelPerUnit,v=(t,i)=>u.map(((s,e)=>({x:this.position.getColumnCenterPositionX(e),y:d-s.segments[t][i]*f})));for(let t=0;t<h.length;t++){const i=v(t,"end"),n=v(t,"start"),r=e?Ls(this.ruleSet.getScenarioColorIndex(o[t])):null,h=new cc(s,i,n,r,t,e);h.draw(),h.drawBoundaryLine()}const p=s.bbox();this.scenariosArea={height:p.height+this.styles.padding.top+this.styles.padding.bottom,width:p.width+this.position.spacings.columnWidth}}drawOverlayLayer(t,i){if(0===t.length)return;const s=i.group().id("Overlay"),e=new dc(this.position,s,this.scenarioStyles(),t.length,this.i18n);if(!0===this.showOverlayAvg){let i=null;const s=function(t){const i=bc(t),s=i.length>0?i.reduce(((t,i)=>t+i),0)/i.length:NaN,e=Object.assign(Object.assign({},t[0]),{scenario1:new Xl(s,t[0].scenario1.scenario,t[0].scenario1.pixelPerUnit,t[0].scenario1.variance)}),n=Object.assign(Object.assign({},t[t.length-1]),{scenario1:new Xl(s,t[t.length-1].scenario1.scenario,t[t.length-1].scenario1.pixelPerUnit,t[t.length-1].scenario1.variance)});return[e,...t.map((t=>Object.assign(Object.assign({},t),{scenario1:new Xl(s,t.scenario1.scenario,t.scenario1.pixelPerUnit,t.scenario1.variance)}))),n]}(t);s.forEach(((t,s)=>{null!=i&&e.createLine(`Ø ${this.i18n.get(t.scenario1.scenario)||t.scenario1.scenario}`,t.scenario1,i,s-1).draw(this.dataFormatDigits,this.measureScale),i=t.scenario1}))}if(!0===this.showOverlayMedian){let i=null;const s=function(t){const i=bc(t).sort(((t,i)=>t-i)),s=i.length%2==0?(i[i.length/2-1]+i[i.length/2])/2:i[Math.floor(i.length/2)],e=Object.assign(Object.assign({},t[0]),{scenario1:new Xl(s,t[0].scenario1.scenario,t[0].scenario1.pixelPerUnit,t[0].scenario1.variance)}),n=Object.assign(Object.assign({},t[t.length-1]),{scenario1:new Xl(s,t[t.length-1].scenario1.scenario,t[t.length-1].scenario1.pixelPerUnit,t[t.length-1].scenario1.variance)});return[e,...t.map((t=>Object.assign(Object.assign({},t),{scenario1:new Xl(s,t.scenario1.scenario,t.scenario1.pixelPerUnit,t.scenario1.variance)}))),n]}(t);s.forEach(((t,s)=>{null!=i&&e.createLine(`Mdn ${this.i18n.get(t.scenario1.scenario)||t.scenario1.scenario}`,t.scenario1,i,s-1).draw(this.dataFormatDigits,this.measureScale),i=t.scenario1}))}}leftOuterJoinDates(t,i){const s=t.map((t=>t.calcdate)).filter((t=>null!=t&&"boolean"==typeof t.isValid&&t.isValid));if(0===s.length)return t;const e=y.max(...s),n=y.min(...s),r=new lt;if(r.countBetween(n,e,i)>1e4)return t;const o=r.datesBetween(n,e,i),h=new Map;return o.forEach(((t,i)=>{h.set(t.toISO(),{id:i,calcdate:t,category:null,ac1:null,ac2:null,ac3:null,ac4:null,pp1:null,pp2:null,pp3:null,pp4:null,fc1:null,fc2:null,fc3:null,fc4:null,pl1:null,pl2:null,pl3:null,pl4:null,isEmpty:!0})})),t.forEach((t=>{const i=t.calcdate.toISO(),s=h.get(i);s&&s.isEmpty&&h.set(i,{id:s.id,calcdate:t.calcdate,category:t.category,ac1:t.ac1,ac2:t.ac2,ac3:t.ac3,ac4:t.ac4,pp1:t.pp1,pp2:t.pp2,pp3:t.pp3,pp4:t.pp4,fc1:t.fc1,fc2:t.fc2,fc3:t.fc3,fc4:t.fc4,pl1:t.pl1,pl2:t.pl2,pl3:t.pl3,pl4:t.pl4,isEmpty:!1})})),Array.from(h.values())}}function bc(t){return t.map((t=>{var i;return null===(i=t.scenario1)||void 0===i?void 0:i.value})).filter((t=>Number.isFinite(t)))}class yc{constructor(t,i){this.data=t,this.scenarios=i,this.variances=[],this.title="",this.hideAxisLabels=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.leftSideOffsetForHorizontalSync=-1,this.dateInterval=ot.AUTO,this.axisLabelsMode=ht.SMART,this.intervalSpanLimit=28,this.filter="",this.measureScale=new la,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.showOverlayMedian=!0,this.showOverlayAvg=!0,this.chartMode=at.BAR,this.maxBars=28,this.stackConfig=null,this.lineFullWidth=!0,this.locale="de"}}class wc{constructor(t,i,s,e,n,r){this.dataRowAdapter=t,this.stringAdapter=i,this.dataFormatDigitsAdapter=s,this.db=e,this.fromExpr=n,this.onQueryError=r}adapt(t){const i=Z.adaptArray(t.data,this.dataRowAdapter),s=Z.adaptArray(t.scenarios,this.stringAdapter),e=new yc(i,s);return R.isArray(t.variances)&&(e.variances=Z.adaptArray(t.variances,this.stringAdapter)),R.isString(t.title)&&(e.title=t.title),R.isBoolean(t.hideAxisLabels)&&(e.hideAxisLabels=t.hideAxisLabels),R.isNumber(t.pixelPerUnit)&&(e.pixelPerUnit=t.pixelPerUnit),R.isNumber(t.pixelPerPercentage)&&(e.pixelPerPercentage=t.pixelPerPercentage),R.isExisting(t.dateInterval)&&(e.dateInterval=t.dateInterval),R.isExisting(t.axisLabelsMode)&&(e.axisLabelsMode=t.axisLabelsMode),R.isNumber(t.leftSideOffsetForHorizontalSync)&&(e.leftSideOffsetForHorizontalSync=t.leftSideOffsetForHorizontalSync),R.isNumber(t.intervalSpanLimit)&&(e.intervalSpanLimit=t.intervalSpanLimit),R.isString(t.filter)&&(e.filter=t.filter),R.isExisting(t.measureScale)&&(e.measureScale=ll.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale,this.onQueryError)),R.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),R.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),R.isExisting(t.dataFormatDigits)&&(e.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),R.isBoolean(t.showOverlayAvg)&&(e.showOverlayAvg=t.showOverlayAvg),R.isBoolean(t.showOverlayMedian)&&(e.showOverlayMedian=t.showOverlayMedian),R.isExisting(t.chartMode)&&(e.chartMode=t.chartMode),R.isNumber(t.maxBars)&&(e.maxBars=t.maxBars),R.isExisting(t.stackConfig)&&(e.stackConfig=t.stackConfig),R.isBoolean(t.lineFullWidth)&&(e.lineFullWidth=t.lineFullWidth),R.isString(t.locale)&&(e.locale=t.locale),e}default(){return new yc([],[])}}const xc=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.scenarios=[],this.variances=[],this.hideAxisLabels=!1,this.pixelPerUnit=2,this.pixelPerPercentage=50,this.leftSideOffsetForHorizontalSync=-1,this.i18n=new Map,this.dateInterval=ot.AUTO,this.intervalSpanLimit=28,this.axisLabelsMode=ht.SMART,this.filter="",this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.showOverlayMedian=!1,this.showOverlayAvg=!1,this.chartMode=at.BAR,this.maxBars=28,this.stackConfig=null,this.lineFullWidth=!0,this.containerWidth=0,this.dataFormatDigits={percent:2,decimal:1},this.parentDimensions={width:0,height:0},a(this)}getDb(){return this.stores||(this.stores=c(this.element)),this.stores.db.db}render(){var t,e,n,r;if(void 0===this.chart||void 0!==this.queryError)return i(s,null);if(this.chart.hasNoData()){const e=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return i(s,{class:"no-data"},i("div",{class:"empty-state"},e))}return i(s,null,i("div",{innerHTML:null===(e=this.pattern)||void 0===e?void 0:e.toString(),class:"hidePatternContainer",style:{width:"0",height:"0",overflow:"hidden"}}),i("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(n=this.chart)||void 0===n?void 0:n.getFooter()),i("div",{innerHTML:null===(r=this.chart)||void 0===r?void 0:r.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(),ui(this.errors,this.queryError)}async componentWillLoad(){var t;const i=this.prepareConfig(),s=this.prepareStyle(),e=this.containerWidth||0;this.chart=new mc(new Cs(this.ruleSetConfig),this.getDb(),this.tableName,i,s,e),this.chart.setI18n(this.i18n);const n=i.pixelPerUnit<=0;this.autoFitScaling(i,s),this.chart.setAvailableHeight(n?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.height)||0),this.pattern=new Vl(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.setAvailableWidth(this.containerWidth||0),this.chart.setRuleSet(new Cs(this.ruleSetConfig)),this.chart.setConfig(i);const e=i.pixelPerUnit<=0;this.autoFitScaling(i,s),this.chart.setAvailableHeight(e?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.height)||0),this.pattern=new Vl(this.chart.styles),this.chart.setPattern("hatched",this.pattern.getFCPolygonPattern()),this.syncQueryError()}autoFitScaling(t,i){var s;const e=t.pixelPerUnit<=0,n=t.pixelPerPercentage<=0;if(!e&&!n)return;const r=()=>{var i;null===(i=this.reportAutoScaling)||void 0===i||i.call(this,{unit:e?t.pixelPerUnit:void 0,percentage:n?t.pixelPerPercentage:void 0})},o=null===(s=this.parentDimensions)||void 0===s?void 0:s.height,h=this.containerWidth||0,a=()=>{this.chart=new mc(new Cs(this.ruleSetConfig),this.getDb(),this.tableName,t,i,h),this.chart.setI18n(this.i18n)},l=()=>(this.chart.layout(),this.chart.getAllocatedCanvasHeight());if(!o||o<=0)return e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=50),a(),void r();e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=1),a();let c=l();if(c<=0)return void r();const u=Math.max(Nl,.9*o/c);let d=!1,f=!1,v=null;for(let i=0;i<=3;i++){const i=Tl({target:o,measured:c,unitExtent:e?this.chart.getUnitBarExtent():0,pctExtent:n?this.chart.getPercentBarExtent():0,currentPpu:t.pixelPerUnit,currentPpp:t.pixelPerPercentage});if(void 0===i.ppu&&void 0===i.ppp)break;if(e&&void 0!==i.ppu&&(t.pixelPerUnit=i.ppu,d=!0),n&&void 0!==i.ppp&&(t.pixelPerPercentage=i.ppp,f=!0),a(),c=l(),c<=o+.5&&(v={ppu:t.pixelPerUnit,ppp:t.pixelPerPercentage},c>=.98*o))break}let p=!1;if(e&&!d&&(t.pixelPerUnit=u,p=!0),n&&!f&&(t.pixelPerPercentage=u,p=!0),c>o+.5){if(v)d&&(t.pixelPerUnit=v.ppu),f&&(t.pixelPerPercentage=v.ppp);else{const i=o/c;e&&(t.pixelPerUnit=Math.max(Nl,t.pixelPerUnit*i)),n&&(t.pixelPerPercentage=Math.max(Nl,t.pixelPerPercentage*i))}p=!0}p&&a(),r()}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){var t,i,s;const e=this.getDb(),n=$(e,this.tableName,this.filter);return this.measureScaleError=void 0,new wc(new ql,new cl,new Ul,e,n,(t=>{this.measureScaleError=ci(t)})).adapt({scenarios:this.scenarios,variances:this.variances,title:this.chartTitle,hideAxisLabels:this.hideAxisLabels,pixelPerUnit:this.pixelPerUnit,pixelPerPercentage:this.pixelPerPercentage,dateInterval:this.dateInterval,axisLabelsMode:this.axisLabelsMode,leftSideOffsetForHorizontalSync:this.leftSideOffsetForHorizontalSync,intervalSpanLimit:this.intervalSpanLimit,filter:this.filter,measureScale:this.measureScale,measureUnit:this.measureUnit,showMeasureScale:this.showMeasureScale,dataFormatDigits:this.dataFormatDigits,showOverlayMedian:this.showOverlayMedian,showOverlayAvg:this.showOverlayAvg,chartMode:this.chartMode,maxBars:this.maxBars,stackConfig:this.stackConfig,lineFullWidth:this.lineFullWidth,locale:(null===(s=null===(i=null===(t=this.stores)||void 0===t?void 0:t.context)||void 0===i?void 0:i.state)||void 0===s?void 0:s.locale)||"de"})}prepareStyle(){var t,i;const s=new Ql(new Il,new Ws,new Is(new Gs),new Ga(new Gs),new zs).adapt(this.styles);return s.locale=(null===(i=null===(t=c(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}get element(){return e(this)}};xc.style=':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}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-default{stroke:black;stroke-width:0.1em}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}.hide{opacity:0}.footer{margin:0.2em;font-size:0.6em}.footer-hide{display:none}svg#drawCanvas{display:block}';const Sc=class{constructor(i){t(this,i),this.name="_default",a(this),this.errors=l(this),Qt(this,(t=>{this.stores||(this.stores=c(this.element));try{const i=JSON.parse(t);this.stores.componentStyles.set(this.name,i),this.errors.remove("ERR_body");const s=_(i);s.length>0?this.errors.addOrReplace({id:"ERR_keys",type:"error",message:`Unknown style keys, they are ignored: ${s.join(", ")}`}):this.errors.remove("ERR_keys")}catch(t){this.errors.addOrReplace({id:"ERR_body",type:"error",message:`bn-component-style: Failed to parse JSON body - ${t.message}`}),console.error(t)}}))}render(){return i(s,{key:"443fd52bc75e267b8699e29f754a15130f444315"})}get element(){return e(this)}};Sc.style="bn-component-style{display:none}";const $c={xga:[1024,768,"px"],hd:[1280,720,"px"],"full-hd":[1920,1080,"px"],"4k":[3840,2160,"px"],"4k2k":[4096,2160,"px"],a6:[4.13,5.83,"in"],a5:[5.83,8.27,"in"],a4:[8.27,11.69,"in"],a3:[11.69,16.54,"in"],a2:[16.54,23.39,"in"],a1:[23.39,33.11,"in"],a0:[33.11,46.81,"in"],letter:[8.5,11,"in"],legal:[8.5,14,"in"],tabloid:[11,17,"in"],ledger:[17,11,"in"]},Mc=Object.keys($c),_c=["landscape","portrait"];function Oc(t,i){const s=null!=t&&Mc.includes(t),[e,n,r]=$c[s?t:"xga"],o=e>=n?"landscape":"portrait",h=s&&_c.includes(null!=i?i:"")?i:o,[a,l]=h===o?[e,n]:[n,e];return{width:`${a}${r}`,height:`${l}${r}`,orientation:h}}function kc(t,i,s){const e=Oc(t,i),n=_c.includes(null!=s?s:"")&&s!==e.orientation;return n?{width:e.height,height:e.width,turned:n}:{width:e.width,height:e.height,turned:n}}function Ac(t,i,s){const{width:e,height:n}=kc(t,i,s);return`@page { size: ${e} ${n}; }`}const Rc=["format","orientation","page-format","page-orientation","render-orientation","page-number"],Nc=(t,i,s)=>{const e=t[i];return"string"==typeof e?e:i in t?null:t.getAttribute(s)},Lc=class{constructor(i){t(this,i),this.assignedPageNumbers=new WeakMap,a(this),this.errors=l(this)}setLocale(t){this.stores.context.state.locale=t}connectedCallback(){this.stores=O(this.element),this.locale&&(this.stores.context.state.locale=this.locale),this.syncPages(),this.pageObserver=new MutationObserver((()=>this.syncPages())),this.pageObserver.observe(this.element,{childList:!0,subtree:!0,attributes:!0,attributeFilter:Rc})}disconnectedCallback(){var t,i;null===(t=this.pageObserver)||void 0===t||t.disconnect(),null===(i=this.pageSizeStyle)||void 0===i||i.remove(),this.pageSizeStyle=void 0}syncPages(){const t=Array.from(this.element.querySelectorAll("bn-page, bn-layout-page"));t.forEach(((t,i)=>{const s="bn-layout-page"===t.localName?t:t.querySelector("bn-footer");if(!s)return;const e=Nc(s,"pageNumber","page-number");if(null!==e&&e!==this.assignedPageNumbers.get(s))return;const n=(i+1).toString();this.assignedPageNumbers.set(s,n),e!==n&&s.setAttribute("page-number",n)}));const i=this.element.getAttribute("render-orientation");void 0!==this.lastRenderOrientation&&this.lastRenderOrientation!==i&&t.filter((t=>"bn-layout-page"===t.localName)).forEach((t=>n(t))),this.lastRenderOrientation=i,this.writePageSize(t[0],i)}writePageSize(t,i){var s;if(!t||document.querySelector("bn-context")!==this.element)return null===(s=this.pageSizeStyle)||void 0===s||s.remove(),void(this.pageSizeStyle=void 0);const e="bn-layout-page"===t.localName?Ac(Nc(t,"pageFormat","page-format"),Nc(t,"pageOrientation","page-orientation"),i):Ac(Nc(t,"format","format"),Nc(t,"orientation","orientation"));this.pageSizeStyle||(this.pageSizeStyle=document.createElement("style"),this.pageSizeStyle.setAttribute("data-bn-page-size",""),document.head.append(this.pageSizeStyle)),this.pageSizeStyle.textContent!==e&&(this.pageSizeStyle.textContent=e)}async getLayoutState(t){var i,s;const e=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",n=Array.from(this.element.querySelectorAll("bn-annotation-layer, bn-annotation-list, bn-body, bn-card, bn-chart-bubble, bn-chart-bullet, bn-chart-scatter, bn-chart-structure, bn-chart-time, bn-footer, bn-grid, bn-image, bn-layout-card, bn-layout-page, bn-message, bn-page, bn-table, bn-text, bn-title, bn-tree"));await Promise.all(n.map((t=>{var i,s,e;return null!==(e=null===(s=(i=t).componentOnReady)||void 0===s?void 0:s.call(i))&&void 0!==e?e:Promise.resolve()})));const r=this.element.getBoundingClientRect(),o={x:r.left,y:r.top},h=await Promise.all(n.map((async t=>{const i=t.getBoundingClientRect(),s={context:o,component:{x:i.left,y:i.top}};try{const i=t;return"function"==typeof i.getLayoutState?await i.getLayoutState({detail:e}):Pi(t,s)}catch(i){let e;try{e=Pi(t,s)}catch(i){const s={x:0,y:0,width:0,height:0};e={version:li,tag:t.localName,id:t.localName,rect:{context:Object.assign({},s),component:Object.assign({},s)},em:{fontSizePx:0,appliedScaleFactor:1},regions:[],metadata:{},diagnostics:[]}}return e.error=String(i instanceof Error?i.message:i),e}}))),a=ni(n.map((t=>({tag:t.localName,explicitId:ri(t)}))));return h.forEach(((t,i)=>{t.id=a[i]})),{version:li,generatedAt:(new Date).toISOString(),detail:e,context:{viewport:oi(r),locale:null===(s=this.stores)||void 0===s?void 0:s.context.state.locale},components:h}}componentWillLoad(){}componentDidLoad(){}componentShouldUpdate(){}componentWillRender(){}componentDidRender(){}componentWillUpdate(){}componentDidUpdate(){}render(){return i(s,{key:"a50946d9cb100a1644a2c758af7854900826c5ce"},i("slot",{key:"c02525871433af7bb15f39c62c1417365a28d931"}))}get element(){return e(this)}static get watchers(){return{locale:[{setLocale:0}]}}};Lc.style=":host{display:block}";const Ec=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],Tc=["rowGroup","category","subCategory","columnGroup","columnSubGroup"];function Cc(t){return"number"==typeof t&&!isNaN(t)&&isFinite(t)}function Pc(t){const i=Array.from(t);return{distinctValues:i,count:i.length,hasData:i.length>0}}var Wc=Uint8Array,Dc=Uint16Array,zc=Int32Array,Uc=new Wc([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Fc=new Wc([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Gc=new Wc([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),jc=function(t,i){for(var s=new Dc(31),e=0;e<31;++e)s[e]=i+=1<<t[e-1];var n=new zc(s[30]);for(e=1;e<30;++e)for(var r=s[e];r<s[e+1];++r)n[r]=r-s[e]<<5|e;return{b:s,r:n}},Ic=jc(Uc,2),Yc=Ic.b,Bc=Ic.r;Yc[28]=258,Bc[258]=28;for(var Hc=jc(Fc,0).b,Vc=new Dc(32768),Xc=0;Xc<32768;++Xc){var Jc=(43690&Xc)>>1|(21845&Xc)<<1;Vc[Xc]=((65280&(Jc=(61680&(Jc=(52428&Jc)>>2|(13107&Jc)<<2))>>4|(3855&Jc)<<4))>>8|(255&Jc)<<8)>>1}var qc=function(t,i,s){for(var e=t.length,n=0,r=new Dc(i);n<e;++n)t[n]&&++r[t[n]-1];var o,h=new Dc(i);for(n=1;n<i;++n)h[n]=h[n-1]+r[n-1]<<1;if(s){o=new Dc(1<<i);var a=15-i;for(n=0;n<e;++n)if(t[n])for(var l=n<<4|t[n],c=i-t[n],u=h[t[n]-1]++<<c,d=u|(1<<c)-1;u<=d;++u)o[Vc[u]>>a]=l}else for(o=new Dc(e),n=0;n<e;++n)t[n]&&(o[n]=Vc[h[t[n]-1]++]>>15-t[n]);return o},Kc=new Wc(288);for(Xc=0;Xc<144;++Xc)Kc[Xc]=8;for(Xc=144;Xc<256;++Xc)Kc[Xc]=9;for(Xc=256;Xc<280;++Xc)Kc[Xc]=7;for(Xc=280;Xc<288;++Xc)Kc[Xc]=8;var Qc=new Wc(32);for(Xc=0;Xc<32;++Xc)Qc[Xc]=5;var Zc=qc(Kc,9,1),tu=qc(Qc,5,1),iu=function(t){for(var i=t[0],s=1;s<t.length;++s)t[s]>i&&(i=t[s]);return i},su=function(t,i,s){var e=i/8|0;return(t[e]|t[e+1]<<8)>>(7&i)&s},eu=function(t,i){var s=i/8|0;return(t[s]|t[s+1]<<8|t[s+2]<<16)>>(7&i)},nu=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ru=function(t,i,s){var e=new Error(i||nu[t]);if(e.code=t,Error.captureStackTrace&&Error.captureStackTrace(e,ru),!s)throw e;return e},ou=new Wc(0);function hu(t,i){var s,e,n=function(t){31==t[0]&&139==t[1]&&8==t[2]||ru(6,"invalid gzip data");var i=t[3],s=10;4&i&&(s+=2+(t[10]|t[11]<<8));for(var e=(i>>3&1)+(i>>4&1);e>0;e-=!t[s++]);return s+(2&i)}(t);return n+8>t.length&&ru(6,"invalid gzip data"),function(t,i,s,e){var n=t.length;if(!n||i.f&&!i.l)return s||new Wc(0);var r=!s,o=r||2!=i.i;r&&(s=new Wc(3*n));var h,a,l=function(t){var i=s.length;if(t>i){var e=new Wc(Math.max(2*i,t));e.set(s),s=e}},c=i.f||0,u=i.p||0,d=i.b||0,f=i.l,v=i.d,p=i.m,g=i.n,m=8*n;do{if(!f){c=su(t,u,1);var b=su(t,u+1,3);if(u+=3,!b){var y=t[(N=4+((u+7)/8|0))-4]|t[N-3]<<8,w=N+y;if(w>n){ru(0);break}o&&l(d+y),s.set(t.subarray(N,w),d),i.b=d+=y,i.p=u=8*w,i.f=c;continue}if(1==b)f=Zc,v=tu,p=9,g=5;else if(2==b){var x=su(t,u,31)+257,S=su(t,u+10,15)+4,$=x+su(t,u+5,31)+1;u+=14;for(var M=new Wc($),_=new Wc(19),O=0;O<S;++O)_[Gc[O]]=su(t,u+3*O,7);u+=3*S;var k=iu(_),A=(1<<k)-1,R=qc(_,k,1);for(O=0;O<$;){var N,L=R[su(t,u,A)];if(u+=15&L,(N=L>>4)<16)M[O++]=N;else{var E=0,T=0;for(16==N?(T=3+su(t,u,3),u+=2,E=M[O-1]):17==N?(T=3+su(t,u,7),u+=3):18==N&&(T=11+su(t,u,127),u+=7);T--;)M[O++]=E}}var C=M.subarray(0,x),P=M.subarray(x);p=iu(C),g=iu(P),f=qc(C,p,1),v=qc(P,g,1)}else ru(1);if(u>m){ru(0);break}}o&&l(d+131072);for(var W=(1<<p)-1,D=(1<<g)-1,z=u;;z=u){var U=(E=f[eu(t,u)&W])>>4;if((u+=15&E)>m){ru(0);break}if(E||ru(2),U<256)s[d++]=U;else{if(256==U){z=u,f=null;break}var F=U-254;U>264&&(F=su(t,u,(1<<(I=Uc[O=U-257]))-1)+Yc[O],u+=I);var G=v[eu(t,u)&D],j=G>>4;if(G||ru(3),u+=15&G,P=Hc[j],j>3){var I=Fc[j];P+=eu(t,u)&(1<<I)-1,u+=I}if(u>m){ru(0);break}o&&l(d+131072);var Y=d+F;if(d<P){var B=0-P,H=Math.min(P,Y);for(B+d<0&&ru(3);d<H;++d)s[d]=e[B+d]}for(;d<Y;++d)s[d]=s[d-P]}}i.l=f,i.p=z,i.b=d,i.f=c,f&&(c=1,i.m=p,i.d=v,i.n=g)}while(!c);return d!=s.length&&r?(h=s,(null==(a=d)||a>h.length)&&(a=h.length),new Wc(h.subarray(0,a))):s.subarray(0,d)}(t.subarray(n,-8),{i:2},new Wc(((s=t)[(e=s.length)-4]|s[e-3]<<8|s[e-2]<<16|s[e-1]<<24)>>>0),i)}var au="undefined"!=typeof TextDecoder&&new TextDecoder;try{au.decode(ou,{stream:!0})}catch(t){}function lu(t){return ut(t)}function cu(t){const i=t.indexOf(":");if(-1===i)throw new Error("Invalid compressed format: missing ':' separator");const s=t.slice(0,i),e=t.slice(i+1),n=atob(e),r=new Uint8Array(n.length);for(let t=0;t<n.length;t++)r[t]=n.charCodeAt(t);const o=hu(r);return{hash:s,json:(new TextDecoder).decode(o)}}const uu=class{constructor(i){t(this,i),this.datasources="",this.static=!1,this.raw=!0,this.refreshInterval=0,this.lastBodyHash=null,this.lastViewQuery=null,this.nameShared=!1,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,this.firstLoadPending=!1,this.onNameShared=t=>{const i=this.nameShared;this.nameShared=t,t?this.errors.addOrReplace({id:"ERR_name",type:"error",message:`name: "${this.name}" is used by more than one dataset or datasource.`}):(this.errors.remove("ERR_name"),i&&this.reload())},this.holdStatus=a(this),this.errors=l(this),((t,i)=>{let s,n=[],r=[];const o=t=>{let e;try{e=s.db.db.exec(`SELECT * FROM \`${t}\``)}catch(t){e=[]}i()},h=()=>{n.forEach((t=>t())),n=[],r.forEach((t=>{t&&(n.push(s.db.subscribe(t,(()=>o(t)))),o(t))}))},a=new MutationObserver((i=>{i.forEach((i=>{"datasources"===i.attributeName&&(r=(e(t).getAttribute("datasources")||"").split(","),h())}))})),l=t.connectedCallback;t.connectedCallback=()=>{const i=e(t);s=c(i),r=(i.getAttribute("datasources")||"").split(","),h(),a.observe(i,{attributes:!0,attributeFilter:["datasources"]}),d(l,t)};const u=t.disconnectedCallback;t.disconnectedCallback=()=>{a.disconnect(),n.forEach((t=>t())),n=[],f(e(t)),d(u,t)}})(this,(()=>{this.executeQuery()})),Qt(this,(t=>this.sync(t)))}sync(t){if(this.stores=c(this.element),!this.releaseName&&this.name&&(this.releaseName=this.stores.db.claim(this.name,this.onNameShared)),this.src){if(this.src===this.currentUrl)return;return this.currentUrl=this.src,this.lastBodyHash=null,this.query="",this.errors.remove("ERR_sql"),this.errors.remove("ERR_body"),this.firstLoadPending=!0,this.holdStatus(this.fetchAndStore(this.src)),void this.startPolling()}let i,s;if(null!==this.currentUrl&&(this.cancelInFlight(),this.currentUrl=null),this.errors.remove("ERR_src"),!this.raw&&this.static&&""!==t.trim())try{const e=cu(t);i=e.hash,s=e.json}catch(t){return this.errors.addOrReplace({id:"ERR_body",type:"error",message:`Body: ${ci(t)}`}),void(this.lastBodyHash=null)}else i=lu(t),s=t;i!==this.lastBodyHash&&(this.lastBodyHash=i,this.errors.remove("ERR_body"),this.query=s,this.executeQuery())}executeQuery(){var t,i;if(this.stores||(this.stores=c(this.element)),this.query||this.errors.remove("ERR_sql"),!this.name)return;if(!(this.query||this.static&&null===this.currentUrl))return;const s=this.stores.db.db;let e;if(this.static){try{e=""===this.query.trim()?[]:null!==(t=JSON.parse(this.query))&&void 0!==t?t:[],Array.isArray(e)?this.errors.remove("ERR_body"):this.errors.addOrReplace({id:"ERR_body",type:"error",message:"Body: not a JSON array."})}catch(t){this.errors.addOrReplace({id:"ERR_body",type:"error",message:`Body: ${ci(t)}`}),e=[]}s.tables[this.name]={data:Array.isArray(e)?e:[]},this.registered=s.tables[this.name],this.dropViewStatements(),this.errors.remove("ERR_sql")}else{if(this.lastViewQuery!==this.query){try{s.exec(`DROP VIEW \`${this.name}\``)}catch(t){}null!=s.tables[this.name]&&delete s.tables[this.name],s.views&&null!=s.views[this.name]&&delete s.views[this.name];try{if(v(this.query))throw new Error("double backticks are not allowed.");s.exec(`CREATE VIEW \`${this.name}\` AS ${this.query}`),this.registered=s.tables[this.name],s.resetSqlCache(),this.lastViewQuery=this.query}catch(t){return console.error("bn-dataset: failed to register SQL view",t,this.query),this.errors.addOrReplace({id:"ERR_sql",type:"error",message:`SQL: ${t instanceof Error?t.message:t}`}),s.resetSqlCache(),this.lastViewQuery=null,e=[],void this.publish(e)}}else null===(i=s.tables[this.name])||void 0===i||delete i.select;try{e=s.exec(`SELECT * FROM \`${this.name}\``),this.errors.remove("ERR_sql")}catch(t){if(void 0===this.latestResult)return;return this.errors.addOrReplace({id:"ERR_sql",type:"error",message:`SQL: ${t instanceof Error?t.message:t}`}),void this.publish([])}}this.publish(e)}publish(t){this.latestResult!==t?(this.latestResult=t,this.stores.db.notify(this.name),this.publishedMeta=function(t){const i={};for(const t of Tc)i[t]=new Set;const s={};for(const t of Ec)s[t]={hasData:!1,min:null,max:null};const e=new Set;let n=null,r=null;const o=Array.isArray(t)?t:[];for(let t=0;t<o.length;t++){const h=o[t];if(null==h)continue;for(const t of Tc){const s=h[t];null!=s&&""!==s&&i[t].add(String(s))}for(const t of Ec){const i=h[t];if(Cc(i)){const e=s[t];e.hasData=!0,(null===e.min||i<e.min)&&(e.min=i),(null===e.max||i>e.max)&&(e.max=i)}}const a=h.date;if(null!=a&&""!==a){const t=String(a);e.add(t),(null===n||t<n)&&(n=t),(null===r||t>r)&&(r=t)}}const h=Ec.map((t=>({key:t,hasData:s[t].hasData,min:s[t].min,max:s[t].max}))),a=h.filter((t=>t.hasData)).map((t=>t.key)),l=Pc(i.rowGroup),c=Pc(i.category),u=Pc(i.subCategory),d=Pc(i.columnGroup),f=Pc(i.columnSubGroup),v={min:n,max:r,hasData:e.size>0,distinctCount:e.size};let p="category";return u.hasData?p="subCategory":c.hasData?p="category":l.hasData&&(p="rowGroup"),{rowCount:o.length,scenarios:h,availableScenarios:a,rowGroup:l,category:c,subCategory:u,columnGroup:d,columnSubGroup:f,dateRange:v,suggestedLevel:p,suggestedOrder:p,suggestedDateInterval:v.hasData?"auto":null,calculatedAt:Date.now()}}(t),this.stores.datasetsMeta.set(this.name,this.publishedMeta)):this.stores.db.notify(this.name)}nameUpdated(t,i){var s;this.unregister(i),this.name&&this.element.isConnected&&this.sync(null!==(s=this.element.textContent)&&void 0!==s?s:"")}onIntervalChange(){this.currentUrl&&this.startPolling()}onSrcChange(){var t;this.element.isConnected&&this.sync(null!==(t=this.element.textContent)&&void 0!==t?t:"")}disconnectedCallback(){this.cancelInFlight(),this.unregister(this.name)}unregister(t){var i,s,e;const n=null===(s=null===(i=this.stores)||void 0===i?void 0:i.db)||void 0===s?void 0:s.db;n&&null!==this.lastViewQuery&&n.resetSqlCache(),null===(e=this.releaseName)||void 0===e||e.call(this),this.releaseName=void 0;const r=null!=(null==n?void 0:n.tables[t])&&n.tables[t]!==this.registered;if(r&&void 0!==this.publishedMeta&&this.stores.datasetsMeta.get(t)===this.publishedMeta&&this.stores.datasetsMeta.set(t,null),this.publishedMeta=void 0,this.registered=void 0,this.lastBodyHash=null,this.lastViewQuery=null,this.currentUrl=null,this.latestResult=void 0,n&&t&&!r){try{n.exec(`DROP VIEW \`${t}\``)}catch(t){}null!=n.tables[t]&&delete n.tables[t],n.views&&null!=n.views[t]&&delete n.views[t],this.stores.datasetsMeta.set(t,null),this.stores.db.notify(t)}}async fetchAndStore(t){var i,s;null===(i=this.abortController)||void 0===i||i.abort(),this.abortController=new AbortController,this.stores||(this.stores=c(this.element));try{const i=await fetch(t,{signal:this.abortController.signal});if(!i.ok)throw new Error(`HTTP ${i.status}`);const e=null!==(s=await i.json())&&void 0!==s?s:[];if(!Array.isArray(e))throw new Error("not a JSON array.");const n=this.stores.db.db;n.tables[this.name]={data:e},this.registered=n.tables[this.name],this.dropViewStatements(),this.errors.remove("ERR_src"),this.publish(e)}catch(t){if(t instanceof DOMException&&"AbortError"===t.name)return;this.errors.addOrReplace({id:"ERR_src",type:"error",message:`src: ${ci(t)}`});const i=this.stores.db.db;i.tables[this.name]={data:[]},this.registered=i.tables[this.name],this.dropViewStatements(),this.publish([])}this.firstLoadPending=!1}reload(){var t;null!==this.lastViewQuery&&this.stores.db.db.resetSqlCache(),this.lastBodyHash=null,this.lastViewQuery=null,this.currentUrl=null,this.latestResult=void 0,this.sync(null!==(t=this.element.textContent)&&void 0!==t?t:"")}dropViewStatements(){null!==this.lastViewQuery&&this.stores.db.db.resetSqlCache(),this.lastViewQuery=null}clearPollTimer(){null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null)}cancelInFlight(){var t;this.clearPollTimer(),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPollTimer(),this.currentUrl&&this.refreshInterval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&!this.firstLoadPending&&this.fetchAndStore(this.currentUrl)}),1e3*this.refreshInterval))}render(){return i(s,{key:"9a491c13d9ad8fba5da3c30f502a027a5ae1c606"})}get element(){return e(this)}static get watchers(){return{name:[{nameUpdated:0}],refreshInterval:[{onIntervalChange:0}],src:[{onSrcChange:0}]}}};uu.style="bn-dataset{display:none}";const du=class{constructor(i){t(this,i),this.raw=!0,this.refreshInterval=0,this.lastHash=null,this.nameShared=!1,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,this.firstLoadPending=!1,this.onNameShared=t=>{const i=this.nameShared;this.nameShared=t,t?this.errors.addOrReplace({id:"ERR_name",type:"error",message:`name: "${this.name}" is used by more than one dataset or datasource.`}):(this.errors.remove("ERR_name"),i&&this.reload())},this.holdStatus=a(this),this.errors=l(this),Qt(this,(t=>this.sync(t)))}sync(t){var i;if(this.stores=c(this.element),!this.releaseName&&this.name&&(this.releaseName=this.stores.db.claim(this.name,this.onNameShared)),this.src){if(this.src===this.currentUrl)return;return this.currentUrl=this.src,this.lastHash=null,this.errors.remove("ERR_body"),this.firstLoadPending=!0,this.holdStatus(this.fetchAndStore(this.src)),void this.startPolling()}null!==this.currentUrl&&(this.cancelInFlight(),this.currentUrl=null),this.errors.remove("ERR_src");try{let s,e;if(this.raw||""===t.trim())s=lu(t),e=t;else{const i=cu(t);s=i.hash,e=i.json}if(s===this.lastHash)return;this.lastHash=s;const n=""===e.trim()?[]:null!==(i=JSON.parse(e))&&void 0!==i?i:[];Array.isArray(n)?this.errors.remove("ERR_body"):this.errors.addOrReplace({id:"ERR_body",type:"error",message:"Body: not a JSON array."}),this.publish(n)}catch(t){this.lastHash=null,this.errors.addOrReplace({id:"ERR_body",type:"error",message:`Body: ${ci(t)}`}),this.publish([])}}reload(){var t;this.lastHash=null,this.currentUrl=null,this.sync(null!==(t=this.element.textContent)&&void 0!==t?t:"")}publish(t){const i=this.stores.db.db;i.tables[this.name]={data:Array.isArray(t)?t:[]},this.registered=i.tables[this.name],this.stores.db.notify(this.name)}onIntervalChange(){this.currentUrl&&this.startPolling()}onSrcChange(){var t;this.element.isConnected&&this.sync(null!==(t=this.element.textContent)&&void 0!==t?t:"")}nameUpdated(t,i){var s;this.unregister(i),this.name&&this.element.isConnected&&this.sync(null!==(s=this.element.textContent)&&void 0!==s?s:"")}disconnectedCallback(){this.cancelInFlight(),this.unregister(this.name),f(this.element)}unregister(t){var i,s,e;null===(i=this.releaseName)||void 0===i||i.call(this),this.releaseName=void 0,this.lastHash=null,this.currentUrl=null;const n=null===(e=null===(s=this.stores)||void 0===s?void 0:s.db)||void 0===e?void 0:e.db,r=null!=(null==n?void 0:n.tables[t])&&n.tables[t]!==this.registered;this.registered=void 0,n&&t&&!r&&(null!=n.tables[t]&&delete n.tables[t],n.views&&null!=n.views[t]&&delete n.views[t],this.stores.db.notify(t))}async fetchAndStore(t){var i,s;null===(i=this.abortController)||void 0===i||i.abort(),this.abortController=new AbortController,this.stores||(this.stores=c(this.element));try{const i=await fetch(t,{signal:this.abortController.signal});if(!i.ok)throw new Error(`HTTP ${i.status}`);const e=null!==(s=await i.json())&&void 0!==s?s:[];if(!Array.isArray(e))throw new Error("not a JSON array.");this.errors.remove("ERR_src"),this.publish(e)}catch(t){if(t instanceof DOMException&&"AbortError"===t.name)return;this.errors.addOrReplace({id:"ERR_src",type:"error",message:`src: ${ci(t)}`}),this.publish([])}this.firstLoadPending=!1}clearPollTimer(){null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null)}cancelInFlight(){var t;this.clearPollTimer(),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPollTimer(),this.currentUrl&&this.refreshInterval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&!this.firstLoadPending&&this.fetchAndStore(this.currentUrl)}),1e3*this.refreshInterval))}render(){return i(s,{key:"323018b2b642f9905874f94010c75b19bebde639"})}get element(){return e(this)}static get watchers(){return{refreshInterval:[{onIntervalChange:0}],src:[{onSrcChange:0}],name:[{nameUpdated:0}]}}};du.style="bn-datasource{display:none}";const fu=class{constructor(i){t(this,i),this.pageNumber=null,this.displayPageNumber=!0,a(this),this.errors=l(this),this.componentStyle=k(this)}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){return i(s,{key:"af4dda021b22094c4c55e25eb34da67dc1a8e41d",id:this.displayPageNumber||this.text?"container-page-footer":"container",style:this.getFontStyles()},i("div",{key:"f059b4ca265505730e9e384704d3b74579e3af9f",id:"footer-text"},null!=this.text?i("span",{class:"note"},this.text):""),i("div",{key:"0c00b17953457763640c4ebad3e0eb99ea742bfd",id:"page-number"},this.displayPageNumber?i("span",{class:"page"},this.pageNumber):""))}get element(){return e(this)}};fu.style=':host{padding:0.2em 0.5em;display:flex;flex-direction:row;justify-content:space-between;gap:1em;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}:host(#container-page-footer){box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em solid #ddd}div#footer-text{font-size:0.6em;display:inline}div#page-number{font-size:0.6em;display:inline}';const vu=new Map([["split-vertical",'"a b"'],["split-horizontal",'"a" "b"'],["2x2",'"a b" "c d"'],["3x3",'"a b c" "d e f" "g h i"'],["4x4",'"a b c d" "e f g h" "i j k l" "m n o p"'],["1-over-2",'"a a" "b c"'],["2-over-1",'"a b" "c c"'],["1-over-3",'"a a a " "b c d"'],["3-over-1",'"a b c" "d d d"']]),pu="custom-template",gu=/"[\w\d\s.]+"|'[\w\d\s.]+'/g,mu=/"[^"]*"|'[^']*'/g;function bu(t){var i;return(null!==(i=null==t?void 0:t.match(gu))&&void 0!==i?i:[]).map((t=>t.slice(1,-1).split(/\s+/).filter((t=>""!==t)))).filter((t=>t.length>0))}function yu(t,i){var s;return t===pu?bu(i).length>0?i:'"a"':null!==(s=vu.get(t))&&void 0!==s?s:'"a"'}function wu(t){var i;const s=(null===(i=bu(t)[0])||void 0===i?void 0:i.length)||1;return Array(s).fill("minmax(0, 1fr)").join(" ")}function xu(t){var i;return Array.from(new Set(null!==(i=null==t?void 0:t.match(/\b\w+\b/g))&&void 0!==i?i:[]))}function Su(t){var i;const s=bu(t);if(0===s.length)return'no row found, the layout is drawn as a single cell. Write one quoted row per grid row, e.g. \'"a a" "b c"\'.';const e=null!==(i=null==t?void 0:t.match(mu))&&void 0!==i?i:[];return e.some((t=>""===t.slice(1,-1).trim()))?"a pair of quotes holds no cell, so the browser ignores the template.":e.length!==s.length?"a row cannot be read. Use only letters, digits, '_' and '.' in a cell name, and open and close every row with the same kind of quote.":s.some((t=>t.length!==s[0].length))?"the rows have different numbers of cells, so the browser ignores the template.":void 0}const $u=class{constructor(i){t(this,i),this.titleImage="",this.titleBusinessUnit="",this.titleOrder="category",this.titleOrderDirection="asc",this.titleDateFormat="none",this.titleDateLink="none",this.footerText="",this.cardLayout="full",this.cardCustomTemplate='"a b" "c d"',this.cardGridGap="0",this.cardFitToContent=!1,this.cardShowBorder=!0,a(this),this.errors=l(this),this.resolveInherited=qt(this,[{propName:"titleScenarios",ancestorAttr:"title-scenarios"},{propName:"titleVariances",ancestorAttr:"title-variances"},{propName:"titleOrder",ancestorAttr:"title-order"},{propName:"titleOrderDirection",ancestorAttr:"title-order-direction"},{propName:"ruleset",ancestorAttr:"ruleset"}])}connectedCallback(){this.stores=c(this.element)}getCommonStyles(){let t="100%";return!0===this.cardFitToContent&&(t="fit-content"),{display:"grid",height:t,width:"100%",gap:this.cardGridGap+"px"}}getGridTemplateColumns(t){return wu(this.getTemplatePattern(t))}getRowCount(t){return bu(this.getTemplatePattern(t)).length||1}getGridTemplateRows(t){const i=this.getRowCount(t);return this.cardFitToContent?Array(i).fill("auto").join(" "):Array(i).fill("minmax(0, 1fr)").join(" ")}getLayoutStyle(){return Object.assign(Object.assign({},this.getCommonStyles()),{"grid-template-areas":this.getTemplatePattern(this.cardLayout),"grid-template-columns":this.getGridTemplateColumns(this.cardLayout),"grid-template-rows":this.getGridTemplateRows(this.cardLayout)})}createDivAreaStyles(t){return t.map((t=>({display:"flex",overflow:"hidden","grid-area":t})))}getSlots(t){const s=this.createDivAreaStyles(t);return i(o,null,s.map(((t,s)=>i("div",{style:t},i("slot",{name:"card-slot-"+s})))))}extractSlotNames(t){return xu(t)}getTemplatePattern(t){return yu(t,this.cardCustomTemplate)}componentWillRender(){const t=this.cardLayout===pu?Su(this.cardCustomTemplate):void 0;t?this.errors.addOrReplace({id:"WARN_cardCustomTemplate",type:"warning",message:`cardCustomTemplate: ${t}`}):this.errors.remove("WARN_cardCustomTemplate")}setCardClass(){return!0===this.cardShowBorder?"card_box border":"card_box"}titleProp(t){return this.resolveInherited(t,this[t],"").value}prepareTitleImage(t){if(null==t||""===t)return"";const i=this.stores.assets.state;return t.startsWith("asset:")?i[t.substring(6)]:i[t]||t}render(){var t;const s=this.getLayoutStyle(),e=this.extractSlotNames(s["grid-template-areas"]);return i("bn-card",{key:"f9d135554b1ab8a8bee9bb4f7084e465e495e180",styles:this.styles,"selected-style":this.selectedStyle,class:this.setCardClass()},i("div",{key:"54766941aa09df561453f620bd2ecd16f9fd3526",class:"cardtitle"},i("bn-title",{key:"ce2dc7bd84943a6b97068441d9da85a150271227","i18n-namespace":null!==(t=this.i18nNamespace)&&void 0!==t?t:this.titleNamespace,ruleset:this.titleProp("ruleset"),"business-unit":this.titleBusinessUnit,scenarios:this.titleProp("titleScenarios"),variances:this.titleProp("titleVariances"),order:this.titleProp("titleOrder"),"order-direction":this.titleProp("titleOrderDirection"),measures:this.titleMeasures,"date-start":this.titleDateStart,"date-end":this.titleDateEnd,"date-format":this.titleDateFormat,"date-link":this.titleDateLink}),null!=this.titleImage&&""!==this.titleImage?i("img",{class:"image",src:this.prepareTitleImage(this.titleImage)}):""),i("bn-body",{key:"b692bf5149c7c34288b612b7179779030ef2031c"},i("div",{key:"2650ddbbae89f6e63fdeba3f65513446eb22a96f",style:s,"data-bn-fit-content":this.cardFitToContent?String(this.getRowCount(this.cardLayout)):null},this.getSlots(e))),i("bn-footer",{key:"d924118be1d48c4f80b8e6d39f90aa1e2b3a1ff2",text:this.footerText,"page-number":"0","display-page-number":"false"}))}get element(){return e(this)}};$u.style=':host{--bn-baseline-offset-top:0px;--bn-baseline-offset-left:0px;--bn-baseline-offset-right:0px;background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden}.cardtitle{display:inline-flex}::slotted(*){flex:1 1 auto;min-width:0}.image{margin-right:0.5em;margin-top:0.5em;z-index:2;background-color:transparent;border:transparent;height:4em;width:auto;display:inline}bn-body{box-sizing:border-box;padding:var(--bn-baseline-offset-top) var(--bn-baseline-offset-right) 0 var(--bn-baseline-offset-left)}';const Mu=class{constructor(i){t(this,i),this.messageText="",this.messageImage="",this.titleBusinessUnit="",this.titleOrder="category",this.titleOrderDirection="asc",this.titleDateFormat="none",this.titleDateLink="none",this.footerDisplayPageNumber=!0,this.pageLayout="full",this.pageCustomTemplate='"a b" "c d"',this.pageGridGap="0",this.pageFitToContent=!1,a(this),this.errors=l(this)}getCommonStyles(){let t="100%";return!0===this.pageFitToContent&&(t="fit-content"),{display:"grid",height:t,width:"100%",gap:this.pageGridGap+"px"}}getRowCount(t){return bu(this.getTemplateAreas(t)).length||1}getGridTemplateRows(t){const i=this.getRowCount(t);return this.pageFitToContent?Array(i).fill("auto").join(" "):Array(i).fill("minmax(0, 1fr)").join(" ")}getLayoutStyle(){return Object.assign(Object.assign({},this.getCommonStyles()),{"grid-template-areas":this.getTemplateAreas(this.pageLayout),"grid-template-columns":this.getGridTemplateColumns(this.pageLayout),"grid-template-rows":this.getGridTemplateRows(this.pageLayout)})}createDivAreaStyles(t){return t.map((t=>({display:"flex",overflow:"hidden","grid-area":t})))}getSlots(t){const s=this.createDivAreaStyles(t);return i(o,null,s.map(((t,s)=>i("div",{style:t},i("slot",{name:"slot-"+s})))))}extractSlotNames(t){return xu(t)}getTemplateAreas(t){return yu(t,this.pageCustomTemplate)}getGridTemplateColumns(t){return(i=t)===pu||vu.has(i)?wu(this.getTemplateAreas(t)):"1fr";var i}mirror(t,i){null==i?this.element.hasAttribute(t)&&this.element.removeAttribute(t):this.element.getAttribute(t)!==i&&this.element.setAttribute(t,i)}componentWillRender(){this.mirror("page-format",this.pageFormat),this.mirror("page-orientation",this.pageOrientation);const t=this.pageLayout===pu?Su(this.pageCustomTemplate):void 0;t?this.errors.addOrReplace({id:"WARN_pageCustomTemplate",type:"warning",message:`pageCustomTemplate: ${t}`}):this.errors.remove("WARN_pageCustomTemplate")}rotation(){var t;const i=null===(t=this.element.closest("bn-context"))||void 0===t?void 0:t.getAttribute("render-orientation"),s=kc(this.pageFormat,this.pageOrientation,i);if(s.turned)return{host:{width:s.width,height:s.height},page:{transform:"rotate(-90deg) translate(-100%)",transformOrigin:"top left"}}}render(){var t;const e=this.getLayoutStyle(),n=this.extractSlotNames(e["grid-template-areas"]),r=this.rotation();return i(s,{key:"290e6e8250c5f8bf53352886a810eeedd7548e57",style:null==r?void 0:r.host},i("bn-page",{key:"71b472107af79e9581e2097aae33c6b2808decbf",styles:this.styles,"selected-style":this.selectedStyle,format:this.pageFormat,orientation:this.pageOrientation,style:null==r?void 0:r.page},i("bn-message",{key:"99ac5c760476f95ff296077736849e6ddfd85120",text:this.messageText,image:this.messageImage}),i("bn-title",{key:"3af5ee4a7be905676a927397ff19cf062b291fb6","i18n-namespace":null!==(t=this.i18nNamespace)&&void 0!==t?t:this.titleNamespace,ruleset:this.ruleset,"business-unit":this.titleBusinessUnit,scenarios:this.titleScenarios,variances:this.titleVariances,order:this.titleOrder,"order-direction":this.titleOrderDirection,measures:this.titleMeasures,"date-start":this.titleDateStart,"date-end":this.titleDateEnd,"date-format":this.titleDateFormat,"date-link":this.titleDateLink}),i("bn-body",{key:"c91e9c708934499b855fe9e321bebb7aed31ab7c"},i("div",{key:"92d01a4bad8ae401e570fcee4a9bbdac42b31d81",style:e,"data-bn-fit-content":this.pageFitToContent?String(this.getRowCount(this.pageLayout)):null},this.getSlots(n)),i("slot",{key:"ac227c5985b827e91d139396915e3a104e44710b",name:"annotations"})),i("bn-footer",{key:"41dfc75b74a158a0e7cdb05456b03ae62cf6d6db",text:this.footerText,"page-number":this.pageNumber,"display-page-number":this.footerDisplayPageNumber})))}get element(){return e(this)}};Mu.style=':host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:block;overflow:hidden}::slotted(*){flex:1 1 auto;min-width:0}';const _u=class{constructor(i){t(this,i),a(this),this.errors=l(this),this.componentStyle=k(this)}connectedCallback(){this.stores=c(this.element)}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}prepareAssetUrl(t){if(null==t||""===t)return"";const i=this.stores.assets.state;return t.startsWith("asset:")?i[t.substring(6)]:i[t]||t}render(){return i(s,{key:"4de8953156b05196149fe7a89e2b6a2d9f831695",id:this.text||this.image?"container-page-message":"container",style:this.getFontStyles()},i("div",{key:"ca005a6c2c06b59facea40c0aab4e146d51be557",id:"message-text"},null!=this.text&&""!==this.text?i("span",{class:"note",innerHTML:zt(this.text)}):""),i("div",{key:"8fbdc7014401f0f02ef5c79b37bcc57b29a18a59",id:"page-image"},null!=this.image&&""!==this.image?i("img",{class:"image",src:this.prepareAssetUrl(this.image)}):""))}get element(){return e(this)}};_u.style=':host{padding:0.2em 0.5em;display:flex;flex-direction:row;justify-content:space-between;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}:host(#container-page-message){min-height:4.55em;box-sizing:border-box;-webkit-box-sizing:border-box;border-bottom:0.1em solid #ddd}div#message-text{font-size:1.4em;overflow:clip;display:inline}span.note p{margin:0}.image{z-index:2;background-color:transparent;border:transparent;height:4em;width:auto;display:block}';const Ou=class{constructor(i){t(this,i),a(this),this.errors=l(this),this.componentStyle=k(this)}validateFormat(t){const i="WARN_format";N(t)||Mc.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`format: invalid value '${t}' is not supported. Valid values: ${Mc.join(", ")}`})}validateOrientation(t){const i="WARN_orientation";N(t)||_c.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`orientation: invalid value '${t}' is not supported. Valid values: ${_c.join(", ")}`})}componentWillLoad(){this.validateFormat(this.format),this.validateOrientation(this.orientation)}render(){return i(s,{key:"b2d1a2638c7bee2b2e134d5fedbac63fe38e9830",format:this.format,orientation:this.orientation,style:this.prepareStyle()},i("slot",{key:"4769d18000916a16ee9da8fb0c19b5d8b12393c0"}))}prepareStyle(){const t={"font-family":this.componentStyle((t=>t.global.fontFamily)),"font-size":`${this.componentStyle((t=>t.global.fontSizePx))}px`,"--bn-font-family":this.componentStyle((t=>t.global.fontFamily))||"'Noto Sans', sans-serif","--bn-font-size":`${this.componentStyle((t=>t.global.fontSizePx))||13.3333}px`,"--bn-font-color":this.componentStyle((t=>t.global.fontColor))||"#000000","--bn-font-background":this.componentStyle((t=>t.global.fontBackgroundColor))||"#ffffff"};if(Mc.includes(this.format)){const{width:i,height:s}=Oc(this.format,this.orientation);t.width=i,t.height=s}return t}get element(){return e(this)}static get watchers(){return{format:[{validateFormat:0}],orientation:[{validateOrientation:0}]}}};Ou.style=':host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);height:768px;width:1024px;display:flex;flex-direction:column;page-break-after:always;overflow:hidden}';const ku=class{constructor(i){t(this,i),a(this),this.errors=l(this)}connectedCallback(){this.stores=c(this.element),this.pushToStore()}disconnectedCallback(){this.removeEntryIfOurs(this.storedName)}onNameChange(t,i){const s=null==i?void 0:i.toString().trim();s&&s!==(null==t?void 0:t.toString().trim())&&this.removeEntryIfOurs(s),this.pushToStore()}onValueChange(){this.pushToStore()}removeEntryIfOurs(t){t&&this.stores&&(this.storedName===t&&this.stores.scalingGroups.state[t]===this.storedValue&&this.stores.scalingGroups.set(t,void 0),this.storedName===t&&(this.storedName=void 0,this.storedValue=void 0))}pushToStore(){var t;if(!this.stores)return;const i=null===(t=this.name)||void 0===t?void 0:t.toString().trim(),s=Kt(i);if("auto"===s.kind)return void this.errors.addOrReplace({id:"WARN_reserved_name",type:"warning",message:'bn-scaling-group: name "auto" is reserved and cannot be used.'});if(this.errors.remove("WARN_reserved_name"),!i)return void this.errors.addOrReplace({id:"WARN_empty_name",type:"warning",message:"bn-scaling-group: name is required."});if(this.errors.remove("WARN_empty_name"),"number"===s.kind)return void this.errors.addOrReplace({id:"WARN_numeric_name",type:"warning",message:`bn-scaling-group: name "${i}" is not allowed - it would be ambiguous with a numeric scaling value.`});this.errors.remove("WARN_numeric_name");const e=Kt(this.value);if("number"!==e.kind)return void this.errors.addOrReplace({id:"WARN_invalid_value",type:"warning",message:`bn-scaling-group: invalid value "${this.value}" - must be a positive number, optionally with k/M/G/T suffix.`});this.errors.remove("WARN_invalid_value");const n=this.stores.scalingGroups.state[i];void 0===n||n===e.value||this.storedName===i&&this.storedValue===n?this.errors.remove("WARN_duplicate_group"):this.errors.addOrReplace({id:"WARN_duplicate_group",type:"warning",message:`bn-scaling-group: "${i}" is already registered with a different value (${Jt(n)}); overwriting.`}),this.storedName&&this.storedName!==i&&this.removeEntryIfOurs(this.storedName),this.stores.scalingGroups.set(i,e.value),this.storedName=i,this.storedValue=e.value}render(){return i(s,{key:"db1fe7bbe3d3caf76ad32eac64f944eef10b1ccd"})}get element(){return e(this)}static get watchers(){return{name:[{onNameChange:0}],value:[{onValueChange:0}]}}};var Au,Ru,Nu,Lu,Eu;ku.style="bn-scaling-group{display:none}",function(t){t[t.ALL=-1]="ALL"}(Au||(Au={})),function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(Ru||(Ru={})),function(t){t.LIST="list",t.SUM="sum",t.SUMNOTOTAL="sumnototal",t.OPT="opt",t.OPTNOTOTAL="optnototal"}(Nu||(Nu={})),function(t){t.ASC="asc",t.DESC="desc"}(Lu||(Lu={})),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"}(Eu||(Eu={}));const Tu="none",Cu="setname";function Pu(t){return t===Cu?"COALESCE([setname],[setName])":`normalizeDate([date], '${t}')`}function Wu(t){if(null==t)return"";if("string"==typeof t)return t.trim();const i=Du(t);return i?i.toISO():String(t)}function Du(t){if(null!=t){if("string"==typeof t){const i=y.fromISO(t,{zone:"utc"});return i.isValid?i:void 0}if("number"==typeof t){const i=y.fromMillis(t,{zone:"utc"});return i.isValid?i:void 0}if("boolean"==typeof t.isValid)return t.isValid?t:void 0}}const zu=class{validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("WARN_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"WARN_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("WARN_scale")}constructor(i){t(this,i),this.layoutObserver=null,this._lastScaledParentWidth=0,this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.hasBlankSetnames=!1,this.sumTitle="",this.filter="",this.measureUnit="",this.barColumnWidth="w10",this.unitScaling="100",this.percentageScaling="2",this.pixelPerUnitGroupMap=new Map,this.dataFormat="decimal",this.grouped=!1,this.showMeasureScale=!1,this.showGroupTitle=!0,this.type="list",this.limit=0,this.thereof="[]",this.partof="[]",this.order="category",this.orderDirection="asc",this.measureType="volume",this.measureScale="greatest",this.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.categoryWidth="w15",this.columnthereof=null,this.interval="none",this.tableAttributes="",this._autoScaleGuard=!1,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=t=>{var i,s,e,n;this.lastAutoScalingReport={unit:null!==(i=t.unit)&&void 0!==i?i:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(e=t.percentage)&&void 0!==e?e:null===(n=this.lastAutoScalingReport)||void 0===n?void 0:n.percentage};const r=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t);if(void 0!==t.unit&&t.unit>0&&this.autoUnitWarningActive){const i=1/t.unit;r(i,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=i,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: invalid value "${this.unitScaling}" - auto-fitted to 1 em ≈ ${Jt(i)} units.`}))}if(void 0!==t.percentage&&t.percentage>0&&this.autoPctWarningActive){const i=1/t.percentage;r(i,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=i,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: invalid value "${this.percentageScaling}" - auto-fitted to 1 em ≈ ${Jt(i)} percentage points.`}))}},E(this),a(this),this.errors=l(this),ns(this),this.componentStyle=k(this),this.ruleSetConfig=es(this),Yt(this,((t,i)=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1,this.hasBlankSetnames=Array.isArray(i)&&i.some((t=>{var i;return N(null!==(i=null==t?void 0:t.setname)&&void 0!==i?i:null==t?void 0:t.setName)}))}),((t,i)=>{this.datasetMeta=i})),this.t=Bt(this).t,this.resolveInherited=qt(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}],this.errors)}validateFilter(t){const i="ERR_filter";v(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(Gt(t))return void this.errors.remove(i);const s=B(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+(null==s?void 0:s.toString())+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(Gt(t))return void this.errors.remove(i);const s=H(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateBarColumns(t){const i="WARN_barColumns";if(N(t))return void this.errors.remove(i);const s=dt(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"barColumns: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateBarColumnWidth(t){const i="WARN_barColumnWidth";ft(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"barColumnWidth: invalid value '"+t+"' is not supported."})}validateUnitScaling(t){const i="WARN_unitScaling";"invalid"===Xt(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="WARN_percentageScaling";"invalid"===Xt(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validateDataFormat(t){const i="WARN_dataFormat";vt(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormat: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateType(t){const i="WARN_type";pt(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"type: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateLimit(t){const i="WARN_limit";L(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateThereOf(t){const i="WARN_thereof",s=gt(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"ThereOf: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validatePartOf(t){const i="WARN_partof",s=mt(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"partof: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderList(t){const i="WARN_order";if(Gt(t))return void this.errors.remove(i);const s=bt(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="WARN_orderDirection";Gt(t)||F(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasureType(t){const i="WARN_measureType";yt(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureType: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";X(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDataFormatDigitsDecimal(t){const i="WARN_dataFormatDigitsDecimal";L(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsDecimal: invalid value(s) '"+t+"' are not supported."})}validateDateFormatDigitsPercent(t){const i="WARN_dataFormatDigitsPercent";L(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsPercent: invalid value(s) '"+t+"' are not supported."})}validateCategoryWidth(t){const i="WARN_categoryWidth";wt(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"categoryWidth: invalid value(s) '"+t+"' are not supported."})}validateColumnThereOf(t){const i=xt(t),s="WARN_columnthereof";i.length>0?this.errors.addOrReplace({id:s,type:"warning",message:"columnthereof: invalid value(s) '"+JSON.stringify(i)+"' are not supported."}):this.errors.remove(s)}validateInterval(t){const i="WARN_interval",s=null==t?void 0:t.trim().toLowerCase();N(t)||s===Tu||s===Cu||nt(s)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"interval: invalid value '"+t+"' is not supported."})}validateTableAttributes(t){const i="WARN_attributes",s=St(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"attributes: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateDataFormat(this.dataFormat),this.validateType(this.type),this.validateLimit(this.limit),this.validateThereOf(this.thereof),this.validatePartOf(this.partof),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDateFormatDigitsPercent(this.dataFormatDigitsPercent),this.validateCategoryWidth(this.categoryWidth),this.validateMeasureType(this.measureType),this.validateMeasureScale(this.measureScale),this.validateColumnThereOf(this.columnthereof),this.validateInterval(this.interval),this.validateTableAttributes(this.tableAttributes),this.validateBarColumns(this.barColumns),this.validateBarColumnWidth(this.barColumnWidth),this.validateUnitScaling(this.unitScaling),this.validatePercentageScaling(this.percentageScaling),this.validateScaling(this.scale)}componentDidLoad(){this.layoutObserver=ss(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=Ut(this.element);t>0&&Math.abs(t-this._lastScaledParentWidth)>2&&(this._lastScaledParentWidth=t,n(this))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}componentDidRender(){$s(this.element,"bn-table-renderer");const{mode:t}=Ht(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{width:s}=Ut(i);if(s<=0)return void this.checkOverflow();this._lastScaledParentWidth=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),n=i.scrollWidth,o=this.appliedScaleFactor;if(n<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const h=Math.max(.3,o*(s-1)/n);Math.abs(h-o)<.001||(i.style.setProperty("--bn-font-size",e*h+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled table by factor ${h.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,r((()=>{this.appliedScaleFactor=h}))),this.checkOverflow()}checkOverflow(){const t=Ut(this.element),i=this.element.scrollWidth,s=this.element.scrollHeight,e=t.width>0&&i>t.width+1,n=t.height>0&&s>t.height+1;if(!e&&!n)return void M(this.errors,null);const{mode:r}=Ht(this.scale),o="auto"!==r&&"empty"!==r,h=[];e&&h.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),n&&h.push(`height (${Math.round(s)}px > ${Math.round(t.height)}px)`),M(this.errors,`Table exceeds available ${h.join(" and ")}. Give the component more space, reduce rows (e.g. limit), or set a smaller scale.`,o)}prepareDataFormat(){var t;return $t[null===(t=this.dataFormat)||void 0===t?void 0:t.toUpperCase()]}prepareGrouped(){return this.grouped}prepareShowGroupTitle(){return this.showGroupTitle}prepareTableType(){var t;return Nu[null===(t=this.type)||void 0===t?void 0:t.toUpperCase()]}prepareLimit(){return Math.floor(Number(this.limit)||0)}prepareThereOf(){if(null==this.thereof||""===this.thereof.trim())return[];try{return JSON.parse(this.thereof)}catch(t){return[]}}preparePartOf(){if(null==this.partof||""===this.partof.trim())return[];try{return JSON.parse(this.partof)}catch(t){return[]}}prepareOrder(){var t;const i=this.resolveInherited("order",this.order,"category").value,s=this.resolveInherited("orderDirection",this.orderDirection,"asc").value,e="auto"===(null==i?void 0:i.trim().toLowerCase());let n=i;return e&&(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)&&(n=this.datasetMeta.suggestedOrder),{hierarchy:n.split(",").map((t=>Mt(t))),direction:j[null==s?void 0:s.toUpperCase()]}}prepareI18nMode(){return _t.META}prepareI18n(){const t=p,i=new Map(["in","category","operation","thereof","part_of","SUM_TOTAL","no-data","REST"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries(),...Ts(this.ruleSetConfig("user"))])}prepareDataFormatDigits(){return{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal}}prepareScenarios(){var t,i,s,e,n,r,o,h,a,l,c;const u=this.resolveInherited("scenarios",this.scenarios),d=this.resolveInherited("variances",this.variances);if(u.inherited||d.inherited){this.errors.remove("AUTO_scenarios");let e=[];return N(u.value)?u.unresolved&&(e=e.concat(null!==(i=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==i?i:[])):e=e.concat(u.value.split(",")),(null===(s=d.value)||void 0===s?void 0:s.trim().length)>0&&(e=e.concat(d.value.split(","))),e.map((t=>t.trim()))}const f="auto"===(null===(e=u.value)||void 0===e?void 0:e.trim().toLowerCase()),v=f||u.unresolved;if((N(u.value)||f)&&N(d.value))return(null===(r=null===(n=this.datasetMeta)||void 0===n?void 0:n.availableScenarios)||void 0===r?void 0:r.length)>0?(v?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),this.datasetMeta.availableScenarios):[];let p=[];return f||N(u.value)?(null===(h=null===(o=this.datasetMeta)||void 0===o?void 0:o.availableScenarios)||void 0===h?void 0:h.length)>0&&(v?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),p=p.concat(this.datasetMeta.availableScenarios)):(this.errors.remove("AUTO_scenarios"),p=p.concat(null===(a=u.value)||void 0===a?void 0:a.split(","))),(null===(l=d.value)||void 0===l?void 0:l.trim().length)>0&&(p=p.concat(null===(c=d.value)||void 0===c?void 0:c.split(","))),p.map((t=>t.trim()))}prepareCategoryWidth(){var t;return N(this.categoryWidth)?Ot.INF:Ot[null===(t=this.categoryWidth)||void 0===t?void 0:t.toUpperCase()]}prepareMeasureScale(){return N(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareMeasureType(){var t;return N(this.measureType)?kt.VOLUME:kt[null===(t=this.measureType)||void 0===t?void 0:t.toUpperCase()]}prepareColumnThereOf(){if(null==this.columnthereof||""===this.columnthereof.trim())return new Map;const t=new Map;try{const i=JSON.parse(this.columnthereof);for(const[s,e]of Object.entries(i))!1===t.has(e.scenario)&&t.set(e.scenario,[]),t.get(e.scenario).push(e)}catch(t){return new Map}return t}prepareInterval(){var t;const i="WARN_intervalConflict",s="WARN_intervalNoDate",e="WARN_intervalSetname",n=N(this.interval)?Tu:this.interval.trim().toLowerCase();return n!==Tu&&n!==Cu&&!nt(n)||n===Tu?(this.errors.remove(i),this.errors.remove(s),this.errors.remove(e),Tu):null!=this.columnthereof&&""!==this.columnthereof.trim()?(this.errors.addOrReplace({id:i,type:"warning",message:"interval: cannot be combined with columnthereof, interval is ignored."}),this.errors.remove(s),this.errors.remove(e),Tu):(this.errors.remove(i),n===Cu?(this.hasBlankSetnames?this.errors.addOrReplace({id:e,type:"warning",message:"interval: rows with blank setname found, they are grouped under '-'."}):this.errors.remove(e),this.errors.remove(s),Cu):(this.errors.remove(e),this.datasetMeta&&!(null===(t=this.datasetMeta.dateRange)||void 0===t?void 0:t.hasData)?(this.errors.addOrReplace({id:s,type:"warning",message:"interval: dataset has no date values, interval is ignored."}),Tu):(this.errors.remove(s),n)))}prepareAttributes(){if(null==this.tableAttributes||""===this.tableAttributes.trim())return[];try{const t=JSON.parse(this.tableAttributes);return null===t||"object"!=typeof t||t instanceof Array?[]:Object.entries(t).map((([t,i],s)=>"string"==typeof i?At(t,`attr_${s}`,i):null)).filter((t=>null!==t))}catch(t){return[]}}prepareSumTitle(){return""===this.sumTitle||null==this.sumTitle?"SUM_TOTAL":this.sumTitle}prepareShowMeasureScale(){return this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareBarColumnWidth(){var t;const i=null===(t=this.barColumnWidth)||void 0===t?void 0:t.toUpperCase(),s=Nt[i];return s?Rt[s]:Rt[Nt.W10]}prepareBarColumns(){return N(this.barColumns)?[]:this.barColumns.split(",").map((t=>t.trim()))}prepareUnitScaling(){const t=Xt(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,1/t.value):"auto"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: invalid value "${t.raw}" - auto-fitting to the bar column width.`}),0)}preparePercentageScaling(){const t=Xt(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,1/t.value):"auto"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: invalid value "${t.raw}" - auto-fitting to the pin area.`}),0)}getDataStructure(){return{ITableDataRow:{setName:{type:"string",isOptional:!1,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}async getBaseline(){return this.readBaseline()}readBaseline(){var t,i,s;return function(t,i){var s;if(!t)return{};const e=si(i),n={},r=t.querySelector("thead");if(r){const t=e.toLocal(r.getBoundingClientRect());n.y=Di(t.y+t.height)}const o=t=>t?Array.from(t.children).filter((t=>"tr"===t.localName)):[],h=o(r),a=null!==(s=h[h.length-1])&&void 0!==s?s:o(t.querySelector("tbody"))[0],l=a?Array.from(a.children):[],c=l.findIndex((t=>t.classList.contains("category"))),u=l[c>=0?c+1:1];return u&&(n.x=Di(e.toLocal(u.getBoundingClientRect()).x)),n}(null===(s=null===(i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelector("bn-table-renderer"))||void 0===i?void 0:i.shadowRoot)||void 0===s?void 0:s.querySelector("table"),this.element)}async getLayoutState(t){var i,s,e,n;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",o=ei(this.element),h=this.getEffectiveScaleFactor(),a=Number.isFinite(h)&&h>0?h:1,l=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*a,c={version:li,tag:this.element.localName,id:ii(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:ti(this.element,o),em:{fontSizePx:l,appliedScaleFactor:a},regions:[],metadata:{},diagnostics:Zt(this.element),scaling:this.resolveScalingInfo(l),baseline:this.readBaseline()},u=null===(e=this.element.shadowRoot)||void 0===e?void 0:e.querySelector("bn-table-renderer");if(u){const t=null!==(n=u.scenarios)&&void 0!==n?n:[];if(c.metadata.scenarios=t.filter((t=>!t.startsWith("d"))),c.metadata.variances=t.filter((t=>t.startsWith("d"))),"function"==typeof u.getLayoutDetail){const t=await u.getLayoutDetail(o,r);c.regions=t.regions,c.metadata=Object.assign(Object.assign({},c.metadata),t.metadata),c.diagnostics=[...c.diagnostics,...t.diagnostics],t.elements&&(c.elements=t.elements),t.table&&(c.table=t.table)}}return c}resolveScalingInfo(t){var i,s;const e={},n=Xt(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===n.kind)e.unitMode="fixed",e.unitsPerEm=n.value,e.unitPxPerUnit=t/n.value;else{e.unitMode="auto";const s=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==s&&s>0&&(e.unitsPerEm=1/s,e.unitPxPerUnit=s*t)}const r=Xt(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)e.percentageMode="fixed",e.percentagePointsPerEm=r.value,e.percentagePxPerPoint=t/r.value;else{e.percentageMode="auto";const i=null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.percentage;void 0!==i&&i>0&&(e.percentagePointsPerEm=1/i,e.percentagePxPerPoint=i*t)}return e}getEffectiveScaleFactor(){const{mode:t,factor:i}=Ht(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const o=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":o*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles(),e=this.getEffectiveScaleFactor();return i(s,{key:"42974a4931f678c35e5c740bf6d630966368fb4b",style:t},i("div",{key:"2c8f99a8bd155e2c93e55e9542090d04afe22a31"},i("bn-table-renderer",{key:"cae9e83bf297e730f12a8a390cbf279413c40b54",tableName:this.datasetName,dataVersion:this.dataVersion,sumTitle:this.prepareSumTitle(),scenarios:this.prepareScenarios(),scenariosDataFormat:this.prepareDataFormat(),grouped:this.prepareGrouped(),limit:this.prepareLimit(),showGroupTitle:this.prepareShowGroupTitle(),thereof:this.prepareThereOf(),partof:this.preparePartOf(),order:this.prepareOrder(),categorythereof:this.prepareColumnThereOf(),attributeColumns:this.prepareAttributes(),type:this.prepareTableType(),categoryWidth:this.prepareCategoryWidth(),dataFormatDigits:this.prepareDataFormatDigits(),i18n:this.prepareI18n(),i18nMode:this.prepareI18nMode(),measureScale:this.prepareMeasureScale(),measureType:this.prepareMeasureType(),measureUnit:this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(),filter:this.prepareFilter(),barColumns:this.prepareBarColumns(),interval:this.prepareInterval(),barColumnMaxWidth:this.prepareBarColumnWidth(),unitScaling:this.prepareUnitScaling(),percentageScaling:this.preparePercentageScaling(),reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,scaleFactor:e,ruleSetConfig:this.ruleSetConfig(),selectedStyle:this.selectedStyle})))}get element(){return e(this)}static get watchers(){return{scale:[{validateScaling:0}],filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat:0}],type:[{validateType:0}],limit:[{validateLimit:0}],thereof:[{validateThereOf:0}],partof:[{validatePartOf:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],measureType:[{validateMeasureType:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDateFormatDigitsPercent:0}],categoryWidth:[{validateCategoryWidth:0}],columnthereof:[{validateColumnThereOf:0}],interval:[{validateInterval:0}],tableAttributes:[{validateTableAttributes:0}]}}};zu.style=':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)}';const Uu=/[\s\u200e\u200f\u061c]*[%\u066a][\s\u200e\u200f\u061c]*/;class Fu{constructor(t,i,s,e,n,r,o,h,a){this.prefixStyle="prefix",this.isBarChart=!1,this.key=t,this.index=i,this.value=s,this.prefix=r||"",this.cssStyle=e||"",this.prefixStyle=o||"prefix",this.type=n,this.mark=void 0,this.colSpan=h||1,this.measureScale=a||1}getAsHeaderList(){if(null==this.value)return[""];const t=[];for(const i of this.value.toString().split("<br/>"))t.push(i);return t}draw(t,i){let s=this.value;if("undefined"===s||void 0===s||null==s)return"";if(Number.isNaN(Number(s)))return s;if(""===this.type||void 0===this.type||null==this.type)return s;let e=t.percent,n=t.percent;return"percentpoint"===this.type?ra.number(Number(s),"percent",e,n,1,i).replace(Uu,""):("decimal"===this.type&&(s=+s/this.measureScale,e=t.decimal,n=t.decimal),ra.number(Number(s),this.type,e,n,1,i))}drawPrefix(){return null==this.prefix?"":this.prefix}}class Gu{constructor(t,i,s){this.index=t,this.groupindex=i,this.type=s,this.cssStyle=this.initCssStyle(),this.elements=[]}initCssStyle(){switch(this.type){case Eu.HEADER:return"groupheader";case Eu.SEPERATORLINE:return"";case Eu.DRILLELEMENT:return"ofit";case Eu.PARTELEMENT:return"partof";case Eu.STANDARD:return"";case Eu.SUM:return"sum";default:return""}}getCells(){return this.elements}createElement(t,i,s,e,n,r,o,h,a,l=!1,c,u=1,d){let f=r;"category"===i&&null!=h&&(f=`category-${h.toString()}`),this.type===Eu.HEADER?f="headerlabel":this.type===Eu.SEPERATORLINE&&(f=null!=r?r:i),this.type===Eu.PARTELEMENT&&("percent"===e&&(t="-"),"category"!==i&&"operation"!==i&&(e="percent",f="")),("-"===t||t===it&&"percent"===e)&&(f="");let v="prefix-first";o&&(v="prefix-second"),s&&(f=`${f} ${s}`);const p=new Fu(i,this.elements.length,t,f,e,n,v,u,a);p.isBarChart=l,p.columnStats=c,p.waterfall=d,this.elements.push(p)}}const ju=.85,Iu=.3,Yu=.25,Bu={".":.28,",":.28,"-":.34,"%":.89," ":.28," ":.28," ":.28,M:.9};function Hu(t,i){var s;let e=0;for(const i of t)e+=null!==(s=Bu[i])&&void 0!==s?s:/[0-9+]/.test(i)?.59:.72;return e*i*1.1}let Vu;function Xu(t,i,s,e){const n=function(){var t,i,s;if(void 0===Vu)try{Vu="undefined"==typeof document?null:null!==(s=null===(i=(t=document.createElement("canvas")).getContext)||void 0===i?void 0:i.call(t,"2d"))&&void 0!==s?s:null}catch(t){Vu=null}return Vu}();if(n){n.font="1px __bn_font_sentinel__";const r=n.font;if(n.font=`${e?"italic ":""}${i}px ${s}`,n.font===r)return Hu(t,i);const o=n.measureText(t).width;if(Number.isFinite(o)&&(o>0||""===t))return o+.15*i}return Hu(t,i)}function Ju(t,i){return Math.max(0,(t-.5)*i)}function qu(t,i,s){const e=void 0!==t.neg,n=void 0!==t.pos||!e,r=(t,e)=>t?i+s+(null!=e?e:0):0;return{sides:(e?1:0)+(n?1:0),neg:r(e,t.neg),pos:r(n,t.pos)}}function Ku(t,i,s,e){const{sides:n,neg:r,pos:o}=qu(i,s,e),h=r+o>0?Math.min(1,t/(r+o)):1,a=Math.max(0,(t-(r+o)*h)/n);return{extent:a,axisX:void 0!==i.neg?r*h+a:0}}function Qu(t,i,s,e){const n=Ju(t,i),{sides:r,neg:o,pos:h}=qu(s,e/2,Iu*i);return o+h+r*function(t,i,s){return Math.min(1*i,t/(2*s))}(n,i,r)<=n+1e-6}function Zu(t,i){const s=.15*t;return{maxBarWidth:t,breakGap:i,overdriveZoneWidth:s,cutWidth:Math.max(0,t-i-s)}}function td(t,i,s,e){var n,r;const o=Ju(t,i),h=Iu*i,{extent:a,axisX:l}=Ku(o,s,Yu*i/2,h),c=Math.min(.3*i,.2*a),u=void 0!==s.neg,d=void 0!==s.pos||!u;let f=u?a:0;const v=Math.max(0,null!==(n=null==e?void 0:e.neg)&&void 0!==n?n:0),p=Math.max(0,null!==(r=null==e?void 0:e.pos)&&void 0!==r?r:0);u&&d&&v+p>0&&(f=(c+(2*a*.85-2*c)*v/(v+p))/.85);const g=d?u?2*a-f:a:0;return{totalWidth:o,neg:Zu(f,c),pos:Zu(g,c),axisX:u?l-a+f:0,labelGap:h}}function id(t,i,s,e,n){var r,o;const h=Ju(t,i),a=Iu*i,{extent:l,axisX:c}=Ku(h,s,e/2,a),u=void 0!==s.neg,d=void 0!==s.pos||!u;let f=u?l:0,v=d?l:0;if(n&&u&&d){const t=2*l,i=Math.max(0,null!==(r=n.neg)&&void 0!==r?r:0),s=Math.max(0,null!==(o=n.pos)&&void 0!==o?o:0);i+s<=t+1e-6?(f=i+(t-i-s)/2,v=t-f):i<l?(f=i,v=t-f):s<l&&(v=s,f=t-v)}return{totalWidth:h,maxPinLength:Math.max(f,v),negPinLength:f,posPinLength:v,axisX:u?c-l+f:0,labelGap:a}}const sd={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},ed="#666666";function nd(t,i){return`pattern-${t}-${i.replace("#","")}`}const rd=({styles:t})=>{const s=t.scaleFactor,e=6*s,n=[{id:nd("pos",t.positive.stroke),stroke:t.positive.stroke,fill:t.positive.fill},{id:nd("neg",t.negative.stroke),stroke:t.negative.stroke,fill:t.negative.fill},{id:nd("neu",t.neutral.stroke),stroke:t.neutral.stroke,fill:t.neutral.fill},...["ac","pp","fc","pl"].map((i=>({id:nd(i,t.scenarios[i].stroke),stroke:t.scenarios[i].stroke,fill:t.scenarios[i].fill})))];return i("defs",null,n.map((t=>i("pattern",{id:t.id,patternUnits:"userSpaceOnUse",width:e,height:e},i("rect",{width:e,height:e,fill:"#ffffff"}),i("line",{x1:"0",y1:e,x2:e,y2:"0",stroke:t.stroke,"stroke-width":1.5*s})))))};function od(t,i,s=1,e,n=0,r=!0,o){const h=(i,s)=>(t>0&&i!==s?"+":"")+i;if(i){const i=(t,i)=>r?ra.number(t,"percent",i,i,1,e):ra.number(100*t,"decimal",i,i,1,e),s=s=>h(i(t,s),i(0,s));let o=Math.min(20,Math.max(0,Math.trunc(n)||0));for(;o>0&&s(o).length>7;)o--;return s(o)}const a=t/s;if(void 0!==o){const t=t=>ra.number(t,"decimal",o,o,1,e);return h(t(a),t(0))}const l=Math.abs(a);let c=1,u="";l>=9995e5?(c=1e9,u="B"):l>=999500?(c=1e6,u="M"):l>=999.5&&(c=1e3,u="K");const d=l>=10*c?0:1;return h(ra.number(a/c,"decimal",d,0,1,e),ra.number(0,"decimal",d,0,1,e))+u}function hd(t){const i=t.slice(0,2).toLowerCase();return["ac","pp","fc","pl"].includes(i)}function ad(t){const i=t.slice(0,2).toLowerCase();return"pp"===i?"pp":"fc"===i?"fc":"pl"===i?"pl":"ac"}function ld(t,i){if(hd(t))return null;const s=new ks(t);if(!s.isValid)return null;const e=ad(s.base),n=ad(s.delta);return{minuend:i.scenarios[e],minuendSlot:e,reference:i.scenarios[n],referenceSlot:n}}const cd=({x:t,height:s,look:e,styles:n})=>{const r=n.scaleFactor,o=Yu*n.emPx,{reference:h,referenceSlot:a}=e;let l;if("outlined"===h.fillpattern){const e=o/2-.5*r;l=[t-e,t+e].map((t=>i("line",{x1:t,y1:0,x2:t,y2:s,stroke:h.stroke,"stroke-width":1*r})))}else l=i("line","hatched"===h.fillpattern?{x1:t,y1:0,x2:t,y2:s,stroke:h.stroke,"stroke-width":o,"stroke-dasharray":""+2*r}:{x1:t,y1:0,x2:t,y2:s,stroke:h.fill,"stroke-width":o});return i("g",{class:`variance-axis axis-${a}`},l)};function ud(t){return void 0!==t.pos||void 0===t.neg}function dd(t,i){return{neg:t.min<0?i:void 0,pos:t.max>0?i:void 0}}function fd(t,i,s,e){return hd(t)?function(t,i){const s=ad(t);return i.scenarios[s]}(t,e):function(t,i,s){const e=t>=0;return i?e?s.positive:s.negative:e?s.negative:s.positive}(i,s,e)}function vd(t,i){const s=t.fillpattern;return"hatched"===s?`url(#${nd(i,t.stroke)})`:"outlined"===s?"transparent":t.fill}function pd(t){return"outlined"===t.fillpattern?{stroke:t.stroke,strokeWidth:1.5}:{stroke:"none",strokeWidth:0}}const gd=t=>{const{value:s,scenario:e,columnStats:n,height:r,isPositiveGood:o,formattedValue:h,measureScale:a,locale:l,decimalDigits:c,columnWidthEm:u=10,labelWidths:d,sideMax:f,styles:v=sd}=t,p=v.scaleFactor,g=v.fontSize,m=h||od(s,!1,a,l,0,!0,c),b=null!=d?d:dd(n,Xu(m,g,v.fontFamily,!1)),y=s>0||0===s&&ud(b),{neg:w=Math.max(0,-n.min),pos:x=Math.max(0,n.max)}=null!=f?f:{},S=td(u,v.emPx,b,{neg:w,pos:x}),{totalWidth:$,axisX:M,labelGap:_}=S,{breakGap:O,overdriveZoneWidth:k,cutWidth:A}=y?S.pos:S.neg,R=Math.abs(s)*v.unitScaling*g,N=R-A>1e-6,L=Math.max(0,(y?x:w)*v.unitScaling*g-A),E=Math.max(0,R-A),T=L>0?E/L*k:0,C=2*p,P=r-2*C,W=C,D=ld(e,v),z=fd(e,s,o,v),U=null==D?void 0:D.minuend.fillpattern,F="hatched"===U||"outlined"===U?Object.assign(Object.assign({},z),{fillpattern:U}):z,G=vd(F,hd(e)?ad(e):o?y?"pos":"neg":y?"neg":"pos"),{stroke:j,strokeWidth:I}=D&&"hatched"===F.fillpattern?{stroke:F.stroke,strokeWidth:1}:pd(F),Y=D?Yu*v.emPx/2:0,B=y?M+Y:M-Y,H=N?A:R,V=N?A+O+T:R,X=y?B+V+_:B-V-_,J=y?"start":"end";return i("svg",{width:$,height:r,class:"cell-bar-chart absolute-variance",style:{overflow:"visible"}},i(rd,{styles:v}),!D&&i("line",{x1:M,y1:0,x2:M,y2:r,stroke:ed,"stroke-width":1*p}),H>0&&i("rect",{x:y?B:B-H,y:W,width:H,height:P,fill:G,stroke:j,"stroke-width":I*p}),N&&T>0&&i("rect",{x:y?B+A+O:B-A-O-T,y:W,width:T,height:P,fill:G,stroke:j,"stroke-width":I*p}),N&&function(t,s,e,n,r){const o=t+s/2,h=.35*s,a=n/3,l=.3*s;let c=`M ${o-h} ${e}`;for(let t=0;t<3;t++)c+=` L ${o-h-l} ${e+a*(t+.5)} L ${o-h} ${e+a*(t+1)}`;let u=`M ${o+h} ${e}`;for(let t=0;t<3;t++)u+=` L ${o+h+l} ${e+a*(t+.5)} L ${o+h} ${e+a*(t+1)}`;return[i("rect",{x:t,y:e-1,width:s,height:n+2,fill:"#ffffff"}),i("path",{d:c,fill:"none",stroke:"#000000","stroke-width":1*r}),i("path",{d:u,fill:"none",stroke:"#000000","stroke-width":1*r})]}(y?B+A:B-A-O,O,W,P,p),D&&i(cd,{x:M,height:r,look:D,styles:v}),i("text",{x:X,y:r/2,dy:"0.35em","text-anchor":J,fill:v.fontColor,"font-size":g,"font-family":v.fontFamily},m))},md=t=>{var s,e;const{value:n,scenario:r,columnStats:o,height:h,isPositiveGood:a,formattedValue:l,measureScale:c,locale:u,percentDigits:d,percentSign:f,columnWidthEm:v=10,labelWidths:p,sideMax:g,styles:m=sd}=t,b=m.scaleFactor,y=m.fontSize,w=10*b,x=100*m.percentageScaling*y,S=l||od(n,!0,c,u,d,f),$=null!=p?p:dd(o,Xu(S,y,m.fontFamily,!0)),{neg:M=Math.max(0,-o.min),pos:_=Math.max(0,o.max)}=null!=g?g:{},{totalWidth:O,negPinLength:k,posPinLength:A,axisX:R,labelGap:N}=id(v,m.emPx,$,w,{neg:M*x,pos:_*x}),L=h/2,E=Math.abs(n)*x,T=n>0||0===n&&ud($),C=T?A:k,P=E-C>1e-6,W=T?1:-1,D=R+W*Math.min(E,C),z=fd(r,n,a,m),U=ld(r,m),F=null!==(s=null==U?void 0:U.minuend)&&void 0!==s?s:m.scenarios.ac,G=R+W*(C+w/2),j=G-W*w,I=(P?G:D+W*(w/2))+W*N;return i("svg",{width:O,height:h,class:"cell-bar-chart relative-variance",style:{overflow:"visible"}},i(rd,{styles:m}),U?i(cd,{x:R,height:h,look:U,styles:m}):i("line",{x1:R,y1:0,x2:R,y2:h,stroke:ed,"stroke-width":1*b}),i("line",{x1:R,y1:L,x2:P?j:D,y2:L,stroke:z.fill,"stroke-width":3*b}),P?i("polygon",{points:`${G},${L} ${j},${L-w/2} ${j},${L+w/2}`,fill:z.fill}):i("rect",{x:D-w/2,y:L-w/2,width:w,height:w,fill:"outlined"===F.fillpattern?"#ffffff":vd(F,null!==(e=null==U?void 0:U.minuendSlot)&&void 0!==e?e:"ac"),stroke:F.stroke,"stroke-width":1*b}),i("text",{x:I,y:h/2,dy:"0.35em","text-anchor":T?"start":"end",fill:m.fontColor,"font-size":y,"font-style":"italic","font-family":m.fontFamily},S))},bd=t=>{const{value:s,columnStats:e,isRelative:n,styles:r=sd}=t;return null==s||isNaN(s)||!e||0===e.absMax?i("span",{class:"bar-chart-empty",style:{color:r.fontColor,fontStyle:"italic"}},"-"):i(n?md:gd,Object.assign({},t))},yd=t=>{const{value:s,scenario:e,height:n,measureScale:r,locale:o,decimalDigits:h,columnWidthEm:a=10,styles:l=sd,waterfall:c}=t,u=l.scaleFactor,d=l.fontSize,f=c.max-c.min;if(null==s||isNaN(s)||f<=0)return i("span",{class:"bar-chart-empty",style:{color:l.fontColor,fontStyle:"italic"}},"-");const{totalWidth:v,labelAreaWidth:p,barAreaWidth:g,labelGap:m}=function(t,i){const s=Ju(t,i),e=Math.min(2.85*i,s/4);return{totalWidth:s,labelAreaWidth:e,barAreaWidth:s-2*e,labelGap:Iu*i}}(a,l.emPx),b=g/f,y=t=>p+(t-c.min)*b,w=2*u,x=n-2*w,S=w,$=y(0),M=y(c.start),_=y(c.end),O=Math.min(M,_),k=Math.abs(_-M),A=fd(e,s,!1,l),R=vd(A,ad(e)),{stroke:N,strokeWidth:L}=pd(A),E=od(s,"partof"===c.kind,r,o,0,!0,h).replace(/^\+/,""),T=_<M,C=T?O-m:O+k+m,P=T?"end":"start";return i("svg",{width:v,height:n,class:"cell-bar-chart waterfall-bar",style:{overflow:"visible"}},i(rd,{styles:l}),i("line",{x1:$,y1:0,x2:$,y2:n,stroke:ed,"stroke-width":1*u}),void 0!==c.parentStart&&void 0!==c.parentEnd&&i("line",{x1:y(c.parentStart),y1:0,x2:y(c.parentStart),y2:n,stroke:ed,"stroke-width":1*u,"stroke-dasharray":`${2*u},${2*u}`}),void 0!==c.parentStart&&void 0!==c.parentEnd&&i("line",{x1:y(c.parentEnd),y1:0,x2:y(c.parentEnd),y2:n,stroke:ed,"stroke-width":1*u,"stroke-dasharray":`${2*u},${2*u}`}),k>0&&i("rect",{x:O,y:S,width:k,height:x,fill:R,stroke:N,"stroke-width":L*u}),i("text",{x:C,y:n/2,dy:"0.35em","text-anchor":P,fill:l.fontColor,"font-size":d,"font-family":l.fontFamily},E))},wd=`IFNULL(${ea.ROWGROUP}, '')`;class xd{constructor(t){this.groups=[ea.CATEGORY,ea.CATEGORYINDEX],Nu.OPT!==t.type&&Nu.OPTNOTOTAL!==t.type||this.groups.unshift(ea.OPERATION),t.grouped&&(this.groups.push(ea.ROWGROUP),this.groups.push(ea.ROWGROUPINDEX))}toString(){return this.groups.map((t=>t===ea.ROWGROUP?wd:t)).toString()}select(){return this.groups.map((t=>t===ea.ROWGROUP?`${wd} as ${t}`:t)).toString()}noCategory(){return this.groups.filter((t=>t!==ea.CATEGORY))}toArray(){return this.groups}}class Sd{constructor(t,i){this.hasPartOf=!1,this.params=[],this.sortSelect="",this.hasBlankRowGroup=!1,this.config=t,this.i18n=i}execute(t,i){var s;this.db=t,this.fromExpr=i;for(const t of[...this.config.scenarios,...this.config.categoryThereOf.keys()])if(!Lt.test(t))throw new Error(`invalid identifier "${t}"`);const e=[],n=[],r=[],o=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),h=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),a=this.getRelativeScenarios(),l=this.config.attributes.map((t=>this.translateAttributeSQL(t))).toString(),c=new xd(this.config),u=this.config.interval===Cu?this.config.sortOrder:{hierarchy:this.config.sortOrder.hierarchy.map((t=>{var i,s;return null!==(s=null===(i=Et(t))||void 0===i?void 0:i.column)&&void 0!==s?s:t})),direction:this.config.sortOrder.direction};let d=["",""];u.hierarchy.length>0&&(d=this.createOrderString(u)),this.hasPartOf=this.checkConfigForPartOf();const{hierarchy:f,direction:v}=u,p=f.filter((t=>t===ea.ROWGROUP||t===ea.ROWGROUPINDEX||t.toUpperCase()in Tt)),g=p.filter((t=>t.toUpperCase()in Tt)).map((t=>`, SUM(${t} * transformOperator(operation)) as ${t}`)).join(""),m=p.length>0?p.map((t=>`${t} ${v}`)).toString():`${ea.ROWGROUPINDEX} asc`,b=t.exec(`SELECT COUNT(DISTINCT ${ea.CATEGORY}) as ${ea.TOTALROWCOUNT} ${this.config.grouped?`, ${wd} as ${ea.ROWGROUP}, FIRST(${ea.ROWGROUPINDEX}) as ${ea.ROWGROUPINDEX}${g}`:""}\n FROM ${i} ${this.config.grouped?`GROUP BY ${wd} ORDER BY ${m}`:""}`);return 0===b.length||1===b.length&&0===(null!==(s=b[0][ea.TOTALROWCOUNT])&&void 0!==s?s:0)&&!this.config.grouped?[]:(this.hasBlankRowGroup=this.config.grouped&&b.some((t=>""===t.rowGroup)),b.forEach((t=>{const i=this.config.grouped?""===t.rowGroup?`WHERE (${ea.ROWGROUP} IS NULL OR ${ea.ROWGROUP} = '')`:`WHERE ${ea.ROWGROUP} = ${this.bind(t.rowGroup)}`:"";let s="";this.config.limit&&(s=`LIMIT ${this.config.limit}`),this.createGroupHeaderRow(t,e),this.createDataRow(e,t,c,o,l,i,d,s),this.createRestRow(t,e,c,o,i,d),this.createGroupSumRow(e,n,t,h,i,d)})),this.createTotalSumRow(e,n,h),e.forEach((t=>r.push(this.exec(t)))),this.detectNaNCells(this.config.scenarios,r),this.createThereOfDrillRows(o,l,d,r),this.createPartOfDrillRows(o,d,n,r),this.createIntervalColumns(r),this.createThereOfDrillColumns(this.config.categoryThereOf,r),this.calculateColumnGroupRest(r,this.config.categoryThereOf),this.calculateRelativeVariances(r,a),r)}detectNaNCells(t,i){i.forEach((i=>{i.map((i=>(t.forEach((t=>{const s=new ks(t);!0===s.isValid?0!==i[s.base+"_cnt"]&&0!==i[s.delta+"_cnt"]||(i[t]=Number.NaN):0===i[t+"_cnt"]&&(i[t]=Number.NaN)})),i)))}))}createPartOfDrillRows(t,i,s,e){if(null==this.config.partOf||0===this.config.partOf.length||this.config.type===Nu.LIST)return;const n=this.createPartOfQuery(t,i);let r=[];const o=this.db,h=this.params;n.forEach((t=>{r.push(...this.exec(t))}));const a=this.exctractScenarioNames(t),l=[];s.forEach((function(t){l.push(...o.exec(t,h))}));const c=new Map;l.forEach((t=>c.set(t[ea.ROWGROUP],t))),r=this.reduceResDrillByCategoryGroups(r,a),r.forEach((function(t){a.forEach((i=>{try{t[i]=t[i]/c.get(t[ea.ROWGROUP])[i]}catch(s){console.error("DataQuery: partOf drill row calculation failed",i,s),t[i]=Number.NaN}}))})),this.injectDrillRowsToResultRows(r,e)}createRestRow(t,i,s,e,n,r){var o;if(t.totalRowCnt-this.config.limit>0&&0!==this.config.limit){const h=this.exctractScenarioNames(e).map((t=>`SUM(${t}) as ${t}`)).join(", "),a=Nu.OPT===this.config.type||Nu.OPTNOTOTAL===this.config.type?", CASE WHEN MAX(transformOperator(operation)) = -1 THEN '-' ELSE '+' END as restOperation":"";i.push(`SELECT ${ea.ROWNR}, 1 as ${ea.ROWGROUPINDEX} , 'ENTRY' as ${ea.TYPE}, 'NO_GROUP' as ${ea.ROWGROUP}, ${this.bind(String(null!==(o=t.rowGroup)&&void 0!==o?o:""))} as restRowGroup, 'REST' as ${ea.CATEGORY}${a} ${h.length>0?", "+h:""} FROM (SELECT ROWNUM() AS ${ea.ROWNR}, ${i.length} as ${ea.ROWGROUPINDEX} , 'ENTRY' as ${ea.TYPE}, ${this.bind(String(t.rowGroup||"NO_GROUP"))} as ${ea.ROWGROUP}, ${s.select()} ${e.length>0?",".concat(e):""}${this.sortSelect} FROM ${this.fromExpr} ${n} GROUP BY ${s} ORDER BY ${r[0]}) t WHERE t.rowNr > ${this.config.limit}`)}}createDataRow(t,i,s,e,n,r,o,h){t.push(`SELECT ROWNUM() AS ${ea.ROWNR},\n ${t.length} as ${ea.ROWGROUPINDEX},\n 'ENTRY' as ${ea.TYPE},\n ${this.bind(String(i.rowGroup||"NO_GROUP"))} as ${ea.ROWGROUP},\n '${ea.CATEGORYINDEX}',\n ${s.select()} ${e.length>0?",".concat(e):""} ${n.length>0?",".concat(n):""}${this.sortSelect}\n FROM ${this.fromExpr} ${r}\n GROUP BY ${s}\n ORDER BY ${o[0]} ${h}`)}createGroupHeaderRow(t,i){if(!0===this.config.grouped&&(this.config.showGroupTitle||!this.hasGroupSum())){const s=this.bind(String(t.rowGroup)),e=""===t.rowGroup?this.bind("-"):s;i.push(`SELECT ROWNUM() AS ${ea.ROWNR},\n ${i.length} as ${ea.ROWGROUPINDEX},\n 'GROUPHEAD' as ${ea.TYPE},\n ${s} as ${ea.ROWGROUP} ${this.config.showGroupTitle?`,${e} as ${ea.CATEGORY}`:""}\n FROM ${this.fromExpr}\n GROUP BY '1'`)}}hasGroupSum(){return Nu.SUM===this.config.type||Nu.SUMNOTOTAL===this.config.type||Nu.OPT===this.config.type||Nu.OPTNOTOTAL===this.config.type}createGroupSumRow(t,i,s,e,n,r){if(!0===this.config.grouped&&this.hasGroupSum()){const o=this.bind(String(s.rowGroup));t.push(`SELECT ${t.length} as ${ea.ROWGROUPINDEX},\n '=' as ${ea.OPERATION},\n ${o} as ${ea.ROWGROUP},\n ROWNUM() AS ${ea.ROWNR},\n 'GROUP_SUM' as ${ea.TYPE} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr} ${n}\n ORDER BY ${r[0]} `),i.push(`SELECT ${t.length} as ${ea.ROWGROUPINDEX},\n '=' as ${ea.OPERATION},\n ${o} as ${ea.ROWGROUP},\n ROWNUM() AS ${ea.ROWNR},\n 'GROUP_SUM' as ${ea.TYPE} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr} ${n}\n ORDER BY ${r[0]} `)}}createTotalSumRow(t,i,s){var e;if(Nu.SUM===this.config.type||Nu.OPT===this.config.type){const i=(null===(e=this.config.title)||void 0===e?void 0:e.trim())||"SUM_TOTAL",n=this.hasPartOf&&!1===this.config.grouped&&"SUM_TOTAL"!==i?`${this.i18n.get("SUM_TOTAL")||"SUM_TOTAL"} ${i}`:i;t.push(`SELECT ${t.length} as ${ea.ROWGROUPINDEX},\n ${this.bind(n)} as ${ea.ROWGROUP},\n '=' as ${ea.OPERATION},\n 'SUM' as ${ea.TYPE} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr} `)}i.push(`SELECT ${t.length} as ${ea.ROWGROUPINDEX},\n 'SUM_TOTAL' as ${ea.ROWGROUP},\n '=' as ${ea.OPERATION},\n 'SUM' as ${ea.TYPE} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr} `)}reduceResDrillByCategoryGroups(t,i){const s=new Map;return t.forEach((function(t){const e=t.rowNr+t.rowGroup+t.type+t.category;if(s.has(e)){const n=s.get(e);i.forEach((i=>{try{n[i]+=t[i]}catch(t){console.error("DataQuery: drill row aggregation failed",i,t)}}))}else s.set(e,t)})),[...s.values()]}injectDrillRowsToResultRows(t,i){const s=new Map;if(!0===this.config.grouped)t.forEach((function(t){i.forEach((function(i){const e=i.findIndex((i=>i.category===t.category&&i.rowGroup===t.rowGroup));if(e>=0){if(s.has(`${t.category}_${t.rowGroup}`)){const i=s.get(`${t.category}_${t.rowGroup}`)||0;s.set(`${t.category}_${t.rowGroup}`,i+1)}else s.set(`${t.category}_${t.rowGroup}`,1);t[ea.ROWNR]=s.get(`${t.category}_${t.rowGroup}`),i.splice(e+t[ea.ROWNR],0,t)}}))}));else{const e=this.findDuplicateSubCategories(t);t.forEach((function(t){i.forEach((function(i){const n=i.findIndex((i=>null!=i.category&&i.category===t.category));if(n>=0){if(s.has(`${t.category}`)){const i=s.get(`${t.category}`)||0;s.set(`${t.category}`,i+1)}else s.set(`${t.category}`,1);null!=t.rowGroup&&""!==t.rowGroup&&e.includes(`${t.category}##${t.subCategory}`)&&(t.rawSubCategory=t.subCategory,t.subCategory=`${t.subCategory} (${t.rowGroup})`),i.splice(n+t[ea.ROWNR],0,t)}}))}))}}createThereOfDrillRows(t,i,s,e){if(void 0===this.config.thereOf||0===this.config.thereOf.length)return;const n=[],r=[];this.config.thereOf.forEach((e=>{let r=!0,o="1 <> 1 OR ( ";null!=e.category&&0!==e.category.length&&e.category.trim()&&(o+=` ${ea.CATEGORY} = ${this.bind(e.category)}`,r=!1),null!=e.rowGroup&&0!==e.rowGroup.length&&e.rowGroup.trim()&&(o+=` ${r?"":"AND"} ${ea.ROWGROUP} = ${this.bind(e.rowGroup)}`,r=!1),null!=e.subCategory&&0!==e.subCategory.length&&e.subCategory.trim()&&(o+=` ${r?"":"AND"} ${ea.SUBCATEGORY} = ${this.bind(e.subCategory)}`),o+=")",n.push(`SELECT ROWNUM() AS ${ea.ROWNR},\n null as operation,\n 'DRILLELEMENT' as ${ea.TYPE},\n ${ea.CATEGORY},\n ${ea.SUBCATEGORY},\n ${this.drillRowGroup} as ${ea.ROWGROUP},\n ${t} ${i.length>0?",".concat(i):""}${this.sortSelect}\n FROM ${this.fromExpr}\n WHERE ${o}\n GROUP BY ${this.drillRowGroup}, ${ea.CATEGORY}, ${ea.SUBCATEGORY}\n ORDER BY ${s[1]}`)})),n.forEach((t=>{r.push(...this.exec(t))})),this.injectDrillRowsToResultRows(r,e)}calculateRelativeVariances(t,i){t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[ea.TYPE]&&i.forEach(((i,s)=>{var e;t[s]=null!==(e=st(t[s],t[i]))&&void 0!==e?e:it}))}))}))}calculateColumnGroupRest(t,i){if(null==i||0===i.size)return;const s=new Map,e=new Map;i.forEach(((t,i)=>{const n=t,r=[];for(const t of n)r.push(`${i}##${t.name}`);s.set(i,r),e.set(`${i}##REST`,!1)})),t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[ea.TYPE]&&s.forEach(((i,s)=>{let n=0;i.forEach((i=>{void 0!==t[i]&&(n+=t[i])})),t[`${s}##REST`]=t[s]-n,0!==t[`${s}##REST`]&&e.set(`${s}##REST`,!0)}))}))}));const n=Array.from(e.entries()).filter((([t,i])=>!i)).map((([t])=>t));t.forEach((t=>{t.forEach((t=>{for(const i of n)delete t[i]}))}))}createIntervalColumns(t){var i,s,e,n,r;if(this.config.interval===Tu||this.config.categoryThereOf.size>0||0===this.config.scenarios.length)return;const o="##",h=`(SELECT *, ${Pu(this.config.interval)} as __interval FROM ${this.fromExpr}) as p`,a=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),l=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),c=[...new Set(this.exctractScenarioNames(a))],u=this.getRelativeScenarios(),d=new xd(this.config),f=Nu.OPT===this.config.type||Nu.OPTNOTOTAL===this.config.type,v=this.config.grouped&&(Nu.SUM===this.config.type||Nu.SUMNOTOTAL===this.config.type||Nu.OPT===this.config.type||Nu.OPTNOTOTAL===this.config.type),p=this.checkConfigForPartOf()&&this.config.type!==Nu.LIST,g=t=>this.exec(t),m=t=>(this.config.scenarios.forEach((i=>{const s=new ks(i);!0===s.isValid?0!==t[s.base+"_cnt"]&&0!==t[s.delta+"_cnt"]||(t[i]=Number.NaN):0===t[i+"_cnt"]&&(t[i]=Number.NaN)})),u.forEach(((i,s)=>{var e;t[s]=null!==(e=st(t[s],t[i]))&&void 0!==e?e:it})),t),b=(t,i,s)=>{for(const e of this.config.scenarios)t[e+o+s]=i[e]},y=g(`SELECT ${d.select()}, __interval ${a.length>0?",".concat(a):""}\n FROM ${h}\n GROUP BY ${d}, __interval`),w=t=>"ENTRY"===t.type&&null!=t.restRowGroup;if(this.config.limit>0)for(let e=0;e<t.length;e++){const n=t[e].find(w);if(!n)continue;let r;for(let i=e-1;i>=0&&!r;i--){const s=t[i].filter((t=>"ENTRY"===t.type&&!w(t)));s.length>0&&(r=s)}if(!r)continue;const o=new Set(r.map((t=>t.category))),h=r[0].rowGroup,a=new Map;for(const t of y){if(this.config.grouped&&t.rowGroup!==h)continue;if(o.has(t.category))continue;const e=Wu(t.__interval);let n=a.get(e);n||(n={},a.set(e,n));for(const e of c)n[e]=(null!==(i=n[e])&&void 0!==i?i:0)+(null!==(s=t[e])&&void 0!==s?s:0)}a.forEach(((t,i)=>{b(n,m(t),i)}))}for(const i of y){const s=Wu(i.__interval);m(i);for(const e of t)for(const t of e)"ENTRY"!==t.type||w(t)||t.category!==i.category||this.config.grouped&&t.rowGroup!==i.rowGroup||f&&t.operation!==i.operation||b(t,i,s)}const x=v||p&&this.config.grouped?g(`SELECT ${wd} as ${ea.ROWGROUP}, __interval ${l.length>0?",".concat(l):""}\n FROM ${h}\n GROUP BY ${wd}, __interval`):[],S=new Map;if(x.forEach((t=>S.set(`${t.rowGroup}${o}${Wu(t.__interval)}`,t))),v)for(const i of x){const s=Wu(i.__interval),e=m(Object.assign({},i));for(const n of t)for(const t of n)"GROUP_SUM"===t.type&&t.rowGroup===i.rowGroup&&b(t,e,s)}const $=Nu.SUM===this.config.type||Nu.OPT===this.config.type,M=$||p&&!this.config.grouped?g(`SELECT __interval ${l.length>0?",".concat(l):""}\n FROM ${h}\n GROUP BY __interval`):[],_=new Map;if(M.forEach((t=>_.set(Wu(t.__interval),t))),$)for(const i of M){const s=Wu(i.__interval),e=m(Object.assign({},i));for(const i of t)for(const t of i)"SUM"===t.type&&b(t,e,s)}if(null!=this.config.thereOf&&this.config.thereOf.length>0){const i=[];this.config.thereOf.forEach((t=>{i.push(...g(`SELECT ${this.drillRowGroup} as ${ea.ROWGROUP}, ${ea.CATEGORY}, ${ea.SUBCATEGORY}, __interval ${a.length>0?",".concat(a):""}\n FROM ${h}\n WHERE ${this.createThereOfWhereClause(t)}\n GROUP BY ${this.drillRowGroup}, ${ea.CATEGORY}, ${ea.SUBCATEGORY}, __interval`))}));for(const s of i){const i=Wu(s.__interval);m(s);for(const e of t)for(const t of e)"DRILLELEMENT"===t.type&&t.category===s.category&&t.rowGroup===s.rowGroup&&(t.subCategory!==s.subCategory&&t.subCategory!==`${s.subCategory} (${s.rowGroup})`||b(t,s,i))}}if(p){let i="1 <> 1 ";null===(e=this.config.partOf)||void 0===e||e.forEach((t=>{i+=`OR (${ea.CATEGORY} = ${this.bind(t.category)}`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(i+=`and ${ea.ROWGROUP} = ${this.bind(t.rowGroup)}`),i+=")"}));const s=g(`SELECT ${ea.CATEGORY}, ${this.config.grouped?`${ea.ROWGROUP}`:`'SUM_TOTAL' as ${ea.ROWGROUP}`}, __interval ${a.length>0?",".concat(a):""}\n FROM ${h}\n WHERE ${i}\n GROUP BY ${ea.ROWGROUP}, ${ea.CATEGORY}, __interval`),l=new Map;for(const t of s){const i=`${t.rowGroup}${o}${t.category}${o}${Wu(t.__interval)}`,s=l.get(i);if(s)for(const i of c)s[i]=(null!==(n=s[i])&&void 0!==n?n:0)+(null!==(r=t[i])&&void 0!==r?r:0);else l.set(i,t)}l.forEach((i=>{const s=Wu(i.__interval),e=this.config.grouped?S.get(`${i.rowGroup}${o}${s}`):_.get(s);for(const t of c)i[t]=i[t]/(e?e[t]:Number.NaN);m(i);for(const e of t)for(const t of e)"PARTELEMENT"===t.type&&t.category===i.category&&t.rowGroup===i.rowGroup&&b(t,i,s)}))}}createThereOfWhereClause(t){let i=!0,s="1 <> 1 OR ( ";return null!=t.category&&0!==t.category.length&&t.category.trim()&&(s+=` ${ea.CATEGORY} = ${this.bind(t.category)}`,i=!1),null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(s+=` ${i?"":"AND"} ${ea.ROWGROUP} = ${this.bind(t.rowGroup)}`,i=!1),null!=t.subCategory&&0!==t.subCategory.length&&t.subCategory.trim()&&(s+=` ${i?"":"AND"} ${ea.SUBCATEGORY} = ${this.bind(t.subCategory)}`),s+")"}getRelativeScenarios(){const t=new Map;return this.config.scenarios.forEach((i=>{const s=this.createRelativeScenario(i);null!=s&&t.set(s.key,s.value)})),t}translateScenarioSQL(t,i,s){const e=new ks(t);if(Nu.OPT===s||Nu.OPTNOTOTAL===s){if(e.isValid){const s=i?" * transformOperator(operation)":"",n=i?`SUM((${e.base} - ${e.delta})${s}) as ${t}`:`SUM(${e.base} - ${e.delta}) as ${t}`;return"dr"===e.type?`${n}, SUM(${e.delta}${s}) as dr_${e.delta}`:n}return i?`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`:`SUM(${t}) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}return e.isValid?"dr"===e.type?`SUM((${e.base} * transformOperator(operation)) - (${e.delta} * transformOperator(operation))) as ${t}, SUM(${e.delta} * transformOperator(operation)) as dr_${e.delta}`:`SUM((${e.base} * transformOperator(operation))- (${e.delta} * transformOperator(operation))) as ${t}`:`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}translateAttributeSQL(t){const i=`[${t.arg}]`,s=/^(ac|pp|fc|pl)[1-4]$/.test(t.arg)&&this.config.type!==Nu.OPT&&this.config.type!==Nu.OPTNOTOTAL;switch(t.fn){case"set":return`SETAGG(${i}) as ${t.alias}`;case"first":return`FIRST(${i}) as ${t.alias}`;case"last":return`LAST(${i}) as ${t.alias}`;case"min":return`MIN(${i}) as ${t.alias}`;case"max":return`MAX(${i}) as ${t.alias}`;case"avg":return s?`AVG(${i} * transformOperator(operation)) as ${t.alias}`:`AVG(${i}) as ${t.alias}`;case"sum":return s?`SUM(${i} * transformOperator(operation)) as ${t.alias}`:`SUM(${i}) as ${t.alias}`;case"lit":{const i=t.arg;return`${this.bind(""===i||Number.isNaN(Number(i))?i:Number(i))} as ${t.alias}`}}}get drillRowGroup(){return this.config.grouped?wd:ea.ROWGROUP}exec(t){const i=this.db.exec(t,this.params);return this.config.grouped&&i.forEach((t=>t.rowGroup=null==t.rowGroup?"":String(t.rowGroup))),i}bind(t){return`$${this.params.push(t)-1} `}createOrderString(t){const i=Lu.ASC===t.direction?Lu.DESC:Lu.ASC,s=new Map;t.hierarchy.forEach(((t,i)=>{const e=Et(t),n=null==e?void 0:e.bucket;("variance"===(null==e?void 0:e.kind)||"scenario"===(null==e?void 0:e.kind)&&void 0!==n)&&s.set(i,this.translateSortKeySQL(e,n,i))})),this.sortSelect=[...s.values()].map((t=>`, ${t}`)).join("");const e=t.hierarchy.some((t=>{var i;const s=null===(i=Et(t))||void 0===i?void 0:i.kind;return"scenario"===s||"variance"===s}));e&&(this.sortSelect+=`, CASE WHEN ${ea.CATEGORY} = 'REST' THEN 1 ELSE 0 END as __sortrest`);const n=(t,i,e)=>s.has(i)?`__sortnull${i} asc, __sort${i} ${e}`:`${t} ${e}`,r=t.hierarchy.map(((i,s)=>n(i,s,t.direction))).toString(),o=t.hierarchy.map(((t,s)=>n(t,s,i))).toString();return e?[`__sortrest asc, ${r}`,`__sortrest desc, ${o}`]:[r,o]}translateSortKeySQL(t,i,s){const e=Nu.OPT===this.config.type||Nu.OPTNOTOTAL===this.config.type?"":" * transformOperator(operation)",n=void 0===i?"":`TRIM(CAST(${Pu(Cu)} AS STRING)) = ${this.bind(i)}`,r=t=>`SUM(${n?`(CASE WHEN ${n} THEN ${t} ELSE 0 END)`:t}${e})`,o=t=>`SUM(CASE WHEN ${n?`${n} AND `:""}${t} IS NOT NULL THEN 1 ELSE 0 END) = 0`;if("scenario"===t.kind)return`${r(t.column)} as __sort${s}, CASE WHEN ${o(t.column)} THEN 1 ELSE 0 END as __sortnull${s}`;const h=`(${r(t.base)} - ${r(t.delta)})`;let a=h,l=`${o(t.base)} OR ${o(t.delta)}`;if("dr"===t.type){const i=r(t.delta),s=`ABS(${i}) <= ABS(${h}) * 0.000000001`;a=`CASE WHEN ${s} THEN 0 ELSE ${h} / ABS(${i}) END`,l+=` OR ${s}`}return`${a} as __sort${s}, CASE WHEN ${l} THEN 1 ELSE 0 END as __sortnull${s}`}createRelativeScenario(t){const i=new ks(t);return i.isValid&&"dr"===i.type?{key:`${t}`,value:`dr_${i.delta}`}:null}exctractScenarioNames(t){const i=[];return t.split(",").forEach((t=>t.length>=2?i.push(t.split("as")[1].trim()):null)),i}findDuplicateSubCategories(t){const i=t.map((t=>({count:1,subCategory:`${t.category}##${t.subCategory}`}))).reduce(((t,i)=>(t[i.subCategory]=(t[i.subCategory]||0)+i.count,t)),{});return Object.keys(i).filter((t=>i[t]>1))}createPartOfQuery(t,i){var s;const e=[];let n="1 <> 1 ",r=` ${this.drillRowGroup} as ${ea.ROWGROUP}`,o="ROWNUM()";return null===(s=this.config.partOf)||void 0===s||s.forEach((t=>{n+=`OR (${ea.CATEGORY} = ${this.bind(t.category)}`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(n+=`and ${ea.ROWGROUP} = ${this.bind(t.rowGroup)}`),!1===this.config.grouped&&(r=` 'SUM_TOTAL' as ${ea.ROWGROUP} `,o="1"),n+=")"})),e.push(`SELECT ${o} AS ${ea.ROWNR},\n 'PARTELEMENT' as ${ea.TYPE},\n ${ea.CATEGORY},\n ${r},\n ${t}${this.sortSelect}\n FROM ${this.fromExpr}\n WHERE ${n}\n GROUP BY ${this.drillRowGroup}, ${ea.CATEGORY}, ${ea.TYPE}\n ORDER BY ${i[1]}`),e}checkConfigForPartOf(){return null!=this.config.partOf&&0!==this.config.partOf.length}createThereOfDrillColumns(t,i){if(null==t||0===t.size)return;const s=[],e=[],n=this.fromExpr;t.forEach(((t,i)=>{let e="1 <> 1 ";t.forEach((t=>{e+=` or columnGroup = ${this.bind(String(t.name))} `})),s.push(`SELECT 'ENTRY' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, columnGroup, scenario`),s.push(`SELECT 'ENTRY' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, scenario`),s.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, columnGroup, scenario`),s.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, columnGroup, scenario`),s.push(`SELECT 'SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, columnGroup, columnSubGroup, scenario`)}));for(const t of s)e.push(...this.db.exec(t,this.params));this.injectDrillColumnsToResultRows(e,i)}injectDrillColumnsToResultRows(t,i){const s="##";for(const e of t)for(const t of i)for(const i of t)if(i.type===e.rowlevel)if("ENTRY"===e.rowlevel)"COLUMNGROUP"===e.columnlevel&&i.category===e.category?i[e.scenario+s+e.columnGroup]=e.val:"SUBGROUP"===e.columnlevel&&i.category===e.category&&(i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val);else if("DRILLELEMENT"===e.rowlevel){if(!this.config.grouped&&i.rowGroup!==e.rowGroup)continue;"COLUMNGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory?i[e.scenario+s+e.columnGroup]=e.val:"SUBGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory?i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val:"COLUMNGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===`${e.subCategory} (${e.rowGroup})`?i[e.scenario+s+e.columnGroup]=e.val:"SUBGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===`${e.subCategory} (${e.rowGroup})`&&(i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val)}else("SUM"===e.rowlevel||"GROUP_SUM"===e.rowlevel)&&("COLUMNGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory&&(i[e.scenario+s+e.columnGroup]=e.val),"SUBGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory&&(i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val))}}class $d{constructor(){this.geometry=new Map}set(t,i,s){let e=this.geometry.get(t);e||(e=new Map,this.geometry.set(t,e)),e.set(i,s)}get(t,i){var s;return null===(s=this.geometry.get(t))||void 0===s?void 0:s.get(i)}}function Md(t,i,s){const e=t[i];if(null==e)return null;const n=Number(e);return isNaN(n)?null:s!==Nu.OPT&&s!==Nu.OPTNOTOTAL||t[ea.TYPE]!==Eu.ENTRY||"-"!==t[ea.OPERATION]?n:-n}class _d{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)?Ls(this.ruleSet.getScenarioColorIndex(t))+t.slice(2):null}getNormalizedHeader(){return this.normalizedHeader}createHeader(t,i,s,e,n,r,o=[]){const h=[];this.attributesByAlias=new Map(o.map((t=>[t.alias,t]))),this.normalizedHeader=this.normalizeHeader(t,i,o);const a=this.normalizedHeader.some((t=>void 0!==t.bucket));a&&h.push(this.createIntervalBandRow());const l=new Gu(a?1:0,0,Eu.HEADER),c=new Gu(a?2:1,0,Eu.SEPERATORLINE);for(const t of this.normalizedHeader){const i=this.attributesByAlias.get(t.name);l.createElement(i?s.get(i.label)||i.label:ra.translateScenarioLabel(t.name,s),t.type,this.createColumnType(t),null,this.setHeaderPrefix(t,s,e,n,r),null,null,null,null),c.createElement(null,t.type,this.createColumnType(t),null,null,this.underlineClass(t.type),null,null,null)}return h.push(l),h.push(c),h}createIntervalBandRow(){const t=new Gu(0,0,Eu.HEADER);let i=0;for(;i<this.normalizedHeader.length;){const s=this.normalizedHeader[i];if(void 0===s.bucket){t.createElement(null,s.type,"filler",null,null,null,null,null,null),i+=1;continue}let e=1;for(;i+e<this.normalizedHeader.length&&this.normalizedHeader[i+e].bucket===s.bucket;)e+=1;t.createElement(s.bucketLabel,s.type,"intervalGroup",null,null,null,null,null,null,!1,void 0,e),i+=e}return t}setHeaderPrefix(t,i,s,e,n){let r="";return"category"===t.name&&n&&(0===s.prefix.length&&0===e.length||(r=ra.translateScenarioLabel("in",i)+" "+s.prefix+e)),t.order&&(r+=ra.translateScenarioLabel("ORDER_"+t.order,i)),r}normalizeHeader(t,i,s){let e=[{name:ea.CATEGORY,group:ea.CATEGORY,type:ea.CATEGORY,order:void 0}];Nu.OPT!==t&&Nu.OPTNOTOTAL!==t||(e=[{name:ea.OPERATION,group:ea.OPERATION,type:ea.OPERATION,order:void 0},{name:ea.CATEGORY,group:ea.CATEGORY,type:ea.CATEGORY,order:void 0}]);const n=s.map((t=>({name:t.alias,group:t.alias,type:t.alias,order:void 0})));return[...e,...n,...i]}createBodyRows(t,i,s,e){var n;const r=[];let o=-1;const h=new Sd(t,i);var a;this.dateBuckets=(a=t.interval)!==Tu&&a!==Cu,this.unsignedEntries=Nu.OPT===t.type||Nu.OPTNOTOTAL===t.type;const l=h.execute(s,e);this.hasBlankRowGroup=h.hasBlankRowGroup;const c=this.calculateColumnStatistics(l,t.barColumns,t.interval!==Tu),u=(null!==(n=t.barColumns)&&void 0!==n?n:[]).filter((t=>t.toUpperCase().trim()in Tt)),d=u.length>0&&t.interval===Tu&&0===t.categoryThereOf.size&&function(t){for(const i of t)for(const t of i){const i=t[ea.TYPE];if(i===Eu.SUM||i===Eu.GROUPSUM||i===Eu.DRILLELEMENT||i===Eu.PARTELEMENT)return!0}return!1}(l)?function(t,i,s){const e=new $d;for(const n of i){let i,r=0,o=0;const h=[],a=(t,i)=>{h.push(i),e.set(t,n,i)};for(const e of t)for(const t of e){const e=t[ea.TYPE];if(e===Eu.GROUPHEAD){r=0,i=void 0;continue}const h=Md(t,n,s);if(e===Eu.ENTRY){if(null===h){i=void 0;continue}a(t,{start:r,end:r+h,min:0,max:0,kind:"cascade"}),i={start:r,end:r+h},o=i.start,r+=h}else if(e===Eu.SUM||e===Eu.GROUPSUM){if(null===h){i=void 0;continue}a(t,{start:0,end:h,min:0,max:0,kind:"anchor"}),i={start:0,end:h},o=0,r=e===Eu.GROUPSUM?0:h}else if(e===Eu.DRILLELEMENT){if(null===h||void 0===i)continue;const s=o+(Math.sign(i.end-i.start)||1)*Math.abs(h);a(t,{start:o,end:s,min:0,max:0,kind:"thereof",parentStart:i.start,parentEnd:i.end}),o=s}else if(e===Eu.PARTELEMENT){if(null===h||void 0===i)continue;const s=o+h*(i.end-i.start);a(t,{start:o,end:s,min:0,max:0,kind:"partof",parentStart:i.start,parentEnd:i.end}),o=s}}let l=0,c=0;for(const t of h)l=Math.min(l,t.start,t.end),c=Math.max(c,t.start,t.end);for(const t of h)t.min=l,t.max=c}return e}(l,u,t.type):void 0;for(const s of l)o+=1,r.push(...this.createRow(t.i18n,i,t.scenariosUnitType,s,o,-1,t.categoryWidth,t.measureScale,t.barColumns,c,d));return r}calculateColumnStatistics(t,i,s=!1){const e=new Map;if(!i||0===i.length)return e;const n=new Map;for(const t of i)e.set(t,{min:1/0,max:-1/0,absMax:0,median:0}),n.set(t,[]);for(const r of t)for(const t of r){const r=t[ea.TYPE];if(r!==Eu.SUM&&r!==Eu.GROUPSUM)for(const r of i){const i=s?this.extractIntervalColumnValues(t,r):[this.extractColumnValue(t,r)];for(const t of i)if(null!==t&&!isNaN(t)){const i=e.get(r);i.min=Math.min(i.min,t),i.max=Math.max(i.max,t),n.get(r).push(Math.abs(t))}}}for(const[t,i]of e){i.min!==1/0&&i.max!==-1/0||(i.min=0,i.max=0),i.absMax=Math.max(Math.abs(i.min),Math.abs(i.max));const s=n.get(t);if(s.length>0){s.sort(((t,i)=>t-i));const t=Math.floor(s.length/2);i.median=s.length%2==0?(s[t-1]+s[t])/2:s[t]}e.set(t,i)}return e}extractIntervalColumnValues(t,i){const s=i+"##",e=[];for(const i of Object.keys(t))if(i.startsWith(s)){const s=Number(t[i]);e.push(isNaN(s)?null:s)}return e}extractColumnValue(t,i){if(void 0!==t[i]){const s=Number(t[i]);return isNaN(s)?null:s}for(const s of Object.keys(t))if(s===i||s.endsWith("##"+i)||s===i+"##"+i){const i=Number(t[s]);if(!isNaN(i))return i}return null}createRow(t,i,s,e,n,r,o,h,a,l,c){var u,d,f;const v=[];let p;for(const g of e){const m=g[ea.ROWGROUP],b=""===m?"-":m,y=g[ea.SUBCATEGORY],w=g[ea.TYPE],x=g[ea.ROWNR]>=2;p=null!==(d=null!==(u=g.operation)&&void 0!==u?u:g.restOperation)&&void 0!==d?d:p;const S=this.createDetailRow(w,r+=1,n,e.length);S.key=this.rowKey(g);for(const e of this.normalizedHeader){const n=this.getRawDataRowElement(g,e),r=null!==(f=null==a?void 0:a.includes(e.type))&&void 0!==f&&f,u=r?null==l?void 0:l.get(e.type):void 0,d=r&&void 0===e.bucket&&e.name===e.group&&e.name===e.type?null==c?void 0:c.get(g,e.type):void 0;S.createElement(this.translateSumCellLabel(t,i,n,b,y,w,e.type),e.type,this.createColumnType(e),this.setCellType(e.type,s),this.translateCellPrefix(i,w,e.type),this.translateScenarioCSS(e.type,n,p),x,o,null==h?void 0:h.value,r,u,1,d);const v=S.elements[S.elements.length-1];this.dateBuckets&&void 0!==e.bucket&&(v.date=Yi(e.bucket));const m=new ks(e.type);m.isValid&&(v.direction=this.resolveDirection(m,p))}v.push(S)}return v}rowKey(t){var i;const s=null!=t.restRowGroup?t.restRowGroup:"NO_GROUP"===t.rowGroup?void 0:t.rowGroup;switch(t.type){case Eu.ENTRY:return{rowGroup:s,category:t.category,subCategory:t.subCategory};case Eu.DRILLELEMENT:return{rowGroup:s,category:t.category,subCategory:null!==(i=t.rawSubCategory)&&void 0!==i?i:t.subCategory};case Eu.GROUPSUM:return{rowGroup:s,row:"subtotal"};case Eu.SUM:return{row:"total"};default:return}}getRawDataRowElement(t,i){return void 0!==i.bucket?t[i.type+"##"+i.bucket]:i.name===i.group&&i.name===i.type?t[i.name]:i.name===i.group&&i.name!==i.type?t[i.type+"##"+i.name]:t[i.type+"##"+i.group+"##"+i.name]}createDetailRow(t,i,s,e){switch(t){case Eu.GROUPHEAD:return new Gu(i,s,Eu.HEADER);case Eu.SUM:case Eu.GROUPSUM:return new Gu(e+2,s,Eu.SUM);case Eu.DRILLELEMENT:return new Gu(e+2,s,Eu.DRILLELEMENT);case Eu.PARTELEMENT:return new Gu(e+2,s,Eu.PARTELEMENT);default:return new Gu(i,s,Eu.STANDARD)}}translateSumCellLabel(t,i,s,e,n,r,o){return this.attributesByAlias.has(o)||!1===Number.isNaN(Number(s))||this.isOperationColumn(o)?s:this.isGroupHeadCategory(r,o)?t===_t.ALL?`${i.get(s)||s}`:s:this.isEntryCategory(r,o)?t===_t.ALL||"REST"===s?`${i.get(s)||s}`:s:this.isDrillElementCategory(r,o)?t===_t.ALL?`${i.get(n)||n}`:`${n}`:this.isPartElementCategory(r,o)?t===_t.ALL||"SUM_TOTAL"===e?`${i.get(e)||e}`:`${e}`:this.isSumElementCategory(r,o)?t===_t.ALL||"SUM_TOTAL"===e?`${i.get(e)||e}`:e:"GROUPHEAD"===r&&null==s||s===it?s:Number.isNaN(Number(s))?"-":Number(s)}isOperationColumn(t){return"operation"===t}translateScenarioCSS(t,i,s){if(this.attributesByAlias.has(t))return"attribute";const e=new ks(t);let n="pos";return i<0&&(n="neg"),e.isValid?n+"_"+this.resolveDirection(e,s)+("dr"===e.type?" relative_variance":""):t}resolveDirection(t,i){return As(t.direction,i,!this.unsignedEntries)}setCellType(t,i){if("category"===t)return"";const s=this.attributesByAlias.get(t);if(s)return s.isNumeric?"decimal":"";let e;const n=new ks(t);return i===$t.PERCENT?(e="percent",n.isValid&&"d"===n.type&&(e="percentpoint")):(e="decimal",n.isValid&&"dr"===n.type&&(e="percent")),e}isDrillElementCategory(t,i){return"DRILLELEMENT"===t&&"category"===i}isPartElementCategory(t,i){return"PARTELEMENT"===t&&"category"===i}isSumElementCategory(t,i){return("GROUP_SUM"===t||"SUM"===t)&&"category"===i}isEntryCategory(t,i){return"ENTRY"===t&&"category"===i}isGroupHeadCategory(t,i){return"GROUPHEAD"===t&&"category"===i}translateCellPrefix(t,i,s){return this.isOperationColumn(s)||this.isGroupHeadCategory(i,s)||this.isEntryCategory(i,s)?null:this.isDrillElementCategory(i,s)?`${t.get("thereof")} `:this.isPartElementCategory(i,s)?`${t.get("part_of")} `:null}createColumnType(t){return t.name===t.group&&t.name===t.type?"base":t.name===t.group?"columnGroup":"columnSubGroup"}}class Od{constructor(t,i,s,e){this.fromExpr="",this.rowCount=0,this.headerRows=[],this.bodyRows=[],this.intervalBuckets=[],this.ruleSet=t||new Cs,this.db=i,this.dataSetFactory=new _d(this.ruleSet),this.config=this.initConfig(e),this.i18n=this.initI18n(new Map),this.setSource(s,e.filter)}setI18n(t){this.i18n=this.initI18n(t)}initI18n(t){const i=new Map([["",""],["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=Ru.DIRTY,new Map([...i,...t||new Map])}initConfig(t){this.state=Ru.DIRTY;const i=t,s=this;return t.scenarios.sort(((t,i)=>s.ruleSet.getScenarioSorIndex(t)-s.ruleSet.getScenarioSorIndex(i))),i}setConfig(t){this.config=this.initConfig(t)}setSource(t,i){var s,e;if(this.state=Ru.DIRTY,this.fromExpr=$(this.db,t,i),!this.fromExpr)return void(this.rowCount=0);const n=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(e=null===(s=n[0])||void 0===s?void 0:s.cnt)&&void 0!==e?e:0}update(){this.prepareIntervalBuckets();const t=this.normalizeScenarios(this.config.scenarios,this.config.categoryThereOf,this.config.sortOrder,this.intervalBuckets);this.headerRows=this.dataSetFactory.createHeader(this.config.type,t,this.i18n,this.config.measureScale,this.config.measureUnit,this.config.showMeasureScale,this.config.attributes),this.bodyRows=0!==this.rowCount&&this.fromExpr?this.dataSetFactory.createBodyRows(this.config,this.i18n,this.db,this.fromExpr):[],this.state=Ru.UP_TO_DATE}getHeader(){return this.state===Ru.DIRTY&&this.update(),this.headerRows}getBody(){return this.state===Ru.DIRTY&&this.update(),this.bodyRows}getColumns(){return this.state===Ru.DIRTY&&this.update(),this.dataSetFactory.getNormalizedHeader()}prepareIntervalBuckets(){this.intervalBuckets=[],this.config.interval===Tu||!this.fromExpr||this.config.categoryThereOf.size>0?this.config.interval=Tu:(this.config.interval=function(t,i,s){var e;if(s!==ot.AUTO)return s;const n=t.exec(`SELECT [date] as d FROM ${i}`);let r,o;for(const t of n){const i=null===(e=Du(t.d))||void 0===e?void 0:e.toMillis();void 0!==i&&(r=void 0===r?i:Math.min(r,i),o=void 0===o?i:Math.max(o,i))}return void 0===r||void 0===o?ot.DAY:(new lt).calculateDistanceType(y.fromMillis(r),y.fromMillis(o))}(this.db,this.fromExpr,this.config.interval),this.intervalBuckets=function(t,i,s,e){const n=t.exec(`SELECT ${Pu(s)} as __interval FROM ${i}`);if(s===Cu){const t=new Set,i=[];for(const s of n){const e=Wu(s.__interval);t.has(e)||(t.add(e),i.push({key:e,label:0===e.length?"-":e}))}return i}const r=new Set,o=[];for(const t of n){const i=Du(t.__interval);if(!i)continue;const s=i.toISO();r.has(s)||(r.add(s),o.push(i))}o.sort(((t,i)=>t.toMillis()-i.toMillis()));const h=new lt;return h.setLocale(e),o.map((t=>({key:t.toISO(),label:h.getDateString(t,s)})))}(this.db,this.fromExpr,this.config.interval,this.config.locale),0===this.intervalBuckets.length&&(this.config.interval=Tu))}normalizeScenarios(t,i,s,e=[]){var n;const r=[],o=null===(n=null==s?void 0:s.hierarchy)||void 0===n?void 0:n.map((t=>Et(t))).find((t=>"dim"!==(null==t?void 0:t.kind))),h=this.config.interval===Cu?null==o?void 0:o.bucket:void 0,a=(t,i)=>{var e;return null==o||(null===(e=Et(t))||void 0===e?void 0:e.column)!==o.column||void 0!==h&&h!==i?void 0:s.direction};if(e.length>0){for(const i of e)for(const s of t)r.push({name:s,group:s,type:s,order:a(s,i.key),bucket:i.key,bucketLabel:i.label});return r}for(const s of t){if(null==i?void 0:i.has(s)){const t=i.get(s);for(const i of t){r.push({name:i.name,group:i.name,type:s,order:void 0});for(const t of i.subGroups)r.push({name:t,group:i.name,type:s,order:void 0})}r.push({name:"REST",group:"REST",type:s,order:void 0})}r.push({name:s,group:s,type:s,order:a(s)})}return r}hasNoData(){return 0===this.rowCount}orderBucketWarning(){var t,i;if(this.hasNoData()||this.state!==Ru.UP_TO_DATE)return;const s=(null!==(i=null===(t=this.config.sortOrder)||void 0===t?void 0:t.hierarchy)&&void 0!==i?i:[]).map((t=>{var i;return null===(i=Et(t))||void 0===i?void 0:i.bucket})).filter((t=>void 0!==t));if(0===s.length)return;if(this.config.interval!==Cu)return`order: '@${s[0]}' needs interval setname, the bucket is ignored.`;const e=s.find((t=>!this.intervalBuckets.some((i=>i.key===t))));return void 0===e?void 0:`order: setname '${e}' not found, the rows are not sorted by it.`}hasBlankRowGroup(){return this.dataSetFactory.hasBlankRowGroup}}class kd{constructor(){this.title="",this.scenarios=[],this.scenariosUnitType=$t.DECIMAL,this.grouped=!1,this.showGroupTitle=!0,this.thereOf=[],this.categoryThereOf=new Map,this.partOf=[],this.attributes=[],this.sortOrder=new tt(new cl).default(),this.type=Nu.LIST,this.limit=0,this.i18n=_t.ALL,this.categoryWidth=Ot.W25,this.measureScale=new la,this.measureUnit="",this.measureType=kt.VOLUME,this.showMeasureScale=!0,this.filter="",this.barColumns=[],this.interval="none",this.locale="de"}}class Ad{constructor(t,i,s,e,n,r){this.tableDrillGroupAdapter=t,this.stringAdapter=i,this.orderAdapter=s,this.db=e,this.fromExpr=n,this.onQueryError=r}adapt(t){const i=new kd;return R.isString(t.title)&&(i.title=t.title),R.isArray(t.scenarios)&&(i.scenarios=Z.adaptArray(t.scenarios,this.stringAdapter)),R.isExisting(t.scenariosUnitType)&&(i.scenariosUnitType=t.scenariosUnitType),R.isBoolean(t.grouped)&&(i.grouped=t.grouped),R.isBoolean(t.showGroupTitle)&&(i.showGroupTitle=t.showGroupTitle),R.isBoolean(t.showMeasureScale)&&(i.showMeasureScale=t.showMeasureScale),R.isArray(t.thereOf)&&(i.thereOf=Z.adaptArray(t.thereOf,this.tableDrillGroupAdapter)),R.isExisting(t.categoryThereOf)&&(i.categoryThereOf=t.categoryThereOf),R.isArray(t.partOf)&&(i.partOf=Z.adaptArray(t.partOf,this.tableDrillGroupAdapter)),R.isArray(t.attributes)&&(i.attributes=t.attributes),R.isExisting(t.order)&&(i.sortOrder=this.orderAdapter.adapt(t.order)),R.isExisting(t.type)&&(i.type=t.type),R.isNumber(t.limit)&&(i.limit=t.limit),R.isExisting(t.i18n)&&(i.i18n=t.i18n),R.isExisting(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),R.isExisting(t.measureScale)&&(i.measureScale=ll.calculateMeasureScale(this.db,this.fromExpr,i.scenarios,t.measureScale,this.onQueryError)),R.isExisting(t.measureType)&&(i.measureType=t.measureType),R.isString(t.measureUnit)&&(i.measureUnit=t.measureUnit),R.isString(t.filter)&&(i.filter=t.filter.trim()),R.isArray(t.barColumns)&&(i.barColumns=t.barColumns),R.isString(t.interval)&&(i.interval=t.interval),R.isString(t.locale)&&(i.locale=t.locale),i}default(){return new kd}}class Rd{constructor(){this.rowGroup="",this.category="",this.subCategory="",this.partOf=""}}class Nd{constructor(){}adapt(t){const i=new Rd;return R.isString(t.rowGroup)&&(i.rowGroup=t.rowGroup),R.isString(t.category)&&(i.category=t.category),R.isString(t.subCategory)&&(i.subCategory=t.subCategory),R.isString(t.partOf)&&(i.partOf=t.partOf),i}default(){return new Rd}}const Ld=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.sumTitle="SUM_TOTAL",this.scenarios=[],this.scenariosDataFormat=$t.DECIMAL,this.grouped=!1,this.limit=0,this.showGroupTitle=!0,this.thereof=[],this.partof=[],this.order={hierarchy:[],direction:Lu.ASC},this.categorythereof=new Map,this.attributeColumns=[],this.type=Nu.LIST,this.categoryWidth=Ot.INF,this.dataFormatDigits={percent:2,decimal:1},this.i18n=new Map,this.i18nMode=_t.ALL,this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.measureType=kt.VOLUME,this.filter="",this.barColumns=[],this.interval="none",this.barColumnMaxWidth=30,this.unitScaling=.01,this.percentageScaling=.5,this.scaleFactor=1,this.componentDataFormatDigits=new zl,this.barColumnLayouts=new Map,this.relayout=()=>{this.barColumnLayouts.size>0&&n(this)},a(this),this.componentStyle=k(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,i){var s,e,n;const r={regions:[],metadata:{},diagnostics:[]},o=null===(s=this.element.shadowRoot)||void 0===s?void 0:s.querySelector("table");if(r.metadata.hasNoData=null===(n=null===(e=this.table)||void 0===e?void 0:e.hasNoData())||void 0===n||n,!this.table||!o)return r;const h=o.querySelector("thead"),a=o.querySelector("tbody");h&&r.regions.push({id:"header",rect:ti(h,t)}),a&&r.regions.push({id:"body",rect:ti(a,t)});const l=this.table.getHeader(),c=this.table.getBody(),u=this.table.getColumns();if(r.metadata.headerRowCount=l.length,r.metadata.rowCount=c.length,r.metadata.columnCount=u.length,r.metadata.cellCount=c.reduce(((t,i)=>t+i.getCells().length),0),"full"!==i)return r;const d=[],f=[],v=(i,s,e)=>{const n=e?Array.from(e.children).filter((t=>"tr"===t.localName)):[];s.forEach(((s,e)=>{const o=n[e];if(!o)return;d.push({section:i,index:e,type:s.type,rect:ti(o,t),point:Ii(o)});const h=s.getCells(),a=Array.from(o.children);h.length===a.length?h.forEach(((s,n)=>{var r,o;const h=a[n],l={kind:"header"===i?"headerCell":"cell",row:e,column:s.index,key:s.key||void 0,colSpan:s.colSpan,value:null!==(r=s.value)&&void 0!==r?r:void 0,text:(null===(o=h.textContent)||void 0===o?void 0:o.trim())||void 0,type:s.type||void 0,rect:ti(h,t),point:Ii(h)};l.point&&(l.content=hi(h,t),l.contentSign=ai(h)||void 0);const c=h.querySelector("svg.cell-bar-chart");c&&(l.bar={variant:c.classList.contains("waterfall-bar")?"waterfall":c.classList.contains("relative-variance")?"relative":"absolute",rect:ti(c,t)}),f.push(l)})):r.diagnostics.push({id:`WARN_layout_cell_pairing_${i}_${e}`,type:"warning",message:`layout-state: model/DOM cell count mismatch in ${i} row ${e} (${h.length} vs ${a.length}); cell details skipped for this row.`})}))};return v("header",l,h),v("body",c,a),r.elements=f,r.table={rows:d,columns:u.map(((t,i)=>({index:i,key:t.name,group:t.group,type:t.type,bucket:t.bucket})))},r}render(){var t;return i(s,{class:{"no-data":!0===(null===(t=this.table)||void 0===t?void 0:t.hasNoData())}},(()=>{var t,s,e,n;if(void 0===this.table)return;if(this.table.hasNoData()){const s=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return i("div",{class:"empty-state"},s)}const r=null===(n=null===(e=null===(s=this.stores)||void 0===s?void 0:s.context)||void 0===e?void 0:e.state)||void 0===n?void 0:n.locale;return i("table",null,i("thead",null,this.table.getHeader().map((t=>i("tr",{class:t.cssStyle},t.getCells().map((t=>i("th",{colSpan:t.colSpan,class:t.cssStyle},t.getAsHeaderList().map(((s,e,n)=>i("span",null,e===n.length-1?i("span",{class:" "===s?"table-footer":""},s,t.drawPrefix()," "):i("span",null,s,t.drawPrefix(),i("br",null)))))))))))),i("tbody",null,this.table.getBody().map((t=>i("tr",Object.assign({class:t.cssStyle},ji(t.key,"element")),null==t?void 0:t.getCells().map((s=>{var e,n,o,h,a;return i("td",Object.assign({colSpan:s.colSpan,class:s.type?`${s.cssStyle} ${s.type}`:s.cssStyle},t.key&&null!=s.value&&""!==s.value&&"-"!==s.value?ji(Object.assign(Object.assign({},t.key),{date:s.date,scenario:s.key}),"element"):{}),null!=s.prefix?i("span",{class:s.cssStyle+" "+s.prefixStyle},s.drawPrefix()):"",!s.isBarChart||!s.columnStats||s.value===it||!this.showGroupTitle&&t.type===Eu.HEADER||void 0===s.waterfall&&t.type===Eu.SUM?s.draw(this.componentDataFormatDigits,r):void 0!==s.waterfall?i(yd,{value:s.value,scenario:s.key,columnStats:s.columnStats,height:18*this.scaleFactor,isRelative:!1,isPositiveGood:"pos"===s.direction,measureScale:s.measureScale,locale:r,decimalDigits:Td(s,this.componentDataFormatDigits),columnWidthEm:this.barColumnMaxWidth,styles:this.barChartStyles,waterfall:s.waterfall}):i(bd,{value:s.value,scenario:s.key,columnStats:s.columnStats,height:18*this.scaleFactor,isRelative:s.key.startsWith("dr"),isPositiveGood:"pos"===s.direction,measureScale:Ed(s),locale:r,decimalDigits:Td(s,this.componentDataFormatDigits),percentDigits:null!==(n=null===(e=this.barColumnLayouts.get(s.key))||void 0===e?void 0:e.percentDigits)&&void 0!==n?n:this.componentDataFormatDigits.percent,percentSign:null===(o=this.barColumnLayouts.get(s.key))||void 0===o?void 0:o.percentSign,columnWidthEm:this.barColumnMaxWidth,labelWidths:null===(h=this.barColumnLayouts.get(s.key))||void 0===h?void 0:h.labels,sideMax:null===(a=this.barColumnLayouts.get(s.key))||void 0===a?void 0:a.sideMax,styles:this.barChartStyles}))})))))))})())}componentWillRender(){var t,i,s,e,n,r,o,h;this.stores||(this.stores=c(this.element));const a=this.stores.db.db;this.componentDataFormatDigits=(new Ul).adapt(this.dataFormatDigits);try{const i=this.prepareConfig(a);this.table=new Od(new Cs(this.ruleSetConfig),a,this.tableName,i),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===(i=this.errors)||void 0===i||i.addOrReplace({id:"ERR_sql",type:"error",message:`Query failed: ${t instanceof Error?t.message:t}`})}(null===(s=this.table)||void 0===s?void 0:s.hasBlankRowGroup())?null===(e=this.errors)||void 0===e||e.addOrReplace({id:"WARN_blankRowGroup",type:"warning",message:"grouped: rows with blank rowGroup found, they are grouped under '-'."}):null===(n=this.errors)||void 0===n||n.remove("WARN_blankRowGroup");const l=null===(r=this.table)||void 0===r?void 0:r.orderBucketWarning();l?null===(o=this.errors)||void 0===o||o.addOrReplace({id:"WARN_orderBucket",type:"warning",message:l}):null===(h=this.errors)||void 0===h||h.remove("WARN_orderBucket"),this.barColumnLayouts=this.collectBarColumnLayouts(),this.barChartStyles=this.prepareBarChartStyles()}prepareConfig(t){var i,s,e;const n=$(t,this.tableName,this.filter);return new Ad(new Nd,new cl,new tt(new cl,!0),t,n,(t=>{throw t})).adapt({title:this.sumTitle,scenarios:this.scenarios,scenariosUnitType:this.scenariosDataFormat,grouped:this.grouped,showGroupTitle:this.showGroupTitle,thereOf:this.thereof,partOf:this.partof,categoryThereOf:this.categorythereof,attributes:this.attributeColumns,order:this.order,type:this.type,limit:this.limit,i18n:this.i18nMode,categoryWidth:this.categoryWidth,measureScale:this.measureScale,measureUnit:this.measureUnit,measureType:this.measureType,showMeasureScale:this.showMeasureScale,filter:this.filter,barColumns:this.barColumns,interval:this.interval,locale:(null===(e=null===(s=null===(i=this.stores)||void 0===i?void 0:i.context)||void 0===s?void 0:s.state)||void 0===e?void 0:e.locale)||"de"})}prepareBarChartStyles(){var t;const i=!(this.unitScaling>0),s=!(this.percentageScaling>0),e=i?this.autoUnitScaling():this.unitScaling,n=s?this.autoPercentageScaling():this.percentageScaling;return(i||s)&&(null===(t=this.reportAutoScaling)||void 0===t||t.call(this,{unit:i?e:void 0,percentage:s?n:void 0})),this.componentStyle((t=>{var i,s,r,o,h,a,l,c,u,d,f,v,p,g,m,b,y,w,x,S,$,M,_,O,k,A;const R=null===(i=t["bn-chart-time"])||void 0===i?void 0:i.varianceStyles,N=null===(s=t["bn-chart-time"])||void 0===s?void 0:s.barStyles;return{positive:{stroke:(null===(r=null==R?void 0:R.pos)||void 0===r?void 0:r.stroke)||"#008f96",fill:(null===(o=null==R?void 0:R.pos)||void 0===o?void 0:o.fill)||"#008f96",fillpattern:Us(null===(h=null==R?void 0:R.pos)||void 0===h?void 0:h.fillpattern)||"solid"},negative:{stroke:(null===(a=null==R?void 0:R.neg)||void 0===a?void 0:a.stroke)||"#ff0000",fill:(null===(l=null==R?void 0:R.neg)||void 0===l?void 0:l.fill)||"#ff0000",fillpattern:Us(null===(c=null==R?void 0:R.neg)||void 0===c?void 0:c.fillpattern)||"solid"},neutral:{stroke:(null===(u=null==R?void 0:R.neu)||void 0===u?void 0:u.stroke)||"#808080",fill:(null===(d=null==R?void 0:R.neu)||void 0===d?void 0:d.fill)||"#808080",fillpattern:Us(null===(f=null==R?void 0:R.neu)||void 0===f?void 0:f.fillpattern)||"outlined"},scenarios:Es({ac:{stroke:(null===(v=null==N?void 0:N.ac)||void 0===v?void 0:v.stroke)||"#404040",fill:(null===(p=null==N?void 0:N.ac)||void 0===p?void 0:p.fill)||"#404040",fillpattern:Us(null===(g=null==N?void 0:N.ac)||void 0===g?void 0:g.fillpattern)||"solid"},pp:{stroke:(null===(m=null==N?void 0:N.pp)||void 0===m?void 0:m.stroke)||"#A6A6A6",fill:(null===(b=null==N?void 0:N.pp)||void 0===b?void 0:b.fill)||"#A6A6A6",fillpattern:Us(null===(y=null==N?void 0:N.pp)||void 0===y?void 0:y.fillpattern)||"solid"},fc:{stroke:(null===(w=null==N?void 0:N.fc)||void 0===w?void 0:w.stroke)||"#404040",fill:(null===(x=null==N?void 0:N.fc)||void 0===x?void 0:x.fill)||"#ffffff",fillpattern:Us(null===(S=null==N?void 0:N.fc)||void 0===S?void 0:S.fillpattern)||"hatched"},pl:{stroke:(null===($=null==N?void 0:N.pl)||void 0===$?void 0:$.stroke)||"#404040",fill:(null===(M=null==N?void 0:N.pl)||void 0===M?void 0:M.fill)||"#ffffff",fillpattern:Us(null===(_=null==N?void 0:N.pl)||void 0===_?void 0:_.fillpattern)||"outlined"}},new Cs(this.ruleSetConfig)),fontColor:(null===(O=t.global)||void 0===O?void 0:O.fontColor)||"#000000",fontSize:((null===(k=t.global)||void 0===k?void 0:k.fontSizePx)||13.3333)*ju*this.scaleFactor,emPx:((null===(A=t.global)||void 0===A?void 0:A.fontSizePx)||13.3333)*this.scaleFactor,fontFamily:this.labelFontFamily(),unitScaling:e,percentageScaling:n,scaleFactor:this.scaleFactor}}))}labelFontFamily(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif"}))}emPx(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*this.scaleFactor}autoUnitScaling(){var t;const i=this.emPx(),s=i*ju;let e=1/0;for(const{isRelative:n,absMax:r,labels:o,sideMax:h}of this.barColumnLayouts.values()){if(n||r<=0)continue;const a=td(this.barColumnMaxWidth,i,o,h);for(const i of["neg","pos"]){const n=null!==(t=h[i])&&void 0!==t?t:0;if(n<=0)continue;const{maxBarWidth:r,cutWidth:o}=a[i];e=Math.min(e,Math.min(.8*r,o)/(n*s))}}return Number.isFinite(e)&&s>0?e:.01}autoPercentageScaling(){var t,i;const s=this.emPx(),e=s*ju;let n=1/0;for(const{isRelative:r,absMax:o,labels:h,sideMax:a}of this.barColumnLayouts.values()){if(!r||o<=0)continue;const l=10*this.scaleFactor,{negPinLength:c,posPinLength:u}=id(this.barColumnMaxWidth,s,h,l),d=100*((null!==(t=a.neg)&&void 0!==t?t:0)+(null!==(i=a.pos)&&void 0!==i?i:0));n=Math.min(n,(c+u)/(d*e))}return Number.isFinite(n)&&e>0?n:.5}collectBarColumnLayouts(){var t,i,s,e;const n=new Map;if(!this.table||this.table.hasNoData())return n;const r=new Map;for(const i of this.table.getBody())if(i.type!==Eu.SUM)for(const s of i.getCells())s.isBarChart&&s.columnStats&&void 0===s.waterfall&&("number"!=typeof s.value||isNaN(s.value)||r.set(s.key,[...null!==(t=r.get(s.key))&&void 0!==t?t:[],s]));const o=this.emPx(),h=o*ju,a=10*this.scaleFactor,l=null===(e=null===(s=null===(i=this.stores)||void 0===i?void 0:i.context)||void 0===s?void 0:s.state)||void 0===e?void 0:e.locale,c=this.labelFontFamily();for(const[t,i]of r){const s=t.startsWith("dr"),e=i.map((t=>t.value)),r=(t,n)=>{var r;const o={neg:e.some((t=>t<0))?0:void 0,pos:e.some((t=>t>0))?0:void 0},a=ud(o);for(const e of i){const i=e.value,u=i>0||0===i&&a?"pos":"neg",d=od(i,s,Ed(e),l,t,n,Td(e,this.componentDataFormatDigits));o[u]=Math.max(null!==(r=o[u])&&void 0!==r?r:0,Xu(d,h,c,s))}return o};let u=Math.min(20,Math.max(0,Math.trunc(this.componentDataFormatDigits.percent)||0)),d=!0,f=r(u,d);for(;s&&(u>0||d)&&!Qu(this.barColumnMaxWidth,o,f,a);)u>0?u--:d=!1,f=r(u,d);const v=Math.max(...e.map(Math.abs))*(s?100:1),p={neg:void 0===f.neg?void 0:Math.max(0,...e.map((t=>-t))),pos:void 0===f.pos?void 0:Math.max(0,...e)};n.set(t,{isRelative:s,absMax:v,labels:f,sideMax:p,percentDigits:u,percentSign:d})}return n}get element(){return e(this)}};function Ed(t){return"percentpoint"===t.type?.01:t.measureScale}function Td(t,i){return"percentpoint"===t.type?i.percent:"decimal"===t.type?i.decimal:void 0}Ld.style=':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{position:relative;display:inline-block}table{background-color:var(--bn-font-background, white);font-size:var(--bn-font-size, 1em);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);border-spacing:0.3em 0}thead{border-style:none}tr:first-child td{border-top:none;padding-top:0.5em}td.ac1,td.ac2,td.ac3,td.ac4,td.pp1,td.pp2,td.pp3,td.pp4,td.pl1,td.pl2,td.pl3,td.pl4,td.fc1,td.fc2,td.fc3,td.fc4,td.share,td.variance,td.pos_pos,td.pos_neg,td.neg_pos,td.neg_neg,td.pos_neutral,td.neg_neutral{text-align:right}.category-w100{min-width:100em;max-width:100em}.category-w50{min-width:50em;max-width:50em}.category-w25{min-width:25em;max-width:25em}.category-w20{min-width:20em;max-width:20em}.category-w15{min-width:15em;max-width:15em}.category-w10{min-width:10em;max-width:10em}.category-w5{min-width:5em;max-width:5em}.prefix-second{color:transparent;font-style:normal}.prefix-first{font-style:normal}th{border-bottom:0.1em solid black;text-align:right;font-weight:normal;vertical-align:text-top}td.columnGroup,th.columnGroup{font-size:0.6em}td.columnSubGroup,th.columnSubGroup{font-size:0.6em;border-spacing:0em 0;font-style:italic}td.base,th.base{font-style:normal}th.ofit,td.ofit,tr.ofit,th.partof,td.partof,tr.partof{font-size:0.6em;font-style:italic}td.ofit,td.partof{font-size:0.6em;font-style:italic}th.ofit td,tr.ofit td,th.partof td,tr.partof td{border-top:0em solid black;padding-left:1em}th.ofit share,th.partof share,tr.share td{border-top:0em solid black}th.share,tr.share,td.share{font-size:0.6em;font-style:italic}th.filler{border-bottom:0em solid black;text-align:right}td.filler{border-top:0em none !important;border-bottom:0em none;text-align:right}th.group{text-align:center;border-spacing:1em 0}th.headerlabel{border-bottom:0em none black;padding-bottom:0em}th.intervalGroup{border-bottom:0.1em solid black;text-align:center;font-weight:bold}td.variance:after{content:"%"}td.relative_variance{font-style:italic}td.percent{font-style:italic;text-align:right}td.decimal,td.percentpoint{text-align:right}td.pos_pos{color:#008f96}td.neg_pos{color:#ff0000}td.pos_neg{color:#ff0000}td.neg_neg{color:#008f96}td.pos_pos:before{content:"+"}td.pos_neg:before{content:"+"}td.pos_neu:before{content:"+"}th.ac1,th.ac2,th.ac3,th.ac4{padding-top:0em;border-bottom:0.3em solid black}th.pp1,th.pp2,th.pp3,th.pp4{padding-top:0em;border-bottom:0.3em solid grey}th.pl1,th.pl2,th.pl3,th.pl4{padding-top:0em;border-bottom:0.3em double black}th.fc1,th.fc2,th.fc3,th.fc4{border-bottom:0.3em solid;border-image:repeating-linear-gradient(-45deg, white, white, black, white, white 0.3em) 2}td.colsum{font-weight:bold}th.colsum{padding-top:0em;font-weight:bold}tr.sum td{border-top:0.1em solid black;font-weight:bold;padding-bottom:0.5em}tr.groupheader td{border-top:0em dotted #ddd;padding-top:0.5em;font-weight:bold;font-style:italic}tr.begingroup td{border-top:0em dotted #ddd;padding-top:0.5em}th.begin-group{padding-left:0.75em}th.end-group{padding-left:0.75em}td{box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em dashed #ddd;padding-left:0.5em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.table-footer{font-size:0.6em}.cell-bar-chart{display:inline-block;vertical-align:middle}.bar-chart-empty{color:#999}td:has(.cell-bar-chart){padding:0 0.25em;vertical-align:middle}td:has(.cell-bar-chart).pos_pos:before,td:has(.cell-bar-chart).pos_neg:before,td:has(.cell-bar-chart).pos_neu:before{content:none}td:has(.cell-bar-chart).variance:after{content:none}';const Cd=class{constructor(i){t(this,i),this.businessUnit="",this.order="category",this.orderDirection="asc",this.dateFormat="none",this.dateLink="none",E(this),a(this),this.t=Bt(this).t,this.errors=l(this),this.componentStyle=k(this),this.ruleSetConfig=es(this)}validateScenario(t){const i="WARN_scenarios",s=B(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+(null==s?void 0:s.toString())+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances",s=H(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+(null==s?void 0:s.toString())+"' are not supported."}):this.errors.remove(i)}validateOrder(t){const i=U(t),s="WARN_order";i.length>0?this.errors.addOrReplace({id:s,type:"warning",message:"order: invalid value(s) '"+(null==i?void 0:i.toString())+"' are not supported."}):this.errors.remove(s)}validateOrderDirection(t){const i="WARN_orderDirection";F(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasures(t){const i="WARN_measures",s=Ct(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"measures: invalid value(s) '"+(null==s?void 0:s.toString())+'\' are not supported. Valid format example: [{"name": "Bruttoumsatz", "unit": "mEUR"}]'}):this.errors.remove(i)}validateDateStart(t){const i="WARN_dateStart";Pt(t)||N(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateStart: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateEnd(t){const i="WARN_dateEnd";Pt(t)||N(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateStart: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateFormat(t){const i="WARN_dateFormat";nt(t)||N(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateFormat: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateLink(t){const i="WARN_dateLink";Wt(t)||N(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateLink: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateMeasures(this.measures),this.validateDateStart(this.dateStart),this.validateDateEnd(this.dateEnd),this.validateDateFormat(this.dateFormat),this.validateDateLink(this.dateLink),this.validateOrderDirection(this.orderDirection),this.validateOrder(this.order)}prepareI18n(){const t=p,i=new Map(["SEPARATOR_WS","in","CONNECTOR_WS"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries(),...Ts(this.ruleSetConfig("user"))])}prepareI18nMode(){return _t.META}prepareLocale(){return c(this.element).context.state.locale||"de"}prepareTitleOrder(){var t;return N(this.order)||N(this.orderDirection)?null:{hierarchy:this.order.split(",").map((t=>t.trim())),direction:j[null===(t=this.orderDirection)||void 0===t?void 0:t.toUpperCase()]}}prepareTitleTimePeriod(){var t,i;return N(this.dateStart)&&N(this.dateEnd)||N(this.dateLink)?null:{start:y.fromISO(this.dateStart,{zone:"utc"}),end:y.fromISO(this.dateEnd,{zone:"utc"}),format:ot[null===(t=this.dateFormat)||void 0===t?void 0:t.toUpperCase()],link:Dt[null===(i=this.dateLink)||void 0===i?void 0:i.toUpperCase()]}}prepareMeasures(){if(N(this.measures))return[];try{return JSON.parse(this.measures)}catch(t){return[]}}prepareScenarios(){var t,i,s,e;if(N(this.scenarios)&&N(this.variances))return[];let n=[];return(null===(t=this.scenarios)||void 0===t?void 0:t.trim().length)>0&&(n=n.concat(null===(i=this.scenarios)||void 0===i?void 0:i.split(","))),(null===(s=this.variances)||void 0===s?void 0:s.trim().length)>0&&(n=n.concat(null===(e=this.variances)||void 0===e?void 0:e.split(","))),n.map((t=>t.trim()))}prepareBusinessUnit(){return N(this.businessUnit)||"null"===this.businessUnit?null:this.businessUnit}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles();return i(s,{key:"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 e(this)}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],measures:[{validateMeasures:0}],dateStart:[{validateDateStart:0}],dateEnd:[{validateDateEnd:0}],dateFormat:[{validateDateFormat:0}],dateLink:[{validateDateLink:0}]}}};Cd.style=':host{padding:0.5em;margin-bottom:0.5em;box-sizing:border-box;-webkit-box-sizing:border-box;width:100%;display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}';class Pd{constructor(){}createMeasures(t,i,s){if(this.allMeasuresUseSameUnit(t)){const e=t.length;let n="",r="";for(let o=0;o<e;o++){let h="";o>0&&(h=i.get("SEPARATOR_WS")),e>1&&o===e-1&&(h=i.get("CONNECTOR_WS")),s===_t.ALL?(n=(i.get(n)||n)+h+(i.get(t[o].name)||t[o].name),r=i.get(t[o].unit)||t[o].unit):(n=n+h+t[o].name,r=t[o].unit)}return[{name:n,unit:r}]}return t}createDimension(t,i,s,e,n,r="de"){let o="";if(void 0!==i){const t=new lt;t.setLocale(r),o=t.getDateLinkString(i.start,i.end,i.link,i.format,n)}const h=t.map((t=>{let i="";return null!=s&&null!=s.hierarchy&&s.hierarchy.find((i=>i===t))&&(i=e.get("asc"===s.direction?"ORDER_asc":"ORDER_desc")),"".concat(" ",ra.translateScenarioLabel(t,e),i)})).toString();return o+h}allMeasuresUseSameUnit(t){const i=new Map;return t.forEach((function(t){i.set(t.unit,!0)})),1===i.size}}class Wd{constructor(){this.businessunit="",this.measures=[],this.scenarios=[],this.i18nMode=_t.ALL,this.intervalSpanLimit=32,this.locale="de"}}class Dd{constructor(t,i,s,e){this.measureEntryAdapter=t,this.timePeriodAdapter=i,this.orderAdapter=s,this.stringAdapter=e}adapt(t){const i=new Wd;return R.isString(t.businessunit)&&(i.businessunit=t.businessunit),R.isArray(t.measures)&&(i.measures=Z.adaptArray(t.measures,this.measureEntryAdapter)),R.isArray(t.scenarios)&&(i.scenarios=Z.adaptArray(t.scenarios,this.stringAdapter)),R.isExisting(t.timeperiod)&&(i.timeperiod=this.timePeriodAdapter.adapt(t.timeperiod)),R.isNumber(t.intervalSpanLimit)&&(i.intervalSpanLimit=t.intervalSpanLimit),R.isExisting(t.i18nMode)&&(i.i18nMode=t.i18nMode),R.isExisting(t.order)&&(i.order=this.orderAdapter.adapt(t.order)),R.isString(t.locale)&&(i.locale=t.locale),i}default(){return new Wd}}var zd;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(zd||(zd={}));class Ud{constructor(t){this.i18n=new Map,this.unit="",this.measures=[],this.dimension="",this.config=new Wd,this.state=zd.DIRTY,this.ruleSet=t||new Cs,this.dataSetFactory=new Pd,this.state=zd.DIRTY,this.setI18n(new Map)}setRuleSet(t){this.ruleSet=t||new Cs}setI18n(t){this.state=zd.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","❖"],["CONNECTOR_WS"," und "]]);this.i18n=new Map([...i,...t||new Map])}update(){return zd.DIRTY===this.state&&(this.unit=this.config.businessunit,this.measures=this.dataSetFactory.createMeasures(this.config.measures,this.i18n,this.config.i18nMode),this.dimension=this.dataSetFactory.createDimension(this.config.scenarios,this.config.timeperiod,this.config.order,this.i18n,this.config.intervalSpanLimit,this.config.locale),this.state=zd.UP_TO_DATE),this}setConfig(t){this.config=this.initConfig(t)}initConfig(t){this.state=zd.DIRTY;const i=t,s=this;return t.scenarios.sort(((t,i)=>s.ruleSet.getScenarioSorIndex(t)-s.ruleSet.getScenarioSorIndex(i))),i}}class Fd{constructor(t="",i=""){this.name=t,this.unit=i}}class Gd{construnctor(){}adapt(t){const i=new Fd;return R.isString(t.name)&&(i.name=t.name),R.isString(t.unit)&&(i.unit=t.unit),i}default(){return new Fd("","")}}class jd{constructor(t=y.now(),i=y.now(),s=ot.AUTO,e=Dt.AUTO){this.start=t,this.end=i,this.format=s,this.link=e}}class Id{construnctor(){}adapt(t){const i=new jd;return R.isDate(t.start)&&(i.start=t.start),R.isDate(t.end)&&(i.end=t.end),R.isExisting(t.format)&&(i.format=t.format),R.isExisting(t.link)&&(i.link=t.link),i}default(){return new jd}}const Yd=class{constructor(i){t(this,i),this.businessUnit="",this.scenarios=[],this.measures=[],this.intervalSpanLimit=28,this.order={hierarchy:[],direction:j.ASC},this.i18n=new Map,this.i18nMode=_t.ALL,this.locale="de",this.title=new Ud(new Cs),a(this)}render(){return i("div",{key:"ecc33a660538732ceea3e4620afabfcb8ffbce95"},i("div",{key:"cb1c3b074817a4c0647419fdc0f2b94c113ebc09",innerHTML:zt(this.title.unit)}),i("div",{key:"92b6ef66f67d33bd3bff6a760d1fc1bee605105d"},this.title.measures.map(((t,s)=>i("span",null,this.isFirstElement(s)?this.title.i18n.get("SEPARATOR_WS"):"",i("span",{class:"measure"},t.name)," ",t.unit?this.title.i18n.get("in"):""," ",t.unit)))),i("div",{key:"74cc33e0e63592e5422b3c0e5c7a52715210c486"},this.title.dimension))}componentWillLoad(){const t=this.prepareConfig();this.title=new Ud(new Cs(this.ruleSetConfig)),this.title.setI18n(this.i18n),this.title.setConfig(t)}componentWillUpdate(){const t=this.prepareConfig();this.title.setI18n(this.i18n),this.title.setRuleSet(new Cs(this.ruleSetConfig)),this.title.setConfig(t)}componentWillRender(){this.title.update()}isFirstElement(t){return 0!==t}prepareConfig(){return new Dd(new Gd,new Id,new tt(new cl),new cl).adapt({businessunit:this.businessUnit,measures:this.measures,scenarios:this.scenarios,timeperiod:this.timeperiod,intervalSpanLimit:this.intervalSpanLimit,i18nMode:this.i18nMode,order:this.order,locale:this.locale})}};Yd.style=':host{display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.measure{font-weight:bold}div{background-color:var(--bn-font-background, white);color:var(--bn-font-color, black)}p{margin:0}';const Bd=["*","/","+","-","x","÷","none"];function Hd(t){switch(t){case"*":case"x":return"×";case"/":case"÷":return"÷";case"+":return"+";case"-":return"−";default:return""}}function Vd(t,i,s){return t.find((t=>t.from===i&&t.to===s))}function Xd(t){return 2*(t-1)+1}function Jd(t){return 2*(t-1)+1}function qd(t){return t<=1?1:2*(t-1)+1}function Kd(t,i){const s=t.getBoundingClientRect(),e=s.left-i.left,n=s.top-i.top;return{left:e,top:n,width:s.width,height:s.height,centerX:e+s.width/2,centerY:n+s.height/2}}function Qd(t,i,s){switch(s){case"ltr":return i?{x:t.left+t.width,y:t.centerY}:{x:t.left,y:t.centerY};case"rtl":return i?{x:t.left,y:t.centerY}:{x:t.left+t.width,y:t.centerY};case"ttb":return i?{x:t.centerX,y:t.top+t.height}:{x:t.centerX,y:t.top};case"btt":return i?{x:t.centerX,y:t.top}:{x:t.centerX,y:t.top+t.height}}}function Zd(t,i,s,e,n=8){const r=-(e-1)*n/2+s*n;switch(i){case"ltr":return{x:t.left,y:t.centerY+r};case"rtl":return{x:t.left+t.width,y:t.centerY+r};case"ttb":return{x:t.centerX+r,y:t.top};case"btt":return{x:t.centerX+r,y:t.top+t.height}}}function tf(t,i,s,e,n){switch(s){case"straight":return function(t,i){return{path:`M ${t.x} ${t.y} L ${i.x} ${i.y}`,midpoint:{x:(t.x+i.x)/2,y:(t.y+i.y)/2}}}(t,i);case"curved":return function(t,i,s){let e,n;if("ltr"===s||"rtl"===s){const s=(t.x+i.x)/2;e={x:s,y:t.y},n={x:s,y:i.y}}else{const s=(t.y+i.y)/2;e={x:t.x,y:s},n={x:i.x,y:s}}return{path:`M ${t.x} ${t.y} C ${e.x} ${e.y}, ${n.x} ${n.y}, ${i.x} ${i.y}`,midpoint:{x:.125*t.x+.375*e.x+.375*n.x+.125*i.x,y:.125*t.y+.375*e.y+.375*n.y+.125*i.y}}}(t,i,e);default:return function(t,i,s,e){let n,r;if("ltr"===s||"rtl"===s){const s=null!=e?e:t.x+.7*(i.x-t.x);n=`M ${t.x} ${t.y} L ${s} ${t.y} L ${s} ${i.y} L ${i.x} ${i.y}`,r={x:s,y:(t.y+i.y)/2}}else{const s=null!=e?e:t.y+.7*(i.y-t.y);n=`M ${t.x} ${t.y} L ${t.x} ${s} L ${i.x} ${s} L ${i.x} ${i.y}`,r={x:(t.x+i.x)/2,y:s}}return{path:n,midpoint:r}}(t,i,e,n)}}function sf(t,i,s){let e,n,r;switch(s){case"ltr":e=t.left+t.width,n=i.map((t=>t.left)),r=1;break;case"rtl":e=t.left,n=i.map((t=>t.left+t.width)),r=-1;break;case"ttb":e=t.top+t.height,n=i.map((t=>t.top)),r=1;break;case"btt":e=t.top,n=i.map((t=>t.top+t.height)),r=-1}const o=n.map((t=>(t-e)*r)).filter((t=>t>=0));if(0!==o.length)return e+Math.min(...o)*r*.7}function ef(t,i,s,e){return"ltr"===e||"rtl"===e?{x:t,y:(i.centerY+s.centerY)/2}:{x:(i.centerX+s.centerX)/2,y:t}}function nf(t,i,s){var e,n;return Object.assign({stroke:null!==(e=null==s?void 0:s.color)&&void 0!==e?e:t,strokeWidth:null!==(n=null==s?void 0:s.width)&&void 0!==n?n:i},(null==s?void 0:s.dasharray)?{strokeDasharray:s.dasharray}:{})}const rf=class{validateEdgesProp(t){const i="ERR_edges",s=function(t){const i=[];if(!t||""===t.trim())return i.push("edges: value is required"),i;let s;try{s=JSON.parse(t)}catch(t){return i.push("edges: invalid JSON structure"),i}if(!Array.isArray(s))return i.push("edges: must be an array"),i;if(0===s.length)return i.push("edges: array must not be empty"),i;const e=new Set,n=new Set,r=new Map;s.forEach(((t,s)=>{if("object"!=typeof t||null===t)return void i.push(`edges[${s}]: must be an object`);const o=t;if("string"!=typeof o.from||""===o.from.trim()?i.push(`edges[${s}]: 'from' is required and must be a non-empty string`):e.add(o.from),"string"!=typeof o.to||""===o.to.trim()?i.push(`edges[${s}]: 'to' is required and must be a non-empty string`):(e.add(o.to),n.add(o.to),"string"==typeof o.from&&r.set(o.from,[...r.get(o.from)||[],o.to])),void 0!==o.operator&&("string"==typeof o.operator&&Bd.includes(o.operator)||i.push(`edges[${s}]: 'operator' must be one of: ${Bd.join(", ")}`)),void 0!==o.label&&"string"!=typeof o.label&&i.push(`edges[${s}]: 'label' must be a string`),void 0!==o.style)if("object"!=typeof o.style||null===o.style)i.push(`edges[${s}]: 'style' must be an object`);else{const t=o.style;void 0!==t.color&&"string"!=typeof t.color&&i.push(`edges[${s}]: 'style.color' must be a string`),void 0!==t.width&&"number"!=typeof t.width&&i.push(`edges[${s}]: 'style.width' must be a number`),void 0!==t.dasharray&&"string"!=typeof t.dasharray&&i.push(`edges[${s}]: 'style.dasharray' must be a string`)}}));const o=Array.from(e).filter((t=>!n.has(t)));return 0===o.length?i.push("edges: tree has no root node (circular reference detected)"):o.length>1?i.push(`edges: tree has multiple root nodes: ${o.join(", ")}`):i.push(...function(t,i,s){const e=[],n=new Set,r=new Set,o=t=>{r.add(t),n.add(t);for(const s of i.get(t)||[])n.has(s)?e.push(`edges: circular reference, the edge from '${t}' to '${s}' leads back`):r.has(s)||o(s);n.delete(t)};o(t);const h=Array.from(s).filter((t=>!r.has(t)));return h.length>0&&e.push(`edges: nodes not connected to the root '${t}': ${h.join(", ")}`),e}(o[0],r,e)),i}(t);s.length>0?(this.errors.addOrReplace({id:i,type:"error",message:`edges: ${s.join("; ")}`}),this.treeConfig=null):(this.errors.remove(i),this.treeConfig=function(t){if(!t||""===t.trim())return null;try{const i=JSON.parse(t);if(!Array.isArray(i))return null;const s=i,e=function(t){const i=new Map;for(const s of t){const t=i.get(s.from)||[];t.push(s.to),i.set(s.from,t)}return i}(s),n=function(t){const i=new Set;for(const s of t)i.add(s.from),i.add(s.to);return i}(s),r=function(t,i){const s=new Set;for(const i of t)s.add(i.to);const e=Array.from(i).filter((t=>!s.has(t)));return 1===e.length?e[0]:null}(s,n);return{edges:s,adjacencyList:e,rootNode:r,allNodes:n}}catch(t){return console.error("parseTreeConfig: failed to parse tree configuration",t),null}}(t)),this.recalculateLayout()}validateDirection(t){const i="WARN_direction",s=["ltr","rtl","ttb","btt"];s.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`direction: invalid value '${t}', must be one of: ${s.join(", ")}`}),this.recalculateLayout()}validateLevelSpacing(t){const i="WARN_levelSpacing";!et(t)||t<0?this.errors.addOrReplace({id:i,type:"warning",message:`level-spacing: invalid value '${t}', must be a non-negative number`}):this.errors.remove(i),this.recalculateLayout()}validateNodeSpacing(t){const i="WARN_nodeSpacing";!et(t)||t<0?this.errors.addOrReplace({id:i,type:"warning",message:`node-spacing: invalid value '${t}', must be a non-negative number`}):this.errors.remove(i),this.recalculateLayout()}validateEdgeStyle(t){const i="WARN_edgeStyle",s=["straight","orthogonal","curved"];s.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`edge-style: invalid value '${t}', must be one of: ${s.join(", ")}`})}constructor(i){t(this,i),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,E(this),a(this),this.errors=l(this),this.componentStyle=k(this)}async getLayoutState(t){var i,s,e,n,r,o,h,a,l,c,u;const d=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",f=ei(this.element),v=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),p={version:li,tag:this.element.localName,id:ii(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:ti(this.element,f),em:{fontSizePx:v,appliedScaleFactor:1},regions:[],metadata:{nodeCount:null!==(n=null===(e=this.treeConfig)||void 0===e?void 0:e.allNodes.size)&&void 0!==n?n:0,edgeCount:null!==(o=null===(r=this.treeConfig)||void 0===r?void 0:r.edges.length)&&void 0!==o?o:0},diagnostics:Zt(this.element)},g=null===(h=this.element.shadowRoot)||void 0===h?void 0:h.querySelector(".tree-grid");if(g&&p.regions.push({id:"grid",rect:ti(g,f)}),"full"!==d||!this.treeConfig)return p;const m=[];for(const t of this.treeConfig.allNodes){const i=this.element.querySelector(`[slot="${t}"]`);if(!i)continue;const s={kind:"node",nodeId:t,rect:ti(i,f)};m.push(s)}const b=Array.from(null!==(l=null===(a=this.element.shadowRoot)||void 0===a?void 0:a.querySelectorAll("svg.edge-layer path"))&&void 0!==l?l:[]);let y=0;for(const t of this.treeConfig.edges){if(!this.nodeRects.get(t.from)||!this.nodeRects.get(t.to))continue;const i=b[y++];if(!i)break;const s={kind:"edge",from:t.from,to:t.to,operator:t.operator,path:null!==(c=i.getAttribute("d"))&&void 0!==c?c:void 0,rect:ti(i,f)};m.push(s)}return null===(u=this.element.shadowRoot)||void 0===u||u.querySelectorAll("svg.edge-layer g.operator-group").forEach((t=>{var i,s;const e=null!==(s=null===(i=t.textContent)||void 0===i?void 0:i.trim())&&void 0!==s?s:"";if(!e)return;const n={kind:"label",role:"operator",text:e,rect:ti(t,f)};m.push(n)})),p.elements=m,p}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,i,s;const e=null!==(i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelector(".tree-grid"))&&void 0!==i?i:null;if(e!==this.gridContainer&&(null===(s=this.resizeObserver)||void 0===s||s.disconnect(),this.observed.clear(),this.gridContainer=e),e){this.resizeObserver||(this.resizeObserver=new ResizeObserver((()=>{this.updateNodeRects()}))),this.parentObserver||(this.parentObserver=ss(this.element,(()=>this.checkOverflow())));for(const t of[e,...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,i,s,e){if(!t.rootNode)return{positions:new Map,gridTemplateColumns:"",gridTemplateRows:"",maxLevel:0,maxIndex:0};const n=function(t){const i=new Map;if(!t.rootNode)return i;const s=[{node:t.rootNode,level:0}],e=new Set;for(;s.length>0;){const{node:n,level:r}=s.shift();if(e.has(n))continue;e.add(n),i.set(n,r);const o=t.adjacencyList.get(n)||[];for(const t of o)e.has(t)||s.push({node:t,level:r+1})}return i}(t),r=function(t){const i=new Map;if(!t.rootNode)return i;let s=0;return function e(n){const r=i.get(n);if(r)return r;const o=t.adjacencyList.get(n)||[];if(i.set(n,{startIndex:s,endIndex:s}),0===o.length){const t={startIndex:s,endIndex:s};return i.set(n,t),s++,t}let h=1/0,a=-1/0;for(const t of o){const i=e(t);h=Math.min(h,i.startIndex),a=Math.max(a,i.endIndex)}const l={startIndex:h,endIndex:a};return i.set(n,l),l}(t.rootNode),i}(t),o=function(t,i,s,e){var n,r;const o=new Map,h=Math.max(...Array.from(i.values()));for(const a of t.allNodes){const l=null!==(n=i.get(a))&&void 0!==n?n:0,c=null!==(r=s.get(a))&&void 0!==r?r:{startIndex:0,endIndex:0};let u,d,f=1,v=1;const p=c.endIndex-c.startIndex+1,g=Array.from(t.allNodes).some((t=>{var e;const n=s.get(t);return t!==a&&void 0!==n&&(null!==(e=i.get(t))&&void 0!==e?e:0)===l&&n.startIndex<=c.endIndex&&c.startIndex<=n.endIndex})),m=g?1:p;switch(e){case"ltr":u=l+1,d=c.startIndex+1,f=p;break;case"rtl":u=h-l+1,d=c.startIndex+1,f=p;break;case"ttb":d=l+1,u=c.startIndex+1,v=m;break;case"btt":d=h-l+1,u=c.startIndex+1,v=m}o.set(a,{nodeId:a,level:l,index:c.startIndex,gridColumn:u,gridRow:d,gridRowSpan:f,gridColumnSpan:v})}return o}(t,n,r,i),h=Math.max(...Array.from(n.values())),a=Math.max(...Array.from(r.values()).map((t=>t.endIndex))),{gridTemplateColumns:l,gridTemplateRows:c}=function(t,i,s,e,n){const r=t+1,o=i+1;if("ltr"===s||"rtl"===s){const t=[];for(let i=0;i<r;i++)t.push("auto"),i<r-1&&t.push(`${e}px`);const i=[];for(let t=0;t<o;t++)i.push("auto"),t<o-1&&i.push(`${n}px`);return{gridTemplateColumns:t.join(" "),gridTemplateRows:i.join(" ")}}{const t=[];for(let i=0;i<r;i++)t.push("auto"),i<r-1&&t.push(`${e}px`);const i=[];for(let t=0;t<o;t++)i.push("auto"),t<o-1&&i.push(`${n}px`);return{gridTemplateColumns:i.join(" "),gridTemplateRows:t.join(" ")}}}(h,a,i,s,e);return{positions:o,gridTemplateColumns:l,gridTemplateRows:c,maxLevel:h,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 i=this.gridContainer.getBoundingClientRect(),s=new Map;for(const t of this.treeConfig.allNodes){const e=this.element.querySelector(`[slot="${t}"]`);e&&s.set(t,Kd(e,i))}(function(t,i){if(t.size!==i.size)return!1;for(const[s,e]of t){const t=i.get(s);if(!t||t.left!==e.left||t.top!==e.top||t.width!==e.width||t.height!==e.height)return!1}return!0})(this.nodeRects,s)||(this.nodeRects=s),this.svgWidth=i.width,this.svgHeight=i.height,this.checkOverflow()}checkOverflow(){var t,i;const s="WARN_overflow",e=Ut(this.element),n=(null===(t=this.gridContainer)||void 0===t?void 0:t.scrollWidth)||0,r=(null===(i=this.gridContainer)||void 0===i?void 0:i.scrollHeight)||0,o=[];e.width>0&&n>e.width+1&&o.push(`width (${Math.round(n)}px > ${Math.round(e.width)}px)`);const h=Ft(this.element,r);h>1&&o.push(`height (${Math.round(r)}px > ${Math.round(r-h)}px)`),0!==o.length?this.errors.addOrReplace({id:s,type:"warning",message:`Tree exceeds available ${o.join(" and ")} and will be cut off. Reduce level-spacing, node-spacing or the node content, or enlarge the container.`}):this.errors.remove(s)}getSlotStyle(t){if(!this.layout)return{};const i=this.layout.positions.get(t);return i?"ltr"===this.direction||"rtl"===this.direction?{"grid-column":String(Xd(i.gridColumn)),"grid-row":`${Jd(i.gridRow)} / span ${qd(i.gridRowSpan)}`,"align-self":"center"}:{"grid-row":String(Jd(i.gridRow)),"grid-column":`${Xd(i.gridColumn)} / span ${s=i.gridColumnSpan,qd(s)}`,"justify-self":"center"}:{};var s}renderEdges(){var t;if(!this.treeConfig||0===this.nodeRects.size)return null;const s=this.getTreeStyle(),e=[],n=[],r=new Map;for(const t of this.treeConfig.edges){const i=r.get(t.to)||[];i.push(t.from),r.set(t.to,i)}const o=new Map;for(const[t,i]of this.treeConfig.adjacencyList.entries()){const s=this.nodeRects.get(t),e=i.map((t=>this.nodeRects.get(t))).filter((t=>void 0!==t)),n=s?sf(s,e,this.direction):void 0;void 0!==n&&o.set(t,n)}for(const t of this.treeConfig.edges){const n=this.nodeRects.get(t.from),h=this.nodeRects.get(t.to);if(!n||!h)continue;const a=Qd(n,!0,this.direction),l=r.get(t.to)||[];let c;if(l.length>1){const i=l.indexOf(t.from);c=Zd(h,this.direction,i,l.length)}else c=Qd(h,!1,this.direction);const{path:u}=tf(a,c,this.edgeStyle,this.direction,o.get(t.from)),d=nf(s.edgeColor,s.edgeWidth,t.style);e.push(i("path",{key:`edge-${t.from}-${t.to}`,d:u,fill:"none",stroke:d.stroke,"stroke-width":d.strokeWidth,"stroke-dasharray":d.strokeDasharray}))}if(this.showOperators)for(const[e,r]of this.treeConfig.adjacencyList.entries()){const h=o.get(e);if(void 0!==h)for(let o=0;o<r.length-1;o++){const a=r[o],l=r[o+1],c=Vd(this.treeConfig.edges,e,a);if(!(null==c?void 0:c.operator)||"none"===c.operator)continue;const u=this.nodeRects.get(a),d=this.nodeRects.get(l);if(!u||!d)continue;const f=null!==(t=c.label)&&void 0!==t?t:Hd(c.operator),v=ef(h,u,d,this.direction);n.push(i("g",{key:`operator-${e}-${a}`,class:"operator-group"},i("circle",{cx:v.x,cy:v.y,r:s.operatorCircleRadius,fill:"white",stroke:s.edgeColor,"stroke-width":s.edgeWidth}),i("text",{x:v.x,y:v.y,"text-anchor":"middle","dominant-baseline":"central",style:{fontSize:`${s.operatorFontSize}px`,fill:s.operatorColor,fontWeight:"bold"}},f)))}}return i("svg",{class:"edge-layer",width:this.svgWidth,height:this.svgHeight,style:{position:"absolute",top:"0",left:"0",pointerEvents:"none"}},e,n)}renderSlots(){return this.treeConfig&&this.layout?Array.from(this.treeConfig.allNodes).map((t=>i("div",{key:t,class:"tree-node",style:this.getSlotStyle(t)},i("slot",{name:t})))):null}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles();return i(s,{style:t},this.treeConfig&&this.layout?i("div",{class:"tree-container"},i("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())):i("div",{class:"tree-container tree-error"},i("slot",null)))}get element(){return e(this)}static get watchers(){return{edges:[{validateEdgesProp:0}],direction:[{validateDirection:0}],levelSpacing:[{validateLevelSpacing:0}],nodeSpacing:[{validateNodeSpacing:0}],edgeStyle:[{validateEdgeStyle:0}]}}};rf.style=':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}';export{Ri as bn_annotation_layer,Ni as bn_annotation_list,Li as bn_asset,Ei as bn_body,Ti as bn_card,Os as bn_chart_bubble,Na as bn_chart_bubble_renderer,Ua as bn_chart_bullet,Xa as bn_chart_bullet_renderer,qa as bn_chart_scatter,tl as bn_chart_scatter_renderer,il as bn_chart_structure,Fl as bn_chart_structure_renderer,Gl as bn_chart_time,xc as bn_chart_time_renderer,Sc as bn_component_style,Lc as bn_context,uu as bn_dataset,du as bn_datasource,fu as bn_footer,$u as bn_layout_card,Mu as bn_layout_page,_u as bn_message,Ou as bn_page,ku as bn_scaling_group,zu as bn_table,Ld as bn_table_renderer,Cd as bn_title,Yd as bn_title_renderer,rf as bn_tree}
1
+ import{r as t,h as i,a as s,g as e,f as n,d as r,F as o}from"./p-CCZcKl0Q.js";import{S as h,w as a,a as l,g as c,C as u,r as d,c as f,h as v,d as p,e as g,X as m,i as b,D as y,j as w,m as x,s as S,k as $,l as M,u as _,n as O}from"./p-D0tNATZq.js";import{a as k,m as A,C as R,i as N,b as L,w as E,c as T,r as C,s as P,d as W,e as D,f as z,v as U,g as F,A as G,O as j,h as I,j as Y,k as B,l as H,n as V,o as X,p as J,S as q,q as K,t as Q,u as Z,x as tt,N as it,y as st,z as et,B as nt,D as rt,E as ot,F as ht,G as at,H as lt,R as ct,I as ut,J as dt,K as ft,L as vt,M as pt,P as gt,Q as mt,T as bt,U as yt,V as wt,W as xt,X as St,Y as $t,Z as Mt,_ as _t,$ as Ot,a0 as kt,a1 as At,a2 as Rt,a3 as Nt,a4 as Lt,a5 as Et,a6 as Tt,a7 as Ct,a8 as Pt,a9 as Wt,aa as Dt}from"./p-BVU4bIsi.js";import{s as zt,g as Ut,b as Ft,i as Gt,f as jt,r as It,a as Yt,w as Bt,p as Ht,c as Vt,d as Xt,e as Jt,h as qt,j as Kt}from"./p-DyupX-Z-.js";import{w as Qt}from"./p-DF9sfwBN.js";import{r as Zt,m as ti,a as ii,l as si,o as ei,b as ni,c as ri,t as oi,d as hi,e as ai}from"./p-qpZjVnX5.js";import{LAYOUT_STATE_VERSION as li}from"./index.esm.js";import{e as ci,r as ui}from"./p-ClruFZD_.js";const di=/^[a-z][a-z0-9-]*$/i;function fi(t,i){var s,e;const n=null!==(s=null==i?void 0:i.color)&&void 0!==s?s:h["bn-annotation"].color,r=null!==(e=null==i?void 0:i.colors)&&void 0!==e?e:{},o=`var(--bn-annotation-color, ${n})`;if(!t||!di.test(t))return o;const a=Object.prototype.hasOwnProperty.call(r,t)?r[t]:void 0;return`var(--bn-annotation-color-${t}, ${null!=a?a:o})`}const vi=t=>"string"==typeof t||"number"==typeof t?String(t):void 0;function pi(t){if(null==t||""===t.trim())return[];try{const i=JSON.parse(t);if(Array.isArray(i)&&i.every((t=>null!==t&&"object"==typeof t)))return i}catch(t){}}const gi=new WeakMap;let mi=1;function bi(t){const i=t.closest("bn-layout-page");if(!i)return"";let s=gi.get(i);return s||(s="page-"+mi++,gi.set(i,s)),s}const yi=t=>({x:t.x+t.width/2,y:t.y+t.height/2});function wi(t,i){const s=yi(t),e=i.x-s.x,n=i.y-s.y,r=Math.min(0===e?1/0:t.width/2/Math.abs(e),0===n?1/0:t.height/2/Math.abs(n));return Number.isFinite(r)?{x:s.x+e*r,y:s.y+n*r}:s}function xi(t,i){return i?Object.assign(Object.assign({},t),{cx:Math.max(t.r,Math.min(t.cx,i.width-t.r)),cy:Math.max(t.r,Math.min(t.cy,i.height-t.r))}):t}const Si=(t,i)=>t.x<i.x+i.width&&i.x<t.x+t.width&&t.y<i.y+i.height&&i.y<t.y+t.height;function $i(t,i,s,e){var n,r,o;const h=.25*s,a=t.y+t.height/2,l=null!==(n=e.obstacles)&&void 0!==n?n:[],c=t=>{const s={x:t-i,y:a-i,width:2*i,height:2*i},n=e.area;return(!n||s.x>=0&&s.x+s.width<=n.width)&&!l.some((t=>Si(s,t)))},u=t.x+t.width,d=t.x-h-i,f=u+h+i;if(c(d))return{x:d,y:a,r:i};if(c(f))return{x:f,y:a,r:i};const v=2*(i+h),p=l.filter((t=>t.y<a&&t.y+t.height>a)),g=Math.max(0,t.x-v,...p.filter((i=>i.x+i.width<=t.x)).map((t=>t.x+t.width))),m=Math.min(null!==(o=null===(r=e.area)||void 0===r?void 0:r.width)&&void 0!==o?o:1/0,u+v,...p.filter((t=>t.x>=u)).map((t=>t.x))),b=t.x-g,y=m-u,w=Math.max(b,y);return{x:y>=b?u+y/2:t.x-b/2,y:a,r:Math.min(i,Math.max(w/2,.3*s))}}function Mi(t,i,s,e,n={}){var r;const{label:o,color:h}=t,{whole:a,area:l,text:c}=n,u=!a&&!c&&null!=n.obstacles,d=((t,i)=>t?Math.min(i,t.height/1.3):i)(null!=c?c:u?i:void 0,e);if("arrow"===t.mark){if(!s)return;const t=yi(i),n=yi(s);if(t.x===n.x&&t.y===n.y)return;let r=wi(i,n),a=wi(s,t);(a.x-r.x)*(n.x-t.x)+(a.y-r.y)*(n.y-t.y)<=0&&(r=t,a=n);const c=Math.hypot(a.x-r.x,a.y-r.y),u=Math.min(.8*e,c),d=(a.x-r.x)/c,f=(a.y-r.y)/c,v=a.x-d*u,p=a.y-f*u,g=.35*e;return{kind:"arrow",color:h,x1:r.x,y1:r.y,x2:v,y2:p,head:[`${a.x},${a.y}`,`${v-f*g},${p+d*g}`,`${v+f*g},${p-d*g}`].join(" "),badge:null!=o?xi({cx:r.x,cy:r.y,r:.65*e,label:o},l):void 0}}if("frame"===t.mark){const s=null!=c?c:i,n=null===(r=t.point)||void 0===r?void 0:r.part,u=!a&&(null!=c||"label"===n||"total"===n),f=(u?.45:.2)*d,v=(u?.1:.2)*d,p=u?Math.max(s.width,s.height):s.width,g=s.x+s.width/2,m=1,b=Math.max(l?m:-1/0,g-p/2-f),y=Math.max(l?m:-1/0,s.y-v),w=Math.min(l?l.width-m:1/0,g+p/2+f),x=Math.min(l?l.height-m:1/0,s.y+s.height+v),S=Math.min(w-b,x-y)/2,$=a?.25*e:S,M=a?.25*e:u?Math.min((w-b)/2,1.6*S):S,_=1-Math.SQRT1_2,O=.65*d,k=u?.6*O:0;return{kind:"frame",color:h,x:b,y,width:w-b,height:x-y,rx:M,ry:$,badge:null!=o?xi({cx:w-M*_+k,cy:y+$*_-k,r:O,label:o},l):void 0}}if(c&&!a){const t=$i(c,(null==o?.4:.65)*d,d,n);return{kind:"marker",color:h,badge:xi({cx:t.x,cy:t.y,r:t.r,label:o},l)}}const f=(null==o?.4:.75)*d,v=u?Math.min(f,i.height/2):f,p=a?{x:i.x+i.width-v,y:i.y+v}:yi(i);if(u){const t={x:p.x-v,y:p.y-v,width:2*v,height:2*v},i=n.obstacles.find((i=>Si(t,i)));if(i){const t=$i(i,v,d,n);return{kind:"marker",color:h,badge:xi({cx:t.x,cy:t.y,r:t.r,label:o},l)}}}return{kind:"marker",color:h,badge:xi({cx:p.x,cy:p.y,r:v,label:o},l)}}const _i=["rowGroup","category","subCategory","date","scenario","row"];function Oi(t,i){const s=i.getBoundingClientRect();if(0===s.width||0===s.height)return!0;const e=t.x+t.width/2,n=t.y+t.height/2;return e>=s.left&&e<=s.right&&n>=s.top&&n<=s.bottom}const ki=new Set(["bn-asset","bn-component-style","bn-dataset","bn-datasource","bn-internationalization","bn-ruleset","bn-scaling-group"]);function Ai(t,i){const s=i.getBoundingClientRect();return 0===s.width||0===s.height||t.x<s.right&&t.x+t.width>s.left&&t.y<s.bottom&&t.y+t.height>s.top}const Ri=class{constructor(i){t(this,i),this.marks=[],this.pageKey="",this.parsedItems=[],this.scheduled=!1,this.run=0,this.observed=new WeakSet,this.reported=new Set,this.schedule=()=>{this.scheduled||(this.scheduled=!0,this.holdStatus(new Promise((t=>{requestAnimationFrame((()=>{this.scheduled=!1,this.place().catch((t=>console.error("bn-annotation-layer: placing the marks failed",t))).finally(t)}))}))))},this.holdStatus=a(this),this.errors=l(this),this.componentStyle=k(this)}connectedCallback(){var t;this.stores=c(this.element),this.pageKey=bi(this.element),this.observed=new WeakSet,this.resizeObserver=new ResizeObserver(this.schedule),this.mutationObserver=new MutationObserver(this.schedule),this.observeSize(this.element);const i=this.element.closest("bn-layout-page");i&&this.mutationObserver.observe(i,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["slot","data-bino-annotation-target"]}),null===(t=document.fonts)||void 0===t||t.addEventListener("loadingdone",this.schedule)}disconnectedCallback(){var t,i,s,e;null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(i=this.mutationObserver)||void 0===i||i.disconnect(),null===(s=document.fonts)||void 0===s||s.removeEventListener("loadingdone",this.schedule),this.run++,(null===(e=this.stores)||void 0===e?void 0:e.annotationsUnplaced.state[this.pageKey])&&this.stores.annotationsUnplaced.set(this.pageKey,void 0)}componentWillLoad(){this.parseItems()}componentDidLoad(){this.schedule()}onItemsChange(){this.parseItems(),this.schedule()}parseItems(){const t=function(t){var i;return null===(i=pi(t))||void 0===i?void 0:i.map((t=>{var i;return Object.assign(Object.assign({},t),{label:vi(t.label),color:vi(t.color),target:null!==(i=vi(t.target))&&void 0!==i?i:"",to:vi(t.to)})}))}(this.items);t?this.errors.remove("ERR_items"):this.errors.addOrReplace({id:"ERR_items",type:"error",message:"items: not a JSON array of objects."}),this.parsedItems=null!=t?t:[]}async place(){var t;const i=++this.run;if(!this.element.isConnected||!this.svg)return;const s=this.element.closest("bn-layout-page"),e=new Map,n=new Map;null==s||s.querySelectorAll("[data-bino-annotation-target]").forEach((t=>{const i=Array.from(t.querySelectorAll("*")).find((t=>t.localName.startsWith("bn-")&&!ki.has(t.localName))),s=null!=i?i:t;e.set(t.getAttribute("data-bino-annotation-target"),s),n.set(s,t)})),null==s||s.querySelectorAll("[slot]").forEach((t=>this.observeSize(t)));const r=new Set(this.parsedItems.flatMap((t=>[t.target,t.to]))),o=[...e].filter((([t])=>r.has(t))).map((([,t])=>t));if(await Promise.all(o.map((t=>{var i;return null===(i=t.componentOnReady)||void 0===i?void 0:i.call(t)}))),i!==this.run)return;o.forEach((t=>this.observe(t)));const h=new Map;if(await Promise.all(o.map((async t=>{var i;h.set(t,await(null===(i=t.getLayoutState)||void 0===i?void 0:i.call(t,{detail:"full"}).catch((()=>{}))))}))),i!==this.run)return;const a=(t,i)=>{var s;const r=null!=t?e.get(t):void 0;if(!r)return{problem:`no target "${t}" on this page`};const o=r.getBoundingClientRect();if(function(t){return!t||_i.every((i=>null==t[i]))&&null==t.part}(i)){const i={x:o.left,y:o.top,width:o.width,height:o.height};return function(t,i,s){if(0===t.width||0===t.height||!Ai(t,s))return!0;for(let s=i;s&&"bn-layout-page"!==s.localName;s=s.parentElement)if(!Ai(t,s))return!0;return!1}(i,n.get(r),this.element)?{problem:`"${t}" cannot be seen`}:{box:i,whole:!0}}const a=h.get(r),l=a?function(t,i){var s;const e=t.table&&null==i.scenario?t.table.rows:null!==(s=t.elements)&&void 0!==s?s:[],n=null!=t.table&&null==i.subCategory;return e.filter((t=>function(t,i){var s;return!(!t||t.part!==(null!==(s=i.part)&&void 0!==s?s:"element"))&&_i.every((s=>null==i[s]||String(i[s])===t[s]))}(t.point,i)&&!(n&&null!=t.point.subCategory))).map((({rect:t,content:i,contentSign:s})=>({rect:t,content:i,contentSign:s})))}(a,i):[];if(1!==l.length)return{problem:`${l.length} elements match the point ${JSON.stringify(i)} in "${t}"`};const c=({component:{x:t,y:i,width:s,height:e}})=>({x:o.left+t,y:o.top+i,width:s,height:e}),u=c(l[0].rect);if(function(t,i){for(let s=i;s&&"bn-layout-page"!==s.localName;s=s.parentElement)if(!Oi(t,s))return!0;return!1}(u,n.get(r))||!Oi(u,this.element))return{problem:`the point ${JSON.stringify(i)} in "${t}" is cut off`};const d=l[0].content;if(!a.table)return{box:u,whole:!1};const f=(null!==(s=a.elements)&&void 0!==s?s:[]).flatMap((t=>"cell"===t.kind&&t.content?[{box:c(t.content),sign:t.contentSign}]:[]));return{box:u,whole:!1,text:d&&{box:c(d),sign:l[0].contentSign},obstacles:f}},l=this.toLocalSpace(),c=({box:t,sign:i=0})=>{const s=l(t);return Object.assign(Object.assign({},s),{x:s.x-i,width:s.width+i})},u=parseFloat(getComputedStyle(this.svg).fontSize)||13.3333,d={width:this.element.clientWidth,height:this.element.clientHeight},f=[],v=[];for(const i of this.parsedItems){const s=a(i.target,i.point),e="arrow"===i.mark?a(i.to,i.toPoint):void 0,n="problem"in s?s:e&&"problem"in e?e:void 0;if(n){v.push({item:i,problem:n.problem});continue}const r=s,o=e,h=Mi(i,l(r.box),o&&l(o.box),u,{whole:r.whole,area:d,text:r.text&&c(r.text),obstacles:null===(t=r.obstacles)||void 0===t?void 0:t.map(c)});h?f.push(h):v.push({item:i,problem:"an arrow needs two ends at different places"})}this.marks=f,this.storeUnplaced(v.flatMap((({item:t})=>null!=t.label?[t.label]:[]))),v.length>0&&this.reportWhenQuiet(i,v)}async reportWhenQuiet(t,i){let s=0;for(let i=0;i<50&&s<2;i++){if(await new Promise((t=>window.setTimeout(t,200))),t!==this.run)return;s=0===u.componentRegisterStatus().running?s+1:0}this.report(i)}report(t){var i,s;for(const{item:e,problem:n}of t){const t=`bn-annotation-layer: ${null!==(i=e.mark)&&void 0!==i?i:"marker"} ${null!==(s=e.label)&&void 0!==s?s:"without a number"} is not drawn: ${n}.`;this.reported.has(t)||(this.reported.add(t),console.warn(t))}}toLocalSpace(){var t;const i=null===(t=this.svg.getScreenCTM())||void 0===t?void 0:t.inverse();return t=>{if(!i)return t;const s=[[t.x,t.y],[t.x+t.width,t.y+t.height]].map((([t,s])=>new DOMPoint(t,s).matrixTransform(i)));return{x:Math.min(s[0].x,s[1].x),y:Math.min(s[0].y,s[1].y),width:Math.abs(s[1].x-s[0].x),height:Math.abs(s[1].y-s[0].y)}}}storeUnplaced(t){var i,s;const e=null===(i=this.stores)||void 0===i?void 0:i.annotationsUnplaced,n=null!==(s=null==e?void 0:e.state[this.pageKey])&&void 0!==s?s:[];e&&JSON.stringify(n)!==JSON.stringify(t)&&e.set(this.pageKey,t)}observe(t){this.observeSize(t);const i=t=>{var s;t&&(this.observed.has(t)||(this.observed.add(t),null===(s=this.mutationObserver)||void 0===s||s.observe(t,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["x","y","width","height","transform","style","class"]})),t.querySelectorAll("*").forEach((t=>i(t.shadowRoot))))};i(t.shadowRoot)}observeSize(t){var i;this.observed.has(t)||(this.observed.add(t),null===(i=this.resizeObserver)||void 0===i||i.observe(t))}renderBadge(t,s){return t?i("g",null,i("circle",{cx:t.cx,cy:t.cy,r:t.r,style:{fill:s}}),null!=t.label?i("text",{class:"badge-text",x:t.cx,y:t.cy,style:{fontSize:1.1*t.r+"px"}},t.label):null):null}renderMark(t){var s,e;const n=fi(t.color,this.componentStyle((t=>t["bn-annotation"])));return"marker"===t.kind?i("g",{class:"mark marker","data-label":t.badge.label},this.renderBadge(t.badge,n)):"frame"===t.kind?i("g",{class:"mark frame","data-label":null===(s=t.badge)||void 0===s?void 0:s.label},i("rect",{x:t.x,y:t.y,width:t.width,height:t.height,rx:t.rx,ry:t.ry,style:{fill:"none",stroke:n,strokeWidth:"1.5"}}),this.renderBadge(t.badge,n)):i("g",{class:"mark arrow","data-label":null===(e=t.badge)||void 0===e?void 0:e.label},i("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,style:{stroke:n,strokeWidth:"1.5"}}),i("polygon",{points:t.head,style:{fill:n}}),this.renderBadge(t.badge,n))}render(){return i(s,{key:"05ca564aeeaf190a45cd42020b307891990e04fe"},i("svg",{key:"995c55b16803107766bf2c394d8d799c0de5765d",ref:t=>this.svg=t},this.marks.map((t=>this.renderMark(t)))))}get element(){return e(this)}static get watchers(){return{items:[{onItemsChange:0}]}}};Ri.style=':host{position:absolute;inset:0;z-index:1;display:block;pointer-events:none;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px)}svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}.badge-text{fill:#ffffff;font-weight:bold;text-anchor:middle;dominant-baseline:central}';const Ni=class{constructor(i){t(this,i),this.pageKey="",a(this),this.errors=l(this),this.componentStyle=k(this)}connectedCallback(){this.stores=c(this.element),this.pageKey=bi(this.element),this.unsubscribe=this.stores.annotationsUnplaced.on("set",(t=>{t===this.pageKey&&n(this.element)})),n(this.element)}disconnectedCallback(){var t;null===(t=this.unsubscribe)||void 0===t||t.call(this)}render(){var t,e;const n=function(t){var i;return null===(i=pi(t))||void 0===i?void 0:i.map((t=>({label:vi(t.label),title:vi(t.title),html:vi(t.html)})))}(this.items);n?this.errors.remove("ERR_items"):this.errors.addOrReplace({id:"ERR_items",type:"error",message:"items: not a JSON array of objects."});const r=fi(void 0,this.componentStyle((t=>t["bn-annotation"]))),o=null!==(e=null===(t=this.stores)||void 0===t?void 0:t.annotationsUnplaced.state[this.pageKey])&&void 0!==e?e:[];return i(s,{key:"69a1cb7ec4623dd722328638b93fa2ac05775dcf"},i("ol",{key:"cc7925db54a9015cd774242487967e25d0eb1dc0"},(null!=n?n:[]).map((t=>i("li",null,null==t.label||o.includes(t.label)?null!=t.label?i("div",{class:"badge-space"}):null:i("div",{class:"badge",style:{background:r}},i("span",null,t.label)),i("div",{class:"text"},t.title?i("span",{class:"title"},t.title," "):null,t.html?i("span",{innerHTML:zt(t.html)}):null))))))}get element(){return e(this)}};Ni.style=':host{display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}ol{margin:0;padding:0;list-style:none}li{display:flex;gap:0.5em;margin-bottom:0.6em;align-items:flex-start}.badge-space{flex:none;width:1.5em;height:1.5em}.badge{flex:none;display:flex;align-items:center;justify-content:center;width:1.5em;height:1.5em;border-radius:50%;color:#ffffff;font-weight:bold;line-height:1}.badge span{font-size:0.825em}.title{font-weight:bold}';const Li=class{constructor(i){t(this,i),a(this),this.errors=l(this),Qt(this,(t=>{this.stores||(this.stores=c(this.element));try{const i=t.replace(/\s/g,"");this.stores.assets.set(this.name,i)}catch(i){console.error("Error parsing asset",i,t),this.stores.assets.set(this.name,void 0)}}))}render(){return i(s,{key:"9df81e3697e02833b8cb1fad7ea06a5f446852be"})}get element(){return e(this)}};Li.style=":host{display:none}";const Ei=class{constructor(i){t(this,i),a(this),this.errors=l(this),this.componentStyle=k(this)}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){return i(s,{key:"fb9799f1ea3fadbf10dbc88aa668cad9d3e63853",style:this.getFontStyles()},i("slot",{key:"e08e29cdcac02cdd5caab034b0398b78de8951bf"}))}get element(){return e(this)}};Ei.style=':host{flex:1;min-height:0;position:relative;overflow:hidden;display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}';const Ti=class{constructor(i){t(this,i),a(this),this.errors=l(this),this.componentStyle=k(this)}render(){return i(s,{key:"66b35f747b56462ca898e7f475edf580eeb5edc0",style:this.prepareStyle()},i("slot",{key:"deaa11cb68cffbdba8b6a4508417c32c0a949d6b"}))}prepareStyle(){return{"font-family":this.componentStyle((t=>t.global.fontFamily)),"font-size":`${this.componentStyle((t=>t.global.fontSizePx))}px`,"--bn-font-family":this.componentStyle((t=>t.global.fontFamily))||"'Noto Sans', sans-serif","--bn-font-size":`${this.componentStyle((t=>t.global.fontSizePx))||13.3333}px`,"--bn-font-color":this.componentStyle((t=>t.global.fontColor))||"#000000","--bn-font-background":this.componentStyle((t=>t.global.fontBackgroundColor))||"#ffffff"}}get element(){return e(this)}};function Ci(t){if("function"==typeof getComputedStyle){const i=parseFloat(getComputedStyle(t).fontSize);if(Number.isFinite(i)&&i>0)return i}return h.global.fontSizePx}function Pi(t,i){var s;return{version:li,tag:t.localName,id:ii(t),slot:null!==(s=t.getAttribute("slot"))&&void 0!==s?s:void 0,rect:ti(t,i),em:{fontSizePx:Ci(t),appliedScaleFactor:1},regions:[],metadata:{},diagnostics:Zt(t)}}Ti.style=':host{display:flex;flex-direction:column;justify-content:space-between;flex:1;min-height:0;padding:0.25em;margin:0.5em;background-origin:content-box;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}:host(.border){box-sizing:border-box;-webkit-box-sizing:border-box;border:0.1em solid #ddd}div{color:var(--bn-font-color, black)}';const Wi="data-bn-baseline",Di=t=>Math.round(100*t)/100;function zi(t,i){const s=t.querySelector(`[${Wi}]`),e=null!=s?s:t.querySelector('g[id="axis"] line');if(!e)return{};const n=si(i);return"frame"===e.getAttribute(Wi)?function(t,i){const s=i.toLocal(t.getBoundingClientRect());return{x:Di(s.x),y:Di(s.y+s.height)}}(e,n):function(t,i){const s=i.toLocal(t.getBoundingClientRect());return s.width>=s.height?{x:Di(s.x),y:Di(s.y+s.height/2)}:{x:Di(s.x+s.width/2),y:Di(s.y)}}(e,n)}function Ui(t,i){var s,e,n;const r=null===(n=null===(e=null===(s=t.shadowRoot)||void 0===s?void 0:s.querySelector(i))||void 0===e?void 0:e.shadowRoot)||void 0===n?void 0:n.querySelector("svg#drawCanvas");return r?zi(r,t):{}}const Fi=[["rowGroup","data-bn-row-group"],["category","data-bn-category"],["subCategory","data-bn-sub-category"],["date","data-bn-date"],["scenario","data-bn-scenario"],["row","data-bn-row"]],Gi="data-bn-part";function ji(t,i){const s={};if(!t)return s;for(const[i,e]of Fi){const n=t[i];null!=n&&""!==n&&(s[e]=String(n))}return i&&(s[Gi]=i),s}function Ii(t){const i=t.getAttribute(Gi);if(!i)return;const s={part:i};for(const[i,e]of Fi){const n=t.getAttribute(e);null!=n&&(s[i]=n)}return s}function Yi(t){if(!t)return;const i=/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})/.exec(t);return i?"00:00:00"===i[2]?i[1]:`${i[1]}T${i[2]}`:t}function Bi(t,i){return null==i?{}:t.startsWith("rowGroup")?{rowGroup:String(i)}:t.startsWith("subCategory")?{subCategory:String(i)}:{category:String(i)}}const Hi=/^Scenario([1-4])$/,Vi=/^stacked_(?:col|bar)_(\d+)_seg_\d+$/,Xi='g[id^="stacked_col_"], g[id^="stacked_bar_"]';function Ji(t,i){var s;let e=t.parentElement;for(;e&&e!==i;){const t=Hi.exec(null!==(s=e.id)&&void 0!==s?s:"");if(t)return`scenario${t[1]}`;e=e.parentElement}}function qi(t){if(""===t)return;const i=Number(t.split("_")[0]);return Number.isFinite(i)?i:void 0}function Ki(t){const i=t.getAttribute("data-bn-index");return null===i?void 0:Number(i)}function Qi(t,i){var s;return(null!==(s=t.getAttribute("class"))&&void 0!==s?s:"").split(/\s+/).includes(i)}function Zi(t,i,s,e,n){var r,o;const h={regions:[],barCount:0,baseline:{}},a=[];return Array.from(null!==(o=null===(r=t.shadowRoot)||void 0===r?void 0:r.querySelectorAll(i))&&void 0!==o?o:[]).forEach(((i,r)=>{var o,l,c,u;const d=null!==(o=s[r])&&void 0!==o?o:`segment${r}`,f=null===(l=i.shadowRoot)||void 0===l?void 0:l.querySelector("svg#drawCanvas");if(f&&(h.regions.push({id:`canvas:${d}`,rect:ti(f,e)}),0===r&&(h.barCount=function(t){const i=t.querySelector('g[id="Scenario1"]');if(i)return Array.from(i.children).filter((t=>{var i;return/^\d+$/.test(null!==(i=t.id)&&void 0!==i?i:"")})).length;const s=new Set;return t.querySelectorAll(Xi).forEach((t=>{const i=Vi.exec(t.id);i&&t.querySelector("rect")&&s.add(i[1])})),s.size}(f),h.baseline=zi(f,t)),"full"===n&&a.push(...function(t,i,s){const e=[],n=new Set;return t.querySelectorAll('g[id$="_RECT"]').forEach(((r,o)=>{var h;n.add(r);const a={kind:"bar",id:r.id,segment:i,scenario:Ji(r,t),index:null!==(h=qi(r.id))&&void 0!==h?h:o,rect:ti(r,s),point:Ii(r)};e.push(a)})),t.querySelectorAll(Xi).forEach((t=>{var r,o,h;const a=Vi.exec(t.id);if(!a||!t.querySelector("rect"))return;n.add(t);const l=Ii(t),c={kind:"bar",id:t.id,segment:i,scenario:`stack:${null!==(h=null!==(o=null!==(r=null==l?void 0:l.scenario)&&void 0!==r?r:null==l?void 0:l.subCategory)&&void 0!==o?o:null==l?void 0:l.category)&&void 0!==h?h:""}`,index:Number(a[1]),rect:ti(t,s),point:l};e.push(c)})),["DATA","SCENARIO"].forEach((r=>{t.querySelectorAll(`g[id$="_${r}_Label"]`).forEach(((t,o)=>{var h,a,l;if(Qi(t,"hide"))return;const c=null!==(a=null===(h=t.textContent)||void 0===h?void 0:h.trim())&&void 0!==a?a:"";if(!c)return;n.add(t);const u={kind:"label",id:t.id,role:"DATA"===r?"data":"scenario",text:c,segment:i,index:null!==(l=qi(t.id))&&void 0!==l?l:o,rect:ti(t,s),point:Ii(t)};e.push(u)}))})),t.querySelectorAll("[data-bn-part]").forEach(((r,o)=>{var h,a,l;if(n.has(r))return;const c=Ii(r),u=null!==(h=Ki(r))&&void 0!==h?h:function(t,i){var s;for(let e=t;e&&e!==i;e=e.parentElement){const t=qi(null!==(s=e.id)&&void 0!==s?s:"");if(void 0!==t)return t}}(r,t);if("element"===c.part){const t={kind:"point",series:c.scenario,index:null!=u?u:o,rect:ti(r,s),point:c};return void e.push(t)}const d={kind:"label",id:r.id||void 0,role:"data",text:null!==(l=null===(a=r.textContent)||void 0===a?void 0:a.trim())&&void 0!==l?l:"",segment:i,index:u,rect:ti(r,s),point:c};e.push(d)})),t.querySelectorAll('g[id="axis"] line').forEach((t=>{var n;const r=(null!==(n=t.getAttribute("class"))&&void 0!==n?n:"").split(/\s+/).find((t=>t.startsWith("axis-"))),o=ti(t,s),h={kind:"axis",style:null==r?void 0:r.slice(5),orientation:o.context.width>=o.context.height?"horizontal":"vertical",segment:i,rect:o};e.push(h)})),t.querySelectorAll('g[id="AxisAndDateLables"] text, g[id="AxisAndDateLabelsLine"] text').forEach((n=>{var r,o;if(Qi(n,"hide")||function(t,i){var s;let e=t.parentElement;for(;e&&e!==i;){if((null!==(s=e.id)&&void 0!==s?s:"").endsWith("_Label"))return!0;e=e.parentElement}return!1}(n,t))return;const h=null!==(o=null===(r=n.textContent)||void 0===r?void 0:r.trim())&&void 0!==o?o:"";if(!h)return;const a={kind:"label",role:Qi(n,"categories")?"title":"category",text:h,segment:i,rect:ti(n,s)};e.push(a)})),e}(f,d,e))),"full"===n){const t=null===(c=i.shadowRoot)||void 0===c?void 0:c.querySelector(".footer"),s=null===(u=null==t?void 0:t.textContent)||void 0===u?void 0:u.trim();s&&a.push({kind:"label",role:"footer",text:s,segment:d,rect:ti(t,e)})}})),"full"===n&&(h.elements=a),h}function ts(t,i,s,e,n,r){var o,h,a,l;const c={version:li,tag:t.localName,id:ii(t),slot:null!==(o=t.getAttribute("slot"))&&void 0!==o?o:void 0,rect:ti(t,n),em:e,regions:[],metadata:{title:s},diagnostics:Zt(t)},u=null===(l=null===(a=null===(h=t.shadowRoot)||void 0===h?void 0:h.querySelector(i))||void 0===a?void 0:a.shadowRoot)||void 0===l?void 0:l.querySelector("svg#drawCanvas");return u&&(c.regions.push({id:"canvas",rect:ti(u,n)}),c.metadata.pointCount=u.querySelectorAll("circle, ellipse").length,c.baseline=zi(u,t),"full"===r&&(c.elements=function(t,i){const s=[];return t.querySelectorAll("circle, ellipse").forEach(((t,e)=>{const n={kind:"point",index:e,rect:ti(t,i),point:Ii(t)};s.push(n)})),t.querySelectorAll('rect[data-bn-part="element"]').forEach(((t,e)=>{var n;const r=Ii(t),o={kind:"bar",segment:"base",scenario:null==r?void 0:r.scenario,index:null!==(n=Ki(t))&&void 0!==n?n:e,rect:ti(t,i),point:r};s.push(o)})),t.querySelectorAll("text").forEach((t=>{var e,n;const r=null!==(n=null===(e=t.textContent)||void 0===e?void 0:e.trim())&&void 0!==n?n:"";if(!r)return;const o={kind:"label",role:"data",text:r,rect:ti(t,i),point:Ii(t)};s.push(o)})),s}(u,n))),c}function is(t,i,s){var e,n,r,o,h;const a="WARN_overflow",l=Ut(t),c=parseFloat(null!==(h=null===(o=null===(r=null===(n=null===(e=t.shadowRoot)||void 0===e?void 0:e.querySelector(i))||void 0===n?void 0:n.shadowRoot)||void 0===r?void 0:r.querySelector("svg#drawCanvas"))||void 0===o?void 0:o.getAttribute("height"))&&void 0!==h?h:""),u=Math.max(Number.isNaN(c)?0:Math.floor(c),t.scrollHeight||0),d=t.scrollWidth||0,f=[];l.width>0&&d>l.width+1&&f.push(`width (${Math.round(d)}px > ${Math.round(l.width)}px)`);const v=Ft(t,u);v>1&&f.push(`height (${Math.round(u)}px > ${Math.round(u-v)}px)`),0!==f.length?s.addOrReplace({id:a,type:"warning",message:`Chart exceeds available ${f.join(" and ")} and will be cut off. Check the scale and aspect values or enlarge the container.`}):s.remove(a)}function ss(t,i,s=80){let e=null,n=!1,r=-1,o=-1;const h=function(t){var i;const s=t.parentElement;return(null===(i=null==s?void 0:s.assignedSlot)||void 0===i?void 0:i.parentElement)?s.assignedSlot.parentElement:s}(t);if(!h)return{disconnect(){}};const a=new ResizeObserver((t=>{var a;if(n)return;let l,c;const u=t[0];if(null===(a=null==u?void 0:u.contentBoxSize)||void 0===a?void 0:a.length){const t=u.contentBoxSize[0];l=t.inlineSize,c=t.blockSize}else l=h.clientWidth,c=h.clientHeight;Math.abs(l-r)<=2&&Math.abs(c-o)<=2||(r=l,o=c,null!=e&&clearTimeout(e),e=setTimeout((()=>{n||i()}),s))}));return a.observe(h),{disconnect(){n=!0,null!=e&&clearTimeout(e),a.disconnect()}}}const es=t=>{let i,s,r,o,h,a=null;const l=()=>{const t=s.ruleSets.state;h=A([t._default||{},t[r]||{}]),o=A([t._system||{},h])},u=()=>{const i=e(t),s=i.getAttribute("ruleset");if(a&&(a.disconnect(),a=null),s&&Gt(s)){const e=jt(i,s);if(r=It(e,"ruleset"),e.length>0){a=new MutationObserver((()=>{r=It(e,"ruleset"),l(),n(t)}));for(const t of e)a.observe(t,{attributes:!0,attributeFilter:["ruleset"]})}}else r=s},v=new MutationObserver((i=>{i.forEach((i=>{"ruleset"===i.attributeName&&(u(),l(),n(t))}))})),p=t.connectedCallback;t.connectedCallback=()=>{const h=e(t);s=c(h),o=s.ruleSets.state._system,v.observe(h,{attributes:!0,attributeFilter:["ruleset"]}),u(),l(),i=s.ruleSets.on("set",(i=>{i!==r&&"_default"!==i||(u(),l(),n(e(t)))})),d(p,t)};const g=t.disconnectedCallback;return t.disconnectedCallback=()=>{v.disconnect(),a&&(a.disconnect(),a=null),d(i),f(e(t)),d(g,t)},(t="all")=>"user"===t?h:o},ns=t=>{let i,s;const r=()=>{"function"==typeof t.validateUnitScaling&&t.validateUnitScaling(t.unitScaling),"function"==typeof t.validatePercentageScaling&&t.validatePercentageScaling(t.percentageScaling),"function"==typeof t.validateSizeScaling&&t.validateSizeScaling()},o=t.connectedCallback;t.connectedCallback=()=>{const h=e(t);s=c(h),(()=>{const i=s.scalingGroups.state;for(const s of Object.keys(i))void 0!==i[s]?t.pixelPerUnitGroupMap.set(s,i[s]):t.pixelPerUnitGroupMap.delete(s)})(),r(),i=s.scalingGroups.on("set",((i,s)=>{void 0!==s?t.pixelPerUnitGroupMap.set(i,s):t.pixelPerUnitGroupMap.delete(i),r(),n(e(t))})),d(o,t)};const h=t.disconnectedCallback;t.disconnectedCallback=()=>{d(i),f(e(t)),d(h,t)}};function rs(t,i){var s;const e=null!==(s=null==t?void 0:t.trim())&&void 0!==s?s:"";if(""===e||"null"===e)return{data:null,parseError:!1};if(e.startsWith("{")||e.startsWith("["))try{const t=JSON.parse(e);return"object"!=typeof t||null===t||Array.isArray(t)?{data:null,parseError:!0}:{data:t,parseError:!1}}catch(t){return{data:null,parseError:!0}}return null!==i?{data:{[i]:e},parseError:!1}:{data:null,parseError:!0}}function os(t,i){return Object.keys(t).filter((t=>!i.includes(t)))}function hs(t,i,s){if(R.isExisting(t[i]))return R.isString(t[i])?t[i]:void s.push(i)}function as(t,i,s){if(R.isExisting(t[i]))return R.isNumber(t[i])?t[i]:void s.push(i)}const ls=["measure","label","unit","min","max","refLine","highlight"];function cs(t){const i=[],s=hs(t,"measure",i);if(void 0===s||""===s.trim())return i.push("measure"),{config:null,unknownKeys:os(t,ls),invalidFields:i};const e={measure:s.trim()};return e.label=hs(t,"label",i),e.unit=hs(t,"unit",i),e.min=as(t,"min",i),e.max=as(t,"max",i),e.refLine=as(t,"refLine",i),e.highlight=function(t,i){if(!R.isExisting(t.highlight))return;if(!R.isObject(t.highlight)||Array.isArray(t.highlight))return void i.push("highlight");const s=t.highlight,e={},n=as(s,"from",i),r=as(s,"to",i);return void 0!==n&&(e.from=n),void 0!==r&&(e.to=r),e}(t,i),{config:e,unknownKeys:os(t,ls),invalidFields:i}}const us=["measure","label","unit","group"];function ds(t){const i=[],s=hs(t,"measure",i);if(void 0===s||""===s.trim())return i.push("measure"),{config:null,unknownKeys:os(t,us),invalidFields:i};const e={measure:s.trim()};return e.label=hs(t,"label",i),e.unit=hs(t,"unit",i),e.group=hs(t,"group",i),{config:e,unknownKeys:os(t,us),invalidFields:i}}const fs=["measure"];function vs(t){const i=[],s=hs(t,"measure",i);return void 0===s||""===s.trim()?(i.push("measure"),{config:null,unknownKeys:os(t,fs),invalidFields:i}):{config:{measure:s.trim()},unknownKeys:os(t,fs),invalidFields:i}}const ps=["values","label","unit","highlight"];function gs(t){const i=[];let s=null;if("auto"===t.values?s="auto":R.isArray(t.values)&&t.values.every((t=>R.isNumber(t)))?s=t.values:i.push("values"),null===s)return{config:null,unknownKeys:os(t,ps),invalidFields:i};const e={values:s};if(e.label=hs(t,"label",i),e.unit=hs(t,"unit",i),R.isExisting(t.highlight))if(R.isObject(t.highlight)&&!Array.isArray(t.highlight)){const s=as(t.highlight,"from",i);void 0!==s&&(e.highlight={from:s})}else i.push("highlight");return{config:e,unknownKeys:os(t,ps),invalidFields:i}}const ms=["points","values","max"];function bs(t,i){const s=[],e={points:i.points,values:i.values,max:i.max};return R.isExisting(t.points)&&("auto"===t.points||"none"===t.points||"all"===t.points||R.isArray(t.points)&&t.points.every((t=>R.isString(t)))?e.points=t.points:s.push("points")),R.isExisting(t.values)&&(R.isBoolean(t.values)?e.values=t.values:s.push("values")),R.isExisting(t.max)&&(R.isNumber(t.max)&&t.max>0?e.max=Math.floor(t.max):s.push("max")),{config:e,unknownKeys:os(t,ms),invalidFields:s}}const ys=["level","columns"];function ws(t){const i=[],s=R.isString(t.level)?t.level.toLowerCase():null;if("rowgroup"!==s&&"category"!==s)return i.push("level"),{config:null,unknownKeys:os(t,ys),invalidFields:i};const e={level:s};return R.isExisting(t.columns)&&(R.isNumber(t.columns)&&t.columns>=1?e.columns=Math.floor(t.columns):i.push("columns")),{config:e,unknownKeys:os(t,ys),invalidFields:i}}const xs=["show","position"];function Ss(t){const i=[],s={show:!0,position:"right"};return R.isExisting(t.show)&&(R.isBoolean(t.show)?s.show=t.show:i.push("show")),R.isExisting(t.position)&&("right"===t.position||"bottom"===t.position?s.position=t.position:i.push("position")),{config:s,unknownKeys:os(t,xs),invalidFields:i}}function $s(t,i){var s,e;const n=Array.from(null!==(e=null===(s=t.shadowRoot)||void 0===s?void 0:s.querySelectorAll(i))&&void 0!==e?e:[]);n.length>0&&n.every((t=>t.classList.contains("no-data")))?t.classList.add("no-data"):t.classList.remove("no-data")}const Ms={rowGroup:0,category:1,subCategory:2},_s=["ac","pp","fc","pl"],Os=class{validateFilter(t){const i="ERR_filter";v(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateX(t){this.validateMeasureSpec("x",t,!0,(t=>cs(t)))}validateY(t){this.validateMeasureSpec("y",t,!0,(t=>cs(t)))}validateSize(t){this.validateMeasureSpec("size",t,!0,(t=>ds(t))),this.validateSizeScaling()}validateShare(t){this.validateMeasureSpec("share",t,!1,(t=>vs(t)))}validateCompareWith(t){const i="WARN_compareWith";N(t)||_s.includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`compare-with: invalid value '${t}' - expected ${_s.join("/")}; ignored.`})}validateLevel(t){const i="WARN_level",s=["auto","category","subcategory"];N(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateSeriesLevel(t){const i="WARN_seriesLevel",s=["auto","rowgroup","category","none"];N(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`series-level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateFacet(t){this.validateObjectSpec("facet",t,(t=>ws(t)))}validateLabels(t){this.validateObjectSpec("labels",t,(t=>bs(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,(t=>Ss(t)))}validateAspect(t){const i="WARN_aspect";N(t)||null!==this.parseAspect(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`aspect: invalid value '${t}' - expected "w:h" (e.g. "16:9"); using the default.`})}validateLimit(t){const i="WARN_limit";L(t)&&Number(t)>=0?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`limit: invalid value '${t}' - expected a non-negative integer; using 0.`})}validateScale(t){const i="WARN_scale";if(N(t))return void this.errors.remove(i);const{mode:s,factor:e}=Ht(t);"factor"===s&&(void 0===e||e<=0)?this.errors.addOrReplace({id:i,type:"warning",message:`scale: invalid value '${t}' - expected none/auto or a positive number.`}):this.errors.remove(i)}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.pixelPerUnitGroupMap=new Map,this.chartTitle="",this.filter="",this.share="",this.compareWith="",this.level="auto",this.seriesLevel="auto",this.facet="",this.labels="",this.legend="",this.aspect="16:9",this.limit=0,this._autoScaleGuard=!1,this._lastObservedWidth=0,this.translateForInner=(t,i)=>this.t(t,i),E(this),a(this),Yt(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.errors=l(this),ns(this),this.componentStyle=k(this),this.ruleSetConfig=es(this),this.t=Bt(this).t}componentWillLoad(){this.validateFilter(this.filter),this.validateX(this.x),this.validateY(this.y),this.validateSize(this.size),this.validateShare(this.share),this.validateCompareWith(this.compareWith),this.validateLevel(this.level),this.validateSeriesLevel(this.seriesLevel),this.validateFacet(this.facet),this.validateLabels(this.labels),this.validateLegend(this.legend),this.validateAspect(this.aspect),this.validateLimit(this.limit),this.validateScale(this.scale)}componentDidRender(){$s(this.element,"bn-chart-bubble-renderer");const{mode:t}=Ht(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{width:s}=Ut(i);if(s<=0)return void this.checkOverflow();this._lastObservedWidth=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),n=i.scrollWidth,o=this.appliedScaleFactor;if(!Number.isFinite(n)||n<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const h=Math.max(.3,o*(s-1)/n);Math.abs(h-o)<.01||(i.style.setProperty("--bn-font-size",e*h+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${h.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,r((()=>{this.appliedScaleFactor=h}))),this.checkOverflow()}checkOverflow(){is(this.element,"bn-chart-bubble-renderer",this.errors)}componentDidLoad(){this.layoutObserver=ss(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=Ut(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2?(this._lastObservedWidth=t,n(this)):this.checkOverflow()})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=Ut(this.element);this._lastObservedWidth=t,n(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{points:"all",values:!0,max:12}}setBlockingError(t,i){null===i?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:i}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateSizeScaling(){var t;const i=null===(t=this.prepareSize())||void 0===t?void 0:t.group;this.setBlockingError("ERR_xy_scale_group",void 0===i||this.pixelPerUnitGroupMap.has(i)?null:this.t(".bubble-scale-group-unknown",{group:i}))}validateMeasureSpec(t,i,s,e){var n;const r=`ERR_xy_json_${t}`,o=`ERR_xy_measure_${t}`,h=`WARN_xy_fields_${t}`,{data:a,parseError:l}=rs(i,"measure");if(l)return this.setBlockingError(r,this.t(".xy-prop-json",{prop:t})),this.setBlockingError(o,null),void this.errors.remove(h);if(this.setBlockingError(r,null),null===a)return this.setBlockingError(o,s?this.t(".xy-measure-invalid",{prop:t,measure:""}):null),void this.errors.remove(h);const c=null!==(n=a.measure)&&void 0!==n?n:"";T(c)?this.setBlockingError(o,null):this.setBlockingError(o,this.t(".xy-measure-invalid",{prop:t,measure:c})),this.reportSpecIssues(h,t,e(a))}validateObjectSpec(t,i,s){const e=`ERR_xy_json_${t}`,n=`WARN_xy_fields_${t}`,{data:r,parseError:o}=rs(i,null);if(o)return this.setBlockingError(e,this.t(".xy-prop-json",{prop:t})),void this.errors.remove(n);this.setBlockingError(e,null),null!==r?this.reportSpecIssues(n,t,s(r)):this.errors.remove(n)}reportSpecIssues(t,i,s){const e=[];null!==s&&s.invalidFields.length>0&&e.push(`invalid: ${s.invalidFields.join(", ")}`),null!==s&&s.unknownKeys.length>0&&e.push(`unknown: ${s.unknownKeys.join(", ")}`),e.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${i}: ignored sub-fields (${e.join("; ")}).`}):this.errors.remove(t)}prepareAxis(t,i){const{data:s,parseError:e}=rs(i,"measure");if(e||null===s)return null;const{config:n}=cs(s);return null!==n&&T(n.measure)?(void 0!==n.min&&void 0!==n.max&&n.min>=n.max?(this.errors.addOrReplace({id:`WARN_xy_domain_${t}`,type:"warning",message:`${t}: min must be smaller than max; the override is ignored.`}),n.min=void 0,n.max=void 0):this.errors.remove(`WARN_xy_domain_${t}`),n):null}prepareSize(){const{data:t,parseError:i}=rs(this.size,"measure");if(i||null===t)return null;const{config:s}=ds(t);return null!==s&&T(s.measure)?s:null}prepareShare(){const{data:t,parseError:i}=rs(this.share,"measure");if(i||null===t)return null;const{config:s}=vs(t);return null!==s&&T(s.measure)?s:null}prepareCompareFamily(){var t;const i=null===(t=this.compareWith)||void 0===t?void 0:t.trim().toLowerCase();return _s.includes(i)?i:null}prepareLabels(){const t=this.labelDefaults(),{data:i,parseError:s}=rs(this.labels,null);return s||null===i?{points:t.points,values:t.values,max:t.max}:bs(i,t).config}prepareLegend(){const{data:t,parseError:i}=rs(this.legend,null);return i||null===t?{show:!0,position:"right"}:Ss(t).config}prepareFacet(){const{data:t,parseError:i}=rs(this.facet,null);return i||null===t?null:ws(t).config}preparePointLevel(){var t,i;const s=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("category"===s)return"category";if("subcategory"===s)return"subCategory";const e=null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel;return"rowGroup"===e||"category"===e||"subCategory"===e?e:"category"}prepareSeriesLevel(t){var i;const s=null===(i=this.seriesLevel)||void 0===i?void 0:i.trim().toLowerCase();return"none"===s?null:"rowgroup"===s?"rowGroup":"category"===s||"subCategory"===t?"category":"category"===t?"rowGroup":null}validateCrossProp(t,i){const s=new Set;let e=!1;for(const i of t){if(void 0===i)continue;const t=C(i);null!==t&&("scenario"===t.kind?s.add(P(t.slot)):e=!0)}this.setBlockingError("ERR_xy_family",s.size>1?this.t(".xy-family-mixed",{families:[...s].join(", ")}):null);const n=this.prepareCompareFamily();this.setBlockingError("ERR_xy_compare_variance",null!==n&&e?this.t(".xy-compare-variance"):null),this.setBlockingError("ERR_xy_compare_family",null!==n&&1===s.size&&s.has(n)?`compare-with: '${n}' is already the primary scenario family.`:null);const r=this.preparePointLevel(),o=this.prepareSeriesLevel(r),h=null!==i?"rowgroup"===i.level?"rowGroup":"category":null;let a=null;if(null!==o&&Ms[o]>=Ms[r]&&(a=`series '${o}' vs point '${r}'`),null!==h){const t=null!=o?o:r;Ms[h]>=Ms[t]&&(a=`facet '${h}' vs '${t}'`)}this.setBlockingError("ERR_xy_level_order",null!==a?this.t(".xy-level-order",{detail:a}):null)}parseAspect(t){const i=/^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/.exec(null!=t?t:"");if(null===i)return null;const s=Number(i[1]),e=Number(i[2]);return s<=0||e<=0?null:s/e}prepareAspect(){var t;return null!==(t=this.parseAspect(this.aspect))&&void 0!==t?t:16/9}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}prepareSizeAreaPerUnit(){var t;const i=null===(t=this.prepareSize())||void 0===t?void 0:t.group;if(void 0===i||!this.pixelPerUnitGroupMap.has(i))return 0;const s=this.pixelPerUnitGroupMap.get(i);if(!(s>0))return 0;const e=this.getEffectiveFontPx();return e*e/s}i18nLocalKeys(){return["no-data","axis.in","legend.title","legend.size","legend.compare"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),i=new Map(p.map((t=>[t,this.t("global.".concat(t))])));return new Map([...i.entries(),...t.entries()])}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const s=i.global.fontSizePx*t;return{scaleFactors:i["bn-chart-bubble"].scaleFactors,fontStyles:{font:`${s}px ${i.global.fontFamily}`,size:s,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-bubble"].axisStyles,seriesColors:i["bn-chart-bubble"].seriesColors,padding:i["bn-chart-bubble"].padding}}))}async getBaseline(){return Ui(this.element,"bn-chart-bubble-renderer")}async getLayoutState(t){var i;const s=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",e=ei(this.element),n=this.getEffectiveScaleFactor(),r=Number.isFinite(n)&&n>0?n:1,o=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*r;return ts(this.element,"bn-chart-bubble-renderer",this.chartTitle||void 0,{fontSizePx:o,appliedScaleFactor:r},e,s)}getEffectiveScaleFactor(){const{mode:t,factor:i}=Ht(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){const t=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}));return t*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const o=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":o*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const i of["ac","pp","fc","pl"])for(const s of[1,2,3,4])t[`${i}${s}`]={type:"number",isOptional:!0,description:""};const i={x:this.prepareAxis("x",this.x),y:this.prepareAxis("y",this.y),size:this.prepareSize(),share:this.prepareShare()};for(const[s,e]of Object.entries(i)){if(null===e)continue;const i=C(e.measure);null!==i&&("scenario"===i.kind?t[i.slot].description=`${s}: ${void 0!==e.label?e.label:e.measure}`:(t[i.measure.base].description=`${s}: ${e.measure} (base)`,t[i.measure.delta].description=`${s}: ${e.measure} (delta)`))}const s=this.prepareCompareFamily();if(null!==s)for(const[e,n]of Object.entries(i)){if(null===n||"share"===e)continue;const i=C(n.measure);if(null!==i&&"scenario"===i.kind){const n=s+i.slot.replace(/^[a-z]+/,"");""===t[n].description&&(t[n].description=`${e}: compareWith`)}}return{IBubbleChartDataRow:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}chartTemplate(){const t=this.prepareAxis("x",this.x),s=this.prepareAxis("y",this.y),e=this.prepareSize(),n=this.prepareShare(),r=this.prepareFacet();if(this.validateCrossProp([null==t?void 0:t.measure,null==s?void 0:s.measure,null==e?void 0:e.measure,null==n?void 0:n.measure],r),this.validateSizeScaling(),this.hasBlockingErrors()||null===t||null===s||null===e)return null;const o=this.preparePointLevel(),h=this.prepareI18n(),a=this.prepareStyle(),l=Ut(this.element).width;return i("bn-chart-bubble-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,x:t,y:s,size:e,share:n,compareFamily:this.prepareCompareFamily(),labels:this.prepareLabels(),legend:this.prepareLegend(),facet:r,pointLevel:o,seriesLevel:this.prepareSeriesLevel(o),aspect:this.prepareAspect(),limit:this.prepareLimit(),filter:this.filter,sizeAreaPerUnit:this.prepareSizeAreaPerUnit(),styles:a,i18n:h,containerWidth:l,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return i(s,{key:"2b15b5b4fc32db48b951e82ecc87f25b0afcc9f8",style:this.getFontStyles()},i("div",{key:"210d8622e1785b8c882f9c9a2fa2072af0e857b6",class:"container"},this.chartTemplate()))}get element(){return e(this)}static get watchers(){return{filter:[{validateFilter:0}],x:[{validateX:0}],y:[{validateY:0}],size:[{validateSize:0}],share:[{validateShare:0}],compareWith:[{validateCompareWith:0}],level:[{validateLevel:0}],seriesLevel:[{validateSeriesLevel:0}],facet:[{validateFacet:0}],labels:[{validateLabels:0}],legend:[{validateLegend:0}],aspect:[{validateAspect:0}],limit:[{validateLimit:0}],scale:[{validateScale:0}]}}};Os.style=':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:column}';class ks{constructor(t){this.type="",this.base="",this.delta="",this.direction="",this.isValid=!1;const i=/(d|dr)(pl\d|ac\d|fc\d|pp\d)_(pl\d|ac\d|fc\d|pp\d)_(pos|neg|neu|opinv|op)/;if(i.test(t)){const s=i.exec(t);null!=s&&(this.type=String(s[1]),this.base=String(s[2]),this.delta=String(s[3]),this.direction=String(s[4]),this.isValid=!0)}}}function As(t,i,s){return"op"!==t&&"opinv"!==t?t:"op"===t!=(!s&&"-"===i)?"pos":"neg"}const Rs=["ac","pp","fc","pl"],Ns={10:"ac",20:"pp",30:"fc",50:"pl"};function Ls(t){var i;return null!==(i=Ns[t])&&void 0!==i?i:"ac"}function Es(t,i){const s=Rs.map((t=>Ls(i.getScenarioColorIndex(`${t}1`))));if(s.every(((t,i)=>t===Rs[i])))return t;const e=Object.assign(Object.create(Object.getPrototypeOf(t)),t);return Rs.forEach(((i,n)=>{e[i]=t[s[n]]})),e}function Ts(t){var i,s;const e=new Map;for(const n of Rs){const r=null===(s=null===(i=null==t?void 0:t.scenarios)||void 0===i?void 0:i[n])||void 0===s?void 0:s.name;if(r)for(const t of[1,2,3,4])e.set(`${n}${t}`,1===t?r:`${r}${t}`)}return e}class Cs{constructor(t){this._dateFormat={year:"YYYY",quarter:"Q[Q] YYYY",month:"MMM YYYY",locale:"[KW]WW YYYY",day:"DD.MM.YYYY"},this._dateLinkFormat={avg:"Ø[DATE]",interval:"[DATE]..[DATE]",start:".[DATE]",end:"[DATE].",ytd:"_[DATE]",ytg:"[DATE]_",cum:"[DATE]_[DATE]",mat:"~[DATE]",none:"[DATE]"},this._scenarioMap=new Map;const i=A([g,null!=t?t:{}]);Object.entries(i.scenarios).forEach((([t,i])=>{var s,e,n;this.createScenarioMapEntry(t,null!==(s=i.name)&&void 0!==s?s:t,null!==(e=i.colorIndex)&&void 0!==e?e:10,null!==(n=i.sortIndex)&&void 0!==n?n:0)})),this._fallBackScenario=i.fallback}createScenarioMapEntry(t,i,s,e){const n=i,r=s;[1,2,3,4].forEach((s=>{this._scenarioMap.set(t+s,{name:i+s,group:n,colorIndex:r,sortIndex:e+10*s})}))}getScenario(t){return this._scenarioMap.has(t)?this._scenarioMap.get(t):this._fallBackScenario}getScenarioGroup(t){return this._scenarioMap.has(t)?this._scenarioMap.get(t).name:this._fallBackScenario.name}getScenarioColorIndex(t){return this._scenarioMap.has(t)?this._scenarioMap.get(t).colorIndex:this._fallBackScenario.colorIndex}getScenarioSorIndex(t){const i=this.normalizeVarianceScenario(t);return this._scenarioMap.has(i)?this._scenarioMap.get(i).sortIndex:this._fallBackScenario.sortIndex}normalizeVarianceScenario(t){if(null==t)return"";const i=new ks(t);return i.isValid?i.type+i.delta:t}}class Ps{constructor(){this.font="16px Arial",this.family="Arial",this.size=16,this.color="#000000",this.background="#ffffff",this.leading=1.8}}class Ws{adapt(t){const i=new Ps;return R.isString(t.font)&&(i.font=t.font),R.isString(t.family)&&(i.family=t.family),R.isNumber(t.size)&&(i.size=t.size),R.isString(t.color)&&(i.color=t.color),R.isString(t.background)&&(i.background=t.background),R.isNumber(t.leading)&&(i.leading=t.leading),i}default(){return new Ps}}let Ds=class{constructor(){this.top=10,this.left=10,this.right=10,this.bottom=10}};class zs{adapt(t){const i=new Ds;return R.isNumber(t.top)&&(i.top=t.top),R.isNumber(t.left)&&(i.left=t.left),R.isNumber(t.right)&&(i.right=t.right),R.isNumber(t.bottom)&&(i.bottom=t.bottom),i}default(){return new Ds}}function Us(t){return"fc"===t||"hatched"===t?"hatched":"solid"===t||"outlined"===t?t:void 0}class Fs{constructor(t="#000000",i="#000000",s=.1){this.stroke=t,this.fill=i,this.width=s}}class Gs{adapt(t){const i=new Fs(t.stroke,t.fill,t.width);return i.fillpattern=Us(t.fillpattern),"outlined"===i.fillpattern&&(i.fill="transparent"),R.isString(t.dasharray)&&(i.dasharray=t.dasharray),i}default(){return new Fs("#000000","#000000",.3)}defaultAC(){return new Fs("#000000","#000000",.3)}defaultFC(){const t=new Fs("#000000","#000000",.3);return t.dasharray="10 5 5 5",t.fillpattern="hatched",t}defaultPP(){return new Fs("#999999","#999999",.3)}defaultPL(){return new Fs("#000000","#ffffff",.3)}defaultPos(){return new Fs("#00ff00","#00ff00",.3)}defaultNeg(){return new Fs("#ff0000","#ff0000",.3)}defaultNeu(){return new Fs("#999999","#999999",.3)}}class js{constructor(t,i,s,e){this.ac=t,this.fc=i,this.pp=s,this.pl=e}getSVGStyle(t){return"ac"===t?this.ac:"fc"===t?this.fc:"pp"===t?this.pp:"pl"===t?this.pl:this.ac}}class Is{constructor(t){this.svgStyleAdapter=t}adapt(t){const i=new js(this.svgStyleAdapter.defaultAC(),this.svgStyleAdapter.defaultFC(),this.svgStyleAdapter.defaultPP(),this.svgStyleAdapter.defaultPL());return R.isExisting(t.ac)&&(i.ac=this.svgStyleAdapter.adapt(t.ac)),R.isExisting(t.fc)&&(i.fc=this.svgStyleAdapter.adapt(t.fc)),R.isExisting(t.pp)&&(i.pp=this.svgStyleAdapter.adapt(t.pp)),R.isExisting(t.pl)&&(i.pl=this.svgStyleAdapter.adapt(t.pl)),i}default(){return new js(this.svgStyleAdapter.defaultAC(),this.svgStyleAdapter.defaultFC(),this.svgStyleAdapter.defaultPP(),this.svgStyleAdapter.defaultPL())}}class Ys{constructor(t,i,s,e){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.padding=e,this.seriesColors=[...m],this.locale="de"}}class Bs{constructor(t,i,s,e){this.scaleFactorsXYChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.paddingAdapter=e}adapt(t){const i=this.default();return R.isExisting(t)&&(R.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsXYChartAdapter.adapt(t.scaleFactors)),R.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),R.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),R.isExisting(t.padding)&&(i.padding=this.paddingAdapter.adapt(t.padding)),Array.isArray(t.seriesColors)&&t.seriesColors.length>0&&(i.seriesColors=t.seriesColors)),i}default(){return new Ys(this.scaleFactorsXYChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.paddingAdapter.default())}}class Hs{constructor(){this.pointRadius=.4,this.bubbleMaxRadius=3.2,this.bubbleMinRadius=.35,this.axisTickLength=.35,this.labelToMark=.3,this.legendSwatch=.9,this.panelGap=1.6,this.refLineWidth=.075,this.gridLineWidth=.075}}class Vs{adapt(t){const i=new Hs;return R.isNumber(t.pointRadius)&&(i.pointRadius=t.pointRadius),R.isNumber(t.bubbleMaxRadius)&&(i.bubbleMaxRadius=t.bubbleMaxRadius),R.isNumber(t.bubbleMinRadius)&&(i.bubbleMinRadius=t.bubbleMinRadius),R.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),R.isNumber(t.labelToMark)&&(i.labelToMark=t.labelToMark),R.isNumber(t.legendSwatch)&&(i.legendSwatch=t.legendSwatch),R.isNumber(t.panelGap)&&(i.panelGap=t.panelGap),R.isNumber(t.refLineWidth)&&(i.refLineWidth=t.refLineWidth),R.isNumber(t.gridLineWidth)&&(i.gridLineWidth=t.gridLineWidth),i}default(){return new Hs}}var Xs=Object.create,Js=Object.defineProperty,qs=Object.getOwnPropertyDescriptor,Ks=Object.getOwnPropertyNames,Qs=Object.getPrototypeOf,Zs=Object.prototype.hasOwnProperty,te=(t,i)=>()=>(i||(t((i={exports:{}}).exports,i),t=null),i.exports),ie=t=>{let i={};for(var s in t)Js(i,s,{get:t[s],enumerable:!0});return Js(i,Symbol.toStringTag,{value:"Module"}),i},se=(t,i,s)=>(s=null!=t?Xs(Qs(t)):{},((t,i,s,e)=>{if(i&&"object"==typeof i||"function"==typeof i)for(var n,r=Ks(i),o=0,h=r.length;o<h;o++)Zs.call(t,n=r[o])||undefined===n||Js(t,n,{get:(t=>i[t]).bind(null,n),enumerable:!(e=qs(i,n))||e.enumerable});return t})(Js(s,"default",{value:t,enumerable:!0}),t));const ee={},ne=[];function re(t,i){if(Array.isArray(t))for(const s of t)re(s,i);else if("object"!=typeof t)he(Object.getOwnPropertyNames(i)),ee[t]=Object.assign(ee[t]||{},i);else for(const i in t)re(i,t[i])}function oe(t){return ee[t]||{}}function he(t){ne.push(...t)}var ae=te(((t,i)=>{i.exports=function(t){try{return!!t()}catch(t){return!0}}})),le=te(((t,i)=>{var s=ae();i.exports=!s((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))})),ce=te(((t,i)=>{var s=le(),e=Function.prototype,n=e.call,r=s&&e.bind.bind(n,n);i.exports=s?r:function(t){return function(){return n.apply(t,arguments)}}})),ue=te(((t,i)=>{var s=ce();i.exports=s({}.isPrototypeOf)})),de=te(((t,i)=>{var s=function(t){return t&&t.Math===Math&&t};i.exports=s("object"==typeof globalThis&&globalThis)||s("object"==typeof window&&window)||s("object"==typeof self&&self)||s("object"==typeof global&&global)||s("object"==typeof t&&t)||function(){return this}()||Function("return this")()})),fe=te(((t,i)=>{var s=le(),e=Function.prototype,n=e.apply,r=e.call;i.exports="object"==typeof Reflect&&Reflect.apply||(s?r.bind(n):function(){return r.apply(n,arguments)})})),ve=te(((t,i)=>{var s=ce(),e=s({}.toString),n=s("".slice);i.exports=function(t){return n(e(t),8,-1)}})),pe=te(((t,i)=>{var s=ve(),e=ce();i.exports=function(t){if("Function"===s(t))return e(t)}})),ge=te(((t,i)=>{var s="object"==typeof document&&document.all;i.exports=void 0===s&&void 0!==s?function(t){return"function"==typeof t||t===s}:function(t){return"function"==typeof t}})),me=te(((t,i)=>{var s=ae();i.exports=!s((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}))})),be=te(((t,i)=>{var s=le(),e=Function.prototype.call;i.exports=s?e.bind(e):function(){return e.apply(e,arguments)}})),ye=te((t=>{var i={}.propertyIsEnumerable,s=Object.getOwnPropertyDescriptor,e=s&&!i.call({1:2},1);t.f=e?function(t){var i=s(this,t);return!!i&&i.enumerable}:i})),we=te(((t,i)=>{i.exports=function(t,i){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:i}}})),xe=te(((t,i)=>{var s=ce(),e=ae(),n=ve(),r=Object,o=s("".split);i.exports=e((function(){return!r("z").propertyIsEnumerable(0)}))?function(t){return"String"===n(t)?o(t,""):r(t)}:r})),Se=te(((t,i)=>{i.exports=function(t){return null==t}})),$e=te(((t,i)=>{var s=Se(),e=TypeError;i.exports=function(t){if(s(t))throw new e("Can't call method on "+t);return t}})),Me=te(((t,i)=>{var s=xe(),e=$e();i.exports=function(t){return s(e(t))}})),_e=te(((t,i)=>{var s=ge();i.exports=function(t){return"object"==typeof t?null!==t:s(t)}})),Oe=te(((t,i)=>{i.exports={}})),ke=te(((t,i)=>{var s=Oe(),e=de(),n=ge(),r=function(t){return n(t)?t:void 0};i.exports=function(t,i){return arguments.length<2?r(s[t])||r(e[t]):s[t]&&s[t][i]||e[t]&&e[t][i]}})),Ae=te(((t,i)=>{var s=de().navigator,e=s&&s.userAgent;i.exports=e?String(e):""})),Re=te(((t,i)=>{var s,e,n=de(),r=Ae(),o=n.process,h=n.Deno,a=o&&o.versions||h&&h.version,l=a&&a.v8;l&&(e=(s=l.split("."))[0]>0&&s[0]<4?1:+(s[0]+s[1])),!e&&r&&(!(s=r.match(/Edge\/(\d+)/))||s[1]>=74)&&(s=r.match(/Chrome\/(\d+)/))&&(e=+s[1]),i.exports=e})),Ne=te(((t,i)=>{var s=Re(),e=ae(),n=de().String;i.exports=!!Object.getOwnPropertySymbols&&!e((function(){var t=Symbol("symbol detection");return!n(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&s&&s<41}))})),Le=te(((t,i)=>{var s=Ne();i.exports=s&&!Symbol.sham&&"symbol"==typeof Symbol.iterator})),Ee=te(((t,i)=>{var s=ke(),e=ge(),n=ue(),r=Le(),o=Object;i.exports=r?function(t){return"symbol"==typeof t}:function(t){var i=s("Symbol");return e(i)&&n(i.prototype,o(t))}})),Te=te(((t,i)=>{var s=String;i.exports=function(t){try{return s(t)}catch(t){return"Object"}}})),Ce=te(((t,i)=>{var s=ge(),e=Te(),n=TypeError;i.exports=function(t){if(s(t))return t;throw new n(e(t)+" is not a function")}})),Pe=te(((t,i)=>{var s=Ce(),e=Se();i.exports=function(t,i){var n=t[i];return e(n)?void 0:s(n)}})),We=te(((t,i)=>{var s=be(),e=ge(),n=_e(),r=TypeError;i.exports=function(t,i){var o,h;if("string"===i&&e(o=t.toString)&&!n(h=s(o,t)))return h;if(e(o=t.valueOf)&&!n(h=s(o,t)))return h;if("string"!==i&&e(o=t.toString)&&!n(h=s(o,t)))return h;throw new r("Can't convert object to primitive value")}})),De=te(((t,i)=>{i.exports=!0})),ze=te(((t,i)=>{var s=de(),e=Object.defineProperty;i.exports=function(t,i){try{e(s,t,{value:i,configurable:!0,writable:!0})}catch(e){s[t]=i}return i}})),Ue=te(((t,i)=>{var s=De(),e=de(),n=ze(),r="__core-js_shared__",o=i.exports=e[r]||n(r,{});(o.versions||(o.versions=[])).push({version:"3.49.0",mode:s?"pure":"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.49.0/LICENSE",source:"https://github.com/zloirock/core-js"})})),Fe=te(((t,i)=>{var s=Ue();i.exports=function(t,i){return s[t]||(s[t]=i||{})}})),Ge=te(((t,i)=>{var s=$e(),e=Object;i.exports=function(t){return e(s(t))}})),je=te(((t,i)=>{var s=ce(),e=Ge(),n=s({}.hasOwnProperty);i.exports=Object.hasOwn||function(t,i){return n(e(t),i)}})),Ie=te(((t,i)=>{var s=ce(),e=0,n=Math.random(),r=s(1.1.toString);i.exports=function(t){return"Symbol("+(void 0===t?"":t)+")_"+r(++e+n,36)}})),Ye=te(((t,i)=>{var s=de(),e=Fe(),n=je(),r=Ie(),o=Ne(),h=Le(),a=s.Symbol,l=e("wks"),c=h?a.for||a:a&&a.withoutSetter||r;i.exports=function(t){return n(l,t)||(l[t]=o&&n(a,t)?a[t]:c("Symbol."+t)),l[t]}})),Be=te(((t,i)=>{var s=be(),e=_e(),n=Ee(),r=Pe(),o=We(),h=Ye(),a=TypeError,l=h("toPrimitive");i.exports=function(t,i){if(!e(t)||n(t))return t;var h,c=r(t,l);if(c){if(void 0===i&&(i="default"),h=s(c,t,i),!e(h)||n(h))return h;throw new a("Can't convert object to primitive value")}return void 0===i&&(i="number"),o(t,i)}})),He=te(((t,i)=>{var s=Be(),e=Ee();i.exports=function(t){var i=s(t,"string");return e(i)?i:i+""}})),Ve=te(((t,i)=>{var s=de(),e=_e(),n=s.document,r=e(n)&&e(n.createElement);i.exports=function(t){return r?n.createElement(t):{}}})),Xe=te(((t,i)=>{var s=me(),e=ae(),n=Ve();i.exports=!s&&!e((function(){return 7!==Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a}))})),Je=te((t=>{var i=me(),s=be(),e=ye(),n=we(),r=Me(),o=He(),h=je(),a=Xe(),l=Object.getOwnPropertyDescriptor;t.f=i?l:function(t,i){if(t=r(t),i=o(i),a)try{return l(t,i)}catch(t){}if(h(t,i))return n(!s(e.f,t,i),t[i])}})),qe=te(((t,i)=>{var s=ae(),e=ge(),n=/#|\.prototype\./,r=function(t,i){var n=h[o(t)];return n===l||n!==a&&(e(i)?s(i):!!i)},o=r.normalize=function(t){return String(t).replace(n,".").toLowerCase()},h=r.data={},a=r.NATIVE="N",l=r.POLYFILL="P";i.exports=r})),Ke=te(((t,i)=>{var s=pe(),e=Ce(),n=le(),r=s(s.bind);i.exports=function(t,i){return e(t),void 0===i?t:n?r(t,i):function(){return t.apply(i,arguments)}}})),Qe=te(((t,i)=>{var s=me(),e=ae();i.exports=s&&e((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))})),Ze=te(((t,i)=>{var s=_e(),e=String,n=TypeError;i.exports=function(t){if(s(t))return t;throw new n(e(t)+" is not an object")}})),tn=te((t=>{var i=me(),s=Xe(),e=Qe(),n=Ze(),r=He(),o=TypeError,h=Object.defineProperty,a=Object.getOwnPropertyDescriptor,l="enumerable",c="configurable",u="writable";t.f=i?e?function(t,i,s){if(n(t),i=r(i),n(s),"function"==typeof t&&"prototype"===i&&"value"in s&&u in s&&!s[u]){var e=a(t,i);e&&e[u]&&(t[i]=s.value,s={configurable:c in s?s[c]:e[c],enumerable:l in s?s[l]:e[l],writable:!1})}return h(t,i,s)}:h:function(t,i,e){if(n(t),i=r(i),n(e),s)try{return h(t,i,e)}catch(t){}if("get"in e||"set"in e)throw new o("Accessors not supported");return"value"in e&&(t[i]=e.value),t}})),sn=te(((t,i)=>{var s=me(),e=tn(),n=we();i.exports=s?function(t,i,s){return e.f(t,i,n(1,s))}:function(t,i,s){return t[i]=s,t}})),en=te(((t,i)=>{var s=de(),e=fe(),n=pe(),r=ge(),o=Je().f,h=qe(),a=Oe(),l=Ke(),c=sn(),u=je();Ue();var d=function(t){var i=function(s,n,r){if(this instanceof i){switch(arguments.length){case 0:return new t;case 1:return new t(s);case 2:return new t(s,n)}return new t(s,n,r)}return e(t,this,arguments)};return i.prototype=t.prototype,i};i.exports=function(t,i){var e,f,v,p,g,m,b,y,w,x=t.target,S=t.global,$=t.stat,M=t.proto,_=S?s:$?s[x]:s[x]&&s[x].prototype,O=S?a:a[x]||c(a,x,{})[x],k=O.prototype;for(p in i)f=!(e=h(S?p:x+($?".":"#")+p,t.forced))&&_&&u(_,p),m=O[p],f&&(b=t.dontCallGetSet?(w=o(_,p))&&w.value:_[p]),g=f&&b?b:i[p],(e||M||typeof m!=typeof g)&&(y=t.bind&&f?l(g,s):t.wrap&&f?d(g):M&&r(g)?n(g):g,(t.sham||g&&g.sham||m&&m.sham)&&c(y,"sham",!0),c(O,p,y),M&&(u(a,v=x+"Prototype")||c(a,v,{}),c(a[v],p,g),t.real&&k&&(e||!k[p])&&c(k,p,g)))}})),nn=te(((t,i)=>{var s=Math.ceil,e=Math.floor;i.exports=Math.trunc||function(t){var i=+t;return(i>0?e:s)(i)}})),rn=te(((t,i)=>{var s=nn();i.exports=function(t){var i=+t;return i!=i||0===i?0:s(i)}})),on=te(((t,i)=>{var s=rn(),e=Math.max,n=Math.min;i.exports=function(t,i){var r=s(t);return r<0?e(r+i,0):n(r,i)}})),hn=te(((t,i)=>{var s=rn(),e=Math.min;i.exports=function(t){var i=s(t);return i>0?e(i,9007199254740991):0}})),an=te(((t,i)=>{var s=hn();i.exports=function(t){return s(t.length)}})),ln=te(((t,i)=>{var s=Me(),e=on(),n=an(),r=function(t){return function(i,r,o){var h=s(i),a=n(h);if(0===a)return!t&&-1;var l,c=e(o,a);if(t&&r!=r){for(;a>c;)if((l=h[c++])!=l)return!0}else for(;a>c;c++)if((t||c in h)&&h[c]===r)return t||c||0;return!t&&-1}};i.exports={includes:r(!0),indexOf:r(!1)}})),cn=te(((t,i)=>{i.exports=function(){}})),un=te((()=>{var t=en(),i=ln().includes,s=ae(),e=cn(),n=s((function(){return!Array(1).includes()})),r=s((function(){return[,1].includes(void 0,1)}));t({target:"Array",proto:!0,forced:n||r},{includes:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),e("includes")})),dn=te(((t,i)=>{var s=de(),e=Oe();i.exports=function(t,i){var n=e[t+"Prototype"],r=n&&n[i];if(r)return r;var o=s[t],h=o&&o.prototype;return h&&h[i]}})),fn=te(((t,i)=>{un();var s=dn();i.exports=s("Array","includes")})),vn=te(((t,i)=>{var s=_e(),e=ve(),n=Ye()("match");i.exports=function(t){var i;return s(t)&&(void 0!==(i=t[n])?!!i:"RegExp"===e(t))}})),pn=te(((t,i)=>{var s=vn(),e=TypeError;i.exports=function(t){if(s(t))throw new e("The method doesn't accept regular expressions");return t}})),gn=te(((t,i)=>{var s={};s[Ye()("toStringTag")]="z",i.exports="[object z]"===String(s)})),mn=te(((t,i)=>{var s=gn(),e=ge(),n=ve(),r=Ye()("toStringTag"),o=Object,h="Arguments"===n(function(){return arguments}());i.exports=s?n:function(t){var i,s,a;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(s=function(t,i){try{return t[i]}catch(t){}}(i=o(t),r))?s:h?n(i):"Object"===(a=n(i))&&e(i.callee)?"Arguments":a}})),bn=te(((t,i)=>{var s=mn(),e=String;i.exports=function(t){if("Symbol"===s(t))throw new TypeError("Cannot convert a Symbol value to a string");return e(t)}})),yn=te(((t,i)=>{var s=Ye()("match");i.exports=function(t){var i=/./;try{"/./"[t](i)}catch(e){try{return i[s]=!1,"/./"[t](i)}catch(t){}}return!1}})),wn=te((()=>{var t=en(),i=ce(),s=pn(),e=$e(),n=bn(),r=yn(),o=i("".indexOf);t({target:"String",proto:!0,forced:!r("includes")},{includes:function(t){return!!~o(n(e(this)),n(s(t)),arguments.length>1?arguments[1]:void 0)}})})),xn=te(((t,i)=>{wn();var s=dn();i.exports=s("String","includes")})),Sn=te(((t,i)=>{var s=ue(),e=fn(),n=xn(),r=Array.prototype,o=String.prototype;i.exports=function(t){var i=t.includes;return t===r||s(r,t)&&i===r.includes?e:"string"==typeof t||t===o||s(o,t)&&i===o.includes?n:i}})),$n=se(te(((t,i)=>{var s=Sn();i.exports=s}))());function Mn(t,i){let s;const e=t.length,n=[];for(s=0;s<e;s++)n.push(i(t[s]));return n}function _n(t){return t%360*Math.PI/180}function On(t){return t.replace(/([A-Z])/g,(function(t,i){return"-"+i.toLowerCase()}))}function kn(t){return t.charAt(0).toUpperCase()+t.slice(1)}function An(t,i,s,e){return null!=i&&null!=s||(e=e||t.bbox(),null==i?i=e.width/e.height*s:null==s&&(s=e.height/e.width*i)),{width:i,height:s}}function Rn(t,i){const s=t.origin;let e=null!=t.ox?t.ox:null!=t.originX?t.originX:"center",n=null!=t.oy?t.oy:null!=t.originY?t.originY:"center";null!=s&&([e,n]=Array.isArray(s)?s:"object"==typeof s?[s.x,s.y]:[s,s]);const r="string"==typeof e,o="string"==typeof n;if(r||o){const{height:t,width:s,x:h,y:a}=i.bbox();r&&(e=(0,$n.default)(e).call(e,"left")?h:(0,$n.default)(e).call(e,"right")?h+s:h+s/2),o&&(n=(0,$n.default)(n).call(n,"top")?a:(0,$n.default)(n).call(n,"bottom")?a+t:a+t/2)}return[e,n]}const Nn=new Set(["desc","metadata","title"]),Ln=t=>Nn.has(t.nodeName),En="http://www.w3.org/2000/svg",Tn="http://www.w3.org/2000/xmlns/",Cn="http://www.w3.org/1999/xlink",Pn={window:"undefined"==typeof window?null:window,document:"undefined"==typeof document?null:document};var Wn=class{};const Dn={},zn="___SYMBOL___ROOT___";function Un(t,i=En){return Pn.document.createElementNS(i,t)}function Fn(t,i=!1){if(t instanceof Wn)return t;if("object"==typeof t)return In(t);if(null==t)return new Dn[zn];if("string"==typeof t&&"<"!==t.trim().charAt(0))return In(Pn.document.querySelector(t));const s=i?Pn.document.createElement("div"):Un("svg");return s.innerHTML=t.trim(),t=In(s.firstElementChild),s.removeChild(s.firstElementChild),t}function Gn(t,i){return i&&(i instanceof Pn.window.Node||i.ownerDocument&&i instanceof i.ownerDocument.defaultView.Node)?i:Un(t)}function jn(t){if(!t)return null;if(t.instance instanceof Wn)return t.instance;if("#document-fragment"===t.nodeName)return new Dn.Fragment(t);let i=kn(t.nodeName||"Dom");return"LinearGradient"===i||"RadialGradient"===i?i="Gradient":Dn[i]||(i="Dom"),new Dn[i](t)}let In=jn;function Yn(t,i=t.name,s=!1){return Dn[i]=t,s&&(Dn[zn]=t),he(Object.getOwnPropertyNames(t.prototype)),t}let Bn=1e3;function Hn(t){return"Svgjs"+kn(t)+Bn++}function Vn(t){for(let i=t.children.length-1;i>=0;i--)Vn(t.children[i]);return t.id?(t.id=Hn(t.nodeName),t):t}function Xn(t,i){let s,e;for(e=(t=Array.isArray(t)?t:[t]).length-1;e>=0;e--)for(s in i)t[e].prototype[s]=i[s]}function Jn(t){return function(...i){const s=i[i.length-1];return!s||s.constructor!==Object||s instanceof Array?t.apply(this,i):t.apply(this,i.slice(0,-1)).attr(s)}}re("Dom",{siblings:function(){return this.parent().children()},position:function(){return this.parent().index(this)},next:function(){return this.siblings()[this.position()+1]},prev:function(){return this.siblings()[this.position()-1]},forward:function(){const t=this.position();return this.parent().add(this.remove(),t+1),this},backward:function(){const t=this.position();return this.parent().add(this.remove(),t?t-1:0),this},front:function(){return this.parent().add(this.remove()),this},back:function(){return this.parent().add(this.remove(),0),this},before:function(t){(t=Fn(t)).remove();const i=this.position();return this.parent().add(t,i),this},after:function(t){(t=Fn(t)).remove();const i=this.position();return this.parent().add(t,i+1),this},insertBefore:function(t){return(t=Fn(t)).before(this),this},insertAfter:function(t){return(t=Fn(t)).after(this),this}});const qn=/^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i,Kn=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,Qn=/rgb\((\d+),(\d+),(\d+)\)/,Zn=/^(#[^\s]+)$/,tr=/\)\s*,?\s*/,ir=/\s/g,sr=/^#[a-f0-9]{3}$|^#[a-f0-9]{6}$/i,er=/^rgb\(/,nr=/^(\s+)?$/,rr=/^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,or=/\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i,hr=/[\s,]+/,ar=/[MLHVCSQTAZ]/i;re("Dom",{classes:function(){const t=this.attr("class");return null==t?[]:t.trim().split(hr)},hasClass:function(t){return-1!==this.classes().indexOf(t)},addClass:function(t){if(!this.hasClass(t)){const i=this.classes();i.push(t),this.attr("class",i.join(" "))}return this},removeClass:function(t){return this.hasClass(t)&&this.attr("class",this.classes().filter((function(i){return i!==t})).join(" ")),this},toggleClass:function(t){return this.hasClass(t)?this.removeClass(t):this.addClass(t)}});const lr=t=>t.startsWith("--")?t:On(t);function cr(t){const i=Math.max(0,Math.min(255,Math.round(t))).toString(16);return 1===i.length?"0"+i:i}function ur(t,i){for(let s=i.length;s--;)if(null==t[i[s]])return!1;return!0}function dr(t,i,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(i-t)*s:s<.5?i:s<2/3?t+(i-t)*(2/3-s)*6:t}re("Dom",{css:function(t,i){const s={};if(0===arguments.length){const t=this.node.style;for(let i=0;i<t.length;i++){const e=t.item(i),n=t.getPropertyValue(e),r=t.getPropertyPriority(e);s[e]=r?`${n} !${r}`:n}return s}if(arguments.length<2){if(Array.isArray(t)){for(const i of t){const t=lr(i);s[i]=this.node.style.getPropertyValue(t)}return s}if("string"==typeof t)return this.node.style.getPropertyValue(lr(t));if("object"==typeof t)for(const i in t)this.node.style.setProperty(lr(i),null==t[i]||nr.test(t[i])?"":t[i])}return 2===arguments.length&&this.node.style.setProperty(lr(t),null==i||nr.test(i)?"":i),this},show:function(){return this.css("display","")},hide:function(){return this.css("display","none")},visible:function(){return"none"!==this.css("display")}}),re("Dom",{data:function(t,i,s){if(null==t)return this.data(Mn(function(t){let i;const s=t.length,e=[];for(i=0;i<s;i++)0===t[i].nodeName.indexOf("data-")&&e.push(t[i]);return e}(this.node.attributes),(t=>t.nodeName.slice(5))));if(t instanceof Array){const i={};for(const s of t)i[s]=this.data(s);return i}if("object"==typeof t)for(i in t)this.data(i,t[i]);else if(arguments.length<2)try{return JSON.parse(this.attr("data-"+t))}catch(i){return this.attr("data-"+t)}else this.attr("data-"+t,null===i?null:!0===s||"string"==typeof i||"number"==typeof i?i:JSON.stringify(i));return this}}),re("Dom",{remember:function(t,i){if("object"==typeof arguments[0])for(const i in t)this.remember(i,t[i]);else{if(1===arguments.length)return this.memory()[t];this.memory()[t]=i}return this},forget:function(){if(0===arguments.length)this._memory={};else for(let t=arguments.length-1;t>=0;t--)delete this.memory()[arguments[t]];return this},memory:function(){return this._memory=this._memory||{}}});var fr=class t{constructor(...t){this.init(...t)}static isColor(i){return i&&(i instanceof t||this.isRgb(i)||this.test(i))}static isRgb(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b}static random(i="vibrant",s){const{random:e,round:n,sin:r,PI:o}=Math;if("vibrant"===i){const i=24*e()+57,s=38*e()+45,n=360*e();return new t(i,s,n,"lch")}if("sine"===i){const i=n(80*r(2*o*(s=null==s?e():s)/.5+.01)+150),h=n(50*r(2*o*s/.5+4.6)+200),a=n(100*r(2*o*s/.5+2.3)+150);return new t(i,h,a)}if("pastel"===i){const i=8*e()+86,s=17*e()+9,n=360*e();return new t(i,s,n,"lch")}if("dark"===i){const i=10+10*e(),s=50*e()+86,n=360*e();return new t(i,s,n,"lch")}if("rgb"===i){const i=255*e(),s=255*e(),n=255*e();return new t(i,s,n)}if("lab"===i){const i=100*e(),s=256*e()-128,n=256*e()-128;return new t(i,s,n,"lab")}if("grey"===i){const i=255*e();return new t(i,i,i)}throw new Error("Unsupported random color mode")}static test(t){return"string"==typeof t&&(sr.test(t)||er.test(t))}cmyk(){const{_a:i,_b:s,_c:e}=this.rgb(),[n,r,o]=[i,s,e].map((t=>t/255)),h=Math.min(1-n,1-r,1-o);return 1===h?new t(0,0,0,1,"cmyk"):new t((1-n-h)/(1-h),(1-r-h)/(1-h),(1-o-h)/(1-h),h,"cmyk")}hsl(){const{_a:i,_b:s,_c:e}=this.rgb(),[n,r,o]=[i,s,e].map((t=>t/255)),h=Math.max(n,r,o),a=Math.min(n,r,o),l=(h+a)/2,c=h===a,u=h-a;return new t(360*(c?0:h===n?((r-o)/u+(r<o?6:0))/6:h===r?((o-n)/u+2)/6:h===o?((n-r)/u+4)/6:0),100*(c?0:l>.5?u/(2-h-a):u/(h+a)),100*l,"hsl")}init(t=0,i=0,s=0,e=0,n="rgb"){if(t=t||0,this.space)for(const t in this.space)delete this[this.space[t]];if("number"==typeof t)n="string"==typeof e?e:n,e="string"==typeof e?0:e,Object.assign(this,{_a:t,_b:i,_c:s,_d:e,space:n});else if(t instanceof Array)this.space=i||("string"==typeof t[3]?t[3]:t[4])||"rgb",Object.assign(this,{_a:t[0],_b:t[1],_c:t[2],_d:t[3]||0});else if(t instanceof Object){const s=function(t,i){const s=ur(t,"rgb")?{_a:t.r,_b:t.g,_c:t.b,_d:0,space:"rgb"}:ur(t,"xyz")?{_a:t.x,_b:t.y,_c:t.z,_d:0,space:"xyz"}:ur(t,"hsl")?{_a:t.h,_b:t.s,_c:t.l,_d:0,space:"hsl"}:ur(t,"lab")?{_a:t.l,_b:t.a,_c:t.b,_d:0,space:"lab"}:ur(t,"lch")?{_a:t.l,_b:t.c,_c:t.h,_d:0,space:"lch"}:ur(t,"cmyk")?{_a:t.c,_b:t.m,_c:t.y,_d:t.k,space:"cmyk"}:{_a:0,_b:0,_c:0,space:"rgb"};return s.space=i||s.space,s}(t,i);Object.assign(this,s)}else if("string"==typeof t)if(er.test(t)){const i=t.replace(ir,""),[s,e,n]=Qn.exec(i).slice(1,4).map((t=>parseInt(t)));Object.assign(this,{_a:s,_b:e,_c:n,_d:0,space:"rgb"})}else{if(!sr.test(t))throw Error("Unsupported string format, can't construct Color");{const i=t=>parseInt(t,16),[,s,e,n]=Kn.exec(function(t){return 4===t.length?["#",t.substring(1,2),t.substring(1,2),t.substring(2,3),t.substring(2,3),t.substring(3,4),t.substring(3,4)].join(""):t}(t)).map(i);Object.assign(this,{_a:s,_b:e,_c:n,_d:0,space:"rgb"})}}const{_a:r,_b:o,_c:h,_d:a}=this;Object.assign(this,"rgb"===this.space?{r,g:o,b:h}:"xyz"===this.space?{x:r,y:o,z:h}:"hsl"===this.space?{h:r,s:o,l:h}:"lab"===this.space?{l:r,a:o,b:h}:"lch"===this.space?{l:r,c:o,h}:"cmyk"===this.space?{c:r,m:o,y:h,k:a}:{})}lab(){const{x:i,y:s,z:e}=this.xyz();return new t(116*s-16,500*(i-s),200*(s-e),"lab")}lch(){const{l:i,a:s,b:e}=this.lab(),n=Math.sqrt(s**2+e**2);let r=180*Math.atan2(e,s)/Math.PI;return r<0&&(r*=-1,r=360-r),new t(i,n,r,"lch")}rgb(){if("rgb"===this.space)return this;if("lab"===(i=this.space)||"xyz"===i||"lch"===i){let{x:i,y:s,z:e}=this;if("lab"===this.space||"lch"===this.space){let{l:t,a:n,b:r}=this;if("lch"===this.space){const{c:t,h:i}=this,s=Math.PI/180;n=t*Math.cos(s*i),r=t*Math.sin(s*i)}const o=(t+16)/116,h=n/500+o,a=o-r/200,l=16/116,c=.008856,u=7.787;i=.95047*(h**3>c?h**3:(h-l)/u),s=1*(o**3>c?o**3:(o-l)/u),e=1.08883*(a**3>c?a**3:(a-l)/u)}const n=3.2406*i+-1.5372*s+-.4986*e,r=-.9689*i+1.8758*s+.0415*e,o=.0557*i+-.204*s+1.057*e,h=Math.pow,a=.0031308,l=n>a?1.055*h(n,1/2.4)-.055:12.92*n,c=r>a?1.055*h(r,1/2.4)-.055:12.92*r,u=o>a?1.055*h(o,1/2.4)-.055:12.92*o;return new t(255*l,255*c,255*u)}if("hsl"===this.space){let{h:i,s,l:e}=this;if(i/=360,s/=100,e/=100,0===s)return e*=255,new t(e,e,e);const n=e<.5?e*(1+s):e+s-e*s,r=2*e-n,o=255*dr(r,n,i+1/3),h=255*dr(r,n,i),a=255*dr(r,n,i-1/3);return new t(o,h,a)}if("cmyk"===this.space){const{c:i,m:s,y:e,k:n}=this,r=255*(1-Math.min(1,i*(1-n)+n)),o=255*(1-Math.min(1,s*(1-n)+n)),h=255*(1-Math.min(1,e*(1-n)+n));return new t(r,o,h)}return this;var i}toArray(){const{_a:t,_b:i,_c:s,_d:e,space:n}=this;return[t,i,s,e,n]}toHex(){const[t,i,s]=this._clamped().map(cr);return`#${t}${i}${s}`}toRgb(){const[t,i,s]=this._clamped();return`rgb(${t},${i},${s})`}toString(){return this.toHex()}xyz(){const{_a:i,_b:s,_c:e}=this.rgb(),[n,r,o]=[i,s,e].map((t=>t/255)),h=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92,a=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,l=o>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92,c=(.4124*h+.3576*a+.1805*l)/.95047,u=(.2126*h+.7152*a+.0722*l)/1,d=(.0193*h+.1192*a+.9505*l)/1.08883,f=c>.008856?Math.pow(c,1/3):7.787*c+16/116,v=u>.008856?Math.pow(u,1/3):7.787*u+16/116,p=d>.008856?Math.pow(d,1/3):7.787*d+16/116;return new t(f,v,p,"xyz")}_clamped(){const{_a:t,_b:i,_c:s}=this.rgb(),{max:e,min:n,round:r}=Math;return[t,i,s].map((t=>e(0,n(r(t),255))))}},vr=class t{constructor(...t){this.init(...t)}clone(){return new t(this)}init(t,i){const s=Array.isArray(t)?{x:t[0],y:t[1]}:"object"==typeof t?{x:t.x,y:t.y}:{x:t,y:i};return this.x=null==s.x?0:s.x,this.y=null==s.y?0:s.y,this}toArray(){return[this.x,this.y]}transform(t){return this.clone().transformO(t)}transformO(t){gr.isMatrixLike(t)||(t=new gr(t));const{x:i,y:s}=this;return this.x=t.a*i+t.c*s+t.e,this.y=t.b*i+t.d*s+t.f,this}};function pr(t,i){return Math.abs(i-t)<1e-6}var gr=class t{constructor(...t){this.init(...t)}static formatTransforms(t){const i="both"===t.flip||!0===t.flip,s=t.flip&&(i||"x"===t.flip)?-1:1,e=t.flip&&(i||"y"===t.flip)?-1:1,n=t.skew&&t.skew.length?t.skew[0]:isFinite(t.skew)?t.skew:isFinite(t.skewX)?t.skewX:0,r=t.skew&&t.skew.length?t.skew[1]:isFinite(t.skew)?t.skew:isFinite(t.skewY)?t.skewY:0,o=t.scale&&t.scale.length?t.scale[0]*s:isFinite(t.scale)?t.scale*s:isFinite(t.scaleX)?t.scaleX*s:s,h=t.scale&&t.scale.length?t.scale[1]*e:isFinite(t.scale)?t.scale*e:isFinite(t.scaleY)?t.scaleY*e:e,a=t.shear||0,l=t.rotate||t.theta||0,c=new vr(t.origin||t.around||t.ox||t.originX,t.oy||t.originY),u=c.x,d=c.y,f=new vr(t.position??t.px??t.positionX??NaN,t.py??t.positionY??NaN),v=f.x,p=f.y,g=new vr(t.translate||t.tx||t.translateX,t.ty||t.translateY),m=g.x,b=g.y,y=new vr(t.relative||t.rx||t.relativeX,t.ry||t.relativeY);return{scaleX:o,scaleY:h,skewX:n,skewY:r,shear:a,theta:l,rx:y.x,ry:y.y,tx:m,ty:b,ox:u,oy:d,px:v,py:p}}static fromArray(t){return{a:t[0],b:t[1],c:t[2],d:t[3],e:t[4],f:t[5]}}static isMatrixLike(t){return null!=t.a||null!=t.b||null!=t.c||null!=t.d||null!=t.e||null!=t.f}static matrixMultiply(t,i,s){const e=t.b*i.a+t.d*i.b,n=t.a*i.c+t.c*i.d,r=t.b*i.c+t.d*i.d,o=t.e+t.a*i.e+t.c*i.f,h=t.f+t.b*i.e+t.d*i.f;return s.a=t.a*i.a+t.c*i.b,s.b=e,s.c=n,s.d=r,s.e=o,s.f=h,s}around(t,i,s){return this.clone().aroundO(t,i,s)}aroundO(t,i,s){const e=t||0,n=i||0;return this.translateO(-e,-n).lmultiplyO(s).translateO(e,n)}clone(){return new t(this)}decompose(t=0,i=0){const s=this.a,e=this.b,n=this.c,r=this.d,o=this.e,h=this.f,a=s*r-e*n,l=a>0?1:-1,c=l*Math.sqrt(s*s+e*e),u=Math.atan2(l*e,l*s),d=(s*n+e*r)/a;return{scaleX:c,scaleY:n*c/(d*s-e)||r*c/(d*e+s),shear:d,rotate:180/Math.PI*u,translateX:o-t+t*s+i*n,translateY:h-i+t*e+i*r,originX:t,originY:i,a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f}}equals(i){if(i===this)return!0;const s=new t(i);return pr(this.a,s.a)&&pr(this.b,s.b)&&pr(this.c,s.c)&&pr(this.d,s.d)&&pr(this.e,s.e)&&pr(this.f,s.f)}flip(t,i){return this.clone().flipO(t,i)}flipO(t,i){return"x"===t?this.scaleO(-1,1,i,0):"y"===t?this.scaleO(1,-1,0,i):this.scaleO(-1,-1,t,i||t)}init(i){const s=t.fromArray([1,0,0,1,0,0]);return i=i instanceof jr?i.matrixify():"string"==typeof i?t.fromArray(i.split(hr).map(parseFloat)):Array.isArray(i)?t.fromArray(i):"object"==typeof i&&t.isMatrixLike(i)?i:"object"==typeof i?(new t).transform(i):6===arguments.length?t.fromArray([].slice.call(arguments)):s,this.a=null!=i.a?i.a:s.a,this.b=null!=i.b?i.b:s.b,this.c=null!=i.c?i.c:s.c,this.d=null!=i.d?i.d:s.d,this.e=null!=i.e?i.e:s.e,this.f=null!=i.f?i.f:s.f,this}inverse(){return this.clone().inverseO()}inverseO(){const t=this.a,i=this.b,s=this.c,e=this.d,n=this.e,r=this.f,o=t*e-i*s;if(!o)throw new Error("Cannot invert "+this);const h=e/o,a=-i/o,l=-s/o,c=t/o,u=-(h*n+l*r),d=-(a*n+c*r);return this.a=h,this.b=a,this.c=l,this.d=c,this.e=u,this.f=d,this}lmultiply(t){return this.clone().lmultiplyO(t)}lmultiplyO(i){const s=i instanceof t?i:new t(i);return t.matrixMultiply(s,this,this)}multiply(t){return this.clone().multiplyO(t)}multiplyO(i){const s=i instanceof t?i:new t(i);return t.matrixMultiply(this,s,this)}rotate(t,i,s){return this.clone().rotateO(t,i,s)}rotateO(t,i=0,s=0){t=_n(t);const e=Math.cos(t),n=Math.sin(t),{a:r,b:o,c:h,d:a,e:l,f:c}=this;return this.a=r*e-o*n,this.b=o*e+r*n,this.c=h*e-a*n,this.d=a*e+h*n,this.e=l*e-c*n+s*n-i*e+i,this.f=c*e+l*n-i*n-s*e+s,this}scale(){return this.clone().scaleO(...arguments)}scaleO(t,i=t,s=0,e=0){3===arguments.length&&(e=s,s=i,i=t);const{a:n,b:r,c:o,d:h,e:a,f:l}=this;return this.a=n*t,this.b=r*i,this.c=o*t,this.d=h*i,this.e=a*t-s*t+s,this.f=l*i-e*i+e,this}shear(t,i,s){return this.clone().shearO(t,i,s)}shearO(t,i=0,s=0){const{a:e,b:n,c:r,d:o,e:h,f:a}=this;return this.a=e+n*t,this.c=r+o*t,this.e=h+a*t-s*t,this}skew(){return this.clone().skewO(...arguments)}skewO(t,i=t,s=0,e=0){3===arguments.length&&(e=s,s=i,i=t),t=_n(t),i=_n(i);const n=Math.tan(t),r=Math.tan(i),{a:o,b:h,c:a,d:l,e:c,f:u}=this;return this.a=o+h*n,this.b=h+o*r,this.c=a+l*n,this.d=l+a*r,this.e=c+u*n-e*n,this.f=u+c*r-s*r,this}skewX(t,i,s){return this.skew(t,0,i,s)}skewY(t,i,s){return this.skew(0,t,i,s)}toArray(){return[this.a,this.b,this.c,this.d,this.e,this.f]}toString(){return"matrix("+this.a+","+this.b+","+this.c+","+this.d+","+this.e+","+this.f+")"}transform(i){if(t.isMatrixLike(i))return new t(i).multiplyO(this);const s=t.formatTransforms(i),{x:e,y:n}=new vr(s.ox,s.oy).transform(this),r=(new t).translateO(s.rx,s.ry).lmultiplyO(this).translateO(-e,-n).scaleO(s.scaleX,s.scaleY).skewO(s.skewX,s.skewY).shearO(s.shear).rotateO(s.theta).translateO(e,n);if(isFinite(s.px)||isFinite(s.py)){const t=new vr(e,n).transform(r),i=isFinite(s.px)?s.px-t.x:0,o=isFinite(s.py)?s.py-t.y:0;r.translateO(i,o)}return r.translateO(s.tx,s.ty),r}translate(t,i){return this.clone().translateO(t,i)}translateO(t,i){return this.e+=t||0,this.f+=i||0,this}valueOf(){return{a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f}}};function mr(){if(!mr.nodes||mr.nodes.svg.node.ownerDocument!==Pn.document){const t=Fn().size(2,0);t.node.style.cssText=["opacity: 0","position: absolute","left: -100%","top: -100%","overflow: hidden"].join(";"),t.attr("focusable","false"),t.attr("aria-hidden","true"),mr.nodes={svg:t,path:t.path().node}}return mr.nodes.svg.node.parentNode||mr.nodes.svg.addTo(Pn.document.body||Pn.document.documentElement),mr.nodes}function br(t){return!(t.width||t.height||t.x||t.y)}Yn(gr,"Matrix");var yr=class t{constructor(...t){this.init(...t)}addOffset(){return this.x+=Pn.window.pageXOffset,this.y+=Pn.window.pageYOffset,new t(this)}init(t){return t="string"==typeof t?t.split(hr).map(parseFloat):Array.isArray(t)?t:"object"==typeof t?[null!=t.left?t.left:t.x,null!=t.top?t.top:t.y,t.width,t.height]:4===arguments.length?[].slice.call(arguments):[0,0,0,0],this.x=t[0]||0,this.y=t[1]||0,this.width=this.w=t[2]||0,this.height=this.h=t[3]||0,this.x2=this.x+this.w,this.y2=this.y+this.h,this.cx=this.x+this.w/2,this.cy=this.y+this.h/2,this}isNulled(){return br(this)}merge(i){const s=Math.min(this.x,i.x),e=Math.min(this.y,i.y),n=Math.max(this.x+this.width,i.x+i.width)-s,r=Math.max(this.y+this.height,i.y+i.height)-e;return new t(s,e,n,r)}toArray(){return[this.x,this.y,this.width,this.height]}toString(){return this.x+" "+this.y+" "+this.width+" "+this.height}transform(i){i instanceof gr||(i=new gr(i));let s=1/0,e=-1/0,n=1/0,r=-1/0;return[new vr(this.x,this.y),new vr(this.x2,this.y),new vr(this.x,this.y2),new vr(this.x2,this.y2)].forEach((function(t){t=t.transform(i),s=Math.min(s,t.x),e=Math.max(e,t.x),n=Math.min(n,t.y),r=Math.max(r,t.y)})),new t(s,n,e-s,r-n)}};function wr(t,i,s){let e;try{if(e=i(t.node),br(e)&&(n=t.node)!==Pn.document&&!(Pn.document.documentElement.contains||function(t){for(;t.parentNode;)t=t.parentNode;return t===Pn.document}).call(Pn.document.documentElement,n))throw new Error("Element not in the dom")}catch(i){e=s(t)}var n;return e}re({viewbox:{viewbox(t,i,s,e){return null==t?new yr(this.attr("viewBox")):this.attr("viewBox",new yr(t,i,s,e))},zoom(t,i){let{width:s,height:e}=this.attr(["width","height"]);if((s||e)&&"string"!=typeof s&&"string"!=typeof e||(s=this.node.clientWidth,e=this.node.clientHeight),!s||!e)throw new Error("Impossible to get absolute width and height. Please provide an absolute width and height attribute on the zooming element");const n=this.viewbox(),r=s/n.width,o=e/n.height,h=Math.min(r,o);if(null==t)return h;let a=h/t;a===1/0&&(a=Number.MAX_SAFE_INTEGER/100),i=i||new vr(s/2/r+n.x,e/2/o+n.y);const l=new yr(n).transform(new gr({scale:a,origin:i}));return this.viewbox(l)}}}),Yn(yr,"Box");var xr=class extends Array{constructor(t=[],...i){if(super(t,...i),"number"==typeof t)return this;this.length=0,this.push(...t)}};Xn([xr],{each(t,...i){return this.map("function"==typeof t?(i,s,e)=>t.call(i,i,s,e):s=>s[t](...i))},toArray(){return Array.prototype.concat.apply([],this)}});const Sr=["toArray","constructor","each"];function $r(t){let i=(t+"").trim();const s=i.match(/^url\((.*)\)$/i);if(s){i=s[1].trim();const t=i[0];if('"'===t||"'"===t){if(i[i.length-1]!==t)return null;i=i.slice(1,-1)}}const e=i.match(Zn);return e?e[1].slice(1):null}function Mr(t,i){const s=`#${Pn.window.CSS.escape(i)}`;return 1===t.nodeType&&t.matches(s)?t:t.querySelector(s)}function _r(t,i,s=`[${i}]`){const e=t.getAttribute("id"),n=t.getRootNode();if(!e||Mr(n,e)!==t)return new xr;const r=[];1===n.nodeType&&n.matches(s)&&$r(n.getAttribute(i))===e&&r.push(jn(n));for(const t of n.querySelectorAll(s))$r(t.getAttribute(i))===e&&r.push(jn(t));return new xr(r)}xr.extend=function(t){t=t.reduce(((t,i)=>((0,$n.default)(Sr).call(Sr,i)||"_"===i[0]||(i in Array.prototype&&(t["$"+i]=Array.prototype[i]),t[i]=function(...t){return this.each(i,...t)}),t)),{}),Xn([xr],t)};let Or=0;const kr=new WeakMap,Ar=new WeakMap,Rr=()=>Object.create(null);function Nr(t){const i=t.getEventHolder();let s=kr.get(i);return s||(s=Rr(),kr.set(i,s)),s}function Lr(t){return t.getEventTarget()}function Er(t,i,s,e,n){const r=s.bind(e||t),o=n||!1,h=Fn(t),a=Nr(h),l=Lr(h);i=Array.isArray(i)?i:i.split(hr);let c=Ar.get(s);c||(c=++Or,Ar.set(s,c)),i.forEach((function(t){const i=t.split(".")[0],s=t.split(".")[1]||"*";a[i]=a[i]||Rr(),a[i][s]=a[i][s]||Rr(),a[i][s][c]=a[i][s][c]||[],a[i][s][c].push({listener:r,options:o}),l.addEventListener(i,r,o)}))}function Tr(t,i,s,e){const n=Fn(t),r=Nr(n),o=Lr(n);("function"!=typeof s||(s=Ar.get(s)))&&(i=Array.isArray(i)?i:(i||"").split(hr)).forEach((function(t){const i=t&&t.split(".")[0],h=t&&t.split(".")[1];let a,l;if(s){if(r[i]&&r[i][h||"*"]){const t=r[i][h||"*"][s];if(!t)return;t.forEach((function(t){o.removeEventListener(i,t.listener,t.options??e??!1)})),delete r[i][h||"*"][s]}}else if(i&&h){if(r[i]&&r[i][h]){for(l in r[i][h])Tr(o,[i,h].join("."),l);delete r[i][h]}}else if(h)for(t in r)for(a in r[t])h===a&&Tr(o,[t,h].join("."));else if(i){if(r[i]){for(a in r[i])Tr(o,[i,a].join("."));delete r[i]}}else{for(t in r)Tr(o,t);!function(t){kr.delete(t.getEventHolder())}(n)}}))}var Cr=class extends Wn{addEventListener(){}dispatch(t,i,s){return function(t,i,s,e){const n=Lr(t);return i instanceof Pn.window.Event||(i=new Pn.window.CustomEvent(i,{detail:s,cancelable:!0,...e})),n.dispatchEvent(i),i}(this,t,i,s)}dispatchEvent(t){const i=Nr(this)[t.type];if(!i)return!0;for(const s in i)for(const e in i[s])i[s][e].forEach((function(i){i.listener(t)}));return!t.defaultPrevented}fire(t,i,s){return this.dispatch(t,i,s),this}getEventHolder(){return this}getEventTarget(){return this}off(t,i,s){return Tr(this,t,i,s),this}on(t,i,s,e){return Er(this,t,i,s,e),this}removeEventListener(){}};function Pr(){}Yn(Cr,"EventTarget");const Wr={"fill-opacity":1,"stroke-opacity":1,"stroke-width":0,"stroke-linejoin":"miter","stroke-linecap":"butt",fill:"#000000",stroke:"#000000",opacity:1,x:0,y:0,cx:0,cy:0,width:0,height:0,r:0,rx:0,ry:0,offset:0,"stop-opacity":1,"stop-color":"#000000","text-anchor":"start"};var Dr=class extends Array{constructor(...t){super(...t),this.init(...t)}clone(){return new this.constructor(this)}init(t){return"number"==typeof t||(this.length=0,this.push(...this.parse(t))),this}parse(t=[]){return t instanceof Array?t:t.trim().split(hr).map(parseFloat)}toArray(){return Array.prototype.concat.apply([],this)}toSet(){return new Set(this)}toString(){return this.join(" ")}valueOf(){const t=[];return t.push(...this),t}},zr=class t{constructor(...t){this.init(...t)}convert(i){return new t(this.value,i)}divide(i){return i=new t(i),new t(this/i,this.unit||i.unit)}init(i,s){return s=Array.isArray(i)?i[1]:s,i=Array.isArray(i)?i[0]:i,this.value=0,this.unit=s||"","number"==typeof i?this.value=isNaN(i)?0:isFinite(i)?i:i<0?-34e37:34e37:"string"==typeof i?(s=i.match(qn))&&(this.value=parseFloat(s[1]),"%"===s[5]?this.value/=100:"s"===s[5]&&(this.value*=1e3),this.unit=s[5]):i instanceof t&&(this.value=i.valueOf(),this.unit=i.unit),this}minus(i){return i=new t(i),new t(this-i,this.unit||i.unit)}plus(i){return i=new t(i),new t(this+i,this.unit||i.unit)}times(i){return i=new t(i),new t(this*i,this.unit||i.unit)}toArray(){return[this.value,this.unit]}toJSON(){return this.toString()}toString(){return("%"===this.unit?~~(1e8*this.value)/1e6:"s"===this.unit?this.value/1e3:this.value)+this.unit}valueOf(){return this.value}};const Ur=new Set(["fill","stroke","color","bgcolor","stop-color","flood-color","lighting-color"]),Fr=[];var Gr=class t extends Cr{constructor(t,i){super(),this.node=t,this.type=t.nodeName,i&&t!==i&&this.attr(i)}add(t,i){return(t=Fn(t)).removeNamespace&&this.node instanceof Pn.window.SVGElement&&t.removeNamespace(),null==i?this.node.appendChild(t.node):t.node!==this.node.childNodes[i]&&this.node.insertBefore(t.node,this.node.childNodes[i]),this}addTo(t,i){return Fn(t).put(this,i)}children(){return new xr(Mn(this.node.children,(function(t){return jn(t)})))}clear(){for(;this.node.hasChildNodes();)this.node.removeChild(this.node.lastChild);return this}clone(t=!0,i=!0){this.writeDataToDom();let s=this.node.cloneNode(t);return i&&(s=Vn(s)),new this.constructor(s)}each(t,i){const s=this.children();let e,n;for(e=0,n=s.length;e<n;e++)t.apply(s[e],[e,s]),i&&s[e].each(t,i);return this}element(i,s){return this.put(new t(Un(i),s))}first(){return jn(this.node.firstChild)}get(t){return jn(this.node.childNodes[t])}getEventHolder(){return this.node}getEventTarget(){return this.node}has(t){return this.index(t)>=0}html(t,i){return this.xml(t,i,"http://www.w3.org/1999/xhtml")}id(t){return void 0!==t||this.node.id||(this.node.id=Hn(this.type)),this.attr("id",t)}index(t){return[].slice.call(this.node.childNodes).indexOf(t.node)}last(){return jn(this.node.lastChild)}matches(t){const i=this.node,s=i.matches||i.matchesSelector||i.msMatchesSelector||i.mozMatchesSelector||i.webkitMatchesSelector||i.oMatchesSelector||null;return s&&s.call(i,t)}parent(t){let i=this;if(!i.node.parentNode)return null;if(i=jn(i.node.parentNode),!t)return i;do{if("string"==typeof t?i.matches(t):i instanceof t)return i}while(i=jn(i.node.parentNode));return i}put(t,i){return t=Fn(t),this.add(t,i),t}putIn(t,i){return Fn(t).add(this,i)}remove(){return this.parent()&&this.parent().removeElement(this),this}removeElement(t){return this.node.removeChild(t.node),this}replace(t){return t=Fn(t),this.node.parentNode&&this.node.parentNode.replaceChild(t.node,this.node),t}round(t=2,i=null){const s=10**t,e=this.attr(i);for(const t in e)"number"==typeof e[t]&&(e[t]=Math.round(e[t]*s)/s);return this.attr(e),this}svg(t,i){return this.xml(t,i,En)}toString(){return this.id()}words(t){return this.node.textContent=t,this}wrap(t){const i=this.parent();if(!i)return this.addTo(t);const s=i.index(this);return i.put(t,s).put(this)}writeDataToDom(){return this.each((function(){this.writeDataToDom()})),this}xml(t,i,s){if("boolean"==typeof t&&(s=i,i=t,t=null),null==t||"function"==typeof t){i=null==i||i,this.writeDataToDom();let s=this;if(null!=t){if(s=jn(s.node.cloneNode(!0)),i){const i=t(s);if(s=i||s,!1===i)return""}s.each((function(){const i=t(this),s=i||this;!1===i?this.remove():i&&this!==s&&this.replace(s)}),!0)}return i?s.node.outerHTML:s.node.innerHTML}i=null!=i&&i;const e=Un("wrapper",s),n=Pn.document.createDocumentFragment();e.innerHTML=t;for(let t=e.children.length;t--;)n.appendChild(e.firstElementChild);const r=this.parent();return i?this.replace(n)&&r:this.add(n)}};Xn(Gr,{attr:function(t,i,s){if(null==t){t={},i=this.node.attributes;for(const s of i)t[s.nodeName]=rr.test(s.nodeValue)?parseFloat(s.nodeValue):s.nodeValue;return t}if(t instanceof Array)return t.reduce(((t,i)=>(t[i]=this.attr(i),t)),{});if("object"==typeof t&&t.constructor===Object)for(i in t)this.attr(i,t[i]);else if(null===i)this.node.removeAttribute(t);else{if(null==i)return null==(i=this.node.getAttribute(t))?Wr[t]:rr.test(i)?parseFloat(i):i;"number"==typeof(i=Fr.reduce(((i,s)=>s(t,i,this)),i))?i=new zr(i):Ur.has(t)&&fr.isColor(i)?i=new fr(i):i.constructor===Array&&(i=new Dr(i)),"leading"===t?this.leading&&this.leading(i):"string"==typeof s?this.node.setAttributeNS(s,t,i.toString()):this.node.setAttribute(t,i.toString()),!this.rebuild||"font-size"!==t&&"x"!==t||this.rebuild()}return this},find:function(t){return function(t,i){return new xr(Mn((i||Pn.document).querySelectorAll(t),(function(t){return jn(t)})))}(t,this.node)},findOne:function(t){return jn(this.node.querySelector(t))}}),Yn(Gr,"Dom");var jr=class extends Gr{constructor(t,i){super(t,i),this.dom={},this.node.instance=this,(t.hasAttribute("data-svgjs")||t.hasAttribute("svgjs:data"))&&this.setData(JSON.parse(t.getAttribute("data-svgjs"))??JSON.parse(t.getAttribute("svgjs:data"))??{})}center(t,i){return this.cx(t).cy(i)}cx(t){return null==t?this.x()+this.width()/2:this.x(t-this.width()/2)}cy(t){return null==t?this.y()+this.height()/2:this.y(t-this.height()/2)}defs(){const t=this.root();return t&&t.defs()}dmove(t,i){return this.dx(t).dy(i)}dx(t=0){return this.x(new zr(t).plus(this.x()))}dy(t=0){return this.y(new zr(t).plus(this.y()))}getEventHolder(){return this}height(t){return this.attr("height",t)}move(t,i){return this.x(t).y(i)}parents(t=this.root()){const i="string"==typeof t,s=this.root(),e=s&&s.node;i||(t=t&&Fn(t).node);const n=new xr;let r=this;for(;(r=r.parent())&&r.node!==Pn.document&&"#document-fragment"!==r.node.nodeName&&(n.push(r),i||r.node!==t)&&(!i||!r.matches(t));)if(e&&r.node===e)return null;return n}reference(t){if(!(t=this.attr(t)))return null;const i=function(t,i){const s=$r(i);return s?Mr(t.getRootNode(),s):null}(this.node,t);return i?Fn(i):null}root(){const t=this.parent(Dn[zn]);return t&&t.root()}setData(t){return this.dom=t,this}size(t,i){const s=An(this,t,i);return this.width(new zr(s.width)).height(new zr(s.height))}width(t){return this.attr("width",t)}writeDataToDom(t){return((t,i,s={})=>{const e={...this.dom};for(const t in e)e[t].valueOf()===s[t]&&delete e[t];Object.keys(e).length?t.node.setAttribute("data-svgjs",JSON.stringify(e)):(t.node.removeAttribute("data-svgjs"),t.node.removeAttribute("svgjs:data"))})(this,0,t),super.writeDataToDom()}x(t){return this.attr("x",t)}y(t){return this.attr("y",t)}};Xn(jr,{bbox:function(){const t=wr(this,(t=>t.getBBox()),(t=>{try{const i=t.clone().addTo(mr().svg).show(),s=i.node.getBBox();return i.remove(),s}catch(i){throw new Error(`Getting bbox of element "${t.node.nodeName}" is not possible: ${i.toString()}`)}}));return new yr(t)},rbox:function(t){const i=wr(this,(t=>t.getBoundingClientRect()),(t=>{throw new Error(`Getting rbox of element "${t.node.nodeName}" is not possible`)})),s=new yr(i);return t?s.transform(t.screenCTM().inverseO()):s.addOffset()},inside:function(t,i){const s=this.bbox();return t>s.x&&i>s.y&&t<s.x+s.width&&i<s.y+s.height},point:function(t,i){return new vr(t,i).transformO(this.screenCTM().inverseO())},ctm:function(){return new gr(this.node.getCTM())},screenCTM:function(){try{if("function"==typeof this.isRoot&&!this.isRoot()){const t=this.rect(1,1),i=t.node.getScreenCTM();return t.remove(),new gr(i)}return new gr(this.node.getScreenCTM())}catch(t){return console.warn(`Cannot get CTM from SVG node ${this.node.nodeName}. Is the element rendered?`),new gr}}}),Yn(jr,"Element");const Ir={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,i){return"color"===i?t:t+"-"+i}};["fill","stroke"].forEach((function(t){const i={};let s;i[t]=function(i){if(void 0===i)return this.attr(t);if("string"==typeof i||i instanceof fr||fr.isRgb(i)||i instanceof jr)this.attr(t,i);else for(s=Ir[t].length-1;s>=0;s--)null!=i[Ir[t][s]]&&this.attr(Ir.prefix(t,Ir[t][s]),i[Ir[t][s]]);return this},re(["Element","Runner"],i)})),re(["Element","Runner"],{matrix:function(t,i,s,e,n,r){return null==t?new gr(this):this.attr("transform",new gr(t,i,s,e,n,r))},rotate:function(t,i,s){return this.transform({rotate:t,ox:i,oy:s},!0)},skew:function(t,i,s,e){return this.transform(1===arguments.length||3===arguments.length?{skew:t,ox:i,oy:s}:{skew:[t,i],ox:s,oy:e},!0)},shear:function(t,i,s){return this.transform({shear:t,ox:i,oy:s},!0)},scale:function(t,i,s,e){return this.transform(1===arguments.length||3===arguments.length?{scale:t,ox:i,oy:s}:{scale:[t,i],ox:s,oy:e},!0)},translate:function(t,i){return this.transform({translate:[t,i]},!0)},relative:function(t,i){return this.transform({relative:[t,i]},!0)},flip:function(t="both",i="center"){return-1==="xybothtrue".indexOf(t)&&(i=t,t="both"),this.transform({flip:t,origin:i},!0)},opacity:function(t){return this.attr("opacity",t)}}),re("radius",{radius:function(t,i=t){return"radialGradient"===(this._element||this).type?this.attr("r",new zr(t)):this.rx(t).ry(i)}}),re("Path",{length:function(){return this.node.getTotalLength()},pointAt:function(t){return new vr(this.node.getPointAtLength(t))}}),re(["Element","Runner"],{font:function(t,i){if("object"==typeof t){for(i in t)this.font(i,t[i]);return this}return"leading"===t?this.leading(i):this.attr("anchor"===t?"text-anchor":"size"===t||"family"===t||"weight"===t||"stretch"===t||"variant"===t||"style"===t?"font-"+t:t,i)}}),re("Element",["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","touchstart","touchmove","touchleave","touchend","touchcancel","contextmenu","wheel","pointerdown","pointermove","pointerup","pointerleave","pointercancel"].reduce((function(t,i){return t[i]=function(t){return null===t?this.off(i):this.on(i,t),this},t}),{})),re("Element",{untransform:function(){return this.attr("transform",null)},matrixify:function(){return(this.attr("transform")||"").split(tr).slice(0,-1).map((function(t){const i=t.trim().split("(");return[i[0].trim(),i[1].split(hr).map((function(t){return parseFloat(t)}))]})).reverse().reduce((function(t,i){return"matrix"===i[0]?t.lmultiply(gr.fromArray(i[1])):t[i[0]].apply(t,i[1])}),new gr)},toParent:function(t,i){if(this===t)return this;if(Ln(this.node))return this.addTo(t,i);const s=this.screenCTM(),e=t.screenCTM().inverse();return this.addTo(t,i).untransform().transform(e.multiply(s)),this},toRoot:function(t){return this.toParent(this.root(),t)},transform:function(t,i){if(null==t||"string"==typeof t){const i=new gr(this).decompose();return null==t?i:i[t]}gr.isMatrixLike(t)||(t={...t,origin:Rn(t,this)});const s=new gr(!0===i?this:i||!1).transform(t);return this.attr("transform",s)}});var Yr=class t extends jr{flatten(){return this.each((function(){if(this instanceof t)return this.flatten().ungroup()})),this}ungroup(t=this.parent(),i=t.index(this)){return i=-1===i?t.children().length:i,this.each((function(s,e){return e[e.length-s-1].toParent(t,i)})),this.remove()}};Yn(Yr,"Container");var Br=class extends Yr{constructor(t,i=t){super(Gn("defs",t),i)}flatten(){return this}ungroup(){return this}};Yn(Br,"Defs");var Hr=class extends jr{};Yn(Hr,"Shape");var Vr=ie({cx:()=>Qr,cy:()=>Zr,height:()=>io,rx:()=>Xr,ry:()=>Jr,width:()=>to,x:()=>qr,y:()=>Kr});function Xr(t){return this.attr("rx",t)}function Jr(t){return this.attr("ry",t)}function qr(t){return null==t?this.cx()-this.rx():this.cx(t+this.rx())}function Kr(t){return null==t?this.cy()-this.ry():this.cy(t+this.ry())}function Qr(t){return this.attr("cx",t)}function Zr(t){return this.attr("cy",t)}function to(t){return null==t?2*this.rx():this.rx(new zr(t).divide(2))}function io(t){return null==t?2*this.ry():this.ry(new zr(t).divide(2))}var so=class extends Hr{constructor(t,i=t){super(Gn("ellipse",t),i)}size(t,i){const s=An(this,t,i);return this.rx(new zr(s.width).divide(2)).ry(new zr(s.height).divide(2))}};Xn(so,Vr),re("Container",{ellipse:Jn((function(t=0,i=t){return this.put(new so).size(t,i).move(0,0)}))}),Yn(so,"Ellipse");var eo=class extends Gr{constructor(t=Pn.document.createDocumentFragment()){super(t)}xml(t,i,s){if("boolean"==typeof t&&(s=i,i=t,t=null),null==t||"function"==typeof t){const t=new Gr(Un("wrapper",s));return t.add(this.node.cloneNode(!0)),t.xml(!1,s)}return super.xml(t,!1,s)}};Yn(eo,"Fragment");var no=ie({from:()=>ro,to:()=>oo});function ro(t,i){return this.attr("radialGradient"===(this._element||this).type?{fx:new zr(t),fy:new zr(i)}:{x1:new zr(t),y1:new zr(i)})}function oo(t,i){return this.attr("radialGradient"===(this._element||this).type?{cx:new zr(t),cy:new zr(i)}:{x2:new zr(t),y2:new zr(i)})}var ho=class extends Yr{constructor(t,i){super(Gn(t+"Gradient","string"==typeof t?null:t),i)}attr(t,i,s){return"transform"===t&&(t="gradientTransform"),super.attr(t,i,s)}bbox(){return new yr}targets(){return _r(this.node,"fill")}toString(){return this.url()}update(t){return this.clear(),"function"==typeof t&&t.call(this,this),this}url(){return"url(#"+this.id()+")"}};Xn(ho,no),re({Container:{gradient(...t){return this.defs().gradient(...t)}},Defs:{gradient:Jn((function(t,i){return this.put(new ho(t)).update(i)}))}}),Yn(ho,"Gradient");var ao=class extends Yr{constructor(t,i=t){super(Gn("pattern",t),i)}attr(t,i,s){return"transform"===t&&(t="patternTransform"),super.attr(t,i,s)}bbox(){return new yr}targets(){return _r(this.node,"fill")}toString(){return this.url()}update(t){return this.clear(),"function"==typeof t&&t.call(this,this),this}url(){return"url(#"+this.id()+")"}};re({Container:{pattern(...t){return this.defs().pattern(...t)}},Defs:{pattern:Jn((function(t,i,s){return this.put(new ao).update(s).attr({x:0,y:0,width:t,height:i,patternUnits:"userSpaceOnUse"})}))}}),Yn(ao,"Pattern");var lo=class extends Hr{constructor(t,i=t){super(Gn("image",t),i)}load(t,i){if(!t)return this;const s=new Pn.window.Image;return Er(s,"load",(function(t){const e=this.parent(ao);0===this.width()&&0===this.height()&&this.size(s.width,s.height),e instanceof ao&&0===e.width()&&0===e.height()&&e.size(this.width(),this.height()),"function"==typeof i&&i.call(this,t)}),this),Er(s,"load error",(function(){Tr(s)})),this.attr("href",s.src=t,Cn)}};Fr.push((function(t,i,s){return"fill"!==t&&"stroke"!==t||or.test(i)&&(i=s.root().defs().image(i)),i instanceof lo&&(i=s.root().defs().pattern(0,0,(t=>{t.add(i)}))),i})),re({Container:{image:Jn((function(t,i){return this.put(new lo).size(0,0).load(t,i)}))}}),Yn(lo,"Image");var co=class extends Dr{bbox(){let t=-1/0,i=-1/0,s=1/0,e=1/0;return this.forEach((function(n){t=Math.max(n[0],t),i=Math.max(n[1],i),s=Math.min(n[0],s),e=Math.min(n[1],e)})),new yr(s,e,t-s,i-e)}move(t,i){const s=this.bbox();if(t-=s.x,i-=s.y,!isNaN(t)&&!isNaN(i))for(let s=this.length-1;s>=0;s--)this[s]=[this[s][0]+t,this[s][1]+i];return this}parse(t=[0,0]){const i=[];(t=t instanceof Array?Array.prototype.concat.apply([],t):t.trim().split(hr).map(parseFloat)).length%2!=0&&t.pop();for(let s=0,e=t.length;s<e;s+=2)i.push([t[s],t[s+1]]);return i}size(t,i){let s;const e=this.bbox();for(s=this.length-1;s>=0;s--)e.width&&(this[s][0]=(this[s][0]-e.x)*t/e.width+e.x),e.height&&(this[s][1]=(this[s][1]-e.y)*i/e.height+e.y);return this}toLine(){return{x1:this[0][0],y1:this[0][1],x2:this[1][0],y2:this[1][1]}}toString(){const t=[];for(let i=0,s=this.length;i<s;i++)t.push(this[i].join(","));return t.join(" ")}transform(t){return this.clone().transformO(t)}transformO(t){gr.isMatrixLike(t)||(t=new gr(t));for(let i=this.length;i--;){const[s,e]=this[i];this[i][0]=t.a*s+t.c*e+t.e,this[i][1]=t.b*s+t.d*e+t.f}return this}},uo=ie({MorphArray:()=>fo,height:()=>mo,width:()=>go,x:()=>vo,y:()=>po});const fo=co;function vo(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)}function po(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)}function go(t){const i=this.bbox();return null==t?i.width:this.size(t,i.height)}function mo(t){const i=this.bbox();return null==t?i.height:this.size(i.width,t)}var bo=class extends Hr{constructor(t,i=t){super(Gn("line",t),i)}array(){return new co([[this.attr("x1"),this.attr("y1")],[this.attr("x2"),this.attr("y2")]])}move(t,i){return this.attr(this.array().move(t,i).toLine())}plot(t,i,s,e){return null==t?this.array():(t=void 0!==i?{x1:t,y1:i,x2:s,y2:e}:new co(t).toLine(),this.attr(t))}size(t,i){const s=An(this,t,i);return this.attr(this.array().size(s.width,s.height).toLine())}};Xn(bo,uo),re({Container:{line:Jn((function(...t){return bo.prototype.plot.apply(this.put(new bo),null!=t[0]?t:[0,0,0,0])}))}}),Yn(bo,"Line");var yo=class extends Yr{constructor(t,i=t){super(Gn("marker",t),i)}height(t){return this.attr("markerHeight",t)}orient(t){return this.attr("orient",t)}ref(t,i){return this.attr("refX",t).attr("refY",i)}toString(){return"url(#"+this.id()+")"}update(t){return this.clear(),"function"==typeof t&&t.call(this,this),this}width(t){return this.attr("markerWidth",t)}};function wo(t,i){return function(s){return null==s?this[t]:(this[t]=s,i&&i.call(this),this)}}re({Container:{marker(...t){return this.defs().marker(...t)}},Defs:{marker:Jn((function(t,i,s){return this.put(new yo).size(t,i).ref(t/2,i/2).viewbox(0,0,t,i).attr("orient","auto").update(s)}))},marker:{marker(t,i,s,e){let n=["marker"];return"all"!==t&&n.push(t),n=n.join("-"),t=arguments[1]instanceof yo?arguments[1]:this.defs().marker(i,s,e),this.attr(n,t)}}}),Yn(yo,"Marker");const xo={"-":function(t){return t},"<>":function(t){return-Math.cos(t*Math.PI)/2+.5},">":function(t){return Math.sin(t*Math.PI/2)},"<":function(t){return 1-Math.cos(t*Math.PI/2)},bezier:function(t,i,s,e){return function(n){return n<0?t>0?i/t*n:s>0?e/s*n:0:n>1?s<1?(1-e)/(1-s)*n+(e-s)/(1-s):t<1?(1-i)/(1-t)*n+(i-t)/(1-t):1:3*n*(1-n)**2*i+3*n**2*(1-n)*e+n**3}},steps:function(t,i="end"){i=i.split("-").reverse()[0];let s=t;return"none"===i?--s:"both"===i&&++s,(e,n=!1)=>{let r=Math.floor(e*t);const o=e*r%1==0;return"start"!==i&&"both"!==i||++r,n&&o&&--r,e>=0&&r<0&&(r=0),e<=1&&r>s&&(r=s),r/s}}};var So=class{done(){return!1}},$o=class extends So{constructor(t=">"){super(),this.ease=xo[t]||t}step(t,i,s){return"number"!=typeof t?s<1?t:i:t+(i-t)*this.ease(s)}},Mo=class extends So{constructor(t){super(),this.stepper=t}done(t){return t.done}step(t,i,s,e){return this.stepper(t,i,s,e)}};function _o(){const t=(this._duration||500)/1e3,i=Math.PI,s=Math.log((this._overshoot||0)/100+1e-10),e=-s/Math.sqrt(i*i+s*s),n=3.9/(e*t);this.d=2*e*n,this.k=n*n}Xn(class extends Mo{constructor(t=500,i=0){super(),this.duration(t).overshoot(i)}step(t,i,s,e){if("string"==typeof t)return t;if(e.done=s===1/0,s===1/0)return i;if(0===s)return t;s>100&&(s=16);const n=e.velocity||0,r=-this.d*n-this.k*(t-i),o=t+n*(s/=1e3)+r*s*s/2;return e.velocity=n+r*s,e.done=Math.abs(i-o)+Math.abs(n)<.002,e.done?i:o}},{duration:wo("_duration",_o),overshoot:wo("_overshoot",_o)}),Xn(class extends Mo{constructor(t=.1,i=.01,s=0,e=1e3){super(),this.p(t).i(i).d(s).windup(e)}step(t,i,s,e){if("string"==typeof t)return t;if(e.done=s===1/0,s===1/0)return i;if(0===s)return t;const n=i-t;let r=(e.integral||0)+n*s;const o=(n-(e.error||0))/s,h=this._windup;return!1!==h&&(r=Math.max(-h,Math.min(r,h))),e.error=n,e.integral=r,e.done=Math.abs(n)<.001,e.done?i:t+(this.P*n+this.I*r+this.D*o)}},{windup:wo("_windup"),p:wo("P"),i:wo("I"),d:wo("D")});const Oo={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0},ko={M:function(t,i,s){return i.x=s.x=t[0],i.y=s.y=t[1],["M",i.x,i.y]},L:function(t,i){return i.x=t[0],i.y=t[1],["L",t[0],t[1]]},H:function(t,i){return i.x=t[0],["H",t[0]]},V:function(t,i){return i.y=t[0],["V",t[0]]},C:function(t,i){return i.x=t[4],i.y=t[5],["C",t[0],t[1],t[2],t[3],t[4],t[5]]},S:function(t,i){return i.x=t[2],i.y=t[3],["S",t[0],t[1],t[2],t[3]]},Q:function(t,i){return i.x=t[2],i.y=t[3],["Q",t[0],t[1],t[2],t[3]]},T:function(t,i){return i.x=t[0],i.y=t[1],["T",t[0],t[1]]},Z:function(t,i,s){return i.x=s.x,i.y=s.y,["Z"]},A:function(t,i){return i.x=t[5],i.y=t[6],["A",t[0],t[1],t[2],t[3],t[4],t[5],t[6]]}},Ao="mlhvqtcsaz".split("");for(let t=0,i=Ao.length;t<i;++t)ko[Ao[t]]=function(t){return function(i,s,e){if("H"===t)i[0]=i[0]+s.x;else if("V"===t)i[0]=i[0]+s.y;else if("A"===t)i[5]=i[5]+s.x,i[6]=i[6]+s.y;else for(let t=0,e=i.length;t<e;++t)i[t]=i[t]+(t%2?s.y:s.x);return ko[t](i,s,e)}}(Ao[t].toUpperCase());function Ro(t){return t.segment.length&&t.segment.length-1===Oo[t.segment[0].toUpperCase()]}function No(t,i){t.inNumber&&Lo(t,!1);const s=ar.test(i);if(s)t.segment=[i];else{const i=t.lastCommand,s=i.toLowerCase();t.segment=["m"===s?i===s?"l":"L":i]}return t.inSegment=!0,t.lastCommand=t.segment[0],s}function Lo(t,i){if(!t.inNumber)throw new Error("Parser Error");t.number&&t.segment.push(parseFloat(t.number)),t.inNumber=i,t.number="",t.pointSeen=!1,t.hasExponent=!1,Ro(t)&&Eo(t)}function Eo(t){t.inSegment=!1,t.absolute&&(t.segment=function(t){return ko[t.segment[0]](t.segment.slice(1),t.p,t.p0)}(t)),t.segments.push(t.segment)}function To(t){if(!t.segment.length)return!1;const i="A"===t.segment[0].toUpperCase(),s=t.segment.length;return i&&(4===s||5===s)}function Co(t){return"E"===t.lastToken.toUpperCase()}const Po=new Set([" ",",","\t","\n","\r","\f"]);var Wo=class extends Dr{bbox(){return mr().path.setAttribute("d",this.toString()),new yr(mr.nodes.path.getBBox())}move(t,i){const s=this.bbox();if(t-=s.x,i-=s.y,!isNaN(t)&&!isNaN(i))for(let s,e=this.length-1;e>=0;e--)s=this[e][0],"M"===s||"L"===s||"T"===s?(this[e][1]+=t,this[e][2]+=i):"H"===s?this[e][1]+=t:"V"===s?this[e][1]+=i:"C"===s||"S"===s||"Q"===s?(this[e][1]+=t,this[e][2]+=i,this[e][3]+=t,this[e][4]+=i,"C"===s&&(this[e][5]+=t,this[e][6]+=i)):"A"===s&&(this[e][6]+=t,this[e][7]+=i);return this}parse(t="M0 0"){return Array.isArray(t)&&(t=Array.prototype.concat.apply([],t).toString()),function(t,i=!0){let s=0,e="";const n={segment:[],inNumber:!1,number:"",lastToken:"",inSegment:!1,segments:[],pointSeen:!1,hasExponent:!1,absolute:i,p0:new vr,p:new vr};for(;n.lastToken=e,e=t.charAt(s++);)if(n.inSegment||!No(n,e))if("."!==e)if(isNaN(parseInt(e)))if(Po.has(e))n.inNumber&&Lo(n,!1);else if("-"!==e&&"+"!==e)if("E"!==e.toUpperCase()){if(ar.test(e)){if(n.inNumber)Lo(n,!1);else{if(!Ro(n))throw new Error("parser Error");Eo(n)}--s}}else n.number+=e,n.hasExponent=!0;else{if(n.inNumber&&!Co(n)){Lo(n,!1),--s;continue}n.number+=e,n.inNumber=!0}else{if("0"===n.number||To(n)){n.inNumber=!0,n.number=e,Lo(n,!0);continue}n.inNumber=!0,n.number+=e}else{if(n.pointSeen||n.hasExponent){Lo(n,!1),--s;continue}n.inNumber=!0,n.pointSeen=!0,n.number+=e}return n.inNumber&&Lo(n,!1),n.inSegment&&Ro(n)&&Eo(n),n.segments}(t)}size(t,i){const s=this.bbox();let e,n;for(s.width=0===s.width?1:s.width,s.height=0===s.height?1:s.height,e=this.length-1;e>=0;e--)n=this[e][0],"M"===n||"L"===n||"T"===n?(this[e][1]=(this[e][1]-s.x)*t/s.width+s.x,this[e][2]=(this[e][2]-s.y)*i/s.height+s.y):"H"===n?this[e][1]=(this[e][1]-s.x)*t/s.width+s.x:"V"===n?this[e][1]=(this[e][1]-s.y)*i/s.height+s.y:"C"===n||"S"===n||"Q"===n?(this[e][1]=(this[e][1]-s.x)*t/s.width+s.x,this[e][2]=(this[e][2]-s.y)*i/s.height+s.y,this[e][3]=(this[e][3]-s.x)*t/s.width+s.x,this[e][4]=(this[e][4]-s.y)*i/s.height+s.y,"C"===n&&(this[e][5]=(this[e][5]-s.x)*t/s.width+s.x,this[e][6]=(this[e][6]-s.y)*i/s.height+s.y)):"A"===n&&(this[e][1]=this[e][1]*t/s.width,this[e][2]=this[e][2]*i/s.height,this[e][6]=(this[e][6]-s.x)*t/s.width+s.x,this[e][7]=(this[e][7]-s.y)*i/s.height+s.y);return this}toString(){return function(t){let i="";for(let s=0,e=t.length;s<e;s++)i+=t[s][0],null!=t[s][1]&&(i+=t[s][1],null!=t[s][2]&&(i+=" ",i+=t[s][2],null!=t[s][3]&&(i+=" ",i+=t[s][3],i+=" ",i+=t[s][4],null!=t[s][5]&&(i+=" ",i+=t[s][5],i+=" ",i+=t[s][6],null!=t[s][7]&&(i+=" ",i+=t[s][7])))));return i+" "}(this)}};const Do=t=>{const i=typeof t;return"number"===i?zr:"string"===i?fr.isColor(t)?fr:hr.test(t)?ar.test(t)?Wo:Dr:qn.test(t)?zr:Uo:Io.indexOf(t.constructor)>-1?t.constructor:Array.isArray(t)?Dr:"object"===i?jo:Uo};var zo=class{constructor(t){this._stepper=t||new $o("-"),this._from=null,this._to=null,this._type=null,this._context=null,this._morphObj=null}at(t){return this._morphObj.morph(this._from,this._to,t,this._stepper,this._context)}done(){return this._context.map(this._stepper.done).reduce((function(t,i){return t&&i}),!0)}from(t){return null==t?this._from:(this._from=this._set(t),this)}stepper(t){return null==t?this._stepper:(this._stepper=t,this)}to(t){return null==t?this._to:(this._to=this._set(t),this)}type(t){return null==t?this._type:(this._type=t,this)}_set(t){this._type||this.type(Do(t));let i=new this._type(t);return this._type===fr&&(i=this._to?i[this._to[4]]():this._from?i[this._from[4]]():i),this._type===jo&&(i=this._to?i.align(this._to):this._from?i.align(this._from):i),i=i.toConsumable(),this._morphObj=this._morphObj||new this._type,this._context=this._context||Array.apply(null,Array(i.length)).map(Object).map((function(t){return t.done=!0,t})),i}},Uo=class{constructor(...t){this.init(...t)}init(t){return t=Array.isArray(t)?t[0]:t,this.value=t,this}toArray(){return[this.value]}valueOf(){return this.value}},Fo=class t{constructor(...t){this.init(...t)}init(i){return Array.isArray(i)&&(i={scaleX:i[0],scaleY:i[1],shear:i[2],rotate:i[3],translateX:i[4],translateY:i[5],originX:i[6],originY:i[7]}),Object.assign(this,t.defaults,i),this}toArray(){const t=this;return[t.scaleX,t.scaleY,t.shear,t.rotate,t.translateX,t.translateY,t.originX,t.originY]}};Fo.defaults={scaleX:1,scaleY:1,shear:0,rotate:0,translateX:0,translateY:0,originX:0,originY:0};const Go=(t,i)=>t[0]<i[0]?-1:t[0]>i[0]?1:0;var jo=class{constructor(...t){this.init(...t)}align(t){const i=this.values;for(let s=0,e=i.length;s<e;++s){if(i[s+1]===t[s+1]){if(i[s+1]===fr&&t[s+7]!==i[s+7]){const i=t[s+7],e=new fr(this.values.splice(s+3,5))[i]().toArray();this.values.splice(s+3,0,...e)}s+=i[s+2]+2;continue}if(!t[s+1])return this;const e=(new t[s+1]).toArray();i.splice(s,i[s+2]+3,t[s],t[s+1],t[s+2],...e),s+=i[s+2]+2}return this}init(t){if(this.values=[],Array.isArray(t))return void(this.values=t.slice());t=t||{};const i=[];for(const s in t){const e=Do(t[s]),n=new e(t[s]).toArray();i.push([s,e,n.length,...n])}return i.sort(Go),this.values=i.reduce(((t,i)=>t.concat(i)),[]),this}toArray(){return this.values}valueOf(){const t={},i=this.values;for(;i.length;){const s=i.shift(),e=i.shift(),n=i.shift();t[s]=new e(i.splice(0,n))}return t}};const Io=[Uo,Fo,jo];var Yo=class extends Hr{constructor(t,i=t){super(Gn("path",t),i)}array(){return this._array||(this._array=new Wo(this.attr("d")))}clear(){return delete this._array,this}height(t){return null==t?this.bbox().height:this.size(this.bbox().width,t)}move(t,i){return this.attr("d",this.array().move(t,i))}plot(t){return null==t?this.array():this.clear().attr("d","string"==typeof t?t:this._array=new Wo(t))}size(t,i){const s=An(this,t,i);return this.attr("d",this.array().size(s.width,s.height))}width(t){return null==t?this.bbox().width:this.size(t,this.bbox().height)}x(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)}y(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)}};Yo.prototype.MorphArray=Wo,re({Container:{path:Jn((function(t){return this.put(new Yo).plot(t||new Wo)}))}}),Yn(Yo,"Path");var Bo=ie({array:()=>Ho,clear:()=>Vo,move:()=>Xo,plot:()=>Jo,size:()=>qo});function Ho(){return this._array||(this._array=new co(this.attr("points")))}function Vo(){return delete this._array,this}function Xo(t,i){return this.attr("points",this.array().move(t,i))}function Jo(t){return null==t?this.array():this.clear().attr("points","string"==typeof t?t:this._array=new co(t))}function qo(t,i){const s=An(this,t,i);return this.attr("points",this.array().size(s.width,s.height))}var Ko=class extends Hr{constructor(t,i=t){super(Gn("polygon",t),i)}};re({Container:{polygon:Jn((function(t){return this.put(new Ko).plot(t||new co)}))}}),Xn(Ko,uo),Xn(Ko,Bo),Yn(Ko,"Polygon");var Qo=class extends Hr{constructor(t,i=t){super(Gn("polyline",t),i)}};re({Container:{polyline:Jn((function(t){return this.put(new Qo).plot(t||new co)}))}}),Xn(Qo,uo),Xn(Qo,Bo),Yn(Qo,"Polyline");var Zo=class extends Hr{constructor(t,i=t){super(Gn("rect",t),i)}};Xn(Zo,{rx:Xr,ry:Jr}),re({Container:{rect:Jn((function(t,i){return this.put(new Zo).size(t,i)}))}}),Yn(Zo,"Rect");var th=class{constructor(){this._first=null,this._last=null}first(){return this._first&&this._first.value}last(){return this._last&&this._last.value}push(t){const i=void 0!==t.next?t:{value:t,next:null,prev:null};return this._last?(i.prev=this._last,this._last.next=i,this._last=i):(this._last=i,this._first=i),i}remove(t){t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t===this._last&&(this._last=t.prev),t===this._first&&(this._first=t.next),t.prev=null,t.next=null}shift(){const t=this._first;return t?(this._first=t.next,this._first&&(this._first.prev=null),this._last=this._first?this._last:null,t.value):null}};const ih={nextDraw:null,frames:new th,timeouts:new th,immediates:new th,timer:()=>Pn.window.performance||Pn.window.Date,transforms:[],frame(t){const i=ih.frames.push({run:t});return null===ih.nextDraw&&(ih.nextDraw=Pn.window.requestAnimationFrame(ih._draw)),i},timeout(t,i){i=i||0;const s=ih.timer().now()+i,e=ih.timeouts.push({run:t,time:s});return null===ih.nextDraw&&(ih.nextDraw=Pn.window.requestAnimationFrame(ih._draw)),e},immediate(t){const i=ih.immediates.push(t);return null===ih.nextDraw&&(ih.nextDraw=Pn.window.requestAnimationFrame(ih._draw)),i},cancelFrame(t){null!=t&&ih.frames.remove(t)},clearTimeout(t){null!=t&&ih.timeouts.remove(t)},cancelImmediate(t){null!=t&&ih.immediates.remove(t)},_draw(t){try{let i=null;const s=ih.timeouts.last();for(;(i=ih.timeouts.shift())&&(t>=i.time?i.run():ih.timeouts.push(i),i!==s););let e=null;const n=ih.frames.last();for(;e!==n&&(e=ih.frames.shift());)e.run(t);let r=null;for(;r=ih.immediates.shift();)r()}finally{const t=ih.timeouts.first()||ih.frames.first()||ih.immediates.first();ih.nextDraw=t?Pn.window.requestAnimationFrame(ih._draw):null}}},sh=function(t){const i=t.start,s=t.runner.duration();return{start:i,duration:s,end:i+s,runner:t.runner}},eh=function(){const t=Pn.window;return(t.performance||t.Date).now()};var nh=class extends Cr{constructor(t=eh){super(),this._timeSource=t,this.terminate()}active(){return!!this._nextFrame}finish(){return this.time(this.getEndTimeOfTimeline()+1),this.pause()}getEndTime(){const t=this.getLastRunnerInfo(),i=t?t.runner.duration():0;return(t?t.start:this._time)+i}getEndTimeOfTimeline(){const t=this._runners.map((t=>t.start+t.runner.duration()));return Math.max(0,...t)}getLastRunnerInfo(){return this.getRunnerInfoById(this._lastRunnerId)}getRunnerInfoById(t){return this._runners[this._runnerIds.indexOf(t)]||null}pause(){return this._paused=!0,this._continue()}persist(t){return null==t?this._persist:(this._persist=t,this)}play(){return this._paused=!1,this.updateTime()._continue()}reverse(t){const i=this.speed();if(null==t)return this.speed(-i);const s=Math.abs(i);return this.speed(t?-s:s)}schedule(t,i,s){if(null==t)return this._runners.map(sh);let e=0;const n=this.getEndTime();if(i=i||0,null==s||"last"===s||"after"===s)e=n;else if("absolute"===s||"start"===s)e=i,i=0;else if("now"===s)e=this._time;else if("relative"===s){const s=this.getRunnerInfoById(t.id);s&&(e=s.start+i,i=0)}else{if("with-last"!==s)throw new Error('Invalid value for the "when" parameter');{const t=this.getLastRunnerInfo();e=t?t.start:this._time}}t.unschedule(),t.timeline(this);const r=t.persist(),o={persist:null===r?this._persist:r,start:e+i,runner:t};return this._lastRunnerId=t.id,this._runners.push(o),this._runners.sort(((t,i)=>t.start-i.start)),this._runnerIds=this._runners.map((t=>t.runner.id)),this.updateTime()._continue(),this}seek(t){return this.time(this._time+t)}source(t){return null==t?this._timeSource:(this._timeSource=t,this)}speed(t){return null==t?this._speed:(this._speed=t,this)}stop(){return this.time(0),this.pause()}time(t){return null==t?this._time:(this._time=t,this._continue(!0))}unschedule(t){const i=this._runnerIds.indexOf(t.id);return i<0||(this._runners.splice(i,1),this._runnerIds.splice(i,1),t.timeline(null)),this}updateTime(){return this.active()||(this._lastSourceTime=this._timeSource()),this}_continue(t=!1){return ih.cancelFrame(this._nextFrame),this._nextFrame=null,t?this._stepImmediate():(this._paused||(this._nextFrame=ih.frame(this._step)),this)}_stepFn(t=!1){const i=this._timeSource();let s=i-this._lastSourceTime;t&&(s=0);const e=this._speed*s+(this._time-this._lastStepTime);this._lastSourceTime=i,t||(this._time+=e,this._time=this._time<0?0:this._time),this._lastStepTime=this._time,this.fire("time",this._time);for(let t=this._runners.length;t--;){const i=this._runners[t];this._time-i.start<=0&&i.runner.reset()}let n=!1;for(let t=0,i=this._runners.length;t<i;t++){const s=this._runners[t],r=s.runner;let o=e;const h=this._time-s.start;h<=0?n=!0:(h<o&&(o=h),r.active()&&(r.step(o).done?!0!==s.persist&&r.duration()-r.time()+this._time+s.persist<this._time&&(r.unschedule(),--t,--i):n=!0))}return n&&!(this._speed<0&&0===this._time)||this._runnerIds.length&&this._speed<0&&this._time>0?this._continue():(this.pause(),this.fire("finished")),this}terminate(){this._startTime=0,this._speed=1,this._persist=0,this._nextFrame=null,this._paused=!0,this._runners=[],this._runnerIds=[],this._lastRunnerId=-1,this._time=0,this._lastSourceTime=0,this._lastStepTime=0,this._step=this._stepFn.bind(this,!1),this._stepImmediate=this._stepFn.bind(this,!0)}};re({Element:{timeline:function(t){return null==t?(this._timeline=this._timeline||new nh,this._timeline):(this._timeline=t,this)}}});var rh=class t extends Cr{constructor(i){super(),this.id=t.id++,i="function"==typeof(i=null==i?400:i)?new Mo(i):i,this._element=null,this._timeline=null,this.done=!1,this._queue=[],this._duration="number"==typeof i&&i,this._isDeclarative=i instanceof Mo,this._stepper=this._isDeclarative?i:new $o,this._history={},this.enabled=!0,this._time=0,this._lastTime=0,this._reseted=!0,this.transforms=new gr,this.transformId=1,this._haveReversed=!1,this._reverse=!1,this._loopsDone=0,this._swing=!1,this._wait=0,this._times=1,this._frameId=null,this._persist=!!this._isDeclarative||null}static sanitise(t,i,s){let e=1,n=!1,r=0;return i=i??0,s=s||"last","object"!=typeof(t=t??400)||t instanceof So||(i=t.delay??i,s=t.when??s,n=t.swing||n,e=t.times??e,r=t.wait??r,t=t.duration??400),{duration:t,delay:i,swing:n,times:e,wait:r,when:s}}active(t){return null==t?this.enabled:(this.enabled=t,this)}addTransform(t){return this.transforms.lmultiplyO(t),this}after(t){return this.on("finished",t)}animate(i,s,e){const n=t.sanitise(i,s,e),r=new t(n.duration);return this._timeline&&r.timeline(this._timeline),this._element&&r.element(this._element),r.loop(n).schedule(n.delay,n.when)}clearTransform(){return this.transforms=new gr,this}clearTransformsFromQueue(){var t;this.done&&this._timeline&&(0,$n.default)(t=this._timeline._runnerIds).call(t,this.id)||(this._queue=this._queue.filter((t=>!t.isTransform)))}delay(t){return this.animate(0,t)}duration(){return this._times*(this._wait+this._duration)-this._wait}during(t){return this.queue(null,t)}ease(t){return this._stepper=new $o(t),this}element(t){return null==t?this._element:(this._element=t,t._prepareRunner(),this)}finish(){return this.step(1/0)}loop(t,i,s){return"object"==typeof t&&(i=t.swing,s=t.wait,t=t.times),this._times=t||1/0,this._swing=i||!1,this._wait=s||0,!0===this._times&&(this._times=1/0),this}loops(t){const i=this._duration+this._wait;if(null==t){const t=Math.floor(this._time/i);return Math.min(t+(this._time-t*i)/this._duration,this._times)}const s=Math.floor(t);return this.time(i*s+this._duration*(t%1))}persist(t){return null==t?this._persist:(this._persist=t,this)}position(t){const i=this._time,s=this._duration,e=this._wait,n=this._swing,r=this._reverse;let o;if(null==t){const t=function(t){const i=n*Math.floor(t%(2*(e+s))/(e+s)),o=i&&!r||!i&&r,h=Math.pow(-1,o)*(t%(e+s))/s+o;return Math.max(Math.min(h,1),0)},h=this._times*(e+s)-e;return o=i<=0?Math.round(t(1e-5)):i<h?t(i):Math.round(t(h-1e-5)),o}const h=Math.floor(this.loops()),a=n&&h%2==0;return o=h+(a&&!r||r&&a?t:1-t),this.loops(o)}progress(t){return null==t?Math.min(1,this._time/this.duration()):this.time(t*this.duration())}queue(t,i,s,e){return this._queue.push({initialiser:t||Pr,runner:i||Pr,retarget:s,isTransform:e,initialised:!1,finished:!1}),this.timeline()&&this.timeline()._continue(),this}reset(){return this._reseted||(this.time(0),this._reseted=!0),this}reverse(t){return this._reverse=null==t?!this._reverse:t,this}schedule(t,i,s){if(t instanceof nh||(s=i,i=t,t=this.timeline()),!t)throw Error("Runner cannot be scheduled without timeline");return t.schedule(this,i,s),this}step(t){if(!this.enabled)return this;this._time+=t=null==t?16:t;const i=this.position(),s=this._lastPosition!==i&&this._time>=0;this._lastPosition=i;const e=this.duration(),n=this._lastTime<=0&&this._time>0,r=this._lastTime<e&&this._time>=e;this._lastTime=this._time,n&&this.fire("start",this);const o=this._isDeclarative;this.done=!o&&!r&&this._time>=e,this._reseted=!1;let h=!1;return(s||o)&&(this._initialise(s),this.transforms=new gr,h=this._run(o?t:i),this.fire("step",this)),this.done=this.done||h&&o,r&&this.fire("finished",this),this}time(t){return null==t?this._time:(this.step(t-this._time),this)}timeline(t){return void 0===t?this._timeline:(this._timeline=t,this)}unschedule(){const t=this.timeline();return t&&t.unschedule(this),this}_initialise(t){if(t||this._isDeclarative)for(let i=0,s=this._queue.length;i<s;++i){const s=this._queue[i],e=this._isDeclarative||!s.initialised&&t;t=!s.finished,e&&t&&(s.initialiser.call(this),s.initialised=!0)}}_rememberMorpher(t,i){if(this._history[t]={morpher:i,caller:this._queue[this._queue.length-1]},this._isDeclarative){const t=this.timeline();t&&t.play()}}_run(t){let i=!0;for(let s=0,e=this._queue.length;s<e;++s){const e=this._queue[s],n=e.runner.call(this,t);e.finished=e.finished||!0===n,i=i&&e.finished}return i}_tryRetarget(t,i,s){if(this._history[t]){if(!this._history[t].caller.initialised){const i=this._queue.indexOf(this._history[t].caller);return this._queue.splice(i,1),!1}this._history[t].caller.retarget?this._history[t].caller.retarget.call(this,i,s):this._history[t].morpher.to(i),this._history[t].caller.finished=!1;const e=this.timeline();return e&&e.play(),!0}return!1}};rh.id=0;var oh=class{constructor(t=new gr,i=-1,s=!0){this.transforms=t,this.id=i,this.done=s}clearTransformsFromQueue(){}};Xn([rh,oh],{mergeWith(t){return new oh(t.transforms.lmultiply(this.transforms),t.id)}});const hh=(t,i)=>t.lmultiplyO(i),ah=t=>t.transforms;function lh(){const t=this._transformationRunners.runners.map(ah).reduce(hh,new gr);this.transform(t),this._transformationRunners.merge(),1===this._transformationRunners.length()&&(this._frameId=null)}var ch=class{constructor(){this.runners=[],this.ids=[]}add(t){var i;if((0,$n.default)(i=this.runners).call(i,t))return;const s=t.id+1;return this.runners.push(t),this.ids.push(s),this}clearBefore(t){const i=this.ids.indexOf(t+1)||1;return this.ids.splice(0,i,0),this.runners.splice(0,i,new oh).forEach((t=>t.clearTransformsFromQueue())),this}edit(t,i){const s=this.ids.indexOf(t+1);return this.ids.splice(s,1,t+1),this.runners.splice(s,1,i),this}getByID(t){return this.runners[this.ids.indexOf(t+1)]}length(){return this.ids.length}merge(){let t=null;for(let e=0;e<this.runners.length;++e){var i,s;const n=this.runners[e];if(!(t&&n.done&&t.done)||n._timeline&&(0,$n.default)(i=n._timeline._runnerIds).call(i,n.id)||t._timeline&&(0,$n.default)(s=t._timeline._runnerIds).call(s,t.id))t=n;else{this.remove(n.id);const i=n.mergeWith(t);this.edit(t.id,i),t=i,--e}}return this}remove(t){const i=this.ids.indexOf(t+1);return this.ids.splice(i,1),this.runners.splice(i,1),this}};re({Element:{animate(t,i,s){const e=rh.sanitise(t,i,s),n=this.timeline();return new rh(e.duration).loop(e).element(this).timeline(n.play()).schedule(e.delay,e.when)},delay(t,i){return this.animate(0,t,i)},_clearTransformRunnersBefore(t){this._transformationRunners.clearBefore(t.id)},_currentTransform(t){return this._transformationRunners.runners.filter((i=>i.id<=t.id)).map(ah).reduce(hh,new gr)},_addRunner(t){this._transformationRunners.add(t),ih.cancelImmediate(this._frameId),this._frameId=ih.immediate(lh.bind(this))},_prepareRunner(){null==this._frameId&&(this._transformationRunners=(new ch).add(new oh(new gr(this))))}}}),Xn(rh,{attr(t,i){return this.styleAttr("attr",t,i)},css(t,i){return this.styleAttr("css",t,i)},styleAttr(t,i,s){if("string"==typeof i)return this.styleAttr(t,{[i]:s});const e=i,n=this._history[t];if(n&&!n.caller.initialised&&n.caller.retarget)return n.caller.retarget.call(this,e),this;if(this._tryRetarget(t,e))return this;let r=new zo(this._stepper).to(e),o=Object.keys(e);return this.queue((function(){r=r.from(this.element()[t](o))}),(function(i){return this.element()[t](r.at(i).valueOf()),r.done()}),(function(i){const s=(e=Object.keys(i),n=o,e.filter((t=>!(0,$n.default)(n).call(n,t))));var e,n;if(s.length&&null!=r.from()){const i=this.element()[t](s),e=new jo(r.from()).valueOf();Object.assign(e,i),r.from(e)}const h=new jo(r.to()).valueOf();Object.assign(h,i),r.to(h),o=Object.keys(h)})),this._rememberMorpher(t,r),this},zoom(t,i){if(this._tryRetarget("zoom",t,i))return this;let s=new zo(this._stepper).to(new zr(t));return this.queue((function(){s=s.from(this.element().zoom())}),(function(t){return this.element().zoom(s.at(t),i),s.done()}),(function(t,e){i=e,s.to(t)})),this._rememberMorpher("zoom",s),this},transform(t,i,s){if(i=t.relative||i,this._isDeclarative&&!i&&this._tryRetarget("transform",t))return this;const e=gr.isMatrixLike(t);s=null!=t.affine?t.affine:null!=s?s:!e;const n=new zo(this._stepper).type(s?Fo:gr);let r,o,h,a,l;return this.queue((function(){o=o||this.element(),r=r||Rn(t,o),l=new gr(i?void 0:o),o._addRunner(this),i||o._clearTransformRunnersBefore(this)}),(function(c){i||this.clearTransform();const{x:u,y:d}=new vr(r).transform(o._currentTransform(this)),f={...t,origin:[u,d]};!0===f.relative&&delete f.relative;let v=new gr(f),p=this._isDeclarative&&h?h:l;if(s){v=v.decompose(u,d),p=p.decompose(u,d);const t=v.rotate,i=p.rotate,s=[t-360,t,t+360],e=s.map((t=>Math.abs(t-i))),n=Math.min(...e),r=e.indexOf(n);v.rotate=s[r]}i&&(e||(v.rotate=t.rotate||0),this._isDeclarative&&a&&(p.rotate=a)),n.from(p),n.to(v);const g=n.at(c);return a=g.rotate,h=new gr(g),this.addTransform(h),o._addRunner(this),n.done()}),(function(i){(i.origin||"center").toString()!==(t.origin||"center").toString()&&(r=Rn(i,o)),t={...i,origin:r}}),!0),this._isDeclarative&&this._rememberMorpher("transform",n),this},x(t){return this._queueNumber("x",t)},y(t){return this._queueNumber("y",t)},ax(t){return this._queueNumber("ax",t)},ay(t){return this._queueNumber("ay",t)},dx(t=0){return this._queueNumberDelta("x",t)},dy(t=0){return this._queueNumberDelta("y",t)},dmove(t,i){return this.dx(t).dy(i)},_queueNumberDelta(t,i){if(i=new zr(i),this._tryRetarget(t,i))return this;const s=new zo(this._stepper).to(i);let e=null;return this.queue((function(){e=this.element()[t](),s.from(e),s.to(e+i)}),(function(i){return this.element()[t](s.at(i)),s.done()}),(function(t){s.to(e+new zr(t))})),this._rememberMorpher(t,s),this},_queueObject(t,i){if(this._tryRetarget(t,i))return this;const s=new zo(this._stepper).to(i);return this.queue((function(){s.from(this.element()[t]())}),(function(i){return this.element()[t](s.at(i)),s.done()})),this._rememberMorpher(t,s),this},_queueNumber(t,i){return this._queueObject(t,new zr(i))},cx(t){return this._queueNumber("cx",t)},cy(t){return this._queueNumber("cy",t)},move(t,i){return this.x(t).y(i)},amove(t,i){return this.ax(t).ay(i)},center(t,i){return this.cx(t).cy(i)},size(t,i){const s=An(this._element,t,i);return this.width(s.width).height(s.height)},width(t){return this._queueNumber("width",t)},height(t){return this._queueNumber("height",t)},plot(t,i,s,e){if(4===arguments.length)return this.plot([t,i,s,e]);if(this._tryRetarget("plot",t))return this;const n=new zo(this._stepper).type(this._element.MorphArray).to(t);return this.queue((function(){n.from(this._element.array())}),(function(t){return this._element.plot(n.at(t)),n.done()})),this._rememberMorpher("plot",n),this},leading(t){return this._queueNumber("leading",t)},viewbox(t,i,s,e){return this._queueObject("viewbox",new yr(t,i,s,e))},update(t){return"object"!=typeof t?this.update({offset:arguments[0],color:arguments[1],opacity:arguments[2]}):(null!=t.opacity&&this.attr("stop-opacity",t.opacity),null!=t.color&&this.attr("stop-color",t.color),null!=t.offset&&this.attr("offset",t.offset),this)}}),Xn(rh,{rx:Xr,ry:Jr,from:ro,to:oo}),Yn(rh,"Runner");var uh=class extends Yr{constructor(t,i=t){super(Gn("svg",t),i),this.namespace()}defs(){return this.isRoot()?jn(this.node.querySelector("defs"))||this.put(new Br):this.root().defs()}isRoot(){return!this.node.parentNode||!(this.node.parentNode instanceof Pn.window.SVGElement)&&"#document-fragment"!==this.node.parentNode.nodeName}namespace(){return this.isRoot()?this.attr({xmlns:En,version:"1.1"}).attr("xmlns:xlink",Cn,Tn):this.root().namespace()}removeNamespace(){return this.attr({xmlns:null,version:null}).attr("xmlns:xlink",null,Tn).attr("xmlns:svgjs",null,Tn)}root(){return this.isRoot()?this:super.root()}};re({Container:{nested:Jn((function(){return this.put(new uh)}))}}),Yn(uh,"Svg",!0);var dh=class extends Yr{constructor(t,i=t){super(Gn("symbol",t),i)}};re({Container:{symbol:Jn((function(){return this.put(new dh)}))}}),Yn(dh,"Symbol");var fh=ie({amove:()=>Mh,ax:()=>Sh,ay:()=>$h,build:()=>_h,center:()=>xh,cx:()=>yh,cy:()=>wh,length:()=>ph,move:()=>bh,plain:()=>vh,x:()=>gh,y:()=>mh});function vh(t){return!1===this._build&&this.clear(),this.node.appendChild(Pn.document.createTextNode(t)),this}function ph(){return this.node.getComputedTextLength()}function gh(t,i=this.bbox()){return null==t?i.x:this.attr("x",this.attr("x")+t-i.x)}function mh(t,i=this.bbox()){return null==t?i.y:this.attr("y",this.attr("y")+t-i.y)}function bh(t,i,s=this.bbox()){return this.x(t,s).y(i,s)}function yh(t,i=this.bbox()){return null==t?i.cx:this.attr("x",this.attr("x")+t-i.cx)}function wh(t,i=this.bbox()){return null==t?i.cy:this.attr("y",this.attr("y")+t-i.cy)}function xh(t,i,s=this.bbox()){return this.cx(t,s).cy(i,s)}function Sh(t){return this.attr("x",t)}function $h(t){return this.attr("y",t)}function Mh(t,i){return this.ax(t).ay(i)}function _h(t){return this._build=!!t,this}var Oh=class extends Hr{constructor(t,i=t){super(Gn("text",t),i),this.dom.leading=this.dom.leading??new zr(1.3),this._rebuild=!0,this._build=!1}leading(t){return null==t?this.dom.leading:(this.dom.leading=new zr(t),this.rebuild())}rebuild(t){if("boolean"==typeof t&&(this._rebuild=t),this._rebuild){const t=this;let i=0;const s=this.dom.leading;this.each((function(e){if(Ln(this.node))return;const n=Pn.window.getComputedStyle(this.node).getPropertyValue("font-size"),r=s*new zr(n);this.dom.newLined&&(this.attr("x",t.attr("x")),"\n"===this.text()?i+=r:(this.attr("dy",e?r+i:0),i=0))})),this.fire("rebuild")}return this}setData(t){return this.dom=t,this.dom.leading=new zr(t.leading||1.3),this}writeDataToDom(){return super.writeDataToDom({leading:1.3})}text(t){if(void 0===t){const i=this.node.childNodes;let s=0;t="";for(let e=0,n=i.length;e<n;++e)"textPath"===i[e].nodeName||Ln(i[e])?0===e&&(s=e+1):(e!==s&&3!==i[e].nodeType&&!0===jn(i[e]).dom.newLined&&(t+="\n"),t+=i[e].textContent);return t}if(this.clear().build(!0),"function"==typeof t)t.call(this,this);else for(let i=0,s=(t=(t+"").split("\n")).length;i<s;i++)this.newLine(t[i]);return this.build(!1).rebuild()}};Xn(Oh,fh),re({Container:{text:Jn((function(t=""){return this.put(new Oh).text(t)})),plain:Jn((function(t=""){return this.put(new Oh).plain(t)}))}}),Yn(Oh,"Text");var kh=class extends Hr{constructor(t,i=t){super(Gn("tspan",t),i),this._build=!1}dx(t){return this.attr("dx",t)}dy(t){return this.attr("dy",t)}newLine(){this.dom.newLined=!0;const t=this.parent();if(!(t instanceof Oh))return this;const i=t.index(this),s=Pn.window.getComputedStyle(this.node).getPropertyValue("font-size"),e=t.dom.leading*new zr(s);return this.dy(i?e:0).attr("x",t.x())}text(t){return null==t?this.node.textContent+(this.dom.newLined?"\n":""):("function"==typeof t?(this.clear().build(!0),t.call(this,this),this.build(!1)):this.plain(t),this)}};Xn(kh,fh),re({Tspan:{tspan:Jn((function(t=""){const i=new kh;return this._build||this.clear(),this.put(i).text(t)}))},Text:{newLine:function(t=""){return this.tspan(t).newLine()}}}),Yn(kh,"Tspan");var Ah=class extends Hr{constructor(t,i=t){super(Gn("circle",t),i)}radius(t){return this.attr("r",t)}rx(t){return this.attr("r",t)}ry(t){return this.rx(t)}size(t){return this.radius(new zr(t).divide(2))}};Xn(Ah,{x:qr,y:Kr,cx:Qr,cy:Zr,width:to,height:io}),re({Container:{circle:Jn((function(t=0){return this.put(new Ah).size(t).move(0,0)}))}}),Yn(Ah,"Circle");var Rh=class extends Yr{constructor(t,i=t){super(Gn("clipPath",t),i)}remove(){return this.targets().forEach((function(t){t.unclip()})),super.remove()}targets(){return _r(this.node,"clip-path")}};re({Container:{clip:Jn((function(){return this.defs().put(new Rh)}))},Element:{clipper(){return this.reference("clip-path")},clipWith(t){const i=t instanceof Rh?t:this.parent().clip().add(t);return this.attr("clip-path","url(#"+i.id()+")")},unclip(){return this.attr("clip-path",null)}}}),Yn(Rh,"ClipPath");var Nh=class extends jr{constructor(t,i=t){super(Gn("foreignObject",t),i)}};re({Container:{foreignObject:Jn((function(t,i){return this.put(new Nh).size(t,i)}))}}),Yn(Nh,"ForeignObject");var Lh=ie({dmove:()=>Eh,dx:()=>Th,dy:()=>Ch,height:()=>Ph,move:()=>Wh,size:()=>Dh,width:()=>zh,x:()=>Uh,y:()=>Fh});function Eh(t,i){return this.children().forEach((s=>{let e;try{e=s.node instanceof Pn.window.SVGSVGElement?new yr(s.attr(["x","y","width","height"])):s.bbox()}catch(t){return}const n=new gr(s),r=n.translate(t,i).transform(n.inverse()),o=new vr(e.x,e.y).transform(r);s.dmove(o.x-e.x,o.y-e.y)})),this}function Th(t){return this.dmove(t,0)}function Ch(t){return this.dmove(0,t)}function Ph(t,i=this.bbox()){return null==t?i.height:this.size(i.width,t,i)}function Wh(t=0,i=0,s=this.bbox()){return this.dmove(t-s.x,i-s.y)}function Dh(t,i,s=this.bbox()){const e=An(this,t,i,s),n=e.width/s.width,r=e.height/s.height;return this.children().forEach((t=>{const i=new vr(s).transform(new gr(t).inverse());t.scale(n,r,i.x,i.y)})),this}function zh(t,i=this.bbox()){return null==t?i.width:this.size(t,i.height,i)}function Uh(t,i=this.bbox()){return null==t?i.x:this.move(t,i.y,i)}function Fh(t,i=this.bbox()){return null==t?i.y:this.move(i.x,t,i)}var Gh=class extends Yr{constructor(t,i=t){super(Gn("g",t),i)}};Xn(Gh,Lh),re({Container:{group:Jn((function(){return this.put(new Gh)}))}}),Yn(Gh,"G");var jh=class extends Yr{constructor(t,i=t){super(Gn("a",t),i)}target(t){return this.attr("target",t)}to(t){return this.attr("href",t,Cn)}};Xn(jh,Lh),re({Container:{link:Jn((function(t){return this.put(new jh).to(t)}))},Element:{unlink(){const t=this.linker();if(!t)return this;const i=t.parent();if(!i)return this.remove();const s=i.index(t);return i.add(this,s),t.remove(),this},linkTo(t){let i=this.linker();return i||(i=new jh,this.wrap(i)),"function"==typeof t?t.call(i,i):i.to(t),this},linker(){const t=this.parent();return t&&"a"===t.node.nodeName.toLowerCase()?t:null}}}),Yn(jh,"A");var Ih=class extends Yr{constructor(t,i=t){super(Gn("mask",t),i)}remove(){return this.targets().forEach((function(t){t.unmask()})),super.remove()}targets(){return _r(this.node,"mask")}};re({Container:{mask:Jn((function(){return this.defs().put(new Ih)}))},Element:{masker(){return this.reference("mask")},maskWith(t){const i=t instanceof Ih?t:this.parent().mask().add(t);return this.attr("mask","url(#"+i.id()+")")},unmask(){return this.attr("mask",null)}}}),Yn(Ih,"Mask");var Yh=class extends jr{constructor(t,i=t){super(Gn("stop",t),i)}update(t){return("number"==typeof t||t instanceof zr)&&(t={offset:arguments[0],color:arguments[1],opacity:arguments[2]}),null!=t.opacity&&this.attr("stop-opacity",t.opacity),null!=t.color&&this.attr("stop-color",t.color),null!=t.offset&&this.attr("offset",new zr(t.offset)),this}};re({Gradient:{stop:function(t,i,s){return this.put(new Yh).update(t,i,s)}}}),Yn(Yh,"Stop");var Bh=class extends jr{constructor(t,i=t){super(Gn("style",t),i)}addText(t=""){return this.node.textContent+=t,this}font(t,i,s={}){return this.rule("@font-face",{fontFamily:t,src:i,...s})}rule(t,i){return this.addText(function(t,i){if(!t)return"";if(!i)return t;let s=t+"{";for(const t in i)s+=On(t)+":"+i[t]+";";return s+="}",s}(t,i))}};re("Dom",{style(t,i){return this.put(new Bh).rule(t,i)},fontface(t,i,s){return this.put(new Bh).font(t,i,s)}}),Yn(Bh,"Style");var Hh=class extends Oh{constructor(t,i=t){super(Gn("textPath",t),i)}array(){const t=this.track();return t?t.array():null}plot(t){const i=this.track();let s=null;return i&&(s=i.plot(t)),null==t?s:this}track(){return this.reference("href")}};re({Container:{textPath:Jn((function(t,i){return t instanceof Oh||(t=this.text(t)),t.path(i)}))},Text:{path:Jn((function(t,i=!0){const s=new Hh;let e;if(t instanceof Yo||(t=this.defs().path(t)),s.attr("href","#"+t,Cn),i)for(;e=this.node.firstChild;)s.node.appendChild(e);return this.put(s)})),textPath(){return this.findOne("textPath")}},Path:{text:Jn((function(t){return t instanceof Oh||(t=(new Oh).addTo(this.parent()).text(t)),t.path(this)})),targets(){return _r(this.node,"href","textPath")}}}),Hh.prototype.MorphArray=Wo,Yn(Hh,"TextPath");var Vh=class extends Hr{constructor(t,i=t){super(Gn("use",t),i)}use(t,i){return this.attr("href",(i||"")+"#"+t,Cn)}};function Xh(t,i,s){const e={[s.pointLevel]:t.name};return null!==s.seriesLevel&&""!==t.seriesKey&&(e[s.seriesLevel]=t.seriesKey),null!==s.facet&&""!==i&&(e["rowgroup"===s.facet.level?"rowGroup":"category"]=i),e}re({Container:{use:Jn((function(t,i){return this.put(new Vh).use(t,i)}))}}),Yn(Vh,"Use"),Xn([uh,dh,lo,ao,yo],oe("viewbox")),Xn([bo,Qo,Ko,Yo],oe("marker")),Xn(Oh,oe("Text")),Xn(Yo,oe("Path")),Xn(Br,oe("Defs")),Xn([Oh,kh],oe("Tspan")),Xn([Zo,so,ho,rh],oe("radius")),Xn(Cr,oe("EventTarget")),Xn(Gr,oe("Dom")),Xn(jr,oe("Element")),Xn(Hr,oe("Shape")),Xn([Yr,eo],oe("Container")),Xn(ho,oe("Gradient")),Xn(rh,oe("Runner")),xr.extend([...new Set(ne)]),function(t=[]){Io.push(...[].concat(t))}([zr,fr,yr,gr,Dr,co,Wo,vr]),Xn(Io,{to(t){return(new zo).type(this.constructor).from(this.toArray()).to(t)},fromArray(t){return this.init(t),this},toConsumable(){return this.toArray()},morph(t,i,s,e,n){return this.fromArray(t.map((function(t,r){return e.step(t,i[r],s,n[r],n)})))}});var Jh,qh={},Kh=function(){if(Jh)return qh;Jh=1;var t={};return Object.defineProperty(qh,"__esModule",{value:!0}),qh.default=function(i,s){void 0===s&&(s={});var e=JSON.stringify({text:i,options:s});if(t[e])return t[e];s.font=s.font||"Times",s.fontSize=s.fontSize||"16px",s.fontWeight=s.fontWeight||"normal",s.width=s.width||"auto";var n=function(t,i){var s=document.createElement("div"),e=document.createTextNode(t);return s.appendChild(e),s.style.fontFamily=i.font,s.style.fontSize=i.fontSize,s.style.fontWeight=i.fontWeight,s.style.position="absolute",s.style.visibility="hidden",s.style.left="-999px",s.style.top="-999px",s.style.width=i.width,s.style.height="auto",document.body.appendChild(s),s}(i,s),r={width:n.offsetWidth,height:n.offsetHeight};return function(t){t.parentNode.removeChild(t)}(n),t[e]=r,r},qh}(),Qh=b(Kh);const Zh=["pl","fc","pp","ac"];function ta(t){return t.replace(/\d+$/,"")}function ia(t){const i=function(t){const i=/^#([0-9a-f]+)$/i.exec(t.trim());if(i){const t=i[1];return 3===t.length||4===t.length?[0,1,2].map((i=>parseInt(t[i]+t[i],16))):6===t.length||8===t.length?[0,2,4].map((i=>parseInt(t.slice(i,i+2),16))):null}const s=/^rgba?\(\s*([\d.]+%?)[\s,]+([\d.]+%?)[\s,]+([\d.]+%?)/i.exec(t.trim());return s?s.slice(1,4).map((t=>t.endsWith("%")?2.55*parseFloat(t):parseFloat(t))):null}(t);if(null===i)return"#000000";const[s,e,n]=i;return.299*s+.587*e+.114*n>128?"#000000":"#ffffff"}class sa{constructor(t,i,s,e){this.count=t,this.drawingRect=s,this.panelGapPx=e,this.columns=Math.max(1,Math.min(null!=i?i:t,t)),this.rows=Math.max(1,Math.ceil(t/this.columns))}panelRect(t){const i=t%this.columns,s=Math.floor(t/this.columns),e=(this.drawingRect.width-(this.columns-1)*this.panelGapPx)/this.columns,n=(this.drawingRect.height-(this.rows-1)*this.panelGapPx)/this.rows;return{x:this.drawingRect.x+i*(e+this.panelGapPx),y:this.drawingRect.y+s*(n+this.panelGapPx),width:e,height:n}}isOuterLeft(t){return t%this.columns==0}isOuterBottom(t){return t+this.columns>=this.count}}var ea,na;!function(t){t.OPERATION="operation",t.ROWGROUP="rowGroup",t.ROWGROUPINDEX="rowGroupIndex",t.CURRENTROW="currentRow",t.CATEGORY="category",t.CATEGORYINDEX="categoryIndex",t.SUBCATEGORY="subCategory",t.SUBCATEGORYINDEX="subCategoryIndex",t.COLUMNGROUP="columnGroup",t.COLUMNGROUPINDEX="columnIndex",t.COLUMNSUBGROUP="columnSubGroup",t.COLUMNSUBGROUPINDEX="columnSubGroupIndex",t.AC1="ac1",t.AC2="ac2",t.AC3="ac3",t.AC4="ac4",t.PP1="pp1",t.PP2="pp2",t.PP3="pp3",t.PP4="pp4",t.FC1="fc1",t.FC2="fc2",t.FC3="fc3",t.FC4="fc4",t.PL1="pl1",t.PL2="pl2",t.PL3="pl3",t.PL4="pl4",t.TOTALROWCOUNT="totalRowCnt",t.ROWNR="rowNr",t.TYPE="type"}(ea||(ea={}));class ra{static number(t,i="decimal",s=1,e=0,n=1,r="de"){const o=`${r}|${i}|${s}|${e}`;let h=this.formats.get(o);if(!h){const t={style:i,useGrouping:!0,maximumFractionDigits:s,minimumFractionDigits:e};try{h=new Intl.NumberFormat([r,"de-DE"],t)}catch(i){h=new Intl.NumberFormat("de-DE",t)}this.formats.set(o,h)}const a=h.format(t/n);return(a===h.format(-0)?h.format(0):a).replace(/\s+(%)/g,"$1")}static translateScenarioLabel(t,i){if(null==t)return"";const s=new ks(t);if(!s.isValid)return`${i.get(t)||t}`;let e,n;return ea.AC1===s.base?(e=i.get("dr"===s.type?"ibcssymbol_delta_ac_relative":"ibcssymbol_delta_ac"),n=i.get(s.delta)||s.delta):(e=i.get("dr"===s.type?"ibcssymbol_delta_generic_relative":"ibcssymbol_delta_generic"),n=`${i.get(s.base)||s.base} - ${i.get(s.delta)||s.delta}`),void 0===e&&(e="{%}"),`${e.replace("{%}",n)}`}static getMaxWidthOfArrayItems(t,i,s){return Qh(t.map((t=>ra.translateScenarioLabel(t,i))).reduce(((t,i)=>t.length<i.length?i:t),""),{font:s.fontStyles.font,fontSize:s.fontStyles.size+"px"}).width}}ra.formats=new Map;class oa{constructor(t,i,s,e){this.domainMin=t,this.domainMax=i,this.rangeMin=s,this.rangeMax=e}scale(t){const i=this.domainMax-this.domainMin;return 0===i?(this.rangeMin+this.rangeMax)/2:this.rangeMin+(t-this.domainMin)/i*(this.rangeMax-this.rangeMin)}static domain(t,i,s,e=.04){let n=i-t;if(0===n){const s=0===t?1:.1*Math.abs(t);n=(i+=s)-(t-=s)}return[void 0!==(null==s?void 0:s.min)?s.min:t-n*e,void 0!==(null==s?void 0:s.max)?s.max:i+n*e]}static niceStep(t,i){if(t<=0||i<=0)return 1;const s=t/i,e=Math.pow(10,Math.floor(Math.log10(s))),n=s/e;let r;return r=n<=1?1:n<=2?2:n<=2.5?2.5:n<=5?5:10,r*e}ticks(t){const i=this.domainMax-this.domainMin;if(i<=0)return[this.domainMin];const s=oa.niceStep(i,t),e=Math.ceil(this.domainMin/s)*s;if(e+s===e||s<Math.pow(10,-15))return[this.domainMin];const n=oa.stepDecimals(s),r=Math.floor((this.domainMax+1e-9*s-e)/s)+1,o=[];for(let t=0;t<r;t++){const i=Number((e+t*s).toFixed(n)),r=0===i?0:i;0!==o.length&&r===o[o.length-1]||o.push(r)}return o}static stepDecimals(t){if(!Number.isFinite(t)||t<=0)return 0;for(let i=0;i<15;i++){const s=t*Math.pow(10,i),e=Math.round(s);if(e>=1&&Math.abs(s-e)<1e-9*e)return i}return 15}static tickDecimals(t){return 0===t.length?0:oa.stepDecimals(1===t.length?Math.abs(t[0]):(t[t.length-1]-t[0])/(t.length-1))}}function ha(t,i,s,e=!1){return ra.number(t,e?"percent":"decimal",i,i,1,s)}function aa(t,i){return oa.tickDecimals(i?t.map((t=>100*t)):t)}class la{constructor(t="",i=1){this.prefix=t,this.value=i}}!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"}(na||(na={}));let ca=class{constructor(t,i,s,e,n,r,o,h){this.ID_SCENARIOLABEL="Label",this.CSS_CATEGORIES="categories",this.isRelativeLabel=!1,this.segmentFillColor=null,this.pointPart="label",this.x=i,this.y=s,this.value=n,this.group=t.group().id(this.createElementID(t.toString(),e)),this.styles=r,this.isVarianceLabel=!1,this.verticalHookLocation=o||na.Top,this.horizontalHookLocation=h||na.Left}setToVarianceLabel(){return this.isVarianceLabel=!0,this}setToRelativeVarianceLabel(){return this.isVarianceLabel=!0,this.isRelativeLabel=!0,this}setSegmentFill(t){return this.segmentFillColor=t,this}setPoint(t,i="label"){return this.pointKey=t,this.pointPart=i,this}updateGroup(t){return this.group=t,this}draw(t=!0,i={percent:2,decimal:1},s=new la){if(this.isEmpty())return this;const e=this.group;let n,r="";if(!1===Number.isNaN(Number(this.value))){let t="percent",e=i.percent,o=i.percent,h=1;!1===this.isRelativeLabel&&(e=i.decimal,o=i.decimal,h=s.value,t="decimal"),n=ra.number(Number(this.value),t,e,o,h,this.styles.locale),this.isVarianceLabel&&Number(this.value)>=0&&(r="+")}else n=""+this.value;const o=this.drawLabel(e,r+n);return!1===t?(o.addClass("hide"),e.addClass("hide")):this.pointKey&&e.attr(ji(this.pointKey,this.pointPart)),this}isEmpty(){return null==this.value||""===this.value}setPos(t,i){return this.x=t,this.y=i,this}forceStringTypeDraw(){const t=this.group;return this.drawLabel(t,""+this.value),this.pointKey&&t.attr(ji(this.pointKey,this.pointPart)),this}drawLabel(t,i){const s=this.styles.fontStyles.background||"#ffffff";let e="start";const n=t.text(i);n.move(this.x,this.y);const r=n.bbox(),o=r.w,h=r.h;let a=0,l=0;const c=n.x();let u=n.y();return this.horizontalHookLocation===na.Left?(e="left",a=n.x()):this.horizontalHookLocation===na.Center?(e="middle",a=n.x()-(o+2)/2):this.horizontalHookLocation===na.Right&&(e="end",a=n.x()-o),this.verticalHookLocation===na.Center?(u=n.y()-1.2*h/2,l=u+.2*h):this.verticalHookLocation===na.Top?(u-=h/4,l=u+.2*h):this.verticalHookLocation===na.Bottom&&(u-=h,l=u+.2*h),n.move(c,u),n.font({anchor:e}),null!=this.segmentFillColor?n.fill(ia(this.segmentFillColor)):t.rect(o+2,.8*h).stroke(s).fill(s).opacity(.9).move(a-1,l).insertBefore(n),n}createElementID(t,i){return t+"_"+i+"_"+this.ID_SCENARIOLABEL}};const ua={ac:1,pp:2,fc:3,pl:4};var da;!function(t){t[t.Above=0]="Above",t[t.Below=1]="Below",t[t.Left=2]="Left",t[t.Right=3]="Right"}(da||(da={}));class fa{constructor(){this.labels=[],this.scenarioLabels=[]}clear(){this.labels=[],this.scenarioLabels=[]}register(t){this.labels.push(t)}hasCollision(t){return this.labels.some((i=>this.intersects(t,i)))}getOptimalPlacement(t,i,s,e,n,r,o,h){const a=ua[o]||99,l=r/2;for(const r of h){const o=this.calculatePlacementForDirection(t,i,s,e,n,l,8,r);if(!this.hasCollision(o.bounds))return o}for(const r of h){const o=this.calculatePlacementForDirection(t,i,s,e,n,l,8,r);if(!this.collidesWithHigherPriority(o.bounds,a))return o}return null}calculatePlacementForDirection(t,i,s,e,n,r,o,h){let a,l,c,u,d,f;switch(h){case da.Above:a=t,l=i-r-o,c=na.Bottom,u=na.Center,d=t-s/2,f=i-r-o-e;break;case da.Below:a=t,l=i+r+o,c=na.Top,u=na.Center,d=t-s/2,f=i+r+o-e/4;break;case da.Left:a=t-r-o,l=i,c=na.Center,u=na.Right,d=t-r-o-s,f=i-.6*e;break;case da.Right:a=t+r+o,l=i,c=na.Center,u=na.Left,d=t+r+o,f=i-.6*e}return{labelX:a,labelY:l,verticalHook:c,horizontalHook:u,bounds:{x:d,y:f,width:s,height:e,pointIndex:n,preferredHook:c}}}collidesWithHigherPriority(t,i){return this.labels.some((s=>!!s.scenarioType&&((ua[s.scenarioType]||99)<i&&this.intersects(t,s))))}shouldHideScenarioLabel(t,i,s,e=20){const n=ua[s]||99;return!(n<=1)&&this.scenarioLabels.some((s=>{if((ua[s.scenarioType]||99)>=n)return!1;const r=Math.abs(i-s.y),o=Math.abs(t-s.x);return r<e&&o<e}))}registerScenarioLabel(t,i,s){this.scenarioLabels.push({x:t,y:i,scenarioType:s})}intersects(t,i){return!(t.x+t.width<i.x||i.x+i.width<t.x||t.y+t.height<i.y||i.y+i.height<t.y)}getLabelCount(){return this.labels.length}}const va=["n","ne","e","se","s","sw","w","nw"],pa=Math.SQRT1_2;class ga{constructor(t,i,s=new fa){this.frame=t,this.gapPx=i,this.manager=s}registerMark(t,i,s){this.manager.register(this.bounds(t-s,i-s,2*s,2*s))}selectCandidates(t,i,s,e){if("none"===i)return{selected:[],unknownNames:[]};if("all"===i)return{selected:[...t],unknownNames:[]};if("auto"===i)return{selected:t.slice(0,s),unknownNames:[]};const n=new Set(i),r=t.filter((t=>n.has(e(t)))),o=new Set(r.map((t=>e(t))));return{selected:r,unknownNames:i.filter((t=>!o.has(t)))}}place(t){const i=[];for(const s of t)for(const t of va){const e=this.anchorBox(s,t);if(!this.insideFrame(e.x,e.y,s.width,s.height))continue;const n=this.bounds(e.x,e.y,s.width,s.height);if(!this.manager.hasCollision(n)){this.manager.register(n),i.push({candidate:s,x:e.x,y:e.y,anchor:t});break}}return i}anchorBox(t,i){const s=t.r+this.gapPx,e=t.r*pa+.5*this.gapPx;switch(i){case"n":return{x:t.cx-t.width/2,y:t.cy-s-t.height};case"ne":return{x:t.cx+e,y:t.cy-e-t.height};case"e":return{x:t.cx+s,y:t.cy-t.height/2};case"se":return{x:t.cx+e,y:t.cy+e};case"s":return{x:t.cx-t.width/2,y:t.cy+s};case"sw":return{x:t.cx-e-t.width,y:t.cy+e};case"w":return{x:t.cx-s-t.width,y:t.cy-t.height/2};case"nw":return{x:t.cx-e-t.width,y:t.cy-e-t.height}}}insideFrame(t,i,s,e){return t>=this.frame.x&&i>=this.frame.y&&t+s<=this.frame.x+this.frame.width&&i+e<=this.frame.y+this.frame.height}bounds(t,i,s,e){return{x:t,y:i,width:s,height:e,pointIndex:0,preferredHook:na.Center}}}class ma{constructor(t,i,s,e,n){this.mode=t,this.vMax=i,this.rMaxPx=s,this.rMinPx=e,this.areaPerUnitPx2=n}static local(t,i,s){return new ma("local",t,i,s,0)}static grouped(t){return new ma("grouped",0,0,0,t)}radius(t){return"grouped"===this.mode?t<=0?0:Math.sqrt(this.areaPerUnitPx2*t/Math.PI):this.vMax<=0||t<=0?this.rMinPx:Math.max(this.rMinPx,this.rMaxPx*Math.sqrt(t/this.vMax))}}class ba{constructor(t,i,s,e){this.xScale=t,this.yScale=i,this.rect=s,this.styles=e}get em(){return this.styles.fontStyles.size}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}drawBands(t,i,s){var e,n,r,o;const h=this.styles.axisStyles.pl.fill;if(void 0!==i&&(void 0!==i.from||void 0!==i.to)){const s=this.xScale.scale(null!==(e=i.from)&&void 0!==e?e:this.xScale.domainMin),r=this.xScale.scale(null!==(n=i.to)&&void 0!==n?n:this.xScale.domainMax);t.rect(Math.abs(r-s),this.rect.height).move(Math.min(s,r),this.rect.y).fill(h)}if(void 0!==s&&(void 0!==s.from||void 0!==s.to)){const i=this.yScale.scale(null!==(r=s.from)&&void 0!==r?r:this.yScale.domainMin),e=this.yScale.scale(null!==(o=s.to)&&void 0!==o?o:this.yScale.domainMax);t.rect(this.rect.width,Math.abs(i-e)).move(this.rect.x,Math.min(i,e)).fill(h)}}drawGrid(t,i,s){const e={color:this.styles.axisStyles.pp.stroke,width:Vt(this.styles.scaleFactors.gridLineWidth,this.em)};for(const s of i){const i=this.yScale.scale(s);t.line(this.rect.x,i,this.rect.x+this.rect.width,i).stroke(e)}if(void 0!==s)for(const i of s){const s=this.xScale.scale(i);t.line(s,this.rect.y,s,this.rect.y+this.rect.height).stroke(e)}}drawRefLines(t,i,s){const e={color:this.styles.axisStyles.fc.stroke,width:Vt(this.styles.scaleFactors.refLineWidth,this.em)};if(void 0!==i){const s=this.xScale.scale(i);t.line(s,this.rect.y,s,this.rect.y+this.rect.height).stroke(e)}if(void 0!==s){const i=this.yScale.scale(s);t.line(this.rect.x,i,this.rect.x+this.rect.width,i).stroke(e)}}drawFrame(t){t.rect(this.rect.width,this.rect.height).move(this.rect.x,this.rect.y).fill("none").stroke({color:this.styles.axisStyles.ac.stroke,width:Vt(this.styles.scaleFactors.gridLineWidth,this.em)}).attr(Wi,"frame")}drawTickLabels(t,i){const s=this.styles.scaleFactors.axisTickLength*this.em,e={size:this.styles.fontStyles.size,anchor:"start"},n=this.fontFamily(),r=this.styles.fontStyles.color;if(i.showXLabels)for(const o of i.ticksX){const h=this.xScale.scale(o);t.text(ha(o,i.xDecimals,this.styles.locale,i.xPercent)).font(Object.assign(Object.assign({},e),{anchor:"middle"})).fill(r).attr({x:h,y:this.rect.y+this.rect.height+s+.8*this.em,"font-family":n})}if(i.showYLabels)for(const o of i.ticksY){const h=this.yScale.scale(o);t.text(ha(o,i.yDecimals,this.styles.locale,i.yPercent)).font(Object.assign(Object.assign({},e),{anchor:"end"})).fill(r).attr({x:this.rect.x-s,y:h+.35*this.em,"font-family":n})}}drawPanelTitle(t,i){""!==i&&t.text(i).font({size:this.styles.fontStyles.size,weight:"bold",anchor:"start"}).fill(this.styles.fontStyles.color).attr({x:this.rect.x+.5*this.em,y:this.rect.y+1.2*this.em,"font-family":this.fontFamily()})}}class ya{constructor(t){this.styles=t}get em(){return this.styles.fontStyles.size}get rowHeight(){return 1.5*this.em}get swatchSize(){return this.styles.scaleFactors.legendSwatch*this.em}textWidth(t,i=!1){const s=Qh(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:i?"bold":"normal"}).width;return Number.isFinite(s)&&s>0?s:.6*t.length*this.em}rows(t){const i=[];t.sizeCaption.forEach(((t,s)=>{i.push({text:t,bold:0===s,treatment:null})})),null!==t.title&&""!==t.title&&i.push({text:t.title,bold:!0,treatment:null});for(const s of[...t.compareEntries,...t.entries])i.push({text:s.label,bold:!1,treatment:s.treatment,fill:s.fill});return i}measure(t,i){const s=this.rows(t);if(0===s.length)return{width:0,height:0};const e=this.swatchSize+.4*this.em;if("bottom"===i){let t=0;for(const i of s)t+=(null!==i.treatment?e:0)+this.textWidth(i.text,i.bold)+1.5*this.em;return{width:t,height:this.rowHeight}}let n=0;for(const t of s)n=Math.max(n,(null!==t.treatment?e:0)+this.textWidth(t.text,t.bold));return{width:n,height:s.length*this.rowHeight}}draw(t,i,s,e,n){var r;const o=this.rows(i),h=this.swatchSize+.4*this.em;let a=s,l=e;for(const i of o){let s=a;if(null!==i.treatment){const e=t.circle(this.swatchSize).move(a,l+(this.rowHeight-this.swatchSize)/2).fill(null!==(r=i.fill)&&void 0!==r?r:i.treatment.hatch?"#ffffff":i.treatment.fill).stroke({color:"#ffffff"===i.treatment.stroke?i.treatment.fill:i.treatment.stroke,width:i.treatment.strokeWidth});void 0!==i.treatment.dasharray&&e.attr("stroke-dasharray",i.treatment.dasharray),s+=h}t.text(i.text).font({size:this.styles.fontStyles.size,weight:i.bold?"bold":"normal",anchor:"start"}).fill(this.styles.fontStyles.color).attr({x:s,y:l+this.rowHeight/2+.35*this.em,"font-family":this.fontFamily()}),"bottom"===n?a=s+this.textWidth(i.text,i.bold)+1.5*this.em:l+=this.rowHeight}}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}}class wa{constructor(){this.operation="+",this.custom={},this.counts={}}slotValue(t){const i=this[t];return R.isNumber(i)?i:null}slotHasNoData(t){return 0===this.counts[t]}}const xa=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"];class Sa{adapt(t){const i=new wa;if(R.isOperator(t.operation)&&(i.operation=t.operation),R.isString(t.date)){const s=y.fromISO(t.date);i.date=s.isValid?s:void 0}R.isString(t.rowGroup)&&R.isNumber(t.rowGroupIndex)&&(i.rowGroup=t.rowGroup,i.rowGroupIndex=t.rowGroupIndex),R.isString(t.category)&&R.isNumber(t.categoryIndex)&&(i.category=t.category,i.categoryIndex=t.categoryIndex),R.isString(t.subCategory)&&R.isNumber(t.subCategoryIndex)&&(i.subCategory=t.subCategory,i.subCategoryIndex=t.subCategoryIndex),R.isString(t.columnGroup)&&R.isNumber(t.columnGroupIndex)&&(i.columnGroup=t.columnGroup,i.columnGroupIndex=t.columnGroupIndex),R.isString(t.columnSubGroup)&&R.isNumber(t.columnSubGroupIndex)&&(i.columnSubGroup=t.columnSubGroup,i.columnSubGroupIndex=t.columnSubGroupIndex);for(const s of xa){R.isNumber(t[s])&&(i[s]=t[s]);const e=t[`${s}_cnt`];R.isNumber(e)&&(i.counts[s]=e)}for(const s of Object.keys(t))s.startsWith("_")&&(i.custom[s]=t[s]);return i}default(){return new wa}}const $a={rowGroup:"rowGroupIndex",category:"categoryIndex",subCategory:"subCategoryIndex"};function Ma(t,i){if("scenario"===i.kind)return{value:t.slotValue(i.slot),varianceNoData:!1};if(t.slotHasNoData(i.measure.base)||t.slotHasNoData(i.measure.delta))return{value:null,varianceNoData:!0};const s=i.measure.compute(t.slotValue(i.measure.base),t.slotValue(i.measure.delta));return{value:s,varianceNoData:null===s}}function _a(t,i){return void 0!==i&&(void 0!==i.min&&t<i.min||void 0!==i.max&&t>i.max)}function Oa(t,i){return"scenario"!==t.kind?null:i+W(t.slot)}function ka(t,i){var s,e,n,r,o,h,a,l,c;const u=[],d=new Set,f=[];let v=0,p=0,g=0,m=0,b=0;const y=new Map,w=new Map,x=new Map,S=null!==(s=i.compareFamily)&&void 0!==s?s:null,$=null!==S?Oa(i.measures.x,S):null,M=null!==S?Oa(i.measures.y,S):null,_=null!==S&&void 0!==i.measures.size?Oa(i.measures.size,S):null;for(const s of t){const t=s[i.pointLevel];if(null==t||""===t)continue;const u=null!==(e=null!==i.facetLevel?s[i.facetLevel]:"")&&void 0!==e?e:"",S=null!==(n=null!==i.seriesLevel?s[i.seriesLevel]:"")&&void 0!==n?n:"",O=`${u}\0${S}\0${t}`;if(d.has(O)){v++,f.length<5&&!f.includes(t)&&f.push(t);continue}const k=Ma(s,i.measures.x),A=Ma(s,i.measures.y);if(null===k.value||null===A.value){(k.varianceNoData||A.varianceNoData)&&p++;continue}if(_a(k.value,null===(r=i.domains)||void 0===r?void 0:r.x)||_a(A.value,null===(o=i.domains)||void 0===o?void 0:o.y)){g++;continue}const R={name:t,seriesKey:S,facetKey:u,x:k.value,y:A.value,row:s};if(void 0!==i.measures.size){const t=Ma(s,i.measures.size).value;if(null===t)continue;if(t<0){m++;continue}R.size=t}if(void 0!==i.measures.share){const t=Ma(s,i.measures.share).value;null!==t&&(t<0||t>1?(b++,R.share=Math.min(1,Math.max(0,t))):R.share=t)}if(null!==$&&null!==M){const t=s.slotValue($),e=s.slotValue(M),n=null!==_?s.slotValue(_):null;null===t||null===e||null!==_&&null===n?R.compare=null:_a(t,null===(h=i.domains)||void 0===h?void 0:h.x)||_a(e,null===(a=i.domains)||void 0===a?void 0:a.y)?(g++,R.compare=null):(R.compare={x:t,y:e},null!==n&&(R.compare.size=n))}if(d.add(O),x.has(u)||x.set(u,[]),x.get(u).push(R),null!==i.facetLevel){const t=s[$a[i.facetLevel]];null!=t&&t<(null!==(l=y.get(u))&&void 0!==l?l:Number.POSITIVE_INFINITY)&&y.set(u,t)}if(null!==i.seriesLevel){const t=s[$a[i.seriesLevel]];null!=t&&t<(null!==(c=w.get(S))&&void 0!==c?c:Number.POSITIVE_INFINITY)&&w.set(S,t)}}const O=[...x.keys()].sort(((t,i)=>{var s,e;return(null!==(s=y.get(t))&&void 0!==s?s:Number.MAX_SAFE_INTEGER)-(null!==(e=y.get(i))&&void 0!==e?e:Number.MAX_SAFE_INTEGER)})),k=O.map((t=>{let s=x.get(t);return i.limit>0&&s.length>i.limit&&(s="size"===i.limitBy?[...s].sort(((t,i)=>{var s,e;return(null!==(s=i.size)&&void 0!==s?s:0)-(null!==(e=t.size)&&void 0!==e?e:0)})).slice(0,i.limit):s.slice(0,i.limit)),{key:t,points:s}})),A=new Set;for(const t of k)for(const i of t.points)A.add(i.seriesKey);const R=[...A].sort(((t,i)=>{var s,e;return(null!==(s=w.get(t))&&void 0!==s?s:Number.MAX_SAFE_INTEGER)-(null!==(e=w.get(i))&&void 0!==e?e:Number.MAX_SAFE_INTEGER)})).map(((t,i)=>({key:t,index:i})));let N=null,L=0;for(const t of k)for(const i of t.points){L++;const t=[i.x],s=[i.y],e=void 0!==i.size?[i.size]:[];null!=i.compare&&(t.push(i.compare.x),s.push(i.compare.y),void 0!==i.compare.size&&e.push(i.compare.size)),null===N&&(N={xMin:t[0],xMax:t[0],yMin:s[0],yMax:s[0],sizeMax:0});for(const i of t)N.xMin=Math.min(N.xMin,i),N.xMax=Math.max(N.xMax,i);for(const t of s)N.yMin=Math.min(N.yMin,t),N.yMax=Math.max(N.yMax,t);for(const t of e)N.sizeMax=Math.max(N.sizeMax,t)}return v>0&&u.push({code:"xy-duplicate-point",data:{count:String(v),names:f.join(", ")}}),p>0&&u.push({code:"xy-variance-nodata",data:{count:String(p)}}),g>0&&u.push({code:"xy-point-clipped",data:{count:String(g)}}),m>0&&u.push({code:"bubble-size-negative",data:{count:String(m)}}),b>0&&u.push({code:"bubble-share-range",data:{count:String(b)}}),L>5e3&&u.push({code:"xy-point-budget",data:{count:String(L)}}),{facets:k,series:R,extents:N,warnings:u,totalPoints:L}}class Aa{constructor(t,i,s,e,n,r){var o,h,a,l;this.ruleSet=t,this.config=e,this.styles=n,this.availableWidth=r,this.warnings=[],this.canvasHeight=0,this.i18nMap=new Map,this.hatchPatterns=new Set,this.scaleOverflowCount=0,this.svgRoot=null,this.config=Object.assign(Object.assign({},e),{x:D(e.x),y:D(e.y)});const c=new Sa;let u=[];try{""!==s&&(u=i.exec(`SELECT * FROM ${s}`))}catch(t){this.queryError=ci(t)}const d=(null!=u?u:[]).map((t=>c.adapt(t)));this.data=ka(d,{pointLevel:e.pointLevel,seriesLevel:e.seriesLevel,facetLevel:null!==e.facet?"rowgroup"===e.facet.level?"rowGroup":"category":null,measures:{x:null!==(o=C(e.x.measure))&&void 0!==o?o:{kind:"scenario",slot:"ac1"},y:null!==(h=C(e.y.measure))&&void 0!==h?h:{kind:"scenario",slot:"ac2"},size:null!==(a=C(e.size.measure))&&void 0!==a?a:{kind:"scenario",slot:"ac3"},share:null!==e.share&&null!==(l=C(e.share.measure))&&void 0!==l?l:void 0},compareFamily:e.compareFamily,domains:{x:{min:this.config.x.min,max:this.config.x.max},y:{min:this.config.y.min,max:this.config.y.max}},limit:e.limit,limitBy:"size"}),this.warnings.push(...this.data.warnings)}get em(){return this.styles.fontStyles.size}get xPercent(){return z(this.config.x.measure)}get yPercent(){return z(this.config.y.measure)}get sizePercent(){return z(this.config.size.measure)}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,i=!1){const s=Qh(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:i?"bold":"normal"}).width;return Number.isFinite(s)&&s>0?s:.6*t.length*this.em}drawText(t,i,s,e,n={}){var r,o;return t.text(i).font({size:this.styles.fontStyles.size,weight:n.bold?"bold":"normal",anchor:null!==(r=n.anchor)&&void 0!==r?r:"start"}).fill(null!==(o=n.color)&&void 0!==o?o:this.styles.fontStyles.color).attr({x:s,y:e,"font-family":this.fontFamily()})}hasNoData(){return 0===this.data.totalPoints}getWarnings(){return this.warnings}getQueryError(){return this.queryError}getAllocatedCanvasWidth(){return this.availableWidth}getAllocatedCanvasHeight(){return this.canvasHeight}setI18n(t){this.i18nMap=t}addWarningOnce(t,i){this.warnings.some((i=>i.code===t))||this.warnings.push({code:t,data:i})}primaryColorIndex(){const t=C(this.config.size.measure);return null===t||"variance"===t.kind?10:this.ruleSet.getScenarioColorIndex(t.slot)}compareColorIndex(){return this.ruleSet.getScenarioColorIndex(`${this.config.compareFamily}1`)}seriesHue(t){const{color:i,overflowed:s}=w(t,this.styles.seriesColors);return s&&this.addWarningOnce("xy-series-overflow",{}),i}familyDisplayName(t){return this.ruleSet.getScenario(`${t}1`).group}legendModel(){var t,i;const s=[],e=null!==(i=null!==(t=this.config.size.label)&&void 0!==t?t:this.i18nMap.get("legend.size"))&&void 0!==i?i:"";""!==e&&(s.push(e),void 0!==this.config.size.unit&&""!==this.config.size.unit&&s.push(`${this.i18nMap.get("axis.in")||"in"} ${this.config.size.unit}`));const n=[];if(null!==this.config.compareFamily){const t=C(this.config.size.measure),i=null!==t&&"scenario"===t.kind?t.slot.replace(/\d+$/,""):"ac";n.push(this.legendEntry(this.familyDisplayName(this.config.compareFamily),this.compareColorIndex(),0)),n.push(this.legendEntry(this.familyDisplayName(i),this.primaryColorIndex(),0))}const r=this.data.series.map((t=>{var i;return this.legendEntry(""===t.key?null!==(i=this.ruleSet.getScenario("").name)&&void 0!==i?i:"Series":t.key,this.primaryColorIndex(),t.index)}));return{sizeCaption:s,title:this.i18nMap.get("legend.title")||null,compareEntries:n,entries:r}}legendEntry(t,i,s){const e=this.seriesHue(s),n=x(i,e,"bubble");return{label:t,treatment:n,fill:this.treatmentFill(n,s,e)}}toString(){const t=new uh;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}axisTitle(t,i){var s;const e=null!==(s=t.label)&&void 0!==s?s:"";return""===e?"":void 0===t.unit||""===t.unit?e:`${e} ${i} ${t.unit}`}draw(t){var i,s,e,n,r,o,h,a,l,c,u;this.warnings=this.data.warnings.slice(),this.hatchPatterns.clear(),this.scaleOverflowCount=0,this.svgRoot=t;const d=this.em,f=this.styles.padding,v=this.i18nMap.get("axis.in")||"in",p=t.group(),g=new ya(this.styles),m=this.legendModel(),b=this.config.legend.show&&(m.entries.length>0||m.sizeCaption.length>0),y=b?g.measure(m,this.config.legend.position):{width:0,height:0},w="right"===this.config.legend.position&&b?y.width+d:0,x=""!==this.config.chartTitle?1.6*d:0,S=this.axisTitle(this.config.y,v),$=this.axisTitle(this.config.x,v),M=""!==S?1.4*d:.4*d,_=1.4*d+(""!==$?1.3*d:0);let O,k=3*d,A={x:0,y:0,width:0,height:0},R=[];const N=Math.max(1,this.data.facets.length),L=null===(i=this.config.facet)||void 0===i?void 0:i.columns,E=oa.domain(null!==(e=null===(s=this.data.extents)||void 0===s?void 0:s.xMin)&&void 0!==e?e:0,null!==(r=null===(n=this.data.extents)||void 0===n?void 0:n.xMax)&&void 0!==r?r:1,{min:this.config.x.min,max:this.config.x.max}),T=oa.domain(null!==(h=null===(o=this.data.extents)||void 0===o?void 0:o.yMin)&&void 0!==h?h:0,null!==(l=null===(a=this.data.extents)||void 0===a?void 0:a.yMax)&&void 0!==l?l:1,{min:this.config.y.min,max:this.config.y.max});for(let t=0;t<2;t++){const t=Math.max(10,this.availableWidth-f.left-f.right-k-w);A={x:f.left+k,y:f.top+x+M,width:t,height:t/this.config.aspect},O=new sa(N,L,A,this.styles.scaleFactors.panelGap*d);const i=O.panelRect(0).height,s=Math.max(4,Math.min(8,Math.round(i/(4*d)))),e=new oa(T[0],T[1],i,0);R=e.ticks(s);const n=aa(R,this.yPercent);k=Math.max(...R.map((t=>this.textWidth(ha(t,n,this.styles.locale,this.yPercent)))),d)+this.styles.scaleFactors.axisTickLength*d+.4*d}this.canvasHeight=A.y+A.height+_+("bottom"===this.config.legend.position&&b?y.height+d:0)+f.bottom,""!==this.config.chartTitle&&this.drawText(p,this.config.chartTitle,f.left,f.top+d,{bold:!0}),""!==S&&this.drawAxisTitleText(p,this.config.y,v,f.left,A.y-.6*d,"start");const C=this.buildPanels(O,E,T),P=C[0].xScale.ticks(Math.max(3,Math.min(8,Math.round(C[0].rect.width/(7*d))))),W=aa(P,this.xPercent),D=aa(R,this.yPercent),z=this.config.sizeAreaPerUnit>0?ma.grouped(this.config.sizeAreaPerUnit):ma.local(null!==(u=null===(c=this.data.extents)||void 0===c?void 0:c.sizeMax)&&void 0!==u?u:0,this.styles.scaleFactors.bubbleMaxRadius*d,this.styles.scaleFactors.bubbleMinRadius*d);0===this.data.facets.length?this.drawPanel(p,C[0],{key:"",points:[]},z,P,R,W,D,!0,!0):this.data.facets.forEach(((t,i)=>{this.drawPanel(p,C[i],t,z,P,R,W,D,O.isOuterLeft(i),O.isOuterBottom(i),this.data.facets.length>1?t.key:"")})),""!==$&&this.drawAxisTitleText(p,this.config.x,v,A.x+A.width,A.y+A.height+2.6*d,"end"),b&&("right"===this.config.legend.position?g.draw(p,m,A.x+A.width+d,A.y,"right"):g.draw(p,m,A.x,A.y+A.height+_,"bottom")),this.scaleOverflowCount>0&&this.addWarningOnce("bubble-scale-overflow",{count:String(this.scaleOverflowCount)}),t.group().addClass("annotations")}drawAxisTitleText(t,i,s,e,n,r){var o;const h=null!==(o=i.label)&&void 0!==o?o:"",a=void 0!==i.unit&&""!==i.unit?`${s} ${i.unit}`:"",l=.3*this.em;"start"===r?(this.drawText(t,h,e,n,{bold:!0}),""!==a&&this.drawText(t,a,e+this.textWidth(h,!0)+l,n,{})):""!==a?(this.drawText(t,a,e,n,{anchor:"end"}),this.drawText(t,h,e-this.textWidth(a)-l,n,{anchor:"end",bold:!0})):this.drawText(t,h,e,n,{anchor:"end",bold:!0})}buildPanels(t,i,s){const e=[];for(let n=0;n<t.count;n++){const r=t.panelRect(n),o=new oa(i[0],i[1],r.x,r.x+r.width),h=new oa(s[0],s[1],r.y+r.height,r.y);e.push({rect:r,xScale:o,yScale:h,frame:new ba(o,h,r,this.styles)})}return e}treatmentFill(t,i,s){return!0!==t.hatch?t.fill:(this.ensureHatchPattern(i,s),`url(#xy-fc-${i})`)}ensureHatchPattern(t,i){this.hatchPatterns.has(t)||null===this.svgRoot||(this.hatchPatterns.add(t),this.svgRoot.defs().pattern(10,10,(t=>{t.rect(10,10).fill("#ffffff"),t.line(0,10,10,0).stroke({color:i,width:2}),t.line(-2.5,2.5,2.5,-2.5).stroke({color:i,width:2}),t.line(7.5,12.5,12.5,7.5).stroke({color:i,width:2})})).id(`xy-fc-${t}`))}drawPanel(t,i,s,e,n,r,o,h,a,l,c=""){var u,d,f,v,p,g;const m=t.group(),b=this.em;i.frame.drawBands(m,this.config.x.highlight,this.config.y.highlight),i.frame.drawGrid(m,r,void 0===this.config.x.refLine&&void 0===this.config.y.refLine&&i.rect.width>30*b?n:void 0),i.frame.drawRefLines(m,this.config.x.refLine,this.config.y.refLine),i.frame.drawFrame(m);const y=m.group().id("compare"),w=m.group().id("primary"),$=new ga(i.rect,this.styles.scaleFactors.labelToMark*b),M=[...s.points].sort(((t,i)=>{var s,e;return(null!==(s=i.size)&&void 0!==s?s:0)-(null!==(e=t.size)&&void 0!==e?e:0)})),_=[];for(const t of M){const n=null!==(d=null===(u=this.data.series.find((i=>i.key===t.seriesKey)))||void 0===u?void 0:u.index)&&void 0!==d?d:0,r=this.seriesHue(n),o=x(this.primaryColorIndex(),r,"bubble"),h=i.xScale.scale(t.x),a=i.yScale.scale(t.y),l=e.radius(null!==(f=t.size)&&void 0!==f?f:0);if(this.config.sizeAreaPerUnit>0&&this.bubbleExceedsPanel(i.rect,h,a,l)&&this.scaleOverflowCount++,null!=t.compare){const s=x(this.compareColorIndex(),r,"bubble"),o=i.xScale.scale(t.compare.x),h=i.yScale.scale(t.compare.y),a=e.radius(null!==(v=t.compare.size)&&void 0!==v?v:0);this.drawBubble(y,o,h,a,s,n,r),$.registerMark(o,h,a),this.config.labels.values&&void 0!==t.compare.size&&a>=1.2*b&&this.drawValueLabel(y,o,h,a,t.compare.size,s.fill)}const c=Xh(t,s.key,this.config);null===(p=this.drawBubble(w,h,a,l,o,n,r))||void 0===p||p.attr(ji(c,"element")),$.registerMark(h,a,l),void 0!==t.share&&l>0&&(null===(g=this.drawShareSlice(w,h,a,l,t.share,S(r)))||void 0===g||g.attr(ji(c))),this.config.labels.values&&void 0!==t.size&&this.drawValueLabel(w,h,a,l,t.size,!0===o.hatch?"#ffffff":o.fill),_.push({point:t,cx:h,cy:a,r:l,seriesIndex:n,hue:r,treatment:o})}this.drawNameLabels(m,$,_,s.key),i.frame.drawTickLabels(m,{ticksX:n,ticksY:r,xDecimals:o,yDecimals:h,xPercent:this.xPercent,yPercent:this.yPercent,showXLabels:l,showYLabels:a}),""!==c&&i.frame.drawPanelTitle(m,c)}bubbleExceedsPanel(t,i,s,e){return i-e<t.x||i+e>t.x+t.width||s-e<t.y||s+e>t.y+t.height}drawBubble(t,i,s,e,n,r,o){if(!(e<=0))return t.circle(2*e).center(i,s).fill(this.treatmentFill(n,r,o)).stroke({color:n.stroke,width:n.strokeWidth})}drawShareSlice(t,i,s,e,n,r){if(n<=0)return;if(n>=1)return t.circle(2*e).center(i,s).fill(r);const o=2*n*Math.PI,h=i+e*Math.sin(o),a=s-e*Math.cos(o),l=o>Math.PI?1:0;return t.path(`M ${i} ${s} L ${i} ${s-e} A ${e} ${e} 0 ${l} 1 ${h} ${a} Z`).fill(r).stroke("none")}drawValueLabel(t,i,s,e,n,r){const o=ha(n,this.valueDecimals(),this.styles.locale,this.sizePercent);this.textWidth(o)+.4*this.em>2*e||this.drawText(t,o,i,s+.35*this.em,{anchor:"middle",color:ia(r)})}drawNameLabels(t,i,s,e){const n=[...s].sort(((t,i)=>{var s,e;return(null!==(s=i.point.size)&&void 0!==s?s:0)-(null!==(e=t.point.size)&&void 0!==e?e:0)})),{selected:r,unknownNames:o}=i.selectCandidates(n,this.config.labels.points,this.config.labels.max,(t=>t.point.name));o.length>0&&this.addWarningOnce("xy-label-unknown",{names:o.join(", ")});const h=new Map,a=r.map((t=>{const i={name:t.point.name,cx:t.cx,cy:t.cy,r:t.r,width:this.textWidth(t.point.name),height:1.1*this.em};return h.set(i,t.point),i}));for(const s of i.place(a))this.drawText(t,s.candidate.name,s.x,s.y+.9*s.candidate.height,{}).attr(ji(Xh(h.get(s.candidate),e,this.config),"label"))}valueDecimals(){var t,i,s;let e=0;for(const n of this.data.facets)for(const r of n.points)e=Math.max(e,Math.abs(null!==(t=r.size)&&void 0!==t?t:0),Math.abs(null!==(s=null===(i=r.compare)||void 0===i?void 0:i.size)&&void 0!==s?s:0));return e>0&&Number.isFinite(e)?(this.sizePercent&&(e*=100),oa.stepDecimals(Math.pow(10,Math.floor(Math.log10(e))-2))):1}}const Ra=["xy-duplicate-point","xy-point-clipped","xy-variance-nodata","xy-label-unknown","xy-series-overflow","xy-point-budget","bubble-size-negative","bubble-share-range","bubble-scale-overflow"],Na=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.chartTitle="",this.share=null,this.compareFamily=null,this.facet=null,this.pointLevel="category",this.seriesLevel=null,this.aspect=16/9,this.limit=0,this.filter="",this.sizeAreaPerUnit=0,this.i18n=new Map,this.containerWidth=0,this.svgMarkup="",a(this)}getDb(){return this.stores||(this.stores=c(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=$(this.getDb(),this.tableName,this.filter);this.chart=new Aa(new Cs(this.ruleSetConfig),this.getDb(),i,{chartTitle:this.chartTitle,x:this.x,y:this.y,size:this.size,share:this.share,compareFamily:this.compareFamily,labels:this.labels,legend:this.legend,facet:this.facet,pointLevel:this.pointLevel,seriesLevel:this.seriesLevel,aspect:this.aspect,limit:this.limit,sizeAreaPerUnit:this.sizeAreaPerUnit},t,this.containerWidth||0),this.chart.setI18n(this.i18n),this.svgMarkup=this.chart.hasNoData()?"":this.chart.toString(),this.syncWarnings(this.chart.getWarnings()),ui(this.errors,this.chart.getQueryError())}syncWarnings(t){if(void 0===this.errors)return;const i=new Map(t.map((t=>[t.code,t.data])));for(const t of Ra){const s=`WARN_${t.replace(/-/g,"_")}`;if(i.has(t)){const e=void 0!==this.translator?this.translator(`.${t}`,i.get(t)):t;this.errors.addOrReplace({id:s,type:"warning",message:e})}else this.errors.remove(s)}}prepareStyle(){var t,i;const s=new Bs(new Vs,new Ws,new Is(new Gs),new zs).adapt(this.styles);return s.locale=(null===(i=null===(t=c(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}render(){var t;if(void 0===this.chart||void 0!==this.chart.getQueryError())return i(s,null);if(this.chart.hasNoData()){const e=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return i(s,{class:"no-data"},i("div",{class:"empty-state"},e))}return i(s,null,i("div",{innerHTML:this.svgMarkup}))}get element(){return e(this)}};Na.style=':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}';const La=["measure","label","unit"];function Ea(t){const i=[],s=Da(t,"measure",i);if(void 0===s||""===s.trim())return i.push("measure"),{config:null,unknownKeys:Wa(t,La),invalidFields:i};const e={measure:s.trim()};return e.label=Da(t,"label",i),e.unit=Da(t,"unit",i),{config:e,unknownKeys:Wa(t,La),invalidFields:i}}const Ta=["show","decimals"];function Ca(t,i){const s=[],e={show:i.show,decimals:i.decimals};return R.isExisting(t.show)&&("auto"===t.show||"none"===t.show?e.show=t.show:s.push("show")),R.isExisting(t.decimals)&&(R.isNumber(t.decimals)&&t.decimals>=0&&t.decimals<=4?e.decimals=Math.floor(t.decimals):s.push("decimals")),{config:e,unknownKeys:Wa(t,Ta),invalidFields:s}}function Pa(t){var i;const s=null!==(i=null==t?void 0:t.trim())&&void 0!==i?i:"";if(""===s||"null"===s)return{ranges:[],parseError:!1,issues:[]};let e;try{e=JSON.parse(s)}catch(t){return{ranges:[],parseError:!0,issues:[]}}if(!Array.isArray(e)||0===e.length)return{ranges:[],parseError:!0,issues:[]};if(!e.every((t=>R.isNumber(t)&&isFinite(t)&&t>0)))return{ranges:[],parseError:!0,issues:[]};const n=[];let r=e;const o=[...r].sort(((t,i)=>t-i));return o.some(((t,i)=>t!==r[i]))&&n.push("not ascending, sorted"),r=o,r.length>2&&(n.push(`${r.length} entries, first 2 kept`),r=r.slice(0,2)),{ranges:r,parseError:!1,issues:n}}function Wa(t,i){return Object.keys(t).filter((t=>!i.includes(t)))}function Da(t,i,s){if(R.isExisting(t[i]))return R.isString(t[i])?t[i]:void s.push(i)}const za=["pl1","pp1","fc1"],Ua=class{validateFilter(t){const i="ERR_filter";v(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateActual(t){this.validateMeasureSpec("actual",t)}validateTarget(t){this.validateMeasureSpec("target",t)}validateRanges(t){const i="ERR_bullet_json_ranges",s="WARN_bullet_ranges",e=Pa(t);if(e.parseError)return this.setBlockingError(i,this.t(".bullet-prop-json",{prop:"ranges"})),void this.errors.remove(s);this.setBlockingError(i,null),e.issues.length>0?this.errors.addOrReplace({id:s,type:"warning",message:this.t(".bullet-ranges-invalid",{detail:e.issues.join("; ")})}):this.errors.remove(s)}validateNormalize(t){this.validateEnum("normalize","WARN_normalize",t,["target","none"],"target")}validateVariances(t){this.validateEnum("variances","WARN_variances",t,["auto","none"],"auto")}validateLevel(t){this.validateEnum("level","WARN_level",t,["auto","rowgroup","category","subcategory"],"auto")}validateOrder(t){const i="WARN_order",s=U(t).filter((t=>""!==t));0===s.length?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`order: invalid value(s) '${s.join(", ")}'; using the dataset order.`})}validateOrderDirection(t){const i="WARN_orderDirection";N(t)||F(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`order-direction: invalid value '${t}' - expected asc/desc; using asc.`})}validateLimit(t){const i="WARN_limit";L(t)&&Number(t)>=0?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`limit: invalid value '${t}' - expected a non-negative integer; using 0.`})}validateLabels(t){const i="ERR_bullet_json_labels",s="WARN_bullet_fields_labels",{data:e,parseError:n}=rs(t,null);if(n)return this.setBlockingError(i,this.t(".bullet-prop-json",{prop:"labels"})),void this.errors.remove(s);this.setBlockingError(i,null),null!==e?this.reportSpecIssues(s,"labels",Ca(e,this.labelDefaults())):this.errors.remove(s)}validateScale(t){const i="WARN_scale";if(N(t))return void this.errors.remove(i);const{mode:s,factor:e}=Ht(t);"factor"===s&&(void 0===e||e<=0)?this.errors.addOrReplace({id:i,type:"warning",message:`scale: invalid value '${t}' - expected none/auto or a positive number.`}):this.errors.remove(i)}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.chartTitle="",this.filter="",this.actual="",this.target="",this.ranges="",this.normalizeMode="target",this.variances="auto",this.level="auto",this.order="",this.orderDirection="",this.limit=0,this.labels="",this._autoScaleGuard=!1,this._lastScaledParentHeight=0,this.translateForInner=(t,i)=>this.t(t,i),E(this),a(this),Yt(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.errors=l(this),this.componentStyle=k(this),this.ruleSetConfig=es(this),this.t=Bt(this).t}componentWillLoad(){this.validateFilter(this.filter),this.validateActual(this.actual),this.validateTarget(this.target),this.validateRanges(this.ranges),this.validateNormalize(this.normalizeMode),this.validateVariances(this.variances),this.validateLevel(this.level),this.validateOrder(this.order),this.validateOrderDirection(this.orderDirection),this.validateLimit(this.limit),this.validateLabels(this.labels),this.validateScale(this.scale)}componentDidRender(){$s(this.element,"bn-chart-bullet-renderer");const{mode:t}=Ht(this.scale);if("auto"!==t&&"empty"!==t)return void(this._autoScaleGuard=!1);if(this._autoScaleGuard)return void(this._autoScaleGuard=!1);const i=this.element,{height:s}=Ut(i);if(s<=0)return;this._lastScaledParentHeight=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),n=i.scrollHeight,o=this.appliedScaleFactor;if(n<=s+1)return void this.errors.remove("AUTO_scale");const h=Math.max(.3,o*(s-1)/n);Math.abs(h-o)<.01||(i.style.setProperty("--bn-font-size",e*h+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${h.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,r((()=>{this.appliedScaleFactor=h})))}componentDidLoad(){this.layoutObserver=ss(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=Ut(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,n(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=Ut(this.element);this._lastScaledParentHeight=t,n(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{show:"auto",decimals:1}}setBlockingError(t,i){null===i?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:i}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateMeasureSpec(t,i){var s;const e=`ERR_bullet_json_${t}`,n=`ERR_bullet_measure_${t}`,r=`WARN_bullet_fields_${t}`,{data:o,parseError:h}=rs(i,"measure");if(h)return this.setBlockingError(e,this.t(".bullet-prop-json",{prop:t})),this.setBlockingError(n,null),void this.errors.remove(r);if(this.setBlockingError(e,null),null===o)return this.setBlockingError(n,null),void this.errors.remove(r);const a=(null!==(s=o.measure)&&void 0!==s?s:"").trim(),l=C(a);"auto"===a.toLowerCase()||null!==l&&"scenario"===l.kind?this.setBlockingError(n,null):this.setBlockingError(n,this.t(".bullet-measure-invalid",{prop:t,measure:a})),this.reportSpecIssues(r,t,Ea(o))}validateEnum(t,i,s,e,n){N(s)||e.includes(s.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`${t}: invalid value '${s}' - expected ${e.join("/")}; using '${n}'.`})}reportSpecIssues(t,i,s){const e=[];null!==s&&s.invalidFields.length>0&&e.push(`invalid: ${s.invalidFields.join(", ")}`),null!==s&&s.unknownKeys.length>0&&e.push(`unknown: ${s.unknownKeys.join(", ")}`),e.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${i}: ignored sub-fields (${e.join("; ")}).`}):this.errors.remove(t)}prepareActual(){var t,i,s,e,n;const{data:r,parseError:o}=rs(this.actual,"measure");if(o)return null;const h=null!==r?Ea(r).config:null;if(null===h||"auto"===h.measure.toLowerCase()){const n=null!==h,r=null!==(i=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==i?i:[],o=null!==(e=r.includes("ac1")?"ac1":null!==(s=r.find((t=>t.startsWith("ac"))))&&void 0!==s?s:r[0])&&void 0!==e?e:"ac1";return n||null===this.datasetMeta?this.errors.remove("AUTO_actual"):this.errors.addOrReplace({id:"AUTO_actual",type:"warning",message:`actual: not set, auto-detected: ${o}`}),null===h?{measure:o}:Object.assign(Object.assign({},h),{measure:o})}return this.errors.remove("AUTO_actual"),"scenario"===(null===(n=C(h.measure))||void 0===n?void 0:n.kind)?h:null}prepareTarget(){var t,i,s;const{data:e,parseError:n}=rs(this.target,"measure");if(n)return null;const r=null!==e?Ea(e).config:null;if(null===r||"auto"===r.measure.toLowerCase()){const s=null!==r,e=null!==(i=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==i?i:[],n=za.find((t=>e.includes(t)));return void 0===n?(this.errors.remove("AUTO_target"),null!==this.datasetMeta?this.errors.addOrReplace({id:"WARN_bullet_target_unavailable",type:"warning",message:this.t(".bullet-target-none")}):this.errors.remove("WARN_bullet_target_unavailable"),null):(this.errors.remove("WARN_bullet_target_unavailable"),s||null===this.datasetMeta?this.errors.remove("AUTO_target"):this.errors.addOrReplace({id:"AUTO_target",type:"warning",message:`target: not set, auto-detected: ${n}`}),null===r?{measure:n}:Object.assign(Object.assign({},r),{measure:n}))}return this.errors.remove("AUTO_target"),this.errors.remove("WARN_bullet_target_unavailable"),"scenario"===(null===(s=C(r.measure))||void 0===s?void 0:s.kind)?r:null}prepareNormalize(){var t;return"none"===(null===(t=this.normalizeMode)||void 0===t?void 0:t.trim().toLowerCase())?"none":"target"}prepareShowVariances(){var t;return"none"!==(null===(t=this.variances)||void 0===t?void 0:t.trim().toLowerCase())}prepareLevel(){var t,i;const s=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("rowgroup"===s)return G.ROWGROUP;if("category"===s)return G.CATEGORY;if("subcategory"===s)return G.SUBCATEGORY;const e=null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel;if(void 0!==e&&""!==e){const t=G[e.toUpperCase()];if(void 0!==t)return t}return G.CATEGORY}prepareOrder(){var t,i,s,e;const n="auto"===(null===(t=this.order)||void 0===t?void 0:t.trim().toLowerCase());let r;N(this.order)||n?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedOrder)?(n?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:`order: not set, auto-detected: ${this.datasetMeta.suggestedOrder}`}),r=this.datasetMeta.suggestedOrder):(this.errors.remove("AUTO_order"),r=""):(this.errors.remove("AUTO_order"),r=this.order);const o=null!==(e=j[null===(s=this.orderDirection)||void 0===s?void 0:s.toUpperCase()])&&void 0!==e?e:j.ASC;if(N(r))return new I([Y.CATEGORYINDEX],o);const h=r.split(",").map((t=>Y[t.trim().toUpperCase()])).filter((t=>void 0!==t));return new I(h.length>0?h:[Y.CATEGORYINDEX],o)}prepareLabels(){const t=this.labelDefaults(),{data:i,parseError:s}=rs(this.labels,null);return s||null===i?{show:t.show,decimals:t.decimals}:Ca(i,t).config}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}i18nLocalKeys(){return["no-data","target","axis.in"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),i=new Map(p.map((t=>[t,this.t("global.".concat(t))])));return new Map([...i.entries(),...t.entries(),...Ts(this.ruleSetConfig("user"))])}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const s=i.global.fontSizePx*t;return{scaleFactors:i["bn-chart-bullet"].scaleFactors,fontStyles:{font:`${s}px ${i.global.fontFamily}`,size:s,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-bullet"].axisStyles,barStyles:i["bn-chart-bullet"].barStyles,varianceStyles:i["bn-chart-bullet"].varianceStyles,rangeColors:i["bn-chart-bullet"].rangeColors,padding:i["bn-chart-bullet"].padding}}))}async getBaseline(){return Ui(this.element,"bn-chart-bullet-renderer")}async getLayoutState(t){var i;const s=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",e=ei(this.element),n=this.getEffectiveScaleFactor(),r=Number.isFinite(n)&&n>0?n:1,o=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*r;return ts(this.element,"bn-chart-bullet-renderer",this.chartTitle||void 0,{fontSizePx:o,appliedScaleFactor:r},e,s)}getEffectiveScaleFactor(){const{mode:t,factor:i}=Ht(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const o=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":o*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const i of["ac","pp","fc","pl"])for(const s of[1,2,3,4])t[`${i}${s}`]={type:"number",isOptional:!0,description:""};const i={actual:this.prepareActual(),target:this.prepareTarget()};for(const[s,e]of Object.entries(i))null!==e&&void 0!==t[e.measure]&&(t[e.measure].description=`${s}: ${void 0!==e.label?e.label:e.measure}`);return{IBulletChartDataRow:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}chartTemplate(){const t=this.prepareActual(),s=this.prepareTarget(),e=Pa(this.ranges).ranges,n=this.prepareNormalize();return this.setBlockingError("ERR_bullet_measure_same",null!==t&&null!==s&&t.measure===s.measure?this.t(".bullet-measure-same",{measure:t.measure}):null),e.length>0&&"target"===n?this.errors.addOrReplace({id:"WARN_bullet_ranges_ignored",type:"warning",message:this.t(".bullet-ranges-ignored")}):this.errors.remove("WARN_bullet_ranges_ignored"),this.hasBlockingErrors()||null===t?null:i("bn-chart-bullet-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,actual:t,target:s,ranges:e,normalizeMode:n,showVariances:this.prepareShowVariances(),level:this.prepareLevel(),order:this.prepareOrder(),limit:this.prepareLimit(),labels:this.prepareLabels(),filter:this.filter,styles:this.prepareStyle(),i18n:this.prepareI18n(),containerWidth:Ut(this.element).width,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return i(s,{key:"cdd2404977255a330652806671d1bea76c796769",style:this.getFontStyles()},i("div",{key:"0b8cfeb6209083f9144c5824bceecb9b02578f02",class:"container"},this.chartTemplate()))}get element(){return e(this)}static get watchers(){return{filter:[{validateFilter:0}],actual:[{validateActual:0}],target:[{validateTarget:0}],ranges:[{validateRanges:0}],normalizeMode:[{validateNormalize:0}],variances:[{validateVariances:0}],level:[{validateLevel:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],labels:[{validateLabels:0}],scale:[{validateScale:0}]}}};Ua.style=':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:column}';class Fa{constructor(t,i,s){this.pos=t,this.neg=i,this.neu=s,this.needleHeadColour="#000000"}getSVGStyle(t){return"pos"===t?this.pos:"neg"===t?this.neg:this.neu}}class Ga{constructor(t){this.svgStyleAdapter=t}adapt(t){const i=new Fa(this.svgStyleAdapter.defaultPos(),this.svgStyleAdapter.defaultNeg(),this.svgStyleAdapter.defaultNeu());return R.isExisting(t.pos)&&(i.pos=this.svgStyleAdapter.adapt(t.pos)),R.isExisting(t.neg)&&(i.neg=this.svgStyleAdapter.adapt(t.neg)),R.isExisting(t.pp)&&(i.neu=this.svgStyleAdapter.adapt(t.neu)),R.isString(t.needleHeadColour)&&(i.needleHeadColour=t.needleHeadColour),i}default(){return new Fa(this.svgStyleAdapter.defaultPos(),this.svgStyleAdapter.defaultNeg(),this.svgStyleAdapter.defaultNeu())}}class ja{constructor(t,i,s,e,n,r){this.ruleSet=t,this.config=e,this.styles=n,this.availableWidth=r,this.rows=[],this.warnings=[],this.i18nMap=new Map,this.populateModel(i,s),this.normalized="target"===this.config.normalize&&this.rows.some((t=>null!==t.fraction)),null!==this.config.target&&this.rows.length>0&&!this.rows.some((t=>null!==t.target))&&this.warnings.push({code:"bullet-target-none",data:{}})}populateModel(t,i){var s,e,n;if(""===i)return;const r=this.config.level,o=this.config.order,h=this.config.actual.measure,a=null!==(e=null===(s=this.config.target)||void 0===s?void 0:s.measure)&&void 0!==e?e:null,l="transformOperator(operation)",c=[h,...null!==a?[a]:[]].map((t=>`CASE WHEN MIN(${l}) = MAX(${l}) THEN SUM(${t}) ELSE SUM(${t} * ${l}) END as ${t}, SUM(ABS(${t})) as ${t}_gross, COUNT(ISNULL(${t})) as ${t}_cnt`)).join(", ");let u;try{u=t.exec(`SELECT ${this.createSelectString(r,o)}, ${c},\n MIN(transformOperator(operation)) as opMin, MAX(transformOperator(operation)) as opMax\n FROM ${i}\n GROUP BY ${this.createGroupByStr(r,o)}\n ORDER BY ${this.createOrderStr(r,o)}`)}catch(t){return void(this.queryError=ci(t))}let d=null!=u?u:[];this.config.limit>0&&(d=d.slice(0,this.config.limit));let f=0,v=0,p=0,g=0;for(const t of d){const i="number"==typeof t.opMin?t.opMin:1,s="number"==typeof t.opMax?t.opMax:1;let e=-1===i&&-1===s?"-":"+";i!==s&&(e="+",f++);const r=this.readValue(t,h),o=null!==a?this.readValue(t,a):null;null!==r&&r<0&&g++;let l=null;"target"===this.config.normalize&&(null===o?null!==a&&v++:o<=0?p++:null!==r&&r>=0&&(l=r/o)),this.rows.push({category:String(null!==(n=t.category)&&void 0!==n?n:""),actual:r,target:o,operation:e,sentiment:this.sentiment(r,o,e),fraction:l})}f>0&&this.warnings.push({code:"bullet-mixed-operation",data:{count:String(f)}}),v>0&&this.warnings.push({code:"bullet-target-missing",data:{count:String(v)}}),p>0&&this.warnings.push({code:"bullet-target-invalid",data:{count:String(p)}}),g>0&&this.warnings.push({code:"bullet-actual-negative",data:{count:String(g)}})}readValue(t,i){if(0===t[`${i}_cnt`])return null;const s=t[i],e=t[`${i}_gross`];return"number"==typeof s&&"number"==typeof e&&Math.abs(s)<=1e-9*e?0:"number"==typeof s&&isFinite(s)?s:null}sentiment(t,i,s){return null===t||null===i||t===i?"neu":t>i!=("-"===s)?"pos":"neg"}createSelectString(t,i){return t===G.CATEGORY&&i.hierarchy.includes(Y.CATEGORYINDEX)?`${Y.CATEGORYINDEX}, ${G.CATEGORY} as category`:t===G.ROWGROUP&&i.hierarchy.includes(Y.ROWGROUPINDEX)?`${Y.ROWGROUPINDEX}, ${G.ROWGROUP} as category`:t===G.SUBCATEGORY&&i.hierarchy.includes(Y.SUBCATEGORYINDEX)?`${Y.SUBCATEGORYINDEX}, ${G.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===G.CATEGORY&&i.hierarchy.includes(Y.CATEGORYINDEX)?`${Y.CATEGORYINDEX}, ${G.CATEGORY}`:t===G.ROWGROUP&&i.hierarchy.includes(Y.ROWGROUPINDEX)?`${Y.ROWGROUPINDEX}, ${G.ROWGROUP}`:t===G.SUBCATEGORY&&i.hierarchy.includes(Y.SUBCATEGORYINDEX)?`${Y.SUBCATEGORYINDEX}, ${G.SUBCATEGORY}`:`${t.toString()}`}createOrderStr(t,i){let s=`${t.toLowerCase()}`;return i.hierarchy.length>=1&&(s=i.hierarchy.map((t=>`${t} ${i.direction}`)).toString()),s}get em(){return this.styles.fontStyles.size}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,i=!1){const s=Qh(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:i?"bold":"normal"}).width;return Number.isFinite(s)&&s>0?s:.6*t.length*this.em}drawText(t,i,s,e,n={}){var r,o,h;return t.text(i).font({size:null!==(r=n.size)&&void 0!==r?r:this.styles.fontStyles.size,weight:n.bold?"bold":"normal",anchor:null!==(o=n.anchor)&&void 0!==o?o:"start"}).fill(null!==(h=n.color)&&void 0!==h?h:this.styles.fontStyles.color).attr({x:s,y:e,"font-family":this.fontFamily()})}setI18n(t){this.i18nMap=t}hasNoData(){return 0===this.rows.length}getWarnings(){return this.warnings}getQueryError(){return this.queryError}getAllocatedCanvasWidth(){return this.availableWidth}getAllocatedCanvasHeight(){return this.styles.padding.top+this.titleHeight()+this.headerHeight()+this.rows.length*this.rowBlockHeight()+this.styles.padding.bottom}titleHeight(){return""!==this.config.chartTitle?1.6*this.em:0}headerHeight(){return this.rows.length>0?1.2*this.em:0}rowBlockHeight(){const t=this.em,i=this.styles.scaleFactors.rowHeight*t;return this.normalized?i:i+this.styles.scaleFactors.tickStripHeight*t}valueLabel(t){return null===t||"none"===this.config.labels.show?"":ra.number(t,"decimal",this.config.labels.decimals,0,1,this.styles.locale)}targetFamily(){var t,i;const s=null!==(i=null===(t=this.config.target)||void 0===t?void 0:t.measure)&&void 0!==i?i:"pl1";return Ls(this.ruleSet.getScenarioColorIndex(s))}actualLabel(){var t;return null!==(t=this.config.actual.label)&&void 0!==t?t:ra.translateScenarioLabel(this.config.actual.measure,this.i18nMap)}targetLabel(){return null===this.config.target?"":void 0!==this.config.target.label?this.config.target.label:this.normalized?this.i18nMap.get("target")||"Target":ra.translateScenarioLabel(this.config.target.measure,this.i18nMap)}toString(){const t=new uh;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}draw(t){var i,s;const e=this.em,n=this.styles.scaleFactors,r=this.styles.padding,o=t.group();if(""!==this.config.chartTitle&&this.drawText(o,this.config.chartTitle,r.left,r.top+e,{bold:!0}),0===this.rows.length)return void t.group().addClass("annotations");const h=n.rowHeight*e,a=this.rowBlockHeight(),l=r.top+this.titleHeight()+this.headerHeight(),c=l+(this.rows.length-1)*a+h,u=Math.max(...this.rows.map((t=>this.textWidth(t.category,!0))),e),d=this.rows.map((t=>this.valueLabel(t.actual))),f="none"===this.config.labels.show?0:Math.max(...d.map((t=>this.textWidth(t))),0),v=r.left+u+n.labelToAxis*e,p=Math.max(10,this.availableWidth-v-r.right-f-(f>0?n.labelToBar*e:0)),g=null!==(i=this.config.actual.unit)&&void 0!==i?i:null===(s=this.config.target)||void 0===s?void 0:s.unit,m=this.i18nMap.get("axis.in")||"in",b=l-.35*e;void 0!==g&&""!==g&&this.drawText(o,`${m} ${g}`,r.left,b,{}),this.drawText(o,this.actualLabel(),v+.2*e,b,{}),this.normalized?this.drawNormalized(o,v,p,l,c,h,a,d):this.drawClassic(o,v,p,l,h,a,d),this.rows.forEach(((t,i)=>{this.drawText(o,t.category,v-n.labelToAxis*e,l+i*a+h/2+.35*e,{anchor:"end",bold:!0})})),o.line(v,l-.2*e,v,c+.2*e).stroke({color:this.styles.axisStyles.ac.stroke,width:Vt(n.axisLineWidth,this.em)}).attr(Wi,"axis"),t.group().addClass("annotations")}drawNormalized(t,i,s,e,n,r,o,h){const a=this.em,l=this.styles.scaleFactors,c=Math.max(1,...this.rows.map((t=>{var i;return null!==(i=t.fraction)&&void 0!==i?i:0}))),u=1.05*c,d=t=>i+t/u*s,f=d(1),v=this.styles.barStyles.getSVGStyle(this.targetFamily()),p=t.line(f,e-.3*a,f,n+.3*a).stroke({color:v.stroke,width:Vt(l.targetLineWidth,this.em)});void 0!==v.dasharray&&p.attr("stroke-dasharray",v.dasharray),this.drawText(t,this.targetLabel(),f,e-.35*a,{anchor:"middle",bold:!0}),this.rows.forEach(((s,n)=>{const c=e+n*o+r/2;if(null===s.fraction)return void this.drawValueText(t,h[n],i+l.labelToBar*a,c,s);const u=l.barHeight*a,v=d(s.fraction);if(t.rect(Math.max(0,v-i),u).move(i,c-u/2).fill(this.styles.barStyles.ac.fill).stroke({color:this.styles.barStyles.ac.stroke,width:this.styles.barStyles.ac.width}).attr(ji(this.rowKey(s),"element")).attr("data-bn-index",String(n)),this.config.showVariances&&"neu"!==s.sentiment){const i=l.varianceHeight*a,e=this.styles.varianceStyles.getSVGStyle(s.sentiment);t.rect(Math.abs(v-f),i).move(Math.min(v,f),c-i/2).fill(e.fill).stroke({color:e.stroke,width:e.width})}this.drawValueText(t,h[n],Math.max(v,f)+l.labelToBar*a,c,s)}))}drawClassic(t,i,s,e,n,r,o){const h=this.em,a=this.styles.scaleFactors,l=a.barHeight*h,c=this.config.ranges.length>0;this.rows.forEach(((u,d)=>{var f,v;const p=e+d*r,g=p+n/2,m=c&&null!==u.target?this.config.ranges.map((t=>t*u.target)):[],b=Math.max(null!==(f=u.actual)&&void 0!==f?f:0,null!==(v=u.target)&&void 0!==v?v:0,...m);if(b<=0)return void this.drawValueText(t,o[d],i+a.labelToBar*h,g,u);const y=oa.niceStep(b,4),w=Math.ceil(b/y-1e-9*y)*y,x=new oa(0,w,i,i+s);let S=i;m.forEach(((i,s)=>{const e=.8*n;t.rect(Math.max(0,x.scale(i)-S),e).move(S,g-e/2).fill(this.styles.rangeColors[Math.min(s,this.styles.rangeColors.length-1)]).stroke("none"),S=x.scale(i)}));let $=i;if(null!==u.actual&&u.actual>0){const s=x.scale(u.actual);t.rect(s-i,l).move(i,g-l/2).fill(this.styles.barStyles.ac.fill).stroke({color:this.styles.barStyles.ac.stroke,width:this.styles.barStyles.ac.width}).attr(ji(this.rowKey(u),"element")).attr("data-bn-index",String(d)),$=s}if(null!==u.target&&u.target>0){const i=x.scale(u.target),s=a.targetTickHeight*h,n=this.styles.barStyles.getSVGStyle(this.targetFamily()),r=t.line(i,g-s/2,i,g+s/2).stroke({color:n.stroke,width:Vt(a.targetLineWidth,this.em)});void 0!==n.dasharray&&r.attr("stroke-dasharray",n.dasharray),0===d&&this.drawText(t,this.targetLabel(),i,e-.35*h,{anchor:"middle"}),$=Math.max($,i)}$=Math.max($,S),this.drawValueText(t,o[d],$+a.labelToBar*h,g,u);const M=x.ticks(4),_=oa.tickDecimals(M),O=p+n;for(const i of M){const s=x.scale(i);t.line(s,O,s,O+a.axisTickLength*h).stroke({color:this.styles.axisStyles.ac.stroke,width:Vt(a.axisLineWidth,this.em)}),this.drawText(t,ra.number(i,"decimal",_,_,1,this.styles.locale),s,O+a.tickStripHeight*h-.2*h,{anchor:"middle"})}}))}drawValueText(t,i,s,e,n){""!==i&&this.drawText(t,i,s,e+.35*this.em,{}).attr(ji(this.rowKey(n),"label"))}rowKey(t){return Object.assign(Object.assign({},Bi(this.config.level,t.category)),{scenario:this.config.actual.measure})}}class Ia{constructor(){this.rowHeight=1.9,this.barHeight=.66,this.varianceHeight=.4,this.targetTickHeight=1.1,this.targetLineWidth=.15,this.axisLineWidth=.075,this.labelToBar=.3,this.labelToAxis=.3,this.axisTickLength=.35,this.tickStripHeight=1.2}}class Ya{adapt(t){const i=new Ia;return R.isNumber(t.rowHeight)&&(i.rowHeight=t.rowHeight),R.isNumber(t.barHeight)&&(i.barHeight=t.barHeight),R.isNumber(t.varianceHeight)&&(i.varianceHeight=t.varianceHeight),R.isNumber(t.targetTickHeight)&&(i.targetTickHeight=t.targetTickHeight),R.isNumber(t.targetLineWidth)&&(i.targetLineWidth=t.targetLineWidth),R.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),R.isNumber(t.labelToBar)&&(i.labelToBar=t.labelToBar),R.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),R.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),R.isNumber(t.tickStripHeight)&&(i.tickStripHeight=t.tickStripHeight),i}default(){return new Ia}}class Ba{constructor(t,i,s,e,n,r){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=e,this.varianceStyles=n,this.padding=r,this.rangeColors=["#D9D9D9","#EFEFEF"],this.locale="de"}}class Ha{constructor(t,i,s,e,n){this.scaleFactorsBulletChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=e,this.paddingAdapter=n}adapt(t){const i=this.default();return R.isExisting(t)&&(R.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsBulletChartAdapter.adapt(t.scaleFactors)),R.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),R.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),R.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),R.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),R.isExisting(t.padding)&&(i.padding=this.paddingAdapter.adapt(t.padding)),Array.isArray(t.rangeColors)&&t.rangeColors.length>0&&(i.rangeColors=t.rangeColors)),i}default(){return new Ba(this.scaleFactorsBulletChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingAdapter.default())}}const Va=["bullet-target-missing","bullet-target-invalid","bullet-actual-negative","bullet-mixed-operation","bullet-target-none"],Xa=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.chartTitle="",this.target=null,this.ranges=[],this.normalizeMode="target",this.showVariances=!0,this.level=G.CATEGORY,this.limit=0,this.filter="",this.i18n=new Map,this.containerWidth=0,this.svgMarkup="",a(this)}getDb(){return this.stores||(this.stores=c(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=$(this.getDb(),this.tableName,this.filter);this.chart=new ja(new Cs(this.ruleSetConfig),this.getDb(),i,{chartTitle:this.chartTitle,actual:this.actual,target:this.target,ranges:this.ranges,normalize:this.normalizeMode,showVariances:this.showVariances,level:this.level,order:this.order,limit:this.limit,labels:this.labels},t,this.containerWidth||0),this.chart.setI18n(this.i18n),this.svgMarkup=this.chart.hasNoData()?"":this.chart.toString(),this.syncWarnings(this.chart.getWarnings()),ui(this.errors,this.chart.getQueryError())}syncWarnings(t){if(void 0===this.errors)return;const i=new Map(t.map((t=>[t.code,t.data])));for(const t of Va){const s=`WARN_${t.replace(/-/g,"_")}`;if(i.has(t)){const e=void 0!==this.translator?this.translator(`.${t}`,i.get(t)):t;this.errors.addOrReplace({id:s,type:"warning",message:e})}else this.errors.remove(s)}}prepareStyle(){var t,i;const s=new Ha(new Ya,new Ws,new Is(new Gs),new Ga(new Gs),new zs).adapt(this.styles);return s.locale=(null===(i=null===(t=c(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}render(){var t;if(void 0===this.chart||void 0!==this.chart.getQueryError())return i(s,null);if(this.chart.hasNoData()){const e=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return i(s,{class:"no-data"},i("div",{class:"empty-state"},e))}return i(s,null,i("div",{innerHTML:this.svgMarkup}))}get element(){return e(this)}};Xa.style=':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}';const Ja={rowGroup:0,category:1,subCategory:2},qa=class{validateFilter(t){const i="ERR_filter";v(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateX(t){this.validateAxisSpec("x",t)}validateY(t){this.validateAxisSpec("y",t)}validateIso(t){this.validateObjectSpec("iso",t,null,(t=>gs(t)))}validateLevel(t){const i="WARN_level",s=["auto","category","subcategory"];N(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateSeriesLevel(t){const i="WARN_seriesLevel",s=["auto","rowgroup","category","none"];N(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`series-level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateFacet(t){this.validateObjectSpec("facet",t,null,(t=>ws(t)))}validateLabels(t){this.validateObjectSpec("labels",t,null,(t=>bs(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,null,(t=>Ss(t)))}validateAspect(t){const i="WARN_aspect";N(t)||null!==this.parseAspect(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`aspect: invalid value '${t}' - expected "w:h" (e.g. "16:9"); using the default.`})}validateLimit(t){const i="WARN_limit";L(t)&&Number(t)>=0?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`limit: invalid value '${t}' - expected a non-negative integer; using 0.`})}validateScale(t){const i="WARN_scale";if(N(t))return void this.errors.remove(i);const{mode:s,factor:e}=Ht(t);"factor"===s&&(void 0===e||e<=0)?this.errors.addOrReplace({id:i,type:"warning",message:`scale: invalid value '${t}' - expected none/auto or a positive number.`}):this.errors.remove(i)}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.chartTitle="",this.filter="",this.iso="",this.level="auto",this.seriesLevel="auto",this.facet="",this.labels="",this.legend="",this.aspect="16:9",this.limit=0,this._autoScaleGuard=!1,this._lastObservedWidth=0,this.translateForInner=(t,i)=>this.t(t,i),E(this),a(this),Yt(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.errors=l(this),this.componentStyle=k(this),this.ruleSetConfig=es(this),this.t=Bt(this).t}componentWillLoad(){this.validateFilter(this.filter),this.validateX(this.x),this.validateY(this.y),this.validateIso(this.iso),this.validateLevel(this.level),this.validateSeriesLevel(this.seriesLevel),this.validateFacet(this.facet),this.validateLabels(this.labels),this.validateLegend(this.legend),this.validateAspect(this.aspect),this.validateLimit(this.limit),this.validateScale(this.scale)}componentDidRender(){$s(this.element,"bn-chart-scatter-renderer");const{mode:t}=Ht(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{width:s}=Ut(i);if(s<=0)return void this.checkOverflow();this._lastObservedWidth=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),n=i.scrollWidth,o=this.appliedScaleFactor;if(!Number.isFinite(n)||n<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const h=Math.max(.3,o*(s-1)/n);Math.abs(h-o)<.01||(i.style.setProperty("--bn-font-size",e*h+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${h.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,r((()=>{this.appliedScaleFactor=h}))),this.checkOverflow()}checkOverflow(){is(this.element,"bn-chart-scatter-renderer",this.errors)}componentDidLoad(){this.layoutObserver=ss(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=Ut(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2?(this._lastObservedWidth=t,n(this)):this.checkOverflow()})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=Ut(this.element);this._lastObservedWidth=t,n(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{points:"auto",values:!1,max:12}}setBlockingError(t,i){null===i?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:i}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateAxisSpec(t,i){var s;const e=`ERR_xy_json_${t}`,n=`ERR_xy_measure_${t}`,r=`WARN_xy_fields_${t}`,o="x"===t||"y"===t||"size"===t,{data:h,parseError:a}=rs(i,"measure");if(a)return this.setBlockingError(e,this.t(".xy-prop-json",{prop:t})),this.setBlockingError(n,null),void this.errors.remove(r);if(this.setBlockingError(e,null),null===h)return this.setBlockingError(n,o?this.t(".xy-measure-invalid",{prop:t,measure:""}):null),void this.errors.remove(r);const l="share"===t?null:cs(h),c=null!==(s=h.measure)&&void 0!==s?s:"";T(c)?this.setBlockingError(n,null):this.setBlockingError(n,this.t(".xy-measure-invalid",{prop:t,measure:c})),this.reportSpecIssues(r,t,l)}validateObjectSpec(t,i,s,e){const n=`ERR_xy_json_${t}`,r=`WARN_xy_fields_${t}`,{data:o,parseError:h}=rs(i,s);if(h)return this.setBlockingError(n,this.t(".xy-prop-json",{prop:t})),void this.errors.remove(r);this.setBlockingError(n,null),null!==o?this.reportSpecIssues(r,t,e(o)):this.errors.remove(r)}reportSpecIssues(t,i,s){const e=[];null!==s&&s.invalidFields.length>0&&e.push(`invalid: ${s.invalidFields.join(", ")}`),null!==s&&s.unknownKeys.length>0&&e.push(`unknown: ${s.unknownKeys.join(", ")}`),e.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${i}: ignored sub-fields (${e.join("; ")}).`}):this.errors.remove(t)}prepareAxis(t,i){const{data:s,parseError:e}=rs(i,"measure");if(e||null===s)return null;const{config:n}=cs(s);return null!==n&&T(n.measure)?(void 0!==n.min&&void 0!==n.max&&n.min>=n.max?(this.errors.addOrReplace({id:`WARN_xy_domain_${t}`,type:"warning",message:`${t}: min must be smaller than max; the override is ignored.`}),n.min=void 0,n.max=void 0):this.errors.remove(`WARN_xy_domain_${t}`),n):null}prepareIso(){const{data:t,parseError:i}=rs(this.iso,null);return i||null===t?null:gs(t).config}prepareLabels(){const t=this.labelDefaults(),{data:i,parseError:s}=rs(this.labels,null);return s||null===i?{points:t.points,values:t.values,max:t.max}:bs(i,t).config}prepareLegend(){const{data:t,parseError:i}=rs(this.legend,null);return i||null===t?{show:!0,position:"right"}:Ss(t).config}prepareFacet(){const{data:t,parseError:i}=rs(this.facet,null);return i||null===t?null:ws(t).config}preparePointLevel(){var t,i;const s=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("category"===s)return"category";if("subcategory"===s)return"subCategory";const e=null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel;return"rowGroup"===e||"category"===e||"subCategory"===e?e:"category"}prepareSeriesLevel(t){var i;const s=null===(i=this.seriesLevel)||void 0===i?void 0:i.trim().toLowerCase();return"none"===s?null:"rowgroup"===s?"rowGroup":"category"===s||"subCategory"===t?"category":"category"===t?"rowGroup":null}validateCrossProp(t,i){const s=new Set;for(const i of t){if(void 0===i)continue;const t=C(i);null!==t&&"scenario"===t.kind&&s.add(P(t.slot))}this.setBlockingError("ERR_xy_family",s.size>1?this.t(".xy-family-mixed",{families:[...s].join(", ")}):null);const e=this.preparePointLevel(),n=this.prepareSeriesLevel(e),r=null!==i?"rowgroup"===i.level?"rowGroup":"category":null;let o=null;if(null!==n&&Ja[n]>=Ja[e]&&(o=`series '${n}' vs point '${e}'`),null!==r){const t=null!=n?n:e;Ja[r]>=Ja[t]&&(o=`facet '${r}' vs '${t}'`)}this.setBlockingError("ERR_xy_level_order",null!==o?this.t(".xy-level-order",{detail:o}):null)}parseAspect(t){const i=/^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/.exec(null!=t?t:"");if(null===i)return null;const s=Number(i[1]),e=Number(i[2]);return s<=0||e<=0?null:s/e}prepareAspect(){var t;return null!==(t=this.parseAspect(this.aspect))&&void 0!==t?t:16/9}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}i18nLocalKeys(){return["no-data","axis.in","legend.title"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),i=new Map(p.map((t=>[t,this.t("global.".concat(t))])));return new Map([...i.entries(),...t.entries()])}prepareStyle(){const t=this.getEffectiveScaleFactor(),i=this.element.localName;return this.componentStyle((s=>{const e=s.global.fontSizePx*t;return{scaleFactors:s[i].scaleFactors,fontStyles:{font:`${e}px ${s.global.fontFamily}`,size:e,color:s.global.fontColor,background:s.global.fontBackgroundColor,leading:1.8},axisStyles:s[i].axisStyles,seriesColors:s[i].seriesColors,padding:s[i].padding}}))}async getBaseline(){return Ui(this.element,"bn-chart-scatter-renderer")}async getLayoutState(t){var i;const s=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",e=ei(this.element),n=this.getEffectiveScaleFactor(),r=Number.isFinite(n)&&n>0?n:1,o=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*r;return ts(this.element,"bn-chart-scatter-renderer",this.chartTitle||void 0,{fontSizePx:o,appliedScaleFactor:r},e,s)}getEffectiveScaleFactor(){const{mode:t,factor:i}=Ht(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const o=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":o*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const i of["ac","pp","fc","pl"])for(const s of[1,2,3,4])t[`${i}${s}`]={type:"number",isOptional:!0,description:""};for(const[i,s]of Object.entries(this.mappedAxes())){if(null===s)continue;const e=C(s.measure);null!==e&&("scenario"===e.kind?t[e.slot].description=`${i}: ${"label"in s&&void 0!==s.label?s.label:s.measure}`:(t[e.measure.base].description=`${i}: ${s.measure} (base)`,t[e.measure.delta].description=`${i}: ${s.measure} (delta)`))}return{[this.dataStructureName()]:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}mappedAxes(){return{x:this.prepareAxis("x",this.x),y:this.prepareAxis("y",this.y)}}dataStructureName(){return"IScatterChartDataRow"}chartTemplate(){const t=this.prepareAxis("x",this.x),s=this.prepareAxis("y",this.y),e=this.prepareFacet();if(this.validateCrossProp([null==t?void 0:t.measure,null==s?void 0:s.measure],e),this.hasBlockingErrors()||null===t||null===s)return null;const n=this.preparePointLevel(),r=this.prepareI18n(),o=this.prepareStyle(),h=Ut(this.element).width;return i("bn-chart-scatter-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,x:t,y:s,iso:this.prepareIso(),labels:this.prepareLabels(),legend:this.prepareLegend(),facet:e,pointLevel:n,seriesLevel:this.prepareSeriesLevel(n),aspect:this.prepareAspect(),limit:this.prepareLimit(),filter:this.filter,styles:o,i18n:r,containerWidth:h,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return i(s,{key:"4947af836a9c76b089bc07fb1f4df8c248aa4f62",style:this.getFontStyles()},i("div",{key:"16abbc30d255d224aefecf9e337d3b23d449828a",class:"container"},this.chartTemplate()))}get element(){return e(this)}static get watchers(){return{filter:[{validateFilter:0}],x:[{validateX:0}],y:[{validateY:0}],iso:[{validateIso:0}],level:[{validateLevel:0}],seriesLevel:[{validateSeriesLevel:0}],facet:[{validateFacet:0}],labels:[{validateLabels:0}],legend:[{validateLegend:0}],aspect:[{validateAspect:0}],limit:[{validateLimit:0}],scale:[{validateScale:0}]}}};qa.style=':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:column}';class Ka{constructor(t,i){this.xScale=t,this.yScale=i}isPositiveDomain(){return this.xScale.domainMin>0&&this.yScale.domainMin>0}static autoK(t){const i=t.filter((t=>t>0)).sort(((t,i)=>t-i));if(0===i.length)return[];const s=t=>i[Math.min(i.length-1,Math.floor(t*i.length))];let e=Ka.ladderValues(s(.25),s(.75));if(e.length<2&&(e=Ka.ladderValues(i[0],i[i.length-1])),0===e.length)return[];if(1===e.length)return e;if(e.length<=4)return e;const n=[];for(let t=0;t<4;t++)n.push(e[Math.round(t*(e.length-1)/3)]);return[...new Set(n)]}static ladderValues(t,i){if(t<=0||i<t)return[];const s=[];for(let e=Math.floor(Math.log10(t))-1;e<=Math.ceil(Math.log10(i));e++)for(const n of[1,2,5]){const r=n*Math.pow(10,e);r>=t&&r<=i&&s.push(r)}return s}visibleRange(t){if(!this.isPositiveDomain()||t<=0)return null;const i=Math.max(this.xScale.domainMin,t/this.yScale.domainMax),s=Math.min(this.xScale.domainMax,t/this.yScale.domainMin);return i>=s?null:[i,s]}samples(t){const i=this.visibleRange(t);if(null===i)return null;const[s,e]=i,n=[];for(let i=0;i<64;i++){const r=s*Math.pow(e/s,i/63);n.push({x:this.xScale.scale(r),y:this.yScale.scale(t/r)})}return n}path(t){const i=this.samples(t);return null===i?null:i.map(((t,i)=>`${0===i?"M":"L"} ${t.x} ${t.y}`)).join(" ")}exitPoint(t){const i=this.visibleRange(t);if(null===i)return null;const s=i[1],e=s>=this.xScale.domainMax-1e-9*Math.abs(this.xScale.domainMax);return{x:this.xScale.scale(s),y:this.yScale.scale(t/s),edge:e?"right":"bottom"}}regionPath(t){if(!this.isPositiveDomain()||t<=0)return null;const i=this.xScale.domainMin,s=this.xScale.domainMax,e=this.yScale.domainMin,n=this.yScale.domainMax,r=this.xScale.scale(i),o=this.xScale.scale(s),h=this.yScale.scale(n),a=this.yScale.scale(e);if(t>=s*n)return null;if(t<=i*e)return`M ${r} ${h} L ${o} ${h} L ${o} ${a} L ${r} ${a} Z`;const l=this.samples(t),[c,u]=this.visibleRange(t),d=c>i,f=u>=s-1e-9*Math.abs(s),v=l.map(((t,i)=>`${0===i?"M":"L"} ${t.x} ${t.y}`));return f||v.push(`L ${o} ${a}`),v.push(`L ${o} ${h}`),d||v.push(`L ${r} ${h}`),v.push("Z"),v.join(" ")}}class Qa{constructor(t,i,s,e,n,r){var o,h;this.ruleSet=t,this.config=e,this.styles=n,this.availableWidth=r,this.warnings=[],this.canvasHeight=0,this.i18nMap=new Map,this.config=Object.assign(Object.assign({},e),{x:D(e.x),y:D(e.y)});const a=new Sa;let l=[];try{""!==s&&(l=i.exec(`SELECT * FROM ${s}`))}catch(t){this.queryError=ci(t)}const c=(null!=l?l:[]).map((t=>a.adapt(t)));this.data=ka(c,{pointLevel:e.pointLevel,seriesLevel:e.seriesLevel,facetLevel:null!==e.facet?"rowgroup"===e.facet.level?"rowGroup":"category":null,measures:{x:null!==(o=C(e.x.measure))&&void 0!==o?o:{kind:"scenario",slot:"ac1"},y:null!==(h=C(e.y.measure))&&void 0!==h?h:{kind:"scenario",slot:"ac2"}},domains:{x:{min:this.config.x.min,max:this.config.x.max},y:{min:this.config.y.min,max:this.config.y.max}},limit:e.limit,limitBy:"order"}),this.warnings.push(...this.data.warnings)}get em(){return this.styles.fontStyles.size}get xPercent(){return z(this.config.x.measure)}get yPercent(){return z(this.config.y.measure)}fontFamily(){return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/,"")}textWidth(t,i=!1){const s=Qh(t,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px",fontWeight:i?"bold":"normal"}).width;return Number.isFinite(s)&&s>0?s:.6*t.length*this.em}drawText(t,i,s,e,n={}){var r,o,h;return t.text(i).font({size:null!==(r=n.size)&&void 0!==r?r:this.styles.fontStyles.size,weight:n.bold?"bold":"normal",anchor:null!==(o=n.anchor)&&void 0!==o?o:"start"}).fill(null!==(h=n.color)&&void 0!==h?h:this.styles.fontStyles.color).attr({x:s,y:e,"font-family":this.fontFamily()})}hasNoData(){return 0===this.data.totalPoints}getWarnings(){return this.warnings}getQueryError(){return this.queryError}getAllocatedCanvasWidth(){return this.availableWidth}getAllocatedCanvasHeight(){return this.canvasHeight}axisTitle(t,i){var s;const e=null!==(s=t.label)&&void 0!==s?s:"";return""===e?"":void 0===t.unit||""===t.unit?e:`${e} ${i} ${t.unit}`}setI18n(t){this.i18nMap=t}legendModel(){const t=this.data.series.map((t=>{var i;return{label:""===t.key?null!==(i=this.ruleSet.getScenario("").name)&&void 0!==i?i:"Series":t.key,treatment:this.seriesTreatment(t.index)}}));return{sizeCaption:[],title:this.i18nMap.get("legend.title")||null,compareEntries:[],entries:t}}primaryColorIndex(){const t=C(this.config.x.measure);return null===t||"variance"===t.kind?10:this.ruleSet.getScenarioColorIndex(t.slot)}seriesTreatment(t){const{color:i,overflowed:s}=w(t,this.styles.seriesColors);return s&&this.addWarningOnce("xy-series-overflow",{}),x(this.primaryColorIndex(),i,"dot")}addWarningOnce(t,i){this.warnings.some((i=>i.code===t))||this.warnings.push({code:t,data:i})}toString(){const t=new uh;return this.draw(t),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}draw(t){var i,s,e,n,r,o,h,a,l,c;this.warnings=this.data.warnings.slice();const u=this.em,d=this.styles.padding,f=this.i18nMap.get("axis.in")||"in",v=t.group(),p=new ya(this.styles),g=this.legendModel(),m=this.config.legend.show&&g.entries.length>0,b=m?p.measure(g,this.config.legend.position):{width:0,height:0},y=null!==this.config.iso,w=y?Math.max(3*u,...this.isoValueLabels().map((t=>this.textWidth(t)+u)),this.textWidth(null!==(i=this.config.iso.label)&&void 0!==i?i:"",!0)+u,this.textWidth(void 0!==this.config.iso.unit&&""!==this.config.iso.unit?`${f} ${this.config.iso.unit}`:"")+u):0,x="right"===this.config.legend.position?Math.max(m?b.width+u:0,w):w,S=""!==this.config.chartTitle?1.6*u:0,$=this.axisTitle(this.config.y,f),M=this.axisTitle(this.config.x,f),_=""!==$?1.4*u:.4*u,O=1.4*u+(""!==M?1.3*u:0);let k,A=3*u,R={x:0,y:0,width:0,height:0},N=[];const L=Math.max(1,this.data.facets.length),E=null===(s=this.config.facet)||void 0===s?void 0:s.columns,T=oa.domain(null!==(n=null===(e=this.data.extents)||void 0===e?void 0:e.xMin)&&void 0!==n?n:0,null!==(o=null===(r=this.data.extents)||void 0===r?void 0:r.xMax)&&void 0!==o?o:1,{min:this.config.x.min,max:this.config.x.max}),C=oa.domain(null!==(a=null===(h=this.data.extents)||void 0===h?void 0:h.yMin)&&void 0!==a?a:0,null!==(c=null===(l=this.data.extents)||void 0===l?void 0:l.yMax)&&void 0!==c?c:1,{min:this.config.y.min,max:this.config.y.max});for(let t=0;t<2;t++){const t=Math.max(10,this.availableWidth-d.left-d.right-A-x);R={x:d.left+A,y:d.top+S+_,width:t,height:t/this.config.aspect},k=new sa(L,E,R,this.styles.scaleFactors.panelGap*u);const i=k.panelRect(0).height,s=Math.max(4,Math.min(8,Math.round(i/(4*u)))),e=new oa(C[0],C[1],i,0);N=e.ticks(s);const n=aa(N,this.yPercent);A=Math.max(...N.map((t=>this.textWidth(ha(t,n,this.styles.locale,this.yPercent)))),u)+this.styles.scaleFactors.axisTickLength*u+.4*u}this.canvasHeight=R.y+R.height+O+("bottom"===this.config.legend.position&&m?b.height+u:0)+d.bottom,""!==this.config.chartTitle&&this.drawText(v,this.config.chartTitle,d.left,d.top+u,{bold:!0}),""!==$&&this.drawAxisTitleText(v,this.config.y,f,d.left,R.y-.6*u,"start");const P=this.buildPanels(k,T,C),W=P[0].xScale.ticks(Math.max(3,Math.min(8,Math.round(P[0].rect.width/(7*u))))),D=aa(W,this.xPercent),z=aa(N,this.yPercent);let U=!1;y&&(T[0]>0&&C[0]>0?U=!0:this.addWarningOnce("xy-iso-domain",{})),0===this.data.facets.length?this.drawPanel(v,P[0],{key:"",points:[]},W,N,D,z,!0,!0,U):this.data.facets.forEach(((t,i)=>{this.drawPanel(v,P[i],t,W,N,D,z,k.isOuterLeft(i),k.isOuterBottom(i),U,this.data.facets.length>1?t.key:"")})),""!==M&&this.drawAxisTitleText(v,this.config.x,f,R.x+R.width,R.y+R.height+2.6*u,"end"),m&&("right"===this.config.legend.position?p.draw(v,g,R.x+R.width+u,R.y,"right"):p.draw(v,g,R.x,R.y+R.height+O,"bottom")),t.group().addClass("annotations")}drawAxisTitleText(t,i,s,e,n,r){var o;const h=null!==(o=i.label)&&void 0!==o?o:"",a=void 0!==i.unit&&""!==i.unit?`${s} ${i.unit}`:"",l=.3*this.em;"start"===r?(this.drawText(t,h,e,n,{bold:!0}),""!==a&&this.drawText(t,a,e+this.textWidth(h,!0)+l,n,{})):""!==a?(this.drawText(t,a,e,n,{anchor:"end"}),this.drawText(t,h,e-this.textWidth(a)-l,n,{anchor:"end",bold:!0})):this.drawText(t,h,e,n,{anchor:"end",bold:!0})}buildPanels(t,i,s){const e=[];for(let n=0;n<t.count;n++){const r=t.panelRect(n),o=new oa(i[0],i[1],r.x,r.x+r.width),h=new oa(s[0],s[1],r.y+r.height,r.y);e.push({rect:r,xScale:o,yScale:h,frame:new ba(o,h,r,this.styles)})}return e}drawPanel(t,i,s,e,n,r,o,h,a,l,c=""){var u,d;const f=t.group(),v=this.em;i.frame.drawBands(f,this.config.x.highlight,this.config.y.highlight),i.frame.drawGrid(f,n,void 0===this.config.x.refLine&&void 0===this.config.y.refLine&&i.rect.width>30*v?e:void 0),l&&null!==this.config.iso&&this.drawIso(f,i),i.frame.drawRefLines(f,this.config.x.refLine,this.config.y.refLine),i.frame.drawFrame(f);const p=this.styles.scaleFactors.pointRadius*v,g=new ga(i.rect,this.styles.scaleFactors.labelToMark*v),m=[];for(const t of s.points){const e=null!==(d=null===(u=this.data.series.find((i=>i.key===t.seriesKey)))||void 0===u?void 0:u.index)&&void 0!==d?d:0,n=this.seriesTreatment(e),r=i.xScale.scale(t.x),o=i.yScale.scale(t.y);m.push({point:t,cx:r,cy:o,treatment:n});const h=f.circle(2*p).center(r,o).fill(n.fill).stroke({color:n.stroke,width:n.strokeWidth}).attr(ji(Xh(t,s.key,this.config),"element"));void 0!==n.dasharray&&h.attr("stroke-dasharray",n.dasharray),g.registerMark(r,o,p)}this.drawPointLabels(f,g,m,p,s.key),i.frame.drawTickLabels(f,{ticksX:e,ticksY:n,xDecimals:r,yDecimals:o,xPercent:this.xPercent,yPercent:this.yPercent,showXLabels:a,showYLabels:h}),""!==c&&i.frame.drawPanelTitle(f,c)}drawPointLabels(t,i,s,e,n){const r=s.reduce(((t,i)=>t+i.cx),0)/Math.max(1,s.length),o=s.reduce(((t,i)=>t+i.cy),0)/Math.max(1,s.length),h=[...s].sort(((t,i)=>Math.hypot(i.cx-r,i.cy-o)-Math.hypot(t.cx-r,t.cy-o))),{selected:a,unknownNames:l}=i.selectCandidates(h,this.config.labels.points,this.config.labels.max,(t=>t.point.name));l.length>0&&this.addWarningOnce("xy-label-unknown",{names:l.join(", ")});const c=new Map,u=a.map((t=>{const i={name:t.point.name,cx:t.cx,cy:t.cy,r:e,width:this.textWidth(t.point.name),height:1.1*this.em};return c.set(i,t.point),i}));for(const s of i.place(u))this.drawText(t,s.candidate.name,s.x,s.y+.9*s.candidate.height,{}).attr(ji(Xh(c.get(s.candidate),n,this.config),"label"))}drawIso(t,i){const s=this.config.iso,e=new Ka(i.xScale,i.yScale),n=this.i18nMap.get("axis.in")||"in",r=this.isoValues(),o=this.isoValueLabels();if(void 0!==s.highlight){const i=e.regionPath(s.highlight.from);null!==i&&t.path(i).fill(this.styles.axisStyles.pl.fill).stroke("none")}const h={color:this.styles.axisStyles.fc.stroke,width:Vt(this.styles.scaleFactors.gridLineWidth,this.em)};let a=null;for(const[i,s]of r.entries()){const n=e.path(s);if(null===n)continue;t.path(n).fill("none").stroke(h);const r=e.exitPoint(s);null!==r&&(this.drawText(t,o[i],r.x+.4*this.em,"right"===r.edge?r.y+.35*this.em:r.y-.5*this.em,{}),(null===a||r.y<a.y)&&(a=r))}if(null!==a&&void 0!==s.label&&""!==s.label){const i=void 0!==s.unit&&""!==s.unit?`${n} ${s.unit}`:"";this.drawText(t,s.label,a.x+.4*this.em,a.y-1.6*this.em,{bold:!0}),""!==i&&this.drawText(t,i,a.x+.4*this.em,a.y-.5*this.em,{})}}isoValues(){const t=this.config.iso;return"auto"!==t.values?t.values:Ka.autoK(this.data.facets.flatMap((t=>t.points.map((t=>t.x*t.y)))))}isoValueLabels(){const t=this.isoValues(),i=Math.max(0,...t.map((t=>oa.stepDecimals(Math.abs(t)))));return t.map((t=>ha(t,i,this.styles.locale)))}}const Za=["xy-duplicate-point","xy-point-clipped","xy-variance-nodata","xy-iso-domain","xy-label-unknown","xy-series-overflow","xy-point-budget"],tl=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.chartTitle="",this.iso=null,this.facet=null,this.pointLevel="category",this.seriesLevel=null,this.aspect=16/9,this.limit=0,this.filter="",this.i18n=new Map,this.containerWidth=0,this.svgMarkup="",a(this)}getDb(){return this.stores||(this.stores=c(this.element)),this.stores.db.db}componentWillLoad(){this.rebuild()}componentWillUpdate(){this.rebuild()}rebuild(){const t=this.prepareStyle(),i=$(this.getDb(),this.tableName,this.filter);this.chart=new Qa(new Cs(this.ruleSetConfig),this.getDb(),i,{chartTitle:this.chartTitle,x:this.x,y:this.y,iso:this.iso,labels:this.labels,legend:this.legend,facet:this.facet,pointLevel:this.pointLevel,seriesLevel:this.seriesLevel,aspect:this.aspect,limit:this.limit},t,this.containerWidth||0),this.chart.setI18n(this.i18n),this.svgMarkup=this.chart.hasNoData()?"":this.chart.toString(),this.syncWarnings(this.chart.getWarnings()),ui(this.errors,this.chart.getQueryError())}syncWarnings(t){if(void 0===this.errors)return;const i=new Map(t.map((t=>[t.code,t.data])));for(const t of Za){const s=`WARN_${t.replace(/-/g,"_")}`;if(i.has(t)){const e=void 0!==this.translator?this.translator(`.${t}`,i.get(t)):t;this.errors.addOrReplace({id:s,type:"warning",message:e})}else this.errors.remove(s)}}prepareStyle(){var t,i;const s=new Bs(new Vs,new Ws,new Is(new Gs),new zs).adapt(this.styles);return s.locale=(null===(i=null===(t=c(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}render(){var t;if(void 0===this.chart||void 0!==this.chart.getQueryError())return i(s,null);if(this.chart.hasNoData()){const e=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return i(s,{class:"no-data"},i("div",{class:"empty-state"},e))}return i(s,null,i("div",{innerHTML:this.svgMarkup}))}get element(){return e(this)}};tl.style=':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}';const il=class{validateFilter(t){const i="ERR_filter";v(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(Gt(t))return void this.errors.remove(i);const s=B(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(Gt(t))return void this.errors.remove(i);const s=H(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateUnitScaling(t){const i="WARN_unitScaling";N(t)?this.errors.remove(i):"invalid"===Xt(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="WARN_percentageScaling";N(t)?this.errors.remove(i):"invalid"===Xt(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validateLevel(t){const i="WARN_level";N(t)||V(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"level: invalid value(s) '"+t+"' are not supported."})}validateOrderList(t){const i="WARN_order";if(Gt(t))return void this.errors.remove(i);const s=U(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="WARN_orderDirection";Gt(t)||N(t)||F(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateLimit(t){const i="WARN_limit";L(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";X(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateStack(t){const i="WARN_stack",s=J(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:s.join("; ")}):this.errors.remove(i)}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("WARN_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"WARN_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("WARN_scale")}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this._lastScaledParentHeight=0,this.chartTitle="",this.filter="",this.limit=0,this.showCategories=!0,this.measureScale="greatest",this.showMeasureScale=!1,this.measureUnit="",this.stack="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=t=>{var i,s,e,n,r,o;this.lastAutoScalingReport={unit:null!==(i=t.unit)&&void 0!==i?i:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(e=t.percentage)&&void 0!==e?e:null===(n=this.lastAutoScalingReport)||void 0===n?void 0:n.percentage};const h=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),a=this.getEffectiveFontPx();if(void 0!==t.unit&&t.unit>0&&this.autoUnitWarningActive){const i=a/t.unit;h(i,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=i,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${il.describeScalingInput(String(null!==(r=this.unitScaling)&&void 0!==r?r:"").trim())}, auto-fitted to 1 em ≈ ${Jt(i)} units.`}))}if(void 0!==t.percentage&&t.percentage>0&&this.autoPctWarningActive){const i=100*a/t.percentage;h(i,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=i,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${il.describeScalingInput(String(null!==(o=this.percentageScaling)&&void 0!==o?o:"").trim())}, auto-fitted to 1 em ≈ ${Jt(i)} percentage points.`}))}},E(this),a(this),Yt(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=l(this),ns(this),this.componentStyle=k(this),this.ruleSetConfig=es(this),this.t=Bt(this).t,this.resolveInherited=qt(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}],this.errors)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateMeasureScale(this.measureScale),this.validateStack(this.stack),this.validateScaling(this.scale)}componentDidRender(){$s(this.element,"bn-chart-structure-renderer");const{mode:t}=Ht(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{height:s}=Ut(i);if(s<=0)return void this.checkOverflow();this._lastScaledParentHeight=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),n=i.scrollHeight,o=this.appliedScaleFactor;if(n<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const h=Math.max(.3,o*(s-1)/n);Math.abs(h-o)<.01||(i.style.setProperty("--bn-font-size",e*h+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${h.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,r((()=>{this.appliedScaleFactor=h}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=ss(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=Ut(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,n(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=Ut(this.element);this._lastScaledParentHeight=t,n(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}measureContentWidth(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-structure-renderer");let s=0,e=!1;return null==i||i.forEach((t=>{var i,n,r;const o=parseFloat(null!==(r=null===(n=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===n?void 0:n.getAttribute("width"))&&void 0!==r?r:"");Number.isNaN(o)||(s+=o,e=!0)})),e?Math.max(Math.floor(s),this.element.scrollWidth):this.element.scrollWidth}checkOverflow(){const t=Ut(this.element),i=this.measureContentWidth(),s=this.element.scrollHeight,e=t.width>0&&i>t.width+1,n=t.height>0&&s>t.height+1;if(!e&&!n)return void M(this.errors,null);const r=this.prepareVariances().some((t=>t.startsWith("dr"))),o="value"===Xt(this.unitScaling,this.pixelPerUnitGroupMap).kind,h=r&&"value"===Xt(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:a}=Ht(this.scale),l="auto"!==a&&"empty"!==a,c=[];e&&o&&c.push("unit-scaling"),e&&h&&c.push("percentage-scaling"),n&&l&&c.push("scale");const u=[];e&&u.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),n&&u.push(`height (${Math.round(s)}px > ${Math.round(t.height)}px)`),M(this.errors,`Chart exceeds available ${u.join(" and ")}. `+(c.length>0?`Adjust ${c.join(" / ")} or set to "auto".`:"Content does not fit even at minimum auto scaling; enlarge the container."),c.length>0)}prepareDimension(){const t=Ut(this.element),i=this.prepareVariances();return this.canvasWidthSegmented=t.width/(1+i.length),{width:this.canvasWidthSegmented,height:t.height}}prepareScenarios(){var t,i,s,e;const n=this.resolveInherited("scenarios",this.scenarios);if(n.inherited)return this.errors.remove("AUTO_scenarios"),n.value.split(",").map((t=>t.trim()));const r="auto"===(null===(t=n.value)||void 0===t?void 0:t.trim().toLowerCase());return N(n.value)||r?(null===(s=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===s?void 0:s.length)>0?(r||n.unresolved?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(e=n.value)||void 0===e?void 0:e.split(",").map((t=>t.trim())))}prepareVariances(){const t=this.resolveInherited("variances",this.variances).value;return N(t)?[]:null==t?void 0:t.split(",").map((t=>t.trim()))}prepareHideCategories(t){return t>=1||!this.showCategories}prepareI18n(){const t=p,i=new Map(["no-data","REST"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries(),...Ts(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const t=Xt(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/t.value):"auto"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${il.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const t=Xt(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/t.value):"auto"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${il.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}prepareLevel(){var t,i,s;const e="auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase());return N(this.level)||e?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?(e?this.errors.remove("AUTO_level"):this.errors.addOrReplace({id:"AUTO_level",type:"warning",message:`level: not set, auto-detected: ${this.datasetMeta.suggestedLevel}`}),G[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),G[null===(s=this.level)||void 0===s?void 0:s.toUpperCase()])}prepareOrder(){var t;const i=this.resolveInherited("order",this.order),s=i.value,e=this.resolveInherited("orderDirection",this.orderDirection).value,n="auto"===(null==s?void 0:s.trim().toLowerCase());let r;return N(s)||n?(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)?(n||i.unresolved?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:`order: not set, auto-detected: ${this.datasetMeta.suggestedOrder}`}),r=this.datasetMeta.suggestedOrder):r=s:(this.errors.remove("AUTO_order"),r=s),{hierarchy:null==r?void 0:r.split(",").map((t=>Y[null==t?void 0:t.toUpperCase()])),direction:j[null==e?void 0:e.toUpperCase()]}}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const s=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-structure"].scaleFactors.scenarioOffset,scenarioLabelToBar:i["bn-chart-structure"].scaleFactors.scenarioLabelToBar,labelToBar:i["bn-chart-structure"].scaleFactors.labelToBar,labelToAxis:i["bn-chart-structure"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-structure"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-structure"].scaleFactors.needleHeadWidth,barWidth:i["bn-chart-structure"].scaleFactors.barWidth,varianceAxisLineWidth:i["bn-chart-structure"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-structure"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-structure"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-structure"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-structure"].scaleFactors.markerWidth,markerOffset:i["bn-chart-structure"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-structure"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-structure"].scaleFactors.axisTickLength},fontStyles:{font:`${s}px ${i.global.fontFamily}`,family:i.global.fontFamily,size:s,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-structure"].axisStyles,barStyles:i["bn-chart-structure"].barStyles,varianceStyles:i["bn-chart-structure"].varianceStyles,stackColors:i["bn-chart-structure"].stackColors,padding:i["bn-chart-structure"].padding,pattern:null}}))}prepareChartTitle(t){return t>=1?"":this.chartTitle}prepareStackConfig(){if(N(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const t=JSON.parse(this.stack),i=t.by,s="WARN_stack_dimensions_scenarios";if(i===q.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:s,type:"warning",message:`stack by dimensions: only the first scenario "${t[0]}" is used, the rest (${t.slice(1).join(", ")}) are discarded.`}):this.errors.remove(s)}else this.errors.remove(s);return{by:i,mode:t.mode||Q.ABSOLUTE,order:t.order||K.DATASET}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareLimit(){return Math.floor(Number(this.limit)||0)}getDataStructure(){return{IStructureChartDataRow:{operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return N(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}chartTemplate(t,s){const e=this.preparePixelPerUnit(),n=this.preparePixelPerPercentage(),r=this.prepareStackConfig(),o=this.prepareScenarios(),h=(null==r?void 0:r.by)===q.DIMENSIONS?o.slice(0,1):o;return i("bn-chart-structure-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(s),scenarios:h,variances:[t],hideCategories:this.prepareHideCategories(s),pixelPerUnit:e,pixelPerPercentage:n,reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,limit:this.prepareLimit(),styles:this.prepareStyle(),i18n:this.prepareI18n(),order:this.prepareOrder(),level:this.prepareLevel(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(s),stackConfig:r,parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}async getBaseline(){return Ui(this.element,"bn-chart-structure-renderer")}async getLayoutState(t){var i,s,e,n;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",o=ei(this.element),h=this.getEffectiveScaleFactor(),a=Number.isFinite(h)&&h>0?h:1,l=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*a,c=this.prepareVariances(),u=Zi(this.element,"bn-chart-structure-renderer",["base",...c],o,r),d=null===(s=this.element.shadowRoot)||void 0===s?void 0:s.querySelector("bn-chart-structure-renderer"),f={version:li,tag:this.element.localName,id:ii(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:ti(this.element,o),em:{fontSizePx:l,appliedScaleFactor:a},regions:u.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(n=null==d?void 0:d.scenarios)&&void 0!==n?n:[],variances:c,barCount:u.barCount,hasNoData:0===u.barCount},diagnostics:Zt(this.element),scaling:this.resolveScalingInfo(l),baseline:u.baseline};return u.elements&&(f.elements=u.elements),f}resolveScalingInfo(t){var i,s;const e={},n=Xt(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===n.kind)e.unitMode="fixed",e.unitsPerEm=n.value,e.unitPxPerUnit=t/n.value;else{e.unitMode="auto";const s=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==s&&s>0&&(e.unitPxPerUnit=s,e.unitsPerEm=t/s)}const r=Xt(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)e.percentageMode="fixed",e.percentagePointsPerEm=r.value,e.percentagePxPerPoint=t/r.value;else{e.percentageMode="auto";const i=null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.percentage;void 0!==i&&i>0&&(e.percentagePxPerPoint=i/100,e.percentagePointsPerEm=100*t/i)}return e}getEffectiveScaleFactor(){const{mode:t,factor:i}=Ht(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){const t=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}));return t*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const o=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":o*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){let t=[""];const e=this.prepareVariances();e.length>0&&(t=[...t,...e]);const n=this.getFontStyles();return i(s,{key:"467a851c6547b300c71a38e812bfea4718f27775",style:n},i("div",{key:"4b5078608132e047a9404987c65c46f43037c043",class:"container"},t.map(this.chartTemplate)))}get element(){return e(this)}static get watchers(){return{filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],measureScale:[{validateMeasureScale:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}}};il.style=':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}';let sl=class{constructor(t,i,s,e,n,r,o,h,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=e,this.leftSideLengthSync=n,this.topSideLabelHeight=r>0?this.fontSize:0,this.hasStackedHeaders=a,this.leftSideLabelLength=this.calculateSideLabelLength(r,o,h),this.calculateSpacings(),this.calculateCategoryPosition(),this.calculateAxisPosition()}getBarPositionX(){return this.axisPosition.x}getBarCenterPositionY(t){return this.categoryPosition.y+this.spacings.scenarioOffset+t*this.spacings.categoryWidth}getBarPositionY(t,i){return i?this.getBarCenterPositionY(t):this.getBarCenterPositionY(t)-this.spacings.scenarioOffset}getCategoryPositionX(t){let i=this.spacings.labelToAxis;return t&&(i=-this.spacings.labelToAxis),this.getAxisPositionX()+i}getAxisTitlePositionX(){return this.axisPosition.x}getAxisTitlePositionY(){return this.axisPosition.y-this.spacings.labelToAxis-this.getTopLabelOverhang()}getStackedHeaderPositionY(){return this.getBarCenterPositionY(0)-.5*this.spacings.barWidth-this.spacings.scenarioLabelToBar}getNeedleWidth(){return this.spacings.needleWidth}getAxisPositionX(){return this.leftSideLabelLength+this.padding.left+this.spacings.labelToAxis}getAxisPositionY(){return this.padding.top+this.getAxisTitleOffset()}loadCategoriesBox(t){this.categoriesBoxOffset=t,this.calculateAxisPosition()}addOffsetByNegativeDataPoints(t,i,s,e){null!=t&&null!=t.value&&t.value<0&&(s&&t.isClipped()?this.axisPosition.x+=Math.abs(t.getClippedValue()*t.pixelPerUnit):this.axisPosition.x+=Math.abs(t.value*t.pixelPerUnit),this.axisPosition.x+=i,this.axisPosition.x+=this.spacings.labelToBar),this.axisPosition.x<e/2&&(this.axisPosition.x=e/2+this.spacings.labelToBar)}getLabelPositionX(t){let i=this.spacings.labelToBar;return t<0&&(i*=-1),this.axisPosition.x+t+i}getLabelPositionY(t){return this.axisPosition.y+t+this.spacings.labelToBar}getCategoryToAxisSpaceing(){return this.spacings.labelToAxis}getCategoryToTopSpaceing(){return this.spacings.scenarioOffset}getCategoryToBottomSpaceing(){return this.spacings.scenarioOffset}getAxisEndPositionY(){return this.getAxisPositionY()+(this.numberOfColumns+.5)*this.spacings.categoryWidth}getScenarioLabelPositionOffsetY(t){if(t){const t=.5*this.getBarWidth()+this.spacings.scenarioLabelToBar;return Math.max(t,this.spacings.categoryWidth-this.spacings.scenarioOffset+this.spacings.labelToAxis)}return-(.5*this.getBarWidth()+this.spacings.scenarioLabelToBar)}getBarWidth(){return this.spacings.barWidth}getMarkerPositionY(t,i){return i?this.getBarCenterPositionY(t)-this.spacings.markerOffset-.5*this.getBarWidth():this.getBarCenterPositionY(t)+this.spacings.markerOffset+.5*this.getBarWidth()}getMarkerPositionX(){return this.getBarPositionX()}getMarkerScenarioLabelPositionOffsetY(t){return t?-(.5*this.spacings.markerWidth+this.spacings.scenarioLabelToBar):this.spacings.scenarioLabelToBar+.5*this.spacings.markerWidth}getAxisEndPositionX(){return this.getAxisPositionX()}calculateSpacings(){this.spacings={scenarioOffset:this.fontSize*this.scaleFactors.scenarioOffset,markerOffset:this.fontSize*this.scaleFactors.markerOffset,scenarioLabelToBar:this.fontSize*this.scaleFactors.scenarioLabelToBar,labelToBar:this.fontSize*this.scaleFactors.labelToBar,labelToAxis:this.fontSize*this.scaleFactors.labelToAxis,needleWidth:this.fontSize*this.scaleFactors.needleWidth,needleHeadWidth:this.fontSize*this.scaleFactors.needleHeadWidth,barWidth:this.fontSize*this.scaleFactors.barWidth,varianceAxisLineWidth:this.fontSize*this.scaleFactors.varianceAxisLineWidth,axisLineWidth:this.fontSize*this.scaleFactors.axisLineWidth,auxiliaryLineWidth:this.fontSize*this.scaleFactors.auxiliaryLineWidth,scenarioLineWidth:this.fontSize*this.scaleFactors.scenarioLineWidth,markerWidth:this.fontSize*this.scaleFactors.markerWidth,categoryWidth:this.fontSize*this.scaleFactors.categoryWidth,axisTickLength:this.fontSize*this.scaleFactors.axisTickLength}}calculateCategoryPosition(){this.categoryPosition={x:this.padding.left,y:this.getAxisPositionY()+.5*this.spacings.categoryWidth}}calculateAxisPosition(){this.axisPosition={x:this.getAxisPositionX(),y:this.getAxisPositionY()}}recalculatePositions(){this.calculateCategoryPosition(),this.calculateAxisPosition()}getAxisTitleOffset(){return this.topSideLabelHeight+this.spacings.labelToAxis+this.getTopLabelOverhang()}getTopLabelOverhang(){return this.hasStackedHeaders?this.getStackedHeaderOverhang():this.getTopScenarioLabelOverhang()}getStackedHeaderOverhang(){return Math.max(0,this.fontSize+this.spacings.scenarioLabelToBar+.5*this.spacings.barWidth-(.5*this.spacings.categoryWidth+this.spacings.scenarioOffset))}getTopScenarioLabelOverhang(){return Math.max(0,this.fontSize+.5*this.spacings.barWidth+this.spacings.scenarioLabelToBar-.5*this.spacings.categoryWidth,this.fontSize+.5*this.spacings.markerWidth+this.spacings.scenarioLabelToBar+this.spacings.markerOffset+.5*this.spacings.barWidth-(.5*this.spacings.categoryWidth+this.spacings.scenarioOffset))}calculateSideLabelLength(t,i,s){if(this.leftSideLengthSync)return this.leftSideLengthSync;const e=t/2;let n=i;return e>n&&(n=e),s>n&&(n=s),n}},el=class{constructor(t){this.top=t.top,this.bottom=t.bottom,this.left=t.left,this.right=t.right}addBoxTopLeft(t){return this.top+=t.height|this.top,this.left+=t.width|this.top,this}},nl=class{constructor(t){const i=1*t,s=.7*t;this.bgOffset=(i-s)/2,this.markerUp={top:s/2+",0",left:"0,"+s,right:s+","+s},this.markerUpBackground={top:i/2+",0",left:"0,"+i,right:i+","+i},this.markerDown={bottom:s/2+","+s,left:"0,0",right:s+",0"},this.markerDownBackground={bottom:i/2+","+i,left:"0,0",right:i+",0"}}upMarkerPatternStrings(){return{background:this.markerUpBackground.left+" "+this.markerUpBackground.right+" "+this.markerUpBackground.top+" "+this.markerUpBackground.left,foreground:this.markerUp.left+" "+this.markerUp.right+" "+this.markerUp.top+" "+this.markerUp.left,bgOffset:this.bgOffset}}downMarkerPatternStrings(){return{background:this.markerDownBackground.left+" "+this.markerDownBackground.right+" "+this.markerDownBackground.bottom+" "+this.markerDownBackground.left,foreground:this.markerDown.left+" "+this.markerDown.right+" "+this.markerDown.bottom+" "+this.markerDown.left,bgOffset:this.bgOffset}}createPatternMapForStructureBar(){const t=new Map;return t.set("marker-up",this.upMarkerPatternStrings()),t.set("marker-down",this.downMarkerPatternStrings()),t}},rl=class{constructor(t){this.container=new uh,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 ol,hl,al;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(ol||(ol={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(hl||(hl={})),function(t){t[t.Y=1e24]="Y",t[t.Z=1e21]="Z",t[t.E=1e18]="E",t[t.P=1e15]="P",t[t.T=1e12]="T",t[t.G=1e9]="G",t[t.M=1e6]="M",t[t.k=1e3]="k",t[t.h=100]="h",t[t.da=10]="da",t[t.d=.1]="d",t[t.c=.01]="c",t[t.m=.001]="m",t[t.my=1e-6]="my",t[t.n=1e-9]="n",t[t.p=1e-12]="p",t[t.f=1e-15]="f",t[t.a=1e-18]="a",t[t.z=1e-21]="z",t[t.y=1e-24]="y"}(al||(al={}));class ll{static calculateMeasureScale(t,i,s,e,n){var r,o;if("_"===e)return new la;if("μ"===e&&(e="my"),null!=e&&[...this.unitsLeast,...this.unitsGreat].includes(e))return this.lookupPrefix(e);const h=s.filter((t=>3===t.length));if(0===h.length||!i)return new la;const a=`SELECT MAX(GREATEST(${h.map((t=>"ABS("+t+")")).toString()})) as prefixvalue\n FROM ${i}`,l=`SELECT MIN(LEAST(${h.map((t=>"ABS("+t+")")).toString()})) as prefixvalue\n FROM ${i}`;let c,u=a;"LEAST"===(null==e?void 0:e.toUpperCase())&&(u=l);try{c=null!==(o=null===(r=t.exec(u)[0])||void 0===r?void 0:r.prefixvalue)&&void 0!==o?o:0}catch(t){return null==n||n(t),new la}return this.determinePrefix(Math.abs(c))}static determinePrefix(t){if(!Number.isFinite(t)||t<=0)return new la;if(t>=1e3){const i=Math.min(Math.floor(Math.log10(t)/3),this.unitsGreat.length)-1;return new la(this.unitsGreat[i],Math.pow(1e3,i+1))}if(t<=.001){const i=Math.min(-Math.floor(Math.log10(t)/3),this.unitsLeast.length)-1;return new la(this.unitsLeast[i],Math.pow(1e3,-(i+1)))}return new la}static lookupPrefix(t){return new la(t,al[t])}}ll.unitsGreat=["k","M","G","T","P","E","Z","Y"],ll.unitsLeast=["m","my","n","p","f","a","z","y"];class cl{adapt(t){return Z.adaptDefaultString(t)}default(){return""}}class ul{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 tt(new cl).default(),this.level=G.CATEGORY,this.filter="",this.measureScale=new la,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.stackConfig=null}}class dl{constructor(t,i,s,e,n,r,o){this.dataRowAdapter=t,this.orderAdapter=i,this.stringAdapter=s,this.dataFormatDigitsAdapter=e,this.db=n,this.fromExpr=r,this.onQueryError=o}adapt(t){const i=Z.adaptArray(t.data,this.dataRowAdapter),s=Z.adaptArray(t.scenarios,this.stringAdapter),e=new ul(i,s);return R.isArray(t.variances)&&(e.variances=Z.adaptArray(t.variances,this.stringAdapter)),R.isString(t.title)&&(e.title=t.title),R.isBoolean(t.hideCategories)&&(e.hideCategories=t.hideCategories),R.isNumber(t.pixelPerUnit)&&(e.pixelPerUnit=t.pixelPerUnit),R.isNumber(t.pixelPerPercentage)&&(e.pixelPerPercentage=t.pixelPerPercentage),R.isNumber(t.limit)&&(e.limit=t.limit),R.isExisting(t.sortOrder)&&(e.sortOrder=this.orderAdapter.adapt(t.sortOrder)),R.isExisting(t.level)&&(e.level=t.level),R.isString(t.filter)&&(e.filter=t.filter.trim()),R.isExisting(t.measureScale)&&(e.measureScale=ll.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale,this.onQueryError)),R.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),R.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),R.isExisting(t.dataFormatDigits)&&(e.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),R.isExisting(t.stackConfig)&&(e.stackConfig=t.stackConfig),e}default(){return new ul([],[])}}let fl=class{constructor(t,i,s,e){this.value=t,this.scenario=i,this.pixelPerUnit=s||1;const n="string"==typeof e?As(e,null,!0):e;this.variance="neg"===n||n===wl.NEG?wl.NEG:"pos"===n||n===wl.POS?wl.POS:wl.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:wl.NEU===this.variance?wl.NEU:wl.POS===this.variance?wl.NEG:wl.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 vl{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 pl{constructor(){}adapt(t){const i=new vl;return R.isOperator(t.operation)&&(i.operation=t.operation),R.isNumber(t.rowGroupIndex)&&R.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),R.isNumber(t.categoryIndex)&&R.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),R.isNumber(t.subCategoryIndex)&&R.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),R.isNumber(t.columnGroupIndex)&&R.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),R.isNumber(t.columnSubGroupIndex)&&R.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 vl}setActualValues(t,i){R.isNumber(t.ac1)&&(i.ac1=t.ac1),R.isNumber(t.ac2)&&(i.ac2=t.ac2),R.isNumber(t.ac3)&&(i.ac3=t.ac3),R.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){R.isNumber(t.pl1)&&(i.pl1=t.pl1),R.isNumber(t.pl2)&&(i.pl2=t.pl2),R.isNumber(t.pl3)&&(i.pl3=t.pl3),R.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){R.isNumber(t.pp1)&&(i.pp1=t.pp1),R.isNumber(t.pp2)&&(i.pp2=t.pp2),R.isNumber(t.pp3)&&(i.pp3=t.pp3),R.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){R.isNumber(t.fc1)&&(i.fc1=t.fc1),R.isNumber(t.fc2)&&(i.fc2=t.fc2),R.isNumber(t.fc3)&&(i.fc3=t.fc3),R.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class gl{constructor(t,i,s,e,n,r){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=e,this.varianceStyles=n,this.padding=r,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"],this.locale="de"}}class ml{constructor(t,i,s,e,n){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=e,this.paddingadapter=n}adapt(t){const i=new gl(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return R.isExisting(t)&&(R.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),R.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),R.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),R.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),R.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),R.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 nl(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new gl(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}class bl{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 yl{adapt(t){const i=new bl;return R.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),R.isNumber(t.scenarioLabelToBar)&&(i.scenarioLabelToBar=t.scenarioLabelToBar),R.isNumber(t.labelToBar)&&(i.labelToBar=t.labelToBar),R.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),R.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),R.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),R.isNumber(t.barWidth)&&(i.barWidth=t.barWidth),R.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),R.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),R.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),R.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),R.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),R.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),R.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),R.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new bl}}var wl,xl,Sl;!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"}(wl||(wl={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(xl||(xl={})),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"}(Sl||(Sl={}));class $l{constructor(t,i,s,e,n,r,o,h){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=n,null!=t&&(this.group=t.group().id(this.createElementID(t.toString(),e))),this.styles=r,this.isVarianceLabel=!1,this.isRelativeLabel=!1,this.verticalHookLocation=o||Sl.Top,this.horizontalHookLocation=h||Sl.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 la){var s;if(this.isEmpty())return this;const e=this.group;let n;const r=this.styles.fontStyles.background||"#ffffff";let o="",h="start";if(!1===Number.isNaN(Number(this.value))){let s=t.percent,e=t.percent,r=1,a="percent";!1===this.isRelativeLabel&&(s=t.decimal,e=t.decimal,r=i.value,a="decimal"),n=ra.number(Number(this.value),a,s,e,r,this.styles.locale),Number(this.value)<0&&(h="end"),this.isVarianceLabel&&Number(this.value)>=0&&(o="+")}else n=""+this.value,h="start";const a=e.text(o+n);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===Sl.Right?(h="end",a.move(a.x()-a.length(),a.y())):this.horizontalHookLocation===Sl.Center&&(h="middle",a.move(a.x()-a.length()/2,a.y())),this.verticalHookLocation===Sl.Center?a.move(a.x(),a.y()-u/2):this.verticalHookLocation===Sl.Bottom&&a.move(a.x(),a.y()-u),a.font({anchor:h}),null!=this.segmentFillColor?a.fill(ia(this.segmentFillColor)):null==e||e.rect(c,.9*u).stroke(r).fill(r).opacity(.7).move(a.x(),a.y()+.1*u).insertBefore(a),this.pointKey&&(null==e||e.attr(ji(this.pointKey,this.pointPart))),this)}isEmpty(){return null==this.value||""===this.value}setPos(t,i){return this.x=t,this.y=i,this}}let Ml=class{constructor(t,i,s,e){this.height=0,this.ID_AXIS="axis",this.ID_AXIS_TITLE="axis-title",this.CSS_AXIS_TITLE="categories",this.scenarioType=t.scenarioType,this.labelText=t.labelText||null,this.position=i,this.style=e,this.label=new $l(s,this.position.getAxisTitlePositionX(),this.position.getAxisTitlePositionY(),this.ID_AXIS_TITLE,this.labelText,this.style,Sl.Bottom,Sl.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 _l{constructor(t,i,s,e,n,r,o,h=null){if(this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.scenarioLabel=null,this.barGroup=null,this.isVarianceBar=!1,this.overflowConfig=null,this.isOverflowing=!1,this.overdriveWidth=0,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=e,this.isPrimaryBar=n,this.position=t,this.barStyles=i.barStyles,this.overflowConfig=h,this.scenarioGroup=r,this.styles=i,null!=r&&(this.barGroup=r.group().id(r.toString()+"_"+this.ID_RECT)),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value){this.hasData=!0;let i=Sl.Left;s.value<0&&(i=Sl.Right),this.dimensions=this.createDimensions(t,s,e,n),this.label=new $l(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,s.value,this.styles,Sl.Center,i).setPoint(s.key),this.scenarioLabel=this.getScenarioLabel(o)}}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 la){var s,e;if(this.isEmpty()||null==this.dataPoint.getScenario())return this;let n=this.barStyles.getSVGStyle(this.dataPoint.getScenario());this.isVarianceBar&&(n=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()));const r=this.convertToSVGStyle(n,"stroke");let o=this.convertToSVGStyle(n,"fill");const h=this.barStyles.getSVGStyle(this.dataPoint.getScenario()).fillpattern;if(null!=h){const t=this.styles.pattern.get(h);null!=t&&(o=t.pattern)}null===(s=this.scenarioGroup)||void 0===s||s.attr(ji(this.dataPoint.key)),null===(e=this.barGroup)||void 0===e||e.attr(ji(this.dataPoint.key,"element")),null!=this.barGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(o,r):this.barGroup.rect(this.dimensions.barLength,this.position.getBarWidth()).fill(o).stroke(r).cy(this.dimensions.yPos).x(this.dimensions.xPos)),this.drawBarDataLabel(t,i),this.drawScenarioLabel()}drawOverdriveBar(t,i){if(!this.barGroup||!this.overflowConfig)return;const s=this.position.getBarPositionX(),e=this.position.getBarWidth(),n=this.dimensions.barLength,{breakGap:r}=this.overflowConfig;this.dataPoint.getScaledUnit()<0?(this.barGroup.rect(n,e).fill(t).stroke(i).x(s-n).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,e).fill(t).stroke(i).x(s-n-r-this.overdriveWidth).cy(this.dimensions.yPos),this.drawBreakIndicator(s-n-r,r)):(this.barGroup.rect(n,e).fill(t).stroke(i).x(s).cy(this.dimensions.yPos),this.barGroup.rect(this.overdriveWidth,e).fill(t).stroke(i).x(s+n+r).cy(this.dimensions.yPos),this.drawBreakIndicator(s+n,r))}drawBreakIndicator(t,i){if(!this.barGroup)return;const s=this.position.getBarWidth(),e=this.dimensions.yPos-s/2,n=t+i/2,r=.35*i,o=s/3;let h=`M ${n-r} ${e}`;for(let t=0;t<3;t++)h+=` L ${n-r-.3*i} ${e+o*(t+.5)} L ${n-r} ${e+o*(t+1)}`;let a=`M ${n+r} ${e}`;for(let t=0;t<3;t++)a+=` L ${n+r+.3*i} ${e+o*(t+.5)} L ${n+r} ${e+o*(t+1)}`;this.barGroup.rect(i,s+2).fill("#ffffff").stroke("none").x(t).cy(this.dimensions.yPos),this.barGroup.path(h).fill("none").stroke({color:"#000000",width:1}),this.barGroup.path(a).fill("none").stroke({color:"#000000",width:1})}createDimensions(t,i,s,e){const n=i.getScaledUnit(),r=Math.abs(n);if(this.overflowConfig&&r>0){const o="ac"===i.getScenario()?this.overflowConfig.cutWidth:this.overflowConfig.cutWidth-this.overflowConfig.scenarioCutOffset;if(r>o){this.isOverflowing=!0;const{breakGap:i,overdriveZoneWidth:h,maxOverflow:a}=this.overflowConfig;this.overdriveWidth=a>0?(r-o)/a*h:0;const l=o+i+this.overdriveWidth;return n<0?{clipped:!1,barLength:o,xPos:t.getBarPositionX()-o,yPos:t.getBarPositionY(s,e),labelXPos:t.getLabelPositionX(-l),scenarioLabelXPos:t.getBarPositionX()-.5*o,scenarioLabelYPos:t.getBarPositionY(s,e)+t.getScenarioLabelPositionOffsetY(e)}:{clipped:!1,barLength:o,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,e),labelXPos:t.getLabelPositionX(l),scenarioLabelXPos:t.getBarPositionX()+.5*o,scenarioLabelYPos:t.getBarPositionY(s,e)+t.getScenarioLabelPositionOffsetY(e)}}}return n<0?{clipped:!1,barLength:r,xPos:t.getBarPositionX()+n,yPos:t.getBarPositionY(s,e),labelXPos:this.position.getLabelPositionX(n),scenarioLabelXPos:this.position.getBarPositionX()-.5*r,scenarioLabelYPos:this.position.getBarPositionY(s,e)+this.position.getScenarioLabelPositionOffsetY(e)}:{clipped:!1,barLength:n,xPos:t.getBarPositionX(),yPos:t.getBarPositionY(s,e),labelXPos:this.position.getLabelPositionX(n),scenarioLabelXPos:this.position.getBarPositionX()+.5*r,scenarioLabelYPos:this.position.getBarPositionY(s,e)+this.position.getScenarioLabelPositionOffsetY(e)}}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.isVarianceBar||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw()}drawBarDataLabel(t,i=new la){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 $l(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,this.isPrimaryBar?Sl.Top:Sl.Bottom,Sl.Center)}}let Ol=class{constructor(t,i,s,e,n,r,o,h,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=n,this.barStyles=n?n.barStyles:null,this.scenario=e,!0!==(null==r?void 0:r.isEmpty())&&(this.hasData=!0,this.pointKey=r.key,this.dimensions=this.createMarkerDimensions(r,o,a),this.scenarioLabel=this.getScenarioLabel(h,n,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 $l(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,s?Sl.Bottom:Sl.Top,Sl.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(ji(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(ji(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)}},kl=class{constructor(t,i,s,e,n){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.dimensions={barLength:0,xPos:0,yPos:0,labelXPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=e,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=n,this.styles=i,this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT);const r=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||r){this.hasData=!0,this.dimensions=this.createDimensions(t,s,e);let i=Sl.Left;s.value<0&&(i=Sl.Right),this.label=new $l(this.scenarioGroup,this.dimensions.labelXPos,this.dimensions.yPos,this.ID_DATA_PREFIX,r?it:s.value,this.styles,Sl.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(ji(this.dataPoint.key)),this.barGroup.attr(ji(this.dataPoint.key,"element"));const e=this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()),n=e.stroke;let r=e.fill;const o=this.barStyles[this.dataPoint.getScenario()];if(null!=o&&o.fillpattern){const t=this.styles.pattern.get(o.fillpattern);null!=t&&null!=t.pattern&&(r=t.pattern)}this.drawNeedleHead(r,n),this.barGroup.rect(this.dimensions.barLength,this.position.getNeedleWidth()).fill(r).stroke(n).cy(this.dimensions.yPos).x(this.dimensions.xPos),null===(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,e=this.styles.varianceStyles.needleHeadColour;if(this.dimensions.clipped){let s="13,0 4,-5 4,5 13,0 8,0 0,-5 0,5 8,0";null!=this.dataPoint.value&&this.dataPoint.value<0&&(s="0,0 9,-5 9,5 0,0 5,0 13,-5 13,5 5,0"),this.barGroup.polygon(s).fill(t).cx(this.getHeadXPosition()).cy(this.dimensions.yPos).fill(t).stroke(i)}else this.barGroup.rect(2*this.position.getNeedleWidth(),2*this.position.getNeedleWidth()).cx(this.getHeadXPosition()).cy(this.dimensions.yPos).fill(s).stroke(e)}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getHeadXPosition(){let t=this.dimensions.xPos;return null!=this.dataPoint.value&&this.dataPoint.value>0&&(t+=this.dimensions.barLength),t}};class Al{constructor(t,i,s,e,n,r,o,h,a,l,c){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=e,this.segment=n,this.segmentIndex=o,this.stackMode=h,this.stack=a,this.group=c,this.barGroup=c.group().id(`stacked_bar_${e}_seg_${o}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new la){if(!this.hasData||!Number.isFinite(this.dataPoint.value))return;const s=this.dataPoint.value,e=this.dataPoint.pixelPerUnit,n=this.position.getBarPositionX(),r=this.position.getBarWidth(),o=Math.abs(this.segment.end-this.segment.start)*e,h=n+Math.min(this.segment.start,this.segment.end)*e,a=this.position.getBarPositionY(this.index,!0),l=this.styles.stackColors,c=l[this.segmentIndex%l.length],u={color:c},d={color:c,width:.5};this.barGroup.attr(ji(this.dataPoint.key,"element")),this.barGroup.rect(Math.max(o,.5),r).fill(u).stroke(d).cy(a).x(h);const f=o-6;if(f>0){const e=h+o/2;if(this.stackMode===Q.RELATIVE||this.stackMode===Q.ABSOLUTE_RELATIVE){const i=ra.number(this.segment.share,"percent",t.percent,t.percent,1,this.styles.locale);new $l(this.group,e,a,"STACK_SEG",i,this.styles,Sl.Center,Sl.Center).setSegmentFill(c).setMaxWidth(f).setPoint(this.dataPoint.key).draw()}else new $l(this.group,e,a,"STACK_SEG",s,this.styles,Sl.Center,Sl.Center).setSegmentFill(c).setMaxWidth(f).setPoint(this.dataPoint.key).draw(t,i)}}drawTotalLabel(t={percent:2,decimal:1},i=new la,s){if(this.stackMode===Q.RELATIVE)return;const e=this.stack.total<0,n=this.position.getLabelPositionX((e?0-this.stack.negative:this.stack.positive)*this.dataPoint.pixelPerUnit),r=this.position.getBarPositionY(this.index,!0);new $l(this.group,n,r,"STACK_TOTAL",this.stack.total,this.styles,Sl.Center,e?Sl.Right:Sl.Left).setPoint(s,"total").draw(t,i)}}let Rl=class{constructor(t,i,s,e,n){this.overflowConfig=null,this.i18n=n;const r=i.group().id("Scenario1"),o=i.group().id("Scenario2").insertBefore(r);this.svgGroups={parent:i,scenario1:r,scenario2:o,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=e}setOverflowConfig(t){this.overflowConfig=t}isLastDataPoint(t){return this.elementCnt-1===t}isFirsttDataPoint(t){return 0===t}createPrimaryBar(t,i){var s,e,n,r;const o=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===e?void 0:e.group().id(""+i),h=null===(r=null===(n=this.svgGroups)||void 0===n?void 0:n.scenario1Label)||void 0===r?void 0:r.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new _l(this.position,this.styles,t,i,!0,o,a,this.overflowConfig).updateLabelGroup(h)}createVarianceBar(t,i){var s,e,n,r;const o=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===e?void 0:e.group().id(""+i),h=null===(r=null===(n=this.svgGroups)||void 0===n?void 0:n.scenario1Label)||void 0===r?void 0:r.group().id(""+i);let a=null;return this.isLastDataPoint(i)&&(a=`${this.i18n.get(t.scenario)||t.scenario}`),new _l(this.position,this.styles,t,i,!0,o,a,this.overflowConfig).updateLabelGroup(h).setAsVariance()}createRelativeVarianceBar(t,i){var s,e,n,r;const o=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario1)||void 0===e?void 0:e.group().id(""+i),h=null===(r=null===(n=this.svgGroups)||void 0===n?void 0:n.scenario1Label)||void 0===r?void 0:r.group().id(""+i);return new kl(this.position,this.styles,t,i,o).updateLabelGroup(h)}createSecondaryBar(t,i){var s,e;const n=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario2)||void 0===e?void 0:e.group().id(""+i);let r=null;return this.isFirsttDataPoint(i)&&(r=`${this.i18n.get(t.scenario)||t.scenario}`),new _l(this.position,this.styles,t,i,!1,n,r,this.overflowConfig)}createPrimaryMarker(t,i){var s,e;const n=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario3)||void 0===e?void 0:e.group().id(""+i),r=this.styles.pattern.get("marker-down")||{foreground:"0,0 1,0 1,1 0,1",background:"0,0 1,0 1,1 0,1",bgOffset:0};let o=null;return this.isFirstDataPoint(i)&&(o=`${this.i18n.get(t.scenario)||t.scenario}`),new Ol(this.position,n,r,t.scenario,this.styles,t,i,o,!0)}createSecondaryMarker(t,i){var s,e;const n=null===(e=null===(s=this.svgGroups)||void 0===s?void 0:s.scenario4)||void 0===e?void 0:e.group().id(""+i),r=this.styles.pattern.get("marker-up")||{foreground:"0,0 1,0 1,1 0,1",background:"0,0 1,0 1,1 0,1",bgOffset:0};let o=null;return this.isLastDataPoint(i)&&(o=`${this.i18n.get(t.scenario)||t.scenario}`),new Ol(this.position,n,r,t.scenario,this.styles,t,i,o,!1)}isFirstDataPoint(t){return 0===t}};const Nl=.001;function Ll(t){return null!=t.fixedDomain?Math.max(0,t.fixedDomain):t.relativeVariance?0:Math.max(0,t.maxPositive)+Math.abs(Math.min(0,t.minNegative))}function El(t){var i;if(!t.relativeVariance)return 0;const s=null!==(i=t.sideClamp)&&void 0!==i?i:1.45;return Math.min(s,Math.max(0,t.maxPositive))+Math.min(s,Math.abs(Math.min(0,t.minNegative)))}function Tl(t){const i=t.unitExtent+t.pctExtent;if(i<=0)return{};const s=Math.max(Nl,(t.target-(t.measured-t.unitExtent*t.currentPpu-t.pctExtent*t.currentPpp))/i);return{ppu:t.unitExtent>0?s:void 0,ppp:t.pctExtent>0?s:void 0}}function Cl(t,i=0){let s=0,e=0,n=0;const r=t.map((t=>{const i=Number.isFinite(t)?t:0;if(n+=i,i<0||Object.is(i,-0)){const t=0-e;return e-=i,{value:i,start:t,end:0-e}}const r=s;return s+=i,{value:i,start:r,end:s}})),o=s+e;let h=1;return i>0&&(h=o>0?i/o:0),{segments:r.map((t=>({start:t.start*h,end:t.end*h,share:o>0?t.value/o:0}))),positive:s*h,negative:e*h,total:n}}function Pl(t){const i={positive:0,negative:0,maxTotal:0,minTotal:0};for(const s of t)i.positive=Math.max(i.positive,s.positive),i.negative=Math.max(i.negative,s.negative),i.maxTotal=Math.max(i.maxTotal,s.total),i.minTotal=Math.min(i.minTotal,s.total);return i}function Wl(t,i=()=>0){const s=t[t.length-1],e=null!=s&&s.total<0,n=t.map((t=>(e?t.positive:t.negative)+((e?t.total>=0:t.total<0)?i(t):0)));return{flipped:e,clearance:Math.max(0,...n)}}class Dl{constructor(t,i,s,e,n){this.dataModel=[],this.variancesDataModel=[],this.title="",this.configTitle="",this.configVariances=[],this.smallestDataPointValue=new fl(0,wl.AC1,1,wl.NEU),this.highestDataPointValue=new fl(0,wl.AC1,1,wl.NEU),this.smallestVarianceDataPointValue=new fl(0,wl.AC1,1,wl.NEU),this.highestVarianceDataPointValue=new fl(0,wl.AC1,1,wl.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.level=G.CATEGORY,this.hideCategories=!1,this.axisScenario=wl.AC1,this.CSS_CATEGORIES="categories",this.state=ol.DIRTY,this.titleLength=0,this.leftSideOffsetForHorizontalSync=0,this.limit=0,this.measureScale=new la,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.stackConfig=null,this.scenarioPropOrder=[],this.overflowConfig=null,this.stackSides=Pl([]),this.stackLabelClearance={left:0,right:0},this.fromExpr="",this.rowCount=0,this.db=i,this.tableName=s,this.ruleSet=t||new Cs,this.i18n=this.createI18n(new Map),this.styles=n,this.setConfig(e),this.position=this.createElementPosition()}updatePosition(){this.position=this.createElementPosition()}createElementPosition(){this.titleLength=this.calculateTitleLength(0);let t=this.calculateLeftSideWidth(this.getVarianceType());const i=this.calculateCategoryWidth();return this.titleLength>t&&(t=this.titleLength),new sl(new el(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 Cs}setConfig(t){var i,s;this.state=ol.DIRTY,this.scenarioPropOrder=[...t.scenarios];const e=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(e,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({},Bi(this.level,t.category)),{scenario:null!==(i=s.scenario)&&void 0!==i?i:void 0}));t.stackConfig&&t.stackConfig.by!==q.SCENARIOS&&this.populateDimensionStackSegments(e,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||ra.translateScenarioLabel(null===(t=this.configVariances)||void 0===t?void 0:t.toString(),this.i18n)}createI18n(t){this.state=ol.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=ol.DIRTY,this.queryError=void 0,this.fromExpr=$(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=ci(t))}getUnitBarExtent(){var t,i;const s=this.isStacked(),e=this.getVarianceType(),n=e!==hl.NONE,r=n?this.highestVarianceDataPointValue:this.highestDataPointValue,o=n?this.smallestVarianceDataPointValue:this.smallestDataPointValue;return Ll({fixedDomain:s?this.stackSides.positive+this.stackSides.negative:void 0,relativeVariance:e===hl.RELATIVE,maxPositive:null!==(t=null==r?void 0:r.value)&&void 0!==t?t:0,minNegative:null!==(i=null==o?void 0:o.value)&&void 0!==i?i:0})}getPercentBarExtent(){var t,i,s,e;return El({relativeVariance:this.getVarianceType()===hl.RELATIVE,maxPositive:null!==(i=null===(t=this.highestVarianceDataPointValue)||void 0===t?void 0:t.value)&&void 0!==i?i:0,minNegative:null!==(e=null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&void 0!==e?e:0})}getAllocatedCanvasWidth(){const t=this.position.getAxisPositionX(),i=this.calculateRightSideWidth(this.getVarianceType());let s=t+i+ +this.styles.padding.left+this.styles.padding.right;return i<this.titleLength/2&&(s+=this.titleLength/2),t<this.titleLength/2&&(s+=this.titleLength/2),s}getAllocatedCanvasHeight(){return this.position.getAxisEndPositionY()+this.position.spacings.labelToAxis+this.position.fontSize+this.styles.padding.bottom}patternToString(){return"<svg></svg>"}layout(){this.draw(new uh)}toString(){const t=new uh;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===ol.DIRTY&&(this.state=ol.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=Qh(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?" ":ra.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}scenarioStyles(){const t=Es(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=wl.AC1;if(null!=t&&t.length>0){const s=new ks(t.toString());s.isValid&&(i=Ls(this.ruleSet.getScenarioColorIndex(s.delta))+s.delta.slice(2))}return null===i&&(i=wl.AC1),i}populateModel(t,i,s){if(0===this.rowCount||!this.fromExpr)return[];const e=[],n=this.createOrderStr(i,s),r=this.createSelectString(i,s),o=this.createGroupByStr(i,s);let h;try{h=this.db.exec(`SELECT ${r} ${t.length>0?","+t.map((t=>`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`)).join(","):""}\n FROM ${this.fromExpr}\n GROUP BY ${o}\n ORDER BY ${n}`)}catch(t){return this.failQuery(t),[]}return this.detectNaNCells(t,h),this.createDataRows(this.limit>0?h.slice(0,this.limit):h,e,t),this.crateRESTRow(h,t,e),e}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new ks(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 e=[];this.createDataRows(t.slice(this.limit),e,i);const n=(t,i)=>Number.isFinite(i)?(Number.isFinite(t)?t:0)+i:t,r=e.reduce((function(t,s){return{id:t.id,category:t.category,type:t.type,scenario1:new fl(n(t.scenario1.value,s.scenario1.value),i[0],t.scenario1.pixelPerUnit,wl.NEU),scenario2:new fl(n(t.scenario2.value,s.scenario2.value),i[1],t.scenario2.pixelPerUnit,wl.NEU),scenario3:new fl(n(t.scenario3.value,s.scenario3.value),i[2],t.scenario3.pixelPerUnit,wl.NEU),scenario4:new fl(n(t.scenario4.value,s.scenario4.value),i[3],t.scenario4.pixelPerUnit,wl.NEU)}}),{id:9999,category:"REST",type:hl.NONE,scenario1:new fl(NaN,i[0],this.pixelPerUnit,wl.NEU),scenario2:new fl(NaN,i[1],this.pixelPerUnit,wl.NEU),scenario3:new fl(NaN,i[2],this.pixelPerUnit,wl.NEU),scenario4:new fl(NaN,i[3],this.pixelPerUnit,wl.NEU)});s.push(r)}createDataRows(t,i,s){t.forEach(((t,e)=>{i.push({id:e,category:t.category,type:hl.NONE,scenario1:new fl(t[s[0]],s[0],this.pixelPerUnit,wl.NEU),scenario2:new fl(t[s[1]],s[1],this.pixelPerUnit,wl.NEU),scenario3:new fl(t[s[2]],s[2],this.pixelPerUnit,wl.NEU),scenario4:new fl(t[s[3]],s[3],this.pixelPerUnit,wl.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===G.CATEGORY&&i.hierarchy.includes(Y.CATEGORYINDEX)?`${Y.CATEGORYINDEX}, ${G.CATEGORY} as category`:t===G.ROWGROUP&&i.hierarchy.includes(Y.ROWGROUPINDEX)?`${Y.ROWGROUPINDEX}, ${G.ROWGROUP} as category`:t===G.SUBCATEGORY&&i.hierarchy.includes(Y.SUBCATEGORYINDEX)?`${Y.SUBCATEGORYINDEX}, ${G.SUBCATEGORY} as category`:`${t.toString()} as category`}createGroupByStr(t,i){return t===G.CATEGORY&&i.hierarchy.includes(Y.CATEGORYINDEX)?`${Y.CATEGORYINDEX}, ${G.CATEGORY}`:t===G.ROWGROUP&&i.hierarchy.includes(Y.ROWGROUPINDEX)?`${Y.ROWGROUPINDEX}, ${G.ROWGROUP}`:t===G.SUBCATEGORY&&i.hierarchy.includes(Y.SUBCATEGORYINDEX)?`${Y.SUBCATEGORYINDEX}, ${G.SUBCATEGORY}`:`${t.toString()}`}calculateCategoryWidth(){if(this.hideCategories)return 5;let t=0;for(const i of this.dataModel){const s=Qh(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 fl(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 fl(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===q.SCENARIOS;let s=[];for(const e of i?["scenario1","scenario2","scenario3","scenario4"]:["scenario1"]){const i=t[e];i&&!i.isEmpty()&&null!=i.value&&s.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0===s.length)return[];const e=this.stackConfig.mode===Q.RELATIVE?1:0,n=(t,i)=>({prefix:t,segments:i,layout:Cl(i.map((t=>t.value)),e),hasValue:i.some((t=>Number.isFinite(t.value)))});if(i){this.sortSegmentsByPropOrder(s);const t=new Map;for(const i of s){const s=ta(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}if(t.size>1){const i=[];for(const s of Zh)t.has(s)&&(i.push(n(s,t.get(s))),t.delete(s));for(const[s,e]of t)i.push(n(s,e));return i}}else t.stackSegments&&t.stackSegments.length>0&&(s=t.stackSegments.map((t=>({value:t.value,scenario:t.label,dataPoint:t.dataPoint}))));const r=t=>Number.isFinite(t.value)?t.value:0;return"asc"===this.stackConfig.order?s.sort(((t,i)=>r(t)-r(i))):"desc"===this.stackConfig.order&&s.sort(((t,i)=>r(i)-r(t))),[n("",s)]}measureStacks(){const t=[];this.stackLabelClearance={left:0,right:0};for(const i of this.dataModel){const{flipped:s,clearance:e}=this.stackLabelPlace(i),n=this.drawnStackLayouts(i),r=s?"right":"left";this.stackLabelClearance[r]=Math.max(this.stackLabelClearance[r],e),t.push(...n)}this.stackSides=Pl(t)}stackLabelPlace(t){const i=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;return Wl(this.drawnStackLayouts(t),(t=>{var s;return(null===(s=this.stackConfig)||void 0===s?void 0:s.mode)===Q.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 Qh(ra.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 e=null;null!=i&&i.length>0&&(e=i[0]);for(const n in t){const r=new ks(t[n]);if(r.isValid){const o=this.mapScenarios(r,e),h=r.direction;let a=this.pixelPerUnit;"dr"===r.type&&(a=this.pixelPerPercentage);for(const e in i){const l=new fl(this.calculateVariance(r,i[e],o),r.base,a,h);null===l.value||Number.isNaN(l.value)||(l.key=Object.assign(Object.assign({},Bi(this.level,i[e].category)),{scenario:t[n]})),s.push({id:Number(e),category:i[e].category,type:"dr"===r.type?hl.RELATIVE:hl.ABSOLUTE,scenario1:l,scenario2:new fl(null,null,null,null),scenario3:new fl(null,null,null,null),scenario4:new fl(null,null,null,null)})}}}return s}calculateVariance(t,i,s){const e=s.get(t.base),n=s.get(t.delta);return null==e||null==n?null:t.type===hl.RELATIVE?st(i[e].value-i[n].value,i[n].value):i[e].value-i[n].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((e=>{i[e].scenario===t.delta?s.set(t.delta,e):i[e].scenario===t.base&&s.set(t.base,e)})),s}calculateTextBoxWidth(t){return Qh(ra.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;return t>=0&&(i+=Qh("+",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width),i+=Qh(" %",{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,Qh(ra.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 e=i.group().id("AxisAndDateLables");let n=!1;this.hideCategories||t.forEach(((t,i)=>{t.type===hl.RELATIVE&&(n=!0);let r=Sl.Right,o=!0,h=0;if(s){const i=this.stackLabelPlace(t);o=!i.flipped,h=i.clearance*this.pixelPerUnit*(i.flipped?1:-1)}else t.scenario1.value<0&&(o=!1);o||(r=Sl.Left),new $l(e,this.position.getCategoryPositionX(o)+h,this.position.getBarCenterPositionY(i),"",this.i18n.get(t.category)||t.category,this.styles,Sl.Center,r).draw()})),new Ml({scenarioType:this.axisScenario,labelText:this.title,isRelative:n},this.position,e,this.styles).draw()}drawScenarios(t,i){const s=i.group().id("Scenarios"),e=new Rl(this.position,s,this.scenarioStyles(),t.length,this.i18n);e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{e.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),e.createSecondaryBar(t.scenario2,i).draw(),e.createPrimaryMarker(t.scenario3,i).draw(),e.createSecondaryMarker(t.scenario4,i).draw()}))}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),e=new Rl(this.position,s,this.scenarioStyles(),t.length,this.i18n);return e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.type===hl.RELATIVE?e.createRelativeVarianceBar(t.scenario1,i).draw():e.createVarianceBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale)})),s}sortSegmentsByPropOrder(t){if(0===this.scenarioPropOrder.length)return;const i=this.scenarioPropOrder;t.sort(((t,s)=>{const e=i.indexOf(t.scenario),n=i.indexOf(s.scenario);return(-1===e?i.length:e)-(-1===n?i.length:n)}))}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),e=this.stackConfig.by===q.SCENARIOS;t.forEach(((t,i)=>{const n=this.stackGroups(t);n.forEach(((r,o)=>{let h=null;r.segments.forEach(((t,a)=>{const l=new Al(this.position,this.styles,t.dataPoint,i,r.layout.segments[a],t.scenario,n.length>1?n.length-1-o:a,this.stackConfig.mode,r.layout,e,s);l.draw(this.dataFormatDigits,this.measureScale),h=l})),h&&r.hasValue&&h.drawTotalLabel(this.dataFormatDigits,this.measureScale,Object.assign(Object.assign({},Bi(this.level,t.category)),{scenario:n.length>1?r.prefix:void 0}))}))}))}drawStackedHeaders(t,i){if(!this.stackConfig||0===t.length)return;const s=t[0];if(this.stackConfig.by!==q.SCENARIOS&&(!s.stackSegments||0===s.stackSegments.length))return;const e=this.stackGroups(s);if(0===e.length)return;const n=i.group().id("StackedHeaders"),r=this.position.getBarPositionX(),o=this.position.getStackedHeaderPositionY(),h=(t,i)=>{new $l(n,t,o,"STACK_HEADER",i,this.styles,Sl.Bottom,Sl.Center).draw()};if(e.length>1)return void e.forEach((t=>{h(r+(t.layout.positive-t.layout.negative)/2*t.segments[0].dataPoint.pixelPerUnit,this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase())}));const[a]=e;a.segments.forEach(((t,i)=>{const{start:s,end:e}=a.layout.segments[i];h(r+(s+e)/2*t.dataPoint.pixelPerUnit,this.i18n.get(t.scenario)||t.scenario)}))}getVarianceType(){return this.variancesDataModel.length>0?this.variancesDataModel[0].type:hl.NONE}calculateLeftSideWidth(t){var i,s,e;let n=0;const r=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(hl.NONE===t&&this.isStacked())this.stackSides.negative>0&&(n=this.stackSides.negative*this.pixelPerUnit,this.stackSides.minTotal<0&&(n+=r+this.calculateTotalLabelWidth(this.stackSides.minTotal))),this.stackLabelClearance.left>0&&(n=Math.max(n,this.stackLabelClearance.left*this.pixelPerUnit+this.calculateCategoryWidth()));else if(hl.NONE===t&&null!=(null===(i=this.smallestDataPointValue)||void 0===i?void 0:i.value)&&this.smallestDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestDataPointValue.value);n=Math.abs(this.smallestDataPointValue.getScaledUnit())+r+t}else if(hl.RELATIVE===t&&null!=(null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculatePercentageTextBoxWidth(this.smallestVarianceDataPointValue.value);n=Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit())+r+t}else if(hl.ABSOLUTE===t&&null!=(null===(e=this.smallestVarianceDataPointValue)||void 0===e?void 0:e.value)&&this.smallestVarianceDataPointValue.value<0){const t=this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value);n=Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())+r+t}return n<=this.titleLength?this.titleLength:n}calculateRightSideWidth(t){var i,s,e;if(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 n=0;const r=this.styles.fontStyles.size*this.styles.scaleFactors.labelToBar;if(hl.NONE===t&&null!=(null===(i=this.highestDataPointValue)||void 0===i?void 0:i.value)&&this.highestDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestDataPointValue.value);n=Math.abs(this.highestDataPointValue.getScaledUnit())+r+t}else if(hl.RELATIVE===t&&null!=(null===(s=this.highestVarianceDataPointValue)||void 0===s?void 0:s.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculatePercentageTextBoxWidth(this.highestVarianceDataPointValue.value);n=Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit())+r+t}else if(hl.ABSOLUTE===t&&null!=(null===(e=this.highestVarianceDataPointValue)||void 0===e?void 0:e.value)&&this.highestVarianceDataPointValue.value>=0){const t=this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value);n=Math.abs(this.highestVarianceDataPointValue.getScaledUnit())+r+t}return n<=this.titleLength?this.titleLength:n}populateDimensionStackSegments(t,i,s){if(0===this.rowCount||!this.fromExpr||0===t.length)return;const e={[G.ROWGROUP]:"category",[G.ROWGROUPINDEX]:"category",[G.CATEGORY]:"subCategory",[G.CATEGORYINDEX]:"subCategory"}[s];if(!e)return;const n=s.toString(),r=t[0];let o;try{o=this.db.exec(`SELECT [${n}] as displayGroup, [${e}] as stackLabel, SUM([${r}] * transformOperator(operation)) as stackValue FROM ${this.fromExpr} GROUP BY [${n}], [${e}]`)}catch(t){return void this.failQuery(t)}const h=new Map;for(const t of o){const i=t.displayGroup;h.has(i)||h.set(i,[]),null!=t.stackValue&&null!=t.stackLabel&&h.get(i).push({label:t.stackLabel,value:t.stackValue})}for(const t of this.dataModel){const i=h.get(t.category);t.stackSegments=i&&i.length>0?i.map((i=>{const s=new fl(i.value,r,this.pixelPerUnit,wl.NEU);return s.key=Object.assign(Object.assign({},Bi(this.level,t.category)),{[e]:i.label,scenario:r}),{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,e=t+i+s;this.variancesDataModel&&this.variancesDataModel.length>0?(this.highestVarianceDataPointValue.getScaledUnit()>t&&(this.highestVarianceDataPointValue=new fl(e,this.highestVarianceDataPointValue.scenario,1,this.highestVarianceDataPointValue.variance)),null!=this.smallestVarianceDataPointValue.value&&Math.abs(this.smallestVarianceDataPointValue.getScaledUnit())>t&&(this.smallestVarianceDataPointValue=new fl(-e,this.smallestVarianceDataPointValue.scenario,1,this.smallestVarianceDataPointValue.variance))):(this.highestDataPointValue.getScaledUnit()>t&&(this.highestDataPointValue=new fl(e,this.highestDataPointValue.scenario,1,this.highestDataPointValue.variance)),null!=this.smallestDataPointValue.value&&Math.abs(this.smallestDataPointValue.getScaledUnit())>t&&(this.smallestDataPointValue=new fl(-e,this.smallestDataPointValue.scenario,1,this.smallestDataPointValue.variance))),this.updatePosition()}}else this.overflowConfig=null}calculateOverflowConfig(t){const i=this.variancesDataModel&&this.variancesDataModel.length>0;if(this.getVarianceType()===hl.RELATIVE)return null;const s=i?this.highestVarianceDataPointValue:this.highestDataPointValue,e=i?this.smallestVarianceDataPointValue:this.smallestDataPointValue,n=s.getScaledUnit(),r=null!=e.value?Math.abs(e.getScaledUnit()):0,o=Math.max(n,r);if(o<=0)return null;const h=this.styles.fontStyles.size,a=h*this.styles.scaleFactors.labelToBar,l=1.5*h,c=.3*h,u=.8*h,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 o<=f?null:{cutWidth:d,overdriveZoneWidth:l,breakGap:c,maxOverflow:o-f,scenarioCutOffset:u}}}class zl{constructor(t=2,i=1){this.percent=t,this.decimal=i}}class Ul{adapt(t){const i=new zl;return R.isNumber(t.percent)&&(i.percent=t.percent),R.isNumber(t.decimal)&&(i.decimal=t.decimal),i}default(){return new zl}}const Fl=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.chartTitle="",this.scenarios=[],this.variances=[],this.hideCategories=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.limit=0,this.i18n=new Map,this.order={hierarchy:[],direction:j.ASC},this.level=G.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},a(this)}getDb(){return this.stores||(this.stores=c(this.element)),this.stores.db.db}render(){var t,e,n,r;if(void 0===this.chart||void 0!==this.queryError)return i(s,null);if(this.chart.hasNoData()){const e=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return i(s,{class:"no-data"},i("div",{class:"empty-state"},e))}return i(s,null,i("div",{innerHTML:null===(e=this.pattern)||void 0===e?void 0:e.toString(),class:"hidePatternContainer",style:{width:"0",height:"0",overflow:"hidden"}}),i("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(n=this.chart)||void 0===n?void 0:n.getFooter()),i("div",{innerHTML:null===(r=this.chart)||void 0===r?void 0:r.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(),ui(this.errors,this.queryError)}async componentWillLoad(){var t;const i=this.getDb(),s=this.prepareConfig(),e=this.prepareStyle();this.chart=new Dl(new Cs(this.ruleSetConfig),i,this.tableName,s,e),this.chart.setI18n(this.i18n);const n=s.pixelPerUnit<=0;this.autoFitScaling(s,e),this.chart.setAvailableWidth(n?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new rl(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 Cs(this.ruleSetConfig)),this.chart.setConfig(i);const e=i.pixelPerUnit<=0;this.autoFitScaling(i,s),this.chart.setAvailableWidth(e?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.width)||0),this.pattern=new rl(this.chart.styles),this.chart.setPattern("hatched",this.pattern.getFCPolygonPattern()),this.syncQueryError()}autoFitScaling(t,i){var s;const e=t.pixelPerUnit<=0,n=t.pixelPerPercentage<=0;if(!e&&!n)return;const r=()=>{var i;null===(i=this.reportAutoScaling)||void 0===i||i.call(this,{unit:e?t.pixelPerUnit:void 0,percentage:n?t.pixelPerPercentage:void 0})},o=null===(s=this.parentDimensions)||void 0===s?void 0:s.width,h=this.getDb(),a=()=>{this.chart=new Dl(new Cs(this.ruleSetConfig),h,this.tableName,t,i),this.chart.setI18n(this.i18n)},l=()=>(this.chart.layout(),this.chart.getAllocatedCanvasWidth());if(!o||o<=0)return e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=50),a(),void r();e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=1),a();let c=l();if(c<=0)return void r();const u=Math.max(Nl,.9*o/c);let d=!1,f=!1,v=null;for(let i=0;i<=3;i++){const i=Tl({target:o,measured:c,unitExtent:e?this.chart.getUnitBarExtent():0,pctExtent:n?this.chart.getPercentBarExtent():0,currentPpu:t.pixelPerUnit,currentPpp:t.pixelPerPercentage});if(void 0===i.ppu&&void 0===i.ppp)break;if(e&&void 0!==i.ppu&&(t.pixelPerUnit=i.ppu,d=!0),n&&void 0!==i.ppp&&(t.pixelPerPercentage=i.ppp,f=!0),a(),c=l(),c<=o+.5&&(v={ppu:t.pixelPerUnit,ppp:t.pixelPerPercentage},c>=.98*o))break}let p=!1;if(e&&!d&&(t.pixelPerUnit=u,p=!0),n&&!f&&(t.pixelPerPercentage=u,p=!0),c>o+.5){if(v)d&&(t.pixelPerUnit=v.ppu),f&&(t.pixelPerPercentage=v.ppp);else{const i=o/c;e&&(t.pixelPerUnit=Math.max(Nl,t.pixelPerUnit*i)),n&&(t.pixelPerPercentage=Math.max(Nl,t.pixelPerPercentage*i))}p=!0}p&&a(),r()}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){const t=this.getDb(),i=$(t,this.tableName,this.filter);return this.measureScaleError=void 0,new dl(new pl,new tt(new cl),new cl,new Ul,t,i,(t=>{this.measureScaleError=ci(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 ml(new yl,new Ws,new Is(new Gs),new Ga(new Gs),new zs).adapt(this.styles);return s.locale=(null===(i=null===(t=c(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}get element(){return e(this)}};Fl.style=':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}';const Gl=class{validateFilter(t){const i="ERR_filter";v(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(Gt(t))return void this.errors.remove(i);const s=B(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(Gt(t))return void this.errors.remove(i);const s=H(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateLeftSync(t){const i="WARN_syncSpaceLeft";et(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"syncSpaceLeft: invalid value(s) '"+t+"' are not supported."})}validateUnitScaling(t){const i="WARN_unitScaling";N(t)?this.errors.remove(i):"invalid"===Xt(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="WARN_percentageScaling";N(t)?this.errors.remove(i):"invalid"===Xt(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."}):this.errors.remove(i)}validateDateInterval(t){const i="WARN_dateInterval";N(t)||nt(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateInterval: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateChartMode(t){const i="WARN_chartMode";["bar","line","auto"].includes(null==t?void 0:t.toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"chartMode: invalid value '"+(null==t?void 0:t.toString())+"' is not supported. Valid values are: bar, line, auto."})}validateMaxBars(t){const i="WARN_maxBars";!L(t)||t<1?this.errors.addOrReplace({id:i,type:"warning",message:"maxBars: invalid value '"+(null==t?void 0:t.toString())+"' is not supported. Must be a positive integer."}):this.errors.remove(i)}validateStack(t){const i="WARN_stack",s=J(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:s.join("; ")}):this.errors.remove(i)}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("WARN_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"WARN_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("WARN_scale")}validateAxisLabelsMode(t){const i="WARN_axisLabelsMode";N(t)||rt(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"axisLabelsMode: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";X(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}constructor(i){t(this,i),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.chartTitle="",this.filter="",this.syncSpaceLeft=-1,this.chartMode="bar",this.maxBars=28,this.stack="",this.intervalSpanLimit=28,this.lineFullWidth=!0,this.showCategories=!0,this.measureScale="greatest",this.showMeasureScale=!1,this.showOverlayAvg=!0,this.showOverlayMedian=!1,this.measureUnit="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,this._lastObservedWidth=0,this._settleTimer=null,this._lastAppliedHeight=0,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=t=>{var i,s,e,n,r,o;this.lastAutoScalingReport={unit:null!==(i=t.unit)&&void 0!==i?i:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(e=t.percentage)&&void 0!==e?e:null===(n=this.lastAutoScalingReport)||void 0===n?void 0:n.percentage};const h=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t),a=this.getEffectiveFontPx();if(void 0!==t.unit&&t.unit>0&&this.autoUnitWarningActive){const i=a/t.unit;h(i,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=i,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${Gl.describeScalingInput(String(null!==(r=this.unitScaling)&&void 0!==r?r:"").trim())}, auto-fitted to 1 em ≈ ${Jt(i)} units.`}))}if(void 0!==t.percentage&&t.percentage>0&&this.autoPctWarningActive){const i=100*a/t.percentage;h(i,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=i,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${Gl.describeScalingInput(String(null!==(o=this.percentageScaling)&&void 0!==o?o:"").trim())}, auto-fitted to 1 em ≈ ${Jt(i)} percentage points.`}))}},E(this),a(this),Yt(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=l(this),ns(this),this.componentStyle=k(this),this.ruleSetConfig=es(this),this.t=Bt(this).t,this.resolveInherited=qt(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"}],this.errors)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLeftSync(this.syncSpaceLeft),this.validateDateInterval(this.dateInterval),this.validateAxisLabelsMode(this.axisLabelsMode),this.validateMeasureScale(this.measureScale),this.validateChartMode(this.chartMode),this.validateMaxBars(this.maxBars),this.validateStack(this.stack),this.validateScaling(this.scale)}measureContentWidth(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-time-renderer");let s=0,e=!1;return null==i||i.forEach((t=>{var i,n,r;const o=parseFloat(null!==(r=null===(n=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===n?void 0:n.getAttribute("width"))&&void 0!==r?r:"");Number.isNaN(o)||(s=Math.max(s,o),e=!0)})),e?Math.max(Math.floor(s),this.element.scrollWidth):this.element.scrollWidth}measureContentHeight(){var t;const i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelectorAll("bn-chart-time-renderer");let s=0,e=!1;return null==i||i.forEach((t=>{var i,n,r;const o=parseFloat(null!==(r=null===(n=null===(i=t.shadowRoot)||void 0===i?void 0:i.querySelector("svg#drawCanvas"))||void 0===n?void 0:n.getAttribute("height"))&&void 0!==r?r:"");Number.isNaN(o)||(s+=o,e=!0)})),e?Math.max(Math.floor(s),this.element.scrollHeight):this.element.scrollHeight}checkOverflow(){const t=Ut(this.element),i=this.measureContentWidth(),s=this.measureContentHeight(),e=t.width>0&&i>t.width+1,n=t.height>0&&s>t.height+1;if(!e&&!n)return void M(this.errors,null);const r=this.prepareVariances().some((t=>t.startsWith("dr"))),o="value"===Xt(this.unitScaling,this.pixelPerUnitGroupMap).kind,h=r&&"value"===Xt(this.percentageScaling,this.pixelPerUnitGroupMap).kind,{mode:a}=Ht(this.scale),l="auto"!==a&&"empty"!==a,c=[];n&&o&&c.push("unit-scaling"),n&&h&&c.push("percentage-scaling"),e&&l&&c.push("scale");const u=[];e&&u.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),n&&u.push(`height (${Math.round(s)}px > ${Math.round(t.height)}px)`),M(this.errors,`Chart exceeds available ${u.join(" and ")}. `+(c.length>0?`Adjust ${c.join(" / ")} or set to "auto".`:"Content does not fit even at minimum auto scaling; enlarge the container."),c.length>0)}componentDidRender(){$s(this.element,"bn-chart-time-renderer");const{mode:t}=Ht(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{width:s}=Ut(i);if(s<=0)return void this.checkOverflow();this._lastObservedWidth=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),n=i.scrollWidth,o=this.appliedScaleFactor;if(n<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const h=Math.max(.3,o*(s-1)/n);Math.abs(h-o)<.01||(i.style.setProperty("--bn-font-size",e*h+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled chart by factor ${h.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,r((()=>{this.appliedScaleFactor=h}))),this.checkOverflow()}componentDidLoad(){this.layoutObserver=ss(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=Ut(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2&&(this._lastObservedWidth=t,n(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=Ut(this.element);this._lastObservedWidth=t,n(this)}))})),this.settleParentHeight()}settleParentHeight(){const t=[150,400,1e3,2500],i=()=>{if(this._settleTimer=null,!this.element.isConnected)return;const{height:s}=Ut(this.element);s>0&&Math.abs(s-this._lastAppliedHeight)>8&&!this._autoScaleGuard&&n(this);const e=t.shift();void 0!==e&&(this._settleTimer=setTimeout(i,e))};this._settleTimer=setTimeout(i,t.shift())}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null,null!=this._settleTimer&&(clearTimeout(this._settleTimer),this._settleTimer=null)}prepareDimension(){const t=Ut(this.element),i=this.prepareScenarios(),s=this.prepareVariances();this.canvasWidthSegmented=t.width/(i.length+s.length||1),this._lastAppliedHeight=t.height;const e=1+s.length,n=this.showMeasureScale?this.getEffectiveFontPx():0;return{width:this.canvasWidthSegmented,height:Math.max(0,t.height-n)/e}}prepareScenarios(){var t,i,s,e;const n=this.resolveInherited("scenarios",this.scenarios);if(n.inherited)return this.errors.remove("AUTO_scenarios"),n.value.split(",").map((t=>t.trim()));const r="auto"===(null===(t=n.value)||void 0===t?void 0:t.trim().toLowerCase());return N(n.value)||r?(null===(s=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===s?void 0:s.length)>0?(r||n.unresolved?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(e=n.value)||void 0===e?void 0:e.split(",").map((t=>t.trim())))}prepareAvg(){return this.showOverlayAvg}prepareMedian(){return this.showOverlayMedian}prepareVariances(){const t=this.resolveInherited("variances",this.variances).value;return N(t)?[]:null==t?void 0:t.split(",").map((t=>t.trim()))}checkVarianceScenarios(t){const i="WARN_variances_scenario",s=this.prepareScenarios(),e=[];for(const i of t){const t=new ks(i);if(t.isValid)for(const n of[t.base,t.delta])s.includes(n)||e.push(`'${i}' needs '${n}'`)}s.length>0&&e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:`variances: ${e.join(", ")}, which is not in scenarios (${s.join(", ")}). The variance has no values.`}):this.errors.remove(i)}prepareHideAxisLabels(t){return t>=1||!this.showCategories}prepareI18n(){const t=p,i=new Map(["no-data"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries(),...Ts(this.ruleSetConfig("user"))])}static describeScalingInput(t){return""===t?"not set":`invalid value "${t}"`}preparePixelPerUnit(){const t=Xt(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,this.getEffectiveFontPx()/t.value):"auto"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: ${Gl.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}preparePixelPerPercentage(){const t=Xt(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,100*this.getEffectiveFontPx()/t.value):"auto"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: ${Gl.describeScalingInput(t.raw)}, auto-calculated to fit available space.`}),0)}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const s=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-time"].scaleFactors.scenarioOffset,scenarioLabelToColumn:i["bn-chart-time"].scaleFactors.scenarioLabelToColumn,labelToColumn:i["bn-chart-time"].scaleFactors.labelToColumn,labelToAxis:i["bn-chart-time"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-time"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-time"].scaleFactors.needleHeadWidth,columnWidth:i["bn-chart-time"].scaleFactors.columnWidth,varianceAxisLineWidth:i["bn-chart-time"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-time"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-time"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-time"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-time"].scaleFactors.markerWidth,markerOffset:i["bn-chart-time"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-time"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-time"].scaleFactors.axisTickLength},fontStyles:{font:`${s}px ${i.global.fontFamily}`,family:i.global.fontFamily,size:s,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-time"].axisStyles,barStyles:i["bn-chart-time"].barStyles,varianceStyles:i["bn-chart-time"].varianceStyles,stackColors:i["bn-chart-time"].stackColors,padding:i["bn-chart-time"].padding,pattern:null,locale:"de"}}))}prepareLeftSideOffset(t,i){return this.syncSpaceLeft>-1?this.syncSpaceLeft:ra.getMaxWidthOfArrayItems([...this.prepareVariances(),...this.prepareScenarios(),this.chartTitle],t,i)}prepareChartTitle(t){return t>=1?"":this.chartTitle}prepareDateInterval(){var t,i,s;const e="auto"===(null===(t=this.dateInterval)||void 0===t?void 0:t.trim().toLowerCase());return N(this.dateInterval)||e?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedDateInterval)?(e?this.errors.remove("AUTO_dateInterval"):this.errors.addOrReplace({id:"AUTO_dateInterval",type:"warning",message:`dateInterval: not set, auto-detected: ${this.datasetMeta.suggestedDateInterval}`}),ot[this.datasetMeta.suggestedDateInterval.toUpperCase()]):e?ot.AUTO:void 0:(this.errors.remove("AUTO_dateInterval"),ot[null===(s=this.dateInterval)||void 0===s?void 0:s.toUpperCase()])}prepareIntervalSpanLimit(){const t=Number(this.intervalSpanLimit);return t>0?t:28}prepareAxisLabelsMode(){var t;return ht[null===(t=this.axisLabelsMode)||void 0===t?void 0:t.toUpperCase()]}prepareFilter(){return 0===this.filter.length?"":this.filter}getDataStructure(){return{ITimeChartDataRow:{setName:{type:"string",isOptional:!1,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return N(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareStackConfig(){if(N(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const t=JSON.parse(this.stack),i=t.by,s="WARN_stack_dimensions_scenarios";if(i===q.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:s,type:"warning",message:`stack by dimensions: only the first scenario "${t[0]}" is used, the rest (${t.slice(1).join(", ")}) are discarded.`}):this.errors.remove(s)}else this.errors.remove(s);return{by:i,mode:t.mode||Q.ABSOLUTE,order:t.order||K.DATASET}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareLineFullWidth(){return this.lineFullWidth}prepareChartMode(){var t;const i=null===(t=this.chartMode)||void 0===t?void 0:t.toLowerCase();return"line"===i?at.LINE:"auto"===i?at.AUTO:at.BAR}prepareMaxBars(){return Math.floor(Number(this.maxBars)||28)}chartTemplate(t,s){const e=this.prepareI18n(),n=this.prepareStyle(),r=Ut(this.element).width,o=this.preparePixelPerUnit(),h=this.preparePixelPerPercentage(),a=this.prepareStackConfig(),l=this.prepareScenarios(),c=(null==a?void 0:a.by)===q.DIMENSIONS?l.slice(0,1):l;return i("bn-chart-time-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.prepareChartTitle(s),scenarios:c,variances:[t],hideAxisLabels:this.prepareHideAxisLabels(s),pixelPerUnit:o,pixelPerPercentage:h,reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,leftSideOffsetForHorizontalSync:this.prepareLeftSideOffset(e,n),styles:n,i18n:e,dateInterval:this.prepareDateInterval(),intervalSpanLimit:this.prepareIntervalSpanLimit(),axisLabelsMode:this.prepareAxisLabelsMode(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showOverlayAvg:this.prepareAvg(),showOverlayMedian:this.prepareMedian(),showMeasureScale:this.prepareShowMeasureScale(s),chartMode:this.prepareChartMode(),maxBars:this.prepareMaxBars(),stackConfig:a,lineFullWidth:this.prepareLineFullWidth(),containerWidth:r,parentDimensions:this.prepareDimension(),ruleSetConfig:this.ruleSetConfig()})}async getBaseline(){return Ui(this.element,"bn-chart-time-renderer")}async getLayoutState(t){var i,s,e,n;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",o=ei(this.element),h=this.getEffectiveScaleFactor(),a=Number.isFinite(h)&&h>0?h:1,l=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*a,c=this.prepareVariances(),u=Zi(this.element,"bn-chart-time-renderer",["base",...c],o,r),d=null===(s=this.element.shadowRoot)||void 0===s?void 0:s.querySelector("bn-chart-time-renderer"),f={version:li,tag:this.element.localName,id:ii(this.element),slot:null!==(e=this.element.getAttribute("slot"))&&void 0!==e?e:void 0,rect:ti(this.element,o),em:{fontSizePx:l,appliedScaleFactor:a},regions:u.regions,metadata:{title:this.chartTitle||void 0,scenarios:null!==(n=null==d?void 0:d.scenarios)&&void 0!==n?n:[],variances:c,barCount:u.barCount,chartMode:this.chartMode||void 0,hasNoData:0===u.barCount},diagnostics:Zt(this.element),scaling:this.resolveScalingInfo(l),baseline:u.baseline};return u.elements&&(f.elements=u.elements),f}resolveScalingInfo(t){var i,s;const e={},n=Xt(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===n.kind)e.unitMode="fixed",e.unitsPerEm=n.value,e.unitPxPerUnit=t/n.value;else{e.unitMode="auto";const s=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==s&&s>0&&(e.unitPxPerUnit=s,e.unitsPerEm=t/s)}const r=Xt(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)e.percentageMode="fixed",e.percentagePointsPerEm=r.value,e.percentagePxPerPoint=t/r.value;else{e.percentageMode="auto";const i=null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.percentage;void 0!==i&&i>0&&(e.percentagePxPerPoint=i/100,e.percentagePointsPerEm=100*t/i)}return e}getEffectiveScaleFactor(){const{mode:t,factor:i}=Ht(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){const t=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}));return t*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const o=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":o*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){let t=[""];const e=this.prepareVariances();this.checkVarianceScenarios(e),e.length>0&&(t=[...t,...e]);const n=this.getFontStyles();return i(s,{key:"37085b275bb92d716a31f79f15b9f2517f1c596b",style:n},i("div",{key:"93e9eacc22334da1deed871db640d6fd4aafb153",class:"container"},t.map(this.chartTemplate)))}get element(){return e(this)}static get watchers(){return{filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],syncSpaceLeft:[{validateLeftSync:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dateInterval:[{validateDateInterval:0}],chartMode:[{validateChartMode:0}],maxBars:[{validateMaxBars:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}],axisLabelsMode:[{validateAxisLabelsMode:0}],measureScale:[{validateMeasureScale:0}]}}};Gl.style=':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:column-reverse}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}';class jl{constructor(){this.scenarioOffset=.3,this.scenarioLabelToColumn=.3,this.labelToColumn=.3,this.labelToAxis=.3,this.needleWidth=.3,this.needleHeadWidth=.6,this.columnWidth=2,this.varianceAxisLineWidth=.3,this.axisLineWidth=.1,this.auxiliaryLineWidth=.1,this.scenarioLineWidth=.2,this.markerWidth=.7,this.markerOffset=0,this.categoryWidth=3,this.axisTickLength=.3}}class Il{adapt(t){const i=new jl;return R.isNumber(t.scenarioOffset)&&(i.scenarioOffset=t.scenarioOffset),R.isNumber(t.scenarioLabelToColumn)&&(i.scenarioLabelToColumn=t.scenarioLabelToColumn),R.isNumber(t.labelToColumn)&&(i.labelToColumn=t.labelToColumn),R.isNumber(t.labelToAxis)&&(i.labelToAxis=t.labelToAxis),R.isNumber(t.needleWidth)&&(i.needleWidth=t.needleWidth),R.isNumber(t.needleHeadWidth)&&(i.needleHeadWidth=t.needleHeadWidth),R.isNumber(t.columnWidth)&&(i.columnWidth=t.columnWidth),R.isNumber(t.varianceAxisLineWidth)&&(i.varianceAxisLineWidth=t.varianceAxisLineWidth),R.isNumber(t.axisLineWidth)&&(i.axisLineWidth=t.axisLineWidth),R.isNumber(t.auxiliaryLineWidth)&&(i.auxiliaryLineWidth=t.auxiliaryLineWidth),R.isNumber(t.scenarioLineWidth)&&(i.scenarioLineWidth=t.scenarioLineWidth),R.isNumber(t.markerWidth)&&(i.markerWidth=t.markerWidth),R.isNumber(t.markerOffset)&&(i.markerOffset=t.markerOffset),R.isNumber(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),R.isNumber(t.axisTickLength)&&(i.axisTickLength=t.axisTickLength),i}default(){return new jl}}class Yl{constructor(t,i,s,e,n,r,o){this.categoryPosition={x:0,y:0},this.spacings=new jl,this.categoriesBoxOffset={width:0,height:0},this.padding=t,this.scaleFactors=i,this.fontStlye=s,this.dataLabelHeight=this.caluculateDataLabelHeight(),this.axisPosition={x:0,y:0},this.columnValue={min:e,max:n},this.numberOfColumns=r,this.leftSideLabelLength=o,this.calculateSpacings(),this.calculateCategoryPosition(),this.calculateAxisPosition()}caluculateDataLabelHeight(){return 1.1*Qh("123456789",{font:this.fontStlye.font,fontSize:this.fontStlye.size+"px"}).height}getColumnCenterPositionX(t){return this.categoryPosition.y+this.spacings.scenarioOffset+t*this.spacings.categoryWidth+this.leftSideLabelLength+.5*this.spacings.columnWidth}getAxisPositionY(t){let i=this.columnValue.max.getScaledUnit();return t&&(i=this.columnValue.max.getScaledPercentUnit()+this.getNeedleWidth()),i+this.dataLabelHeight+this.spacings.labelToAxis+this.padding.top}getAxisPositionX(){return this.padding.left+this.leftSideLabelLength}getColumnPositionX(t,i){return i?this.getColumnCenterPositionX(t):this.getColumnCenterPositionX(t)-this.spacings.scenarioOffset}getColumnPositionY(){return this.columnValue.max.getScaledUnit()+this.dataLabelHeight+this.spacings.labelToColumn+this.padding.top}getNeedlePositionY(){return this.columnValue.max.getScaledPercentUnit()+this.dataLabelHeight+this.spacings.labelToColumn+this.getNeedleWidth()+this.padding.top}getMarkerPositionX(t,i){return i?this.getColumnCenterPositionX(t)-this.spacings.markerOffset-.5*this.getColumnWidth():this.getColumnCenterPositionX(t)+this.spacings.markerOffset+.5*this.getColumnWidth()}getMarkerPositionY(){return this.getColumnPositionY()}getAxisTitlePositionX(t){const i=t.width();return this.axisPosition.x-i}getAxisTitlePositionY(t,i){let s=this.columnValue.max.getScaledUnit();return i&&(s=this.columnValue.max.getScaledPercentUnit()),t?s+this.dataLabelHeight+this.spacings.labelToAxis:s}getColumnDataLabelPositionY(t){const i=this.spacings.labelToColumn;return t<0?this.getColumnPositionY()+Math.abs(t)+i:this.getColumnPositionY()-t-i}getNeedleDataLabelPositionY(t){const i=this.spacings.labelToColumn;return t<0?this.getNeedlePositionY()+Math.abs(t)+i+2*this.getNeedleWidth():this.getNeedlePositionY()-t-i-2*this.getNeedleWidth()}getAxisEndPositionX(){return this.getAxisPositionX()+(this.numberOfColumns+.5)*this.spacings.categoryWidth}getColumnWidth(){return this.spacings.columnWidth}getNeedleWidth(){return this.spacings.needleWidth}getNeedleHeadWidth(){return this.spacings.needleHeadWidth}getScenarioLabelPositionOffsetX(t){return t?.5*this.getColumnWidth()+this.spacings.scenarioLabelToColumn:-(.5*this.getColumnWidth()+this.spacings.scenarioLabelToColumn)}calculateSpacings(){this.spacings={scenarioOffset:this.fontStlye.size*this.scaleFactors.scenarioOffset,scenarioLabelToColumn:this.fontStlye.size*this.scaleFactors.scenarioLabelToColumn,markerOffset:this.fontStlye.size*this.scaleFactors.markerOffset,labelToColumn:this.fontStlye.size*this.scaleFactors.labelToColumn,labelToAxis:this.fontStlye.size*this.scaleFactors.labelToAxis,needleWidth:this.fontStlye.size*this.scaleFactors.needleWidth,needleHeadWidth:this.fontStlye.size*this.scaleFactors.needleHeadWidth,columnWidth:this.fontStlye.size*this.scaleFactors.columnWidth,varianceAxisLineWidth:this.fontStlye.size*this.scaleFactors.varianceAxisLineWidth,axisLineWidth:this.fontStlye.size*this.scaleFactors.axisLineWidth,auxiliaryLineWidth:this.fontStlye.size*this.scaleFactors.auxiliaryLineWidth,scenarioLineWidth:this.fontStlye.size*this.scaleFactors.scenarioLineWidth,markerWidth:this.fontStlye.size*this.scaleFactors.markerWidth,categoryWidth:this.fontStlye.size*this.scaleFactors.categoryWidth,axisTickLength:this.fontStlye.size*this.scaleFactors.axisTickLength}}calculateCategoryPosition(){this.categoryPosition={x:this.padding.left+.5*this.spacings.columnWidth,y:this.padding.top}}calculateAxisPosition(){this.axisPosition={x:this.getAxisPositionX(),y:this.getAxisPositionY(!1)}}getMarkerScenarioLabelPositionOffsetX(t){return t?this.spacings.labelToColumn-this.fontStlye.size:this.spacings.labelToColumn+.5*this.spacings.markerWidth}}class Bl{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 Hl{constructor(t){const i=1*t,s=.7*t;this.bgOffset=(i-s)/2,this.markerUp={top:s/2+",0",left:"0,"+s,right:s+","+s},this.markerUpBackground={top:i/2+",0",left:"0,"+i,right:i+","+i},this.markerDown={bottom:s/2+","+s,left:"0,0",right:s+",0"},this.markerDownBackground={bottom:i/2+","+i,left:"0,0",right:i+",0"},this.markerRight={bottom:"0,"+s,top:"0,0",right:s+","+s/2},this.markerRightBackground={bottom:"0,"+i,top:"0,0",right:i+","+i/2},this.markerLeft={bottom:s+","+s,top:s+",0",left:"0,"+s/2},this.markerLeftBackground={bottom:i+","+i,top:i+",0",Left:"0,"+i/2}}upMarkerPatternStrings(){return{background:this.markerUpBackground.left+" "+this.markerUpBackground.right+" "+this.markerUpBackground.top+" "+this.markerUpBackground.left,foreground:this.markerUp.left+" "+this.markerUp.right+" "+this.markerUp.top+" "+this.markerUp.left,bgOffset:this.bgOffset}}downMarkerPatternStrings(){return{background:this.markerDownBackground.left+" "+this.markerDownBackground.right+" "+this.markerDownBackground.bottom+" "+this.markerDownBackground.left,foreground:this.markerDown.left+" "+this.markerDown.right+" "+this.markerDown.bottom+" "+this.markerDown.left,bgOffset:this.bgOffset}}rightMarkerPatternStrings(){return{background:this.markerRightBackground.top+" "+this.markerRightBackground.right+" "+this.markerRightBackground.bottom+" "+this.markerRightBackground.top,foreground:this.markerRight.top+" "+this.markerRight.right+" "+this.markerRight.bottom+" "+this.markerRight.top,bgOffset:this.bgOffset}}leftMarkerPatternStrings(){return{background:this.markerLeftBackground.top+" "+this.markerLeftBackground.Left+" "+this.markerLeftBackground.bottom+" "+this.markerLeftBackground.top,foreground:this.markerLeft.top+" "+this.markerLeft.left+" "+this.markerLeft.bottom+" "+this.markerLeft.top,bgOffset:this.bgOffset}}createPatternMapForStructureBar(){const t=new Map;return t.set("marker-up",this.upMarkerPatternStrings()),t.set("marker-down",this.downMarkerPatternStrings()),t.set("marker-right",this.rightMarkerPatternStrings()),t.set("marker-left",this.leftMarkerPatternStrings()),t}}class Vl{constructor(t){this.container=new uh,this.pattern=this.createFCPattern(this.container.group(),t),this.styles=t;let i=10;null!=t&&null!=t.fontStyles&&t.fontStyles.size&&(i=t.fontStyles.size),this.bgOffset=(1*i-.7*i)/2}createFCPattern(t,i){const s=i;return t.pattern(10,10,(function(t){t.rect(10,10).fill(s.barStyles.fc.fill),t.line(0,5,5,0).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"}),t.line(5,10,10,5).stroke({width:s.barStyles.fc.width,color:s.barStyles.fc.stroke,linecap:"square"})})).id("pattern-time-fc")}getFCPolygonPattern(){return{background:"",foreground:"",bgOffset:0,pattern:this.pattern}}toString(){return this.container.svg()}}class Xl{constructor(t,i,s,e){this.value=t,this.scenario=i,this.pixelPerUnit=s||1;const n="string"==typeof e?As(e,null,!0):e;this.variance="neg"===n||n===Zl.NEG?Zl.NEG:"pos"===n||n===Zl.POS?Zl.POS:Zl.NEU}isEmpty(){return void 0===this.value||null==this.scenario}getScaledUnit(){return null==this.value?0:this.value*this.pixelPerUnit}getScaledPercentUnit(){return null==this.value?0:this.value>1.45?1.45*this.pixelPerUnit:this.value<-1.45?-1.45*this.pixelPerUnit:this.value*this.pixelPerUnit}getVarianceStyle(){return null==this.value||this.value>=0?this.variance:Zl.NEU===this.variance?Zl.NEU:Zl.POS===this.variance?Zl.NEG:Zl.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 Jl{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 ql{constructor(){}adapt(t){const i=new Jl;return R.isString(t.date)&&(i.date=this.parseDateString(t.date)),R.isOperator(t.operation)&&(i.operation=t.operation),R.isNumber(t.rowGroupIndex)&&R.isString(t.rowGroup)&&i.addRowGroup(t.rowGroup,t.rowGroupIndex),R.isNumber(t.categoryIndex)&&R.isString(t.category)&&i.addCategory(t.category,t.categoryIndex),R.isNumber(t.subCategoryIndex)&&R.isString(t.subCategory)&&i.addSubCategory(t.subCategory,t.subCategoryIndex),R.isNumber(t.columnGroupIndex)&&R.isString(t.columnGroup)&&i.addColumnGroup(t.columnGroup,t.columnGroupIndex),R.isNumber(t.columnSubGroupIndex)&&R.isString(t.columnSubGroup)&&i.addSubColumnGroup(t.columnSubGroup,t.columnSubGroupIndex),this.setActualValues(t,i),this.setPlanValues(t,i),this.setPreviousPeriodValues(t,i),this.setForecastValues(t,i),i}parseDateString(t){if("string"!=typeof t)return;const i=y.fromISO(t,{zone:"utc"});if(i.isValid)return i;console.warn(`TimeChartDataRow: invalid date value '${t}' - skipping row`)}default(){return new Jl}setActualValues(t,i){R.isNumber(t.ac1)&&(i.ac1=t.ac1),R.isNumber(t.ac2)&&(i.ac2=t.ac2),R.isNumber(t.ac3)&&(i.ac3=t.ac3),R.isNumber(t.ac4)&&(i.ac4=t.ac4)}setPlanValues(t,i){R.isNumber(t.pl1)&&(i.pl1=t.pl1),R.isNumber(t.pl2)&&(i.pl2=t.pl2),R.isNumber(t.pl3)&&(i.pl3=t.pl3),R.isNumber(t.pl4)&&(i.pl4=t.pl4)}setPreviousPeriodValues(t,i){R.isNumber(t.pp1)&&(i.pp1=t.pp1),R.isNumber(t.pp2)&&(i.pp2=t.pp2),R.isNumber(t.pp3)&&(i.pp3=t.pp3),R.isNumber(t.pp4)&&(i.pp4=t.pp4)}setForecastValues(t,i){R.isNumber(t.fc1)&&(i.fc1=t.fc1),R.isNumber(t.fc2)&&(i.fc2=t.fc2),R.isNumber(t.fc3)&&(i.fc3=t.fc3),R.isNumber(t.fc4)&&(i.fc4=t.fc4)}}class Kl{constructor(t,i,s,e,n,r){this.scaleFactors=t,this.fontStyles=i,this.axisStyles=s,this.barStyles=e,this.varianceStyles=n,this.padding=r,this.pattern=new Map,this.stackColors=["#000000","#c0c0c0","#808080"],this.locale="de"}}class Ql{constructor(t,i,s,e,n){this.scaleFactorsStructureChartAdapter=t,this.fontStyleAdapter=i,this.svgStyleGroupAdapter=s,this.svgVariancesStyleGroupAdapter=e,this.paddingadapter=n}adapt(t){const i=new Kl(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default());return R.isExisting(t)&&(R.isExisting(t.scaleFactors)&&(i.scaleFactors=this.scaleFactorsStructureChartAdapter.adapt(t.scaleFactors)),R.isExisting(t.fontStyles)&&(i.fontStyles=this.fontStyleAdapter.adapt(t.fontStyles)),R.isExisting(t.axisStyles)&&(i.axisStyles=this.svgStyleGroupAdapter.adapt(t.axisStyles)),R.isExisting(t.barStyles)&&(i.barStyles=this.svgStyleGroupAdapter.adapt(t.barStyles)),R.isExisting(t.varianceStyles)&&(i.varianceStyles=this.svgVariancesStyleGroupAdapter.adapt(t.varianceStyles)),R.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 Hl(i.fontStyles.size).createPatternMapForStructureBar()),i}default(){return new Kl(this.scaleFactorsStructureChartAdapter.default(),this.fontStyleAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgStyleGroupAdapter.default(),this.svgVariancesStyleGroupAdapter.default(),this.paddingadapter.default())}}var Zl,tc;!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"}(Zl||(Zl={})),function(t){t.LIST="LIST",t.SUM="SUM",t.OPT="OPT"}(tc||(tc={}));class ic{constructor(t,i,s){this.ID_AXIS="axis",this.CSS_AXIS_TITLE="categories",this.scenarioType=t.scenarioType,this.labelText=t.labelText||null,this.isRelative=t.isRelative||!1,this.position=i,this.svgGroup=s.group().id(this.ID_AXIS)}drawAxisTitle(t,i){null==i&&(i=""),t.text(i).addClass(this.CSS_AXIS_TITLE).attr("text-anchor","middle").move(this.position.getAxisTitlePositionX(t),this.position.getAxisTitlePositionY(!0,this.isRelative))}draw(){return this.labelText&&this.drawAxisTitle(this.svgGroup,this.labelText),this.svgGroup.line(this.position.getAxisPositionX(),this.position.getAxisPositionY(this.isRelative),this.position.getAxisEndPositionX(),this.position.getAxisPositionY(this.isRelative)).addClass(this.ID_AXIS+"-"+this.convertScenarioType()),this}convertScenarioType(){return void 0===this.scenarioType||null==this.scenarioType?"default":`${this.scenarioType}`.slice(0,2)}}class sc{constructor(t,i,s,e,n,r,o,h=null){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.scenarioLabel=null,this.isVarianceColumn=!1,this.overflowConfig=null,this.isOverflowing=!1,this.overdriveHeight=0,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=e,this.isPrimaryColumn=n,this.position=t,this.columnBarStyles=i.barStyles,this.overflowConfig=h,this.scenarioGroup=r,this.styles=i,this.columnGroup=r.group().id(r.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&(this.hasData=!0,this.dimensions=this.createDimensions(s,e,n),this.label=this.getDataLabel(s),this.scenarioLabel=this.getScenarioLabel(o))}setAsVariance(){var t;return this.isVarianceColumn=!0,null===(t=this.label)||void 0===t||t.setToVarianceLabel(),this}updateLabelGroup(t){var i;return this.isEmpty()||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1},i=new la){var s;if(this.isEmpty())return this;const e=this.getScenarioStyle(),n=this.convertToSVGStyle(e,"stroke"),r=this.getFillStyle(e);this.scenarioGroup.attr(ji(this.dataPoint.key)),null===(s=this.columnGroup)||void 0===s||s.attr(ji(this.dataPoint.key,"element")),null!=this.columnGroup&&(this.isOverflowing&&this.overflowConfig?this.drawOverdriveBar(r,n):this.columnGroup.rect(this.position.getColumnWidth(),this.dimensions.columnLength).fill(r).stroke(n).y(this.dimensions.yPos).cx(this.dimensions.xPos)),this.drawColumnDataLabel(t,i),this.drawScenarioLabel()}drawOverdriveBar(t,i){if(!this.columnGroup||!this.overflowConfig)return;const s=this.position.getColumnPositionY(),e=this.position.getColumnWidth(),n=this.dimensions.columnLength,{breakGap:r}=this.overflowConfig,o=s-n;this.columnGroup.rect(e,n).fill(t).stroke(i).y(o).cx(this.dimensions.xPos);const h=o-r-this.overdriveHeight;this.columnGroup.rect(e,this.overdriveHeight).fill(t).stroke(i).y(h).cx(this.dimensions.xPos),this.drawBreakIndicator(o,r)}drawBreakIndicator(t,i){if(!this.columnGroup)return;const s=this.position.getColumnWidth(),e=this.dimensions.xPos-s/2,n=t-i/2,r=.35*i,o=s/3;let h=`M ${e} ${n-r}`;for(let t=0;t<3;t++)h+=` L ${e+o*(t+.5)} ${n-r-.3*i} L ${e+o*(t+1)} ${n-r}`;let a=`M ${e} ${n+r}`;for(let t=0;t<3;t++)a+=` L ${e+o*(t+.5)} ${n+r+.3*i} L ${e+o*(t+1)} ${n+r}`;this.columnGroup.rect(s+2,i).fill("#ffffff").stroke("none").y(t-i).cx(this.dimensions.xPos),this.columnGroup.path(h).fill("none").stroke({color:"#000000",width:1}),this.columnGroup.path(a).fill("none").stroke({color:"#000000",width:1})}createDimensions(t,i,s){const e=t.getScaledUnit();if(this.overflowConfig&&e>0){const n="ac"===t.getScenario()?this.overflowConfig.cutHeight:this.overflowConfig.cutHeight-this.overflowConfig.scenarioCutOffset;if(e>n){this.isOverflowing=!0;const{breakGap:t,overdriveZoneHeight:r,maxOverflow:o}=this.overflowConfig;this.overdriveHeight=o>0?(e-n)/o*r:0;const h=n+t+this.overdriveHeight,a=this.position.getColumnPositionY();return{clipped:!1,columnLength:n,xPos:this.position.getColumnPositionX(i,s),yPos:a-n,labelYPos:a-h-this.position.spacings.labelToColumn,scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:a-.5*n}}}return e<0?{clipped:!1,columnLength:Math.abs(e),xPos:this.position.getColumnPositionX(i,s),yPos:this.position.getColumnPositionY(),labelYPos:this.position.getColumnDataLabelPositionY(e),scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getColumnPositionY()+.5*Math.abs(e)}:{clipped:!1,columnLength:e,xPos:this.position.getColumnPositionX(i,s),yPos:this.position.getColumnPositionY()-e,labelYPos:this.position.getColumnDataLabelPositionY(e),scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getColumnPositionY()-.5*Math.abs(e)}}getDataLabel(t){let i=na.Bottom;null!=t.value&&t.value<0&&(i=na.Top);const s=this.isOverflowing?this.dimensions.labelYPos:this.position.getColumnDataLabelPositionY(this.dataPoint.getScaledUnit());return new ca(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),s,this.ID_DATA_PREFIX,t.value,this.styles,i,na.Center).setPoint(t.key)}getScenarioLabel(t){return new ca(this.scenarioGroup,-1,-1,this.ID_SCENARIO_PREFIX,t,this.styles,na.Center,this.isPrimaryColumn?na.Left:na.Right)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.isVarianceColumn||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(!0)}drawColumnDataLabel(t,i=new la){var s;null===(s=this.label)||void 0===s||s.draw(this.isPrimaryColumn,t,i)}getFillStyle(t){var i,s,e,n;const r=this.columnBarStyles[this.dataPoint.getScenario()];return(null==r?void 0:r.fillpattern)&&(null===(i=this.styles.pattern.get(r.fillpattern))||void 0===i?void 0:i.pattern)?null===(n=null===(e=null===(s=this.styles)||void 0===s?void 0:s.pattern)||void 0===e?void 0:e.get(r.fillpattern))||void 0===n?void 0:n.pattern:this.convertToSVGStyle(t,"fill")}getScenarioStyle(){var t;return this.isVarianceColumn?null===(t=this.styles)||void 0===t?void 0:t.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()):this.columnBarStyles[this.dataPoint.getScenario()]}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}}class ec{constructor(t,i,s,e,n,r,o,h,a){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.FALLBACK_COLOUR="#000000",this.scenarioLabel=null,this._defaultMarkerPattern=null,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.position=t,this.markerGroup=i||null,this.markerPattern=s||this._defaultMarkerPattern,this.styles=n,this.barStyles=n?n.barStyles:null,this.scenario=e,!0!==(null==r?void 0:r.isEmpty())&&(this.hasData=!0,this.pointKey=r.key,this.dimensions=this.createMarkerDimensions(r,o,a),this.scenarioLabel=this.getScenarioLabel(h,n,a))}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(ji(this.pointKey)),this.markerGroup.polygon(this.markerPattern.background).fill("#ffffff").cy(this.dimensions.yPos-this.dimensions.columnLength).cx(this.dimensions.xPos),this.markerGroup.polygon(this.markerPattern.foreground).fill(i).stroke(t).cy(this.dimensions.yPos-this.dimensions.columnLength).cx(this.dimensions.xPos).attr(ji(this.pointKey,"element")),null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(),this}createMarkerDimensions(t,i,s){return t.getScaledUnit()<0?{clipped:!1,labelYPos:0,columnLength:t.getScaledUnit(),xPos:this.position.getMarkerPositionX(i,s),yPos:this.position.getMarkerPositionY(),scenarioLabelXPos:this.position.getMarkerPositionX(i,s)+this.position.getMarkerScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getMarkerPositionY()+Math.abs(t.getScaledUnit())}:{clipped:!1,labelYPos:0,columnLength:t.getScaledUnit(),xPos:this.position.getMarkerPositionX(i,s),yPos:this.position.getMarkerPositionY(),scenarioLabelXPos:this.position.getMarkerPositionX(i,s)+this.position.getMarkerScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getMarkerPositionY()-Math.abs(t.getScaledUnit())}}getScenarioLabel(t,i,s){return null==this.markerGroup?null:new ca(this.markerGroup,-1,-1,this.ID_DATA_PREFIX,t,i,na.Center,s?na.Right:na.Left)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}isEmpty(){return!1===this.hasData}getScenario(){var t;return null===(t=this.scenario)||void 0===t?void 0:t.slice(0,2)}}class nc{constructor(t,i,s,e,n){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.dataLabel=null,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=e,this.position=t,this.barStyles=i.barStyles,this.scenarioGroup=n,this.styles=i,this.barGroup=n.group().id(n.toString()+"_"+this.ID_RECT);const r=void 0===(null==s?void 0:s.value)&&null!=(null==s?void 0:s.scenario);(!0!==(null==s?void 0:s.isEmpty())||r)&&(this.hasData=!0,this.dimensions=this.createDimensions(t,s,e),this.dataLabel=new ca(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),this.position.getNeedleDataLabelPositionY(this.dataPoint.getScaledPercentUnit()),this.ID_DATA_PREFIX,r?it:s.value,this.styles,na.Center,na.Center),this.dataLabel.setToRelativeVarianceLabel().setPoint(s.key))}updateLabelGroup(t){var i;return this.isEmpty()||null===(i=this.dataLabel)||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.dataLabel)||void 0===i||i.draw(),this;if(this.isEmpty())return this;this.scenarioGroup.attr(ji(this.dataPoint.key)),this.barGroup.attr(ji(this.dataPoint.key,"element"));const e=this.styles.varianceStyles[this.dataPoint.getVarianceStyle()],n=this.convertToSVGStyle(e,"stroke");let r=this.convertToSVGStyle(e,"fill");const o=this.convertToSVGStyle(this.styles.varianceStyles.ac,"stroke"),h=this.convertToSVGStyle(this.styles.varianceStyles.ac,"fill"),a=this.barStyles[this.dataPoint.getScenario()];if(null!=a&&a.fillpattern){const t=this.styles.pattern.get(a.fillpattern);null!=t&&(r=t.pattern)}this.dimensions.clipped?this.createClippedNeedleHead(r,n):this.createNeedleHead(o,h),this.barGroup.rect(this.position.getNeedleWidth(),this.dimensions.columnLength).cx(this.dimensions.xPos).y(this.dimensions.yPos).fill(r).stroke(n),null===(s=this.dataLabel)||void 0===s||s.draw()}createDimensions(t,i,s){return i.getScaledPercentUnit()<0?{labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,columnLength:Math.abs(i.getScaledPercentUnit()),xPos:t.getColumnCenterPositionX(s),yPos:t.getNeedlePositionY(),clipped:i.isClipped()}:{columnLength:i.getScaledPercentUnit(),xPos:t.getColumnCenterPositionX(s),yPos:t.getNeedlePositionY()-i.getScaledPercentUnit(),labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:i.isClipped()}}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}createClippedNeedleHead(t,i){const s=this.barGroup.polygon("0,0 5,9 -5,9 0,0 0,5 5,13 -5,13 0,5").fill(t).cx(this.dimensions.xPos).cy(this.getHeadYPosition()).fill(t).stroke(i);null!=this.dataPoint.value&&this.dataPoint.value<0&&s.flip("y")}createNeedleHead(t,i){this.barGroup.rect(2*this.position.getNeedleWidth(),this.position.getNeedleHeadWidth()).cx(this.dimensions.xPos).cy(this.getHeadYPosition()).fill(t).stroke(i)}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}getHeadYPosition(){let t=this.dimensions.yPos;return null!=this.dataPoint.value&&this.dataPoint.value<0&&(t+=this.dimensions.columnLength),t}}const rc={ac:{markerFill:"#000000",markerStroke:"#000000",lineColor:"#000000"},pp:{markerFill:"#999999",markerStroke:"#999999",lineColor:"#999999"},fc:{markerFill:"#ffffff",markerStroke:"#000000",lineColor:"#000000",lineDashArray:"4,4"},pl:{markerFill:"#ffffff",markerStroke:"#000000",lineColor:"#000000"}};class oc{constructor(t,i,s,e,n,r,o,h,a=null,l){this.lineSlot=l,this.MARKER_SIZE=8,this.LINE_WIDTH=2,this.ID_LINE_PREFIX="LINE",this.ID_MARKER_PREFIX="MARKER",this.ID_LABEL_PREFIX="LABEL",this.ESTIMATED_LABEL_WIDTH=56,this.ESTIMATED_LABEL_HEIGHT=24,this.position=t,this.styles=i,this.dataPoints=s,this.scenarioGroup=e,this.labelGroup=n,this.scenarioName=r,this.scenarioLabel=o,this.collisionManager=a}draw(t={percent:2,decimal:1},i=new la){return this.drawGeometry(),this.drawLabels(t,i),this}drawGeometry(){if(0===this.dataPoints.length)return this;const t=this.getLineStyle();return this.drawLines(t),this.drawMarkers(t),this}drawLabels(t={percent:2,decimal:1},i=new la){return 0===this.dataPoints.length||(this.drawScenarioLabel(),this.drawValueLabels(t,i)),this}getLineStyle(){var t,i,s;const e=null!==(t=this.lineSlot)&&void 0!==t?t:(null===(s=null===(i=this.scenarioName)||void 0===i?void 0:i.slice(0,2))||void 0===s?void 0:s.toLowerCase())||"ac";return rc[e]||rc.ac}getScenarioVariant(){var t;const i=parseInt((null===(t=this.scenarioName)||void 0===t?void 0:t.slice(-1))||"1",10);return isNaN(i)?1:Math.min(Math.max(i,1),4)}drawSquareMarker(t,i,s,e){const n=this.MARKER_SIZE/2;return t.rect(this.MARKER_SIZE,this.MARKER_SIZE).fill(e.markerFill).stroke({color:e.markerStroke,width:1}).move(i-n,s-n)}drawCircleMarker(t,i,s,e){return t.circle(this.MARKER_SIZE).fill(e.markerFill).stroke({color:e.markerStroke,width:1}).center(i,s)}drawTriangleMarker(t,i,s,e){const n=this.MARKER_SIZE/2;return t.polygon(`${i},${s-n} ${i-n},${s+n} ${i+n},${s+n}`).fill(e.markerFill).stroke({color:e.markerStroke,width:1})}drawDiamondMarker(t,i,s,e){const n=this.MARKER_SIZE/2;return t.polygon(`${i},${s-n} ${i+n},${s} ${i},${s+n} ${i-n},${s}`).fill(e.markerFill).stroke({color:e.markerStroke,width:1})}drawLines(t){const i=this.scenarioGroup.group().id(this.ID_LINE_PREFIX);for(let s=1;s<this.dataPoints.length;s++){const e=this.dataPoints[s-1],n=this.dataPoints[s];if(e.dataPoint.isEmpty()||n.dataPoint.isEmpty())continue;const r=this.position.getColumnCenterPositionX(e.index),o=this.position.getColumnPositionY()-e.dataPoint.getScaledUnit(),h=this.position.getColumnCenterPositionX(n.index),a=this.position.getColumnPositionY()-n.dataPoint.getScaledUnit(),l=i.line([[r,o],[h,a]]).stroke({color:t.lineColor,width:this.LINE_WIDTH,linecap:"round"}).fill("none");t.lineDashArray&&l.attr("stroke-dasharray",t.lineDashArray)}}drawMarkers(t){const i=this.scenarioGroup.group().id(this.ID_MARKER_PREFIX),s=this.getScenarioVariant();for(const e of this.dataPoints){if(e.dataPoint.isEmpty())continue;const n=this.position.getColumnCenterPositionX(e.index),r=this.position.getColumnPositionY()-e.dataPoint.getScaledUnit();let o;switch(s){case 2:o=this.drawCircleMarker(i,n,r,t);break;case 3:o=this.drawTriangleMarker(i,n,r,t);break;case 4:o=this.drawDiamondMarker(i,n,r,t);break;default:o=this.drawSquareMarker(i,n,r,t)}o.attr(ji(e.dataPoint.key,"element")).attr("data-bn-index",String(e.index))}}getLabelPositionPriority(t){const i=this.dataPoints[t];let s=null;for(let i=t+1;i<this.dataPoints.length;i++)if(!this.dataPoints[i].dataPoint.isEmpty()){s=this.dataPoints[i];break}let e=null;for(let i=t-1;i>=0;i--)if(!this.dataPoints[i].dataPoint.isEmpty()){e=this.dataPoints[i];break}const n=i.dataPoint.getScaledUnit();return e&&s&&e.dataPoint.getScaledUnit()>n&&s.dataPoint.getScaledUnit()>n?[da.Below,da.Left,da.Right,da.Above]:[da.Above,da.Left,da.Right,da.Below]}getScenarioType(){var t,i;return(null===(i=null===(t=this.scenarioName)||void 0===t?void 0:t.slice(0,2))||void 0===i?void 0:i.toLowerCase())||"ac"}drawValueLabels(t,i){const s=this.getScenarioType();for(let e=0;e<this.dataPoints.length;e++){const n=this.dataPoints[e];if(n.dataPoint.isEmpty()||null===n.dataPoint.value)continue;const r=this.position.getColumnCenterPositionX(n.index),o=this.position.getColumnPositionY()-n.dataPoint.getScaledUnit();let h=r,a=o-this.MARKER_SIZE/2-2,l=na.Bottom,c=na.Center;if(this.collisionManager){const t=this.getLabelPositionPriority(e),i=this.collisionManager.getOptimalPlacement(r,o,this.ESTIMATED_LABEL_WIDTH,this.ESTIMATED_LABEL_HEIGHT,n.index,this.MARKER_SIZE,s,t);if(null===i)continue;h=i.labelX,a=i.labelY,l=i.verticalHook,c=i.horizontalHook;const u=Object.assign(Object.assign({},i.bounds),{scenarioType:s});this.collisionManager.register(u)}new ca(this.labelGroup,h,a,this.ID_LABEL_PREFIX,n.dataPoint.value,this.styles,l,c).setPoint(n.dataPoint.key).draw(!0,t,i)}}drawScenarioLabel(){if(!this.scenarioLabel)return;let t=null;for(let i=this.dataPoints.length-1;i>=0;i--)if(!this.dataPoints[i].dataPoint.isEmpty()){t=this.dataPoints[i];break}if(!t)return;const i=this.position.getColumnCenterPositionX(t.index)+this.MARKER_SIZE+4,s=this.position.getColumnPositionY()-t.dataPoint.getScaledUnit(),e=this.getScenarioType();if(this.collisionManager){if(this.collisionManager.shouldHideScenarioLabel(i,s,e))return;this.collisionManager.registerScenarioLabel(i,s,e)}new ca(this.labelGroup,i,s,"SCENARIO_LABEL",this.scenarioLabel,this.styles,na.Center,na.Left).forceStringTypeDraw()}}class hc{constructor(t,i,s,e,n,r,o,h,a,l,c){this.hasData=!1,this.position=t,this.styles=i,this.dataPoint=s,this.index=e,this.segment=n,this.segmentIndex=o,this.stackMode=h,this.stack=a,this.group=c,this.columnGroup=c.group().id(`stacked_col_${e}_seg_${o}`),!0!==(null==s?void 0:s.isEmpty())&&null!=s.value&&(this.hasData=!0)}draw(t={percent:2,decimal:1},i=new la){if(!this.hasData||!Number.isFinite(this.dataPoint.value))return;const s=this.dataPoint.value,e=this.dataPoint.pixelPerUnit,n=this.position.getColumnPositionY(),r=Math.abs(this.segment.end-this.segment.start)*e,o=n-Math.max(this.segment.start,this.segment.end)*e,h=this.position.getColumnCenterPositionX(this.index),a=this.position.getColumnWidth(),l=this.styles.stackColors,c=l[this.segmentIndex%l.length],u={color:c},d={color:c,width:.5};if(this.columnGroup.attr(ji(this.dataPoint.key,"element")),this.columnGroup.rect(a,Math.max(r,.5)).fill(u).stroke(d).y(o).cx(h),r>=18){const e=o+r/2;if(this.stackMode===Q.RELATIVE||this.stackMode===Q.ABSOLUTE_RELATIVE){const i=ra.number(this.segment.share,"percent",t.percent,t.percent,1,this.styles.locale);new ca(this.group,h,e,"STACK_SEG",i,this.styles,na.Center,na.Center).setSegmentFill(c).setPoint(this.dataPoint.key).forceStringTypeDraw()}else new ca(this.group,h,e,"STACK_SEG",s,this.styles,na.Center,na.Center).setSegmentFill(c).setPoint(this.dataPoint.key).draw(!0,t,i)}}drawTotalLabel(t={percent:2,decimal:1},i=new la,s){if(this.stackMode===Q.RELATIVE)return;const e=this.stack.total<0,n=e?0-this.stack.negative:this.stack.positive,r=this.position.getColumnCenterPositionX(this.index),o=this.position.getColumnDataLabelPositionY(n*this.dataPoint.pixelPerUnit);new ca(this.group,r,o,"STACK_TOTAL",this.stack.total,this.styles,e?na.Top:na.Bottom,na.Center).setPoint(s,"total").draw(!0,t,i)}}const ac={ac:{fill:"#000000",opacity:.3,lineColor:"#000000"},pp:{fill:"#999999",opacity:.3,lineColor:"#999999"},fc:{fill:"#000000",opacity:.2,lineColor:"#000000",dashArray:"4,4"},pl:{fill:"#000000",opacity:.1,lineColor:"#000000"}},lc=[{fill:"#000000",opacity:.3},{fill:"#555555",opacity:.25},{fill:"#999999",opacity:.2},{fill:"#bbbbbb",opacity:.15},{fill:"#dddddd",opacity:.1}];class cc{constructor(t,i,s,e,n,r){this.group=t.group().id(`area_fill_${n}`),this.upperPoints=i,this.lowerPoints=s,this.scenarioType=e,this.segmentIndex=n,this.isScenarioStack=r}draw(){if(this.upperPoints.length<2||this.lowerPoints.length<2)return;let t,i,s=`M ${this.upperPoints[0].x},${this.upperPoints[0].y}`;for(let t=1;t<this.upperPoints.length;t++)s+=` L ${this.upperPoints[t].x},${this.upperPoints[t].y}`;for(let t=this.lowerPoints.length-1;t>=0;t--)s+=` L ${this.lowerPoints[t].x},${this.lowerPoints[t].y}`;if(s+=" Z",this.isScenarioStack&&this.scenarioType){const s=this.scenarioType.slice(0,2).toLowerCase(),e=ac[s]||ac.ac;t=e.fill,i=e.opacity}else{const s=Math.min(this.segmentIndex,lc.length-1);t=lc[s].fill,i=lc[s].opacity}this.group.path(s).fill(t).opacity(i).stroke("none")}drawBoundaryLine(){if(this.upperPoints.length<2)return;let t,i="#000000";if(this.isScenarioStack&&this.scenarioType){const s=this.scenarioType.slice(0,2).toLowerCase(),e=ac[s]||ac.ac;i=e.lineColor,t=e.dashArray}const s=this.group.polyline(this.upperPoints.map((t=>[t.x,t.y]))).fill("none").stroke({color:i,width:1.5});t&&s.attr("stroke-dasharray",t)}}class uc{constructor(t,i,s,e,n,r,o,h){this.ID_DATA_PREFIX="DATA",this.ID_SCENARIO_PREFIX="SCENARIO",this.ID_RECT="RECT",this.FALLBACK_COLOUR="#000000",this.label=null,this.scenarioLabel=null,this.isVarianceLine=!1,this.dimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.previousDimensions={columnLength:0,xPos:0,yPos:0,labelYPos:0,scenarioLabelXPos:0,scenarioLabelYPos:0,clipped:!1},this.hasData=!1,this.dataPoint=s,this.index=n,this.isPrimaryLine=r,this.position=t,this.LineBarStyles=i.barStyles,this.scenarioGroup=o,this.styles=i,this.LineGroup=o.group().id(o.toString()+"_"+this.ID_RECT),!0!==(null==s?void 0:s.isEmpty())&&(this.hasData=!0,this.dimensions=this.createDimensions(s,n,r),this.label=this.getDataLabel(s),this.scenarioLabel=this.getScenarioLabel(h)),this.previousDimensions=this.createDimensions(e,n-1,r)}setAsVariance(){var t;return this.isVarianceLine=!0,null===(t=this.label)||void 0===t||t.setToVarianceLabel(),this}updateLabelGroup(t){var i;return this.isEmpty()||null===(i=this.label)||void 0===i||i.updateGroup(t),this}draw(t={percent:2,decimal:1},i=new la){if(this.isEmpty())return this;const s=this.getScenarioStyle(),e=this.getFillStyle(s);null!=this.LineGroup&&this.LineGroup.line([[this.previousDimensions.xPos,this.previousDimensions.yPos],[this.dimensions.xPos,this.dimensions.yPos]]).fill(e).stroke({color:"#f06",width:3,linecap:"round"}),this.drawLineDataLabel(t,i),this.drawScenarioLabel()}createDimensions(t,i,s){return{clipped:!1,columnLength:t.getScaledUnit(),xPos:this.position.getColumnPositionX(i,s),yPos:this.position.getColumnPositionY()-t.getScaledUnit(),labelYPos:this.position.getColumnDataLabelPositionY(t.getScaledUnit()),scenarioLabelXPos:this.position.getColumnPositionX(i,s)+this.position.getScenarioLabelPositionOffsetX(s),scenarioLabelYPos:this.position.getColumnPositionY()-t.getScaledUnit()}}getDataLabel(t){let i=na.Bottom;return null!=t.value&&t.value<0&&(i=na.Top),new ca(this.scenarioGroup,this.position.getColumnCenterPositionX(this.index),this.position.getColumnDataLabelPositionY(this.dataPoint.getScaledUnit()),this.ID_DATA_PREFIX,t.value,this.styles,i,na.Center)}getScenarioLabel(t){return new ca(this.scenarioGroup,0,0,this.ID_SCENARIO_PREFIX,t,this.styles,na.Bottom,na.Left)}convertToSVGStyle(t,i){return null==t&&(t=[]),t.color=t[i]||this.FALLBACK_COLOUR,Object.assign({},t)}drawScenarioLabel(){null==this.scenarioLabel||this.scenarioLabel.isEmpty()||this.isVarianceLine||this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos,this.dimensions.scenarioLabelYPos).draw(!0)}drawLineDataLabel(t,i=new la){var s;null===(s=this.label)||void 0===s||s.draw(this.isPrimaryLine,t,i)}getFillStyle(t){var i,s,e,n;const r=this.LineBarStyles[this.dataPoint.getScenario()];return(null==r?void 0:r.fillpattern)&&(null===(i=this.styles.pattern.get(r.fillpattern))||void 0===i?void 0:i.pattern)?null===(n=null===(e=null===(s=this.styles)||void 0===s?void 0:s.pattern)||void 0===e?void 0:e.get(r.fillpattern))||void 0===n?void 0:n.pattern:this.convertToSVGStyle(t,"fill")}getScenarioStyle(){var t;return this.isVarianceLine?null===(t=this.styles)||void 0===t?void 0:t.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle()):this.LineBarStyles[this.dataPoint.getScenario()]}isEmpty(){return!1===this.hasData||Number.isNaN(this.dataPoint.value)}}class dc{constructor(t,i,s,e,n){this.pixelPerUnit=1,this.collisionManager=null,this.overflowConfig=null,this.i18n=n;const r=i.group().id("Scenario1"),o=i.group().id("Scenario2").insertBefore(r);this.svgGroups={parent:i,scenario1:r,scenario2:o,scenario3:i.group().id("Scenario3"),scenario4:i.group().id("Scenario4"),scenario1Label:i.group().id("label")},this.styles=s,this.position=t,this.elementCnt=e}setOverflowConfig(t){this.overflowConfig=t}createLine(t,i,s,e){const n=this.svgGroups.scenario1.group().id(""+e),r=this.svgGroups.scenario1Label.group().id(""+e);let o=null;return this.isLastDataPoint(e-1)&&(o=t),new uc(this.position,this.styles,i,s,e,!1,n,o).updateLabelGroup(r)}createPrimaryBar(t,i){const s=this.svgGroups.scenario1.group().id(""+i),e=this.svgGroups.scenario1Label.group().id(""+i);let n=null;return this.isLastDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new sc(this.position,this.styles,t,i,!0,s,n,this.overflowConfig).updateLabelGroup(e)}createVarianceBar(t,i){const s=this.svgGroups.scenario1.group().id(""+i),e=this.svgGroups.scenario1Label.group().id(""+i);let n=null;return this.isLastDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new sc(this.position,this.styles,t,i,!0,s,n,this.overflowConfig).updateLabelGroup(e).setAsVariance()}createRelativeVarianceBar(t,i){const s=this.svgGroups.scenario1.group().id(""+i),e=this.svgGroups.scenario1Label.group().id(""+i);return new nc(this.position,this.styles,t,i,s).updateLabelGroup(e)}createSecondaryBar(t,i){const s=this.svgGroups.scenario2.group().id(""+i);let e=null;return this.isFirstDataPoint(i)&&(e=`${this.i18n.get(t.scenario)||t.scenario}`),new sc(this.position,this.styles,t,i,!1,s,e,this.overflowConfig)}createPrimaryMarker(t,i){const s=this.svgGroups.scenario3.group().id(""+i),e=this.styles.pattern.get("marker-right")||{foreground:"#000000",background:"#ffffff",bgOffset:0};let n=null;return this.isFirstDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new ec(this.position,s,e,t.scenario,this.styles,t,i,n,!0)}createSecondaryMarker(t,i){const s=this.svgGroups.scenario4.group().id(""+i),e=this.styles.pattern.get("marker-left")||{foreground:"#000000",background:"#ffffff",bgOffset:0};let n=null;return this.isLastDataPoint(i)&&(n=`${this.i18n.get(t.scenario)||t.scenario}`),new ec(this.position,s,e,t.scenario,this.styles,t,i,n,!1)}isLastDataPoint(t){return this.elementCnt-1===t}isFirstDataPoint(t){return 0===t}setCollisionManager(t){this.collisionManager=t}moveLabelsToFront(){this.svgGroups.scenario1Label.front()}createLineSeries(t,i,s){const e=this.svgGroups.parent.group().id("LineSeries_"+i),n=this.svgGroups.scenario1Label.group().id("LineSeries_Label_"+i),r=`${this.i18n.get(i)||i}`;return new oc(this.position,this.styles,t,e,n,i,r,this.i18n,this.collisionManager,s)}}const fc="bn-measurement-host";function vc(t,i){const s=function(){if("undefined"==typeof document||!document.body)return null;let t=document.getElementById(fc);return t||(t=document.createElement("div"),t.id=fc,t.style.cssText="opacity:0;position:absolute;left:-100%;top:-100%;overflow:hidden",t.setAttribute("aria-hidden","true"),document.body.appendChild(t)),t}();if(s){s.appendChild(t.node);try{i()}finally{t.node.parentNode===s&&s.removeChild(t.node)}}else i()}var pc,gc;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(pc||(pc={})),function(t){t.RELATIVE="dr",t.ABSOLUTE="d",t.NONE=""}(gc||(gc={}));class mc{constructor(t,i,s,e,n,r=0){this.CSS_CATEGORIES="categories",this.dataModel=[],this.variancesDataModel=[],this.title="",this.configTitle="",this.configVariances=[],this.smallestDataPointValue=new Xl(0,Zl.AC1,1,Zl.NEU),this.highestDataPointValue=new Xl(0,Zl.AC1,1,Zl.NEU),this.smallestVarianceDataPointValue=new Xl(0,Zl.AC1,1,Zl.NEU),this.highestVarianceDataPointValue=new Xl(0,Zl.AC1,1,Zl.NEU),this.pixelPerUnit=1,this.pixelPerPercentage=1,this.hideAxisLabels=!1,this.axisScenario=Zl.AC1,this.fromExpr="",this.rowCount=0,this.axisCategoryArea={width:0,height:0},this.scenariosArea={width:0,height:0},this.state=pc.DIRTY,this.i18n=new Map,this.leftSideOffsetForHorizontalSync=-1,this.dateInterval=ot.DAY,this.locale="de",this.axisLabelsMode=ht.SMART,this.intervalSpanLimit=32,this.measureScale=new la,this.measureUnit="",this.dataFormatDigits={percent:2,decimal:1},this.showOverlayMedian=!1,this.showOverlayAvg=!1,this.chartMode=at.BAR,this.maxBars=28,this.stackConfig=null,this.scenarioPropOrder=[],this.lineFullWidth=!0,this.availableWidth=0,this.overflowConfig=null,this.lastScenarios=[],this.db=i,this.tableName=s,this.ruleSet=t||new Cs,this.i18n=this.createI18n(new Map),this.styles=n,this.availableWidth=r,this.setConfig(e),this.position=this.createElementPosition(this.lastScenarios)}updatePosition(t){this.position=this.createElementPosition(t)}setStyles(t){this.styles=t}setRuleSet(t){this.ruleSet=t||new Cs}setAvailableWidth(t){this.availableWidth=t}setAvailableHeight(t){this.pixelPerUnit<=0||t<=0?this.overflowConfig=null:null==this.stackConfig&&this.determineEffectiveChartMode()===at.BAR?(this.overflowConfig=this.calculateOverflowConfig(t),this.overflowConfig&&this.updatePosition(this.lastScenarios)):this.overflowConfig=null}calculateOverflowConfig(t){const i=(this.isVarianceChart()?this.highestVarianceDataPointValue:this.highestDataPointValue).getScaledUnit();if(i<=0)return null;const s=this.styles.fontStyles.size,e=1.5*s,n=.3*s,r=t-(this.position.dataLabelHeight+this.position.spacings.labelToColumn+this.position.padding.top+this.position.padding.bottom+this.position.spacings.labelToAxis+s)-e-n,o=.8*s;if(r<=o)return null;const h=r-o;return i<=h?null:{cutHeight:r,overdriveZoneHeight:e,breakGap:n,maxOverflow:i-h,scenarioCutOffset:o}}setConfig(t){var i;this.state=pc.DIRTY,this.locale=t.locale,this.scenarioPropOrder=[...t.scenarios];const s=this.sortScenariosbyVisualisationRules(t.scenarios);if(this.setSource(t.filter),this.hideAxisLabels=t.hideAxisLabels||!1,this.pixelPerUnit=t.pixelPerUnit,this.pixelPerPercentage=t.pixelPerPercentage,this.axisLabelsMode=t.axisLabelsMode,this.intervalSpanLimit=t.intervalSpanLimit,this.dateInterval=this.findDateInterval(t.dateInterval),this.dataModel=this.populateModel(s,this.dateInterval),this.variancesDataModel=this.populateVarianceModel(t.variances,this.dataModel),this.configTitle=t.title,this.configVariances=null!==(i=null==t?void 0:t.variances)&&void 0!==i?i:[],this.updateTitle(),this.smallestDataPointValue=this.findSmallestDataPointValue(this.dataModel),this.smallestVarianceDataPointValue=this.findSmallestDataPointValue(this.variancesDataModel),this.highestDataPointValue=this.findHighestDataPointValue(this.dataModel),this.highestVarianceDataPointValue=this.findHighestDataPointValue(this.variancesDataModel),this.axisScenario=this.setAxisScenario(t.variances),this.leftSideOffsetForHorizontalSync=t.leftSideOffsetForHorizontalSync,this.measureScale=t.measureScale,this.measureUnit=t.measureUnit,this.dataFormatDigits=t.dataFormatDigits,this.showOverlayMedian=t.showOverlayMedian,this.showOverlayAvg=t.showOverlayAvg,this.chartMode=t.chartMode,this.maxBars=t.maxBars,this.stackConfig=t.stackConfig,this.lineFullWidth=t.lineFullWidth,this.lastScenarios=s,null!=this.stackConfig){const t=[];for(const i of this.dataModel)t.push(...this.stackGroups(i).map((t=>t.layout)));const i=Pl(t),{scenario:s,variance:e}=this.highestDataPointValue;this.highestDataPointValue=new Xl(i.positive,s,this.pixelPerUnit,e),this.smallestDataPointValue=new Xl(0-i.negative,s,this.pixelPerUnit,e)}this.updatePosition(s)}getFooter(){return 1===this.measureScale.value&&""===this.measureUnit?" ":ra.translateScenarioLabel("in",this.i18n)+" "+this.measureScale.prefix+this.measureUnit}sortScenariosbyVisualisationRules(t){const i=this;return[...t].sort(((t,s)=>i.ruleSet.getScenarioSorIndex(t)-i.ruleSet.getScenarioSorIndex(s))).reverse()}setI18n(t){this.i18n=this.createI18n(t),this.updateTitle()}updateTitle(){var t;this.title=this.configTitle||ra.translateScenarioLabel(null===(t=this.configVariances)||void 0===t?void 0:t.toString(),this.i18n)}setSource(t){var i,s;if(this.state=pc.DIRTY,this.queryError=void 0,this.fromExpr=$(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=ci(t))}getAllocatedCanvasWidth(){const t=this.position.getAxisEndPositionX(),i=3*this.styles.fontStyles.size,s=Math.max(this.axisCategoryArea.width,this.scenariosArea.width);return Math.max(t+i,s>0?s+this.position.leftSideLabelLength:0)}getAllocatedCanvasHeight(){if(null==this.smallestVarianceDataPointValue.value||null==this.highestVarianceDataPointValue.value||null==this.smallestDataPointValue.value||null==this.highestDataPointValue.value)return 0;const t=this.isVarianceChart()&&this.variancesDataModel.some((t=>t.type===gc.RELATIVE)),i=this.position.getAxisPositionY(t),s=this.position.spacings.labelToAxis+this.position.dataLabelHeight+this.styles.padding.bottom;let e;if(this.isOnSameAxisSide())e=i+s;else{const t=this.isVarianceChart()?this.smallestVarianceDataPointValue:this.smallestDataPointValue;e=i+Math.abs(t.getScaledUnit())+this.position.spacings.labelToColumn+this.position.dataLabelHeight+s}const n=this.isOnSameAxisSide();return Math.max(e,n?this.axisCategoryArea.height+this.scenariosArea.height:this.scenariosArea.height)}getUnitBarExtent(){var t,i;const s=this.isVarianceChart()&&this.variancesDataModel.some((t=>t.type===gc.RELATIVE)),e=this.isVarianceChart(),n=e?this.highestVarianceDataPointValue:this.highestDataPointValue,r=e?this.smallestVarianceDataPointValue:this.smallestDataPointValue;return Ll({relativeVariance:s,maxPositive:null!==(t=null==n?void 0:n.value)&&void 0!==t?t:0,minNegative:this.isOnSameAxisSide()?0:null!==(i=null==r?void 0:r.value)&&void 0!==i?i:0})}getPercentBarExtent(){var t,i,s,e;return El({relativeVariance:this.isVarianceChart()&&this.variancesDataModel.some((t=>t.type===gc.RELATIVE)),maxPositive:null!==(i=null===(t=this.highestVarianceDataPointValue)||void 0===t?void 0:t.value)&&void 0!==i?i:0,minNegative:this.isOnSameAxisSide()?0:null!==(e=null===(s=this.smallestVarianceDataPointValue)||void 0===s?void 0:s.value)&&void 0!==e?e:0})}layout(){const t=new uh;vc(t,(()=>this.draw(t)))}toString(){const t=new uh;return vc(t,(()=>this.draw(t))),t.id("drawCanvas"),t.width(this.getAllocatedCanvasWidth()),t.height(this.getAllocatedCanvasHeight()),t.attr("overflow","visible"),t.svg()}applyFontToContainer(t){t.attr({"font-size":this.styles.fontStyles.size,"font-family":this.styles.fontStyles.family})}draw(t){this.cleanSVGforRedraw(t),this.applyFontToContainer(t),this.state===pc.DIRTY&&(this.state=pc.UP_TO_DATE),this.isVarianceChart()?(this.drawVarianceScenario(this.variancesDataModel,t),this.drawAxisAndLabels(this.variancesDataModel,t)):null!=this.stackConfig?this.determineEffectiveChartMode()===at.LINE?(this.drawStackedAreaScenarios(this.dataModel,t),this.drawAxisAndLabelsForLineChart(this.dataModel,t)):(this.drawStackedScenarios(this.dataModel,t),this.drawStackedHeaders(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t)):this.determineEffectiveChartMode()===at.LINE?(this.drawLineScenarios(this.dataModel,t),this.drawAxisAndLabelsForLineChart(this.dataModel,t)):(this.drawScenarios(this.dataModel,t),this.drawOverlayLayer(this.dataModel,t),this.drawAxisAndLabels(this.dataModel,t))}determineEffectiveChartMode(){return this.chartMode===at.LINE||this.chartMode===at.AUTO&&this.dataModel.length>this.maxBars?at.LINE:at.BAR}setPattern(t,i){this.styles.pattern.set(t,i)}hasNoData(){return 0===this.dataModel.length}isOnSameAxisSide(){return null!=this.smallestVarianceDataPointValue.value&&null!=this.highestVarianceDataPointValue.value&&null!=this.smallestDataPointValue.value&&null!=this.highestDataPointValue.value&&(this.isVarianceChart()?Math.sign(this.smallestVarianceDataPointValue.value)===Math.sign(this.highestVarianceDataPointValue.value)||0===this.smallestDataPointValue.value&&1===Math.sign(this.highestDataPointValue.value):Math.sign(this.smallestDataPointValue.value)===Math.sign(this.highestDataPointValue.value)||0===this.smallestDataPointValue.value&&1===Math.sign(this.highestDataPointValue.value))}createI18n(t){this.state=pc.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])}createElementPosition(t){let i;const s=Qh(t.filter(((t,i)=>1===i||2===i)).map((t=>ra.translateScenarioLabel(t,this.i18n))).reduce(((t,i)=>t.length<i.length?i:t),""),{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width,e=this.calculateTitleLength(this.leftSideOffsetForHorizontalSync);let n,r;if(i=s>e?s:e,null!=this.position&&(i+=this.position.spacings.labelToColumn),this.leftSideOffsetForHorizontalSync>-1&&(i=this.leftSideOffsetForHorizontalSync),this.isVarianceChart()?(n=this.smallestVarianceDataPointValue,r=this.highestVarianceDataPointValue):(n=this.smallestDataPointValue,r=this.highestDataPointValue),this.overflowConfig){const{cutHeight:t,overdriveZoneHeight:i,breakGap:s}=this.overflowConfig;r=new Xl(t+i+s,r.scenario,1,r.variance)}let o=this.styles.scaleFactors;const h=this.determineEffectiveChartMode();if(this.lineFullWidth&&this.availableWidth>0&&this.dataModel.length>0&&!this.isVarianceChart()&&h===at.LINE){const t=this.styles.fontStyles.size,s=this.styles.padding,e=this.styles.scaleFactors,n=this.availableWidth-(s.left+s.right+t*e.scenarioOffset+i+t*e.columnWidth);if(n>0){const i=Math.max(n/this.dataModel.length/t,1.2*e.columnWidth),s=new jl;Object.assign(s,e),s.categoryWidth=i,o=s}}return new Yl(new Bl(this.styles.padding),o,this.styles.fontStyles,n,r,this.dataModel.length,i)}calculateTitleLength(t){let i="_______";i.length<this.title.length&&(i=this.title);const s=Qh(i,{font:this.styles.fontStyles.font,fontSize:this.styles.fontStyles.size+"px"}).width;return s<t?t:s}scenarioStyles(){const t=Es(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=Zl.AC1;if(null!=t&&t.length>0){const s=new ks(t.toString());s.isValid&&(i=Ls(this.ruleSet.getScenarioColorIndex(s.delta))+s.delta.slice(2))}return null===i&&(i=Zl.AC1),i}populateModel(t,i){if(0===this.rowCount||!this.fromExpr)return[];let s=this.queryDataSet(i,"","");return this.detectNaNCells(t,s),s=this.leftOuterJoinDates(s,i),this.createDataRows(s,t)}detectNaNCells(t,i){i.forEach((i=>(t.forEach((t=>{const s=new ks(t);!0===s.isValid?0!==i[s.base+"_cnt"]&&0!==i[s.delta+"_cnt"]||(i[t]=Number.NaN):0===i[t+"_cnt"]&&(i[t]=Number.NaN)})),i)))}findDateInterval(t){if(t!==ot.AUTO)return t;const i=this.queryDates();if(0===i.length)return ot.DAY;let s=i[0],e=i[0];for(const t of i)t<s&&(s=t),t>e&&(e=t);return(new lt).calculateDistanceType(s,e,this.intervalSpanLimit)}queryDates(){if(0===this.rowCount)return[];let t;try{t=this.db.exec(`SELECT DISTINCT [date] FROM ${this.fromExpr}`)}catch(t){return this.failQuery(t),[]}return t.map((t=>mc.coerceDateTime(t.date))).filter((t=>null!=t))}static coerceDateTime(t){if(null!=t){if("string"==typeof t){const i=y.fromISO(t,{zone:"utc"});return i.isValid?i:void 0}if("number"==typeof t){const i=y.fromMillis(t,{zone:"utc"});return i.isValid?i:void 0}return"boolean"==typeof t.isValid?t:void 0}}queryDataSet(t,i,s){const e=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],n=`normalizeDate([date], '${t}' , '${this.locale}') as calcdate`;let r;try{r=this.db.exec(`SELECT p.calcdate ${i},\n ${e.map((t=>`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`)).join(",")}\n\n FROM (SELECT ${n} ${i},\n ac1,\n ac2,\n ac3,\n ac4,\n pp1,\n pp2,\n pp3,\n pp4,\n fc1,\n fc2,\n fc3,\n fc4,\n pl1,\n pl2,\n pl3,\n pl4\n FROM ${this.fromExpr}) as p\n GROUP BY calcdate ${s}\n ORDER BY calcdate asc`)}catch(t){return this.failQuery(t),[]}return r}createDataRows(t,i){var s;const e=[];t.forEach(((t,s)=>{e.push({id:s,category:t.category,type:gc.NONE,date:t.calcdate,scenario1:new Xl(t[i[0]],i[0],this.pixelPerUnit,Zl.NEU),scenario2:new Xl(t[i[1]],i[1],this.pixelPerUnit,Zl.NEU),scenario3:new Xl(t[i[2]],i[2],this.pixelPerUnit,Zl.NEU),scenario4:new Xl(t[i[3]],i[3],this.pixelPerUnit,Zl.NEU)})}));for(const t of e)for(const i of[t.scenario1,t.scenario2,t.scenario3,t.scenario4])null==i.value||Number.isNaN(i.value)||(i.key={date:mc.pointDate(t.date),scenario:null!==(s=i.scenario)&&void 0!==s?s:void 0});return e}static pointDate(t){var i;return Yi(null===(i=null==t?void 0:t.toISO)||void 0===i?void 0:i.call(t))}findSmallestDataPointValue(t){const i=this.isVarianceChart()?this.pixelPerPercentage:this.pixelPerUnit;let s=new Xl(0,"default",i,Zl.NEU);for(const i of t)for(const t of[i.scenario1,i.scenario2,i.scenario3,i.scenario4])t&&null!=t.value&&t.value<Number(s.value)&&(s=t);return s}findHighestDataPointValue(t){const i=this.isVarianceChart()?this.pixelPerPercentage:this.pixelPerUnit;let s=new Xl(0,"default",i,Zl.NEU);for(const i of t)for(const t of[i.scenario1,i.scenario2,i.scenario3,i.scenario4])null!=t&&t.value>Number(s.value)&&(s=t);return s}populateVarianceModel(t,i){const s=[];if(null==t||0===t.length)return s;let e=null;null!=i&&i.length>0&&(e=i[0]);for(const n in t){const r=new ks(t[n]);if(r.isValid){const o=this.mapScenarios(r,e),h=r.direction,a="dr"===r.type?this.pixelPerPercentage:this.pixelPerUnit;for(const e in i){const l=new Xl(this.calculateVariance(r,i[e],o),r.delta,a,h);null===l.value||Number.isNaN(l.value)||(l.key={date:mc.pointDate(i[e].date),scenario:t[n]}),s.push({id:Number(e),category:i[e].category,type:"dr"===r.type?gc.RELATIVE:gc.ABSOLUTE,date:i[e].date,scenario1:l,scenario2:new Xl(null,null,null,null),scenario3:new Xl(null,null,null,null),scenario4:new Xl(null,null,null,null)})}}}return s}calculateVariance(t,i,s){const e=s.get(t.base),n=s.get(t.delta);return null==e||null==n||null==i[e].value||null==i[n].value?null:t.type===gc.RELATIVE?st(i[e].value-i[n].value,i[n].value):i[e].value-i[n].value}mapScenarios(t,i){const s=new Map;return null==i||["scenario1","scenario2","scenario3","scenario4"].forEach((e=>{i[e].scenario===t.delta?s.set(t.delta,e):i[e].scenario===t.base&&s.set(t.base,e)})),s}cleanSVGforRedraw(t){t.clear()}isVarianceChart(){return this.variancesDataModel&&this.variancesDataModel.length>0}createDateFactory(){const t=new lt;return t.setLocale(this.locale),t}dateLabelPlace(t){let i=t.scenario1.value<0,s=this.position.spacings.labelToAxis;if(null!=this.stackConfig&&!this.isVarianceChart()){const e=this.stackConfig.mode!==Q.RELATIVE&&this.determineEffectiveChartMode()!==at.LINE?(this.position.spacings.labelToColumn+this.position.dataLabelHeight)/this.pixelPerUnit:0,n=this.stackGroups(t).filter((t=>t.hasValue)).map((t=>t.layout));let r=Wl(n,(()=>e));r.flipped&&e>0&&n.some((t=>t.total>=0))&&(r={flipped:!1,clearance:Math.max(...n.map((t=>t.negative+(t.total<0?e:0))))}),i=r.flipped,s+=r.clearance*this.pixelPerUnit}return i?{hookLocation:na.Bottom,offset:-s}:{hookLocation:na.Top,offset:s}}drawAxisAndLabels(t,i){const s=this.createDateFactory(),e=i.group().id("AxisAndDateLables");let n=!1;if(!1===this.hideAxisLabels)t.forEach(((t,i)=>{const{hookLocation:r,offset:o}=this.dateLabelPlace(t);t.type===gc.RELATIVE&&(n=!0);let h=s.getDateString(t.date,this.dateInterval);this.axisLabelsMode===ht.SMART?(h=s.getSmartDateString(t.date,this.dateInterval),0===i&&this.dateInterval!==ot.YEAR&&(h=s.getShortDateString(t.date,this.dateInterval))):this.axisLabelsMode===ht.SHORT&&(h=s.getShortDateString(t.date,this.dateInterval)),new ca(e,this.position.getColumnCenterPositionX(i),this.position.getAxisPositionY(n)+o,"",h,this.styles,r,na.Center).forceStringTypeDraw()}));else{const i=null==t?void 0:t[0];i&&i.type===gc.RELATIVE&&(n=!0)}new ic({scenarioType:this.axisScenario,labelText:this.title,isRelative:n},this.position,e).draw();const r=e.bbox();this.axisCategoryArea={height:r.height,width:r.width}}drawScenarios(t,i){const s=i.group().id("Scenarios"),e=new dc(this.position,s,this.scenarioStyles(),t.length,this.i18n);e.setOverflowConfig(this.overflowConfig);let n=!1;t.forEach(((t,i)=>{e.createPrimaryBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale),e.createSecondaryBar(t.scenario2,i).draw(),e.createPrimaryMarker(t.scenario3,i).draw(),e.createSecondaryMarker(t.scenario4,i).draw(),!1===t.scenario1.isEmpty()&&(n=!0)}));let r=0;!1===n&&(r=this.isOnSameAxisSide()?this.position.dataLabelHeight:2*this.position.dataLabelHeight);const o=s.bbox();this.scenariosArea={height:o.height+this.styles.padding.top+this.styles.padding.bottom+r,width:o.width+this.position.spacings.columnWidth}}drawLineScenarios(t,i){var s,e;const n=i.group().id("LineScenarios"),r=new fa,o=new dc(this.position,n,this.scenarioStyles(),t.length,this.i18n);o.setCollisionManager(r);const h=["ac1","pp1","fc1","pl1"],a=[[],[],[],[]];t.forEach(((t,i)=>{["scenario1","scenario2","scenario3","scenario4"].forEach(((s,e)=>{t[s]&&a[e].push({dataPoint:t[s],index:i})}))}));const l=[];for(let t=0;t<a.length;t++){const i=a[t];if(i.length>0&&i.some((t=>!t.dataPoint.isEmpty()))){const n=(null===(e=null===(s=i[0])||void 0===s?void 0:s.dataPoint)||void 0===e?void 0:e.scenario)||h[t],r=n.slice(0,2).toLowerCase();l.push({points:i,scenarioName:n,scenarioType:r})}}l.sort(((t,i)=>(ua[i.scenarioType]||99)-(ua[t.scenarioType]||99)));const c=[];for(const t of l){const i=o.createLineSeries(t.points,t.scenarioName,Ls(this.ruleSet.getScenarioColorIndex(t.scenarioName)));c.push({series:i,scenarioType:t.scenarioType})}for(const t of c)t.series.drawGeometry();o.moveLabelsToFront();const u=[...c].sort(((t,i)=>(ua[t.scenarioType]||99)-(ua[i.scenarioType]||99)));for(const t of u)t.series.drawLabels(this.dataFormatDigits,this.measureScale);const d=this.position.getColumnPositionY(),f=n.bbox();this.scenariosArea={height:Math.max(f.height+this.styles.padding.top,d)+this.styles.padding.bottom,width:f.width+this.position.spacings.columnWidth}}drawAxisAndLabelsForLineChart(t,i){const s=this.createDateFactory(),e=i.group().id("AxisAndDateLabelsLine"),n=!1,r=t.length-1;!1===this.hideAxisLabels&&t.forEach(((i,o)=>{if(!this.shouldShowLineChartAxisLabel(t,o))return;const{hookLocation:h,offset:a}=this.dateLabelPlace(i);let l;this.lineFullWidth&&this.availableWidth>0?this.axisLabelsMode===ht.SMART?(l=s.getSmartDateString(i.date,this.dateInterval),0===o&&this.dateInterval!==ot.YEAR&&(l=s.getShortDateString(i.date,this.dateInterval))):l=this.axisLabelsMode===ht.SHORT?s.getShortDateString(i.date,this.dateInterval):s.getDateString(i.date,this.dateInterval):l=s.getShortDateString(i.date,this.dateInterval),new ca(e,this.position.getColumnCenterPositionX(o),this.position.getAxisPositionY(n)+a,"",l,this.styles,h,na.Center).forceStringTypeDraw(),o>0&&o<r&&this.isYearChange(t,o)&&this.drawYearSeparatorLine(e,o,n)})),new ic({scenarioType:this.axisScenario,labelText:this.title,isRelative:n},this.position,e).draw();const o=e.bbox();this.axisCategoryArea={height:o.height,width:o.width}}shouldShowLineChartAxisLabel(t,i){return!!(this.lineFullWidth&&this.availableWidth>0)||(0===i||i===t.length-1||this.isYearChange(t,i))}isYearChange(t,i){var s,e;if(0===i)return!1;const n=null===(s=t[i])||void 0===s?void 0:s.date,r=null===(e=t[i-1])||void 0===e?void 0:e.date;return!(!n||!r)&&(this.dateInterval===ot.WEEK?n.weekYear!==r.weekYear:n.year!==r.year)}drawYearSeparatorLine(t,i,s){const e=this.position.getColumnCenterPositionX(i)-this.position.spacings.columnWidth/2,n=this.position.columnValue.max.getScaledUnit()+this.position.dataLabelHeight,r=this.position.getAxisPositionY(s)-n,o=this.position.getAxisPositionY(s);t.line([[e,r],[e,o]]).stroke({color:"#999999",width:1,dasharray:"4,4"}).attr("stroke-dasharray","4,4")}drawVarianceScenario(t,i){const s=i.group().id("Scenarios"),e=new dc(this.position,s,this.scenarioStyles(),t.length,this.i18n);e.setOverflowConfig(this.overflowConfig),t.forEach(((t,i)=>{t.type===gc.RELATIVE?e.createRelativeVarianceBar(t.scenario1,i).draw():e.createVarianceBar(t.scenario1,i).draw(this.dataFormatDigits,this.measureScale)}));const n=s.bbox();return this.scenariosArea={height:n.height+this.styles.padding.top+this.styles.padding.bottom,width:n.width+this.position.spacings.columnWidth},s}sortSegmentsByPropOrder(t){if(0===this.scenarioPropOrder.length)return;const i=this.scenarioPropOrder;t.sort(((t,s)=>{const e=i.indexOf(t.scenario),n=i.indexOf(s.scenario);return(-1===e?i.length:e)-(-1===n?i.length:n)}))}stackGroups(t){if(!this.stackConfig)return[];const i=this.stackConfig.by===q.SCENARIOS,s=this.determineEffectiveChartMode()===at.LINE,e=[];for(const n of i||s?["scenario1","scenario2","scenario3","scenario4"]:["scenario1"]){const i=t[n];i&&!i.isEmpty()&&null!=i.value&&e.push({value:i.value,scenario:i.scenario,dataPoint:i})}if(0===e.length)return[];const n=this.stackConfig.mode===Q.RELATIVE?ct:0,r=(t,i)=>({prefix:t,segments:i,layout:Cl(i.map((t=>t.value)),n),hasValue:i.some((t=>Number.isFinite(t.value)))});if(i&&this.sortSegmentsByPropOrder(e),s)return[r("",e)];if(i){const t=new Map;for(const i of e){const s=ta(i.scenario);t.has(s)||t.set(s,[]),t.get(s).push(i)}if(t.size>1){const i=[];for(const s of Zh)t.has(s)&&(i.push(r(s,t.get(s))),t.delete(s));for(const[s,e]of t)i.push(r(s,e));return i}}const o=t=>Number.isFinite(t.value)?t.value:0;return"asc"===this.stackConfig.order?e.sort(((t,i)=>o(t)-o(i))):"desc"===this.stackConfig.order&&e.sort(((t,i)=>o(i)-o(t))),[r("",e)]}drawStackedScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedScenarios"),e=this.stackConfig.by===q.SCENARIOS;t.forEach(((t,i)=>{const n=this.stackGroups(t);n.forEach(((r,o)=>{let h=null;r.segments.forEach(((t,a)=>{const l=new hc(this.position,this.styles,t.dataPoint,i,r.layout.segments[a],t.scenario,n.length>1?n.length-1-o:a,this.stackConfig.mode,r.layout,e,s);l.draw(this.dataFormatDigits,this.measureScale),h=l})),h&&r.hasValue&&h.drawTotalLabel(this.dataFormatDigits,this.measureScale,{date:mc.pointDate(t.date),scenario:n.length>1?r.prefix:void 0})}))}));const n=s.bbox();this.scenariosArea={height:n.height+this.styles.padding.top+this.styles.padding.bottom,width:n.width+this.position.spacings.columnWidth}}drawStackedHeaders(t,i){if(!this.stackConfig||0===t.length)return;if(this.stackConfig.by!==q.SCENARIOS)return;const s=i.group().id("StackedHeaders"),e=this.stackGroups(t[0]);if(0===e.length)return;const n=this.position.getColumnPositionY(),r=this.position.getColumnCenterPositionX(0)-this.position.getColumnWidth()/2-this.position.spacings.labelToColumn,o=(t,i)=>{new ca(s,r,t,"STACK_HEADER",i,this.styles,na.Center,na.Right).forceStringTypeDraw()};if(e.length>1)return void e.forEach(((t,i)=>{const{positive:s,negative:r,total:h}=t.layout;o(n-(i===e.length-1?(s-r)/2:h<0?0-r:s)*t.segments[0].dataPoint.pixelPerUnit,this.i18n.get(t.prefix+"1")||t.prefix.toUpperCase())}));const[h]=e;h.segments.forEach(((t,i)=>{const{start:s,end:e}=h.layout.segments[i];o(n-(s+e)/2*t.dataPoint.pixelPerUnit,this.i18n.get(t.scenario)||t.scenario)}))}drawStackedAreaScenarios(t,i){if(!this.stackConfig)return;const s=i.group().id("StackedAreaScenarios"),e=this.stackConfig.by===q.SCENARIOS,n=this.stackConfig.mode,r=["scenario1","scenario2","scenario3","scenario4"];if(0===(e?r.filter((i=>t.some((t=>t[i]&&!t[i].isEmpty())))).length:1))return;const o=[],h=[];for(const i of r)t.some((t=>t[i]&&!t[i].isEmpty()))&&h.push(i);if(e&&this.scenarioPropOrder.length>0){const i=this.scenarioPropOrder;h.sort(((s,e)=>{var n,r,o,h;const a=i.indexOf(null!==(r=null===(n=t[0][s])||void 0===n?void 0:n.scenario)&&void 0!==r?r:""),l=i.indexOf(null!==(h=null===(o=t[0][e])||void 0===o?void 0:o.scenario)&&void 0!==h?h:"");return(-1===a?i.length:a)-(-1===l?i.length:l)}))}for(const i of h){const s=t[0][i];o.push((null==s?void 0:s.scenario)||"ac1")}const a=(t,i)=>{const s=t[i];return s&&!s.isEmpty()&&Number.isFinite(s.value)?s.value:0},l=h.map((i=>t.reduce(((t,s)=>t+a(s,i)),0)<0?-0:0)),c=n===Q.RELATIVE?ct:0,u=t.map((t=>Cl(h.map(((i,s)=>a(t,i)||l[s])),c))),d=this.position.getColumnPositionY(),f=this.pixelPerUnit,v=(t,i)=>u.map(((s,e)=>({x:this.position.getColumnCenterPositionX(e),y:d-s.segments[t][i]*f})));for(let t=0;t<h.length;t++){const i=v(t,"end"),n=v(t,"start"),r=e?Ls(this.ruleSet.getScenarioColorIndex(o[t])):null,h=new cc(s,i,n,r,t,e);h.draw(),h.drawBoundaryLine()}const p=s.bbox();this.scenariosArea={height:p.height+this.styles.padding.top+this.styles.padding.bottom,width:p.width+this.position.spacings.columnWidth}}drawOverlayLayer(t,i){if(0===t.length)return;const s=i.group().id("Overlay"),e=new dc(this.position,s,this.scenarioStyles(),t.length,this.i18n);if(!0===this.showOverlayAvg){let i=null;const s=function(t){const i=bc(t),s=i.length>0?i.reduce(((t,i)=>t+i),0)/i.length:NaN,e=Object.assign(Object.assign({},t[0]),{scenario1:new Xl(s,t[0].scenario1.scenario,t[0].scenario1.pixelPerUnit,t[0].scenario1.variance)}),n=Object.assign(Object.assign({},t[t.length-1]),{scenario1:new Xl(s,t[t.length-1].scenario1.scenario,t[t.length-1].scenario1.pixelPerUnit,t[t.length-1].scenario1.variance)});return[e,...t.map((t=>Object.assign(Object.assign({},t),{scenario1:new Xl(s,t.scenario1.scenario,t.scenario1.pixelPerUnit,t.scenario1.variance)}))),n]}(t);s.forEach(((t,s)=>{null!=i&&e.createLine(`Ø ${this.i18n.get(t.scenario1.scenario)||t.scenario1.scenario}`,t.scenario1,i,s-1).draw(this.dataFormatDigits,this.measureScale),i=t.scenario1}))}if(!0===this.showOverlayMedian){let i=null;const s=function(t){const i=bc(t).sort(((t,i)=>t-i)),s=i.length%2==0?(i[i.length/2-1]+i[i.length/2])/2:i[Math.floor(i.length/2)],e=Object.assign(Object.assign({},t[0]),{scenario1:new Xl(s,t[0].scenario1.scenario,t[0].scenario1.pixelPerUnit,t[0].scenario1.variance)}),n=Object.assign(Object.assign({},t[t.length-1]),{scenario1:new Xl(s,t[t.length-1].scenario1.scenario,t[t.length-1].scenario1.pixelPerUnit,t[t.length-1].scenario1.variance)});return[e,...t.map((t=>Object.assign(Object.assign({},t),{scenario1:new Xl(s,t.scenario1.scenario,t.scenario1.pixelPerUnit,t.scenario1.variance)}))),n]}(t);s.forEach(((t,s)=>{null!=i&&e.createLine(`Mdn ${this.i18n.get(t.scenario1.scenario)||t.scenario1.scenario}`,t.scenario1,i,s-1).draw(this.dataFormatDigits,this.measureScale),i=t.scenario1}))}}leftOuterJoinDates(t,i){const s=t.map((t=>t.calcdate)).filter((t=>null!=t&&"boolean"==typeof t.isValid&&t.isValid));if(0===s.length)return t;const e=y.max(...s),n=y.min(...s),r=new lt;if(r.countBetween(n,e,i)>1e4)return t;const o=r.datesBetween(n,e,i),h=new Map;return o.forEach(((t,i)=>{h.set(t.toISO(),{id:i,calcdate:t,category:null,ac1:null,ac2:null,ac3:null,ac4:null,pp1:null,pp2:null,pp3:null,pp4:null,fc1:null,fc2:null,fc3:null,fc4:null,pl1:null,pl2:null,pl3:null,pl4:null,isEmpty:!0})})),t.forEach((t=>{const i=t.calcdate.toISO(),s=h.get(i);s&&s.isEmpty&&h.set(i,{id:s.id,calcdate:t.calcdate,category:t.category,ac1:t.ac1,ac2:t.ac2,ac3:t.ac3,ac4:t.ac4,pp1:t.pp1,pp2:t.pp2,pp3:t.pp3,pp4:t.pp4,fc1:t.fc1,fc2:t.fc2,fc3:t.fc3,fc4:t.fc4,pl1:t.pl1,pl2:t.pl2,pl3:t.pl3,pl4:t.pl4,isEmpty:!1})})),Array.from(h.values())}}function bc(t){return t.map((t=>{var i;return null===(i=t.scenario1)||void 0===i?void 0:i.value})).filter((t=>Number.isFinite(t)))}class yc{constructor(t,i){this.data=t,this.scenarios=i,this.variances=[],this.title="",this.hideAxisLabels=!1,this.pixelPerUnit=10,this.pixelPerPercentage=50,this.leftSideOffsetForHorizontalSync=-1,this.dateInterval=ot.AUTO,this.axisLabelsMode=ht.SMART,this.intervalSpanLimit=28,this.filter="",this.measureScale=new la,this.measureUnit="",this.showMeasureScale=!0,this.dataFormatDigits={decimal:1,percent:2},this.showOverlayMedian=!0,this.showOverlayAvg=!0,this.chartMode=at.BAR,this.maxBars=28,this.stackConfig=null,this.lineFullWidth=!0,this.locale="de"}}class wc{constructor(t,i,s,e,n,r){this.dataRowAdapter=t,this.stringAdapter=i,this.dataFormatDigitsAdapter=s,this.db=e,this.fromExpr=n,this.onQueryError=r}adapt(t){const i=Z.adaptArray(t.data,this.dataRowAdapter),s=Z.adaptArray(t.scenarios,this.stringAdapter),e=new yc(i,s);return R.isArray(t.variances)&&(e.variances=Z.adaptArray(t.variances,this.stringAdapter)),R.isString(t.title)&&(e.title=t.title),R.isBoolean(t.hideAxisLabels)&&(e.hideAxisLabels=t.hideAxisLabels),R.isNumber(t.pixelPerUnit)&&(e.pixelPerUnit=t.pixelPerUnit),R.isNumber(t.pixelPerPercentage)&&(e.pixelPerPercentage=t.pixelPerPercentage),R.isExisting(t.dateInterval)&&(e.dateInterval=t.dateInterval),R.isExisting(t.axisLabelsMode)&&(e.axisLabelsMode=t.axisLabelsMode),R.isNumber(t.leftSideOffsetForHorizontalSync)&&(e.leftSideOffsetForHorizontalSync=t.leftSideOffsetForHorizontalSync),R.isNumber(t.intervalSpanLimit)&&(e.intervalSpanLimit=t.intervalSpanLimit),R.isString(t.filter)&&(e.filter=t.filter),R.isExisting(t.measureScale)&&(e.measureScale=ll.calculateMeasureScale(this.db,this.fromExpr,e.scenarios,t.measureScale,this.onQueryError)),R.isString(t.measureUnit)&&(e.measureUnit=t.measureUnit),R.isBoolean(t.showMeasureScale)&&(e.showMeasureScale=t.showMeasureScale),R.isExisting(t.dataFormatDigits)&&(e.dataFormatDigits=this.dataFormatDigitsAdapter.adapt(t.dataFormatDigits)),R.isBoolean(t.showOverlayAvg)&&(e.showOverlayAvg=t.showOverlayAvg),R.isBoolean(t.showOverlayMedian)&&(e.showOverlayMedian=t.showOverlayMedian),R.isExisting(t.chartMode)&&(e.chartMode=t.chartMode),R.isNumber(t.maxBars)&&(e.maxBars=t.maxBars),R.isExisting(t.stackConfig)&&(e.stackConfig=t.stackConfig),R.isBoolean(t.lineFullWidth)&&(e.lineFullWidth=t.lineFullWidth),R.isString(t.locale)&&(e.locale=t.locale),e}default(){return new yc([],[])}}const xc=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.scenarios=[],this.variances=[],this.hideAxisLabels=!1,this.pixelPerUnit=2,this.pixelPerPercentage=50,this.leftSideOffsetForHorizontalSync=-1,this.i18n=new Map,this.dateInterval=ot.AUTO,this.intervalSpanLimit=28,this.axisLabelsMode=ht.SMART,this.filter="",this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.showOverlayMedian=!1,this.showOverlayAvg=!1,this.chartMode=at.BAR,this.maxBars=28,this.stackConfig=null,this.lineFullWidth=!0,this.containerWidth=0,this.dataFormatDigits={percent:2,decimal:1},this.parentDimensions={width:0,height:0},a(this)}getDb(){return this.stores||(this.stores=c(this.element)),this.stores.db.db}render(){var t,e,n,r;if(void 0===this.chart||void 0!==this.queryError)return i(s,null);if(this.chart.hasNoData()){const e=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return i(s,{class:"no-data"},i("div",{class:"empty-state"},e))}return i(s,null,i("div",{innerHTML:null===(e=this.pattern)||void 0===e?void 0:e.toString(),class:"hidePatternContainer",style:{width:"0",height:"0",overflow:"hidden"}}),i("div",{class:this.showMeasureScale?"footer":"footer-hide"},null===(n=this.chart)||void 0===n?void 0:n.getFooter()),i("div",{innerHTML:null===(r=this.chart)||void 0===r?void 0:r.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(),ui(this.errors,this.queryError)}async componentWillLoad(){var t;const i=this.prepareConfig(),s=this.prepareStyle(),e=this.containerWidth||0;this.chart=new mc(new Cs(this.ruleSetConfig),this.getDb(),this.tableName,i,s,e),this.chart.setI18n(this.i18n);const n=i.pixelPerUnit<=0;this.autoFitScaling(i,s),this.chart.setAvailableHeight(n?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.height)||0),this.pattern=new Vl(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.setAvailableWidth(this.containerWidth||0),this.chart.setRuleSet(new Cs(this.ruleSetConfig)),this.chart.setConfig(i);const e=i.pixelPerUnit<=0;this.autoFitScaling(i,s),this.chart.setAvailableHeight(e?0:(null===(t=this.parentDimensions)||void 0===t?void 0:t.height)||0),this.pattern=new Vl(this.chart.styles),this.chart.setPattern("hatched",this.pattern.getFCPolygonPattern()),this.syncQueryError()}autoFitScaling(t,i){var s;const e=t.pixelPerUnit<=0,n=t.pixelPerPercentage<=0;if(!e&&!n)return;const r=()=>{var i;null===(i=this.reportAutoScaling)||void 0===i||i.call(this,{unit:e?t.pixelPerUnit:void 0,percentage:n?t.pixelPerPercentage:void 0})},o=null===(s=this.parentDimensions)||void 0===s?void 0:s.height,h=this.containerWidth||0,a=()=>{this.chart=new mc(new Cs(this.ruleSetConfig),this.getDb(),this.tableName,t,i,h),this.chart.setI18n(this.i18n)},l=()=>(this.chart.layout(),this.chart.getAllocatedCanvasHeight());if(!o||o<=0)return e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=50),a(),void r();e&&(t.pixelPerUnit=1),n&&(t.pixelPerPercentage=1),a();let c=l();if(c<=0)return void r();const u=Math.max(Nl,.9*o/c);let d=!1,f=!1,v=null;for(let i=0;i<=3;i++){const i=Tl({target:o,measured:c,unitExtent:e?this.chart.getUnitBarExtent():0,pctExtent:n?this.chart.getPercentBarExtent():0,currentPpu:t.pixelPerUnit,currentPpp:t.pixelPerPercentage});if(void 0===i.ppu&&void 0===i.ppp)break;if(e&&void 0!==i.ppu&&(t.pixelPerUnit=i.ppu,d=!0),n&&void 0!==i.ppp&&(t.pixelPerPercentage=i.ppp,f=!0),a(),c=l(),c<=o+.5&&(v={ppu:t.pixelPerUnit,ppp:t.pixelPerPercentage},c>=.98*o))break}let p=!1;if(e&&!d&&(t.pixelPerUnit=u,p=!0),n&&!f&&(t.pixelPerPercentage=u,p=!0),c>o+.5){if(v)d&&(t.pixelPerUnit=v.ppu),f&&(t.pixelPerPercentage=v.ppp);else{const i=o/c;e&&(t.pixelPerUnit=Math.max(Nl,t.pixelPerUnit*i)),n&&(t.pixelPerPercentage=Math.max(Nl,t.pixelPerPercentage*i))}p=!0}p&&a(),r()}async componentWillRender(){}componentDidLoad(){}componentDidUpdate(){}prepareConfig(){var t,i,s;const e=this.getDb(),n=$(e,this.tableName,this.filter);return this.measureScaleError=void 0,new wc(new ql,new cl,new Ul,e,n,(t=>{this.measureScaleError=ci(t)})).adapt({scenarios:this.scenarios,variances:this.variances,title:this.chartTitle,hideAxisLabels:this.hideAxisLabels,pixelPerUnit:this.pixelPerUnit,pixelPerPercentage:this.pixelPerPercentage,dateInterval:this.dateInterval,axisLabelsMode:this.axisLabelsMode,leftSideOffsetForHorizontalSync:this.leftSideOffsetForHorizontalSync,intervalSpanLimit:this.intervalSpanLimit,filter:this.filter,measureScale:this.measureScale,measureUnit:this.measureUnit,showMeasureScale:this.showMeasureScale,dataFormatDigits:this.dataFormatDigits,showOverlayMedian:this.showOverlayMedian,showOverlayAvg:this.showOverlayAvg,chartMode:this.chartMode,maxBars:this.maxBars,stackConfig:this.stackConfig,lineFullWidth:this.lineFullWidth,locale:(null===(s=null===(i=null===(t=this.stores)||void 0===t?void 0:t.context)||void 0===i?void 0:i.state)||void 0===s?void 0:s.locale)||"de"})}prepareStyle(){var t,i;const s=new Ql(new Il,new Ws,new Is(new Gs),new Ga(new Gs),new zs).adapt(this.styles);return s.locale=(null===(i=null===(t=c(this.element).context)||void 0===t?void 0:t.state)||void 0===i?void 0:i.locale)||"de",s}get element(){return e(this)}};xc.style=':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}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-default{stroke:black;stroke-width:0.1em}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}.hide{opacity:0}.footer{margin:0.2em;font-size:0.6em}.footer-hide{display:none}svg#drawCanvas{display:block}';const Sc=class{constructor(i){t(this,i),this.name="_default",a(this),this.errors=l(this),Qt(this,(t=>{this.stores||(this.stores=c(this.element));try{const i=JSON.parse(t);this.stores.componentStyles.set(this.name,i),this.errors.remove("ERR_body");const s=_(i);s.length>0?this.errors.addOrReplace({id:"ERR_keys",type:"error",message:`Unknown style keys, they are ignored: ${s.join(", ")}`}):this.errors.remove("ERR_keys")}catch(t){this.errors.addOrReplace({id:"ERR_body",type:"error",message:`bn-component-style: Failed to parse JSON body - ${t.message}`}),console.error(t)}}))}render(){return i(s,{key:"443fd52bc75e267b8699e29f754a15130f444315"})}get element(){return e(this)}};Sc.style="bn-component-style{display:none}";const $c={xga:[1024,768,"px"],hd:[1280,720,"px"],"full-hd":[1920,1080,"px"],"4k":[3840,2160,"px"],"4k2k":[4096,2160,"px"],a6:[4.13,5.83,"in"],a5:[5.83,8.27,"in"],a4:[8.27,11.69,"in"],a3:[11.69,16.54,"in"],a2:[16.54,23.39,"in"],a1:[23.39,33.11,"in"],a0:[33.11,46.81,"in"],letter:[8.5,11,"in"],legal:[8.5,14,"in"],tabloid:[11,17,"in"],ledger:[17,11,"in"]},Mc=Object.keys($c),_c=["landscape","portrait"];function Oc(t,i){const s=null!=t&&Mc.includes(t),[e,n,r]=$c[s?t:"xga"],o=e>=n?"landscape":"portrait",h=s&&_c.includes(null!=i?i:"")?i:o,[a,l]=h===o?[e,n]:[n,e];return{width:`${a}${r}`,height:`${l}${r}`,orientation:h}}function kc(t,i,s){const e=Oc(t,i),n=_c.includes(null!=s?s:"")&&s!==e.orientation;return n?{width:e.height,height:e.width,turned:n}:{width:e.width,height:e.height,turned:n}}function Ac(t,i,s){const{width:e,height:n}=kc(t,i,s);return`@page { size: ${e} ${n}; }`}const Rc=["format","orientation","page-format","page-orientation","render-orientation","page-number"],Nc=(t,i,s)=>{const e=t[i];return"string"==typeof e?e:i in t?null:t.getAttribute(s)},Lc=class{constructor(i){t(this,i),this.assignedPageNumbers=new WeakMap,a(this),this.errors=l(this)}setLocale(t){this.stores.context.state.locale=t}connectedCallback(){this.stores=O(this.element),this.locale&&(this.stores.context.state.locale=this.locale),this.syncPages(),this.pageObserver=new MutationObserver((()=>this.syncPages())),this.pageObserver.observe(this.element,{childList:!0,subtree:!0,attributes:!0,attributeFilter:Rc})}disconnectedCallback(){var t,i;null===(t=this.pageObserver)||void 0===t||t.disconnect(),null===(i=this.pageSizeStyle)||void 0===i||i.remove(),this.pageSizeStyle=void 0}syncPages(){const t=Array.from(this.element.querySelectorAll("bn-page, bn-layout-page"));t.forEach(((t,i)=>{const s="bn-layout-page"===t.localName?t:t.querySelector("bn-footer");if(!s)return;const e=Nc(s,"pageNumber","page-number");if(null!==e&&e!==this.assignedPageNumbers.get(s))return;const n=(i+1).toString();this.assignedPageNumbers.set(s,n),e!==n&&s.setAttribute("page-number",n)}));const i=this.element.getAttribute("render-orientation");void 0!==this.lastRenderOrientation&&this.lastRenderOrientation!==i&&t.filter((t=>"bn-layout-page"===t.localName)).forEach((t=>n(t))),this.lastRenderOrientation=i,this.writePageSize(t[0],i)}writePageSize(t,i){var s;if(!t||document.querySelector("bn-context")!==this.element)return null===(s=this.pageSizeStyle)||void 0===s||s.remove(),void(this.pageSizeStyle=void 0);const e="bn-layout-page"===t.localName?Ac(Nc(t,"pageFormat","page-format"),Nc(t,"pageOrientation","page-orientation"),i):Ac(Nc(t,"format","format"),Nc(t,"orientation","orientation"));this.pageSizeStyle||(this.pageSizeStyle=document.createElement("style"),this.pageSizeStyle.setAttribute("data-bn-page-size",""),document.head.append(this.pageSizeStyle)),this.pageSizeStyle.textContent!==e&&(this.pageSizeStyle.textContent=e)}async getLayoutState(t){var i,s;const e=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",n=Array.from(this.element.querySelectorAll("bn-annotation-layer, bn-annotation-list, bn-body, bn-card, bn-chart-bubble, bn-chart-bullet, bn-chart-scatter, bn-chart-structure, bn-chart-time, bn-footer, bn-grid, bn-image, bn-layout-card, bn-layout-page, bn-message, bn-page, bn-table, bn-text, bn-title, bn-tree"));await Promise.all(n.map((t=>{var i,s,e;return null!==(e=null===(s=(i=t).componentOnReady)||void 0===s?void 0:s.call(i))&&void 0!==e?e:Promise.resolve()})));const r=this.element.getBoundingClientRect(),o={x:r.left,y:r.top},h=await Promise.all(n.map((async t=>{const i=t.getBoundingClientRect(),s={context:o,component:{x:i.left,y:i.top}};try{const i=t;return"function"==typeof i.getLayoutState?await i.getLayoutState({detail:e}):Pi(t,s)}catch(i){let e;try{e=Pi(t,s)}catch(i){const s={x:0,y:0,width:0,height:0};e={version:li,tag:t.localName,id:t.localName,rect:{context:Object.assign({},s),component:Object.assign({},s)},em:{fontSizePx:0,appliedScaleFactor:1},regions:[],metadata:{},diagnostics:[]}}return e.error=String(i instanceof Error?i.message:i),e}}))),a=ni(n.map((t=>({tag:t.localName,explicitId:ri(t)}))));return h.forEach(((t,i)=>{t.id=a[i]})),{version:li,generatedAt:(new Date).toISOString(),detail:e,context:{viewport:oi(r),locale:null===(s=this.stores)||void 0===s?void 0:s.context.state.locale},components:h}}componentWillLoad(){}componentDidLoad(){}componentShouldUpdate(){}componentWillRender(){}componentDidRender(){}componentWillUpdate(){}componentDidUpdate(){}render(){return i(s,{key:"a50946d9cb100a1644a2c758af7854900826c5ce"},i("slot",{key:"c02525871433af7bb15f39c62c1417365a28d931"}))}get element(){return e(this)}static get watchers(){return{locale:[{setLocale:0}]}}};Lc.style=":host{display:block}";const Ec=["ac1","ac2","ac3","ac4","pp1","pp2","pp3","pp4","fc1","fc2","fc3","fc4","pl1","pl2","pl3","pl4"],Tc=["rowGroup","category","subCategory","columnGroup","columnSubGroup"];function Cc(t){return"number"==typeof t&&!isNaN(t)&&isFinite(t)}function Pc(t){const i=Array.from(t);return{distinctValues:i,count:i.length,hasData:i.length>0}}var Wc=Uint8Array,Dc=Uint16Array,zc=Int32Array,Uc=new Wc([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Fc=new Wc([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Gc=new Wc([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),jc=function(t,i){for(var s=new Dc(31),e=0;e<31;++e)s[e]=i+=1<<t[e-1];var n=new zc(s[30]);for(e=1;e<30;++e)for(var r=s[e];r<s[e+1];++r)n[r]=r-s[e]<<5|e;return{b:s,r:n}},Ic=jc(Uc,2),Yc=Ic.b,Bc=Ic.r;Yc[28]=258,Bc[258]=28;for(var Hc=jc(Fc,0).b,Vc=new Dc(32768),Xc=0;Xc<32768;++Xc){var Jc=(43690&Xc)>>1|(21845&Xc)<<1;Vc[Xc]=((65280&(Jc=(61680&(Jc=(52428&Jc)>>2|(13107&Jc)<<2))>>4|(3855&Jc)<<4))>>8|(255&Jc)<<8)>>1}var qc=function(t,i,s){for(var e=t.length,n=0,r=new Dc(i);n<e;++n)t[n]&&++r[t[n]-1];var o,h=new Dc(i);for(n=1;n<i;++n)h[n]=h[n-1]+r[n-1]<<1;if(s){o=new Dc(1<<i);var a=15-i;for(n=0;n<e;++n)if(t[n])for(var l=n<<4|t[n],c=i-t[n],u=h[t[n]-1]++<<c,d=u|(1<<c)-1;u<=d;++u)o[Vc[u]>>a]=l}else for(o=new Dc(e),n=0;n<e;++n)t[n]&&(o[n]=Vc[h[t[n]-1]++]>>15-t[n]);return o},Kc=new Wc(288);for(Xc=0;Xc<144;++Xc)Kc[Xc]=8;for(Xc=144;Xc<256;++Xc)Kc[Xc]=9;for(Xc=256;Xc<280;++Xc)Kc[Xc]=7;for(Xc=280;Xc<288;++Xc)Kc[Xc]=8;var Qc=new Wc(32);for(Xc=0;Xc<32;++Xc)Qc[Xc]=5;var Zc=qc(Kc,9,1),tu=qc(Qc,5,1),iu=function(t){for(var i=t[0],s=1;s<t.length;++s)t[s]>i&&(i=t[s]);return i},su=function(t,i,s){var e=i/8|0;return(t[e]|t[e+1]<<8)>>(7&i)&s},eu=function(t,i){var s=i/8|0;return(t[s]|t[s+1]<<8|t[s+2]<<16)>>(7&i)},nu=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ru=function(t,i,s){var e=new Error(i||nu[t]);if(e.code=t,Error.captureStackTrace&&Error.captureStackTrace(e,ru),!s)throw e;return e},ou=new Wc(0);function hu(t,i){var s,e,n=function(t){31==t[0]&&139==t[1]&&8==t[2]||ru(6,"invalid gzip data");var i=t[3],s=10;4&i&&(s+=2+(t[10]|t[11]<<8));for(var e=(i>>3&1)+(i>>4&1);e>0;e-=!t[s++]);return s+(2&i)}(t);return n+8>t.length&&ru(6,"invalid gzip data"),function(t,i,s,e){var n=t.length;if(!n||i.f&&!i.l)return s||new Wc(0);var r=!s,o=r||2!=i.i;r&&(s=new Wc(3*n));var h,a,l=function(t){var i=s.length;if(t>i){var e=new Wc(Math.max(2*i,t));e.set(s),s=e}},c=i.f||0,u=i.p||0,d=i.b||0,f=i.l,v=i.d,p=i.m,g=i.n,m=8*n;do{if(!f){c=su(t,u,1);var b=su(t,u+1,3);if(u+=3,!b){var y=t[(N=4+((u+7)/8|0))-4]|t[N-3]<<8,w=N+y;if(w>n){ru(0);break}o&&l(d+y),s.set(t.subarray(N,w),d),i.b=d+=y,i.p=u=8*w,i.f=c;continue}if(1==b)f=Zc,v=tu,p=9,g=5;else if(2==b){var x=su(t,u,31)+257,S=su(t,u+10,15)+4,$=x+su(t,u+5,31)+1;u+=14;for(var M=new Wc($),_=new Wc(19),O=0;O<S;++O)_[Gc[O]]=su(t,u+3*O,7);u+=3*S;var k=iu(_),A=(1<<k)-1,R=qc(_,k,1);for(O=0;O<$;){var N,L=R[su(t,u,A)];if(u+=15&L,(N=L>>4)<16)M[O++]=N;else{var E=0,T=0;for(16==N?(T=3+su(t,u,3),u+=2,E=M[O-1]):17==N?(T=3+su(t,u,7),u+=3):18==N&&(T=11+su(t,u,127),u+=7);T--;)M[O++]=E}}var C=M.subarray(0,x),P=M.subarray(x);p=iu(C),g=iu(P),f=qc(C,p,1),v=qc(P,g,1)}else ru(1);if(u>m){ru(0);break}}o&&l(d+131072);for(var W=(1<<p)-1,D=(1<<g)-1,z=u;;z=u){var U=(E=f[eu(t,u)&W])>>4;if((u+=15&E)>m){ru(0);break}if(E||ru(2),U<256)s[d++]=U;else{if(256==U){z=u,f=null;break}var F=U-254;U>264&&(F=su(t,u,(1<<(I=Uc[O=U-257]))-1)+Yc[O],u+=I);var G=v[eu(t,u)&D],j=G>>4;if(G||ru(3),u+=15&G,P=Hc[j],j>3){var I=Fc[j];P+=eu(t,u)&(1<<I)-1,u+=I}if(u>m){ru(0);break}o&&l(d+131072);var Y=d+F;if(d<P){var B=0-P,H=Math.min(P,Y);for(B+d<0&&ru(3);d<H;++d)s[d]=e[B+d]}for(;d<Y;++d)s[d]=s[d-P]}}i.l=f,i.p=z,i.b=d,i.f=c,f&&(c=1,i.m=p,i.d=v,i.n=g)}while(!c);return d!=s.length&&r?(h=s,(null==(a=d)||a>h.length)&&(a=h.length),new Wc(h.subarray(0,a))):s.subarray(0,d)}(t.subarray(n,-8),{i:2},new Wc(((s=t)[(e=s.length)-4]|s[e-3]<<8|s[e-2]<<16|s[e-1]<<24)>>>0),i)}var au="undefined"!=typeof TextDecoder&&new TextDecoder;try{au.decode(ou,{stream:!0})}catch(t){}function lu(t){return ut(t)}function cu(t){const i=t.indexOf(":");if(-1===i)throw new Error("Invalid compressed format: missing ':' separator");const s=t.slice(0,i),e=t.slice(i+1),n=atob(e),r=new Uint8Array(n.length);for(let t=0;t<n.length;t++)r[t]=n.charCodeAt(t);const o=hu(r);return{hash:s,json:(new TextDecoder).decode(o)}}const uu=class{constructor(i){t(this,i),this.datasources="",this.static=!1,this.raw=!0,this.refreshInterval=0,this.lastBodyHash=null,this.lastViewQuery=null,this.nameShared=!1,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,this.firstLoadPending=!1,this.onNameShared=t=>{const i=this.nameShared;this.nameShared=t,t?this.errors.addOrReplace({id:"ERR_name",type:"error",message:`name: "${this.name}" is used by more than one dataset or datasource.`}):(this.errors.remove("ERR_name"),i&&this.reload())},this.holdStatus=a(this),this.errors=l(this),((t,i)=>{let s,n=[],r=[];const o=t=>{let e;try{e=s.db.db.exec(`SELECT * FROM \`${t}\``)}catch(t){e=[]}i()},h=()=>{n.forEach((t=>t())),n=[],r.forEach((t=>{t&&(n.push(s.db.subscribe(t,(()=>o(t)))),o(t))}))},a=new MutationObserver((i=>{i.forEach((i=>{"datasources"===i.attributeName&&(r=(e(t).getAttribute("datasources")||"").split(","),h())}))})),l=t.connectedCallback;t.connectedCallback=()=>{const i=e(t);s=c(i),r=(i.getAttribute("datasources")||"").split(","),h(),a.observe(i,{attributes:!0,attributeFilter:["datasources"]}),d(l,t)};const u=t.disconnectedCallback;t.disconnectedCallback=()=>{a.disconnect(),n.forEach((t=>t())),n=[],f(e(t)),d(u,t)}})(this,(()=>{this.executeQuery()})),Qt(this,(t=>this.sync(t)))}sync(t){if(this.stores=c(this.element),!this.releaseName&&this.name&&(this.releaseName=this.stores.db.claim(this.name,this.onNameShared)),this.src){if(this.src===this.currentUrl)return;return this.currentUrl=this.src,this.lastBodyHash=null,this.query="",this.errors.remove("ERR_sql"),this.errors.remove("ERR_body"),this.firstLoadPending=!0,this.holdStatus(this.fetchAndStore(this.src)),void this.startPolling()}let i,s;if(null!==this.currentUrl&&(this.cancelInFlight(),this.currentUrl=null),this.errors.remove("ERR_src"),!this.raw&&this.static&&""!==t.trim())try{const e=cu(t);i=e.hash,s=e.json}catch(t){return this.errors.addOrReplace({id:"ERR_body",type:"error",message:`Body: ${ci(t)}`}),void(this.lastBodyHash=null)}else i=lu(t),s=t;i!==this.lastBodyHash&&(this.lastBodyHash=i,this.errors.remove("ERR_body"),this.query=s,this.executeQuery())}executeQuery(){var t,i;if(this.stores||(this.stores=c(this.element)),this.query||this.errors.remove("ERR_sql"),!this.name)return;if(!(this.query||this.static&&null===this.currentUrl))return;const s=this.stores.db.db;let e;if(this.static){try{e=""===this.query.trim()?[]:null!==(t=JSON.parse(this.query))&&void 0!==t?t:[],Array.isArray(e)?this.errors.remove("ERR_body"):this.errors.addOrReplace({id:"ERR_body",type:"error",message:"Body: not a JSON array."})}catch(t){this.errors.addOrReplace({id:"ERR_body",type:"error",message:`Body: ${ci(t)}`}),e=[]}s.tables[this.name]={data:Array.isArray(e)?e:[]},this.registered=s.tables[this.name],this.dropViewStatements(),this.errors.remove("ERR_sql")}else{if(this.lastViewQuery!==this.query){try{s.exec(`DROP VIEW \`${this.name}\``)}catch(t){}null!=s.tables[this.name]&&delete s.tables[this.name],s.views&&null!=s.views[this.name]&&delete s.views[this.name];try{if(v(this.query))throw new Error("double backticks are not allowed.");s.exec(`CREATE VIEW \`${this.name}\` AS ${this.query}`),this.registered=s.tables[this.name],s.resetSqlCache(),this.lastViewQuery=this.query}catch(t){return console.error("bn-dataset: failed to register SQL view",t,this.query),this.errors.addOrReplace({id:"ERR_sql",type:"error",message:`SQL: ${t instanceof Error?t.message:t}`}),s.resetSqlCache(),this.lastViewQuery=null,e=[],void this.publish(e)}}else null===(i=s.tables[this.name])||void 0===i||delete i.select;try{e=s.exec(`SELECT * FROM \`${this.name}\``),this.errors.remove("ERR_sql")}catch(t){if(void 0===this.latestResult)return;return this.errors.addOrReplace({id:"ERR_sql",type:"error",message:`SQL: ${t instanceof Error?t.message:t}`}),void this.publish([])}}this.publish(e)}publish(t){this.latestResult!==t?(this.latestResult=t,this.stores.db.notify(this.name),this.publishedMeta=function(t){const i={};for(const t of Tc)i[t]=new Set;const s={};for(const t of Ec)s[t]={hasData:!1,min:null,max:null};const e=new Set;let n=null,r=null;const o=Array.isArray(t)?t:[];for(let t=0;t<o.length;t++){const h=o[t];if(null==h)continue;for(const t of Tc){const s=h[t];null!=s&&""!==s&&i[t].add(String(s))}for(const t of Ec){const i=h[t];if(Cc(i)){const e=s[t];e.hasData=!0,(null===e.min||i<e.min)&&(e.min=i),(null===e.max||i>e.max)&&(e.max=i)}}const a=h.date;if(null!=a&&""!==a){const t=String(a);e.add(t),(null===n||t<n)&&(n=t),(null===r||t>r)&&(r=t)}}const h=Ec.map((t=>({key:t,hasData:s[t].hasData,min:s[t].min,max:s[t].max}))),a=h.filter((t=>t.hasData)).map((t=>t.key)),l=Pc(i.rowGroup),c=Pc(i.category),u=Pc(i.subCategory),d=Pc(i.columnGroup),f=Pc(i.columnSubGroup),v={min:n,max:r,hasData:e.size>0,distinctCount:e.size};let p="category";return u.hasData?p="subCategory":c.hasData?p="category":l.hasData&&(p="rowGroup"),{rowCount:o.length,scenarios:h,availableScenarios:a,rowGroup:l,category:c,subCategory:u,columnGroup:d,columnSubGroup:f,dateRange:v,suggestedLevel:p,suggestedOrder:p,suggestedDateInterval:v.hasData?"auto":null,calculatedAt:Date.now()}}(t),this.stores.datasetsMeta.set(this.name,this.publishedMeta)):this.stores.db.notify(this.name)}nameUpdated(t,i){var s;this.unregister(i),this.name&&this.element.isConnected&&this.sync(null!==(s=this.element.textContent)&&void 0!==s?s:"")}onIntervalChange(){this.currentUrl&&this.startPolling()}onSrcChange(){var t;this.element.isConnected&&this.sync(null!==(t=this.element.textContent)&&void 0!==t?t:"")}disconnectedCallback(){this.cancelInFlight(),this.unregister(this.name)}unregister(t){var i,s,e;const n=null===(s=null===(i=this.stores)||void 0===i?void 0:i.db)||void 0===s?void 0:s.db;n&&null!==this.lastViewQuery&&n.resetSqlCache(),null===(e=this.releaseName)||void 0===e||e.call(this),this.releaseName=void 0;const r=null!=(null==n?void 0:n.tables[t])&&n.tables[t]!==this.registered;if(r&&void 0!==this.publishedMeta&&this.stores.datasetsMeta.get(t)===this.publishedMeta&&this.stores.datasetsMeta.set(t,null),this.publishedMeta=void 0,this.registered=void 0,this.lastBodyHash=null,this.lastViewQuery=null,this.currentUrl=null,this.latestResult=void 0,n&&t&&!r){try{n.exec(`DROP VIEW \`${t}\``)}catch(t){}null!=n.tables[t]&&delete n.tables[t],n.views&&null!=n.views[t]&&delete n.views[t],this.stores.datasetsMeta.set(t,null),this.stores.db.notify(t)}}async fetchAndStore(t){var i,s;null===(i=this.abortController)||void 0===i||i.abort(),this.abortController=new AbortController,this.stores||(this.stores=c(this.element));try{const i=await fetch(t,{signal:this.abortController.signal});if(!i.ok)throw new Error(`HTTP ${i.status}`);const e=null!==(s=await i.json())&&void 0!==s?s:[];if(!Array.isArray(e))throw new Error("not a JSON array.");const n=this.stores.db.db;n.tables[this.name]={data:e},this.registered=n.tables[this.name],this.dropViewStatements(),this.errors.remove("ERR_src"),this.publish(e)}catch(t){if(t instanceof DOMException&&"AbortError"===t.name)return;this.errors.addOrReplace({id:"ERR_src",type:"error",message:`src: ${ci(t)}`});const i=this.stores.db.db;i.tables[this.name]={data:[]},this.registered=i.tables[this.name],this.dropViewStatements(),this.publish([])}this.firstLoadPending=!1}reload(){var t;null!==this.lastViewQuery&&this.stores.db.db.resetSqlCache(),this.lastBodyHash=null,this.lastViewQuery=null,this.currentUrl=null,this.latestResult=void 0,this.sync(null!==(t=this.element.textContent)&&void 0!==t?t:"")}dropViewStatements(){null!==this.lastViewQuery&&this.stores.db.db.resetSqlCache(),this.lastViewQuery=null}clearPollTimer(){null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null)}cancelInFlight(){var t;this.clearPollTimer(),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPollTimer(),this.currentUrl&&this.refreshInterval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&!this.firstLoadPending&&this.fetchAndStore(this.currentUrl)}),1e3*this.refreshInterval))}render(){return i(s,{key:"9a491c13d9ad8fba5da3c30f502a027a5ae1c606"})}get element(){return e(this)}static get watchers(){return{name:[{nameUpdated:0}],refreshInterval:[{onIntervalChange:0}],src:[{onSrcChange:0}]}}};uu.style="bn-dataset{display:none}";const du=class{constructor(i){t(this,i),this.raw=!0,this.refreshInterval=0,this.lastHash=null,this.nameShared=!1,this.currentUrl=null,this.pollTimerId=null,this.abortController=null,this.firstLoadPending=!1,this.onNameShared=t=>{const i=this.nameShared;this.nameShared=t,t?this.errors.addOrReplace({id:"ERR_name",type:"error",message:`name: "${this.name}" is used by more than one dataset or datasource.`}):(this.errors.remove("ERR_name"),i&&this.reload())},this.holdStatus=a(this),this.errors=l(this),Qt(this,(t=>this.sync(t)))}sync(t){var i;if(this.stores=c(this.element),!this.releaseName&&this.name&&(this.releaseName=this.stores.db.claim(this.name,this.onNameShared)),this.src){if(this.src===this.currentUrl)return;return this.currentUrl=this.src,this.lastHash=null,this.errors.remove("ERR_body"),this.firstLoadPending=!0,this.holdStatus(this.fetchAndStore(this.src)),void this.startPolling()}null!==this.currentUrl&&(this.cancelInFlight(),this.currentUrl=null),this.errors.remove("ERR_src");try{let s,e;if(this.raw||""===t.trim())s=lu(t),e=t;else{const i=cu(t);s=i.hash,e=i.json}if(s===this.lastHash)return;this.lastHash=s;const n=""===e.trim()?[]:null!==(i=JSON.parse(e))&&void 0!==i?i:[];Array.isArray(n)?this.errors.remove("ERR_body"):this.errors.addOrReplace({id:"ERR_body",type:"error",message:"Body: not a JSON array."}),this.publish(n)}catch(t){this.lastHash=null,this.errors.addOrReplace({id:"ERR_body",type:"error",message:`Body: ${ci(t)}`}),this.publish([])}}reload(){var t;this.lastHash=null,this.currentUrl=null,this.sync(null!==(t=this.element.textContent)&&void 0!==t?t:"")}publish(t){const i=this.stores.db.db;i.tables[this.name]={data:Array.isArray(t)?t:[]},this.registered=i.tables[this.name],this.stores.db.notify(this.name)}onIntervalChange(){this.currentUrl&&this.startPolling()}onSrcChange(){var t;this.element.isConnected&&this.sync(null!==(t=this.element.textContent)&&void 0!==t?t:"")}nameUpdated(t,i){var s;this.unregister(i),this.name&&this.element.isConnected&&this.sync(null!==(s=this.element.textContent)&&void 0!==s?s:"")}disconnectedCallback(){this.cancelInFlight(),this.unregister(this.name),f(this.element)}unregister(t){var i,s,e;null===(i=this.releaseName)||void 0===i||i.call(this),this.releaseName=void 0,this.lastHash=null,this.currentUrl=null;const n=null===(e=null===(s=this.stores)||void 0===s?void 0:s.db)||void 0===e?void 0:e.db,r=null!=(null==n?void 0:n.tables[t])&&n.tables[t]!==this.registered;this.registered=void 0,n&&t&&!r&&(null!=n.tables[t]&&delete n.tables[t],n.views&&null!=n.views[t]&&delete n.views[t],this.stores.db.notify(t))}async fetchAndStore(t){var i,s;null===(i=this.abortController)||void 0===i||i.abort(),this.abortController=new AbortController,this.stores||(this.stores=c(this.element));try{const i=await fetch(t,{signal:this.abortController.signal});if(!i.ok)throw new Error(`HTTP ${i.status}`);const e=null!==(s=await i.json())&&void 0!==s?s:[];if(!Array.isArray(e))throw new Error("not a JSON array.");this.errors.remove("ERR_src"),this.publish(e)}catch(t){if(t instanceof DOMException&&"AbortError"===t.name)return;this.errors.addOrReplace({id:"ERR_src",type:"error",message:`src: ${ci(t)}`}),this.publish([])}this.firstLoadPending=!1}clearPollTimer(){null!==this.pollTimerId&&(clearInterval(this.pollTimerId),this.pollTimerId=null)}cancelInFlight(){var t;this.clearPollTimer(),null===(t=this.abortController)||void 0===t||t.abort(),this.abortController=null}startPolling(){this.clearPollTimer(),this.currentUrl&&this.refreshInterval>0&&(this.pollTimerId=setInterval((()=>{this.currentUrl&&!this.firstLoadPending&&this.fetchAndStore(this.currentUrl)}),1e3*this.refreshInterval))}render(){return i(s,{key:"323018b2b642f9905874f94010c75b19bebde639"})}get element(){return e(this)}static get watchers(){return{refreshInterval:[{onIntervalChange:0}],src:[{onSrcChange:0}],name:[{nameUpdated:0}]}}};du.style="bn-datasource{display:none}";const fu=class{constructor(i){t(this,i),this.pageNumber=null,this.displayPageNumber=!0,a(this),this.errors=l(this),this.componentStyle=k(this)}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){return i(s,{key:"af4dda021b22094c4c55e25eb34da67dc1a8e41d",id:this.displayPageNumber||this.text?"container-page-footer":"container",style:this.getFontStyles()},i("div",{key:"f059b4ca265505730e9e384704d3b74579e3af9f",id:"footer-text"},null!=this.text?i("span",{class:"note"},this.text):""),i("div",{key:"0c00b17953457763640c4ebad3e0eb99ea742bfd",id:"page-number"},this.displayPageNumber?i("span",{class:"page"},this.pageNumber):""))}get element(){return e(this)}};fu.style=':host{padding:0.2em 0.5em;display:flex;flex-direction:row;justify-content:space-between;gap:1em;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}:host(#container-page-footer){box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em solid #ddd}div#footer-text{font-size:0.6em;display:inline}div#page-number{font-size:0.6em;display:inline}';const vu=new Map([["split-vertical",'"a b"'],["split-horizontal",'"a" "b"'],["2x2",'"a b" "c d"'],["3x3",'"a b c" "d e f" "g h i"'],["4x4",'"a b c d" "e f g h" "i j k l" "m n o p"'],["1-over-2",'"a a" "b c"'],["2-over-1",'"a b" "c c"'],["1-over-3",'"a a a " "b c d"'],["3-over-1",'"a b c" "d d d"']]),pu="custom-template",gu=/"[\w\d\s.]+"|'[\w\d\s.]+'/g,mu=/"[^"]*"|'[^']*'/g;function bu(t){var i;return(null!==(i=null==t?void 0:t.match(gu))&&void 0!==i?i:[]).map((t=>t.slice(1,-1).split(/\s+/).filter((t=>""!==t)))).filter((t=>t.length>0))}function yu(t,i){var s;return t===pu?bu(i).length>0?i:'"a"':null!==(s=vu.get(t))&&void 0!==s?s:'"a"'}function wu(t){var i;const s=(null===(i=bu(t)[0])||void 0===i?void 0:i.length)||1;return Array(s).fill("minmax(0, 1fr)").join(" ")}function xu(t){var i;return Array.from(new Set(null!==(i=null==t?void 0:t.match(/\b\w+\b/g))&&void 0!==i?i:[]))}function Su(t){var i;const s=bu(t);if(0===s.length)return'no row found, the layout is drawn as a single cell. Write one quoted row per grid row, e.g. \'"a a" "b c"\'.';const e=null!==(i=null==t?void 0:t.match(mu))&&void 0!==i?i:[];return e.some((t=>""===t.slice(1,-1).trim()))?"a pair of quotes holds no cell, so the browser ignores the template.":e.length!==s.length?"a row cannot be read. Use only letters, digits, '_' and '.' in a cell name, and open and close every row with the same kind of quote.":s.some((t=>t.length!==s[0].length))?"the rows have different numbers of cells, so the browser ignores the template.":void 0}const $u=class{constructor(i){t(this,i),this.titleImage="",this.titleBusinessUnit="",this.titleOrder="category",this.titleOrderDirection="asc",this.titleDateFormat="none",this.titleDateLink="none",this.footerText="",this.cardLayout="full",this.cardCustomTemplate='"a b" "c d"',this.cardGridGap="0",this.cardFitToContent=!1,this.cardShowBorder=!0,a(this),this.errors=l(this),this.resolveInherited=qt(this,[{propName:"titleScenarios",ancestorAttr:"title-scenarios"},{propName:"titleVariances",ancestorAttr:"title-variances"},{propName:"titleOrder",ancestorAttr:"title-order"},{propName:"titleOrderDirection",ancestorAttr:"title-order-direction"},{propName:"ruleset",ancestorAttr:"ruleset"}])}connectedCallback(){this.stores=c(this.element)}getCommonStyles(){let t="100%";return!0===this.cardFitToContent&&(t="fit-content"),{display:"grid",height:t,width:"100%",gap:this.cardGridGap+"px"}}getGridTemplateColumns(t){return wu(this.getTemplatePattern(t))}getRowCount(t){return bu(this.getTemplatePattern(t)).length||1}getGridTemplateRows(t){const i=this.getRowCount(t);return this.cardFitToContent?Array(i).fill("auto").join(" "):Array(i).fill("minmax(0, 1fr)").join(" ")}getLayoutStyle(){return Object.assign(Object.assign({},this.getCommonStyles()),{"grid-template-areas":this.getTemplatePattern(this.cardLayout),"grid-template-columns":this.getGridTemplateColumns(this.cardLayout),"grid-template-rows":this.getGridTemplateRows(this.cardLayout)})}createDivAreaStyles(t){return t.map((t=>({display:"flex",overflow:"hidden","grid-area":t})))}getSlots(t){const s=this.createDivAreaStyles(t);return i(o,null,s.map(((t,s)=>i("div",{style:t},i("slot",{name:"card-slot-"+s})))))}extractSlotNames(t){return xu(t)}getTemplatePattern(t){return yu(t,this.cardCustomTemplate)}componentWillRender(){const t=this.cardLayout===pu?Su(this.cardCustomTemplate):void 0;t?this.errors.addOrReplace({id:"WARN_cardCustomTemplate",type:"warning",message:`cardCustomTemplate: ${t}`}):this.errors.remove("WARN_cardCustomTemplate")}setCardClass(){return!0===this.cardShowBorder?"card_box border":"card_box"}titleProp(t){return this.resolveInherited(t,this[t],"").value}prepareTitleImage(t){if(null==t||""===t)return"";const i=this.stores.assets.state;return t.startsWith("asset:")?i[t.substring(6)]:i[t]||t}render(){var t;const s=this.getLayoutStyle(),e=this.extractSlotNames(s["grid-template-areas"]);return i("bn-card",{key:"f9d135554b1ab8a8bee9bb4f7084e465e495e180",styles:this.styles,"selected-style":this.selectedStyle,class:this.setCardClass()},i("div",{key:"54766941aa09df561453f620bd2ecd16f9fd3526",class:"cardtitle"},i("bn-title",{key:"ce2dc7bd84943a6b97068441d9da85a150271227","i18n-namespace":null!==(t=this.i18nNamespace)&&void 0!==t?t:this.titleNamespace,ruleset:this.titleProp("ruleset"),"business-unit":this.titleBusinessUnit,scenarios:this.titleProp("titleScenarios"),variances:this.titleProp("titleVariances"),order:this.titleProp("titleOrder"),"order-direction":this.titleProp("titleOrderDirection"),measures:this.titleMeasures,"date-start":this.titleDateStart,"date-end":this.titleDateEnd,"date-format":this.titleDateFormat,"date-link":this.titleDateLink}),null!=this.titleImage&&""!==this.titleImage?i("img",{class:"image",src:this.prepareTitleImage(this.titleImage)}):""),i("bn-body",{key:"b692bf5149c7c34288b612b7179779030ef2031c"},i("div",{key:"2650ddbbae89f6e63fdeba3f65513446eb22a96f",style:s,"data-bn-fit-content":this.cardFitToContent?String(this.getRowCount(this.cardLayout)):null},this.getSlots(e))),i("bn-footer",{key:"d924118be1d48c4f80b8e6d39f90aa1e2b3a1ff2",text:this.footerText,"page-number":"0","display-page-number":"false"}))}get element(){return e(this)}};$u.style=':host{--bn-baseline-offset-top:0px;--bn-baseline-offset-left:0px;--bn-baseline-offset-right:0px;background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden}.cardtitle{display:inline-flex}::slotted(*){flex:1 1 auto;min-width:0}.image{margin-right:0.5em;margin-top:0.5em;z-index:2;background-color:transparent;border:transparent;height:4em;width:auto;display:inline}bn-body{box-sizing:border-box;padding:var(--bn-baseline-offset-top) var(--bn-baseline-offset-right) 0 var(--bn-baseline-offset-left)}';const Mu=class{constructor(i){t(this,i),this.messageText="",this.messageImage="",this.titleBusinessUnit="",this.titleOrder="category",this.titleOrderDirection="asc",this.titleDateFormat="none",this.titleDateLink="none",this.footerDisplayPageNumber=!0,this.pageLayout="full",this.pageCustomTemplate='"a b" "c d"',this.pageGridGap="0",this.pageFitToContent=!1,a(this),this.errors=l(this)}getCommonStyles(){let t="100%";return!0===this.pageFitToContent&&(t="fit-content"),{display:"grid",height:t,width:"100%",gap:this.pageGridGap+"px"}}getRowCount(t){return bu(this.getTemplateAreas(t)).length||1}getGridTemplateRows(t){const i=this.getRowCount(t);return this.pageFitToContent?Array(i).fill("auto").join(" "):Array(i).fill("minmax(0, 1fr)").join(" ")}getLayoutStyle(){return Object.assign(Object.assign({},this.getCommonStyles()),{"grid-template-areas":this.getTemplateAreas(this.pageLayout),"grid-template-columns":this.getGridTemplateColumns(this.pageLayout),"grid-template-rows":this.getGridTemplateRows(this.pageLayout)})}createDivAreaStyles(t){return t.map((t=>({display:"flex",overflow:"hidden","grid-area":t})))}getSlots(t){const s=this.createDivAreaStyles(t);return i(o,null,s.map(((t,s)=>i("div",{style:t},i("slot",{name:"slot-"+s})))))}extractSlotNames(t){return xu(t)}getTemplateAreas(t){return yu(t,this.pageCustomTemplate)}getGridTemplateColumns(t){return(i=t)===pu||vu.has(i)?wu(this.getTemplateAreas(t)):"1fr";var i}mirror(t,i){null==i?this.element.hasAttribute(t)&&this.element.removeAttribute(t):this.element.getAttribute(t)!==i&&this.element.setAttribute(t,i)}componentWillRender(){this.mirror("page-format",this.pageFormat),this.mirror("page-orientation",this.pageOrientation);const t=this.pageLayout===pu?Su(this.pageCustomTemplate):void 0;t?this.errors.addOrReplace({id:"WARN_pageCustomTemplate",type:"warning",message:`pageCustomTemplate: ${t}`}):this.errors.remove("WARN_pageCustomTemplate")}rotation(){var t;const i=null===(t=this.element.closest("bn-context"))||void 0===t?void 0:t.getAttribute("render-orientation"),s=kc(this.pageFormat,this.pageOrientation,i);if(s.turned)return{host:{width:s.width,height:s.height},page:{transform:"rotate(-90deg) translate(-100%)",transformOrigin:"top left"}}}render(){var t;const e=this.getLayoutStyle(),n=this.extractSlotNames(e["grid-template-areas"]),r=this.rotation();return i(s,{key:"290e6e8250c5f8bf53352886a810eeedd7548e57",style:null==r?void 0:r.host},i("bn-page",{key:"71b472107af79e9581e2097aae33c6b2808decbf",styles:this.styles,"selected-style":this.selectedStyle,format:this.pageFormat,orientation:this.pageOrientation,style:null==r?void 0:r.page},i("bn-message",{key:"99ac5c760476f95ff296077736849e6ddfd85120",text:this.messageText,image:this.messageImage}),i("bn-title",{key:"3af5ee4a7be905676a927397ff19cf062b291fb6","i18n-namespace":null!==(t=this.i18nNamespace)&&void 0!==t?t:this.titleNamespace,ruleset:this.ruleset,"business-unit":this.titleBusinessUnit,scenarios:this.titleScenarios,variances:this.titleVariances,order:this.titleOrder,"order-direction":this.titleOrderDirection,measures:this.titleMeasures,"date-start":this.titleDateStart,"date-end":this.titleDateEnd,"date-format":this.titleDateFormat,"date-link":this.titleDateLink}),i("bn-body",{key:"c91e9c708934499b855fe9e321bebb7aed31ab7c"},i("div",{key:"92d01a4bad8ae401e570fcee4a9bbdac42b31d81",style:e,"data-bn-fit-content":this.pageFitToContent?String(this.getRowCount(this.pageLayout)):null},this.getSlots(n)),i("slot",{key:"ac227c5985b827e91d139396915e3a104e44710b",name:"annotations"})),i("bn-footer",{key:"41dfc75b74a158a0e7cdb05456b03ae62cf6d6db",text:this.footerText,"page-number":this.pageNumber,"display-page-number":this.footerDisplayPageNumber})))}get element(){return e(this)}};Mu.style=':host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);display:block;overflow:hidden}::slotted(*){flex:1 1 auto;min-width:0}';const _u=class{constructor(i){t(this,i),a(this),this.errors=l(this),this.componentStyle=k(this)}connectedCallback(){this.stores=c(this.element)}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}prepareAssetUrl(t){if(null==t||""===t)return"";const i=this.stores.assets.state;return t.startsWith("asset:")?i[t.substring(6)]:i[t]||t}render(){return i(s,{key:"4de8953156b05196149fe7a89e2b6a2d9f831695",id:this.text||this.image?"container-page-message":"container",style:this.getFontStyles()},i("div",{key:"ca005a6c2c06b59facea40c0aab4e146d51be557",id:"message-text"},null!=this.text&&""!==this.text?i("span",{class:"note",innerHTML:zt(this.text)}):""),i("div",{key:"8fbdc7014401f0f02ef5c79b37bcc57b29a18a59",id:"page-image"},null!=this.image&&""!==this.image?i("img",{class:"image",src:this.prepareAssetUrl(this.image)}):""))}get element(){return e(this)}};_u.style=':host{padding:0.2em 0.5em;display:flex;flex-direction:row;justify-content:space-between;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}:host(#container-page-message){min-height:4.55em;box-sizing:border-box;-webkit-box-sizing:border-box;border-bottom:0.1em solid #ddd}div#message-text{font-size:1.4em;overflow:clip;display:inline}span.note p{margin:0}.image{z-index:2;background-color:transparent;border:transparent;height:4em;width:auto;display:block}';const Ou=class{constructor(i){t(this,i),a(this),this.errors=l(this),this.componentStyle=k(this)}validateFormat(t){const i="WARN_format";N(t)||Mc.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`format: invalid value '${t}' is not supported. Valid values: ${Mc.join(", ")}`})}validateOrientation(t){const i="WARN_orientation";N(t)||_c.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`orientation: invalid value '${t}' is not supported. Valid values: ${_c.join(", ")}`})}componentWillLoad(){this.validateFormat(this.format),this.validateOrientation(this.orientation)}render(){return i(s,{key:"b2d1a2638c7bee2b2e134d5fedbac63fe38e9830",format:this.format,orientation:this.orientation,style:this.prepareStyle()},i("slot",{key:"4769d18000916a16ee9da8fb0c19b5d8b12393c0"}))}prepareStyle(){const t={"font-family":this.componentStyle((t=>t.global.fontFamily)),"font-size":`${this.componentStyle((t=>t.global.fontSizePx))}px`,"--bn-font-family":this.componentStyle((t=>t.global.fontFamily))||"'Noto Sans', sans-serif","--bn-font-size":`${this.componentStyle((t=>t.global.fontSizePx))||13.3333}px`,"--bn-font-color":this.componentStyle((t=>t.global.fontColor))||"#000000","--bn-font-background":this.componentStyle((t=>t.global.fontBackgroundColor))||"#ffffff"};if(Mc.includes(this.format)){const{width:i,height:s}=Oc(this.format,this.orientation);t.width=i,t.height=s}return t}get element(){return e(this)}static get watchers(){return{format:[{validateFormat:0}],orientation:[{validateOrientation:0}]}}};Ou.style=':host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);height:768px;width:1024px;display:flex;flex-direction:column;page-break-after:always;overflow:hidden}';const ku=class{constructor(i){t(this,i),a(this),this.errors=l(this)}connectedCallback(){this.stores=c(this.element),this.pushToStore()}disconnectedCallback(){this.removeEntryIfOurs(this.storedName)}onNameChange(t,i){const s=null==i?void 0:i.toString().trim();s&&s!==(null==t?void 0:t.toString().trim())&&this.removeEntryIfOurs(s),this.pushToStore()}onValueChange(){this.pushToStore()}removeEntryIfOurs(t){t&&this.stores&&(this.storedName===t&&this.stores.scalingGroups.state[t]===this.storedValue&&this.stores.scalingGroups.set(t,void 0),this.storedName===t&&(this.storedName=void 0,this.storedValue=void 0))}pushToStore(){var t;if(!this.stores)return;const i=null===(t=this.name)||void 0===t?void 0:t.toString().trim(),s=Kt(i);if("auto"===s.kind)return void this.errors.addOrReplace({id:"WARN_reserved_name",type:"warning",message:'bn-scaling-group: name "auto" is reserved and cannot be used.'});if(this.errors.remove("WARN_reserved_name"),!i)return void this.errors.addOrReplace({id:"WARN_empty_name",type:"warning",message:"bn-scaling-group: name is required."});if(this.errors.remove("WARN_empty_name"),"number"===s.kind)return void this.errors.addOrReplace({id:"WARN_numeric_name",type:"warning",message:`bn-scaling-group: name "${i}" is not allowed - it would be ambiguous with a numeric scaling value.`});this.errors.remove("WARN_numeric_name");const e=Kt(this.value);if("number"!==e.kind)return void this.errors.addOrReplace({id:"WARN_invalid_value",type:"warning",message:`bn-scaling-group: invalid value "${this.value}" - must be a positive number, optionally with k/M/G/T suffix.`});this.errors.remove("WARN_invalid_value");const n=this.stores.scalingGroups.state[i];void 0===n||n===e.value||this.storedName===i&&this.storedValue===n?this.errors.remove("WARN_duplicate_group"):this.errors.addOrReplace({id:"WARN_duplicate_group",type:"warning",message:`bn-scaling-group: "${i}" is already registered with a different value (${Jt(n)}); overwriting.`}),this.storedName&&this.storedName!==i&&this.removeEntryIfOurs(this.storedName),this.stores.scalingGroups.set(i,e.value),this.storedName=i,this.storedValue=e.value}render(){return i(s,{key:"db1fe7bbe3d3caf76ad32eac64f944eef10b1ccd"})}get element(){return e(this)}static get watchers(){return{name:[{onNameChange:0}],value:[{onValueChange:0}]}}};var Au,Ru,Nu,Lu,Eu;ku.style="bn-scaling-group{display:none}",function(t){t[t.ALL=-1]="ALL"}(Au||(Au={})),function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(Ru||(Ru={})),function(t){t.LIST="list",t.SUM="sum",t.SUMNOTOTAL="sumnototal",t.OPT="opt",t.OPTNOTOTAL="optnototal"}(Nu||(Nu={})),function(t){t.ASC="asc",t.DESC="desc"}(Lu||(Lu={})),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"}(Eu||(Eu={}));const Tu="none",Cu="setname";function Pu(t){return t===Cu?"COALESCE([setname],[setName])":`normalizeDate([date], '${t}')`}function Wu(t){if("string"==typeof t?""===t.trim():"number"!=typeof t)return;const i=Number(t);return Number.isFinite(i)?i:void 0}function Du(t){if(null==t)return"";if("string"==typeof t)return t.trim();const i=zu(t);return i?i.toISO():String(t)}function zu(t){if(null!=t){if("string"==typeof t){const i=y.fromISO(t,{zone:"utc"});return i.isValid?i:void 0}if("number"==typeof t){const i=y.fromMillis(t,{zone:"utc"});return i.isValid?i:void 0}if("boolean"==typeof t.isValid)return t.isValid?t:void 0}}const Uu=class{validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("WARN_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"WARN_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("WARN_scale")}constructor(i){t(this,i),this.layoutObserver=null,this._lastScaledParentWidth=0,this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.hasBlankSetnames=!1,this.hasSetnameIndexWithoutSetname=!1,this.sumTitle="",this.filter="",this.measureUnit="",this.barColumnWidth="w10",this.unitScaling="100",this.percentageScaling="2",this.pixelPerUnitGroupMap=new Map,this.dataFormat="decimal",this.grouped=!1,this.showMeasureScale=!1,this.showGroupTitle=!0,this.type="list",this.limit=0,this.thereof="[]",this.partof="[]",this.order="category",this.orderDirection="asc",this.measureType="volume",this.measureScale="greatest",this.dataFormatDigitsDecimal=1,this.dataFormatDigitsPercent=2,this.categoryWidth="w15",this.columnthereof=null,this.interval="none",this.categoryIntervalPosition=0,this.tableAttributes="",this._autoScaleGuard=!1,this.autoUnitWarningActive=!1,this.autoPctWarningActive=!1,this.handleAutoScalingReport=t=>{var i,s,e,n;this.lastAutoScalingReport={unit:null!==(i=t.unit)&&void 0!==i?i:null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.unit,percentage:null!==(e=t.percentage)&&void 0!==e?e:null===(n=this.lastAutoScalingReport)||void 0===n?void 0:n.percentage};const r=(t,i)=>void 0===i||Math.abs(t-i)>.001*Math.abs(t);if(void 0!==t.unit&&t.unit>0&&this.autoUnitWarningActive){const i=1/t.unit;r(i,this.lastReportedUnitsPerEm)&&(this.lastReportedUnitsPerEm=i,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: invalid value "${this.unitScaling}" - auto-fitted to 1 em ≈ ${Jt(i)} units.`}))}if(void 0!==t.percentage&&t.percentage>0&&this.autoPctWarningActive){const i=1/t.percentage;r(i,this.lastReportedPpPerEm)&&(this.lastReportedPpPerEm=i,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: invalid value "${this.percentageScaling}" - auto-fitted to 1 em ≈ ${Jt(i)} percentage points.`}))}},E(this),a(this),this.errors=l(this),ns(this),this.componentStyle=k(this),this.ruleSetConfig=es(this),Yt(this,((t,i)=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1,this.hasBlankSetnames=Array.isArray(i)&&i.some((t=>{var i;return N(null!==(i=null==t?void 0:t.setname)&&void 0!==i?i:null==t?void 0:t.setName)})),this.hasSetnameIndexWithoutSetname=Array.isArray(i)&&i.some((t=>{var i,s;return void 0!==Wu(null!==(i=null==t?void 0:t.setnameIndex)&&void 0!==i?i:null==t?void 0:t.setNameIndex)&&N(null!==(s=null==t?void 0:t.setname)&&void 0!==s?s:null==t?void 0:t.setName)}))}),((t,i)=>{this.datasetMeta=i})),this.t=Bt(this).t,this.resolveInherited=qt(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}],this.errors)}validateFilter(t){const i="ERR_filter";v(t)?this.errors.addOrReplace({id:i,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(i)}validateScenario(t){const i="WARN_scenarios";if(Gt(t))return void this.errors.remove(i);const s=B(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+(null==s?void 0:s.toString())+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances";if(Gt(t))return void this.errors.remove(i);const s=H(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateBarColumns(t){const i="WARN_barColumns";if(N(t))return void this.errors.remove(i);const s=dt(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"barColumns: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateBarColumnWidth(t){const i="WARN_barColumnWidth";ft(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"barColumnWidth: invalid value '"+t+"' is not supported."})}validateUnitScaling(t){const i="WARN_unitScaling";"invalid"===Xt(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validatePercentageScaling(t){const i="WARN_percentageScaling";"invalid"===Xt(t,this.pixelPerUnitGroupMap).kind?this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value '"+t+"' is not supported."}):this.errors.remove(i)}validateDataFormat(t){const i="WARN_dataFormat";vt(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormat: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateType(t){const i="WARN_type";pt(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"type: invalid value(s) '"+(null==t?void 0:t.toString())+"' are not supported."})}validateLimit(t){const i="WARN_limit";L(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateThereOf(t){const i="WARN_thereof",s=gt(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"ThereOf: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validatePartOf(t){const i="WARN_partof",s=mt(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"partof: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderList(t){const i="WARN_order";if(Gt(t))return void this.errors.remove(i);const s=bt(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="WARN_orderDirection";Gt(t)||F(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasureType(t){const i="WARN_measureType";yt(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureType: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasureScale(t){const i="WARN_measureScale";X(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDataFormatDigitsDecimal(t){const i="WARN_dataFormatDigitsDecimal";L(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsDecimal: invalid value(s) '"+t+"' are not supported."})}validateDateFormatDigitsPercent(t){const i="WARN_dataFormatDigitsPercent";L(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dataFormatDigitsPercent: invalid value(s) '"+t+"' are not supported."})}validateCategoryWidth(t){const i="WARN_categoryWidth";wt(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"categoryWidth: invalid value(s) '"+t+"' are not supported."})}validateColumnThereOf(t){const i=xt(t),s="WARN_columnthereof";i.length>0?this.errors.addOrReplace({id:s,type:"warning",message:"columnthereof: invalid value(s) '"+JSON.stringify(i)+"' are not supported."}):this.errors.remove(s)}validateInterval(t){const i="WARN_interval",s=null==t?void 0:t.trim().toLowerCase();N(t)||s===Tu||s===Cu||nt(s)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"interval: invalid value '"+t+"' is not supported."})}validateCategoryIntervalPosition(t){const i="WARN_categoryIntervalPosition";N(t)||L(t)&&Number(t)>=0?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"categoryIntervalPosition: invalid value '"+t+"' is not supported."})}validateTableAttributes(t){const i="WARN_attributes",s=St(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"attributes: invalid value(s) '"+JSON.stringify(s)+"' are not supported."}):this.errors.remove(i)}componentWillLoad(){this.validateFilter(this.filter),this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateDataFormat(this.dataFormat),this.validateType(this.type),this.validateLimit(this.limit),this.validateThereOf(this.thereof),this.validatePartOf(this.partof),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal),this.validateDateFormatDigitsPercent(this.dataFormatDigitsPercent),this.validateCategoryWidth(this.categoryWidth),this.validateMeasureType(this.measureType),this.validateMeasureScale(this.measureScale),this.validateColumnThereOf(this.columnthereof),this.validateInterval(this.interval),this.validateCategoryIntervalPosition(this.categoryIntervalPosition),this.validateTableAttributes(this.tableAttributes),this.validateBarColumns(this.barColumns),this.validateBarColumnWidth(this.barColumnWidth),this.validateUnitScaling(this.unitScaling),this.validatePercentageScaling(this.percentageScaling),this.validateScaling(this.scale)}componentDidLoad(){this.layoutObserver=ss(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=Ut(this.element);t>0&&Math.abs(t-this._lastScaledParentWidth)>2&&(this._lastScaledParentWidth=t,n(this))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}componentDidRender(){$s(this.element,"bn-table-renderer");const{mode:t}=Ht(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const i=this.element,{width:s}=Ut(i);if(s<=0)return void this.checkOverflow();this._lastScaledParentWidth=s;const e=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),n=i.scrollWidth,o=this.appliedScaleFactor;if(n<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const h=Math.max(.3,o*(s-1)/n);Math.abs(h-o)<.001||(i.style.setProperty("--bn-font-size",e*h+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:`Auto-scaled table by factor ${h.toFixed(3)}`}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,r((()=>{this.appliedScaleFactor=h}))),this.checkOverflow()}checkOverflow(){const t=Ut(this.element),i=this.element.scrollWidth,s=this.element.scrollHeight,e=t.width>0&&i>t.width+1,n=t.height>0&&s>t.height+1;if(!e&&!n)return void M(this.errors,null);const{mode:r}=Ht(this.scale),o="auto"!==r&&"empty"!==r,h=[];e&&h.push(`width (${Math.round(i)}px > ${Math.round(t.width)}px)`),n&&h.push(`height (${Math.round(s)}px > ${Math.round(t.height)}px)`),M(this.errors,`Table exceeds available ${h.join(" and ")}. Give the component more space, reduce rows (e.g. limit), or set a smaller scale.`,o)}prepareDataFormat(){var t;return $t[null===(t=this.dataFormat)||void 0===t?void 0:t.toUpperCase()]}prepareGrouped(){return this.grouped}prepareShowGroupTitle(){return this.showGroupTitle}prepareTableType(){var t;return Nu[null===(t=this.type)||void 0===t?void 0:t.toUpperCase()]}prepareLimit(){return Math.floor(Number(this.limit)||0)}prepareThereOf(){if(null==this.thereof||""===this.thereof.trim())return[];try{return JSON.parse(this.thereof)}catch(t){return[]}}preparePartOf(){if(null==this.partof||""===this.partof.trim())return[];try{return JSON.parse(this.partof)}catch(t){return[]}}prepareOrder(){var t;const i=this.resolveInherited("order",this.order,"category").value,s=this.resolveInherited("orderDirection",this.orderDirection,"asc").value,e="auto"===(null==i?void 0:i.trim().toLowerCase());let n=i;return e&&(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)&&(n=this.datasetMeta.suggestedOrder),{hierarchy:n.split(",").map((t=>Mt(t))),direction:j[null==s?void 0:s.toUpperCase()]}}prepareI18nMode(){return _t.META}prepareI18n(){const t=p,i=new Map(["in","category","operation","thereof","part_of","SUM_TOTAL","no-data","REST"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries(),...Ts(this.ruleSetConfig("user"))])}prepareDataFormatDigits(){return{percent:this.dataFormatDigitsPercent,decimal:this.dataFormatDigitsDecimal}}prepareScenarios(){var t,i,s,e,n,r,o,h,a,l,c;const u=this.resolveInherited("scenarios",this.scenarios),d=this.resolveInherited("variances",this.variances);if(u.inherited||d.inherited){this.errors.remove("AUTO_scenarios");let e=[];return N(u.value)?u.unresolved&&(e=e.concat(null!==(i=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==i?i:[])):e=e.concat(u.value.split(",")),(null===(s=d.value)||void 0===s?void 0:s.trim().length)>0&&(e=e.concat(d.value.split(","))),e.map((t=>t.trim()))}const f="auto"===(null===(e=u.value)||void 0===e?void 0:e.trim().toLowerCase()),v=f||u.unresolved;if((N(u.value)||f)&&N(d.value))return(null===(r=null===(n=this.datasetMeta)||void 0===n?void 0:n.availableScenarios)||void 0===r?void 0:r.length)>0?(v?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),this.datasetMeta.availableScenarios):[];let p=[];return f||N(u.value)?(null===(h=null===(o=this.datasetMeta)||void 0===o?void 0:o.availableScenarios)||void 0===h?void 0:h.length)>0&&(v?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:`scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`}),p=p.concat(this.datasetMeta.availableScenarios)):(this.errors.remove("AUTO_scenarios"),p=p.concat(null===(a=u.value)||void 0===a?void 0:a.split(","))),(null===(l=d.value)||void 0===l?void 0:l.trim().length)>0&&(p=p.concat(null===(c=d.value)||void 0===c?void 0:c.split(","))),p.map((t=>t.trim()))}prepareCategoryWidth(){var t;return N(this.categoryWidth)?Ot.INF:Ot[null===(t=this.categoryWidth)||void 0===t?void 0:t.toUpperCase()]}prepareMeasureScale(){return N(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareMeasureType(){var t;return N(this.measureType)?kt.VOLUME:kt[null===(t=this.measureType)||void 0===t?void 0:t.toUpperCase()]}prepareColumnThereOf(){if(null==this.columnthereof||""===this.columnthereof.trim())return new Map;const t=new Map;try{const i=JSON.parse(this.columnthereof);for(const[s,e]of Object.entries(i))!1===t.has(e.scenario)&&t.set(e.scenario,[]),t.get(e.scenario).push(e)}catch(t){return new Map}return t}prepareInterval(){var t;const i="WARN_intervalConflict",s="WARN_intervalNoDate",e="WARN_intervalSetname",n="WARN_intervalSetnameIndex",r=N(this.interval)?Tu:this.interval.trim().toLowerCase();return r!==Tu&&r!==Cu&&!nt(r)||r===Tu?(this.errors.remove(i),this.errors.remove(s),this.errors.remove(e),this.errors.remove(n),Tu):null!=this.columnthereof&&""!==this.columnthereof.trim()?(this.errors.addOrReplace({id:i,type:"warning",message:"interval: cannot be combined with columnthereof, interval is ignored."}),this.errors.remove(s),this.errors.remove(e),this.errors.remove(n),Tu):(this.errors.remove(i),r===Cu?(this.hasBlankSetnames?this.errors.addOrReplace({id:e,type:"warning",message:"interval: rows with blank setname found, they are grouped under '-'."}):this.errors.remove(e),this.hasSetnameIndexWithoutSetname?this.errors.addOrReplace({id:n,type:"warning",message:"interval: rows with setnameIndex but blank setname found, setnameIndex needs setname."}):this.errors.remove(n),this.errors.remove(s),Cu):(this.errors.remove(e),this.errors.remove(n),this.datasetMeta&&!(null===(t=this.datasetMeta.dateRange)||void 0===t?void 0:t.hasData)?(this.errors.addOrReplace({id:s,type:"warning",message:"interval: dataset has no date values, interval is ignored."}),Tu):(this.errors.remove(s),r)))}prepareCategoryIntervalPosition(){const t=Number(this.categoryIntervalPosition);return Number.isInteger(t)&&t>0?t:0}prepareAttributes(){if(null==this.tableAttributes||""===this.tableAttributes.trim())return[];try{const t=JSON.parse(this.tableAttributes);return null===t||"object"!=typeof t||t instanceof Array?[]:Object.entries(t).map((([t,i],s)=>"string"==typeof i?At(t,`attr_${s}`,i):null)).filter((t=>null!==t))}catch(t){return[]}}prepareSumTitle(){return""===this.sumTitle||null==this.sumTitle?"SUM_TOTAL":this.sumTitle}prepareShowMeasureScale(){return this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareBarColumnWidth(){var t;const i=null===(t=this.barColumnWidth)||void 0===t?void 0:t.toUpperCase(),s=Nt[i];return s?Rt[s]:Rt[Nt.W10]}prepareBarColumns(){return N(this.barColumns)?[]:this.barColumns.split(",").map((t=>t.trim()))}prepareUnitScaling(){const t=Xt(this.unitScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,1/t.value):"auto"===t.kind?(this.errors.remove("AUTO_unitScaling"),this.autoUnitWarningActive=!1,this.lastReportedUnitsPerEm=void 0,0):(this.autoUnitWarningActive=!0,this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:`unit-scaling: invalid value "${t.raw}" - auto-fitting to the bar column width.`}),0)}preparePercentageScaling(){const t=Xt(this.percentageScaling,this.pixelPerUnitGroupMap);return"value"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,1/t.value):"auto"===t.kind?(this.errors.remove("AUTO_percentageScaling"),this.autoPctWarningActive=!1,this.lastReportedPpPerEm=void 0,0):(this.autoPctWarningActive=!0,this.errors.addOrReplace({id:"AUTO_percentageScaling",type:"warning",message:`percentage-scaling: invalid value "${t.raw}" - auto-fitting to the pin area.`}),0)}getDataStructure(){return{ITableDataRow:{setName:{type:"string",isOptional:!1,description:""},setNameIndex:{type:"number",isOptional:!0,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}async getBaseline(){return this.readBaseline()}readBaseline(){var t,i,s;return function(t,i){var s;if(!t)return{};const e=si(i),n={},r=t.querySelector("thead");if(r){const t=e.toLocal(r.getBoundingClientRect());n.y=Di(t.y+t.height)}const o=t=>t?Array.from(t.children).filter((t=>"tr"===t.localName)):[],h=o(r),a=null!==(s=h[h.length-1])&&void 0!==s?s:o(t.querySelector("tbody"))[0],l=a?Array.from(a.children):[],c=t=>t.classList.contains("category")||t.classList.contains("operation"),u=l.some(c)?l.find((t=>!c(t))):l[1];return u&&(n.x=Di(e.toLocal(u.getBoundingClientRect()).x)),n}(null===(s=null===(i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelector("bn-table-renderer"))||void 0===i?void 0:i.shadowRoot)||void 0===s?void 0:s.querySelector("table"),this.element)}async getLayoutState(t){var i,s,e,n;const r=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",o=ei(this.element),h=this.getEffectiveScaleFactor(),a=Number.isFinite(h)&&h>0?h:1,l=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*a,c={version:li,tag:this.element.localName,id:ii(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:ti(this.element,o),em:{fontSizePx:l,appliedScaleFactor:a},regions:[],metadata:{},diagnostics:Zt(this.element),scaling:this.resolveScalingInfo(l),baseline:this.readBaseline()},u=null===(e=this.element.shadowRoot)||void 0===e?void 0:e.querySelector("bn-table-renderer");if(u){const t=null!==(n=u.scenarios)&&void 0!==n?n:[];if(c.metadata.scenarios=t.filter((t=>!t.startsWith("d"))),c.metadata.variances=t.filter((t=>t.startsWith("d"))),"function"==typeof u.getLayoutDetail){const t=await u.getLayoutDetail(o,r);c.regions=t.regions,c.metadata=Object.assign(Object.assign({},c.metadata),t.metadata),c.diagnostics=[...c.diagnostics,...t.diagnostics],t.elements&&(c.elements=t.elements),t.table&&(c.table=t.table)}}return c}resolveScalingInfo(t){var i,s;const e={},n=Xt(this.unitScaling,this.pixelPerUnitGroupMap);if("value"===n.kind)e.unitMode="fixed",e.unitsPerEm=n.value,e.unitPxPerUnit=t/n.value;else{e.unitMode="auto";const s=null===(i=this.lastAutoScalingReport)||void 0===i?void 0:i.unit;void 0!==s&&s>0&&(e.unitsPerEm=1/s,e.unitPxPerUnit=s*t)}const r=Xt(this.percentageScaling,this.pixelPerUnitGroupMap);if("value"===r.kind)e.percentageMode="fixed",e.percentagePointsPerEm=r.value,e.percentagePxPerPoint=t/r.value;else{e.percentageMode="auto";const i=null===(s=this.lastAutoScalingReport)||void 0===s?void 0:s.percentage;void 0!==i&&i>0&&(e.percentagePointsPerEm=1/i,e.percentagePxPerPoint=i*t)}return e}getEffectiveScaleFactor(){const{mode:t,factor:i}=Ht(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var s,e,n,r;const o=(null===(s=i.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(e=i.global)||void 0===e?void 0:e.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":o*t+"px","--bn-font-color":(null===(n=i.global)||void 0===n?void 0:n.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles(),e=this.getEffectiveScaleFactor();return i(s,{key:"9c4b7d3df45c425ab5d6f1443a3a067220d3a451",style:t},i("div",{key:"b0332096da43ca9d5c139da7f18abdcb89356c37"},i("bn-table-renderer",{key:"f9ae1288c299bf3e5a5d1da5161fd9c663472e76",tableName:this.datasetName,dataVersion:this.dataVersion,sumTitle:this.prepareSumTitle(),scenarios:this.prepareScenarios(),scenariosDataFormat:this.prepareDataFormat(),grouped:this.prepareGrouped(),limit:this.prepareLimit(),showGroupTitle:this.prepareShowGroupTitle(),thereof:this.prepareThereOf(),partof:this.preparePartOf(),order:this.prepareOrder(),categorythereof:this.prepareColumnThereOf(),attributeColumns:this.prepareAttributes(),type:this.prepareTableType(),categoryWidth:this.prepareCategoryWidth(),dataFormatDigits:this.prepareDataFormatDigits(),i18n:this.prepareI18n(),i18nMode:this.prepareI18nMode(),measureScale:this.prepareMeasureScale(),measureType:this.prepareMeasureType(),measureUnit:this.prepareMeasureUnit(),showMeasureScale:this.prepareShowMeasureScale(),filter:this.prepareFilter(),barColumns:this.prepareBarColumns(),interval:this.prepareInterval(),categoryIntervalPosition:this.prepareCategoryIntervalPosition(),barColumnMaxWidth:this.prepareBarColumnWidth(),unitScaling:this.prepareUnitScaling(),percentageScaling:this.preparePercentageScaling(),reportAutoScaling:this.handleAutoScalingReport,errors:this.errors,scaleFactor:e,ruleSetConfig:this.ruleSetConfig(),selectedStyle:this.selectedStyle})))}get element(){return e(this)}static get watchers(){return{scale:[{validateScaling:0}],filter:[{validateFilter:0}],scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],barColumns:[{validateBarColumns:0}],barColumnWidth:[{validateBarColumnWidth:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],dataFormat:[{validateDataFormat:0}],type:[{validateType:0}],limit:[{validateLimit:0}],thereof:[{validateThereOf:0}],partof:[{validatePartOf:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],measureType:[{validateMeasureType:0}],measureScale:[{validateMeasureScale:0}],dataFormatDigitsDecimal:[{validateDataFormatDigitsDecimal:0}],dataFormatDigitsPercent:[{validateDateFormatDigitsPercent:0}],categoryWidth:[{validateCategoryWidth:0}],columnthereof:[{validateColumnThereOf:0}],interval:[{validateInterval:0}],categoryIntervalPosition:[{validateCategoryIntervalPosition:0}],tableAttributes:[{validateTableAttributes:0}]}}};Uu.style=':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)}';const Fu=/[\s\u200e\u200f\u061c]*[%\u066a][\s\u200e\u200f\u061c]*/;class Gu{constructor(t,i,s,e,n,r,o,h,a){this.prefixStyle="prefix",this.isBarChart=!1,this.key=t,this.index=i,this.value=s,this.prefix=r||"",this.cssStyle=e||"",this.prefixStyle=o||"prefix",this.type=n,this.mark=void 0,this.colSpan=h||1,this.measureScale=a||1}getAsHeaderList(){if(null==this.value)return[""];const t=[];for(const i of this.value.toString().split("<br/>"))t.push(i);return t}draw(t,i){let s=this.value;if("undefined"===s||void 0===s||null==s)return"";if(Number.isNaN(Number(s)))return s;if(""===this.type||void 0===this.type||null==this.type)return s;let e=t.percent,n=t.percent;return"percentpoint"===this.type?ra.number(Number(s),"percent",e,n,1,i).replace(Fu,""):("decimal"===this.type&&(s=+s/this.measureScale,e=t.decimal,n=t.decimal),ra.number(Number(s),this.type,e,n,1,i))}drawPrefix(){return null==this.prefix?"":this.prefix}}class ju{constructor(t,i,s){this.index=t,this.groupindex=i,this.type=s,this.cssStyle=this.initCssStyle(),this.elements=[]}initCssStyle(){switch(this.type){case Eu.HEADER:return"groupheader";case Eu.SEPERATORLINE:return"";case Eu.DRILLELEMENT:return"ofit";case Eu.PARTELEMENT:return"partof";case Eu.STANDARD:return"";case Eu.SUM:return"sum";default:return""}}getCells(){return this.elements}createElement(t,i,s,e,n,r,o,h,a,l=!1,c,u=1,d){let f=r;"category"===i&&null!=h&&(f=`category-${h.toString()}`),this.type===Eu.HEADER?f="headerlabel":this.type===Eu.SEPERATORLINE&&(f=null!=r?r:i),this.type===Eu.PARTELEMENT&&("percent"===e&&(t="-"),"category"!==i&&"operation"!==i&&(e="percent",f="")),("-"===t||t===it&&"percent"===e)&&(f="");let v="prefix-first";o&&(v="prefix-second"),s&&(f=`${f} ${s}`);const p=new Gu(i,this.elements.length,t,f,e,n,v,u,a);p.isBarChart=l,p.columnStats=c,p.waterfall=d,this.elements.push(p)}}const Iu=.85,Yu=.3,Bu=.25,Hu={".":.28,",":.28,"-":.34,"%":.89," ":.28," ":.28," ":.28,M:.9};function Vu(t,i){var s;let e=0;for(const i of t)e+=null!==(s=Hu[i])&&void 0!==s?s:/[0-9+]/.test(i)?.59:.72;return e*i*1.1}let Xu;function Ju(t,i,s,e){const n=function(){var t,i,s;if(void 0===Xu)try{Xu="undefined"==typeof document?null:null!==(s=null===(i=(t=document.createElement("canvas")).getContext)||void 0===i?void 0:i.call(t,"2d"))&&void 0!==s?s:null}catch(t){Xu=null}return Xu}();if(n){n.font="1px __bn_font_sentinel__";const r=n.font;if(n.font=`${e?"italic ":""}${i}px ${s}`,n.font===r)return Vu(t,i);const o=n.measureText(t).width;if(Number.isFinite(o)&&(o>0||""===t))return o+.15*i}return Vu(t,i)}function qu(t,i){return Math.max(0,(t-.5)*i)}function Ku(t,i,s){const e=void 0!==t.neg,n=void 0!==t.pos||!e,r=(t,e)=>t?i+s+(null!=e?e:0):0;return{sides:(e?1:0)+(n?1:0),neg:r(e,t.neg),pos:r(n,t.pos)}}function Qu(t,i,s,e){const{sides:n,neg:r,pos:o}=Ku(i,s,e),h=r+o>0?Math.min(1,t/(r+o)):1,a=Math.max(0,(t-(r+o)*h)/n);return{extent:a,axisX:void 0!==i.neg?r*h+a:0}}function Zu(t,i,s,e){const n=qu(t,i),{sides:r,neg:o,pos:h}=Ku(s,e/2,Yu*i);return o+h+r*function(t,i,s){return Math.min(1*i,t/(2*s))}(n,i,r)<=n+1e-6}function td(t,i){const s=.15*t;return{maxBarWidth:t,breakGap:i,overdriveZoneWidth:s,cutWidth:Math.max(0,t-i-s)}}function id(t,i,s,e){var n,r;const o=qu(t,i),h=Yu*i,{extent:a,axisX:l}=Qu(o,s,Bu*i/2,h),c=Math.min(.3*i,.2*a),u=void 0!==s.neg,d=void 0!==s.pos||!u;let f=u?a:0;const v=Math.max(0,null!==(n=null==e?void 0:e.neg)&&void 0!==n?n:0),p=Math.max(0,null!==(r=null==e?void 0:e.pos)&&void 0!==r?r:0);u&&d&&v+p>0&&(f=(c+(2*a*.85-2*c)*v/(v+p))/.85);const g=d?u?2*a-f:a:0;return{totalWidth:o,neg:td(f,c),pos:td(g,c),axisX:u?l-a+f:0,labelGap:h}}function sd(t,i,s,e,n){var r,o;const h=qu(t,i),a=Yu*i,{extent:l,axisX:c}=Qu(h,s,e/2,a),u=void 0!==s.neg,d=void 0!==s.pos||!u;let f=u?l:0,v=d?l:0;if(n&&u&&d){const t=2*l,i=Math.max(0,null!==(r=n.neg)&&void 0!==r?r:0),s=Math.max(0,null!==(o=n.pos)&&void 0!==o?o:0);i+s<=t+1e-6?(f=i+(t-i-s)/2,v=t-f):i<l?(f=i,v=t-f):s<l&&(v=s,f=t-v)}return{totalWidth:h,maxPinLength:Math.max(f,v),negPinLength:f,posPinLength:v,axisX:u?c-l+f:0,labelGap:a}}const ed={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},nd="#666666";function rd(t,i){return`pattern-${t}-${i.replace("#","")}`}const od=({styles:t})=>{const s=t.scaleFactor,e=6*s,n=[{id:rd("pos",t.positive.stroke),stroke:t.positive.stroke,fill:t.positive.fill},{id:rd("neg",t.negative.stroke),stroke:t.negative.stroke,fill:t.negative.fill},{id:rd("neu",t.neutral.stroke),stroke:t.neutral.stroke,fill:t.neutral.fill},...["ac","pp","fc","pl"].map((i=>({id:rd(i,t.scenarios[i].stroke),stroke:t.scenarios[i].stroke,fill:t.scenarios[i].fill})))];return i("defs",null,n.map((t=>i("pattern",{id:t.id,patternUnits:"userSpaceOnUse",width:e,height:e},i("rect",{width:e,height:e,fill:"#ffffff"}),i("line",{x1:"0",y1:e,x2:e,y2:"0",stroke:t.stroke,"stroke-width":1.5*s})))))};function hd(t,i,s=1,e,n=0,r=!0,o){const h=(i,s)=>(t>0&&i!==s?"+":"")+i;if(i){const i=(t,i)=>r?ra.number(t,"percent",i,i,1,e):ra.number(100*t,"decimal",i,i,1,e),s=s=>h(i(t,s),i(0,s));let o=Math.min(20,Math.max(0,Math.trunc(n)||0));for(;o>0&&s(o).length>7;)o--;return s(o)}const a=t/s;if(void 0!==o){const t=t=>ra.number(t,"decimal",o,o,1,e);return h(t(a),t(0))}const l=Math.abs(a);let c=1,u="";l>=9995e5?(c=1e9,u="B"):l>=999500?(c=1e6,u="M"):l>=999.5&&(c=1e3,u="K");const d=l>=10*c?0:1;return h(ra.number(a/c,"decimal",d,0,1,e),ra.number(0,"decimal",d,0,1,e))+u}function ad(t){const i=t.slice(0,2).toLowerCase();return["ac","pp","fc","pl"].includes(i)}function ld(t){const i=t.slice(0,2).toLowerCase();return"pp"===i?"pp":"fc"===i?"fc":"pl"===i?"pl":"ac"}function cd(t,i){if(ad(t))return null;const s=new ks(t);if(!s.isValid)return null;const e=ld(s.base),n=ld(s.delta);return{minuend:i.scenarios[e],minuendSlot:e,reference:i.scenarios[n],referenceSlot:n}}const ud=({x:t,height:s,look:e,styles:n})=>{const r=n.scaleFactor,o=Bu*n.emPx,{reference:h,referenceSlot:a}=e;let l;if("outlined"===h.fillpattern){const e=o/2-.5*r;l=[t-e,t+e].map((t=>i("line",{x1:t,y1:0,x2:t,y2:s,stroke:h.stroke,"stroke-width":1*r})))}else l=i("line","hatched"===h.fillpattern?{x1:t,y1:0,x2:t,y2:s,stroke:h.stroke,"stroke-width":o,"stroke-dasharray":""+2*r}:{x1:t,y1:0,x2:t,y2:s,stroke:h.fill,"stroke-width":o});return i("g",{class:`variance-axis axis-${a}`},l)};function dd(t){return void 0!==t.pos||void 0===t.neg}function fd(t,i){return{neg:t.min<0?i:void 0,pos:t.max>0?i:void 0}}function vd(t,i,s,e){return ad(t)?function(t,i){const s=ld(t);return i.scenarios[s]}(t,e):function(t,i,s){const e=t>=0;return i?e?s.positive:s.negative:e?s.negative:s.positive}(i,s,e)}function pd(t,i){const s=t.fillpattern;return"hatched"===s?`url(#${rd(i,t.stroke)})`:"outlined"===s?"transparent":t.fill}function gd(t){return"outlined"===t.fillpattern?{stroke:t.stroke,strokeWidth:1.5}:{stroke:"none",strokeWidth:0}}const md=t=>{const{value:s,scenario:e,columnStats:n,height:r,isPositiveGood:o,formattedValue:h,measureScale:a,locale:l,decimalDigits:c,columnWidthEm:u=10,labelWidths:d,sideMax:f,styles:v=ed}=t,p=v.scaleFactor,g=v.fontSize,m=h||hd(s,!1,a,l,0,!0,c),b=null!=d?d:fd(n,Ju(m,g,v.fontFamily,!1)),y=s>0||0===s&&dd(b),{neg:w=Math.max(0,-n.min),pos:x=Math.max(0,n.max)}=null!=f?f:{},S=id(u,v.emPx,b,{neg:w,pos:x}),{totalWidth:$,axisX:M,labelGap:_}=S,{breakGap:O,overdriveZoneWidth:k,cutWidth:A}=y?S.pos:S.neg,R=Math.abs(s)*v.unitScaling*g,N=R-A>1e-6,L=Math.max(0,(y?x:w)*v.unitScaling*g-A),E=Math.max(0,R-A),T=L>0?E/L*k:0,C=2*p,P=r-2*C,W=C,D=cd(e,v),z=vd(e,s,o,v),U=null==D?void 0:D.minuend.fillpattern,F="hatched"===U||"outlined"===U?Object.assign(Object.assign({},z),{fillpattern:U}):z,G=pd(F,ad(e)?ld(e):o?y?"pos":"neg":y?"neg":"pos"),{stroke:j,strokeWidth:I}=D&&"hatched"===F.fillpattern?{stroke:F.stroke,strokeWidth:1}:gd(F),Y=D?Bu*v.emPx/2:0,B=y?M+Y:M-Y,H=N?A:R,V=N?A+O+T:R,X=y?B+V+_:B-V-_,J=y?"start":"end";return i("svg",{width:$,height:r,class:"cell-bar-chart absolute-variance",style:{overflow:"visible"}},i(od,{styles:v}),!D&&i("line",{x1:M,y1:0,x2:M,y2:r,stroke:nd,"stroke-width":1*p}),H>0&&i("rect",{x:y?B:B-H,y:W,width:H,height:P,fill:G,stroke:j,"stroke-width":I*p}),N&&T>0&&i("rect",{x:y?B+A+O:B-A-O-T,y:W,width:T,height:P,fill:G,stroke:j,"stroke-width":I*p}),N&&function(t,s,e,n,r){const o=t+s/2,h=.35*s,a=n/3,l=.3*s;let c=`M ${o-h} ${e}`;for(let t=0;t<3;t++)c+=` L ${o-h-l} ${e+a*(t+.5)} L ${o-h} ${e+a*(t+1)}`;let u=`M ${o+h} ${e}`;for(let t=0;t<3;t++)u+=` L ${o+h+l} ${e+a*(t+.5)} L ${o+h} ${e+a*(t+1)}`;return[i("rect",{x:t,y:e-1,width:s,height:n+2,fill:"#ffffff"}),i("path",{d:c,fill:"none",stroke:"#000000","stroke-width":1*r}),i("path",{d:u,fill:"none",stroke:"#000000","stroke-width":1*r})]}(y?B+A:B-A-O,O,W,P,p),D&&i(ud,{x:M,height:r,look:D,styles:v}),i("text",{x:X,y:r/2,dy:"0.35em","text-anchor":J,fill:v.fontColor,"font-size":g,"font-family":v.fontFamily},m))},bd=t=>{var s,e;const{value:n,scenario:r,columnStats:o,height:h,isPositiveGood:a,formattedValue:l,measureScale:c,locale:u,percentDigits:d,percentSign:f,columnWidthEm:v=10,labelWidths:p,sideMax:g,styles:m=ed}=t,b=m.scaleFactor,y=m.fontSize,w=10*b,x=100*m.percentageScaling*y,S=l||hd(n,!0,c,u,d,f),$=null!=p?p:fd(o,Ju(S,y,m.fontFamily,!0)),{neg:M=Math.max(0,-o.min),pos:_=Math.max(0,o.max)}=null!=g?g:{},{totalWidth:O,negPinLength:k,posPinLength:A,axisX:R,labelGap:N}=sd(v,m.emPx,$,w,{neg:M*x,pos:_*x}),L=h/2,E=Math.abs(n)*x,T=n>0||0===n&&dd($),C=T?A:k,P=E-C>1e-6,W=T?1:-1,D=R+W*Math.min(E,C),z=vd(r,n,a,m),U=cd(r,m),F=null!==(s=null==U?void 0:U.minuend)&&void 0!==s?s:m.scenarios.ac,G=R+W*(C+w/2),j=G-W*w,I=(P?G:D+W*(w/2))+W*N;return i("svg",{width:O,height:h,class:"cell-bar-chart relative-variance",style:{overflow:"visible"}},i(od,{styles:m}),U?i(ud,{x:R,height:h,look:U,styles:m}):i("line",{x1:R,y1:0,x2:R,y2:h,stroke:nd,"stroke-width":1*b}),i("line",{x1:R,y1:L,x2:P?j:D,y2:L,stroke:z.fill,"stroke-width":3*b}),P?i("polygon",{points:`${G},${L} ${j},${L-w/2} ${j},${L+w/2}`,fill:z.fill}):i("rect",{x:D-w/2,y:L-w/2,width:w,height:w,fill:"outlined"===F.fillpattern?"#ffffff":pd(F,null!==(e=null==U?void 0:U.minuendSlot)&&void 0!==e?e:"ac"),stroke:F.stroke,"stroke-width":1*b}),i("text",{x:I,y:h/2,dy:"0.35em","text-anchor":T?"start":"end",fill:m.fontColor,"font-size":y,"font-style":"italic","font-family":m.fontFamily},S))},yd=t=>{const{value:s,columnStats:e,isRelative:n,styles:r=ed}=t;return null==s||isNaN(s)||!e||0===e.absMax?i("span",{class:"bar-chart-empty",style:{color:r.fontColor,fontStyle:"italic"}},"-"):i(n?bd:md,Object.assign({},t))},wd=t=>{const{value:s,scenario:e,height:n,measureScale:r,locale:o,decimalDigits:h,columnWidthEm:a=10,styles:l=ed,waterfall:c}=t,u=l.scaleFactor,d=l.fontSize,f=c.max-c.min;if(null==s||isNaN(s)||f<=0)return i("span",{class:"bar-chart-empty",style:{color:l.fontColor,fontStyle:"italic"}},"-");const{totalWidth:v,labelAreaWidth:p,barAreaWidth:g,labelGap:m}=function(t,i){const s=qu(t,i),e=Math.min(2.85*i,s/4);return{totalWidth:s,labelAreaWidth:e,barAreaWidth:s-2*e,labelGap:Yu*i}}(a,l.emPx),b=g/f,y=t=>p+(t-c.min)*b,w=2*u,x=n-2*w,S=w,$=y(0),M=y(c.start),_=y(c.end),O=Math.min(M,_),k=Math.abs(_-M),A=vd(e,s,!1,l),R=pd(A,ld(e)),{stroke:N,strokeWidth:L}=gd(A),E=hd(s,"partof"===c.kind,r,o,0,!0,h).replace(/^\+/,""),T=_<M,C=T?O-m:O+k+m,P=T?"end":"start";return i("svg",{width:v,height:n,class:"cell-bar-chart waterfall-bar",style:{overflow:"visible"}},i(od,{styles:l}),i("line",{x1:$,y1:0,x2:$,y2:n,stroke:nd,"stroke-width":1*u}),void 0!==c.parentStart&&void 0!==c.parentEnd&&i("line",{x1:y(c.parentStart),y1:0,x2:y(c.parentStart),y2:n,stroke:nd,"stroke-width":1*u,"stroke-dasharray":`${2*u},${2*u}`}),void 0!==c.parentStart&&void 0!==c.parentEnd&&i("line",{x1:y(c.parentEnd),y1:0,x2:y(c.parentEnd),y2:n,stroke:nd,"stroke-width":1*u,"stroke-dasharray":`${2*u},${2*u}`}),k>0&&i("rect",{x:O,y:S,width:k,height:x,fill:R,stroke:N,"stroke-width":L*u}),i("text",{x:C,y:n/2,dy:"0.35em","text-anchor":P,fill:l.fontColor,"font-size":d,"font-family":l.fontFamily},E))},xd=`IFNULL(${ea.ROWGROUP}, '')`;class Sd{constructor(t){this.groups=[ea.CATEGORY,ea.CATEGORYINDEX],Nu.OPT!==t.type&&Nu.OPTNOTOTAL!==t.type||this.groups.unshift(ea.OPERATION),t.grouped&&(this.groups.push(ea.ROWGROUP),this.groups.push(ea.ROWGROUPINDEX))}toString(){return this.groups.map((t=>t===ea.ROWGROUP?xd:t)).toString()}select(){return this.groups.map((t=>t===ea.ROWGROUP?`${xd} as ${t}`:t)).toString()}noCategory(){return this.groups.filter((t=>t!==ea.CATEGORY))}toArray(){return this.groups}}class $d{constructor(t,i){this.hasPartOf=!1,this.params=[],this.sortSelect="",this.hasBlankRowGroup=!1,this.config=t,this.i18n=i}execute(t,i){var s;this.db=t,this.fromExpr=i;for(const t of[...this.config.scenarios,...this.config.categoryThereOf.keys()])if(!Lt.test(t))throw new Error(`invalid identifier "${t}"`);const e=[],n=[],r=[],o=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),h=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),a=this.getRelativeScenarios(),l=this.config.attributes.map((t=>this.translateAttributeSQL(t))).toString(),c=new Sd(this.config),u=this.config.interval===Cu?this.config.sortOrder:{hierarchy:this.config.sortOrder.hierarchy.map((t=>{var i,s;return null!==(s=null===(i=Et(t))||void 0===i?void 0:i.column)&&void 0!==s?s:t})),direction:this.config.sortOrder.direction};let d=["",""];u.hierarchy.length>0&&(d=this.createOrderString(u)),this.hasPartOf=this.checkConfigForPartOf();const{hierarchy:f,direction:v}=u,p=f.filter((t=>t===ea.ROWGROUP||t===ea.ROWGROUPINDEX||t.toUpperCase()in Tt)),g=p.filter((t=>t.toUpperCase()in Tt)).map((t=>`, SUM(${t} * transformOperator(operation)) as ${t}`)).join(""),m=p.length>0?p.map((t=>`${t} ${v}`)).toString():`${ea.ROWGROUPINDEX} asc`,b=t.exec(`SELECT COUNT(DISTINCT ${ea.CATEGORY}) as ${ea.TOTALROWCOUNT} ${this.config.grouped?`, ${xd} as ${ea.ROWGROUP}, FIRST(${ea.ROWGROUPINDEX}) as ${ea.ROWGROUPINDEX}${g}`:""}\n FROM ${i} ${this.config.grouped?`GROUP BY ${xd} ORDER BY ${m}`:""}`);return 0===b.length||1===b.length&&0===(null!==(s=b[0][ea.TOTALROWCOUNT])&&void 0!==s?s:0)&&!this.config.grouped?[]:(this.hasBlankRowGroup=this.config.grouped&&b.some((t=>""===t.rowGroup)),b.forEach((t=>{const i=this.config.grouped?""===t.rowGroup?`WHERE (${ea.ROWGROUP} IS NULL OR ${ea.ROWGROUP} = '')`:`WHERE ${ea.ROWGROUP} = ${this.bind(t.rowGroup)}`:"";let s="";this.config.limit&&(s=`LIMIT ${this.config.limit}`),this.createGroupHeaderRow(t,e),this.createDataRow(e,t,c,o,l,i,d,s),this.createRestRow(t,e,c,o,i,d),this.createGroupSumRow(e,n,t,h,i,d)})),this.createTotalSumRow(e,n,h),e.forEach((t=>r.push(this.exec(t)))),this.detectNaNCells(this.config.scenarios,r),this.createThereOfDrillRows(o,l,d,r),this.createPartOfDrillRows(o,d,n,r),this.createIntervalColumns(r),this.createThereOfDrillColumns(this.config.categoryThereOf,r),this.calculateColumnGroupRest(r,this.config.categoryThereOf),this.calculateRelativeVariances(r,a),r)}detectNaNCells(t,i){i.forEach((i=>{i.map((i=>(t.forEach((t=>{const s=new ks(t);!0===s.isValid?0!==i[s.base+"_cnt"]&&0!==i[s.delta+"_cnt"]||(i[t]=Number.NaN):0===i[t+"_cnt"]&&(i[t]=Number.NaN)})),i)))}))}createPartOfDrillRows(t,i,s,e){if(null==this.config.partOf||0===this.config.partOf.length||this.config.type===Nu.LIST)return;const n=this.createPartOfQuery(t,i);let r=[];const o=this.db,h=this.params;n.forEach((t=>{r.push(...this.exec(t))}));const a=this.exctractScenarioNames(t),l=[];s.forEach((function(t){l.push(...o.exec(t,h))}));const c=new Map;l.forEach((t=>c.set(t[ea.ROWGROUP],t))),r=this.reduceResDrillByCategoryGroups(r,a),r.forEach((function(t){a.forEach((i=>{try{t[i]=t[i]/c.get(t[ea.ROWGROUP])[i]}catch(s){console.error("DataQuery: partOf drill row calculation failed",i,s),t[i]=Number.NaN}}))})),this.injectDrillRowsToResultRows(r,e)}createRestRow(t,i,s,e,n,r){var o;if(t.totalRowCnt-this.config.limit>0&&0!==this.config.limit){const h=this.exctractScenarioNames(e).map((t=>`SUM(${t}) as ${t}`)).join(", "),a=Nu.OPT===this.config.type||Nu.OPTNOTOTAL===this.config.type?", CASE WHEN MAX(transformOperator(operation)) = -1 THEN '-' ELSE '+' END as restOperation":"";i.push(`SELECT ${ea.ROWNR}, 1 as ${ea.ROWGROUPINDEX} , 'ENTRY' as ${ea.TYPE}, 'NO_GROUP' as ${ea.ROWGROUP}, ${this.bind(String(null!==(o=t.rowGroup)&&void 0!==o?o:""))} as restRowGroup, 'REST' as ${ea.CATEGORY}${a} ${h.length>0?", "+h:""} FROM (SELECT ROWNUM() AS ${ea.ROWNR}, ${i.length} as ${ea.ROWGROUPINDEX} , 'ENTRY' as ${ea.TYPE}, ${this.bind(String(t.rowGroup||"NO_GROUP"))} as ${ea.ROWGROUP}, ${s.select()} ${e.length>0?",".concat(e):""}${this.sortSelect} FROM ${this.fromExpr} ${n} GROUP BY ${s} ORDER BY ${r[0]}) t WHERE t.rowNr > ${this.config.limit}`)}}createDataRow(t,i,s,e,n,r,o,h){t.push(`SELECT ROWNUM() AS ${ea.ROWNR},\n ${t.length} as ${ea.ROWGROUPINDEX},\n 'ENTRY' as ${ea.TYPE},\n ${this.bind(String(i.rowGroup||"NO_GROUP"))} as ${ea.ROWGROUP},\n '${ea.CATEGORYINDEX}',\n ${s.select()} ${e.length>0?",".concat(e):""} ${n.length>0?",".concat(n):""}${this.sortSelect}\n FROM ${this.fromExpr} ${r}\n GROUP BY ${s}\n ORDER BY ${o[0]} ${h}`)}createGroupHeaderRow(t,i){if(!0===this.config.grouped&&(this.config.showGroupTitle||!this.hasGroupSum())){const s=this.bind(String(t.rowGroup)),e=""===t.rowGroup?this.bind("-"):s;i.push(`SELECT ROWNUM() AS ${ea.ROWNR},\n ${i.length} as ${ea.ROWGROUPINDEX},\n 'GROUPHEAD' as ${ea.TYPE},\n ${s} as ${ea.ROWGROUP} ${this.config.showGroupTitle?`,${e} as ${ea.CATEGORY}`:""}\n FROM ${this.fromExpr}\n GROUP BY '1'`)}}hasGroupSum(){return Nu.SUM===this.config.type||Nu.SUMNOTOTAL===this.config.type||Nu.OPT===this.config.type||Nu.OPTNOTOTAL===this.config.type}createGroupSumRow(t,i,s,e,n,r){if(!0===this.config.grouped&&this.hasGroupSum()){const o=this.bind(String(s.rowGroup));t.push(`SELECT ${t.length} as ${ea.ROWGROUPINDEX},\n '=' as ${ea.OPERATION},\n ${o} as ${ea.ROWGROUP},\n ROWNUM() AS ${ea.ROWNR},\n 'GROUP_SUM' as ${ea.TYPE} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr} ${n}\n ORDER BY ${r[0]} `),i.push(`SELECT ${t.length} as ${ea.ROWGROUPINDEX},\n '=' as ${ea.OPERATION},\n ${o} as ${ea.ROWGROUP},\n ROWNUM() AS ${ea.ROWNR},\n 'GROUP_SUM' as ${ea.TYPE} ${e.length>0?",".concat(e):""}\n FROM ${this.fromExpr} ${n}\n ORDER BY ${r[0]} `)}}createTotalSumRow(t,i,s){var e;if(Nu.SUM===this.config.type||Nu.OPT===this.config.type){const i=(null===(e=this.config.title)||void 0===e?void 0:e.trim())||"SUM_TOTAL",n=this.hasPartOf&&!1===this.config.grouped&&"SUM_TOTAL"!==i?`${this.i18n.get("SUM_TOTAL")||"SUM_TOTAL"} ${i}`:i;t.push(`SELECT ${t.length} as ${ea.ROWGROUPINDEX},\n ${this.bind(n)} as ${ea.ROWGROUP},\n '=' as ${ea.OPERATION},\n 'SUM' as ${ea.TYPE} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr} `)}i.push(`SELECT ${t.length} as ${ea.ROWGROUPINDEX},\n 'SUM_TOTAL' as ${ea.ROWGROUP},\n '=' as ${ea.OPERATION},\n 'SUM' as ${ea.TYPE} ${s.length>0?",".concat(s):""}\n FROM ${this.fromExpr} `)}reduceResDrillByCategoryGroups(t,i){const s=new Map;return t.forEach((function(t){const e=t.rowNr+t.rowGroup+t.type+t.category;if(s.has(e)){const n=s.get(e);i.forEach((i=>{try{n[i]+=t[i]}catch(t){console.error("DataQuery: drill row aggregation failed",i,t)}}))}else s.set(e,t)})),[...s.values()]}injectDrillRowsToResultRows(t,i){const s=new Map;if(!0===this.config.grouped)t.forEach((function(t){i.forEach((function(i){const e=i.findIndex((i=>i.category===t.category&&i.rowGroup===t.rowGroup));if(e>=0){if(s.has(`${t.category}_${t.rowGroup}`)){const i=s.get(`${t.category}_${t.rowGroup}`)||0;s.set(`${t.category}_${t.rowGroup}`,i+1)}else s.set(`${t.category}_${t.rowGroup}`,1);t[ea.ROWNR]=s.get(`${t.category}_${t.rowGroup}`),i.splice(e+t[ea.ROWNR],0,t)}}))}));else{const e=this.findDuplicateSubCategories(t);t.forEach((function(t){i.forEach((function(i){const n=i.findIndex((i=>null!=i.category&&i.category===t.category));if(n>=0){if(s.has(`${t.category}`)){const i=s.get(`${t.category}`)||0;s.set(`${t.category}`,i+1)}else s.set(`${t.category}`,1);null!=t.rowGroup&&""!==t.rowGroup&&e.includes(`${t.category}##${t.subCategory}`)&&(t.rawSubCategory=t.subCategory,t.subCategory=`${t.subCategory} (${t.rowGroup})`),i.splice(n+t[ea.ROWNR],0,t)}}))}))}}createThereOfDrillRows(t,i,s,e){if(void 0===this.config.thereOf||0===this.config.thereOf.length)return;const n=[],r=[];this.config.thereOf.forEach((e=>{let r=!0,o="1 <> 1 OR ( ";null!=e.category&&0!==e.category.length&&e.category.trim()&&(o+=` ${ea.CATEGORY} = ${this.bind(e.category)}`,r=!1),null!=e.rowGroup&&0!==e.rowGroup.length&&e.rowGroup.trim()&&(o+=` ${r?"":"AND"} ${ea.ROWGROUP} = ${this.bind(e.rowGroup)}`,r=!1),null!=e.subCategory&&0!==e.subCategory.length&&e.subCategory.trim()&&(o+=` ${r?"":"AND"} ${ea.SUBCATEGORY} = ${this.bind(e.subCategory)}`),o+=")",n.push(`SELECT ROWNUM() AS ${ea.ROWNR},\n null as operation,\n 'DRILLELEMENT' as ${ea.TYPE},\n ${ea.CATEGORY},\n ${ea.SUBCATEGORY},\n ${this.drillRowGroup} as ${ea.ROWGROUP},\n ${t} ${i.length>0?",".concat(i):""}${this.sortSelect}\n FROM ${this.fromExpr}\n WHERE ${o}\n GROUP BY ${this.drillRowGroup}, ${ea.CATEGORY}, ${ea.SUBCATEGORY}\n ORDER BY ${s[1]}`)})),n.forEach((t=>{r.push(...this.exec(t))})),this.injectDrillRowsToResultRows(r,e)}calculateRelativeVariances(t,i){t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[ea.TYPE]&&i.forEach(((i,s)=>{var e;t[s]=null!==(e=st(t[s],t[i]))&&void 0!==e?e:it}))}))}))}calculateColumnGroupRest(t,i){if(null==i||0===i.size)return;const s=new Map,e=new Map;i.forEach(((t,i)=>{const n=t,r=[];for(const t of n)r.push(`${i}##${t.name}`);s.set(i,r),e.set(`${i}##REST`,!1)})),t.forEach((t=>{t.forEach((t=>{"GROUPHEAD"!==t[ea.TYPE]&&s.forEach(((i,s)=>{let n=0;i.forEach((i=>{void 0!==t[i]&&(n+=t[i])})),t[`${s}##REST`]=t[s]-n,0!==t[`${s}##REST`]&&e.set(`${s}##REST`,!0)}))}))}));const n=Array.from(e.entries()).filter((([t,i])=>!i)).map((([t])=>t));t.forEach((t=>{t.forEach((t=>{for(const i of n)delete t[i]}))}))}createIntervalColumns(t){var i,s,e,n,r;if(this.config.interval===Tu||this.config.categoryThereOf.size>0||0===this.config.scenarios.length)return;const o="##",h=`(SELECT *, ${Pu(this.config.interval)} as __interval FROM ${this.fromExpr}) as p`,a=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!1,this.config.type))).toString(),l=this.config.scenarios.map((t=>this.translateScenarioSQL(t,!0,this.config.type))).toString(),c=[...new Set(this.exctractScenarioNames(a))],u=this.getRelativeScenarios(),d=new Sd(this.config),f=Nu.OPT===this.config.type||Nu.OPTNOTOTAL===this.config.type,v=this.config.grouped&&(Nu.SUM===this.config.type||Nu.SUMNOTOTAL===this.config.type||Nu.OPT===this.config.type||Nu.OPTNOTOTAL===this.config.type),p=this.checkConfigForPartOf()&&this.config.type!==Nu.LIST,g=t=>this.exec(t),m=t=>(this.config.scenarios.forEach((i=>{const s=new ks(i);!0===s.isValid?0!==t[s.base+"_cnt"]&&0!==t[s.delta+"_cnt"]||(t[i]=Number.NaN):0===t[i+"_cnt"]&&(t[i]=Number.NaN)})),u.forEach(((i,s)=>{var e;t[s]=null!==(e=st(t[s],t[i]))&&void 0!==e?e:it})),t),b=(t,i,s)=>{for(const e of this.config.scenarios)t[e+o+s]=i[e]},y=g(`SELECT ${d.select()}, __interval ${a.length>0?",".concat(a):""}\n FROM ${h}\n GROUP BY ${d}, __interval`),w=t=>"ENTRY"===t.type&&null!=t.restRowGroup;if(this.config.limit>0)for(let e=0;e<t.length;e++){const n=t[e].find(w);if(!n)continue;let r;for(let i=e-1;i>=0&&!r;i--){const s=t[i].filter((t=>"ENTRY"===t.type&&!w(t)));s.length>0&&(r=s)}if(!r)continue;const o=new Set(r.map((t=>t.category))),h=r[0].rowGroup,a=new Map;for(const t of y){if(this.config.grouped&&t.rowGroup!==h)continue;if(o.has(t.category))continue;const e=Du(t.__interval);let n=a.get(e);n||(n={},a.set(e,n));for(const e of c)n[e]=(null!==(i=n[e])&&void 0!==i?i:0)+(null!==(s=t[e])&&void 0!==s?s:0)}a.forEach(((t,i)=>{b(n,m(t),i)}))}for(const i of y){const s=Du(i.__interval);m(i);for(const e of t)for(const t of e)"ENTRY"!==t.type||w(t)||t.category!==i.category||this.config.grouped&&t.rowGroup!==i.rowGroup||f&&t.operation!==i.operation||b(t,i,s)}const x=v||p&&this.config.grouped?g(`SELECT ${xd} as ${ea.ROWGROUP}, __interval ${l.length>0?",".concat(l):""}\n FROM ${h}\n GROUP BY ${xd}, __interval`):[],S=new Map;if(x.forEach((t=>S.set(`${t.rowGroup}${o}${Du(t.__interval)}`,t))),v)for(const i of x){const s=Du(i.__interval),e=m(Object.assign({},i));for(const n of t)for(const t of n)"GROUP_SUM"===t.type&&t.rowGroup===i.rowGroup&&b(t,e,s)}const $=Nu.SUM===this.config.type||Nu.OPT===this.config.type,M=$||p&&!this.config.grouped?g(`SELECT __interval ${l.length>0?",".concat(l):""}\n FROM ${h}\n GROUP BY __interval`):[],_=new Map;if(M.forEach((t=>_.set(Du(t.__interval),t))),$)for(const i of M){const s=Du(i.__interval),e=m(Object.assign({},i));for(const i of t)for(const t of i)"SUM"===t.type&&b(t,e,s)}if(null!=this.config.thereOf&&this.config.thereOf.length>0){const i=[];this.config.thereOf.forEach((t=>{i.push(...g(`SELECT ${this.drillRowGroup} as ${ea.ROWGROUP}, ${ea.CATEGORY}, ${ea.SUBCATEGORY}, __interval ${a.length>0?",".concat(a):""}\n FROM ${h}\n WHERE ${this.createThereOfWhereClause(t)}\n GROUP BY ${this.drillRowGroup}, ${ea.CATEGORY}, ${ea.SUBCATEGORY}, __interval`))}));for(const s of i){const i=Du(s.__interval);m(s);for(const e of t)for(const t of e)"DRILLELEMENT"===t.type&&t.category===s.category&&t.rowGroup===s.rowGroup&&(t.subCategory!==s.subCategory&&t.subCategory!==`${s.subCategory} (${s.rowGroup})`||b(t,s,i))}}if(p){let i="1 <> 1 ";null===(e=this.config.partOf)||void 0===e||e.forEach((t=>{i+=`OR (${ea.CATEGORY} = ${this.bind(t.category)}`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(i+=`and ${ea.ROWGROUP} = ${this.bind(t.rowGroup)}`),i+=")"}));const s=g(`SELECT ${ea.CATEGORY}, ${this.config.grouped?`${ea.ROWGROUP}`:`'SUM_TOTAL' as ${ea.ROWGROUP}`}, __interval ${a.length>0?",".concat(a):""}\n FROM ${h}\n WHERE ${i}\n GROUP BY ${ea.ROWGROUP}, ${ea.CATEGORY}, __interval`),l=new Map;for(const t of s){const i=`${t.rowGroup}${o}${t.category}${o}${Du(t.__interval)}`,s=l.get(i);if(s)for(const i of c)s[i]=(null!==(n=s[i])&&void 0!==n?n:0)+(null!==(r=t[i])&&void 0!==r?r:0);else l.set(i,t)}l.forEach((i=>{const s=Du(i.__interval),e=this.config.grouped?S.get(`${i.rowGroup}${o}${s}`):_.get(s);for(const t of c)i[t]=i[t]/(e?e[t]:Number.NaN);m(i);for(const e of t)for(const t of e)"PARTELEMENT"===t.type&&t.category===i.category&&t.rowGroup===i.rowGroup&&b(t,i,s)}))}}createThereOfWhereClause(t){let i=!0,s="1 <> 1 OR ( ";return null!=t.category&&0!==t.category.length&&t.category.trim()&&(s+=` ${ea.CATEGORY} = ${this.bind(t.category)}`,i=!1),null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(s+=` ${i?"":"AND"} ${ea.ROWGROUP} = ${this.bind(t.rowGroup)}`,i=!1),null!=t.subCategory&&0!==t.subCategory.length&&t.subCategory.trim()&&(s+=` ${i?"":"AND"} ${ea.SUBCATEGORY} = ${this.bind(t.subCategory)}`),s+")"}getRelativeScenarios(){const t=new Map;return this.config.scenarios.forEach((i=>{const s=this.createRelativeScenario(i);null!=s&&t.set(s.key,s.value)})),t}translateScenarioSQL(t,i,s){const e=new ks(t);if(Nu.OPT===s||Nu.OPTNOTOTAL===s){if(e.isValid){const s=i?" * transformOperator(operation)":"",n=i?`SUM((${e.base} - ${e.delta})${s}) as ${t}`:`SUM(${e.base} - ${e.delta}) as ${t}`;return"dr"===e.type?`${n}, SUM(${e.delta}${s}) as dr_${e.delta}`:n}return i?`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`:`SUM(${t}) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}return e.isValid?"dr"===e.type?`SUM((${e.base} * transformOperator(operation)) - (${e.delta} * transformOperator(operation))) as ${t}, SUM(${e.delta} * transformOperator(operation)) as dr_${e.delta}`:`SUM((${e.base} * transformOperator(operation))- (${e.delta} * transformOperator(operation))) as ${t}`:`SUM(${t} * transformOperator(operation)) as ${t}, COUNT(ISNULL(${t})) as ${t}_cnt`}translateAttributeSQL(t){const i=`[${t.arg}]`,s=/^(ac|pp|fc|pl)[1-4]$/.test(t.arg)&&this.config.type!==Nu.OPT&&this.config.type!==Nu.OPTNOTOTAL;switch(t.fn){case"set":return`SETAGG(${i}) as ${t.alias}`;case"first":return`FIRST(${i}) as ${t.alias}`;case"last":return`LAST(${i}) as ${t.alias}`;case"min":return`MIN(${i}) as ${t.alias}`;case"max":return`MAX(${i}) as ${t.alias}`;case"avg":return s?`AVG(${i} * transformOperator(operation)) as ${t.alias}`:`AVG(${i}) as ${t.alias}`;case"sum":return s?`SUM(${i} * transformOperator(operation)) as ${t.alias}`:`SUM(${i}) as ${t.alias}`;case"lit":{const i=t.arg;return`${this.bind(""===i||Number.isNaN(Number(i))?i:Number(i))} as ${t.alias}`}}}get drillRowGroup(){return this.config.grouped?xd:ea.ROWGROUP}exec(t){const i=this.db.exec(t,this.params);return this.config.grouped&&i.forEach((t=>t.rowGroup=null==t.rowGroup?"":String(t.rowGroup))),i}bind(t){return`$${this.params.push(t)-1} `}createOrderString(t){const i=Lu.ASC===t.direction?Lu.DESC:Lu.ASC,s=new Map;t.hierarchy.forEach(((t,i)=>{const e=Et(t),n=null==e?void 0:e.bucket;("variance"===(null==e?void 0:e.kind)||"scenario"===(null==e?void 0:e.kind)&&void 0!==n)&&s.set(i,this.translateSortKeySQL(e,n,i))})),this.sortSelect=[...s.values()].map((t=>`, ${t}`)).join("");const e=t.hierarchy.some((t=>{var i;const s=null===(i=Et(t))||void 0===i?void 0:i.kind;return"scenario"===s||"variance"===s}));e&&(this.sortSelect+=`, CASE WHEN ${ea.CATEGORY} = 'REST' THEN 1 ELSE 0 END as __sortrest`);const n=(t,i,e)=>s.has(i)?`__sortnull${i} asc, __sort${i} ${e}`:`${t} ${e}`,r=t.hierarchy.map(((i,s)=>n(i,s,t.direction))).toString(),o=t.hierarchy.map(((t,s)=>n(t,s,i))).toString();return e?[`__sortrest asc, ${r}`,`__sortrest desc, ${o}`]:[r,o]}translateSortKeySQL(t,i,s){const e=Nu.OPT===this.config.type||Nu.OPTNOTOTAL===this.config.type?"":" * transformOperator(operation)",n=void 0===i?"":`TRIM(CAST(${Pu(Cu)} AS STRING)) = ${this.bind(i)}`,r=t=>`SUM(${n?`(CASE WHEN ${n} THEN ${t} ELSE 0 END)`:t}${e})`,o=t=>`SUM(CASE WHEN ${n?`${n} AND `:""}${t} IS NOT NULL THEN 1 ELSE 0 END) = 0`;if("scenario"===t.kind)return`${r(t.column)} as __sort${s}, CASE WHEN ${o(t.column)} THEN 1 ELSE 0 END as __sortnull${s}`;const h=`(${r(t.base)} - ${r(t.delta)})`;let a=h,l=`${o(t.base)} OR ${o(t.delta)}`;if("dr"===t.type){const i=r(t.delta),s=`ABS(${i}) <= ABS(${h}) * 0.000000001`;a=`CASE WHEN ${s} THEN 0 ELSE ${h} / ABS(${i}) END`,l+=` OR ${s}`}return`${a} as __sort${s}, CASE WHEN ${l} THEN 1 ELSE 0 END as __sortnull${s}`}createRelativeScenario(t){const i=new ks(t);return i.isValid&&"dr"===i.type?{key:`${t}`,value:`dr_${i.delta}`}:null}exctractScenarioNames(t){const i=[];return t.split(",").forEach((t=>t.length>=2?i.push(t.split("as")[1].trim()):null)),i}findDuplicateSubCategories(t){const i=t.map((t=>({count:1,subCategory:`${t.category}##${t.subCategory}`}))).reduce(((t,i)=>(t[i.subCategory]=(t[i.subCategory]||0)+i.count,t)),{});return Object.keys(i).filter((t=>i[t]>1))}createPartOfQuery(t,i){var s;const e=[];let n="1 <> 1 ",r=` ${this.drillRowGroup} as ${ea.ROWGROUP}`,o="ROWNUM()";return null===(s=this.config.partOf)||void 0===s||s.forEach((t=>{n+=`OR (${ea.CATEGORY} = ${this.bind(t.category)}`,null!=t.rowGroup&&0!==t.rowGroup.length&&t.rowGroup.trim()&&(n+=`and ${ea.ROWGROUP} = ${this.bind(t.rowGroup)}`),!1===this.config.grouped&&(r=` 'SUM_TOTAL' as ${ea.ROWGROUP} `,o="1"),n+=")"})),e.push(`SELECT ${o} AS ${ea.ROWNR},\n 'PARTELEMENT' as ${ea.TYPE},\n ${ea.CATEGORY},\n ${r},\n ${t}${this.sortSelect}\n FROM ${this.fromExpr}\n WHERE ${n}\n GROUP BY ${this.drillRowGroup}, ${ea.CATEGORY}, ${ea.TYPE}\n ORDER BY ${i[1]}`),e}checkConfigForPartOf(){return null!=this.config.partOf&&0!==this.config.partOf.length}createThereOfDrillColumns(t,i){if(null==t||0===t.size)return;const s=[],e=[],n=this.fromExpr;t.forEach(((t,i)=>{let e="1 <> 1 ";t.forEach((t=>{e+=` or columnGroup = ${this.bind(String(t.name))} `})),s.push(`SELECT 'ENTRY' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, columnGroup, scenario`),s.push(`SELECT 'ENTRY' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, scenario`),s.push(`SELECT 'DRILLELEMENT' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n category,\n subCategory,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, category, subCategory, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, columnGroup, scenario`),s.push(`SELECT 'GROUP_SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n rowGroup,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, rowGroup, columnGroup, columnSubGroup, scenario`),s.push(`SELECT 'SUM' as rowlevel,\n 'COLUMNGROUP' as columnlevel,\n columnGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, columnGroup, scenario`),s.push(`SELECT 'SUM' as rowlevel,\n 'SUBGROUP' as columnlevel,\n columnGroup,\n columnSubGroup,\n '${i}' as scenario,\n sum(${i} * transformOperator(operation)) as val\n FROM ${n}\n WHERE ${e}\n GROUP BY rowlevel, columnGroup, columnSubGroup, scenario`)}));for(const t of s)e.push(...this.db.exec(t,this.params));this.injectDrillColumnsToResultRows(e,i)}injectDrillColumnsToResultRows(t,i){const s="##";for(const e of t)for(const t of i)for(const i of t)if(i.type===e.rowlevel)if("ENTRY"===e.rowlevel)"COLUMNGROUP"===e.columnlevel&&i.category===e.category?i[e.scenario+s+e.columnGroup]=e.val:"SUBGROUP"===e.columnlevel&&i.category===e.category&&(i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val);else if("DRILLELEMENT"===e.rowlevel){if(!this.config.grouped&&i.rowGroup!==e.rowGroup)continue;"COLUMNGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory?i[e.scenario+s+e.columnGroup]=e.val:"SUBGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory?i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val:"COLUMNGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===`${e.subCategory} (${e.rowGroup})`?i[e.scenario+s+e.columnGroup]=e.val:"SUBGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===`${e.subCategory} (${e.rowGroup})`&&(i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val)}else("SUM"===e.rowlevel||"GROUP_SUM"===e.rowlevel)&&("COLUMNGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory&&(i[e.scenario+s+e.columnGroup]=e.val),"SUBGROUP"===e.columnlevel&&i.category===e.category&&i.subCategory===e.subCategory&&(i[e.scenario+s+e.columnGroup+s+e.columnSubGroup]=e.val))}}class Md{constructor(){this.geometry=new Map}set(t,i,s){let e=this.geometry.get(t);e||(e=new Map,this.geometry.set(t,e)),e.set(i,s)}get(t,i){var s;return null===(s=this.geometry.get(t))||void 0===s?void 0:s.get(i)}}function _d(t,i,s){const e=t[i];if(null==e)return null;const n=Number(e);return isNaN(n)?null:s!==Nu.OPT&&s!==Nu.OPTNOTOTAL||t[ea.TYPE]!==Eu.ENTRY||"-"!==t[ea.OPERATION]?n:-n}class Od{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)?Ls(this.ruleSet.getScenarioColorIndex(t))+t.slice(2):null}getNormalizedHeader(){return this.normalizedHeader}createHeader(t,i,s,e,n,r,o=[],h=0){const a=[];this.attributesByAlias=new Map(o.map((t=>[t.alias,t]))),this.normalizedHeader=this.normalizeHeader(t,i,o,h);const l=this.normalizedHeader.some((t=>void 0!==t.bucket));l&&a.push(this.createIntervalBandRow());const c=new ju(l?1:0,0,Eu.HEADER),u=new ju(l?2:1,0,Eu.SEPERATORLINE);for(const t of this.normalizedHeader){const i=this.attributesByAlias.get(t.name);c.createElement(i?s.get(i.label)||i.label:ra.translateScenarioLabel(t.name,s),t.type,this.createColumnType(t),null,this.setHeaderPrefix(t,s,e,n,r),null,null,null,null),u.createElement(null,t.type,this.createColumnType(t),null,null,this.underlineClass(t.type),null,null,null)}return a.push(c),a.push(u),a}createIntervalBandRow(){const t=new ju(0,0,Eu.HEADER);let i=0;for(;i<this.normalizedHeader.length;){const s=this.normalizedHeader[i];if(void 0===s.bucket){t.createElement(null,s.type,"filler",null,null,null,null,null,null),i+=1;continue}let e=1;for(;i+e<this.normalizedHeader.length&&this.normalizedHeader[i+e].bucket===s.bucket;)e+=1;t.createElement(s.bucketLabel,s.type,"intervalGroup",null,null,null,null,null,null,!1,void 0,e),i+=e}return t}setHeaderPrefix(t,i,s,e,n){let r="";return"category"===t.name&&n&&(0===s.prefix.length&&0===e.length||(r=ra.translateScenarioLabel("in",i)+" "+s.prefix+e)),t.order&&(r+=ra.translateScenarioLabel("ORDER_"+t.order,i)),r}normalizeHeader(t,i,s,e=0){let n=[{name:ea.CATEGORY,group:ea.CATEGORY,type:ea.CATEGORY,order:void 0}];Nu.OPT!==t&&Nu.OPTNOTOTAL!==t||(n=[{name:ea.OPERATION,group:ea.OPERATION,type:ea.OPERATION,order:void 0},{name:ea.CATEGORY,group:ea.CATEGORY,type:ea.CATEGORY,order:void 0}]);const r=s.map((t=>({name:t.alias,group:t.alias,type:t.alias,order:void 0})));return[...i.slice(0,e),...n,...r,...i.slice(e)]}createBodyRows(t,i,s,e){var n;const r=[];let o=-1;const h=new $d(t,i);var a;this.dateBuckets=(a=t.interval)!==Tu&&a!==Cu,this.unsignedEntries=Nu.OPT===t.type||Nu.OPTNOTOTAL===t.type;const l=h.execute(s,e);this.hasBlankRowGroup=h.hasBlankRowGroup;const c=this.calculateColumnStatistics(l,t.barColumns,t.interval!==Tu),u=(null!==(n=t.barColumns)&&void 0!==n?n:[]).filter((t=>t.toUpperCase().trim()in Tt)),d=u.length>0&&t.interval===Tu&&0===t.categoryThereOf.size&&function(t){for(const i of t)for(const t of i){const i=t[ea.TYPE];if(i===Eu.SUM||i===Eu.GROUPSUM||i===Eu.DRILLELEMENT||i===Eu.PARTELEMENT)return!0}return!1}(l)?function(t,i,s){const e=new Md;for(const n of i){let i,r=0,o=0;const h=[],a=(t,i)=>{h.push(i),e.set(t,n,i)};for(const e of t)for(const t of e){const e=t[ea.TYPE];if(e===Eu.GROUPHEAD){r=0,i=void 0;continue}const h=_d(t,n,s);if(e===Eu.ENTRY){if(null===h){i=void 0;continue}a(t,{start:r,end:r+h,min:0,max:0,kind:"cascade"}),i={start:r,end:r+h},o=i.start,r+=h}else if(e===Eu.SUM||e===Eu.GROUPSUM){if(null===h){i=void 0;continue}a(t,{start:0,end:h,min:0,max:0,kind:"anchor"}),i={start:0,end:h},o=0,r=e===Eu.GROUPSUM?0:h}else if(e===Eu.DRILLELEMENT){if(null===h||void 0===i)continue;const s=o+(Math.sign(i.end-i.start)||1)*Math.abs(h);a(t,{start:o,end:s,min:0,max:0,kind:"thereof",parentStart:i.start,parentEnd:i.end}),o=s}else if(e===Eu.PARTELEMENT){if(null===h||void 0===i)continue;const s=o+h*(i.end-i.start);a(t,{start:o,end:s,min:0,max:0,kind:"partof",parentStart:i.start,parentEnd:i.end}),o=s}}let l=0,c=0;for(const t of h)l=Math.min(l,t.start,t.end),c=Math.max(c,t.start,t.end);for(const t of h)t.min=l,t.max=c}return e}(l,u,t.type):void 0;for(const s of l)o+=1,r.push(...this.createRow(t.i18n,i,t.scenariosUnitType,s,o,-1,t.categoryWidth,t.measureScale,t.barColumns,c,d));return r}calculateColumnStatistics(t,i,s=!1){const e=new Map;if(!i||0===i.length)return e;const n=new Map;for(const t of i)e.set(t,{min:1/0,max:-1/0,absMax:0,median:0}),n.set(t,[]);for(const r of t)for(const t of r){const r=t[ea.TYPE];if(r!==Eu.SUM&&r!==Eu.GROUPSUM)for(const r of i){const i=s?this.extractIntervalColumnValues(t,r):[this.extractColumnValue(t,r)];for(const t of i)if(null!==t&&!isNaN(t)){const i=e.get(r);i.min=Math.min(i.min,t),i.max=Math.max(i.max,t),n.get(r).push(Math.abs(t))}}}for(const[t,i]of e){i.min!==1/0&&i.max!==-1/0||(i.min=0,i.max=0),i.absMax=Math.max(Math.abs(i.min),Math.abs(i.max));const s=n.get(t);if(s.length>0){s.sort(((t,i)=>t-i));const t=Math.floor(s.length/2);i.median=s.length%2==0?(s[t-1]+s[t])/2:s[t]}e.set(t,i)}return e}extractIntervalColumnValues(t,i){const s=i+"##",e=[];for(const i of Object.keys(t))if(i.startsWith(s)){const s=Number(t[i]);e.push(isNaN(s)?null:s)}return e}extractColumnValue(t,i){if(void 0!==t[i]){const s=Number(t[i]);return isNaN(s)?null:s}for(const s of Object.keys(t))if(s===i||s.endsWith("##"+i)||s===i+"##"+i){const i=Number(t[s]);if(!isNaN(i))return i}return null}createRow(t,i,s,e,n,r,o,h,a,l,c){var u,d,f;const v=[];let p;for(const g of e){const m=g[ea.ROWGROUP],b=""===m?"-":m,y=g[ea.SUBCATEGORY],w=g[ea.TYPE],x=g[ea.ROWNR]>=2;p=null!==(d=null!==(u=g.operation)&&void 0!==u?u:g.restOperation)&&void 0!==d?d:p;const S=this.createDetailRow(w,r+=1,n,e.length);S.key=this.rowKey(g);for(const e of this.normalizedHeader){const n=this.getRawDataRowElement(g,e),r=null!==(f=null==a?void 0:a.includes(e.type))&&void 0!==f&&f,u=r?null==l?void 0:l.get(e.type):void 0,d=r&&void 0===e.bucket&&e.name===e.group&&e.name===e.type?null==c?void 0:c.get(g,e.type):void 0;S.createElement(this.translateSumCellLabel(t,i,n,b,y,w,e.type),e.type,this.createColumnType(e),this.setCellType(e.type,s),this.translateCellPrefix(i,w,e.type),this.translateScenarioCSS(e.type,n,p),x,o,null==h?void 0:h.value,r,u,1,d);const v=S.elements[S.elements.length-1];this.dateBuckets&&void 0!==e.bucket&&(v.date=Yi(e.bucket));const m=new ks(e.type);m.isValid&&(v.direction=this.resolveDirection(m,p))}v.push(S)}return v}rowKey(t){var i;const s=null!=t.restRowGroup?t.restRowGroup:"NO_GROUP"===t.rowGroup?void 0:t.rowGroup;switch(t.type){case Eu.ENTRY:return{rowGroup:s,category:t.category,subCategory:t.subCategory};case Eu.DRILLELEMENT:return{rowGroup:s,category:t.category,subCategory:null!==(i=t.rawSubCategory)&&void 0!==i?i:t.subCategory};case Eu.GROUPSUM:return{rowGroup:s,row:"subtotal"};case Eu.SUM:return{row:"total"};default:return}}getRawDataRowElement(t,i){return void 0!==i.bucket?t[i.type+"##"+i.bucket]:i.name===i.group&&i.name===i.type?t[i.name]:i.name===i.group&&i.name!==i.type?t[i.type+"##"+i.name]:t[i.type+"##"+i.group+"##"+i.name]}createDetailRow(t,i,s,e){switch(t){case Eu.GROUPHEAD:return new ju(i,s,Eu.HEADER);case Eu.SUM:case Eu.GROUPSUM:return new ju(e+2,s,Eu.SUM);case Eu.DRILLELEMENT:return new ju(e+2,s,Eu.DRILLELEMENT);case Eu.PARTELEMENT:return new ju(e+2,s,Eu.PARTELEMENT);default:return new ju(i,s,Eu.STANDARD)}}translateSumCellLabel(t,i,s,e,n,r,o){return this.attributesByAlias.has(o)||!1===Number.isNaN(Number(s))||this.isOperationColumn(o)?s:this.isGroupHeadCategory(r,o)?t===_t.ALL?`${i.get(s)||s}`:s:this.isEntryCategory(r,o)?t===_t.ALL||"REST"===s?`${i.get(s)||s}`:s:this.isDrillElementCategory(r,o)?t===_t.ALL?`${i.get(n)||n}`:`${n}`:this.isPartElementCategory(r,o)?t===_t.ALL||"SUM_TOTAL"===e?`${i.get(e)||e}`:`${e}`:this.isSumElementCategory(r,o)?t===_t.ALL||"SUM_TOTAL"===e?`${i.get(e)||e}`:e:"GROUPHEAD"===r&&null==s||s===it?s:Number.isNaN(Number(s))?"-":Number(s)}isOperationColumn(t){return"operation"===t}translateScenarioCSS(t,i,s){if(this.attributesByAlias.has(t))return"attribute";const e=new ks(t);let n="pos";return i<0&&(n="neg"),e.isValid?n+"_"+this.resolveDirection(e,s)+("dr"===e.type?" relative_variance":""):t}resolveDirection(t,i){return As(t.direction,i,!this.unsignedEntries)}setCellType(t,i){if("category"===t)return"";const s=this.attributesByAlias.get(t);if(s)return s.isNumeric?"decimal":"";let e;const n=new ks(t);return i===$t.PERCENT?(e="percent",n.isValid&&"d"===n.type&&(e="percentpoint")):(e="decimal",n.isValid&&"dr"===n.type&&(e="percent")),e}isDrillElementCategory(t,i){return"DRILLELEMENT"===t&&"category"===i}isPartElementCategory(t,i){return"PARTELEMENT"===t&&"category"===i}isSumElementCategory(t,i){return("GROUP_SUM"===t||"SUM"===t)&&"category"===i}isEntryCategory(t,i){return"ENTRY"===t&&"category"===i}isGroupHeadCategory(t,i){return"GROUPHEAD"===t&&"category"===i}translateCellPrefix(t,i,s){return this.isOperationColumn(s)||this.isGroupHeadCategory(i,s)||this.isEntryCategory(i,s)?null:this.isDrillElementCategory(i,s)?`${t.get("thereof")} `:this.isPartElementCategory(i,s)?`${t.get("part_of")} `:null}createColumnType(t){return t.name===t.group&&t.name===t.type?"base":t.name===t.group?"columnGroup":"columnSubGroup"}}class kd{constructor(t,i,s,e){this.fromExpr="",this.rowCount=0,this.headerRows=[],this.bodyRows=[],this.intervalBuckets=[],this.ruleSet=t||new Cs,this.db=i,this.dataSetFactory=new Od(this.ruleSet),this.config=this.initConfig(e),this.i18n=this.initI18n(new Map),this.setSource(s,e.filter)}setI18n(t){this.i18n=this.initI18n(t)}initI18n(t){const i=new Map([["",""],["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=Ru.DIRTY,new Map([...i,...t||new Map])}initConfig(t){this.state=Ru.DIRTY;const i=t,s=this;return t.scenarios.sort(((t,i)=>s.ruleSet.getScenarioSorIndex(t)-s.ruleSet.getScenarioSorIndex(i))),i}setConfig(t){this.config=this.initConfig(t)}setSource(t,i){var s,e;if(this.state=Ru.DIRTY,this.fromExpr=$(this.db,t,i),!this.fromExpr)return void(this.rowCount=0);const n=this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);this.rowCount=null!==(e=null===(s=n[0])||void 0===s?void 0:s.cnt)&&void 0!==e?e: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=Ru.UP_TO_DATE}getHeader(){return this.state===Ru.DIRTY&&this.update(),this.headerRows}getBody(){return this.state===Ru.DIRTY&&this.update(),this.bodyRows}getColumns(){return this.state===Ru.DIRTY&&this.update(),this.dataSetFactory.getNormalizedHeader()}prepareIntervalBuckets(){this.intervalBuckets=[],this.config.interval===Tu||!this.fromExpr||this.config.categoryThereOf.size>0?this.config.interval=Tu:(this.config.interval=function(t,i,s){var e;if(s!==ot.AUTO)return s;const n=t.exec(`SELECT [date] as d FROM ${i}`);let r,o;for(const t of n){const i=null===(e=zu(t.d))||void 0===e?void 0:e.toMillis();void 0!==i&&(r=void 0===r?i:Math.min(r,i),o=void 0===o?i:Math.max(o,i))}return void 0===r||void 0===o?ot.DAY:(new lt).calculateDistanceType(y.fromMillis(r),y.fromMillis(o))}(this.db,this.fromExpr,this.config.interval),this.intervalBuckets=function(t,i,s,e){if(s===Cu){const e=t.exec(`SELECT ${Pu(s)} as __interval, COALESCE([setnameIndex],[setNameIndex]) as __index FROM ${i}`),n=new Set,r=new Map,o=[];for(const t of e){const i=Du(t.__interval);n.has(i)||(n.add(i),o.push({key:i,label:0===i.length?"-":i}));const s=Wu(t.__index),e=r.get(i);void 0!==s&&(void 0===e||s<e)&&r.set(i,s)}if(r.size>0){const t=t=>{var i;return null!==(i=r.get(t.key))&&void 0!==i?i:Number.POSITIVE_INFINITY};o.sort(((i,s)=>t(i)===t(s)?0:t(i)<t(s)?-1:1))}return o}const n=t.exec(`SELECT ${Pu(s)} as __interval FROM ${i}`),r=new Set,o=[];for(const t of n){const i=zu(t.__interval);if(!i)continue;const s=i.toISO();r.has(s)||(r.add(s),o.push(i))}o.sort(((t,i)=>t.toMillis()-i.toMillis()));const h=new lt;return h.setLocale(e),o.map((t=>({key:t.toISO(),label:h.getDateString(t,s)})))}(this.db,this.fromExpr,this.config.interval,this.config.locale),0===this.intervalBuckets.length&&(this.config.interval=Tu))}normalizeScenarios(t,i,s,e=[]){var n;const r=[],o=null===(n=null==s?void 0:s.hierarchy)||void 0===n?void 0:n.map((t=>Et(t))).find((t=>"dim"!==(null==t?void 0:t.kind))),h=this.config.interval===Cu?null==o?void 0:o.bucket:void 0,a=(t,i)=>{var e;return null==o||(null===(e=Et(t))||void 0===e?void 0:e.column)!==o.column||void 0!==h&&h!==i?void 0:s.direction};if(e.length>0){for(const i of e)for(const s of t)r.push({name:s,group:s,type:s,order:a(s,i.key),bucket:i.key,bucketLabel:i.label});return r}for(const s of t){if(null==i?void 0:i.has(s)){const t=i.get(s);for(const i of t){r.push({name:i.name,group:i.name,type:s,order:void 0});for(const t of i.subGroups)r.push({name:t,group:i.name,type:s,order:void 0})}r.push({name:"REST",group:"REST",type:s,order:void 0})}r.push({name:s,group:s,type:s,order:a(s)})}return r}hasNoData(){return 0===this.rowCount}orderBucketWarning(){var t,i;if(this.hasNoData()||this.state!==Ru.UP_TO_DATE)return;const s=(null!==(i=null===(t=this.config.sortOrder)||void 0===t?void 0:t.hierarchy)&&void 0!==i?i:[]).map((t=>{var i;return null===(i=Et(t))||void 0===i?void 0:i.bucket})).filter((t=>void 0!==t));if(0===s.length)return;if(this.config.interval!==Cu)return`order: '@${s[0]}' needs interval setname, the bucket is ignored.`;const e=s.find((t=>!this.intervalBuckets.some((i=>i.key===t))));return void 0===e?void 0:`order: setname '${e}' 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!==Ru.UP_TO_DATE)return;const i=this.intervalBuckets.length;return 0===i?{id:"WARN_categoryIntervalPositionNoInterval",message:"categoryIntervalPosition: needs an active interval, the value is ignored."}:t>i?{id:"WARN_categoryIntervalPositionRange",message:`categoryIntervalPosition: '${t}' is greater than the number of interval groups, ${i} is used.`}:void 0}hasBlankRowGroup(){return this.dataSetFactory.hasBlankRowGroup}}class Ad{constructor(){this.title="",this.scenarios=[],this.scenariosUnitType=$t.DECIMAL,this.grouped=!1,this.showGroupTitle=!0,this.thereOf=[],this.categoryThereOf=new Map,this.partOf=[],this.attributes=[],this.sortOrder=new tt(new cl).default(),this.type=Nu.LIST,this.limit=0,this.i18n=_t.ALL,this.categoryWidth=Ot.W25,this.measureScale=new la,this.measureUnit="",this.measureType=kt.VOLUME,this.showMeasureScale=!0,this.filter="",this.barColumns=[],this.interval="none",this.categoryIntervalPosition=0,this.locale="de"}}class Rd{constructor(t,i,s,e,n,r){this.tableDrillGroupAdapter=t,this.stringAdapter=i,this.orderAdapter=s,this.db=e,this.fromExpr=n,this.onQueryError=r}adapt(t){const i=new Ad;return R.isString(t.title)&&(i.title=t.title),R.isArray(t.scenarios)&&(i.scenarios=Z.adaptArray(t.scenarios,this.stringAdapter)),R.isExisting(t.scenariosUnitType)&&(i.scenariosUnitType=t.scenariosUnitType),R.isBoolean(t.grouped)&&(i.grouped=t.grouped),R.isBoolean(t.showGroupTitle)&&(i.showGroupTitle=t.showGroupTitle),R.isBoolean(t.showMeasureScale)&&(i.showMeasureScale=t.showMeasureScale),R.isArray(t.thereOf)&&(i.thereOf=Z.adaptArray(t.thereOf,this.tableDrillGroupAdapter)),R.isExisting(t.categoryThereOf)&&(i.categoryThereOf=t.categoryThereOf),R.isArray(t.partOf)&&(i.partOf=Z.adaptArray(t.partOf,this.tableDrillGroupAdapter)),R.isArray(t.attributes)&&(i.attributes=t.attributes),R.isExisting(t.order)&&(i.sortOrder=this.orderAdapter.adapt(t.order)),R.isExisting(t.type)&&(i.type=t.type),R.isNumber(t.limit)&&(i.limit=t.limit),R.isExisting(t.i18n)&&(i.i18n=t.i18n),R.isExisting(t.categoryWidth)&&(i.categoryWidth=t.categoryWidth),R.isExisting(t.measureScale)&&(i.measureScale=ll.calculateMeasureScale(this.db,this.fromExpr,i.scenarios,t.measureScale,this.onQueryError)),R.isExisting(t.measureType)&&(i.measureType=t.measureType),R.isString(t.measureUnit)&&(i.measureUnit=t.measureUnit),R.isString(t.filter)&&(i.filter=t.filter.trim()),R.isArray(t.barColumns)&&(i.barColumns=t.barColumns),R.isString(t.interval)&&(i.interval=t.interval),R.isNumber(t.categoryIntervalPosition)&&(i.categoryIntervalPosition=t.categoryIntervalPosition),R.isString(t.locale)&&(i.locale=t.locale),i}default(){return new Ad}}class Nd{constructor(){this.rowGroup="",this.category="",this.subCategory="",this.partOf=""}}class Ld{constructor(){}adapt(t){const i=new Nd;return R.isString(t.rowGroup)&&(i.rowGroup=t.rowGroup),R.isString(t.category)&&(i.category=t.category),R.isString(t.subCategory)&&(i.subCategory=t.subCategory),R.isString(t.partOf)&&(i.partOf=t.partOf),i}default(){return new Nd}}const Ed=class{constructor(i){t(this,i),this.tableName="",this.dataVersion=0,this.sumTitle="SUM_TOTAL",this.scenarios=[],this.scenariosDataFormat=$t.DECIMAL,this.grouped=!1,this.limit=0,this.showGroupTitle=!0,this.thereof=[],this.partof=[],this.order={hierarchy:[],direction:Lu.ASC},this.categorythereof=new Map,this.attributeColumns=[],this.type=Nu.LIST,this.categoryWidth=Ot.INF,this.dataFormatDigits={percent:2,decimal:1},this.i18n=new Map,this.i18nMode=_t.ALL,this.measureScale="_",this.measureUnit="",this.showMeasureScale=!0,this.measureType=kt.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 zl,this.barColumnLayouts=new Map,this.relayout=()=>{this.barColumnLayouts.size>0&&n(this)},a(this),this.componentStyle=k(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,i){var s,e,n;const r={regions:[],metadata:{},diagnostics:[]},o=null===(s=this.element.shadowRoot)||void 0===s?void 0:s.querySelector("table");if(r.metadata.hasNoData=null===(n=null===(e=this.table)||void 0===e?void 0:e.hasNoData())||void 0===n||n,!this.table||!o)return r;const h=o.querySelector("thead"),a=o.querySelector("tbody");h&&r.regions.push({id:"header",rect:ti(h,t)}),a&&r.regions.push({id:"body",rect:ti(a,t)});const l=this.table.getHeader(),c=this.table.getBody(),u=this.table.getColumns();if(r.metadata.headerRowCount=l.length,r.metadata.rowCount=c.length,r.metadata.columnCount=u.length,r.metadata.cellCount=c.reduce(((t,i)=>t+i.getCells().length),0),"full"!==i)return r;const d=[],f=[],v=(i,s,e)=>{const n=e?Array.from(e.children).filter((t=>"tr"===t.localName)):[];s.forEach(((s,e)=>{const o=n[e];if(!o)return;d.push({section:i,index:e,type:s.type,rect:ti(o,t),point:Ii(o)});const h=s.getCells(),a=Array.from(o.children);h.length===a.length?h.forEach(((s,n)=>{var r,o;const h=a[n],l={kind:"header"===i?"headerCell":"cell",row:e,column:s.index,key:s.key||void 0,colSpan:s.colSpan,value:null!==(r=s.value)&&void 0!==r?r:void 0,text:(null===(o=h.textContent)||void 0===o?void 0:o.trim())||void 0,type:s.type||void 0,rect:ti(h,t),point:Ii(h)};l.point&&(l.content=hi(h,t),l.contentSign=ai(h)||void 0);const c=h.querySelector("svg.cell-bar-chart");c&&(l.bar={variant:c.classList.contains("waterfall-bar")?"waterfall":c.classList.contains("relative-variance")?"relative":"absolute",rect:ti(c,t)}),f.push(l)})):r.diagnostics.push({id:`WARN_layout_cell_pairing_${i}_${e}`,type:"warning",message:`layout-state: model/DOM cell count mismatch in ${i} row ${e} (${h.length} vs ${a.length}); cell details skipped for this row.`})}))};return v("header",l,h),v("body",c,a),r.elements=f,r.table={rows:d,columns:u.map(((t,i)=>({index:i,key:t.name,group:t.group,type:t.type,bucket:t.bucket})))},r}render(){var t;return i(s,{class:{"no-data":!0===(null===(t=this.table)||void 0===t?void 0:t.hasNoData())}},(()=>{var t,s,e,n;if(void 0===this.table)return;if(this.table.hasNoData()){const s=null!==(t=this.i18n.get("no-data"))&&void 0!==t?t:"No Data";return i("div",{class:"empty-state"},s)}const r=null===(n=null===(e=null===(s=this.stores)||void 0===s?void 0:s.context)||void 0===e?void 0:e.state)||void 0===n?void 0:n.locale;return i("table",null,i("thead",null,this.table.getHeader().map((t=>i("tr",{class:t.cssStyle},t.getCells().map((t=>i("th",{colSpan:t.colSpan,class:t.cssStyle},t.getAsHeaderList().map(((s,e,n)=>i("span",null,e===n.length-1?i("span",{class:" "===s?"table-footer":""},s,t.drawPrefix()," "):i("span",null,s,t.drawPrefix(),i("br",null)))))))))))),i("tbody",null,this.table.getBody().map((t=>i("tr",Object.assign({class:t.cssStyle},ji(t.key,"element")),null==t?void 0:t.getCells().map((s=>{var e,n,o,h,a;return i("td",Object.assign({colSpan:s.colSpan,class:s.type?`${s.cssStyle} ${s.type}`:s.cssStyle},t.key&&null!=s.value&&""!==s.value&&"-"!==s.value?ji(Object.assign(Object.assign({},t.key),{date:s.date,scenario:s.key}),"element"):{}),null!=s.prefix?i("span",{class:s.cssStyle+" "+s.prefixStyle},s.drawPrefix()):"",!s.isBarChart||!s.columnStats||s.value===it||!this.showGroupTitle&&t.type===Eu.HEADER||void 0===s.waterfall&&t.type===Eu.SUM?s.draw(this.componentDataFormatDigits,r):void 0!==s.waterfall?i(wd,{value:s.value,scenario:s.key,columnStats:s.columnStats,height:18*this.scaleFactor,isRelative:!1,isPositiveGood:"pos"===s.direction,measureScale:s.measureScale,locale:r,decimalDigits:Cd(s,this.componentDataFormatDigits),columnWidthEm:this.barColumnMaxWidth,styles:this.barChartStyles,waterfall:s.waterfall}):i(yd,{value:s.value,scenario:s.key,columnStats:s.columnStats,height:18*this.scaleFactor,isRelative:s.key.startsWith("dr"),isPositiveGood:"pos"===s.direction,measureScale:Td(s),locale:r,decimalDigits:Cd(s,this.componentDataFormatDigits),percentDigits:null!==(n=null===(e=this.barColumnLayouts.get(s.key))||void 0===e?void 0:e.percentDigits)&&void 0!==n?n:this.componentDataFormatDigits.percent,percentSign:null===(o=this.barColumnLayouts.get(s.key))||void 0===o?void 0:o.percentSign,columnWidthEm:this.barColumnMaxWidth,labelWidths:null===(h=this.barColumnLayouts.get(s.key))||void 0===h?void 0:h.labels,sideMax:null===(a=this.barColumnLayouts.get(s.key))||void 0===a?void 0:a.sideMax,styles:this.barChartStyles}))})))))))})())}componentWillRender(){var t,i,s,e,n,r,o,h,a,l,u;this.stores||(this.stores=c(this.element));const d=this.stores.db.db;this.componentDataFormatDigits=(new Ul).adapt(this.dataFormatDigits);try{const i=this.prepareConfig(d);this.table=new kd(new Cs(this.ruleSetConfig),d,this.tableName,i),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===(i=this.errors)||void 0===i||i.addOrReplace({id:"ERR_sql",type:"error",message:`Query failed: ${t instanceof Error?t.message:t}`})}(null===(s=this.table)||void 0===s?void 0:s.hasBlankRowGroup())?null===(e=this.errors)||void 0===e||e.addOrReplace({id:"WARN_blankRowGroup",type:"warning",message:"grouped: rows with blank rowGroup found, they are grouped under '-'."}):null===(n=this.errors)||void 0===n||n.remove("WARN_blankRowGroup");const f=null===(r=this.table)||void 0===r?void 0:r.orderBucketWarning();f?null===(o=this.errors)||void 0===o||o.addOrReplace({id:"WARN_orderBucket",type:"warning",message:f}):null===(h=this.errors)||void 0===h||h.remove("WARN_orderBucket");const v=null===(a=this.table)||void 0===a?void 0:a.categoryIntervalPositionWarning();for(const t of["WARN_categoryIntervalPositionNoInterval","WARN_categoryIntervalPositionRange"])(null==v?void 0:v.id)===t?null===(l=this.errors)||void 0===l||l.addOrReplace({id:t,type:"warning",message:v.message}):null===(u=this.errors)||void 0===u||u.remove(t);this.barColumnLayouts=this.collectBarColumnLayouts(),this.barChartStyles=this.prepareBarChartStyles()}prepareConfig(t){var i,s,e;const n=$(t,this.tableName,this.filter);return new Rd(new Ld,new cl,new tt(new cl,!0),t,n,(t=>{throw t})).adapt({title:this.sumTitle,scenarios:this.scenarios,scenariosUnitType:this.scenariosDataFormat,grouped:this.grouped,showGroupTitle:this.showGroupTitle,thereOf:this.thereof,partOf:this.partof,categoryThereOf:this.categorythereof,attributes:this.attributeColumns,order:this.order,type:this.type,limit:this.limit,i18n:this.i18nMode,categoryWidth:this.categoryWidth,measureScale:this.measureScale,measureUnit:this.measureUnit,measureType:this.measureType,showMeasureScale:this.showMeasureScale,filter:this.filter,barColumns:this.barColumns,interval:this.interval,categoryIntervalPosition:this.categoryIntervalPosition,locale:(null===(e=null===(s=null===(i=this.stores)||void 0===i?void 0:i.context)||void 0===s?void 0:s.state)||void 0===e?void 0:e.locale)||"de"})}prepareBarChartStyles(){var t;const i=!(this.unitScaling>0),s=!(this.percentageScaling>0),e=i?this.autoUnitScaling():this.unitScaling,n=s?this.autoPercentageScaling():this.percentageScaling;return(i||s)&&(null===(t=this.reportAutoScaling)||void 0===t||t.call(this,{unit:i?e:void 0,percentage:s?n:void 0})),this.componentStyle((t=>{var i,s,r,o,h,a,l,c,u,d,f,v,p,g,m,b,y,w,x,S,$,M,_,O,k,A;const R=null===(i=t["bn-chart-time"])||void 0===i?void 0:i.varianceStyles,N=null===(s=t["bn-chart-time"])||void 0===s?void 0:s.barStyles;return{positive:{stroke:(null===(r=null==R?void 0:R.pos)||void 0===r?void 0:r.stroke)||"#008f96",fill:(null===(o=null==R?void 0:R.pos)||void 0===o?void 0:o.fill)||"#008f96",fillpattern:Us(null===(h=null==R?void 0:R.pos)||void 0===h?void 0:h.fillpattern)||"solid"},negative:{stroke:(null===(a=null==R?void 0:R.neg)||void 0===a?void 0:a.stroke)||"#ff0000",fill:(null===(l=null==R?void 0:R.neg)||void 0===l?void 0:l.fill)||"#ff0000",fillpattern:Us(null===(c=null==R?void 0:R.neg)||void 0===c?void 0:c.fillpattern)||"solid"},neutral:{stroke:(null===(u=null==R?void 0:R.neu)||void 0===u?void 0:u.stroke)||"#808080",fill:(null===(d=null==R?void 0:R.neu)||void 0===d?void 0:d.fill)||"#808080",fillpattern:Us(null===(f=null==R?void 0:R.neu)||void 0===f?void 0:f.fillpattern)||"outlined"},scenarios:Es({ac:{stroke:(null===(v=null==N?void 0:N.ac)||void 0===v?void 0:v.stroke)||"#404040",fill:(null===(p=null==N?void 0:N.ac)||void 0===p?void 0:p.fill)||"#404040",fillpattern:Us(null===(g=null==N?void 0:N.ac)||void 0===g?void 0:g.fillpattern)||"solid"},pp:{stroke:(null===(m=null==N?void 0:N.pp)||void 0===m?void 0:m.stroke)||"#A6A6A6",fill:(null===(b=null==N?void 0:N.pp)||void 0===b?void 0:b.fill)||"#A6A6A6",fillpattern:Us(null===(y=null==N?void 0:N.pp)||void 0===y?void 0:y.fillpattern)||"solid"},fc:{stroke:(null===(w=null==N?void 0:N.fc)||void 0===w?void 0:w.stroke)||"#404040",fill:(null===(x=null==N?void 0:N.fc)||void 0===x?void 0:x.fill)||"#ffffff",fillpattern:Us(null===(S=null==N?void 0:N.fc)||void 0===S?void 0:S.fillpattern)||"hatched"},pl:{stroke:(null===($=null==N?void 0:N.pl)||void 0===$?void 0:$.stroke)||"#404040",fill:(null===(M=null==N?void 0:N.pl)||void 0===M?void 0:M.fill)||"#ffffff",fillpattern:Us(null===(_=null==N?void 0:N.pl)||void 0===_?void 0:_.fillpattern)||"outlined"}},new Cs(this.ruleSetConfig)),fontColor:(null===(O=t.global)||void 0===O?void 0:O.fontColor)||"#000000",fontSize:((null===(k=t.global)||void 0===k?void 0:k.fontSizePx)||13.3333)*Iu*this.scaleFactor,emPx:((null===(A=t.global)||void 0===A?void 0:A.fontSizePx)||13.3333)*this.scaleFactor,fontFamily:this.labelFontFamily(),unitScaling:e,percentageScaling:n,scaleFactor:this.scaleFactor}}))}labelFontFamily(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif"}))}emPx(){return this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}))*this.scaleFactor}autoUnitScaling(){var t;const i=this.emPx(),s=i*Iu;let e=1/0;for(const{isRelative:n,absMax:r,labels:o,sideMax:h}of this.barColumnLayouts.values()){if(n||r<=0)continue;const a=id(this.barColumnMaxWidth,i,o,h);for(const i of["neg","pos"]){const n=null!==(t=h[i])&&void 0!==t?t:0;if(n<=0)continue;const{maxBarWidth:r,cutWidth:o}=a[i];e=Math.min(e,Math.min(.8*r,o)/(n*s))}}return Number.isFinite(e)&&s>0?e:.01}autoPercentageScaling(){var t,i;const s=this.emPx(),e=s*Iu;let n=1/0;for(const{isRelative:r,absMax:o,labels:h,sideMax:a}of this.barColumnLayouts.values()){if(!r||o<=0)continue;const l=10*this.scaleFactor,{negPinLength:c,posPinLength:u}=sd(this.barColumnMaxWidth,s,h,l),d=100*((null!==(t=a.neg)&&void 0!==t?t:0)+(null!==(i=a.pos)&&void 0!==i?i:0));n=Math.min(n,(c+u)/(d*e))}return Number.isFinite(n)&&e>0?n:.5}collectBarColumnLayouts(){var t,i,s,e;const n=new Map;if(!this.table||this.table.hasNoData())return n;const r=new Map;for(const i of this.table.getBody())if(i.type!==Eu.SUM)for(const s of i.getCells())s.isBarChart&&s.columnStats&&void 0===s.waterfall&&("number"!=typeof s.value||isNaN(s.value)||r.set(s.key,[...null!==(t=r.get(s.key))&&void 0!==t?t:[],s]));const o=this.emPx(),h=o*Iu,a=10*this.scaleFactor,l=null===(e=null===(s=null===(i=this.stores)||void 0===i?void 0:i.context)||void 0===s?void 0:s.state)||void 0===e?void 0:e.locale,c=this.labelFontFamily();for(const[t,i]of r){const s=t.startsWith("dr"),e=i.map((t=>t.value)),r=(t,n)=>{var r;const o={neg:e.some((t=>t<0))?0:void 0,pos:e.some((t=>t>0))?0:void 0},a=dd(o);for(const e of i){const i=e.value,u=i>0||0===i&&a?"pos":"neg",d=hd(i,s,Td(e),l,t,n,Cd(e,this.componentDataFormatDigits));o[u]=Math.max(null!==(r=o[u])&&void 0!==r?r:0,Ju(d,h,c,s))}return o};let u=Math.min(20,Math.max(0,Math.trunc(this.componentDataFormatDigits.percent)||0)),d=!0,f=r(u,d);for(;s&&(u>0||d)&&!Zu(this.barColumnMaxWidth,o,f,a);)u>0?u--:d=!1,f=r(u,d);const v=Math.max(...e.map(Math.abs))*(s?100:1),p={neg:void 0===f.neg?void 0:Math.max(0,...e.map((t=>-t))),pos:void 0===f.pos?void 0:Math.max(0,...e)};n.set(t,{isRelative:s,absMax:v,labels:f,sideMax:p,percentDigits:u,percentSign:d})}return n}get element(){return e(this)}};function Td(t){return"percentpoint"===t.type?.01:t.measureScale}function Cd(t,i){return"percentpoint"===t.type?i.percent:"decimal"===t.type?i.decimal:void 0}Ed.style=':host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{position:relative;display:inline-block}table{background-color:var(--bn-font-background, white);font-size:var(--bn-font-size, 1em);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);border-spacing:0.3em 0}thead{border-style:none}tr:first-child td{border-top:none;padding-top:0.5em}td.ac1,td.ac2,td.ac3,td.ac4,td.pp1,td.pp2,td.pp3,td.pp4,td.pl1,td.pl2,td.pl3,td.pl4,td.fc1,td.fc2,td.fc3,td.fc4,td.share,td.variance,td.pos_pos,td.pos_neg,td.neg_pos,td.neg_neg,td.pos_neutral,td.neg_neutral{text-align:right}.category-w100{min-width:100em;max-width:100em}.category-w50{min-width:50em;max-width:50em}.category-w25{min-width:25em;max-width:25em}.category-w20{min-width:20em;max-width:20em}.category-w15{min-width:15em;max-width:15em}.category-w10{min-width:10em;max-width:10em}.category-w5{min-width:5em;max-width:5em}.prefix-second{color:transparent;font-style:normal}.prefix-first{font-style:normal}th{border-bottom:0.1em solid black;text-align:right;font-weight:normal;vertical-align:text-top}td.columnGroup,th.columnGroup{font-size:0.6em}td.columnSubGroup,th.columnSubGroup{font-size:0.6em;border-spacing:0em 0;font-style:italic}td.base,th.base{font-style:normal}th.ofit,td.ofit,tr.ofit,th.partof,td.partof,tr.partof{font-size:0.6em;font-style:italic}td.ofit,td.partof{font-size:0.6em;font-style:italic}th.ofit td,tr.ofit td,th.partof td,tr.partof td{border-top:0em solid black;padding-left:1em}th.ofit share,th.partof share,tr.share td{border-top:0em solid black}th.share,tr.share,td.share{font-size:0.6em;font-style:italic}th.filler{border-bottom:0em solid black;text-align:right}td.filler{border-top:0em none !important;border-bottom:0em none;text-align:right}th.group{text-align:center;border-spacing:1em 0}th.headerlabel{border-bottom:0em none black;padding-bottom:0em}th.intervalGroup{border-bottom:0.1em solid black;text-align:center;font-weight:bold}td.variance:after{content:"%"}td.relative_variance{font-style:italic}td.percent{font-style:italic;text-align:right}td.decimal,td.percentpoint{text-align:right}td.pos_pos{color:#008f96}td.neg_pos{color:#ff0000}td.pos_neg{color:#ff0000}td.neg_neg{color:#008f96}td.pos_pos:before{content:"+"}td.pos_neg:before{content:"+"}td.pos_neu:before{content:"+"}th.ac1,th.ac2,th.ac3,th.ac4{padding-top:0em;border-bottom:0.3em solid black}th.pp1,th.pp2,th.pp3,th.pp4{padding-top:0em;border-bottom:0.3em solid grey}th.pl1,th.pl2,th.pl3,th.pl4{padding-top:0em;border-bottom:0.3em double black}th.fc1,th.fc2,th.fc3,th.fc4{border-bottom:0.3em solid;border-image:repeating-linear-gradient(-45deg, white, white, black, white, white 0.3em) 2}td.colsum{font-weight:bold}th.colsum{padding-top:0em;font-weight:bold}tr.sum td{border-top:0.1em solid black;font-weight:bold;padding-bottom:0.5em}tr.groupheader td{border-top:0em dotted #ddd;padding-top:0.5em;font-weight:bold;font-style:italic}tr.begingroup td{border-top:0em dotted #ddd;padding-top:0.5em}th.begin-group{padding-left:0.75em}th.end-group{padding-left:0.75em}td{box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em dashed #ddd;padding-left:0.5em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.table-footer{font-size:0.6em}.cell-bar-chart{display:inline-block;vertical-align:middle}.bar-chart-empty{color:#999}td:has(.cell-bar-chart){padding:0 0.25em;vertical-align:middle}td:has(.cell-bar-chart).pos_pos:before,td:has(.cell-bar-chart).pos_neg:before,td:has(.cell-bar-chart).pos_neu:before{content:none}td:has(.cell-bar-chart).variance:after{content:none}';const Pd=class{constructor(i){t(this,i),this.businessUnit="",this.order="category",this.orderDirection="asc",this.dateFormat="none",this.dateLink="none",E(this),a(this),this.t=Bt(this).t,this.errors=l(this),this.componentStyle=k(this),this.ruleSetConfig=es(this)}validateScenario(t){const i="WARN_scenarios",s=B(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+(null==s?void 0:s.toString())+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="WARN_variances",s=H(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+(null==s?void 0:s.toString())+"' are not supported."}):this.errors.remove(i)}validateOrder(t){const i=U(t),s="WARN_order";i.length>0?this.errors.addOrReplace({id:s,type:"warning",message:"order: invalid value(s) '"+(null==i?void 0:i.toString())+"' are not supported."}):this.errors.remove(s)}validateOrderDirection(t){const i="WARN_orderDirection";F(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateMeasures(t){const i="WARN_measures",s=Ct(t);s.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"measures: invalid value(s) '"+(null==s?void 0:s.toString())+'\' are not supported. Valid format example: [{"name": "Bruttoumsatz", "unit": "mEUR"}]'}):this.errors.remove(i)}validateDateStart(t){const i="WARN_dateStart";Pt(t)||N(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateStart: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateEnd(t){const i="WARN_dateEnd";Pt(t)||N(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateStart: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateFormat(t){const i="WARN_dateFormat";nt(t)||N(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateFormat: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}validateDateLink(t){const i="WARN_dateLink";Wt(t)||N(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateLink: invalid value '"+(null==t?void 0:t.toString())+"' is not supported."})}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateMeasures(this.measures),this.validateDateStart(this.dateStart),this.validateDateEnd(this.dateEnd),this.validateDateFormat(this.dateFormat),this.validateDateLink(this.dateLink),this.validateOrderDirection(this.orderDirection),this.validateOrder(this.order)}prepareI18n(){const t=p,i=new Map(["SEPARATOR_WS","in","CONNECTOR_WS"].map((t=>[t,this.t(".".concat(t))]))),s=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...s.entries(),...i.entries(),...Ts(this.ruleSetConfig("user"))])}prepareI18nMode(){return _t.META}prepareLocale(){return c(this.element).context.state.locale||"de"}prepareTitleOrder(){var t;return N(this.order)||N(this.orderDirection)?null:{hierarchy:this.order.split(",").map((t=>t.trim())),direction:j[null===(t=this.orderDirection)||void 0===t?void 0:t.toUpperCase()]}}prepareTitleTimePeriod(){var t,i;return N(this.dateStart)&&N(this.dateEnd)||N(this.dateLink)?null:{start:y.fromISO(this.dateStart,{zone:"utc"}),end:y.fromISO(this.dateEnd,{zone:"utc"}),format:ot[null===(t=this.dateFormat)||void 0===t?void 0:t.toUpperCase()],link:Dt[null===(i=this.dateLink)||void 0===i?void 0:i.toUpperCase()]}}prepareMeasures(){if(N(this.measures))return[];try{return JSON.parse(this.measures)}catch(t){return[]}}prepareScenarios(){var t,i,s,e;if(N(this.scenarios)&&N(this.variances))return[];let n=[];return(null===(t=this.scenarios)||void 0===t?void 0:t.trim().length)>0&&(n=n.concat(null===(i=this.scenarios)||void 0===i?void 0:i.split(","))),(null===(s=this.variances)||void 0===s?void 0:s.trim().length)>0&&(n=n.concat(null===(e=this.variances)||void 0===e?void 0:e.split(","))),n.map((t=>t.trim()))}prepareBusinessUnit(){return N(this.businessUnit)||"null"===this.businessUnit?null:this.businessUnit}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles();return i(s,{key:"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 e(this)}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],measures:[{validateMeasures:0}],dateStart:[{validateDateStart:0}],dateEnd:[{validateDateEnd:0}],dateFormat:[{validateDateFormat:0}],dateLink:[{validateDateLink:0}]}}};Pd.style=':host{padding:0.5em;margin-bottom:0.5em;box-sizing:border-box;-webkit-box-sizing:border-box;width:100%;display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}';class Wd{constructor(){}createMeasures(t,i,s){if(this.allMeasuresUseSameUnit(t)){const e=t.length;let n="",r="";for(let o=0;o<e;o++){let h="";o>0&&(h=i.get("SEPARATOR_WS")),e>1&&o===e-1&&(h=i.get("CONNECTOR_WS")),s===_t.ALL?(n=(i.get(n)||n)+h+(i.get(t[o].name)||t[o].name),r=i.get(t[o].unit)||t[o].unit):(n=n+h+t[o].name,r=t[o].unit)}return[{name:n,unit:r}]}return t}createDimension(t,i,s,e,n,r="de"){let o="";if(void 0!==i){const t=new lt;t.setLocale(r),o=t.getDateLinkString(i.start,i.end,i.link,i.format,n)}const h=t.map((t=>{let i="";return null!=s&&null!=s.hierarchy&&s.hierarchy.find((i=>i===t))&&(i=e.get("asc"===s.direction?"ORDER_asc":"ORDER_desc")),"".concat(" ",ra.translateScenarioLabel(t,e),i)})).toString();return o+h}allMeasuresUseSameUnit(t){const i=new Map;return t.forEach((function(t){i.set(t.unit,!0)})),1===i.size}}class Dd{constructor(){this.businessunit="",this.measures=[],this.scenarios=[],this.i18nMode=_t.ALL,this.intervalSpanLimit=32,this.locale="de"}}class zd{constructor(t,i,s,e){this.measureEntryAdapter=t,this.timePeriodAdapter=i,this.orderAdapter=s,this.stringAdapter=e}adapt(t){const i=new Dd;return R.isString(t.businessunit)&&(i.businessunit=t.businessunit),R.isArray(t.measures)&&(i.measures=Z.adaptArray(t.measures,this.measureEntryAdapter)),R.isArray(t.scenarios)&&(i.scenarios=Z.adaptArray(t.scenarios,this.stringAdapter)),R.isExisting(t.timeperiod)&&(i.timeperiod=this.timePeriodAdapter.adapt(t.timeperiod)),R.isNumber(t.intervalSpanLimit)&&(i.intervalSpanLimit=t.intervalSpanLimit),R.isExisting(t.i18nMode)&&(i.i18nMode=t.i18nMode),R.isExisting(t.order)&&(i.order=this.orderAdapter.adapt(t.order)),R.isString(t.locale)&&(i.locale=t.locale),i}default(){return new Dd}}var Ud;!function(t){t[t.UP_TO_DATE=0]="UP_TO_DATE",t[t.DIRTY=1]="DIRTY"}(Ud||(Ud={}));class Fd{constructor(t){this.i18n=new Map,this.unit="",this.measures=[],this.dimension="",this.config=new Dd,this.state=Ud.DIRTY,this.ruleSet=t||new Cs,this.dataSetFactory=new Wd,this.state=Ud.DIRTY,this.setI18n(new Map)}setRuleSet(t){this.ruleSet=t||new Cs}setI18n(t){this.state=Ud.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","❖"],["CONNECTOR_WS"," und "]]);this.i18n=new Map([...i,...t||new Map])}update(){return Ud.DIRTY===this.state&&(this.unit=this.config.businessunit,this.measures=this.dataSetFactory.createMeasures(this.config.measures,this.i18n,this.config.i18nMode),this.dimension=this.dataSetFactory.createDimension(this.config.scenarios,this.config.timeperiod,this.config.order,this.i18n,this.config.intervalSpanLimit,this.config.locale),this.state=Ud.UP_TO_DATE),this}setConfig(t){this.config=this.initConfig(t)}initConfig(t){this.state=Ud.DIRTY;const i=t,s=this;return t.scenarios.sort(((t,i)=>s.ruleSet.getScenarioSorIndex(t)-s.ruleSet.getScenarioSorIndex(i))),i}}class Gd{constructor(t="",i=""){this.name=t,this.unit=i}}class jd{construnctor(){}adapt(t){const i=new Gd;return R.isString(t.name)&&(i.name=t.name),R.isString(t.unit)&&(i.unit=t.unit),i}default(){return new Gd("","")}}class Id{constructor(t=y.now(),i=y.now(),s=ot.AUTO,e=Dt.AUTO){this.start=t,this.end=i,this.format=s,this.link=e}}class Yd{construnctor(){}adapt(t){const i=new Id;return R.isDate(t.start)&&(i.start=t.start),R.isDate(t.end)&&(i.end=t.end),R.isExisting(t.format)&&(i.format=t.format),R.isExisting(t.link)&&(i.link=t.link),i}default(){return new Id}}const Bd=class{constructor(i){t(this,i),this.businessUnit="",this.scenarios=[],this.measures=[],this.intervalSpanLimit=28,this.order={hierarchy:[],direction:j.ASC},this.i18n=new Map,this.i18nMode=_t.ALL,this.locale="de",this.title=new Fd(new Cs),a(this)}render(){return i("div",{key:"ecc33a660538732ceea3e4620afabfcb8ffbce95"},i("div",{key:"cb1c3b074817a4c0647419fdc0f2b94c113ebc09",innerHTML:zt(this.title.unit)}),i("div",{key:"92b6ef66f67d33bd3bff6a760d1fc1bee605105d"},this.title.measures.map(((t,s)=>i("span",null,this.isFirstElement(s)?this.title.i18n.get("SEPARATOR_WS"):"",i("span",{class:"measure"},t.name)," ",t.unit?this.title.i18n.get("in"):""," ",t.unit)))),i("div",{key:"74cc33e0e63592e5422b3c0e5c7a52715210c486"},this.title.dimension))}componentWillLoad(){const t=this.prepareConfig();this.title=new Fd(new Cs(this.ruleSetConfig)),this.title.setI18n(this.i18n),this.title.setConfig(t)}componentWillUpdate(){const t=this.prepareConfig();this.title.setI18n(this.i18n),this.title.setRuleSet(new Cs(this.ruleSetConfig)),this.title.setConfig(t)}componentWillRender(){this.title.update()}isFirstElement(t){return 0!==t}prepareConfig(){return new zd(new jd,new Yd,new tt(new cl),new cl).adapt({businessunit:this.businessUnit,measures:this.measures,scenarios:this.scenarios,timeperiod:this.timeperiod,intervalSpanLimit:this.intervalSpanLimit,i18nMode:this.i18nMode,order:this.order,locale:this.locale})}};Bd.style=':host{display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.measure{font-weight:bold}div{background-color:var(--bn-font-background, white);color:var(--bn-font-color, black)}p{margin:0}';const Hd=["*","/","+","-","x","÷","none"];function Vd(t){switch(t){case"*":case"x":return"×";case"/":case"÷":return"÷";case"+":return"+";case"-":return"−";default:return""}}function Xd(t,i,s){return t.find((t=>t.from===i&&t.to===s))}function Jd(t){return 2*(t-1)+1}function qd(t){return 2*(t-1)+1}function Kd(t){return t<=1?1:2*(t-1)+1}function Qd(t,i){const s=t.getBoundingClientRect(),e=s.left-i.left,n=s.top-i.top;return{left:e,top:n,width:s.width,height:s.height,centerX:e+s.width/2,centerY:n+s.height/2}}function Zd(t,i,s){switch(s){case"ltr":return i?{x:t.left+t.width,y:t.centerY}:{x:t.left,y:t.centerY};case"rtl":return i?{x:t.left,y:t.centerY}:{x:t.left+t.width,y:t.centerY};case"ttb":return i?{x:t.centerX,y:t.top+t.height}:{x:t.centerX,y:t.top};case"btt":return i?{x:t.centerX,y:t.top}:{x:t.centerX,y:t.top+t.height}}}function tf(t,i,s,e,n=8){const r=-(e-1)*n/2+s*n;switch(i){case"ltr":return{x:t.left,y:t.centerY+r};case"rtl":return{x:t.left+t.width,y:t.centerY+r};case"ttb":return{x:t.centerX+r,y:t.top};case"btt":return{x:t.centerX+r,y:t.top+t.height}}}function sf(t,i,s,e,n){switch(s){case"straight":return function(t,i){return{path:`M ${t.x} ${t.y} L ${i.x} ${i.y}`,midpoint:{x:(t.x+i.x)/2,y:(t.y+i.y)/2}}}(t,i);case"curved":return function(t,i,s){let e,n;if("ltr"===s||"rtl"===s){const s=(t.x+i.x)/2;e={x:s,y:t.y},n={x:s,y:i.y}}else{const s=(t.y+i.y)/2;e={x:t.x,y:s},n={x:i.x,y:s}}return{path:`M ${t.x} ${t.y} C ${e.x} ${e.y}, ${n.x} ${n.y}, ${i.x} ${i.y}`,midpoint:{x:.125*t.x+.375*e.x+.375*n.x+.125*i.x,y:.125*t.y+.375*e.y+.375*n.y+.125*i.y}}}(t,i,e);default:return function(t,i,s,e){let n,r;if("ltr"===s||"rtl"===s){const s=null!=e?e:t.x+.7*(i.x-t.x);n=`M ${t.x} ${t.y} L ${s} ${t.y} L ${s} ${i.y} L ${i.x} ${i.y}`,r={x:s,y:(t.y+i.y)/2}}else{const s=null!=e?e:t.y+.7*(i.y-t.y);n=`M ${t.x} ${t.y} L ${t.x} ${s} L ${i.x} ${s} L ${i.x} ${i.y}`,r={x:(t.x+i.x)/2,y:s}}return{path:n,midpoint:r}}(t,i,e,n)}}function ef(t,i,s){let e,n,r;switch(s){case"ltr":e=t.left+t.width,n=i.map((t=>t.left)),r=1;break;case"rtl":e=t.left,n=i.map((t=>t.left+t.width)),r=-1;break;case"ttb":e=t.top+t.height,n=i.map((t=>t.top)),r=1;break;case"btt":e=t.top,n=i.map((t=>t.top+t.height)),r=-1}const o=n.map((t=>(t-e)*r)).filter((t=>t>=0));if(0!==o.length)return e+Math.min(...o)*r*.7}function nf(t,i,s,e){return"ltr"===e||"rtl"===e?{x:t,y:(i.centerY+s.centerY)/2}:{x:(i.centerX+s.centerX)/2,y:t}}function rf(t,i,s){var e,n;return Object.assign({stroke:null!==(e=null==s?void 0:s.color)&&void 0!==e?e:t,strokeWidth:null!==(n=null==s?void 0:s.width)&&void 0!==n?n:i},(null==s?void 0:s.dasharray)?{strokeDasharray:s.dasharray}:{})}const of=class{validateEdgesProp(t){const i="ERR_edges",s=function(t){const i=[];if(!t||""===t.trim())return i.push("edges: value is required"),i;let s;try{s=JSON.parse(t)}catch(t){return i.push("edges: invalid JSON structure"),i}if(!Array.isArray(s))return i.push("edges: must be an array"),i;if(0===s.length)return i.push("edges: array must not be empty"),i;const e=new Set,n=new Set,r=new Map;s.forEach(((t,s)=>{if("object"!=typeof t||null===t)return void i.push(`edges[${s}]: must be an object`);const o=t;if("string"!=typeof o.from||""===o.from.trim()?i.push(`edges[${s}]: 'from' is required and must be a non-empty string`):e.add(o.from),"string"!=typeof o.to||""===o.to.trim()?i.push(`edges[${s}]: 'to' is required and must be a non-empty string`):(e.add(o.to),n.add(o.to),"string"==typeof o.from&&r.set(o.from,[...r.get(o.from)||[],o.to])),void 0!==o.operator&&("string"==typeof o.operator&&Hd.includes(o.operator)||i.push(`edges[${s}]: 'operator' must be one of: ${Hd.join(", ")}`)),void 0!==o.label&&"string"!=typeof o.label&&i.push(`edges[${s}]: 'label' must be a string`),void 0!==o.style)if("object"!=typeof o.style||null===o.style)i.push(`edges[${s}]: 'style' must be an object`);else{const t=o.style;void 0!==t.color&&"string"!=typeof t.color&&i.push(`edges[${s}]: 'style.color' must be a string`),void 0!==t.width&&"number"!=typeof t.width&&i.push(`edges[${s}]: 'style.width' must be a number`),void 0!==t.dasharray&&"string"!=typeof t.dasharray&&i.push(`edges[${s}]: 'style.dasharray' must be a string`)}}));const o=Array.from(e).filter((t=>!n.has(t)));return 0===o.length?i.push("edges: tree has no root node (circular reference detected)"):o.length>1?i.push(`edges: tree has multiple root nodes: ${o.join(", ")}`):i.push(...function(t,i,s){const e=[],n=new Set,r=new Set,o=t=>{r.add(t),n.add(t);for(const s of i.get(t)||[])n.has(s)?e.push(`edges: circular reference, the edge from '${t}' to '${s}' leads back`):r.has(s)||o(s);n.delete(t)};o(t);const h=Array.from(s).filter((t=>!r.has(t)));return h.length>0&&e.push(`edges: nodes not connected to the root '${t}': ${h.join(", ")}`),e}(o[0],r,e)),i}(t);s.length>0?(this.errors.addOrReplace({id:i,type:"error",message:`edges: ${s.join("; ")}`}),this.treeConfig=null):(this.errors.remove(i),this.treeConfig=function(t){if(!t||""===t.trim())return null;try{const i=JSON.parse(t);if(!Array.isArray(i))return null;const s=i,e=function(t){const i=new Map;for(const s of t){const t=i.get(s.from)||[];t.push(s.to),i.set(s.from,t)}return i}(s),n=function(t){const i=new Set;for(const s of t)i.add(s.from),i.add(s.to);return i}(s),r=function(t,i){const s=new Set;for(const i of t)s.add(i.to);const e=Array.from(i).filter((t=>!s.has(t)));return 1===e.length?e[0]:null}(s,n);return{edges:s,adjacencyList:e,rootNode:r,allNodes:n}}catch(t){return console.error("parseTreeConfig: failed to parse tree configuration",t),null}}(t)),this.recalculateLayout()}validateDirection(t){const i="WARN_direction",s=["ltr","rtl","ttb","btt"];s.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`direction: invalid value '${t}', must be one of: ${s.join(", ")}`}),this.recalculateLayout()}validateLevelSpacing(t){const i="WARN_levelSpacing";!et(t)||t<0?this.errors.addOrReplace({id:i,type:"warning",message:`level-spacing: invalid value '${t}', must be a non-negative number`}):this.errors.remove(i),this.recalculateLayout()}validateNodeSpacing(t){const i="WARN_nodeSpacing";!et(t)||t<0?this.errors.addOrReplace({id:i,type:"warning",message:`node-spacing: invalid value '${t}', must be a non-negative number`}):this.errors.remove(i),this.recalculateLayout()}validateEdgeStyle(t){const i="WARN_edgeStyle",s=["straight","orthogonal","curved"];s.includes(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:`edge-style: invalid value '${t}', must be one of: ${s.join(", ")}`})}constructor(i){t(this,i),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,E(this),a(this),this.errors=l(this),this.componentStyle=k(this)}async getLayoutState(t){var i,s,e,n,r,o,h,a,l,c,u;const d=null!==(i=null==t?void 0:t.detail)&&void 0!==i?i:"summary",f=ei(this.element),v=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333})),p={version:li,tag:this.element.localName,id:ii(this.element),slot:null!==(s=this.element.getAttribute("slot"))&&void 0!==s?s:void 0,rect:ti(this.element,f),em:{fontSizePx:v,appliedScaleFactor:1},regions:[],metadata:{nodeCount:null!==(n=null===(e=this.treeConfig)||void 0===e?void 0:e.allNodes.size)&&void 0!==n?n:0,edgeCount:null!==(o=null===(r=this.treeConfig)||void 0===r?void 0:r.edges.length)&&void 0!==o?o:0},diagnostics:Zt(this.element)},g=null===(h=this.element.shadowRoot)||void 0===h?void 0:h.querySelector(".tree-grid");if(g&&p.regions.push({id:"grid",rect:ti(g,f)}),"full"!==d||!this.treeConfig)return p;const m=[];for(const t of this.treeConfig.allNodes){const i=this.element.querySelector(`[slot="${t}"]`);if(!i)continue;const s={kind:"node",nodeId:t,rect:ti(i,f)};m.push(s)}const b=Array.from(null!==(l=null===(a=this.element.shadowRoot)||void 0===a?void 0:a.querySelectorAll("svg.edge-layer path"))&&void 0!==l?l:[]);let y=0;for(const t of this.treeConfig.edges){if(!this.nodeRects.get(t.from)||!this.nodeRects.get(t.to))continue;const i=b[y++];if(!i)break;const s={kind:"edge",from:t.from,to:t.to,operator:t.operator,path:null!==(c=i.getAttribute("d"))&&void 0!==c?c:void 0,rect:ti(i,f)};m.push(s)}return null===(u=this.element.shadowRoot)||void 0===u||u.querySelectorAll("svg.edge-layer g.operator-group").forEach((t=>{var i,s;const e=null!==(s=null===(i=t.textContent)||void 0===i?void 0:i.trim())&&void 0!==s?s:"";if(!e)return;const n={kind:"label",role:"operator",text:e,rect:ti(t,f)};m.push(n)})),p.elements=m,p}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,i,s;const e=null!==(i=null===(t=this.element.shadowRoot)||void 0===t?void 0:t.querySelector(".tree-grid"))&&void 0!==i?i:null;if(e!==this.gridContainer&&(null===(s=this.resizeObserver)||void 0===s||s.disconnect(),this.observed.clear(),this.gridContainer=e),e){this.resizeObserver||(this.resizeObserver=new ResizeObserver((()=>{this.updateNodeRects()}))),this.parentObserver||(this.parentObserver=ss(this.element,(()=>this.checkOverflow())));for(const t of[e,...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,i,s,e){if(!t.rootNode)return{positions:new Map,gridTemplateColumns:"",gridTemplateRows:"",maxLevel:0,maxIndex:0};const n=function(t){const i=new Map;if(!t.rootNode)return i;const s=[{node:t.rootNode,level:0}],e=new Set;for(;s.length>0;){const{node:n,level:r}=s.shift();if(e.has(n))continue;e.add(n),i.set(n,r);const o=t.adjacencyList.get(n)||[];for(const t of o)e.has(t)||s.push({node:t,level:r+1})}return i}(t),r=function(t){const i=new Map;if(!t.rootNode)return i;let s=0;return function e(n){const r=i.get(n);if(r)return r;const o=t.adjacencyList.get(n)||[];if(i.set(n,{startIndex:s,endIndex:s}),0===o.length){const t={startIndex:s,endIndex:s};return i.set(n,t),s++,t}let h=1/0,a=-1/0;for(const t of o){const i=e(t);h=Math.min(h,i.startIndex),a=Math.max(a,i.endIndex)}const l={startIndex:h,endIndex:a};return i.set(n,l),l}(t.rootNode),i}(t),o=function(t,i,s,e){var n,r;const o=new Map,h=Math.max(...Array.from(i.values()));for(const a of t.allNodes){const l=null!==(n=i.get(a))&&void 0!==n?n:0,c=null!==(r=s.get(a))&&void 0!==r?r:{startIndex:0,endIndex:0};let u,d,f=1,v=1;const p=c.endIndex-c.startIndex+1,g=Array.from(t.allNodes).some((t=>{var e;const n=s.get(t);return t!==a&&void 0!==n&&(null!==(e=i.get(t))&&void 0!==e?e:0)===l&&n.startIndex<=c.endIndex&&c.startIndex<=n.endIndex})),m=g?1:p;switch(e){case"ltr":u=l+1,d=c.startIndex+1,f=p;break;case"rtl":u=h-l+1,d=c.startIndex+1,f=p;break;case"ttb":d=l+1,u=c.startIndex+1,v=m;break;case"btt":d=h-l+1,u=c.startIndex+1,v=m}o.set(a,{nodeId:a,level:l,index:c.startIndex,gridColumn:u,gridRow:d,gridRowSpan:f,gridColumnSpan:v})}return o}(t,n,r,i),h=Math.max(...Array.from(n.values())),a=Math.max(...Array.from(r.values()).map((t=>t.endIndex))),{gridTemplateColumns:l,gridTemplateRows:c}=function(t,i,s,e,n){const r=t+1,o=i+1;if("ltr"===s||"rtl"===s){const t=[];for(let i=0;i<r;i++)t.push("auto"),i<r-1&&t.push(`${e}px`);const i=[];for(let t=0;t<o;t++)i.push("auto"),t<o-1&&i.push(`${n}px`);return{gridTemplateColumns:t.join(" "),gridTemplateRows:i.join(" ")}}{const t=[];for(let i=0;i<r;i++)t.push("auto"),i<r-1&&t.push(`${e}px`);const i=[];for(let t=0;t<o;t++)i.push("auto"),t<o-1&&i.push(`${n}px`);return{gridTemplateColumns:i.join(" "),gridTemplateRows:t.join(" ")}}}(h,a,i,s,e);return{positions:o,gridTemplateColumns:l,gridTemplateRows:c,maxLevel:h,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 i=this.gridContainer.getBoundingClientRect(),s=new Map;for(const t of this.treeConfig.allNodes){const e=this.element.querySelector(`[slot="${t}"]`);e&&s.set(t,Qd(e,i))}(function(t,i){if(t.size!==i.size)return!1;for(const[s,e]of t){const t=i.get(s);if(!t||t.left!==e.left||t.top!==e.top||t.width!==e.width||t.height!==e.height)return!1}return!0})(this.nodeRects,s)||(this.nodeRects=s),this.svgWidth=i.width,this.svgHeight=i.height,this.checkOverflow()}checkOverflow(){var t,i;const s="WARN_overflow",e=Ut(this.element),n=(null===(t=this.gridContainer)||void 0===t?void 0:t.scrollWidth)||0,r=(null===(i=this.gridContainer)||void 0===i?void 0:i.scrollHeight)||0,o=[];e.width>0&&n>e.width+1&&o.push(`width (${Math.round(n)}px > ${Math.round(e.width)}px)`);const h=Ft(this.element,r);h>1&&o.push(`height (${Math.round(r)}px > ${Math.round(r-h)}px)`),0!==o.length?this.errors.addOrReplace({id:s,type:"warning",message:`Tree exceeds available ${o.join(" and ")} and will be cut off. Reduce level-spacing, node-spacing or the node content, or enlarge the container.`}):this.errors.remove(s)}getSlotStyle(t){if(!this.layout)return{};const i=this.layout.positions.get(t);return i?"ltr"===this.direction||"rtl"===this.direction?{"grid-column":String(Jd(i.gridColumn)),"grid-row":`${qd(i.gridRow)} / span ${Kd(i.gridRowSpan)}`,"align-self":"center"}:{"grid-row":String(qd(i.gridRow)),"grid-column":`${Jd(i.gridColumn)} / span ${s=i.gridColumnSpan,Kd(s)}`,"justify-self":"center"}:{};var s}renderEdges(){var t;if(!this.treeConfig||0===this.nodeRects.size)return null;const s=this.getTreeStyle(),e=[],n=[],r=new Map;for(const t of this.treeConfig.edges){const i=r.get(t.to)||[];i.push(t.from),r.set(t.to,i)}const o=new Map;for(const[t,i]of this.treeConfig.adjacencyList.entries()){const s=this.nodeRects.get(t),e=i.map((t=>this.nodeRects.get(t))).filter((t=>void 0!==t)),n=s?ef(s,e,this.direction):void 0;void 0!==n&&o.set(t,n)}for(const t of this.treeConfig.edges){const n=this.nodeRects.get(t.from),h=this.nodeRects.get(t.to);if(!n||!h)continue;const a=Zd(n,!0,this.direction),l=r.get(t.to)||[];let c;if(l.length>1){const i=l.indexOf(t.from);c=tf(h,this.direction,i,l.length)}else c=Zd(h,!1,this.direction);const{path:u}=sf(a,c,this.edgeStyle,this.direction,o.get(t.from)),d=rf(s.edgeColor,s.edgeWidth,t.style);e.push(i("path",{key:`edge-${t.from}-${t.to}`,d:u,fill:"none",stroke:d.stroke,"stroke-width":d.strokeWidth,"stroke-dasharray":d.strokeDasharray}))}if(this.showOperators)for(const[e,r]of this.treeConfig.adjacencyList.entries()){const h=o.get(e);if(void 0!==h)for(let o=0;o<r.length-1;o++){const a=r[o],l=r[o+1],c=Xd(this.treeConfig.edges,e,a);if(!(null==c?void 0:c.operator)||"none"===c.operator)continue;const u=this.nodeRects.get(a),d=this.nodeRects.get(l);if(!u||!d)continue;const f=null!==(t=c.label)&&void 0!==t?t:Vd(c.operator),v=nf(h,u,d,this.direction);n.push(i("g",{key:`operator-${e}-${a}`,class:"operator-group"},i("circle",{cx:v.x,cy:v.y,r:s.operatorCircleRadius,fill:"white",stroke:s.edgeColor,"stroke-width":s.edgeWidth}),i("text",{x:v.x,y:v.y,"text-anchor":"middle","dominant-baseline":"central",style:{fontSize:`${s.operatorFontSize}px`,fill:s.operatorColor,fontWeight:"bold"}},f)))}}return i("svg",{class:"edge-layer",width:this.svgWidth,height:this.svgHeight,style:{position:"absolute",top:"0",left:"0",pointerEvents:"none"}},e,n)}renderSlots(){return this.treeConfig&&this.layout?Array.from(this.treeConfig.allNodes).map((t=>i("div",{key:t,class:"tree-node",style:this.getSlotStyle(t)},i("slot",{name:t})))):null}getFontStyles(){return this.componentStyle((t=>{var i,s,e,n;return{"--bn-font-family":(null===(i=t.global)||void 0===i?void 0:i.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":`${(null===(s=t.global)||void 0===s?void 0:s.fontSizePx)||13.3333}px`,"--bn-font-color":(null===(e=t.global)||void 0===e?void 0:e.fontColor)||"#000000","--bn-font-background":(null===(n=t.global)||void 0===n?void 0:n.fontBackgroundColor)||"#ffffff"}}))}render(){const t=this.getFontStyles();return i(s,{style:t},this.treeConfig&&this.layout?i("div",{class:"tree-container"},i("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())):i("div",{class:"tree-container tree-error"},i("slot",null)))}get element(){return e(this)}static get watchers(){return{edges:[{validateEdgesProp:0}],direction:[{validateDirection:0}],levelSpacing:[{validateLevelSpacing:0}],nodeSpacing:[{validateNodeSpacing:0}],edgeStyle:[{validateEdgeStyle:0}]}}};of.style=':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}';export{Ri as bn_annotation_layer,Ni as bn_annotation_list,Li as bn_asset,Ei as bn_body,Ti as bn_card,Os as bn_chart_bubble,Na as bn_chart_bubble_renderer,Ua as bn_chart_bullet,Xa as bn_chart_bullet_renderer,qa as bn_chart_scatter,tl as bn_chart_scatter_renderer,il as bn_chart_structure,Fl as bn_chart_structure_renderer,Gl as bn_chart_time,xc as bn_chart_time_renderer,Sc as bn_component_style,Lc as bn_context,uu as bn_dataset,du as bn_datasource,fu as bn_footer,$u as bn_layout_card,Mu as bn_layout_page,_u as bn_message,Ou as bn_page,ku as bn_scaling_group,Uu as bn_table,Ed as bn_table_renderer,Pd as bn_title,Bd as bn_title_renderer,of as bn_tree}